From 8d86f6077f32190e6d4ed244b792ee745b2e6ca2 Mon Sep 17 00:00:00 2001 From: IAmKirbki Date: Wed, 18 Feb 2026 10:41:11 +0100 Subject: [PATCH 001/230] chore: remove unused GitHub Actions workflow for documentation --- .github/workflows/docs.yml | 65 -------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 .github/workflows/docs.yml diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 3e5c6640..00000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,65 +0,0 @@ -# Workflow disabled - blog is unused atm -# name: Docs -# -# on: -# push: -# branches: -# - main -# -# permissions: -# contents: read -# pages: write -# id-token: write -# -# concurrency: -# group: "pages" -# cancel-in-progress: true -# -# jobs: -# build: -# name: Build for GitHub Pages -# runs-on: ubuntu-latest -# defaults: -# run: -# working-directory: ./docs -# steps: -# - uses: actions/checkout@v5 -# - uses: pnpm/action-setup@v4 -# with: -# version: ${{ vars.PNPM_VERSION }} -# - name: Set-up Node -# uses: actions/setup-node@v5 -# with: -# node-version: ${{ vars.NODEJS_VERSION }} -# cache: 'pnpm' -# - name: Install Dependencies -# run: pnpm install - - # - name: Setup Pages - # uses: actions/configure-pages@v3 - # - uses: actions/setup-node@v3 - # with: - # node-version: 18 - # cache: npm - # - name: Install dependencies - # run: npm ci - # - name: Build website - # run: npm run build - # - name: List files - # run: ls - # - name: Upload artifact - # uses: actions/upload-pages-artifact@v3 - # with: - # path: docs/build - - # deploy: - # name: Deploy to GitHub Pages - # environment: - # name: github-pages - # url: ${{ steps.deployment.outputs.page_url }} - # runs-on: ubuntu-latest - # needs: build - # steps: - # - name: Deploy to GitHub Pages - # id: deployment - # uses: actions/deploy-pages@v4 \ No newline at end of file From 15edf75f58a92a069a8a634ad3685f71684e5f4e Mon Sep 17 00:00:00 2001 From: IAmKirbki Date: Wed, 18 Feb 2026 15:14:54 +0100 Subject: [PATCH 002/230] Feat: Added an endpoint to run a journey for a specific user --- .../controllers/v1/management/controller.go | 2 +- .../controllers/v1/management/journeys.go | 104 ++++++++- .../v1/management/journeys_test.go | 10 +- .../v1/management/oapi/resources.yml | 47 ++++ .../v1/management/oapi/resources_gen.go | 217 ++++++++++++++++++ internal/store/users/events.go | 30 +++ internal/wasm/test/provider.wasm | Bin 505929 -> 508361 bytes 7 files changed, 403 insertions(+), 7 deletions(-) diff --git a/internal/http/controllers/v1/management/controller.go b/internal/http/controllers/v1/management/controller.go index 4f619a93..d10c7064 100644 --- a/internal/http/controllers/v1/management/controller.go +++ b/internal/http/controllers/v1/management/controller.go @@ -19,7 +19,7 @@ func NewController(logger *zap.Logger, db *sqlx.DB, cfg config.Node, storage sto EventsController: NewEventsController(logger, db), TagsController: NewTagsController(logger, db), LocalesController: NewLocalesController(logger, db), - JourneysController: NewJourneysController(logger, db), + JourneysController: NewJourneysController(logger, db, pub), OrganizationsController: NewOrganizationsController(logger, db), ListsController: NewListsController(logger, db, pub, cfg.Storage.MaxUploadSize), DocumentsController: NewDocumentsController(logger, db, storage, cfg.Storage.MaxUploadSize), diff --git a/internal/http/controllers/v1/management/journeys.go b/internal/http/controllers/v1/management/journeys.go index 1e478d10..0468c272 100644 --- a/internal/http/controllers/v1/management/journeys.go +++ b/internal/http/controllers/v1/management/journeys.go @@ -10,6 +10,9 @@ import ( "github.com/lunogram/platform/internal/http/controllers/v1/management/oapi" "github.com/lunogram/platform/internal/http/json" "github.com/lunogram/platform/internal/http/problem" + "github.com/lunogram/platform/internal/pubsub" + "github.com/lunogram/platform/internal/pubsub/consumer" + "github.com/lunogram/platform/internal/pubsub/schemas" "github.com/lunogram/platform/internal/store" "github.com/lunogram/platform/internal/store/journey" "github.com/lunogram/platform/internal/store/management" @@ -17,13 +20,14 @@ import ( "go.uber.org/zap" ) -func NewJourneysController(logger *zap.Logger, db *sqlx.DB) *JourneysController { +func NewJourneysController(logger *zap.Logger, db *sqlx.DB, pub pubsub.Publisher) *JourneysController { return &JourneysController{ logger: logger, db: db, mgmt: management.NewState(db), users: users.NewState(db), jrny: journey.NewState(db), + pub: pub, } } @@ -33,6 +37,7 @@ type JourneysController struct { mgmt *management.State users *users.State jrny *journey.State + pub pubsub.Publisher } func (srv *JourneysController) ListJourneys(w http.ResponseWriter, r *http.Request, projectID uuid.UUID, params oapi.ListJourneysParams) { @@ -308,6 +313,103 @@ func (srv *JourneysController) DeleteJourney(w http.ResponseWriter, r *http.Requ w.WriteHeader(http.StatusNoContent) } +func (srv *JourneysController) RunJourneyForUser(w http.ResponseWriter, r *http.Request, projectID, journeyID uuid.UUID) { + ctx := r.Context() + + body := oapi.RunJourneyForUserJSONRequestBody{} + err := json.Decode(r.Body, &body) + if err != nil { + oapi.WriteProblem(w, err) + return + } + + userIDStr := body.UserID + journeyEntryIDStr := body.JourneyEntryID + + logger := srv.logger.With( + zap.Stringer("project_id", projectID), + zap.Stringer("journey_id", journeyID), + zap.String("user_id", userIDStr), + zap.String("journey_entry_id", journeyEntryIDStr), + ) + + logger.Info("running journey for user") + + journeys := journey.NewJourneysStore(srv.db) + + currJourney, err := journeys.GetJourney(ctx, projectID, journeyID) + if errors.Is(err, sql.ErrNoRows) { + logger.Info("journey not found") + oapi.WriteProblem(w, problem.ErrNotFound(problem.Describe("journey not found"))) + return + } + + if err != nil { + logger.Error("failed to get journey", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + userID, err := uuid.Parse(userIDStr) + if err != nil { + logger.Error("invalid user_id format", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrBadRequest(problem.Describe("invalid user_id format"))) + return + } + + journeyEntryID, err := uuid.Parse(journeyEntryIDStr) + if err != nil { + logger.Error("invalid journey_entry_id format", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrBadRequest(problem.Describe("invalid journey_entry_id format"))) + return + } + + stepId, err := journeys.CreateUserJourneyState(ctx, journey.JourneyUserState{ + UserID: userID, + JourneyID: journeyID, + JourneyEntryID: journeyEntryID, + PinnedVersionID: currJourney.VersionID, + }) + if err != nil { + logger.Error("failed to create user journey state", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + if currJourney.VersionID == nil { + logger.Info("no published version for journey, returning error") + oapi.WriteProblem(w, problem.ErrBadRequest(problem.Describe("journey has no published version"))) + return + } + + step, err := srv.users.GetEventJourneyStep(ctx, stepId, *currJourney.VersionID) + if err != nil { + logger.Error("failed to get event journey step dependencies", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + for _, child := range step.Children { + step := consumer.JourneyStep{ + ProjectID: currJourney.ProjectID, + JourneyID: step.JourneyID, + JourneyEntryID: journeyEntryID, + ExternalStepID: child.ChildExternalID, + UserID: userID, + } + + err = srv.pub.Publish(ctx, schemas.JourneysAdvance(currJourney.ProjectID, step.JourneyID), step) + if err != nil { + logger.Error("failed to publish journey state to project subject", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + } + + logger.Info("journey run for user") + json.Write(w, http.StatusOK, "Journey run successfully for user") +} + func (srv *JourneysController) GetJourneySteps(w http.ResponseWriter, r *http.Request, projectID, journeyID uuid.UUID) { ctx := r.Context() diff --git a/internal/http/controllers/v1/management/journeys_test.go b/internal/http/controllers/v1/management/journeys_test.go index 337dfe92..164d4e16 100644 --- a/internal/http/controllers/v1/management/journeys_test.go +++ b/internal/http/controllers/v1/management/journeys_test.go @@ -35,7 +35,7 @@ func TestCreateJourney(t *testing.T) { projectID, err := projects.CreateProject(ctx, DefaultProject) require.NoError(t, err) - journeys := NewJourneysController(logger, db) + journeys := NewJourneysController(logger, db, nil) type test struct { body oapi.CreateJourneyJSONRequestBody @@ -115,7 +115,7 @@ func TestListJourneys(t *testing.T) { require.NoError(t, err) } - journeys := NewJourneysController(logger, db) + journeys := NewJourneysController(logger, db, nil) type test struct { limit int @@ -205,7 +205,7 @@ func TestGetJourney(t *testing.T) { }) require.NoError(t, err) - journeys := NewJourneysController(logger, db) + journeys := NewJourneysController(logger, db, nil) type test struct { journeyID uuid.UUID @@ -270,7 +270,7 @@ func TestUpdateJourney(t *testing.T) { }) require.NoError(t, err) - journeys := NewJourneysController(logger, db) + journeys := NewJourneysController(logger, db, nil) type test struct { body oapi.UpdateJourneyJSONRequestBody @@ -357,7 +357,7 @@ func TestDeleteJourney(t *testing.T) { }) require.NoError(t, err) - journeys := NewJourneysController(logger, db) + journeys := NewJourneysController(logger, db, nil) type test struct { journeyID uuid.UUID diff --git a/internal/http/controllers/v1/management/oapi/resources.yml b/internal/http/controllers/v1/management/oapi/resources.yml index 297be02b..14c51000 100644 --- a/internal/http/controllers/v1/management/oapi/resources.yml +++ b/internal/http/controllers/v1/management/oapi/resources.yml @@ -1028,6 +1028,53 @@ paths: description: Journey deleted successfully default: $ref: "#/components/responses/Error" + + /api/admin/projects/{projectID}/journeys/{journeyID}/users: + post: + summary: Manually runs a journey for a user + description: Triggers a journey to run for a specific user, typically used for testing or manual overrides + operationId: runJourneyForUser + tags: + - Journeys + security: + - HttpBearerAuth: [] + parameters: + - name: projectID + in: path + required: true + schema: + type: string + format: uuid + description: The project ID + - name: journeyID + in: path + required: true + schema: + type: string + format: uuid + description: The journey ID + requestBody: + required: true + content: + application/json: + schema: + type: object + required: + - userID + - journeyEntryID + properties: + userID: + type: string + description: The ID of the user to run the journey for + journeyEntryID: + type: string + description: The ID of the journey entry to run + responses: + "200": + description: Journey run successfully for user + default: + $ref: "#/components/responses/Error" + /api/admin/projects/{projectID}/journeys/{journeyID}/steps: get: diff --git a/internal/http/controllers/v1/management/oapi/resources_gen.go b/internal/http/controllers/v1/management/oapi/resources_gen.go index a63b7e63..4a0faede 100644 --- a/internal/http/controllers/v1/management/oapi/resources_gen.go +++ b/internal/http/controllers/v1/management/oapi/resources_gen.go @@ -1156,6 +1156,15 @@ type ListJourneysParams struct { Offset *Offset `form:"offset,omitempty" json:"offset,omitempty"` } +// RunJourneyForUserJSONBody defines parameters for RunJourneyForUser. +type RunJourneyForUserJSONBody struct { + // JourneyEntryID The ID of the journey entry to run + JourneyEntryID string `json:"journeyEntryID"` + + // UserID The ID of the user to run the journey for + UserID string `json:"userID"` +} + // ListApiKeysParams defines parameters for ListApiKeys. type ListApiKeysParams struct { // Limit Maximum number of items to return @@ -1321,6 +1330,9 @@ type UpdateJourneyJSONRequestBody = UpdateJourney // SetJourneyStepsJSONRequestBody defines body for SetJourneySteps for application/json ContentType. type SetJourneyStepsJSONRequestBody = JourneyStepMap +// RunJourneyForUserJSONRequestBody defines body for RunJourneyForUser for application/json ContentType. +type RunJourneyForUserJSONRequestBody RunJourneyForUserJSONBody + // CreateApiKeyJSONRequestBody defines body for CreateApiKey for application/json ContentType. type CreateApiKeyJSONRequestBody = CreateApiKey @@ -1786,6 +1798,11 @@ type ClientInterface interface { SetJourneySteps(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, body SetJourneyStepsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // RunJourneyForUserWithBody request with any body + RunJourneyForUserWithBody(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + RunJourneyForUser(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, body RunJourneyForUserJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // VersionJourney request VersionJourney(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -2657,6 +2674,30 @@ func (c *Client) SetJourneySteps(ctx context.Context, projectID openapi_types.UU return c.Client.Do(req) } +func (c *Client) RunJourneyForUserWithBody(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRunJourneyForUserRequestWithBody(c.Server, projectID, journeyID, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) RunJourneyForUser(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, body RunJourneyForUserJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRunJourneyForUserRequest(c.Server, projectID, journeyID, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) VersionJourney(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewVersionJourneyRequest(c.Server, projectID, journeyID) if err != nil { @@ -5533,6 +5574,60 @@ func NewSetJourneyStepsRequestWithBody(server string, projectID openapi_types.UU return req, nil } +// NewRunJourneyForUserRequest calls the generic RunJourneyForUser builder with application/json body +func NewRunJourneyForUserRequest(server string, projectID openapi_types.UUID, journeyID openapi_types.UUID, body RunJourneyForUserJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewRunJourneyForUserRequestWithBody(server, projectID, journeyID, "application/json", bodyReader) +} + +// NewRunJourneyForUserRequestWithBody generates requests for RunJourneyForUser with any type of body +func NewRunJourneyForUserRequestWithBody(server string, projectID openapi_types.UUID, journeyID openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectID", runtime.ParamLocationPath, projectID) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "journeyID", runtime.ParamLocationPath, journeyID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/admin/projects/%s/journeys/%s/users", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + // NewVersionJourneyRequest generates requests for VersionJourney func NewVersionJourneyRequest(server string, projectID openapi_types.UUID, journeyID openapi_types.UUID) (*http.Request, error) { var err error @@ -8242,6 +8337,11 @@ type ClientWithResponsesInterface interface { SetJourneyStepsWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, body SetJourneyStepsJSONRequestBody, reqEditors ...RequestEditorFn) (*SetJourneyStepsResponse, error) + // RunJourneyForUserWithBodyWithResponse request with any body + RunJourneyForUserWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RunJourneyForUserResponse, error) + + RunJourneyForUserWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, body RunJourneyForUserJSONRequestBody, reqEditors ...RequestEditorFn) (*RunJourneyForUserResponse, error) + // VersionJourneyWithResponse request VersionJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*VersionJourneyResponse, error) @@ -9456,6 +9556,28 @@ func (r SetJourneyStepsResponse) StatusCode() int { return 0 } +type RunJourneyForUserResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *Error +} + +// Status returns HTTPResponse.Status +func (r RunJourneyForUserResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r RunJourneyForUserResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type VersionJourneyResponse struct { Body []byte HTTPResponse *http.Response @@ -11071,6 +11193,23 @@ func (c *ClientWithResponses) SetJourneyStepsWithResponse(ctx context.Context, p return ParseSetJourneyStepsResponse(rsp) } +// RunJourneyForUserWithBodyWithResponse request with arbitrary body returning *RunJourneyForUserResponse +func (c *ClientWithResponses) RunJourneyForUserWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RunJourneyForUserResponse, error) { + rsp, err := c.RunJourneyForUserWithBody(ctx, projectID, journeyID, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRunJourneyForUserResponse(rsp) +} + +func (c *ClientWithResponses) RunJourneyForUserWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, body RunJourneyForUserJSONRequestBody, reqEditors ...RequestEditorFn) (*RunJourneyForUserResponse, error) { + rsp, err := c.RunJourneyForUser(ctx, projectID, journeyID, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRunJourneyForUserResponse(rsp) +} + // VersionJourneyWithResponse request returning *VersionJourneyResponse func (c *ClientWithResponses) VersionJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*VersionJourneyResponse, error) { rsp, err := c.VersionJourney(ctx, projectID, journeyID, reqEditors...) @@ -13064,6 +13203,32 @@ func ParseSetJourneyStepsResponse(rsp *http.Response) (*SetJourneyStepsResponse, return response, nil } +// ParseRunJourneyForUserResponse parses an HTTP response from a RunJourneyForUserWithResponse call +func ParseRunJourneyForUserResponse(rsp *http.Response) (*RunJourneyForUserResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RunJourneyForUserResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + // ParseVersionJourneyResponse parses an HTTP response from a VersionJourneyWithResponse call func ParseVersionJourneyResponse(rsp *http.Response) (*VersionJourneyResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -14727,6 +14892,9 @@ type ServerInterface interface { // Set journey steps // (PUT /api/admin/projects/{projectID}/journeys/{journeyID}/steps) SetJourneySteps(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) + // Manually runs a journey for a user + // (POST /api/admin/projects/{projectID}/journeys/{journeyID}/users) + RunJourneyForUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) // Create journey version // (POST /api/admin/projects/{projectID}/journeys/{journeyID}/version) VersionJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) @@ -15147,6 +15315,12 @@ func (_ Unimplemented) SetJourneySteps(w http.ResponseWriter, r *http.Request, p w.WriteHeader(http.StatusNotImplemented) } +// Manually runs a journey for a user +// (POST /api/admin/projects/{projectID}/journeys/{journeyID}/users) +func (_ Unimplemented) RunJourneyForUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + // Create journey version // (POST /api/admin/projects/{projectID}/journeys/{journeyID}/version) func (_ Unimplemented) VersionJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { @@ -17115,6 +17289,46 @@ func (siw *ServerInterfaceWrapper) SetJourneySteps(w http.ResponseWriter, r *htt handler.ServeHTTP(w, r) } +// RunJourneyForUser operation middleware +func (siw *ServerInterfaceWrapper) RunJourneyForUser(w http.ResponseWriter, r *http.Request) { + + var err error + + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return + } + + // ------------- Path parameter "journeyID" ------------- + var journeyID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "journeyID", chi.URLParam(r, "journeyID"), &journeyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "journeyID", Err: err}) + return + } + + ctx := r.Context() + + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) + + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.RunJourneyForUser(w, r, projectID, journeyID) + })) + + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) + } + + handler.ServeHTTP(w, r) +} + // VersionJourney operation middleware func (siw *ServerInterfaceWrapper) VersionJourney(w http.ResponseWriter, r *http.Request) { @@ -19344,6 +19558,9 @@ func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handl r.Group(func(r chi.Router) { r.Put(options.BaseURL+"/api/admin/projects/{projectID}/journeys/{journeyID}/steps", wrapper.SetJourneySteps) }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/api/admin/projects/{projectID}/journeys/{journeyID}/users", wrapper.RunJourneyForUser) + }) r.Group(func(r chi.Router) { r.Post(options.BaseURL+"/api/admin/projects/{projectID}/journeys/{journeyID}/version", wrapper.VersionJourney) }) diff --git a/internal/store/users/events.go b/internal/store/users/events.go index 85c69e36..5660060b 100644 --- a/internal/store/users/events.go +++ b/internal/store/users/events.go @@ -178,3 +178,33 @@ func (s *EventsStore) ListEventJourneyDependencies(ctx context.Context, eventID err := s.db.SelectContext(ctx, &entrances, query, eventID) return entrances, err } + +func (s *EventsStore) GetEventJourneyStep(ctx context.Context, stepID uuid.UUID, versionID uuid.UUID) (JourneyEntranceStep, error) { + query := ` + SELECT + j.id AS journey_id, + jv.id AS version_id, + jvs.id AS step_id, + jvs.external_id, + jvs.type, + jvs.data_key, + jvs.data, + COALESCE( + json_agg(row_to_json(c)) FILTER (WHERE c.version_id IS NOT NULL), + '[]' + ) AS children + FROM journeys j + JOIN journey_versions jv ON jv.id = j.version_id + JOIN journey_version_steps jvs ON jvs.version_id = jv.id + LEFT JOIN journey_version_step_children c ON jvs.version_id = c.version_id + AND jvs.external_id = c.parent_external_id + WHERE jv.id = $2 + AND jvs.id = $1 + AND j.deleted_at IS NULL + AND jvs.type = 'entrance' + GROUP BY j.id, jv.id, jvs.id` + + var entrances JourneyEntranceStep + err := s.db.SelectContext(ctx, &entrances, query, stepID, versionID) + return entrances, err +} diff --git a/internal/wasm/test/provider.wasm b/internal/wasm/test/provider.wasm index be7831a3c3d86dac10c17e70017f532f94fe438c..a21bbcfacc7aa72f5665754bef0775e784f2b3e7 100644 GIT binary patch delta 46448 zcmcG%cYGDa_dm?+&Tf*M+~kIYBqRiq&t_Uk*Xp{wV+55uz_@tB1&^5gVF^B zL~4XZq!;N`KtPmUq@#dJk>5GHb7n7}kKga}{GQkA`R~4GXXj2ibNbBgyj5`L$U@7e z7@D;pR~Qd;J|mp@#K9CT#abTGFgz_!Fi&BY($IPo@ummf@(uF9JzuspVq!{GFi)gY zmk&+LW2EIt3kyW0hhs^QHS)9MwD8E_Br_VX4SC%(JsAE*h7rsYoXs9a z=83ctWBa6>KBHyi3G&A2dExQ5?2U{#sFWTb%#$8&&57+Ep5}J5p%t5Vl@EaYpWFj^ z>oUZe`@dHH_#y~(2^+dEi}2A(G}5-LPdh2ZKbJm?Put=pfc ziWZAC!}=#>lld}ZL$#sSu!(7=oY^Y{vW=-a3maeUOnbgWGD$QA<6lgOLXU#sJ zWsKArymT;7DECysqVSx%?>f)Vl*lIzj9@8jdv4vdZm?uN+3@1@V?F>hl@l^F7?4j* zDR z0*UEBSMH?n4r}6;{MNF`N!G?K+{#MF>X=rrtG559|l6IXw{uRjP;6gf2{6z zs^twSdsw5AQx@lySyG1}}8G#nTc#GAJxAxac$3M;|YyVxV3f4?`qGp0q z^V!-3ux6sHIiR*vGwF$%N!IY%`K%+gQ?O=!YP0sO@U$370=MeS^Z}sd7j@r2NUQD( z4nRmN{&BEBLgG#SdN4^b#G9Psp_u{R(jjzN*=abdAv@{*4J6ZHK%zResCVO#cDRO8fnr0y^AYtdGTM?#8 zSh`u(P=E#hqp5=KMll?o=hq{lN+GHeED>lBEJXW1GA$!bTMVosJp(GGQ6*>j(!5Gh z!E|~QtPby|dygWbf*I~J>z8Kd!qcKdcH)U=Ui3i$Ed`LKyAxk%-Vw`bO_10RHt&i> zv@TfGyhSH0qP4-I9W4%E5$(b`EjtGQ%Jp%k*u*Io+jkpjR{d7h%EO=vtDcvHo)=a< zM{x?gFDh7sD!>XA5eL^83D%}omJfIgb+BXWIsYOPO18=7a}5@b%=fk2J#A_MA0l}X zcn;WwNh24)_7dX(%LaMf;M$MP;IOe=>|eqY#XHN5%3|p}J%tOMnbw?XDOQcrQC8OT zD?Ltr<@r=(yfl}Aw&U2b+-Yr1&0~HG+5x$Gj4!2q2ZZuJtzqqJBBUAK*1k4En%$@u z`yiy59rfZ+ghcuN4i4)i%73TByZDrN+MNy{6Fh#_y<=sB#LDJ(tc8%+*!7N65E2Lb zsM92bl6&PA>Fn|w;#}3ce1MN7*Rr;E0g{Lc64T1+Is_pxtd(5_LdmOgpL@w|i}+NJ zmz}mGkFx%Hc>>lZzBKWbpAbsEWWD+7c!b1@jBd^!OI~F4?B={n{6~LnF;7DBmQExm^W<;Ki?*n>H&SMEm3>~$Dx zXSfucd#+bU=dmPttMQwc@UbLtt6Coi7IkY|CHp$Cn1uQJIk32d5pOxLgoJ;)u%ruf ze|tO9`KMCy@uPRn<3D9ec;#K^<v{llEMvm`d&2OS1pFDr5Uzz7GI zlepL*-NEH0t}xiGU%|yza7a~ry`qG}hkTX*u#yWw7=Z#6$O|fUB`dZY=m$f4VC~AX z_Nt*X5mu3~rt4f$Xd=$cL34a(~sUpB?E`)uI8q$K}W*~pCn#)-tLKMxYV0E{m zh>bMjtvVwjv8@`itu`Yv5!RG&%!mpBfVHUUKyt8_V70Y)>*R=dd{SFIi3`>i2Y)f* z<1|pvk$E$CT*rN!TXbX$`K*o~Z1gxukx_^E_Yo{gbZKj*SU1ln zi%Dy>61i9^rTeoJ-XoY{~x7tlQ8MzHF;YPml`&%=8zuGq zI@YZj$32l3oE&G(_&Tq3cV-*%AF<3H_mP}7hGoM&8>#upBV|gpK?aL=tEb*&jY)9^`uj+^VL-hqE@eS&A z&jss}0D8SfVZUHJ2PUD3GaFe8F}nuKZ!K6Dt<6zn>9Z1Y%UE^4uJ0{`JEK)X$un(M znmcTL(X-mNNM{Pgpz(T3D=^!adtgz2*hMs#Etb3zI+tsg0HLe7w4#=#J_}INCFo8W zLH)n?dpJ=l%)Q6zxLeWHFI}5DT+#6ROA94H!%8Xh-V@6YYjM~IBIsR9n<6BFF1QRx zC0r@c4VF1iiJ+%08yGfE*Yu%mkhOlrr`D3?O}wdM-&V7-S44+SRjY41S&LWr*n`~F zE9${w5p!YRKC$6jecP2?uvV}5(t2U#n9y3)tU{~)qrt9WmvoH})dq=!Q_XVLzE$hJ z7c3h{Rq1DvRCOTL+s_lJMy>A0Hs%gp9ZEVozdIO0I=OS#pk!3EW95E7wyZ~sz;5!S zF|gq?f#t~6ibj@`2U!mBl-Jj0VH2dv%~}h#lE+iFtj)w0 z=?F>PE4K+0x(KE2iA_$+r0yNw1QI7ANa|kx&7jdnD08#zX3%IOl)5)#b823IQr+Wq zHE`plhoK|Ly0SSZoE#a}m@QyFMkqZnVk?k$gfitiZgsj#df-=EoxzYE_@`T0>Va0% zZ9lTDxrKf>4|GkQB;O8L73E2?vUb2aD@W23>#RMw&YpW|^bS~OVo6 zlCffT!-n-K66x$hB9W!LPvcV}k*RxN-h7Hge%s@`OC(ZlZv%WvBr6@p&&}aa4Y&0;e58Q5jH_~!sUHu`B{U7iP+CU zGm8dgT?|{R6}6HMd==t#gB`*GsbYB}kd)^RfCa7Oq3E9k?z7hqIx?H3)v=if$;b8Au?+}`X>2?WT2q)}8kdj5s)i9o>(;OE4<-pqYw5Y6?5ap#zzT|9@upAonZp8N zeKz=r}{DqS7(Cs4Dh%-ajvRrmH0;q+Y6|v`_k^h^q z&$7y%?-mXd=P1S2^z#+8*{|jvIFF4&xBxX}>+}T}e7u^_=PrUnBwmrAeQ_Z|8hrOl zu-x&A1Y<8xLr5gJ@-i^ac*S_C{x$(2k>I}HoXRAt`dx7p$+SEJE5E6H~?n3fn)VtdppOP2jv%4of${utN z_?n_@(dvwzfd9b7tpGUQ20x6p;{F8ZcsvQa+!23P3Sm#{{`%zKU*Fk_rCFc+Jpx~q zKF-|K`%xj|E%#tZ$apRL0mPR6d#I`-PD@gz=7v8S4J{=|0-f^D3LgO4@hu|ln>dL2&IZ8sxr0;v7}IOkFlQ+OD-vnY7B@nfoN2`ue|Mk(+_q6{EMgk&KSz`f(ig>2V|W-Fj`($gUB#IX0!b3i2gc7QqYLb(z-vF>B)+pt*HDFD@F z-@tH54s!I`CJLUH)x(x#H|-XASpc-@c=C@~pWQ7f9*ClK5%CxHpGr3_90@LkM{Z5PuhC!_)|p7 zWcICUNkpcwVxdh{Php)xo0^ltnn!z0L2uIp`^wBmeJvn57huuaR>O6Nd|ZG*n1#FB zM~qBmvqK_#cIkr5VA?_^Vt>&qLOd@iT2sCx)cC;@lPIoduxjGxLhL#Asa-ye9S1U? z_F^+wCGD*9dXr}0mzTl?45|AN{!4f={HGDMxEcpMlnxk-4QjNBVL-PXvmv*bs`qI2%SThOvoaeG%3rJdMd& zs5{k674?d;!agV>3hrH$bz*lwMwSwP7G-UepcJi&F)%Y!=f#9#tOEN(Y%0c8r(O!PZTW0;>~?|wZKqKELma}u$l!Lh^*iB zbkSuDi?%id!oX=)W;q4K0_}3_3RaLTaQ@fj8AF~TS)j9(BHgvz zQ-OWWr}`-DJ^lmub^0Bi&;GU|O8^Iml#TYm%IpvL4^KMot;&jrii<~8St4Q@WokBi zlix6zU-W%bPq7zev+saH19Gij1AwPo!91i*3Q6 zRmf}UVo_~2h5aRhbr|G>&=%NQhrPo;4nTuoA2bnT>axBbn|xds`>NQaT`0)%1DPlf ztR1Y+3ONOGG?#aju}abLDOM@dakC7Pn4EvBDg22#vK6D03)6@7_R=zyE;EBCB z@}cmM`BV-rnDDe9A1=mlV0`NfcSz~^q+ zkK3`sY@KDL3_~ni4h;0qNGdHI{OH#5y9LDK&oo1%zrjB7CV0&osDvp0 zjZ#9mnD#kOvL;2EqD~LgM*L)Bh_yW!DDZwVGVIu%tN<*uOoV_xG_6g4#fhf9SPe`} zpjF0TG-8_grM=i1Y({!TM8Do{v(j@WpxFfbm)@)_v@LmIXxkB@VjmVC${1VrVb`%i z=}55~^#$py5;R1ger!Or*B@vrOgwr~OA)bev6n+SW)FUgm4OZCCre1=zRg-9mZp%1 zdWV6j?{}4Tg+<+KdYI_)E^8G|8v)JMkPwv@IGPWEqkPZkf(^iI=z}0{41y& z*@IXHJ7T{$h;@XmMGEkSAt*~d&R%*b8_3ue0SZzX`^Yf%bI8_0Es2lNnQkrjXNlP# zuxK%Cj9yuE8Oh%A1j&h!>{GGgH$7gwxmS-AARs^T9u^wK#_(@7XkyNc;!etzRjO3F zxK)&e<&0)6JZ^&G_<={KFONm8>Cx$&v1}Y-qNYk8;u7o@C4Djv)MtuUt=7oFh#k* zK$DR&#{OdtdtPHx#la1FL9wWm;X`4OC_bFWo>lZ^pPvWa(AHxFtR&H45Apab*2^PS zb0aGv#C%pX#MD66*Z`E@FcDY)241cWj=0i5p;BQGSHFdK`Y%ML=ea1>F2rS5N;En} z@{0p&%%{ZK1T&id0fP};$3qh3qZOb{l0z?A?0s1a6SKd@KFNs^@r&3BJ`(2#)U={v zV@JJ&Nc;wMHR{2{Z`k+7=5Q7KpA|D~v$c&?0{ zOL5SiZu;j^HW)GOqruD2E>vM2v3D6u#XyVPM>1Zw3{w+Cm*qx2QEWAz7#MzY$TzZBY+kjPW`%=_9)vs=>8r0HoU!f|2yO_YA@R5 z*8s7_dYcg@Iy|_IiG!PYelhxcTog}*Jo-JGftYlbL2Ho;Rd7_yTg$*vuQW(;Y^|$u z60?h6hg7UWqT&UKiP=qG=hi1?cT8epcJb?xcZDlv*M2={+GjZAhCt3*QPFXS9uNgK zFi6{z(NO^#uH*l*wAz0y?Z+EgBb-{fv{qo8v#)B3a+_FQzBGcRSToxe5MWEaYH#1f z4#Gy29yoi}7S@CF7buIE9aNn1{YtiEXD~qG> zl4{*m$5AA^qkuq^9EEggi|q%{Yw9B>wJ3NH^-mvpp2fI>tRrISKNhzRvZ{z>P*#*X zgzBe{(q_eoLoA3mU3vre9CD{VL*nos(TU>oyoo=$s#FpAe9(`qR(W_{l)Q(SC7K55 zF2SPi5JIg=A2}KA%RjO(#-`f04zp{pyOLdd%RYCM2{5yhX(!ktkF$|ZfmGG(n3JrO zi8bWj74^;{uLFOo?9hO-$gYwV`oz=c}+<^_nu5+PmbJBU%1vw3=!+)R09i-T% zNWFm8no?niO|%m4B^yabh|E9tbu_ABnfxjabJ*}$d0+oA{km+vd^H5 z#)+j7+6YnS95_1H-(y|abW!L}b}kB(2kA_a2U_N8c%bF>pT$JCzu5XHQg5&cOC4z0 zX?OV>%o&_ZdOHn&0VViDb0O8z!RtViqE2C+XtReb0aRt>#De4rNS}a%H>uDUvX7cR zLVMI(+S!lTD1ILkuUoyxidw@K6%;-HVMjd~*7z}!t>@40`|n~Rt> z*gZqLjF^`5lBu0WOjLOwOanIQ1y-7dYiFYYdvZk+vFE{k^h|^X3|P5S#i9u9D{XRN zQSK)r)$Zfd>Od!H{#He5TX6oUlOv)u;H_%T#e*o#3Y}l!*P0@xPG0qEV2yZNr*O1( z05Or=!)WaX#H4)fj&U*VlFtJ!COOwV*2Sd6Wao7;DKTMjE+!@BXq+}2+b4^yOS}eh zGg3*g-SHZ*=}3}bqI^DW3}Wec5u5U9I}nqw`XoUUh^4R+6%sXvm5~4Aexe5Mi%2D_ zZY62IAtqUMHotZeG0Ccf$=X9U)83b&rNgX~m2j_s_T_(WnTq!DR7mcKhDvfVob7mf z9gnw@3u%!&Y)Xt4FPTS*K+DUTv?!nbZei_ra6QPT?Kg{ScYtfCM(my?wdRcNvcE5- z9S1d?xXrXO8n~2{SMyu@b0*wSrAQ>|$hGgMVdsOHW)OREpDn!6ql`ma%L*}Y@Mxv zWo0V*oSUuHLrnB}BU^*`q^b0MH&g_B_+l?#%Pkq&Q7VV z)nxpOFbG^wW>J(qqK`p-~0j9}|LpaLzub-P)VrxCEvT+Ugn!C_N>T40& zlWPjc8~@*M%&KC2BOIz{W+U6QM?IyTV{EbAy)n?AGJ(aHO_0SZFNIySsWu&Y=$XK~ znj!sqCUD|2S{=m1m^weBwMI@aK4?d@bf3bx&60u}V z_N5luJf{P+@}IWCl~<{a;%qA%oyu(#nXTOp5N8_Q+U)@8)><3419IW*)@`(H&L7aq zr#*+HrZO5u=jXIU#KfA0KBsj-OswhhbGR2&QlqH!y!K@Puw+fRd4u^>kgSzx)>f+= zHYQSwfRKska@zDTYtf;DwkT}8UkgVT zh0TdFoAn~1Sx0TVCrOh#Y3D*Eso7Zrv&JKdI-Rxe5tB^RySUG3Rcm(9AXz~rpou@_ za}qb@x@w?9sT4G^qAQ9km4hbCm)!P9+|+r=txt=(=_PF!n;|}aS%c(tvif_zqAdtj zUsGSzz@gx&ubW@ho(WN3MN&5u?4F^&wHyAaXXrobhJ*AB{Y|gA&xsW8zorew=R}Ib zUdM&^4E@=!YpIAsI-OsfdR^Pd?%A`uYahTilCF3=vxim+h)TsJ?M^+ll1_nKL@}wC zHX19?j2G&ytwu~Ue!92z05R>O^KXLZ8!*lIz&_eI#MJrdzBoAn)%o1MC{P2mk3^e( z+VhC1^DFvk;C>7!2KtA@B;YH(g;X6-{Bzh_8bn$Gihr(?nE2=Yx3qcqT<#)!{@Yp( zFyH`5c)QViS^#D!zqEup_See6gydHuCTD;K3L<3VyHqaL11^vjmzEf0Z>6Qz%hS3a zTG4S(gQo270UE?e0%~KfeIHv0sEv94eJzNX?Axq??hr_4=rPc(FLegn8VI=#_yQTY zLk4RF5R-vBcQ8u9fC^>&JlLHhY2b?DLr`V}C_T&WIRvsC15hB3nK?qEfY?6)+^*J8 z?E==78CCZ1VVdU57a6u6k3i)&K!)x7QzI}~A0WflzC2P};uNII37a(vRiFSR*4Pt9 zYlc&yu&gkBjP?gsDB@y!>R1gA;|0jJ6-z$UZX+%xD=ZkN#W)p;%N90%q}{*@C0sn; z{@CqPN%_LY@fsW)f(oT%!O01-51F#y%0y7v*+RSfWGxG{BDvM=nU+=oUi3`WP)R&dXARLjAMzQ zhdqs~u5Amy9>JVGp6ryF*}1{kpCrY*Wr>w&(o zC)!%NQR~Il+Nql~j2Fu>+fQxQ+QC$LnF9;ApnOu919si5S|so@l{#QQ`-AqZ^9E7c z^6eU)jP=v>i^QGUBgAs{?bKb45#ePIl-;fUh!u#`BKK(R5fiEP-lNq*Or-Yh9%LeZ zCF9QQ(W-90$U2cpq1=bTpFj!v0agK%f2~IMM(6+ z%s8J29@DbeB)iWs$LOFely8n}!*HF5?kb&gl3Jsk^Zyl?!fL5Rjr8(Pf# z6^G+d68J>Z#i?Jl>BerK+C38+8f7su8)hFk<@jQV#V4H6&Z7cPf3KfK)yy+_J~``J z6!h=c&!Sr3nLP0C$)fZ*4SbuP-P7`%YZcIpPd}%X!so1D<2<=}0tQ`88vQ!Z$WLiXt1i`u)P67`mPpu%EvQTqAE< ztRiV}>mz}Re{7y0KDnk<@WDfx&Ar#OLx^cH7hHEV;aIhpCvKqsEtWbccHh)CAtu_L zatk?TEU^Uihe zHcA_xBqo$HQo+GJM6|l6E%A7v`KLB1be?DZiTav1&*T5nRv{*$X!bWMS8AHY)Avy( zsc99BA0Ul;(WyfZG{_tBc3_K#C}zDt)H9FV_ldVP{|9B27l=CjkJ~@#ptA=&h5#{E zkj!n$7X1%)$+nr^1BOpQ@RGV-5bZKroR+%&0%D?`<+=`Y?b(4Hxejh#bpl4L;CgSw zv^FITw>_frmJ$<{zh~$*us*HL_l6D{vN~{-W9s!062oq0>cGGulICiQ;uBM^h?tC$ zeWni126g60B!s!o$+mAD=C(&h$;>dl0oEte{;I4`PMzZ6ZhK_fzZvefN2dLvaJ><} zPZq@ea2+hpFf#2$%LpCxxiIB*+!>*RZvxJq$^Iw$^kRs~fN12?GZ0gRtglap018CI zWc{V^JOEf7TLj6HB3f-X(sCm8k?eu}L8Lw(mXkPF1-}l#F2%X*5Bz!!AOgj@>>bg1 zX{Uh5^ihmHGz%(t+#pXH56oggd3-p*b^pcVNmE+n1p&QH1;BEVQ6dFrUxdtnz;s4& znMC)!eE1$MerBv*unl0j_>LrV{!5-h%jdoW@mJ;UfjV%M7UW&o^vqy{EAZlz(=yXb zVI?Ay&!Ax(C6UR-SUm+h=*jgwX{CZVu=z@|$GLwNi|vqWC^E0^@N6QVvU&A_cn(*R zkLpaB^pX^IjZID~nO+L*^A700UfnnH)G+f1R@op!iwJI9q)5~VUb7`!Gc0%5B-`Z|mG%E9u2)5zEpf#X$h{)y z;uX=igr3<7aCP@N5=HRTB_n7cZB}=QE6ODW{l7pMRGy#C|9cWz4APwx#Xt7qX~9iW15%j(%!aF7b_mDMX?!67QBP)>gd z3x1@6ndS7hSa6sM9+%V0m4SjIvcO>xHn5pQvDDdHs1T zI7S8M%Ij6I;5Zc&uHeqW2`YHLf?ff$@qU&C@V9!PM|wCE2zC|%xXUW&e_#_Q>5at| z_2yXc3l$iZ^gUScD;4})Nnefyr>G#OvfIXKDzK{Pjj_fVD!5ohuZRU_si1IGy*n11 zqk^2OdgGxWzaoO?Wl;+B6|8*7hG1!tfj&^~Qc9S!o#3IC9tCnU^63obXORy7hJ)P^ z!3*+z$40#%Ukbeko zSt7D)=-sf&6)IRzL*Ib~SE=Crn(kn)QNi_^dJCk?>#_g_lPCDdq0H;D!>-v41A}Te zWHq~IEj^vFFYO7n^|4-j)lLoS-vJl(oI|JT>0lds&Y`3A^=A>2MpUtZJ_xbYh{Wm! z`VWYu_G6D}sNZ!OBpr9uQ~G;Yfz%x1Y5f*rspi=KJgtA^yg;h^Cr$KySb@}+?oIXM zh)I2E+6*N{45=@6{bzJ^(#0q}rA>2vB4W~0t~S>Lf6Q5TFAu z1H{`!=jM7{QM(l?#xdlK7voy#8}J3Gq`(Vcusbj06&qT>3o~2moA3qFgkNvt4wAH% zuFs+h7Na!bvCpFPiy=+ee&;!Tgfj-IwybKaW27^N)D}_b1w9urslq?Mpo9Gsqg3Ia z+UXAvQ(oB5?NJ!UD2=4qi|!wiMpCVV-T|MJ`+Q~x{ZI3}ZgwTepa%2bXG30a z-w^#dyR%*wB^a4Q!#nE_wGjpFp@hDp3#76&Z1IX-4Myjs z!yJEA{}eG1)w|trbShoL?)RFGzIm0eVGny<@8%Q`Ro(2azls&ea_abo4py?4*3`U* zehx7aRrQ`ICDk>%Vn|QDFk&*DzV4})Lrl8wxt@9}#6(lIdg;x}0rqs?JZUDd&v^yu$ephOmH`s+cgPh`Od=v@&LujxI&wLpn1 z)(+60#^=Oq{O{{8A||rv`#xGDo<%+PeN>XwH69}GKz$@)Vl^`df`wTg3KXk>JcxiR zj6yRZ!-ymt$rJ0I1urz%{WGGDR)h8L*#_G`M1KyZlwv{Mhw3S?6}(u`_+k3MkXVq2 z9j=2bMtK;;)mVL0C?Qt* zP%nX)2<6oekuW?$oC&xbU^yt1l4vU9{*)Q`?)2mJshmu8@$f?(yn}F4vs8r(jnfCQ zP2yGuxFuyNWI5Vf$LVun?&TQ~(feclCOc|(8m|`x{zth@<0k4GVMR=}LEB8mU8T~2 z?2jgcB7gN(iL-+meDL5zIzNhmbt%SJ*Vi^Z> zK>fi>W4w#4;gnRS-CXFY;E&|wkEF}ZL|`KvKh2qnJ{WJ}pFF6tz)t@RSh1IUQRZ_r z=e;;y*U$BrLqm9bKiA(34dFGMh8xa{-dWRNhOvP3hol*LOAQNXOZT0nuR~00Qgyc8 z25-!jjtcUm+*-NZ_Tf^yzFEo>Pt!ecGCl;#7H~3c9rO*{{zB4M`aeg<#6O zjLnR%b?|X}8JlyyMqRR!U>w#w!@`*0r=qbht%$*W*Fm8sT zACCkj;<>yqvH2VQvL}3&FV-hV1JOz0gN=#d^)$E|evMgE%wD2b4%-stChJVj26`Ib zSj!YcOR)l?)>3`18ij~mrh`M+8^nQSC>p&%G+nL_4;{pj<*2ZzL5S)r^zRW9-Tbpc zhf}>!pxkai7p6$BttE;I-|A-~?gex|+}6$p3#VV;pRXWZU#YKAL$gb+l3E4{)~dF? zGIWF8wNV;+g0=K&-S)P^mDRX&yseP`J0vA9nmzhE{caUc3VE0s4f)Y4GO z56p0~D7Q_|FLtca6Y%fl2<=O2^d>+EUe;>$wfakli8Ft>7Nw)71f5!|&w@jlL)Yn( zy$I`#TyXJctw%+~3$wnsUhl>y{Ck+S;RYbb4K|#M(}5}}SM=wNs2h44smLbu{d)9{ z8%a#wqz`5bMa*XXp%*&HyG4HuBYujaK#^jBSAy)5tMOv?7Cj%j={3ob*Kg53K}?*p z-Bxt!cyWZITk&tbI6~=dD3HB4!s>1M62!z!-uwY|B`=N;w;kP7-hq~x+w~l6gyEi{ zg#$p1#q=HeT91r7??lbjBjblV^)=djLj-@++l#!r^*NrfShE|w_3EU0&K~_BLK@kL zJ-7rA?sP{AfxrY&=U2Tp+m0;UhEuS4L#BJ|J`}Rvbno4#7yr-cMojaRx*r_kOT?W0 zy5;q##sPdu^$1R&fV???mEuHdoLL7?9Q#D(LA|~A&c_GcZqgos#Pn2g^q~GUngx|ZSsld5vtq&py@QzcqYhsfAxT=|7;YY~D_D;`60^_2G;TYrCwnz7 z9{%qZspjS*dNMc`NwT5L53Un+E}_Tk-`n1BG_>v0NB^bmoj9)6(JEya^QttlbHe-#0;0rimFR^?vLIj_ZQgpNGHv%itg55y3!V4fJffB~EjDGkLxzy3=j3&pTgI%K3!rJh&+rIK81SdhF)>HpEJ ztG)#viyMdkr={!}$oP+!MEcqP>2G?9m~(o#*P(*v{->I6|L>Kw+sxhS5BKX)f?v?n zz51mu=r6IwxSL)R_b%wQyeHK!{!f3`UL;%!CCI9m{^y#3-}K~Ino~JLGscR#moQ4> zkyYqU!dJX*l>hBt8vpLe?Vl_PUD2z1?{vAML+XIn`mif{59Sg{R49>%R#)|S@3nth zadG{s{#Jw>K);5f`!)Ryw(g0|=4--ZL< zM7sZ%e;XSmiPGC4|JDNE5eYYX;e|a)U#c!z{I0{PW;&*`;dlLHsGynm2g-I&U;6bA zbOI=)&yKp|ghxDuss3H`U?_!2%(#nYnbMcU*1H(9Qs;C;p?hdbd&hHn-$R8~eIh}8 zeow#6*BOwnkI6gY`$}4rz3NZBByc#g_AmaWw~Yl9BH05rvu+iSM+a@5G_8sjh|(eO zr5pgjqaY;)kM-GziLowztpANzGS(?e`A-PRAeqQG%zUC! zA$BqjT45q-T{#+Wfsm|_7c>rGq(tR;`bgtWZ^*?^UgyrgkvUwE^N+ATd7id&4vKK1 z@;tRNcqPQr#ULga9ClF5en8NtQ!#Oxr5|!_=e>jIo zVWRR~&JO3L5tHxoNI36-n4+nTBX~W;%W>eV6v(2!0vXUmh8n{!l_&LO+cdv`(?}Og$xwPxX@tW~~ zl}Varrl+L^(o@9bQgB{jVH_W+l}szH)RF>l(}1%_fJFVyncfnS@R;beO#*N015EUq zo4|)4CVH)&$mb#^dcBy)pDGVnDFV)I_puO{c*51;UUFWXh9Np6ak%BYIMFfKBkFc^ zanQNtyf}?WK$1|%?U>?X5(m{peJ4na%+ISJCO6vV{QN1zMB{mrIcVX^WiMtXyE9BQ z{zVGXtmm;e3h-AD6OH#PfO|+e?8TP_kb;zd-rie)tAacyjgsSeSzg#dGyHEy5x0?78}9 z7U8`S({{;Mls838+ogL^cQMG-|6Ni35|cz7r5&S=fd5jAUqPH9 zpC2gBK~Tg{rh&*T!Ltz;kMmC3siF#pLq>CHXGI#U;L3l21llLgEig zx$T#f_qtEr!0&BDBi9K4QuZXkOVJ0p$j~TiM-*lpAooGM|ehR=EMAtMF!6 zpmGCFR^g+uK;;JXtjb@<0?G}rf33>w`VHq|7H#T6xL8t|BW?x3oKAk|NJ$1Yb;Pv z|95J-{h+A7*i@6(!5S*Q@2kb1#R3)If4!Fbw<^BBz7}tSHB@{*Z*BK)ReZlkZMS18 zzQ4A%J6ekGi>NxhF1De<`Onwk1+hSd^M};o5Z;dQ!uboJpb8XFIA2onq%jztJ}v{p zkYofY3$7f9393N?a? z0{g}4^BinL1@?ca&ue1=1@`Ue2E3X>DHPeaTQ%e_IVBX>7wZ~vNIi*Bk$Q2fkvkI< zmlw%Txdjx67Y$?q#oSnwAW9B=OK;=ie&dkgnp z?o+{!E!?p@pn_5@-G6yV1ua|h3E1c(D!AOz9qm6<5NPGj`(rBT-HMOESB8=1bH5cY zSP2S-dlo|kcmpHT!XbV(oVm;x(w*c@{4v21^k$RRd?+?Gk_vuo&C9_h4p8)gEJB;Z zA2`9Fz-=fjS!A@~xE*088yuGMd$x2O|$NsN+&1xfA~an4(!Fn%oy<>NreszPA7~Gu~iUusrMVNs!`0#IB z927}yTCT|HL!#??)?Exe%nFP4Z}8%LJKR(9#My)}aqSKMyXRxL(1SmRCO%C@{hnx= zdOn7Rz0fdIJ_hk!FFp`486vfM^S2SxWUT4U?;8w7*D12{m zh*_v_F^V>Cx#OesjO}mX+NiHF+HKzEuQ0wBu9LvyVTDDPx^VqD9+44I@ABEPump|= z0u}(SQ_B;`D^690%fODj%Pm|%n$^DV@zIEh#GJ5g?QB+83@c*9idpBiu(*gST3TVP zuvS9L6D;xue%NC_Ua{?d8%%uBpP%DlVJH7Td4?um}YrpjS=uq%Tc;ov#h?rK* zH;`{*W9$P1c{QytWcT10;4|LbNHZ{jF0c*0uZ)E-06$z?r-{--IAp1KX+X{`4D!s9 zyv=+45S~9`%zJu4aMWmn&{bnU7{W1LM2DD+Vf;NjgG94(Y9h}kJ|Bjj26d82{4oqI zb?+ck-Qj!@V(R*x;XDU15u7ywS)n=-C!9u0j^u5ykf?6dNZf(mu{hrcsPuZr;(C4H zHbPXlX*TpsAH~zL5|Lh+QE0TNvvFekC?pki3Qn{c?KVRBLQYS98;vXFU9Vek403jL zy{;HDhJT>^7$Waj^ecI8jK*VKWu54z?^ra#y{mMiKjgg-lbQR$he&7Mow#x1+%A!s z>vU=1IJZmW+xc~zyDVg^cKV3l_qx>iW8|@3m*yo9zgT?}JQ{0@9W6>lD7i2Z%PoXF2@2XuwLg;zc&} znLv>w_(N=r4C&OVD9HUJ*zLAc`CQmxo+TM2}9242(*EYz=z z@t;3Oi_uTYfhazWL)wC0N%Y>+(75(1iT=wpR5tv|7%wp0op3V78%*bOJ$kw^-6b6w zf6W;@HI$TInt`4>KZ$!`&O`y=S2DiAO!T$-$#fUfXYyi*DaC*HOm}(6LT@~agU{Qq zQvCbOa-T~JUEG+3s+C`*_}887l2a9_dI2kNMknp_oH^(z@v98~SLe8!hs<+_bKIZf z&VWqw7a3ph!T6F)=NAjUaNDH({YziCOo43lmUH>@Sf6b4rE^h;`RQA!;@VvP4xYbN zHhPbF98%8xo{heE9;*9(&qlu}YmkjDN_>fiuirD#-~N&x@Rq6RSJ(w_+wWiKvH_x` z$gg=5QEonu#!5s^J-_BX#ESW71NcE2${9Q{pJ!r$GWBB?@akBgO#Li8Y!d?d~d6K`0!lf+b4r#Ok{WN~>xWlj&yeSqacgT?yygwEw zcZjn|dgh|p<@e4!H!<=We;#wOQoEdRr9 zw22R7p__HrX19V=_UyN7io0ZJ9j{I2MeV6Wk0tY zuC~Ae(*2qqKpjU#GwkaJczY8IWKyu*@+a^vVF4K)X~+3(#8Q>BlTYx=&VR@dogMiL zk8uh}nJawCjgXKY_xvf0GO7ax;^8UR2`}|5yW43##Q94Zq_eM|;TN11N!9xKJa17R zT9B$1sBs@JG}EHtlqlXWn(Xoo_|9rrI;6OJ(TH{zP&|3jh@1;3qP=LujSDYkYt+^rCJHcDoxK?{HBO3cKe`KF%p9E^9o#1-?D3A$=yc?|0t9DWD+5 zOMme1u>yHIirwKO5R<24`5it9F?l+g+~uC-CUT@0Dag?+q{&|n2VVBwv}K&s8L;PE{-G^V1Rm;)cX>Rmk^Wv{7$0r zGGcProJlk~BPNd8ILRnq0kGt#uzB;KLscG72NxYW4B#>%%-YeR9_2uMorJ?PRDAeB zk^y_xP}X#%{04*!4dSWd{rpCuYJi{gXt^OddACfc>(wAui{7vxWWKL~@0JWJ3*Yy- zn%{`UhAEJ2Bpc(kgU+`D;G#$P+Nn5{Yz*`!^w|_+k}(m!xi?fST>`hXe|}0UE7muJ zdqt`jFg^}(U+hgaK0qy;ESL5LjV}!Mh?@fu=sUF4)2!w}Qd7s|k$ z;JGe_WEhSqLQ{Vr!*DEP5@wl&jbUY>z7l3Iaw)`&kT8$B-3KXFbnOoI`qje5WByen zd;-ZyID(|s*5bvY#t`M3u}>E@Vqn*Kqx-9v0WKtObRQQtrZ^Qy*)LVnsGkWHq)QuB6^j-nbqwJ!%kk1Fs-B1>qYIaDEm)88L8|=@+Le7+^Me&a`_K zjQWUa3)ib?3`a~ey{Dov4>65)KqUjB|K9Brw<;MI`F`$v8mFjuT-jI^1*bWr-Y1Vf z*gsY=+OV+OJ}nY2)$H2VOvd8|CB&QA1|)>iLcCZFnX$JJldBo$5L4F%SI1rKEySwo zMoq-jwFlLW9}v@;@2X)G$pkDH!kI^TPdOdT#Q?jvGKn>f!q@=OeEpipM$|%xPiq?B ztx@wXVBSlL%*wzkAJjA~P*^9{GEREqDNxU-Di+o@YT!Gxaj(}l79yrW&8p*43(fcK zItG|h-k{3V#rgIIHLtEwB_6OElsX`yzF1-{JCP?&rqkwm?s#XI7 z{I1^lo^=fjaJhIV{LVEn#1AKn!CM)soQwF$= zyfbF2o-*nu0ap9~vi(fQn_LRMbb97Huse!8ZGdg=9XlKKG>%mrI|~`BGm$?(#afAq zjg1U`f-?r+eM++jG&b;q;bo*f0^hMr7af`!&$2c4@}|alxFR;&ePmB>Vf5F10A>H} z)HV=m!UCG<(QR?rvuUQqv9?Gi*)#xA;02IgfQgp7y?~^cP0KFq7YqnBWGkj}U)Cqm zZP3oGPZDuTJGVYLnUA$|+b1g{qrHnMw9&IYl3_MUM0-JdqYKy&*(CYw*sjJ5r$CB2 z+kVZc?i7%falekeTt<0An-=t!$ME2nDa$R|gsQ!?9G_8upD* z#)nQdX>8cT#u_)BhRACSHQL(yCmJs})yU>3_lZ$D3>%U*hj{ffqYh$ea@dPMGg6#o zk~W8ZaJq3&&x9J%zw59JdGAW7)|E}kPxkKFhM~jJxr1|!Vj;8v_gGEQR>g`<=e1_y zA4`uGH@`IA_vpLNSIBie`d<5$(LI#Dv*sJ%$MxvD+k8~K6n%?%^Nr$&i98O^H;N%9 znWHaopOeg~C^3=8%YYN0zLMra2){bAA|huY?BQ=0xciI9<<0_Q1h!A)GIXKQ05Orv zo`uFZ#8QD0oxetXGn}YJtp3`VikS4Gc8iQ`#FAFT=ZlOV5tBjs?l(p=#FA3P?r)3~ z#FR36^BZ?FlR4UQv5|<+$sFyo7`aS1op%>Gi;bB)C(QkbPYT}Dm@IlN2~}+?Ep=5- z;yBYKrVY!NxzCAD_grRxH^NhG_b)>Z<*Bx*%TY`4RND^AjqXwt^u8kHd<$}f$1I1f zFoZVI5T{qbA(tBixeq_P3tv5>Lr-vaYGCLooPOULlkjGI*-0Q*_j3BslQ@|xjREWn zvGF|If{GVk+Iv?Tn}JlNkhXJdqasW4I5aRq%tt%@DQ5C8D|SS@XtxGPBH}xvWGLgV z@tyGpVw#YuYmC>*0`^!i-dvxbZmtSdZPYPYv3rftA^~3Vq}k<9c`!Oq8;;VQ*~nUe zvn(Bv(8dV|pj?LK1IVuR5gG)^zd6tM|KJ0&Sx+k~s{B`LJnY}~-wax&~j zTZ~fRi=q?s?`<=(LfyDaw&C{i+_(?68GmL1mapSF2KE2;lzK<%Q??u6DOG3oME&h> zl_LBMslf9hkKgHbhiH52PBi1x--|xGklT3wwq%#vUE($mBqnb2 z^lqee?_3~USD7vr>^7ERm*}OgdyLaj6f6QuE=&~M3D+t1*lR?FMvaE<#s5+{0QR1} zj$z|@-LCI9Uc`2ZwY55cl1?QmpdLc zAbUgcWoRHxq!%$0MBOX!jlQpr8e`#*9-OR<6SGShk#NtV555gkR1~}lPj4OsCOP9L z)E_B`-sBh(j%TM0KZcu4*=g<<0&jLQTZuBqjV%77FJ!J4d(-^N33u4UYnPnB-Q-Pk z?9ax0#Kc-Q{cQ9^Ow?WFqyauYZ<;5ZblW3(Ja*EZMw;eUzaZ=KrWtRJuLxL?hgE*^bYFK_es*|NO;R%qRJoX{FCi5d+(rjqRvYMl0Yk z#06eCZG02D4fCHt9nj+fJXZNn~SQOJ3le%M)~7h*YV``%dt?zV*j z8n^$vTY;qh$n(b6?6jSA!T2GhTMsUxrSEZv=Pwx>5EIcCylf0WOuTLOWrI0?L(4Jn zChkbDU#D&wwDw>kIwN8W#9|rc)7SZSxQT=4z%qk21lBO#fBYlV0G$k18$I}FnIj$$P-i; z+GE zm+ti7uF(k_rsaR>o&m9QFWqV3J@k5c=}tHA;qHwh?jp+niT1NfcUtwAfdP^zrR06^ zw{aLTDS2J*qge6MoetkeZ=RR#RQG|4Ny+<0Vp8&w9-^Z~r8|jH5|fhm`$OX>J|`vb z;3K0cVp8&o{$m_NOjdyT*tm+A^#A*hjY`e{NdK?O%zIdYLJn0lb24I5{|{(pyz>I3 zcU;#^r$tKdIK$2U_yQeuc*!u^BBrAbn+@|R#1u=&Yno2N7sV1@G|htL;d#328glq~ zy35Z)Jv&j9?}7UynBfSoEvA{v{t|GxgyPjz#O^S2ly}`|+i(*^r{~(46=f!h@548V7pRM1=9OQWc^qZT-oXykz!G-30&6u9Hg1ogwzo4bC6~7n!wzB z%Hnw@uep|QgAY`Q+gJ4#R^Tt6=oV*|@_acW&TJm4=-!AkyRb)gi+B@m)&Paqalwi9 z`ApD2JazbBKC=a$b^H&DK`I1I63k)jn!P*0tODAryg}Ly&u``f!&==LZ5K;1Ayfbb zvK4SvoAaFlk`Y%@O_UL_w6Nk%L31f$(gwdNggeW-HF`FDcpWkEuA1p4XkOl}(G%0n zeu!zgd>Q6e#I#&LWtgCO#j52RSJ(vJ6swl&QDL0kSjD?ii@2C#rnQQg*Z9;TaJtm_ zghb<_CLZvj4?ztoX5#lRyt_8+;wG>r@2-uU66Qt3H2zT~O-#d8_s)o|rObN?fYr8w z4+i6nZm`kBhX=v_n8v9t;5v$}@HPAFsI9X{$F8qqAv{24LLNV&2maOY?> zBmQzOCIY@9F%j_g^6qou=JP6;ckq2VBlet%W^d;Y$!1TgY@WgjlAY&NF?-^@IFg$? ztSZ)J6cehLbNL#eU26_}G@)fxbAU&X2dbJCLJ1O%iziqu7uFOVv(0F2cs{#VwmBS# zkG{5ax4QW{{wwK<-D;Rq5tDWjR?~clnD|*#EfZ8!Z{q9MLJp)RUM#C+f{N|UbIIE7 zN)q9P*D>G6=fo#Is$;f7Ow)X!j(HL>5#Fx4X6H=6a+;lKfb#;-U->Bj_xMY+qQurg zvpaq+O3pjH5Qi#x9L}YjdnikWu+s7fZ5V!XGFtSnXTGM*FKM5tXSNK{+<@Cw5Fd5b zBSfJh+z|a6n9-;U(Ns-rV0J_Nf6BV{peU;-?k>wgd8|Mn4Pl7k3oM5$a>nPXfhZ~p z7@CS}EDw<-VHbwd9Q`9Ros>|nVPjL7k2IA@`T|8+#Z^GSscEuFW}NX4XDoASrpcL1 zJ7>Rp?%k$8f8TzOy^r&|zjM#M_i$A`o)2|FT1jkq71m|o?}~gKhyMvh`lXDXihk|H zoOm9rmUod^)FMjWi7i>gj7r;yTUq3T=u=^=+3+i2uED>usYN1G4VEl`!hFQ42K6~L zvLekL7-mJPBlED53OFx>nH7(3;2u392UgRE*v8#C5O8a`L!ZoniS#?`lc5|yH$k12 zXN+7331|WOxV$Ngh;sFDdG9U)gD?w}tXx1rrL!KsmrI@Ws%<|-&B}AeTJQ*o!mYVNld2)NHSzswojA!#;ZlFM{ zPb!u{!0~5&62BZ!Ax5x15w9%CtQ zydE{svB&-2IwI5>Q=54~!)*tZH_nl%GGmY0p&#jpd}gPnP|lNwVy z^FKL>8MQONd_5^59Z^2Io|sR?TrnFQY$eP?dRz&KUmZ~{DS;b=xqLHSR0O>aevJ#z zO$?4GCyF^!Fp}Qt0!(@FpGdMJ++@S*QkWmQJH`?vn^D?-gCFl=jFpq>3vtUX& z;ADZ8pbh1ulC=c&m&5afx!oR>n-Z0a<*pzW)oOF7g6K_eunE~%L*ki$?!|J`ZG?7#dBk=^_$<^=>yB+7)PTzzvSjvzs8_0OA2BJ`2CMwIS@=!<8 zDYiR3M5{W*_7e|zRXWA?0xwDLL}ggQ3pnMQs5;(FFU%&)Ei|Uiyq{aBy3V|xTj)%k zc|W(%Ly1{A&8au|BZSZ@4bO*4)hK^2V?JKrCLRDAzv z>61J@0f+2}WCsYmEs&{bbkGL^feh0vX_|E;%(#CN&RHy9isPpMPj=#fNZx7UP~caI z&eO1su>7MU`wV1JfJBlsehTM5@wk_0yryIiQYXfUIoc503NtN!Bd--^qYUNhYyKL# zf~&9iEDhz_t-g4c`h;?;o7=!gkV&Pt4TcCashs%+aH>Y-><|eC+#xKv(g^t$=#W*F zoI^}#hhv1f&)#gO(Madqi0Xi;gt^a}6TvFyhN$iUoCsFAHOz_#sLm1GZSfkZPO1oz z*NQvMI__ER!f_6=!>&YHqj=>;)AY%aqU{_!(5skEoF`qRmxWn7sdRc-ScSwqRNm+$ zU7}-W_6x9&FxSqB3$T(fkCagtA(JqVB)J#iE@3w48C}F-dij^=f*FL_pl@}-IKo^x z;XY`G`$^XDt)ar*h=)(V)sJUuKJvk*G1xDp{W+2xgW%OdPljn+bFKkM5>HLg!m{chexD^DW=*1_xm-VcHd%r2$pK!7If2pql>$ zKWrk*B|PQ_oa)p0mLK?G9bu-dqN`9qn5A*sRj4J*jFoZC{63E=Z(kz@112oty9Tci z=267bLrPVpTNZ12%>Toq$d5flp`es;axW=Y;6X#I?xh|AYU=KCFNrNs$~dOa{2nXg zWqoFOSQ&Tpk-33V#((!gD`8f~ZP&>>K`G<-e!wYeP!o3z{ji-dPu$rCVEib=QW#?l zG)~6DlZEd(#EXIfvM*2@we}8>iU6gQhX%|B7%PW>)IstsK&=Wc9E62m#a{Q?+|DZ3 zuuxl-v%+opu;ycKeEO-Ya85eRFpOp*LteoEcUwVE8Hb5O+H&f r{6TB1`mxOA!5f?&mr>dlw%8h5Inv{-p^K$1r^j34ss-UU!dCqYeh$1o delta 43123 zcmb@vcYIaF)-cTMJ$t8~oP>lVBmok7FVcGsh)6HeMY;`?CW@$36$GRnVMIhgRHP^+ z!d8lO=?JJGVgUtIIyMwk-qp?y-sj%?K40MvepzSwnl-D>?7hzx+k3U>>N$?JYfheV zZrXZYw2C#ezO*yLYhs#3l~B#H3p5)Z{yS!f|M%mu&-j1;5nD$!3!ly^Qa)55uGw%s zHoHJ}RAPKibf`cH6;gKvR7Q5RlU*P#bnBKq40;Qw0%m-?RW5HyT!N+kGDk91vdM1c z6wUiCFiKIsQ83JF^O_ZFHh5SVN@r{H=T zBn}73J6$kW324EX6;etHWCPSaob#Atk*dgSEFQ=5w8(-*g zODei|4WFHUzW`CtYDoGo0!0J#XyNw+ih;o^WR#2y9*e_e4wS+;fDUG+2^0^|<;+Vl z{gfJOjfE)y>a$(Idv0h~c;?g^%H-u1>CI@2ZZ_Oh-DKUNC)mm|*P2<`=F|igm8Xjp zmE;y|W+S-(vwa2Xj8BA!7+OtBPAZyVww-W@CwqQi!NoQ}VPxfSSBl zOT{VuvkNqIBu{0UxRNS1?{Mi@6+nDBIMeI`iRs~4U!{d_m5HK;4()MbSze?=LsTof zleP&K5&o;}GO35dtu8mrdQFF?FE3|Sf8a!!tCLg?E-W^0O!;Ceh{M3b03iq7c0+HQ zLu)nnt8o<5Ay?&uuTkp(-*B0}&xvyjrnyDeNYhy7_sI4n-w4 z$*1QyDkHq4S8Bv4i-%@?t0sqsRqjqxji)8yFRR){g)dj`Ex#i6@YkyCqQb+f+$X={ zvhde;;n$z4Fv-M+kkI;8eMIU2p;4XlRUeRFfWGLLN2?8xUy#VKpUeI)NND)WkUJ(z z9UwORC9hERg1n{iAtbnJHTFmaBsi>)TGOw9RENDZtHtLfJ`|8j>9zez2~w$fop+_D zpj0YY*RPZ)l|uE_Nu?yIlw3a$nNLCasbPZ}k)M*K-SmdNq+JU9@>|1(0u=(NVWV0C zr2;g%Q5}KO0NUc0r2}-!FDndCsPR=IwIJ+a-Q3rxRgm`YbS|I5Ad%$h+~n{>A;x|% zgnNd+TnO=g1!=$Vmq(k-mp*XM@Rw3eyUH)PXZXv!rjdSd&+wP5J0tzzp2079uig2$ zmS(tVMOt(e2=>ct8|zH{@9lgj=(ahquzGb)0tKO+0a{^$-;U_yY7jSWn$Z|5=Y?oH| zXXjyRPIz#aZ~nm!VOPFNiI+(cH#7&g>muQKT_061=S6jMEkYqOnL<67B$>fX?$MJb z98aBJ>Cr$SL|e^!8wrGrWc0m51wwRPzjv%ah^}!xBkT!@@yDJ|NEs61!}moP5Ypf` z_tlg#c2PkLkJb`Kev~%nffocNO zZQN@D)dGEL{80gFL(!MxpBJbOK!YaK5U4Id%O(`7#w?&7u>evAPPmDML-m*uL=*ec zxdq~c71W1THz!n(J{ka2_1QZFY6#FH&qml}BY@s`wuF>5hSeQ;HmKCr@agA%po0o( zPWZ_4M=dYLY-_0c=DCyJRx}D~$hnEd!?Rv56ouL&u!r#R7m86&ad?K;PWBjUaU@{2 zO*(*Il^Y(qXprfntk}GUFBWDFfdluNUY+`5t!n;s<_WA-ot{2k%8)}m zGGp8S?7jQUuIhT;nwh!G&alV6E0V+Uvl+YGYs=Yv^|E9YWmYd%rOc_Jy5ib!9yf?- zHau_ROO;hQ#C{B}5HvnFF)ar)dB%KPMs`$AG~pu#*PNF!x28?gilIf{Gp|J4qSo7LZJ0?8m z)i3wT$aG*Qyk*ISUtk4CKKBhJh$>Xrx( zUGlU(90f9~?z_x`ey*aGh?YpL6*I-7xYj#Gqd;6}1_rAH4#^y~k zZ}F02NI;)|>vO%!QLfpR4mLoQ!;WKe>pE4!h2FmAkCw2koV3SN5L&ibAY60w^5@jT z@S2%D!#DFPg;Q5F^-JnC`NqrQTRaP_gL=&xb^C1+M<9!I}Z29U|(hlkD)@t6m=n&Fb z={1ouq_d~jJRSAAZP{bhGvQgwpAVOPFBqP+w&iV0OAg<7uXH#oFM)bw>M7>+io3Ib z{EPb|Z$Vy@f1b=6@7;bfi+O$3ci{zjZ-yJMpY%Vvj`IH5bzgNhJl^}ouQ&Sr+p&B2 z{dwxOyn!Dy^-p$q-G(DHH#*pPGdGGrpmQ8vyy=BXOh3R~(9X+N*;Zl&IQcfyPy(L( z0&?;Z&D}OLPvs*$b91J2j%Z%DnR#(c2+@4rFGDm3Kdc}l0h;}hD&=H`paVDy0pKy2 zIfZ2;ME=7cvcQQ6p{}z0!>Te8p64?kvK|vdW=(}HY(~U{P*oYUWs%fGRi)6@NIO(j z+HGab$AnN-nYOi?)I|H`%GSFDLQN&KEmt7aRMzZD4!^c-viySDO115*k;H^hTbZ{# z(l2T&$G0;Fj|ri+Qe+2fU@;-oR(kGeD69*#6*%#mUSw98VU7&2h*hHAvTw&`+F`I~ z!!ve{l5tUoDY%OXG$w>P%!9ikvqT+c&92A_P=~QUYDK1XOo$AD#Eek334LLMu70?i zNl11Jg}?r&jar^parYTj0f_*d2>!-Y$w`lx&w-5W^qf@M7;-Iy8}8+;B+r81qB69w zcq`*?Z-HXV>}A4;C027_FB45Hoz!c4d7EQND%`P;SxhXE(Ea;(n`1*rLM!+2HpkLQ zy|`~8p(U1#;b-k!EZq;?DK(K;mLB3m7#l)jxpAnGlp&!s`M3;icq|eMZ1^s4PGluE3ZB$?phZ`C&@sVI2e4!^A8!ih&dBjP}wdFcof2lLFK zM<-A_;+f$;kDiF0kz^;2wZ>TCVIO3f%w|q~Gvgg6J}>vv4$L9YaX0TX-W_(_9r}zh z8HFM#td2z>+{YTncx6$vkIx)yNux#4J{~?6asMGJh&$d)%8(WGI36j(eVlVVN6L`n zZascbAUyQu^T-IekKcU0P|9#0UpVoaK$>0hcnOA{udN53;W+JTEC{0P5#O7YiFAhYXBn~^yG|iQjyBm(E)iy&c!f+rNC?} zf6qurA)V)q@4M5+r4WHd{jf|R#KMLjc*9eO!216H@j6Tn#oiOwXh6GmP zLZl`V*q#fKnn+-+E@aA9G_-BEhv8E&iN0s`wY_h`k$l!`LQ z{I31VKwIX0$1erqGWWS^p0ow(nj7U03)E$1MyZEM1gD08yzqF0;=^NG)G!UBm7!KC zA&}JO>u43(0}$0-tr#_xmkI78vo}`O$^N6wzoeO0;}r9Gaw3_s@oEP37Eg=a7OxCR z9P&qldrw(?rc{WLnq>;#MHoBnV9VWZk%qr-Y;vN-DR=vo@7Kdja z$1xqgh4ImvGbULzk)B}A-gn6=Q4yRHDh_RdYWEYxg6(S#7gBu4NE>I8g(G3QrK$)m zm4G(KQq?5sq9lM1rl|;9Dh1%aG}VDtof0Z7t1fL87g6oZQ|YRynr1#sSH~iU#JpNq z4WYi6%?~}AV`^on(()4$<{Vn=7BN>!D|YCh`7qqHxmOi7HOr`G`lpC+GOv|UJ*W{(cy3w60*)s* zteI6fytQayb=3?jt5!vJ!7E!%IhNoZyRBV8)eyYHLSWLx&8&60kXiJjUBR4MU`Ls) z6;!FH?FFqw(6h|UA+B$#H#BW4s>9SX9AvL_CFQ#jvFB=)RRA*tI`C-<(;alhNz2P`+9H=2t$dmtyLPR%~U6mb`%4DruUuT ziO6cGmZ+WH)`n^m*M`u9d9JbALA5C^fj;~7)^%mJPEtio;Fuk6?g*)l)Hj}n7enfC z{d}T|X9q`i6Sb%e8a?FS17}t9h`HmCmoXsTKb(m7V-r=FX@WSH7vD@3i@>lLuV!;~ zftOCa%am`SY7p~~U~^(|2sMvC3CeyP>Mmw-3pG(4F^MhJ9-1F$bmmk`RftwYDxG($ zrCQ2el2T_@w^r;UB(=_5YOUD9iAHAWRcfQk@`T9yVS2Yyll2iByg8T^;6=4pcXBir zR8rdC0x+G-@YbMXMs)yoHo-wNYwVEsVBYGguF$kWxi<^Csq!>!Qfn!&lgNP` zX#B%VI+T#uC>;7VbxwwrZu;bav+a)Vip`+{M1&7^R}ZV%-jVJqmr26@7uFSwliwp; zXr8{}sDK&21pH`#!gw#KC+rT*2rO(9>ZOde&@o%mRT*=2haKa^_EtN2dngJH$FBe` zKh^xyN4=nzR8omP&E|L;`l={C0|Dr4Z$HHIa<8z8QGp})E=AfCC41N_R! zQbyeGS4NhS@PH^40iw}Y9#BiAEowon9#lOAL@j8|gKC?A$WWenNR1&KB7nv?=n#r@ z2qzS4#@(-;lbWa!z4oyBOF&SG%$oy+Py%S1o9_lH)}#aI$uZ>ysew`%ly0+NkZMgX z!2p_dFp8DqW~*?K>sco45oLS~uYW`o0CHE50$_?Q)>+}I0oOEmRJ4EqD(hy$ql#7I zKnS#TFLAKS;_ZacGK>ID+#AWJ%5W89It@`ATcAL*ga|3jY}O1>8)TlK^Q?)Hw0kZ>V}hjea^l-9}UAZ5n)%y6|^dIl50Yx5Ymc4?h3J@e!U z#dZ$Q=;jF7K$?^{>2XzwPgwvx59Y%sRD0s2lvG>Ok_F4*^+w|BOeF4=J>Ct_~Fq_nlc)P4#+>Qoq?WXVhkUj`jr? z%D{=E75fl49GbMKFnFgrm^;U)a_SRr@ECO;9~@LvJ{cz>khDoJG+sTe^!AA2;z2&i zS;h^rd(>IN`5ipy{J4XMJD;=G*v}FJdbOpsSgCi^EhIinwK1{t)V+jq6p7bfRrS5M=c)BvodlzKXujZq1<&I7DveGM2_7Kh;-nUbx1MTX z7L5Ttt>UYo8ehTQms7{6szArrxldMAetJ#Sp-xCup-xE0YqL<@udYLkFxkx9q2tW{ z#j2r6SftiaPbgk?F9M=F1YwV4vvsjLf3F|RCFm#7)YdoyE&>Rk|bpNtcBIfrIW4PRTBN)$xSD3h~N4OTyynJd)>YKg1s z_zqZe6KHkdcr0Yzov6}GuM$pzSvSKj8&3Qt);#yFYT}P{=v}o@Z;S?JIctZLY3kQ? znwaye)EugSh@Z4tmAxJDAFL5Af_22WwW<_Ni2_un-dZ(UKs+DY)~e%b@@ zhKEJBqOhW=o2OnisN;7b{~9C)MHltUwTi?)^EhAXb8tO7y^a zcaV=VnvsCEl4k05m1+iisxZw%3`$R>(L5+XOTw-I*w;E_nf4#3baTv8?Co^ulqbEf zR!D1H#YgX}d&=Q%IOsLS))2DOA%{KZ5VF%bEGHZi!*_n5UX|8(?9YE7cCdqrkqKN9 zrP?9AzUu}xR(}N!77X%cnvIp*SaWNGT1WWD6SZlhdVzZ5v($Ezun9U#-o#CiRVT%$ zFKpVZ9uyE~Ug<-%fVc?hm_kQC%+j<2M_vK#HkzjV*N3Wt1U1QF03jtiu?VPi$@1gBJQqgq1vR$zUjJ7kpZAxJ?c%9S0 z%*?a3d3gs|-0yfxcc{)RsK7Dh>5tSf#v{3=44Rte@(#C~xw>0DX#H8l>%K?z%NH6u z_A1U`VWIKVK9xz+VWF{bpO6y^jW6;`aZ_&X^LZ~Sad+((yMUr8X5xNztP(SR-U^QI zRf6M;R96*4oA z`fX7UI)7AE5gby)PGY2`Ax4_PICL;Z$~h^qn8;`D{zUwFv6#tc7JZ`nOaI^kHGxmn zeFB0{(~S63)fNzaf$KgMCLfDoI}`nx3Q1`WfcJdnBeXbxGd~lbL2Rf5fV)5QwU3ej zy2pIlC#8hf}n@`Nt#dF9V2p=m{`WsCovP7GBbq>e&bk z$HIHHcK#SDGo)rxu1KFGz{H>K^I-OP9)LR(HDmpjIp~G1UB3fXn z4>_k+`b?_C_o@$d%uH(9_d*sd@YjAXS}w;oSl`ks5o5$Rmj-$f*^KCwm7f0&`9i%EOe;m1!-?*rHON)PS@Hpb&l`pB6-QUuz^s$!d zy+>sk*pxor-Is4y`yabgUIz^! z$|T-YA5uB$B9Popx$D->7?aczf?F$=$9mQOR5kO}{Gopf`(-tM*59hSBK3tfN#|O* zku3TmocwKW+!A|>_H9mk>v?@0Q#~PVrqrCjEk9Sn+)x&)wan+uEty0 z`bKfk9pKnxdQ}2eW0p{OZk|Z6*wx18rfJY({>kTNbI=OY2!wyrBhhLlAX40_M2ig< za)y~760O5hie}CBBmx!$oVXcmK}4*{`OQf-qY|y6 zrg0&QJ?(KMqK+2wyFi`c^;B!TjE4?~N@*5LyEt+<%uBPFHOHZ0GdJCuBy~|B%}TfS z2#5lye__iA2m;CI3@gG*P#zu3ur5g{%A=i`){g?BJo2)va{{6~T3W>VQ_qLQ9CFv0 z!dHML9x7^GCu%`O{9rNbO`ja`40$tw2>8^qW9!{@Zo2n#juod>*t=EAYNBbAp)qW6 zGB}hV5iixdzr6MNZLPfK6|J@^>Z4dI7Jb)vQ3n}Ls&}xG^*WzO^fQdCYH>h?{0!c% zs#Z)edkY~nUVP8gQ(8r@+{vGgiTC<9JV&il27bxtJ#?K+{VgF?5|uux1Z z$euRmYgz20MfEho9o&tDEO)GJ#_fO!;dK;mNo}jSs)(8lt%y|02`b{Ujb)du6=&yC z74n6p*A=>>xV`C6*J2fbBKPLCx)ytyAS?!q?o3@vQej<^SJ&%V>|b^14Ari0vA5GD z9zMCg)r7XsC9e2ceTx$lT;k!Q8~ANehuz#jjyf3I0LC};+X6j$-5Of8S**IG#LjDM zu?gf7LGEcRY{n%^yI`(A52VNex&9)MBA4e{b;zaTqA!c~y`Y)(0489%s3dvd6>OmN zqA2iALY7}CZ+H_+yzk&o_d48ZrSiVALmkxCXVeAnax<$s(}HZ#9shU!IFhjQ?^vTZ zx~27`FdyCaMHVA8Wu$oILa+rx7tOEifhw0hTdR9Q-Fy4TOIHe_&uHUXL!;u1MFodF8rUwP?2}7Y%kRBa|e&6@&X{ zrgXDd4~iiT_m^%$z%iIRU_#xkH)Z0;QLc8k7OLmGnLVsi>}e`~F@#r;Vb;FqEVxO;%bUd$*uTl)uy^oXLfm3_Zo z86`lE`~AweJzw2#?Xzabn^`@q6!US=jYFS9j`{Hc>t&ibQtadht+#1(RwwH}WU)cb z>g4H%tTs}LqPEV%B6&G*arR*uox>`{2Ffzo&^;JL8yX2(WQ3w=Lkogo z43h^V=`=)43qtN!jCfk3QI45QgRB#3x3~Kd>p4CV;3D?!8Elnjav|TaH))7fE&`*D zuwke*ktUu(l*bRZZVHGfPkKz0oJ3-0%O11XEtyCtZ#Y6wl1M23ZiEQ7 zL}F*pJ#KZ8u5hwv9=GZUi0rKN6F!LI^`R$(NE3;ht$V`am}??&v!C-pH2A8GwBC@e z;6QlajI`!5D@;V!yf^kKE0OV081P}9wyN^_3ln=k@{H(mg(=i=13*d@NKFf=$Fg&p z6zDiy?ApSFpqisC_R%NO;re5=Rg9b&iFmlgnK5po1I~Z6%ZlI$4am=)7xgp|lS!7Ao9NfZWRmKWtal?bLksf4 z3!-`?V&;T*a6DJcH?MeCXrqYe4TG%FZsT?UE^ z&af^^aaov3>`Z?u<)C)TEGs!uyF9?vX6KJx0pQ%Q1-{TXye%(Tm3@ih{W{mWgInc!0A*kTLK|N-Uf@I0`5R&EoY|dN?u5F*Cjei{;aK)|{xh zfK=pn+a{>eX6`E%dxz1@diQ**p1a<*qQ)priC8qkj`CK`w_4^a#A<<6PtEokEU>Qg zOi_p}TIr;ldlp%v)o0$3Mb>z(j*R%rB@kU4{<_5pUMybWw=8q?bveb%iK*UGODy)b zLn02~6n!piy-i$Y_B1-Kv@4RX43c^)ExJVsLG zW!_q2tqVfTT-JD|0IqTPT5Az8cTi2ej65reXUQ?Jn(tY^(>z!;t-a3rUO+@;+4a^S z0g*{AST7=!ZQ<6QRVdOIE^*NN)*<5OLFAI8PDOEAM9&Yb<@$sMzcE_5=4xNiP-|?k ze&G$rxGY`bzJR_+yiNf=`6_1hCTjuB8~u)*H;bHMOVs+%`dClLR2R%pz51cmD-m}F zeAmF4W~$JhZyZyt1<=qVJMCmMWsB8K|DnarjwW>Yz{EPHW+O<<09uVTL$_KdXehMZ zI&8C^qD8aq22lfWMsBl)sXbnw?N%$EGsdp+b_jO-uxVk?!0o!`shw6eaB{BPX-V)A zR_GnyWp!t4ap<|;ZV@pQdiIX)w&Ivc1(1rp@Aq1rBGr++n(epb+FXDX?v)3uzi5^e zefIJWM)dIjiKvebS)WKT($|{Nb|Lfr$D*4BNKQo^wi-$mlv8aF3!4a#+WpL7IeY=q z+_oOJvS@E9?o4|dK&BC&O_66J$pj+FvPZ0KdNtVdXcsr|${hu6M7RZ%dHp}JCh@8m zXTN-EJwa9qxo$z>DgdtUc`A|@@3Nhu#odY|`SNGNF)20Pn|aJ?8tD*E-B-u0K{QYD z=hC!Xo+l;9!w(suD4OR>pIbAmt8i)ORY-rK>pP2fXooI3na(Gy8#HIshq``Y-Jrur z>=e5+N4D!!^xmUh0m>j;ea&~S0R_}F7fxE0qoyQ)nW)B?HE&uOUcE2juuz{!?p?pK z#tH6`)tvsyS}7p18uPU^(iRxkoc^s8Nq!Izbh*mUr+6OA;aRXiYlr z(*@v%=pq{F0^EA&gqM^fTj&C}p~400asu)I^7=!IsF2C{(9Q6gT(n9?CSsbLTK!%LK9^Le&3?wVP-xi82!) zM36Yo^nJ-rHyy89chItvNadP-)jBF5ZtK8n5sfs71l59{tRJKpCpP0}Ya4fq2OK7r z9D>Nq06_T2Uqt97kv1Cjt9XQx=%}Cm)v8Pzn}pgZF35m`s*o8n((P>?UGG*i+kdli zAdX5GBH$SkipyqrS=TL(DH6FJ$YR;q-+#BBSL3`fe?;UrZph&q)=Zi!pWA^qt+N6m z^1J_Otrrl9rtn{)6VVwpseg-%;W&NzEuno5xx9YM;w)1-pmVZqmcev`#S~LEizg1# z=U6tosyMjvo@GZS1!B=_Yun=D;h_9HZU3zHd(#|y5U&#)s&k|4qBK)B%gRRCtU9n+ zHYLhlBBi*F+R--Wy3id1GcDR4Top--?r$Jbh8CT3LOStP6$wZFgJDI{ZdHo$N5rGh zImYJr9h+;f#Mtasi6WkSD#mUq6F{C^Db{8d9Ys8OM66w1O3`*$6Kk_oA4Rsqjr>xy zrfbLfU7_vpT%655DZ1iej>h?2p(i95?{|fkbhmiF6n%4Z;_bU+T-5B(#@lQHMqwJh zX%Mi7N-6s0)(33%)JEYw9pfa}rKJ=V`Yo{uM!?D~AXiGO*U3)&KsW!J~g$@W;Oj)&}-6q_x1iiw*= zDfT^5ifrqz6uT(xFkQ%_9ex9L*ufnJ-i@p$l|@ntv7Q*R|JoGt`$Xk!SRtFkkuhYf z&MhSS&mNHvp;U%|JtWQs&kAMh#HA_}&qE~h5J@rwdP?F_{XTJTtESpTDP7LFT!Hr1{qAZ~b8nqP_= z-Y(5A#SNdBX0wBuuJV~JX?Db$gd3ijZdWSHbAt`11;)a2Npn;vou`&S%Y&&S0Sr&~ z`$7U(k?t=H2!J-=W`V@HDg;4OTo$(tM9IQ1SonLoKRgBtI~DdjL|boKVVh-T4BC3$ zyM^s>5o$qWuTEw@wV<&#ILm%c@K7AUKeObp#$dS63l*`&9*YT;gyLRB?O&vJDFAyG zv)Qc~gDLPvXWJ8`v*1h92m!c$fb$-Q_RO zD~~6v`FHtaLTCVH7PrM{Dh?;(jS@0oagsh&OWJ2>h~lKD6fI@5#ZjE}%e2zA7|k)E ziZFxXW$a-xp-Ry6f--jH2%;)O@n>c2hora)fX&OvF^&mU1@N(QHuLb9P&ELrmGiN9 z2Y_SC+l{1cbpUslwTZstI7L3U*7WTnoU373?PktPNmJMZ30ubpY&F zQP@XJs4jquEBZ8E55Qv;?V@Fv66^ninCdf1<06FE04f)$dz1chs_L348+K$7=a& z{es%p@+Wu_VDC&VJ4s1{FX4x|b?mkReueeB*Rc->{58T=>)LAs{s!TTb?u)8K85i4 zdUgwePb1u@zFl45ZxMc`zWuPk-ywXpzTKj z7EGT8cBbshS*i){gR>^&sg!7xAm^~ZWep&5&j|e)z62z&wIFLV7FUqrZl$ZjX)mk?eava3NmLu#WC?|qNW0ni`{aj$GAyH;c<6xa`S_G_btrn>mGL126Py4d1p z3{tS;bXR}gD6vm=6Qv_aDw^G0L_v_8uh+WU6Cy)_$o59xYfB(2h`G&XK~FnRCWo`N@>mfD=f+z-W_74>~!_oG{VRi{=izu}+v^a#+j$vc7AJN~%+u=Ir9iIz{;r36G{Z`2d^d;!r&Dmqg3pK&*H zr2U@0g0C?`Qeg=*=t-M%chOPojuPFB^Kl!GvMWMMjm!tJ-&LaoGn(?Fz8q!u zvVKVn_sK4T(Y9Ex|5LU+M}~PaZ$B+M2HSO4pSG(}*KF5Sc*X~@>j&~dvN+Bbf1vmY33hoooRY;dgg6%hGD))?RTLH;mkjD5G1B7fLC#=ciT-0b3G zMayRUt@Bt>5ThvevumvVtW-w!&~Y5tIdqc9fFt)nqFnlk!tf8Btt9YurJ2vh`yHcl zA3ed|Xsw0FHU#~=6BBHC_6U4iUe0rNCX+J93hsK|ewqel-`4);Z8r1Cy=68`wD(CV z;%)jQdyas>Sxu!EME&Jp-)Aq_J){)zR(G=9L_oyb^OJ23l2N43oSiIYFbDW5OcC}K zO?K}+Q|x!7E#fV9s(nMBaBsV+(8Y{;(e6w1i*)wwi#B`Ln9d%VW^{@kgZUsXYVmYCi>}aUH0DXquoD-WRky4{ZZ<{DfPh4 z?S-!hYB(_oa@zZZhc1sbTh>9&`djni(!)Fd?io^eZb@mc%&T@`?wO)M3q*1Mcggn7 zYe^BmTI423L(}Uudm-%^Mtq!wqPugjr`|%lKh2ZlJWChaLj=S<%U&eMj6*y_7TM1* zUJ@ut@7Kk4d-kQ%TZyLK8}?>tjT@HwrhN}N%o4<5mTZzPDZE4k@vb-RB2pF4^ZGaK z3;G2Ye1MoD?Lmrk7k{@*u|`gosrR<9S>CaS-nIwODWx4F71%=mGiH?F%&)&~zpvJs z)ywQWS~?~x4O%Xoj=Okyxv&(@!?9NgXX6f9t*~FUZpNBoec(nfdQQ!PgLbmlZlyhq zX9me~-kEpoVvG<@mkX@2pP*Io&Dm+IM85O=_m->e5j1DH{|+)5-XVjBZ_K+botCE0 zWwvl&|={@@( zEg5e$S?g?e81nqKuM^S5^J}!;9xu~Hob6q2_Y@GxyozUU6c81z$zXZo-Qdh-DkfmZSka!-!G~Pdy`8auqP0qlQ)?T zXN>7EMh`J%4%#`^IEQB)IaMFil960T91{JI$+h6e_67@>#nw;lz7RUHU!jV~>yI23 zhb?%bVf^$X_7R$nO&ZS6M}${E8YYzH9JM=HJGA*Y4^RcHrL{SA)ZXahdC4at6B*Ax zeqxvTcbp}bISZ^N*{EeUhwXcQYWGts&6ZC^`@*^P_{=UNlfk)7{mkwUH?FRHX0P|B z|IRUgf>?#}eXk$0Td0L5blm0?A?)h(@qg5dT&!xOmf?{1nk}E(&HPT|Psjmcoa9%& zi7zCK@aqM>_z#^@y&mTL7j}kUIsW8-uUzk(T`*V}9w-VG2$Hi9rycj@e`vG^m)FL$ z|JruU%xiX>ZUu><=JJ1#WV*$xg^@*Deu+fe@fH$sj~ z4lkY(s$y~|f7;(4WOMhPwoB1|+Ytr=_qIrq*c4Y-aoT=aUBroZF|T}U&+unj?YsZ5 z%5k(xNRTX{;0=4r$yWKPrGTU1a4QAg!4D{iYZUz_=1A{Rp;srmq0(mSRhuJ!|GJ+` zc`|WlZGP|%F>v46|1cTZRM@BdP3?K^zgMpN{cV-+{r>-2xnQuwKi6S;{P4eMl>EPJ zWL;I}@OgWnX@1@=;-mkO^L9Ve|8u*iDSyFk;s5;fh5tTsw~M!}?Wv3Zy>iz}w^bf> z>Hk6HColi|%I5irDkZ#Vc^tk3(a3bYVz-PO8|0JWH5HO?BjkNo>_LjjsrvthoU;D~ zqyLF2Os#A7V=2v0o&xaMmt&WxDC+k7IUokW2qKtg%jP3p}l(f3iFI*go;o zzhCBmY1}HYw9GQHaP$AFmoopq^b-HS?&U*M__}?OR*s@7@Vosb?G%fupMMw2mo=-( ze~2khnxA*y9}zDX`BhN8cZ-^Pj7bDVdN~DDzO)(>GieXF_Bh1d5qQ&x) zDc5e=*YpSUt^-_;;H31pzw8Rk9MNQN^tauWX38e}!oS5VW0U>J-!|Vu&1aYy?1pBP?cstryU6X(Wr|v}RvQ8p-1R zS}&4PWWE7M{~;hEBGJ{y1w<9|nycBnkVXbz#VE~wj5G=d4v5n2q%xWio1-*`JJKi| zcrD7G2D$`Zj`jya({_H0o+@q8|5G(qvm%^EE`g1)x<)xX9BC5v%b_=iK}uk3ECugc z zlt0}yUbmO2VGwXlypKPO`o;wGol=THz^(yZPe61i&JSqzgQQW=?@~Y)lTvgjrY7i$ z0%Fv+b%N%kvoyL4xGh1m;~))_IZYs_IRcc14n?nRQ2)Rrh1qS5lJtYT=j<(Bm8|De z&+IMklp>R4Z}ICXvghn5Ze2*?dYPH*CBAPAKGNcBaDnTuig?i5%Ica<-2dq{`|!LRUeeN|U46A|gMwaf%DQ2Z;#l7MJ-2DMz_q zab1z0ZpoyZHt=){xP!qw&LqTmB{aKIgXFX2Ce&4&};+->9xB975vKCP?}RwvpF2Z&r+C474>=PsyKj8SJE8?ECJy0 zO1h4KB>^m4SvM506o7py>%Ib(25^66&HlY$s0@G$t7taqgQ2nj)~o9GTn@mwRW--6 zgBY?lZZ$nnx`N2Gd8(Q|DquwbyWF7{3kcC=qpJIDF}OS|AH?AD>FT`kquC4wIeVR-rN+CDxoynLm$ zk4p?Me^*DJlg==_{7GHS22?PF;bmP<4skF9;bn7wJu#iNF*?{=2chOJIs2x69R4 z1*RDClw8em(_n~V$QN?`2~iBWNk})B`V>QcDWo~-7YtDh`Ep2ilyZt8w`$^#Pch_| zo9M<;jxl8OZ4=!|U5W;P~aHx}}s;;P_Hge>@5tH^0-L4+W0r-RZ9n1IOn4 zojUgpWZOZC69Z3)&W_Jc&2E!e2Y%ph1ICZd^46NO5rQF%5}U7E`zxdfaZDQ@#t5;g zkq={l*z|7W?-a#{KWw9m$_ywz{C$3Xj1PMS+v?qs2~dFeOgr6E8eo9fYt>#`kqQ_g zHr+aC&YuW|t{}X+gFnJmgimzPcS{G?5U$u!KQHi42ye=Ve@3|VJ-UyS|AMf0kLDzU zVCYwb3wP2Sp$>+ALpZmS?kx4MBfO}St|IX72!GMZKa77MJgBqZ{|$tXb@u0f6XD8T z{Qmz$xN{dhUHbbA;mck8_5F=-T2~*#w-A1!tDYdVI}Rio&@SX5XQ#lI+H&Cr{y52% zz3o#J!O(crge!K_MJc8c3{9YRiJjmNyzrWAhIG^S%N(A?y5DruRf}<+K``_jj}l1y zLc!mBI55GWN_Ra)8ad)y78%g9RaX0f5Z5DqG*CV?Q(sxN^bbKxyB&%na?%_e2lQ`I=Tlo35Ydh)K^PF04etw+`pNID z+!&%aIq#*a#DA9p9%X(T;#M*3hv^-@wVgR!cc$Uk+J0)dSaWP`kA6%n8IH63^q78H zDx+RMa)cfsAnNtMj?ljfh&JXgkL%?Eq9^<9C-hJOF)mPir05=OY(G2FFU3{=HB#4< z%4lOYcv7$*Pggl!d{QhZ`ox_%_@tO>@ubZsjnXxwE#?@s8>KnRM)-vPw4?l?VJ0I<|ibOPT=XVWD^{%U#Cu)ST>H<69vTR3q&2^Wm$fItg_n2 z0n9~Dflues7|lyQkAxb87t?}FT->waKSOE%`?yGNJ1=fFu2;Cf48TQ$#`BTST`T{%0I75 zv4KICIwtCoG$vp0`Fx_-GW@n=^GRZS()}JYXOdnam2rYCU(j;}L}EDqg77JRTk?^~ zLe+e^=j+LG1On`Em?AnO-|N{k#czwm&~mCUHNMv~WvVFke6Od}i?W0Kp5)pW{kE8J zQe&E6F+jKJ$4(RGMDIzOAE)W(D2@uIHwd4E#58m5J)M>j3qU;NG{?g2v$%N8J_R<& z-6*Ct2I(2ojQFq7fJ3?ZBVC9ym`)1NIS zJ^eM)pDlVQ?w;ju2O4vGXXzVsZeg}&|7=~I`sHawhke~0336aqOlxLXtk=heY!`hb;8@i&;w+(Zhc#i zmT}Q)ZNAL!3a!>j%ls1#R;#(TOm~sWXq5S$2aZ>vNY@7yHXin-4gvdDU zxI*;fK!}Xf7xT+0-}&PeV*7y`2ld&kmGJd0vc-Vx%CFWHP4+v!FA2Hu_|^WY#od_o zj(=*ALbBKBL8jNcqB93VWZzDDS67fZl6|}RU0qLLvTv>YB@-hU;OTDkwh(KE;r=pYVZr9|9q=_FH_Q zIio!gB5Qx)2l`1tGgK>VWUq!WarP#hsn-AxlunQ^~uifvq^K_c_2h~{*+CAd$RLC-sGPdvhxdW z_E$u9{+!Kzd$RMlZ1&reov%Oi+f$x+^AG*@lqbILL(O*z0+c0gtSx%J%nz-6@9iyM zT&W%TcLTk{TlLeDXh>omAHK~oN6x^5Aw#x{qRtT;_YVYU0IwcYhK(z{*Dd7)GKnt-U1 zC!W?nL@)p@bk91YgAo{Yrp$9bhee&K-8qR)QKGo{?VRr)235!F`@J3$84JQX-j6@% zvyskF+4=l}2tam$SG(v7PmJqyyC~8lNO7IH7yZhp>|BA$<=7Di$_^kl2Xu2tu}r)x zRFo0RH=w{@fZ9*(OMdHY0B2tEhspuayCimUkhGs`m-I=&31~mwvCH~a1jC^Ic;Ec2 zM@5!}`cJ=KwY=mIM7MzV#BX{^q#Tu**x$i1CH;Xe;-&tf+eKhhMuyzb8>P5BfHiLF z2?C-rvh}8(DIh8%J^s`S1w>`U{>v`~1KwNkmyU{H7*q`J-CMeRWGL{Bulv>+5dlfZ zu$+Na7>S@`z=?cunF|yiLlh3KBBW3FI$cywj8HhJ9^OsM`99JK`phqC=YS%wK@gP> z=q3L$T1~!?{Jrb2_C;QFuSS%!+?GXvLgM`p>y(ecppkf43C<^x5kMvJ{s=l1BdbDB zdX<9CFlmlD$?}5E`vRg)@<_77N(gz<&4FZxEi-bMdv=N=&)fv*5>~@PPDx^L;xT`u zkP~reky7$yAt&M_B&DQEsuOXPl2Y2tIFoZgVr_!DNyxiI(5(j5E97(NBneBTr91f1wrl5O9rn6gr9S2Ew z&74yB96^*x%5t_6^Td3<6Il)$_ngI-Uc^~K$l~W1cNK9sWW{eOM;CQCvN?jkm2;eU85_M2cjh?L z)M0$1x~RFD@C{HNmJV!mTQT}Qv=XC*5 ze%xK!N$0I$t9)Qthcgocgs+oj9Zn?YH#hDtCzQxm`L1#f`xe<()Jc7==Qy3Qj7#EEfke#|s!{a6Q%0yj9T|LrcT=LMm2r{ypG0`hfK*VV^?#&P%n93S95Y0MVN>YRo!9s$YT9s zb%*1*oQTn*hQqOHeyVI^4Tl5Ad?)^94QCL|itkPgttlwsyYD+{I_%=&r^-ULoC-8Y zy8BN19_?RYAaM$_j^QM?C?qTI{aQ{x3)F|qx(>h3jyJ#)>p7fUz!!o#)e~mK4_GX& z=ZvQr@%`_L^_@2a#1rsEeP=Lft&um;qeJ`_xnrt+50551*1*|i9n$zwoHC|wLx*!C zA-~;&Z0~`}Jr|1?kHR_UGV?zU8P5Gwn_n9{+iC9*qg!%?M=?f!%XPjJBmvQx??Q4` z7^6j+I1Qu}XV|}q^O1mfMyoe>kH87{q`iE!Ut&N2aUx{1yGJw?-|e{+XjCrki~nmZiW zW&%jR+b0j4ZnwLgsn!yWUv~E2jV}tH`*Hf*K6vef=z%#7i6lnY=PmqBaR%*M3d>`J z&1mV2)+cZORK-1JOe?1vb%|FIyjBi7;`k~;oz@O#Oz{1W-mRT!po~f?y9Yc2zVeMi z6CZmi-PU=6*3S1~-fHWxJAm)Q{My#3Ev1NxTJ41L`0=}E+c{53DehcUdzm%ghXGU+ zGw^|g4rYCO$dQ28kW_f)@@((V_RdBgzY>fOAL`06r#d>F)B>;OJyDN*t=1WFeZjs(l z{XH^8w9>SZ|ED&5nBcW{TErXIhlxC)V)AuJ~0xsUiz%waVc{2Y$uz znN_mGOvo$qOHobuDj!4=Nm%W-MG|Se+TpASzSy;RwKGAcfz(lHjdQ1fNF7hFai$0e z)M0{aMNf*R$i%~IotLE)b%MA&r;dO?8m3L2^NE0H29j(}RX*HEi1Z!d2jD5h(rgec_q>1&gc?oQGN2sb=6yR|zKY9(>jfzSa|K zu72QfMlo`^&<4losg8V=qtOH%Yi4G;Q6_q$!|%P}WevFf@idLhmk4TZa@hFb%NqC+ zapY#w)lJSQJwNg&6MhxNTejI*!4!!Cu;&)1I%^!vR_ASXIMT{&)!yd(Oe1MzJ#)8< zBE`4rhHZB;3E}YJ4mt|($~_=F&E#!&?vPd}FRp9{O#e=J zUjp2+*Xcorih{RrtWwOC-SD(>lYP#|(gxP(W$t&%v!?>xc5MzioCeBnyXOxIZL{a@ zlY`E6!T?<{0%njAvPt(T=wBT|Gix=z`9a_Dq;dEO@S-0(`(;=>o5l5Zvr`ouXRlfcS% zed?T|Nnp}(<{|svLYcXhHi~JC!815R5SgA^C=CEB75K$qCYXGTm6O8l6q!Nr%#G1#+obKFLVjnT5OZZw8 zHNL`HM zZ24Iq3#dB4z1X#YkzB{}P3TuOj^Umz*xXics=z zQ0!2X<*NuU{_Qk^1YiV-(!j5)@D66QNm>h^Q2P0AzcG?s<}Eom@#MPbbxRB``kL#y z%C2~nIa?x6xu42NsFTdHTxPeNE#cU1e|TrAnGKowL3s6qfW9RA4Hv` ztm7V&QgqBlyKXB1(J_0U>wYdE>ZgsP+zSGtW?CcKtr0;UYNo?u+~1@a{j$Sj-B|*n zVj75ZQzEs|FJ05H zFe`%Kx{e30D@YkXDiEC$PbMyBIrT_&AEX)c#nt_(Zb#_>PWeB2fLWs7*3HPy?*X|{ z>ooU8a?{FfR`^IEKLb}5o=dN`1FQr)T~Nr+CDuuIC(4kheD6tjyU36rl3+-P^nkw| zCoK=rK`0{{u2%8Fkowycc3Fp_?;4r~g z|0}O@F}D`0b@0Ha_ehRgh^;_+)YF?)FZxnY_kz2ynmNH%@XI)%*EaxObx=}}K}vz*Hwnj{jOBg?xx zrB4)`%__L8#UzpQ^^Xd|qmsz^`e;QrO)BFaPR|E1ytJyKdl53DUajP|V$9)}Ev{5{ zTkr8iT1{L%0t=#&E2LyIL9p zrF%1Ly7Hz4y~bd6*K$uvG4kq_wT1mA5U-w6#|M#wAFAtvs8!un&j)d(CF{GtNLT1w zDBi#w%o~+J*-WoAbia{eWY*6%avveqm5~3M3SYG!@ECkDGPkk&xO$(-vgdbk_~ta2 z;f>t~e3I;(>#`}sBnkJN`#3+Ps6t~+pFQvm2@sXty@4S&mPrfWym+Rm%gKt2<;zXo zmt{hzI?TM&<%}AB)_iU=m(2@C@}XwJkQm7g?s8eiGm_We} zxDCgT-|c=WAX3x4E!^IM2*5FrBs?}QS)~a?P-k1X4@(6=Gtz7*fG0RUJ3;*U8KDHz z_jhNM$sOV*7`K%>*u7cSO1|wIU3Z#seSkwklTD&59?fTqT}-P|@V zd*@iUOKt121@C9z7Qm-{n1d`x~)qsv|Dz&t%#PQ2_XRl zrI;(kU=+}bQ6Z*WN_drb3-mz?ttk8A9N3FHW)XJSn;1QuT?F+S1tf-TL@|z8D`5xcYB9=< z98cuD#kgW*Hj$G`FiMy*z%gvJ_QAP1#nlwp8_ zyGfP7Q-%|Ci|Hf2gfa|Bkl8>fUa>dk+A+vgu3tBXVpsFtCR@zM>Bw--mZ5;sFOPW> zmql369fo*a?aIpL3qyF?2E!+RO$dn#4&T9Mlw*^%GPvn4$66x^+_>Qij8(Iv^7+Ok z9_uon-(7;qHcElUv@Qvs%Y8XT)cB>$zOoYPoik>q;~n__yfRY`4)YDO7-^Dg1dRWO%mk8p;YzE~ zWUY+mu2&lZRWIE18uZ8n#S16m%I`V8_-Idw*v4ykY$SqL?P)CS+9T*p`fIrRQ7tT) z5yu)60)0W$vYAR!5)`yin|kyluvTN03vrPQ5z4-)bn=d}it za6{z-&bc;e1XFTc%h@>B*_;BVz3uCWAVm*s>$ojTT$8Mb!H~|w#n>bGLCd+A?esyy$Z_o74+R z9>}$uu@2Tu3+z6&6*)fNK6mam?AC<$v=XdzojI;AvpH?_5cU_PxQ}ip2%Ox@MK+|I zFP+O&cjp)QRF{v{ zi`>em9oX7}Pjtoe#S1m{JM2>FlP^1<)e!P|`K9u2A_@H($F~QAzJB-e9%Sp|vgqY# z#ddjl7C+6QqI?QfvjkcbGQZ~Y?@CEZZt`2MN6O8U<=k>nE+b+KckzCccWUA8*pCn7 ziE804Y{N@(kR^K-O9xIPK$TRaj2$l{=eqjo!G+GoZi=*c`~YV8T(|51W-CnN75e%h zj^4LI%MY3I)SGDUA=_QOiHOesZQSs{2}Yi4v)^0hBq|sWZWs6iN>9*yGQcLyM4;^ zzB)W6oyHa!j5<8JPebjh>hPF+2Km;?Cogse*NxWpNGv9#BFFXP76UK1dYZ*=bV;#up=5_#4I(>PM((Ajpu8wOjQGW$$& zL6SU__8GW?z{bz}Y?C2=u;hM2EfCoFM!)wWHaczT_ol$G@t=M>7ZBJu=OXsnsMzLo z=b{}V2y9$@32Fj`Bzb7Rgb%GVfBCRr08bdnsIhUtTO3A>zYLfXhJN`l=q)Ux#^|7d zYDfzA9fO$n{fL|K Date: Wed, 18 Feb 2026 17:27:02 +0100 Subject: [PATCH 003/230] feat: add user-specific journey advancement and status tracking --- cmd/lunogram/main.go | 2 +- internal/cluster/scheduler/scheduler.go | 2 +- .../http/controllers/v1/client/controller.go | 4 +- internal/http/controllers/v1/http.go | 8 +- .../controllers/v1/management/controller.go | 6 +- .../controllers/v1/management/journeys.go | 47 ++++++- .../v1/management/journeys_test.go | 10 +- .../v1/management/oapi/resources.yml | 58 ++++++++ internal/http/sse/sse.go | 126 ++++++++++++++++++ internal/journeys/link.go | 2 +- internal/journeys/link_test.go | 2 +- internal/pubsub/consumer/bootstrap.go | 8 ++ internal/pubsub/consumer/consumer.go | 15 ++- internal/pubsub/consumer/events.go | 2 +- internal/pubsub/consumer/journeys.go | 2 +- internal/pubsub/schemas/events.go | 4 +- 16 files changed, 269 insertions(+), 29 deletions(-) create mode 100644 internal/http/sse/sse.go diff --git a/cmd/lunogram/main.go b/cmd/lunogram/main.go index 6e886536..a18c5247 100644 --- a/cmd/lunogram/main.go +++ b/cmd/lunogram/main.go @@ -125,7 +125,7 @@ func run() error { logger.Info("starting http server") - server, err := v1.NewServer(ctx, logger, conf, managementDB, bucket, pub, registry) + server, err := v1.NewServer(ctx, logger, conf, managementDB, bucket, jet, registry) if err != nil { return err } diff --git a/internal/cluster/scheduler/scheduler.go b/internal/cluster/scheduler/scheduler.go index 0ef6edfd..12155a1d 100644 --- a/internal/cluster/scheduler/scheduler.go +++ b/internal/cluster/scheduler/scheduler.go @@ -46,7 +46,7 @@ func (controller *Controller) ReconcileJourneyResumptions(ctx context.Context) { StateID: &state.ID, } - err = controller.pub.Publish(ctx, schemas.JourneysAdvance(state.ProjectID, state.JourneyID), step) + err = controller.pub.Publish(ctx, schemas.JourneysAdvance(state.ProjectID, state.JourneyID, state.UserID), step) if err != nil { controller.logger.Error("failed to publish journey step", zap.Error(err), zap.Stringer("journey_id", state.JourneyID), zap.Stringer("journey_entry_id", state.JourneyEntryID)) } diff --git a/internal/http/controllers/v1/client/controller.go b/internal/http/controllers/v1/client/controller.go index e16bd152..157b9e1a 100644 --- a/internal/http/controllers/v1/client/controller.go +++ b/internal/http/controllers/v1/client/controller.go @@ -5,10 +5,12 @@ import ( "github.com/lunogram/platform/internal/pubsub" "github.com/lunogram/platform/internal/store/management" "github.com/lunogram/platform/internal/store/users" + "github.com/nats-io/nats.go/jetstream" "go.uber.org/zap" ) -func NewController(logger *zap.Logger, db *sqlx.DB, mgmt *management.State, usrs *users.State, pub pubsub.Publisher) (*Controller, error) { +func NewController(logger *zap.Logger, db *sqlx.DB, mgmt *management.State, usrs *users.State, jet jetstream.JetStream) (*Controller, error) { + pub := pubsub.NewPublisher(jet) subsController, err := NewSubscriptionsController(logger, db, mgmt, usrs) if err != nil { return nil, err diff --git a/internal/http/controllers/v1/http.go b/internal/http/controllers/v1/http.go index d624e2b0..9ae84618 100644 --- a/internal/http/controllers/v1/http.go +++ b/internal/http/controllers/v1/http.go @@ -20,10 +20,10 @@ import ( mgmtoapi "github.com/lunogram/platform/internal/http/controllers/v1/management/oapi" "github.com/lunogram/platform/internal/http/scalar" "github.com/lunogram/platform/internal/providers" - "github.com/lunogram/platform/internal/pubsub" "github.com/lunogram/platform/internal/storage" "github.com/lunogram/platform/internal/store/management" "github.com/lunogram/platform/internal/store/users" + "github.com/nats-io/nats.go/jetstream" "go.uber.org/zap" ) @@ -33,7 +33,7 @@ var staticFiles embed.FS // NewServer constructs a unified HTTP server combining both management and client // API endpoints. Management endpoints use JWT+API Key auth, while client endpoints // use API Key only authentication. -func NewServer(ctx graceful.Context, logger *zap.Logger, cfg config.Node, db *sqlx.DB, storage storage.Storage, pub pubsub.Publisher, registry *providers.Registry) (*http.Server, error) { +func NewServer(ctx graceful.Context, logger *zap.Logger, cfg config.Node, db *sqlx.DB, storage storage.Storage, jet jetstream.JetStream, registry *providers.Registry) (*http.Server, error) { mgmtStores := management.NewState(db) usersStore := users.NewState(db) @@ -49,13 +49,13 @@ func NewServer(ctx graceful.Context, logger *zap.Logger, cfg config.Node, db *sq } // Create management controller - mgmtController, err := managementv1.NewController(logger, db, cfg, storage, pub, registry) + mgmtController, err := managementv1.NewController(logger, db, cfg, storage, jet, registry) if err != nil { return nil, fmt.Errorf("failed to create management controller: %w", err) } // Create client controller - clientController, err := clientv1.NewController(logger, db, mgmtStores, usersStore, pub) + clientController, err := clientv1.NewController(logger, db, mgmtStores, usersStore, jet) if err != nil { return nil, fmt.Errorf("failed to create client controller: %w", err) } diff --git a/internal/http/controllers/v1/management/controller.go b/internal/http/controllers/v1/management/controller.go index d10c7064..edbf02bd 100644 --- a/internal/http/controllers/v1/management/controller.go +++ b/internal/http/controllers/v1/management/controller.go @@ -6,10 +6,12 @@ import ( "github.com/lunogram/platform/internal/providers" "github.com/lunogram/platform/internal/pubsub" "github.com/lunogram/platform/internal/storage" + "github.com/nats-io/nats.go/jetstream" "go.uber.org/zap" ) -func NewController(logger *zap.Logger, db *sqlx.DB, cfg config.Node, storage storage.Storage, pub pubsub.Publisher, registry *providers.Registry) (_ *Controller, err error) { +func NewController(logger *zap.Logger, db *sqlx.DB, cfg config.Node, storage storage.Storage, jet jetstream.JetStream, registry *providers.Registry) (_ *Controller, err error) { + pub := pubsub.NewPublisher(jet) controller := &Controller{ ProjectsController: NewProjectsController(logger, db), CampaignsController: NewCampaignsController(logger, db), @@ -19,7 +21,7 @@ func NewController(logger *zap.Logger, db *sqlx.DB, cfg config.Node, storage sto EventsController: NewEventsController(logger, db), TagsController: NewTagsController(logger, db), LocalesController: NewLocalesController(logger, db), - JourneysController: NewJourneysController(logger, db, pub), + JourneysController: NewJourneysController(logger, db, jet, pub), OrganizationsController: NewOrganizationsController(logger, db), ListsController: NewListsController(logger, db, pub, cfg.Storage.MaxUploadSize), DocumentsController: NewDocumentsController(logger, db, storage, cfg.Storage.MaxUploadSize), diff --git a/internal/http/controllers/v1/management/journeys.go b/internal/http/controllers/v1/management/journeys.go index 0468c272..7c799e6f 100644 --- a/internal/http/controllers/v1/management/journeys.go +++ b/internal/http/controllers/v1/management/journeys.go @@ -10,6 +10,7 @@ import ( "github.com/lunogram/platform/internal/http/controllers/v1/management/oapi" "github.com/lunogram/platform/internal/http/json" "github.com/lunogram/platform/internal/http/problem" + "github.com/lunogram/platform/internal/http/sse" "github.com/lunogram/platform/internal/pubsub" "github.com/lunogram/platform/internal/pubsub/consumer" "github.com/lunogram/platform/internal/pubsub/schemas" @@ -17,10 +18,12 @@ import ( "github.com/lunogram/platform/internal/store/journey" "github.com/lunogram/platform/internal/store/management" "github.com/lunogram/platform/internal/store/users" + "github.com/nats-io/nats.go" + "github.com/nats-io/nats.go/jetstream" "go.uber.org/zap" ) -func NewJourneysController(logger *zap.Logger, db *sqlx.DB, pub pubsub.Publisher) *JourneysController { +func NewJourneysController(logger *zap.Logger, db *sqlx.DB, jet jetstream.JetStream, pub pubsub.Publisher) *JourneysController { return &JourneysController{ logger: logger, db: db, @@ -28,6 +31,7 @@ func NewJourneysController(logger *zap.Logger, db *sqlx.DB, pub pubsub.Publisher users: users.NewState(db), jrny: journey.NewState(db), pub: pub, + jet: jet, } } @@ -38,6 +42,7 @@ type JourneysController struct { users *users.State jrny *journey.State pub pubsub.Publisher + jet jetstream.JetStream } func (srv *JourneysController) ListJourneys(w http.ResponseWriter, r *http.Request, projectID uuid.UUID, params oapi.ListJourneysParams) { @@ -313,6 +318,44 @@ func (srv *JourneysController) DeleteJourney(w http.ResponseWriter, r *http.Requ w.WriteHeader(http.StatusNoContent) } +func (srv *JourneysController) FollowUserJourneyStatus(w http.ResponseWriter, r *http.Request, projectID, journeyID uuid.UUID) { + ctx := r.Context() + enc := sse.NewEncoder(w) + + userID, err := uuid.Parse(r.URL.Query().Get("user_id")) + if err != nil { + oapi.WriteProblem(w, problem.ErrBadRequest(problem.Describe("invalid user_id format"))) + return + } + + logger := srv.logger.With( + zap.Stringer("project_id", projectID), + zap.Stringer("journey_id", journeyID), + zap.Stringer("user_id", userID), + ) + + logger.Info("following user journey status") + + nconn := srv.jet.Conn() + + handler := func(msg *nats.Msg) { + if ctx.Done() != nil { + logger.Info("stopping user journey status follow") + return + } + + enc.WriteEvent("UserAdvanced", msg.Data) + } + + subject := schemas.JourneysAdvance(projectID, journeyID, userID) + _, err = nconn.Subscribe(string(subject), handler) + if err != nil { + logger.Error("failed to subscribe to journey updates", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } +} + func (srv *JourneysController) RunJourneyForUser(w http.ResponseWriter, r *http.Request, projectID, journeyID uuid.UUID) { ctx := r.Context() @@ -398,7 +441,7 @@ func (srv *JourneysController) RunJourneyForUser(w http.ResponseWriter, r *http. UserID: userID, } - err = srv.pub.Publish(ctx, schemas.JourneysAdvance(currJourney.ProjectID, step.JourneyID), step) + err = srv.pub.Publish(ctx, schemas.JourneysAdvance(currJourney.ProjectID, step.JourneyID, step.UserID), step) if err != nil { logger.Error("failed to publish journey state to project subject", zap.Error(err)) oapi.WriteProblem(w, err) diff --git a/internal/http/controllers/v1/management/journeys_test.go b/internal/http/controllers/v1/management/journeys_test.go index 164d4e16..e9e0a152 100644 --- a/internal/http/controllers/v1/management/journeys_test.go +++ b/internal/http/controllers/v1/management/journeys_test.go @@ -35,7 +35,7 @@ func TestCreateJourney(t *testing.T) { projectID, err := projects.CreateProject(ctx, DefaultProject) require.NoError(t, err) - journeys := NewJourneysController(logger, db, nil) + journeys := NewJourneysController(logger, db, nil, nil) type test struct { body oapi.CreateJourneyJSONRequestBody @@ -115,7 +115,7 @@ func TestListJourneys(t *testing.T) { require.NoError(t, err) } - journeys := NewJourneysController(logger, db, nil) + journeys := NewJourneysController(logger, db, nil, nil) type test struct { limit int @@ -205,7 +205,7 @@ func TestGetJourney(t *testing.T) { }) require.NoError(t, err) - journeys := NewJourneysController(logger, db, nil) + journeys := NewJourneysController(logger, db, nil, nil) type test struct { journeyID uuid.UUID @@ -270,7 +270,7 @@ func TestUpdateJourney(t *testing.T) { }) require.NoError(t, err) - journeys := NewJourneysController(logger, db, nil) + journeys := NewJourneysController(logger, db, nil, nil) type test struct { body oapi.UpdateJourneyJSONRequestBody @@ -357,7 +357,7 @@ func TestDeleteJourney(t *testing.T) { }) require.NoError(t, err) - journeys := NewJourneysController(logger, db, nil) + journeys := NewJourneysController(logger, db, nil, nil) type test struct { journeyID uuid.UUID diff --git a/internal/http/controllers/v1/management/oapi/resources.yml b/internal/http/controllers/v1/management/oapi/resources.yml index 14c51000..c732b2a3 100644 --- a/internal/http/controllers/v1/management/oapi/resources.yml +++ b/internal/http/controllers/v1/management/oapi/resources.yml @@ -1030,6 +1030,64 @@ paths: $ref: "#/components/responses/Error" /api/admin/projects/{projectID}/journeys/{journeyID}/users: + get: + summary: Get user journey status + description: Retrieves the current status and progress of a specific user in a journey in real-time + operationId: followUserJourneyStatus + tags: + - Journeys + security: + - HttpBearerAuth: [] + parameters: + - name: projectID + in: path + required: true + schema: + type: string + format: uuid + description: The project ID + - name: journeyID + in: path + required: true + schema: + type: string + format: uuid + description: The journey ID + - name: userID + in: query + required: true + schema: + type: string + format: uuid + description: The user ID to check journey status for + responses: + "200": + description: User journey status retrieved successfully + content: + application/json: + schema: + type: object + properties: + user_id: + type: string + format: uuid + journey_id: + type: string + format: uuid + current_step_id: + type: string + nullable: true + status: + type: string + enum: [active, completed, exited] + started_at: + type: string + format: date-time + updated_at: + type: string + format: date-time + default: + $ref: "#/components/responses/Error" post: summary: Manually runs a journey for a user description: Triggers a journey to run for a specific user, typically used for testing or manual overrides diff --git a/internal/http/sse/sse.go b/internal/http/sse/sse.go new file mode 100644 index 00000000..a3b1234c --- /dev/null +++ b/internal/http/sse/sse.go @@ -0,0 +1,126 @@ +package sse + +import ( + "bufio" + "bytes" + "encoding/json" + "fmt" + "io" + "net/http" +) + +func NewDecoder(res *http.Response) *Decoder { + if res == nil || res.Body == nil { + return nil + } + + scanner := bufio.NewScanner(res.Body) + return &Decoder{rc: res.Body, scn: scanner} +} + +type Event struct { + Type string + Data []byte +} + +// A base implementation of a Decoder for text/event-stream. +type Decoder struct { + evt Event + rc io.ReadCloser + scn *bufio.Scanner + err error +} + +func (s *Decoder) Next() bool { + if s.err != nil { + return false + } + + event := "" + data := bytes.NewBuffer(nil) + +scanner: + for s.scn.Scan() { + txt := s.scn.Bytes() + + // Dispatch event on an empty line + if len(txt) == 0 { + s.evt = Event{ + Type: event, + Data: data.Bytes(), + } + return true + } + + // Split a string like "event: bar" into name="event" and value=" bar". + name, value, _ := bytes.Cut(txt, []byte(":")) + + // Consume an optional space after the colon if it exists. + if len(value) > 0 && value[0] == ' ' { + value = value[1:] + } + + switch string(name) { + case "": + // An empty line in the for ": something" is a comment and should be ignored. + continue + case "event": + event = string(value) + case "data": + _, s.err = data.Write(value) + if s.err != nil { + break scanner + } + _, s.err = data.WriteRune('\n') + if s.err != nil { + break scanner + } + } + } + + if s.scn.Err() != nil { + s.err = s.scn.Err() + } + + return false +} + +func (s *Decoder) Event() Event { + return s.evt +} + +func (s *Decoder) Close() error { + return s.rc.Close() +} + +func (s *Decoder) Err() error { + return s.err +} + +func NewEncoder(w http.ResponseWriter) *Encoder { + w.Header().Set("Content-Type", "text/event-stream") + w.Header().Set("Cache-Control", "no-cache") + w.Header().Set("Connection", "keep-alive") + w.WriteHeader(http.StatusOK) + + return &Encoder{ + ResponseWriter: w, + flusher: w.(http.Flusher), + } +} + +type Encoder struct { + http.ResponseWriter + flusher http.Flusher +} + +func (encoder *Encoder) WriteEvent(event string, data any) { + jsonBytes, _ := json.Marshal(data) + fmt.Fprintf(encoder, "event: %s\n", event) + fmt.Fprintf(encoder, "data: %s\n\n", jsonBytes) + encoder.flusher.Flush() +} + +func (encoder *Encoder) Write(p []byte) (int, error) { + return encoder.ResponseWriter.Write(p) +} diff --git a/internal/journeys/link.go b/internal/journeys/link.go index 7c96ebf4..dc097fab 100644 --- a/internal/journeys/link.go +++ b/internal/journeys/link.go @@ -80,7 +80,7 @@ func HandleLink(ctx HandlerContext, step journey.JourneyVersionStep, state journ ExternalStepID: child.ChildExternalID, } - err = ctx.Publisher.Publish(ctx, schemas.JourneysAdvance(ctx.ProjectID, targetJourneyID), journeyStep) + err = ctx.Publisher.Publish(ctx, schemas.JourneysAdvance(ctx.ProjectID, targetJourneyID, ctx.UserID), journeyStep) if err != nil { return state, nil, fmt.Errorf("failed to publish journey step: %w", err) } diff --git a/internal/journeys/link_test.go b/internal/journeys/link_test.go index 80027f88..47f02168 100644 --- a/internal/journeys/link_test.go +++ b/internal/journeys/link_test.go @@ -197,7 +197,7 @@ func TestHandleLink(t *testing.T) { if tc.expectedPublish > 0 { for _, event := range mockPub.publishedEvents { - assert.Equal(t, schemas.JourneysAdvance(projectID, targetJourneyID), event.subject) + assert.Equal(t, schemas.JourneysAdvance(projectID, targetJourneyID, userID), event.subject) step, ok := event.data.(schemas.JourneyStep) require.True(t, ok) assert.Equal(t, projectID, step.ProjectID) diff --git a/internal/pubsub/consumer/bootstrap.go b/internal/pubsub/consumer/bootstrap.go index c7b1fe58..bc8b2e43 100644 --- a/internal/pubsub/consumer/bootstrap.go +++ b/internal/pubsub/consumer/bootstrap.go @@ -97,6 +97,14 @@ func Bootstrap(ctx graceful.Context, logger *zap.Logger, jet jetstream.JetStream MaxDeliver: 5, }) + bootstrap.EnsureConsumer(ctx, StreamJourneys, jetstream.ConsumerConfig{ + Name: ConsumerJourneysAdvanceUser, + Description: "Processes journey advancement requests per specific user", + AckPolicy: jetstream.AckExplicitPolicy, + FilterSubject: "journeys.advance.>", + MaxDeliver: 5, + }) + bootstrap.EnsureStream(ctx, jetstream.StreamConfig{ Name: StreamCampaigns, Description: "Campaign sending and execution", diff --git a/internal/pubsub/consumer/consumer.go b/internal/pubsub/consumer/consumer.go index 5a3a5898..38812f4a 100644 --- a/internal/pubsub/consumer/consumer.go +++ b/internal/pubsub/consumer/consumer.go @@ -23,13 +23,14 @@ const ( // Consumer names for NATS JetStream subscribers. const ( - ConsumerUsersProcess = "users-process" - ConsumerUsersSchema = "users-schema" - ConsumerEventsProcess = "events-process" - ConsumerEventsSchema = "events-schema" - ConsumerListsRecompute = "lists-recompute" - ConsumerJourneysAdvance = "journeys-advance" - ConsumerCampaignsSend = "campaigns-send" + ConsumerUsersProcess = "users-process" + ConsumerUsersSchema = "users-schema" + ConsumerEventsProcess = "events-process" + ConsumerEventsSchema = "events-schema" + ConsumerListsRecompute = "lists-recompute" + ConsumerJourneysAdvance = "journeys-advance" + ConsumerJourneysAdvanceUser = "journeys-advance-user" + ConsumerCampaignsSend = "campaigns-send" ) // Serve starts all JetStream consumers and registers their handlers. diff --git a/internal/pubsub/consumer/events.go b/internal/pubsub/consumer/events.go index 99a1eac7..53b25516 100644 --- a/internal/pubsub/consumer/events.go +++ b/internal/pubsub/consumer/events.go @@ -194,7 +194,7 @@ func PublishEventJourneyDependencies(ctx context.Context, logger *zap.Logger, us UserID: event.UserID, } - err = pub.Publish(ctx, schemas.JourneysAdvance(event.ProjectID, dep.JourneyID), step) + err = pub.Publish(ctx, schemas.JourneysAdvance(event.ProjectID, dep.JourneyID, event.UserID), step) if err != nil { logger.Error("failed to publish journey state to project subject", zap.Error(err)) return err diff --git a/internal/pubsub/consumer/journeys.go b/internal/pubsub/consumer/journeys.go index 358e385d..c190f52e 100644 --- a/internal/pubsub/consumer/journeys.go +++ b/internal/pubsub/consumer/journeys.go @@ -83,7 +83,7 @@ func JourneyStepHandler(logger *zap.Logger, db *sqlx.DB, jrny *journey.State, pu ExternalStepID: child.ChildExternalID, } - err = pub.Publish(ctx, schemas.JourneysAdvance(event.ProjectID, event.JourneyID), next) + err = pub.Publish(ctx, schemas.JourneysAdvance(event.ProjectID, event.JourneyID, event.UserID), next) if err != nil { logger.Error("failed to publish next journey step", zap.Error(err)) return err diff --git a/internal/pubsub/schemas/events.go b/internal/pubsub/schemas/events.go index 933fa961..55f5c82d 100644 --- a/internal/pubsub/schemas/events.go +++ b/internal/pubsub/schemas/events.go @@ -105,6 +105,6 @@ func ListsRecompute(projectID uuid.UUID, listID uuid.UUID) Subject { } // JourneysAdvance returns the NATS subject for journey advancement. -func JourneysAdvance(projectID uuid.UUID, journeyID uuid.UUID) Subject { - return Subject(fmt.Sprintf("journeys.advance.%s.%s", projectID, journeyID)) +func JourneysAdvance(projectID uuid.UUID, journeyID uuid.UUID, userID uuid.UUID) Subject { + return Subject(fmt.Sprintf("journeys.advance.%s.%s.%s", projectID, journeyID, userID)) } From 61f712f0966e3295611f0f953f05414b4769b9a3 Mon Sep 17 00:00:00 2001 From: Jeroen Rinzema Date: Sun, 22 Feb 2026 13:26:26 +0100 Subject: [PATCH 004/230] feat: renamed users store to subjects and included organizations migrations and store --- cmd/lunogram/main.go | 8 +- docker-compose.yml | 2 +- docker/postgres/init-databases.sh | 6 +- internal/http/controllers/v1/client/client.go | 10 +- .../http/controllers/v1/client/client_test.go | 4 +- .../http/controllers/v1/client/controller.go | 4 +- .../controllers/v1/client/subscriptions.go | 6 +- .../v1/client/subscriptions_test.go | 10 +- internal/http/controllers/v1/http.go | 8 +- .../http/controllers/v1/management/events.go | 6 +- .../controllers/v1/management/journeys.go | 4 +- .../http/controllers/v1/management/lists.go | 28 +- .../controllers/v1/management/lists_test.go | 30 +- .../controllers/v1/management/projects.go | 6 +- .../http/controllers/v1/management/users.go | 14 +- .../controllers/v1/management/users_test.go | 28 +- internal/importer/users.go | 22 +- internal/importer/users_test.go | 20 +- internal/journeys/event.go | 4 +- internal/journeys/update.go | 6 +- internal/journeys/update_test.go | 10 +- internal/providers/channels/channels.go | 6 +- internal/providers/channels/email.go | 4 +- internal/providers/channels/push.go | 4 +- internal/providers/channels/sms.go | 4 +- internal/pubsub/consumer/campaigns.go | 4 +- internal/pubsub/consumer/consumer.go | 6 +- internal/pubsub/consumer/events.go | 10 +- internal/pubsub/consumer/events_test.go | 18 +- internal/pubsub/consumer/recompute.go | 10 +- internal/pubsub/consumer/recompute_test.go | 36 +- internal/pubsub/consumer/users.go | 8 +- internal/pubsub/consumer/users_test.go | 14 +- internal/store/store.go | 16 +- internal/store/{users => subjects}/devices.go | 2 +- internal/store/{users => subjects}/events.go | 2 +- internal/store/{users => subjects}/lists.go | 2 +- internal/store/{users => subjects}/migrate.go | 2 +- .../migrations/1764106028_migration.down.sql | 0 .../migrations/1764106028_migration.up.sql | 0 .../1771762205_organizations.down.sql | 5 + .../1771762205_organizations.up.sql | 37 ++ internal/store/subjects/organizations.go | 282 +++++++++ internal/store/subjects/organizations_test.go | 578 ++++++++++++++++++ internal/store/{users => subjects}/rules.go | 2 +- internal/store/subjects/store.go | 25 + internal/store/{users => subjects}/users.go | 2 +- .../store/{users => subjects}/users_test.go | 2 +- internal/store/test/store.go | 4 +- internal/store/users/store.go | 23 - 50 files changed, 1124 insertions(+), 220 deletions(-) rename internal/store/{users => subjects}/devices.go (99%) rename internal/store/{users => subjects}/events.go (99%) rename internal/store/{users => subjects}/lists.go (99%) rename internal/store/{users => subjects}/migrate.go (95%) rename internal/store/{users => subjects}/migrations/1764106028_migration.down.sql (100%) rename internal/store/{users => subjects}/migrations/1764106028_migration.up.sql (100%) create mode 100644 internal/store/subjects/migrations/1771762205_organizations.down.sql create mode 100644 internal/store/subjects/migrations/1771762205_organizations.up.sql create mode 100644 internal/store/subjects/organizations.go create mode 100644 internal/store/subjects/organizations_test.go rename internal/store/{users => subjects}/rules.go (99%) create mode 100644 internal/store/subjects/store.go rename internal/store/{users => subjects}/users.go (99%) rename internal/store/{users => subjects}/users_test.go (99%) delete mode 100644 internal/store/users/store.go diff --git a/cmd/lunogram/main.go b/cmd/lunogram/main.go index 12f60202..00195c57 100644 --- a/cmd/lunogram/main.go +++ b/cmd/lunogram/main.go @@ -21,7 +21,7 @@ import ( "github.com/lunogram/platform/internal/store" "github.com/lunogram/platform/internal/store/journey" "github.com/lunogram/platform/internal/store/management" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "go.uber.org/zap" ) @@ -59,8 +59,8 @@ func run() error { if err := management.Migrate(conf.Store.ManagementURI); err != nil { return fmt.Errorf("management migration failed: %w", err) } - if err := users.Migrate(conf.Store.UsersURI); err != nil { - return fmt.Errorf("users migration failed: %w", err) + if err := subjects.Migrate(conf.Store.SubjectsURI); err != nil { + return fmt.Errorf("subjects migration failed: %w", err) } if err := journey.Migrate(conf.Store.JourneyURI); err != nil { return fmt.Errorf("journey migration failed: %w", err) @@ -79,7 +79,7 @@ func run() error { } managementStore := management.NewState(db.Management) - usersStore := users.NewState(db.Users) + usersStore := subjects.NewState(db.Subjects) journeyStore := journey.NewState(db.Journey) logger.Info("initializing block storage") diff --git a/docker-compose.yml b/docker-compose.yml index 4b516487..dd56630c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,7 +14,7 @@ services: - "8081:8081" environment: POSTGRES_MANAGEMENT_URI: postgres://postgres:postgrespw@postgres:5432/management?sslmode=disable - POSTGRES_USERS_URI: postgres://postgres:postgrespw@postgres:5432/users?sslmode=disable + POSTGRES_SUBJECTS_URI: postgres://postgres:postgrespw@postgres:5432/subjects?sslmode=disable POSTGRES_JOURNEY_URI: postgres://postgres:postgrespw@postgres:5432/journey?sslmode=disable REDIS_ADDRESS: redis://redis:6379 NATS_URL: nats://nats:4222 diff --git a/docker/postgres/init-databases.sh b/docker/postgres/init-databases.sh index 0c8f32e6..11daec23 100755 --- a/docker/postgres/init-databases.sh +++ b/docker/postgres/init-databases.sh @@ -4,13 +4,13 @@ set -e # Create the three databases for the split store architecture psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname "$POSTGRES_DB" <<-EOSQL CREATE DATABASE management; - CREATE DATABASE users; + CREATE DATABASE subjects; CREATE DATABASE journey; -- Grant privileges GRANT ALL PRIVILEGES ON DATABASE management TO $POSTGRES_USER; - GRANT ALL PRIVILEGES ON DATABASE users TO $POSTGRES_USER; + GRANT ALL PRIVILEGES ON DATABASE subjects TO $POSTGRES_USER; GRANT ALL PRIVILEGES ON DATABASE journey TO $POSTGRES_USER; EOSQL -echo "Created databases: management, users, journey" +echo "Created databases: management, subjects, journey" diff --git a/internal/http/controllers/v1/client/client.go b/internal/http/controllers/v1/client/client.go index 91ecd5db..238875ae 100644 --- a/internal/http/controllers/v1/client/client.go +++ b/internal/http/controllers/v1/client/client.go @@ -11,11 +11,11 @@ import ( "github.com/lunogram/platform/internal/http/problem" "github.com/lunogram/platform/internal/pubsub" "github.com/lunogram/platform/internal/pubsub/schemas" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "go.uber.org/zap" ) -func NewClientController(logger *zap.Logger, db *sqlx.DB, usrs *users.State, pub pubsub.Publisher) *ClientController { +func NewClientController(logger *zap.Logger, db *sqlx.DB, usrs *subjects.State, pub pubsub.Publisher) *ClientController { return &ClientController{ logger: logger, db: db, @@ -27,7 +27,7 @@ func NewClientController(logger *zap.Logger, db *sqlx.DB, usrs *users.State, pub type ClientController struct { logger *zap.Logger db *sqlx.DB - users *users.State + users *subjects.State pubsub pubsub.Publisher } @@ -121,14 +121,14 @@ func (srv *ClientController) IdentifyUserClient(w http.ResponseWriter, r *http.R } defer tx.Rollback() //nolint:errcheck - usersStore := users.NewUsersStore(tx) + usersStore := subjects.NewUsersStore(tx) var data map[string]any if req.Data != nil { data = *req.Data } - params := users.UpsertUserParams{ + params := subjects.UpsertUserParams{ AnonymousID: req.AnonymousId, ExternalID: req.ExternalId, Email: req.Email, diff --git a/internal/http/controllers/v1/client/client_test.go b/internal/http/controllers/v1/client/client_test.go index b55702e1..a657fb58 100644 --- a/internal/http/controllers/v1/client/client_test.go +++ b/internal/http/controllers/v1/client/client_test.go @@ -14,7 +14,7 @@ import ( "github.com/lunogram/platform/internal/pubsub/consumer" "github.com/lunogram/platform/internal/store/management" teststore "github.com/lunogram/platform/internal/store/test" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" @@ -44,7 +44,7 @@ func setupClientController(t *testing.T) *testClientController { require.NoError(t, err) pub := pubsub.NewPublisher(jet) - usersState := users.NewState(usrs) + usersState := subjects.NewState(usrs) controller := NewClientController(logger, usrs, usersState, pub) return &testClientController{ diff --git a/internal/http/controllers/v1/client/controller.go b/internal/http/controllers/v1/client/controller.go index cbe58971..c237329c 100644 --- a/internal/http/controllers/v1/client/controller.go +++ b/internal/http/controllers/v1/client/controller.go @@ -4,11 +4,11 @@ import ( "github.com/jmoiron/sqlx" "github.com/lunogram/platform/internal/pubsub" "github.com/lunogram/platform/internal/store/management" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "go.uber.org/zap" ) -func NewController(logger *zap.Logger, mgmtDB, usersDB *sqlx.DB, mgmt *management.State, usrs *users.State, pub pubsub.Publisher) (*Controller, error) { +func NewController(logger *zap.Logger, mgmtDB, usersDB *sqlx.DB, mgmt *management.State, usrs *subjects.State, pub pubsub.Publisher) (*Controller, error) { subsController, err := NewSubscriptionsController(logger, mgmtDB, mgmt, usrs) if err != nil { return nil, err diff --git a/internal/http/controllers/v1/client/subscriptions.go b/internal/http/controllers/v1/client/subscriptions.go index 9be24e39..fa9cf39d 100644 --- a/internal/http/controllers/v1/client/subscriptions.go +++ b/internal/http/controllers/v1/client/subscriptions.go @@ -13,7 +13,7 @@ import ( "github.com/lunogram/platform/internal/http/controllers/v1/client/oapi" "github.com/lunogram/platform/internal/http/problem" "github.com/lunogram/platform/internal/store/management" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "go.uber.org/zap" ) @@ -24,11 +24,11 @@ type SubscriptionsController struct { logger *zap.Logger db *sqlx.DB mgmt *management.State - users *users.State + users *subjects.State tmpl *template.Template } -func NewSubscriptionsController(logger *zap.Logger, db *sqlx.DB, mgmt *management.State, usrs *users.State) (*SubscriptionsController, error) { +func NewSubscriptionsController(logger *zap.Logger, db *sqlx.DB, mgmt *management.State, usrs *subjects.State) (*SubscriptionsController, error) { tmpl, err := template.ParseFS(templatesFS, "templates/*.html") if err != nil { return nil, err diff --git a/internal/http/controllers/v1/client/subscriptions_test.go b/internal/http/controllers/v1/client/subscriptions_test.go index 423271b5..4c038ccc 100644 --- a/internal/http/controllers/v1/client/subscriptions_test.go +++ b/internal/http/controllers/v1/client/subscriptions_test.go @@ -12,7 +12,7 @@ import ( "github.com/lunogram/platform/internal/http/json" "github.com/lunogram/platform/internal/store/management" teststore "github.com/lunogram/platform/internal/store/test" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" ) @@ -25,7 +25,7 @@ func setupSubscriptionsController(t *testing.T) (*SubscriptionsController, uuid. mgmtDB, usrsDB, _ := teststore.RunPostgreSQL(t) mgmt := management.NewState(mgmtDB) - usrs := users.NewState(usrsDB) + usrs := subjects.NewState(usrsDB) // Create project projectsStore := management.NewProjectsStore(mgmtDB) @@ -38,7 +38,7 @@ func setupSubscriptionsController(t *testing.T) (*SubscriptionsController, uuid. // Create user email := "test@example.com" - userID, err := usrs.CreateUser(ctx, users.User{ + userID, err := usrs.CreateUser(ctx, subjects.User{ ProjectID: projectID, Email: &email, Data: json.RawMessage("{}"), @@ -137,7 +137,7 @@ func TestEmailUnsubscribe(t *testing.T) { mgmtDB, usrsDB, _ := teststore.RunPostgreSQL(t) mgmt := management.NewState(mgmtDB) - usrs := users.NewState(usrsDB) + usrs := subjects.NewState(usrsDB) // Create project projectsStore := management.NewProjectsStore(mgmtDB) @@ -150,7 +150,7 @@ func TestEmailUnsubscribe(t *testing.T) { // Create user email := "test@example.com" - userID, err := usrs.CreateUser(ctx, users.User{ + userID, err := usrs.CreateUser(ctx, subjects.User{ ProjectID: projectID, Email: &email, Data: json.RawMessage("{}"), diff --git a/internal/http/controllers/v1/http.go b/internal/http/controllers/v1/http.go index 0673e677..b8878675 100644 --- a/internal/http/controllers/v1/http.go +++ b/internal/http/controllers/v1/http.go @@ -23,7 +23,7 @@ import ( "github.com/lunogram/platform/internal/storage" "github.com/lunogram/platform/internal/store" "github.com/lunogram/platform/internal/store/management" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "go.uber.org/zap" ) @@ -35,7 +35,7 @@ var staticFiles embed.FS // use API Key only authentication. func NewServer(ctx graceful.Context, logger *zap.Logger, cfg config.Node, db *store.Connections, storage storage.Storage, pub pubsub.Publisher, registry *providers.Registry) (*http.Server, error) { mgmtStores := management.NewState(db.Management) - usersStore := users.NewState(db.Users) + usersStore := subjects.NewState(db.Subjects) // Load OpenAPI specs mgmtSpec, err := mgmtoapi.Spec() @@ -49,13 +49,13 @@ func NewServer(ctx graceful.Context, logger *zap.Logger, cfg config.Node, db *st } // Create management controller - mgmtController, err := managementv1.NewController(logger, db.Management, db.Users, db.Journey, cfg, storage, pub, registry) + mgmtController, err := managementv1.NewController(logger, db.Management, db.Subjects, db.Journey, cfg, storage, pub, registry) if err != nil { return nil, fmt.Errorf("failed to create management controller: %w", err) } // Create client controller - clientController, err := clientv1.NewController(logger, db.Management, db.Users, mgmtStores, usersStore, pub) + clientController, err := clientv1.NewController(logger, db.Management, db.Subjects, mgmtStores, usersStore, pub) if err != nil { return nil, fmt.Errorf("failed to create client controller: %w", err) } diff --git a/internal/http/controllers/v1/management/events.go b/internal/http/controllers/v1/management/events.go index d32a2936..fa975202 100644 --- a/internal/http/controllers/v1/management/events.go +++ b/internal/http/controllers/v1/management/events.go @@ -9,7 +9,7 @@ import ( "github.com/lunogram/platform/internal/http/controllers/v1/management/oapi" "github.com/lunogram/platform/internal/http/json" "github.com/lunogram/platform/internal/http/problem" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "go.uber.org/zap" ) @@ -17,14 +17,14 @@ func NewEventsController(logger *zap.Logger, db *sqlx.DB) *EventsController { return &EventsController{ logger: logger, db: db, - store: users.NewState(db), + store: subjects.NewState(db), } } type EventsController struct { logger *zap.Logger db *sqlx.DB - store *users.State + store *subjects.State } func (srv *EventsController) ListEvents(w http.ResponseWriter, r *http.Request, projectID uuid.UUID) { diff --git a/internal/http/controllers/v1/management/journeys.go b/internal/http/controllers/v1/management/journeys.go index fc4e1ab8..895a2e9c 100644 --- a/internal/http/controllers/v1/management/journeys.go +++ b/internal/http/controllers/v1/management/journeys.go @@ -13,7 +13,7 @@ import ( "github.com/lunogram/platform/internal/store" "github.com/lunogram/platform/internal/store/journey" "github.com/lunogram/platform/internal/store/management" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "go.uber.org/zap" ) @@ -386,7 +386,7 @@ func (srv *JourneysController) SetJourneySteps(w http.ResponseWriter, r *http.Re defer tx.Rollback() //nolint:errcheck journeys := journey.NewJourneysStore(tx) - events := users.NewEventsStore(tx) + events := subjects.NewEventsStore(tx) versionID, err := journeys.EnsureDraftVersion(ctx, journeyID) if err != nil { diff --git a/internal/http/controllers/v1/management/lists.go b/internal/http/controllers/v1/management/lists.go index 04ab4598..5a88c9b2 100644 --- a/internal/http/controllers/v1/management/lists.go +++ b/internal/http/controllers/v1/management/lists.go @@ -18,7 +18,7 @@ import ( "github.com/lunogram/platform/internal/pubsub/consumer" "github.com/lunogram/platform/internal/store" "github.com/lunogram/platform/internal/store/management" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "go.uber.org/zap" ) @@ -26,7 +26,7 @@ func NewListsController(logger *zap.Logger, usersDB *sqlx.DB, projects *manageme return &ListsController{ logger: logger, usersDB: usersDB, - store: users.NewState(usersDB), + store: subjects.NewState(usersDB), projects: projects, maxUploadSize: maxUploadSize, pub: pub, @@ -36,7 +36,7 @@ func NewListsController(logger *zap.Logger, usersDB *sqlx.DB, projects *manageme type ListsController struct { logger *zap.Logger usersDB *sqlx.DB - store *users.State + store *subjects.State projects *management.ProjectsStore maxUploadSize int64 pub pubsub.Publisher @@ -75,9 +75,9 @@ func (srv *ListsController) CreateList(w http.ResponseWriter, r *http.Request, p } defer tx.Rollback() //nolint:errcheck - lists := users.NewListsStore(tx) - rules := users.NewRulesStore(tx) - events := users.NewEventsStore(tx) + lists := subjects.NewListsStore(tx) + rules := subjects.NewRulesStore(tx) + events := subjects.NewEventsStore(tx) var ruleID *uuid.UUID @@ -108,10 +108,10 @@ func (srv *ListsController) CreateList(w http.ResponseWriter, r *http.Request, p ruleID = &id } - listID, err := lists.CreateList(ctx, users.List{ + listID, err := lists.CreateList(ctx, subjects.List{ ProjectID: projectID, Name: body.Name, - Type: users.ListType(body.Type), + Type: subjects.ListType(body.Type), RuleID: ruleID, }) if err != nil { @@ -220,11 +220,11 @@ func (srv *ListsController) UpdateList(w http.ResponseWriter, r *http.Request, p defer tx.Rollback() //nolint:errcheck - lists := users.NewListsStore(tx) - rules := users.NewRulesStore(tx) - events := users.NewEventsStore(tx) + lists := subjects.NewListsStore(tx) + rules := subjects.NewRulesStore(tx) + events := subjects.NewEventsStore(tx) - update := users.ListUpdate{ + update := subjects.ListUpdate{ Name: &body.Name, } @@ -380,7 +380,7 @@ func (srv *ListsController) ImportListUsers(w http.ResponseWriter, r *http.Reque return } - if list.Type != users.ListTypeStatic { + if list.Type != subjects.ListTypeStatic { logger.Error("list is not static", zap.String("type", string(list.Type))) oapi.WriteProblem(w, problem.ErrBadRequest(problem.Describe("only static lists support user imports"))) return @@ -437,7 +437,7 @@ func (srv *ListsController) processUserImport(ctx context.Context, logger *zap.L } defer tx.Rollback() //nolint:errcheck - stores := users.NewState(tx) + stores := subjects.NewState(tx) for { record, err := reader.Read() diff --git a/internal/http/controllers/v1/management/lists_test.go b/internal/http/controllers/v1/management/lists_test.go index cada166f..c89ba18e 100644 --- a/internal/http/controllers/v1/management/lists_test.go +++ b/internal/http/controllers/v1/management/lists_test.go @@ -19,7 +19,7 @@ import ( "github.com/lunogram/platform/internal/store" "github.com/lunogram/platform/internal/store/management" teststore "github.com/lunogram/platform/internal/store/test" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" ) @@ -129,9 +129,9 @@ func TestListLists(t *testing.T) { projectID, err := projects.CreateProject(ctx, DefaultProject) require.NoError(t, err) - listsStore := users.NewListsStore(usrs) + listsStore := subjects.NewListsStore(usrs) - testLists := []users.List{ + testLists := []subjects.List{ { ProjectID: projectID, Name: "Test List 1", @@ -233,8 +233,8 @@ func TestGetList(t *testing.T) { projectID, err := projects.CreateProject(ctx, DefaultProject) require.NoError(t, err) - listsStore := users.NewListsStore(usrs) - listID, err := listsStore.CreateList(ctx, users.List{ + listsStore := subjects.NewListsStore(usrs) + listID, err := listsStore.CreateList(ctx, subjects.List{ ProjectID: projectID, Name: "Test List", Type: "static", @@ -280,8 +280,8 @@ func TestUpdateList(t *testing.T) { projectID, err := projects.CreateProject(ctx, DefaultProject) require.NoError(t, err) - listsStore := users.NewListsStore(usrs) - listID, err := listsStore.CreateList(ctx, users.List{ + listsStore := subjects.NewListsStore(usrs) + listID, err := listsStore.CreateList(ctx, subjects.List{ ProjectID: projectID, Name: "Test List", Type: "dynamic", @@ -333,8 +333,8 @@ func TestDeleteList(t *testing.T) { projectID, err := projects.CreateProject(ctx, DefaultProject) require.NoError(t, err) - listsStore := users.NewListsStore(usrs) - listID, err := listsStore.CreateList(ctx, users.List{ + listsStore := subjects.NewListsStore(usrs) + listID, err := listsStore.CreateList(ctx, subjects.List{ ProjectID: projectID, Name: "Test List", Type: "static", @@ -377,8 +377,8 @@ func TestDuplicateList(t *testing.T) { projectID, err := projects.CreateProject(ctx, DefaultProject) require.NoError(t, err) - listsStore := users.NewListsStore(usrs) - listID, err := listsStore.CreateList(ctx, users.List{ + listsStore := subjects.NewListsStore(usrs) + listID, err := listsStore.CreateList(ctx, subjects.List{ ProjectID: projectID, Name: "Original List", Type: "static", @@ -452,13 +452,13 @@ func TestImportListUsers(t *testing.T) { projectID, err := projects.CreateProject(ctx, DefaultProject) require.NoError(t, err) - usersStore := users.NewUsersStore(usrs) - listsStore := users.NewListsStore(usrs) + usersStore := subjects.NewUsersStore(usrs) + listsStore := subjects.NewListsStore(usrs) - list := users.List{ + list := subjects.List{ ProjectID: projectID, Name: "Import Test List", - Type: users.ListTypeStatic, + Type: subjects.ListTypeStatic, } listID, err := listsStore.CreateList(ctx, list) diff --git a/internal/http/controllers/v1/management/projects.go b/internal/http/controllers/v1/management/projects.go index 49abcb9c..a1eed14c 100644 --- a/internal/http/controllers/v1/management/projects.go +++ b/internal/http/controllers/v1/management/projects.go @@ -18,7 +18,7 @@ import ( "github.com/lunogram/platform/internal/store" "github.com/lunogram/platform/internal/store/journey" "github.com/lunogram/platform/internal/store/management" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "go.uber.org/zap" ) @@ -28,7 +28,7 @@ func NewProjectsController(logger *zap.Logger, managementDB, usersDB, journeyDB managementDB: managementDB, store: management.NewState(managementDB), journey: journey.NewState(journeyDB), - users: users.NewState(usersDB), + users: subjects.NewState(usersDB), } } @@ -37,7 +37,7 @@ type ProjectsController struct { managementDB *sqlx.DB store *management.State journey *journey.State - users *users.State + users *subjects.State } func (srv *ProjectsController) loadProjectCounts(ctx context.Context, project *management.Project) { diff --git a/internal/http/controllers/v1/management/users.go b/internal/http/controllers/v1/management/users.go index b4964c44..84994d88 100644 --- a/internal/http/controllers/v1/management/users.go +++ b/internal/http/controllers/v1/management/users.go @@ -20,7 +20,7 @@ import ( "github.com/lunogram/platform/internal/store" "github.com/lunogram/platform/internal/store/journey" "github.com/lunogram/platform/internal/store/management" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "go.uber.org/zap" ) @@ -29,7 +29,7 @@ func NewUsersController(logger *zap.Logger, pub pubsub.Publisher, usersDB, journ logger: logger, usersDB: usersDB, mgmt: mgmt, - users: users.NewState(usersDB), + users: subjects.NewState(usersDB), journey: journey.NewState(journeyDB), pubsub: pub, maxUploadSize: maxUploadSize, @@ -41,7 +41,7 @@ type UsersController struct { usersDB *sqlx.DB pubsub pubsub.Publisher mgmt *management.State - users *users.State + users *subjects.State journey *journey.State maxUploadSize int64 } @@ -123,9 +123,9 @@ func (srv *UsersController) IdentifyUser(w http.ResponseWriter, r *http.Request, } defer tx.Rollback() //nolint:errcheck - usersStore := users.NewUsersStore(tx) + usersStore := subjects.NewUsersStore(tx) - params := users.UpsertUserParams{ + params := subjects.UpsertUserParams{ AnonymousID: body.AnonymousId, ExternalID: body.ExternalId, Email: body.Email, @@ -243,7 +243,7 @@ func (srv *UsersController) UpdateUser(w http.ResponseWriter, r *http.Request, p logger.Info("updating user") - update := users.UserUpdate{ + update := subjects.UserUpdate{ Email: body.Email, Phone: body.Phone, Timezone: body.Timezone, @@ -641,7 +641,7 @@ func (srv *UsersController) processUserImport(ctx context.Context, logger *zap.L } defer tx.Rollback() //nolint:errcheck - usersStore := users.NewState(tx) + usersStore := subjects.NewState(tx) for { record, err := reader.Read() diff --git a/internal/http/controllers/v1/management/users_test.go b/internal/http/controllers/v1/management/users_test.go index 03b8e5ad..3ff5ab78 100644 --- a/internal/http/controllers/v1/management/users_test.go +++ b/internal/http/controllers/v1/management/users_test.go @@ -25,7 +25,7 @@ import ( "github.com/lunogram/platform/internal/store/journey" "github.com/lunogram/platform/internal/store/management" teststore "github.com/lunogram/platform/internal/store/test" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" ) @@ -94,7 +94,7 @@ func TestListUsers(t *testing.T) { usersStore := controller.users.UsersStore for i := 0; i < 5; i++ { - _, err := usersStore.CreateUser(ctx, users.User{ + _, err := usersStore.CreateUser(ctx, subjects.User{ ProjectID: projectID, AnonymousID: ptr(uuid.New().String()), Data: json.RawMessage(`{}`), @@ -153,7 +153,7 @@ func TestGetUser(t *testing.T) { ctx := context.Background() usersStore := controller.users.UsersStore - userID, err := usersStore.CreateUser(ctx, users.User{ + userID, err := usersStore.CreateUser(ctx, subjects.User{ ProjectID: projectID, AnonymousID: ptr("anon_get"), Email: ptr("get@example.com"), @@ -183,7 +183,7 @@ func TestUpdateUser(t *testing.T) { ctx := context.Background() usersStore := controller.users.UsersStore - userID, err := usersStore.CreateUser(ctx, users.User{ + userID, err := usersStore.CreateUser(ctx, subjects.User{ ProjectID: projectID, AnonymousID: ptr("anon_update"), Email: ptr("old@example.com"), @@ -227,7 +227,7 @@ func TestDeleteUser(t *testing.T) { ctx := context.Background() usersStore := controller.users.UsersStore - userID, err := usersStore.CreateUser(ctx, users.User{ + userID, err := usersStore.CreateUser(ctx, subjects.User{ ProjectID: projectID, AnonymousID: ptr("anon_delete"), Data: json.RawMessage(`{}`), @@ -253,7 +253,7 @@ func TestVersionIncrementsOnUpdate(t *testing.T) { ctx := context.Background() usersStore := controller.users.UsersStore - userID, err := usersStore.CreateUser(ctx, users.User{ + userID, err := usersStore.CreateUser(ctx, subjects.User{ ProjectID: projectID, AnonymousID: ptr("anon_version"), Data: json.RawMessage(`{}`), @@ -290,7 +290,7 @@ func TestGetUserEvents(t *testing.T) { ctx := context.Background() usersStore := controller.users.UsersStore - userID, err := usersStore.CreateUser(ctx, users.User{ + userID, err := usersStore.CreateUser(ctx, subjects.User{ ProjectID: projectID, AnonymousID: ptr("anon_events"), Data: json.RawMessage(`{}`), @@ -298,7 +298,7 @@ func TestGetUserEvents(t *testing.T) { require.NoError(t, err) for i := 0; i < 3; i++ { - _, err := usersStore.CreateUserEvent(ctx, users.UserEvent{ + _, err := usersStore.CreateUserEvent(ctx, subjects.UserEvent{ ProjectID: projectID, UserID: userID, Name: "page_viewed", @@ -346,7 +346,7 @@ func TestGetUserSubscriptions(t *testing.T) { ctx := context.Background() usersStore := controller.users.UsersStore - userID, err := usersStore.CreateUser(ctx, users.User{ + userID, err := usersStore.CreateUser(ctx, subjects.User{ ProjectID: projectID, AnonymousID: ptr("anon_subscriptions"), Data: json.RawMessage(`{}`), @@ -403,7 +403,7 @@ func TestUpdateUserSubscriptions(t *testing.T) { ctx := context.Background() usersStore := controller.users.UsersStore - userID, err := usersStore.CreateUser(ctx, users.User{ + userID, err := usersStore.CreateUser(ctx, subjects.User{ ProjectID: projectID, AnonymousID: ptr("anon_update_subs"), Data: json.RawMessage(`{}`), @@ -452,7 +452,7 @@ func TestUpdateUserSubscriptionsNotFound(t *testing.T) { ctx := context.Background() usersStore := controller.users.UsersStore - userID, err := usersStore.CreateUser(ctx, users.User{ + userID, err := usersStore.CreateUser(ctx, subjects.User{ ProjectID: projectID, AnonymousID: ptr("anon_sub_not_found"), Data: json.RawMessage(`{}`), @@ -487,7 +487,7 @@ func TestGetUserJourneys(t *testing.T) { ctx := context.Background() usersStore := controller.users.UsersStore - userID, err := usersStore.CreateUser(ctx, users.User{ + userID, err := usersStore.CreateUser(ctx, subjects.User{ ProjectID: projectID, AnonymousID: ptr("anon_journeys"), Data: json.RawMessage(`{}`), @@ -553,7 +553,7 @@ func TestGetUserJourneysPagination(t *testing.T) { ctx := context.Background() usersStore := controller.users.UsersStore - userID, err := usersStore.CreateUser(ctx, users.User{ + userID, err := usersStore.CreateUser(ctx, subjects.User{ ProjectID: projectID, AnonymousID: ptr("anon_journeys_page"), Data: json.RawMessage(`{}`), @@ -830,7 +830,7 @@ func TestImportUsers(t *testing.T) { }) require.NoError(t, err) - usersStore := users.NewUsersStore(usrsDB) + usersStore := subjects.NewUsersStore(usrsDB) mgmt := management.NewState(mgmtDB) controller := NewUsersController(logger, pub, usrsDB, jrnyDB, mgmt, 32<<20) diff --git a/internal/importer/users.go b/internal/importer/users.go index e8229585..b2722b26 100644 --- a/internal/importer/users.go +++ b/internal/importer/users.go @@ -4,21 +4,21 @@ import ( "errors" "strings" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" ) var ErrMissingExternalID = errors.New("external_id column is required") -var UserFieldMap = map[string]func(*users.UpsertUserParams, string){ - "external_id": func(u *users.UpsertUserParams, v string) { u.ExternalID = &v }, - "email": func(u *users.UpsertUserParams, v string) { u.Email = &v }, - "phone": func(u *users.UpsertUserParams, v string) { u.Phone = &v }, - "timezone": func(u *users.UpsertUserParams, v string) { u.Timezone = &v }, - "locale": func(u *users.UpsertUserParams, v string) { u.Locale = &v }, +var UserFieldMap = map[string]func(*subjects.UpsertUserParams, string){ + "external_id": func(u *subjects.UpsertUserParams, v string) { u.ExternalID = &v }, + "email": func(u *subjects.UpsertUserParams, v string) { u.Email = &v }, + "phone": func(u *subjects.UpsertUserParams, v string) { u.Phone = &v }, + "timezone": func(u *subjects.UpsertUserParams, v string) { u.Timezone = &v }, + "locale": func(u *subjects.UpsertUserParams, v string) { u.Locale = &v }, } func NewUsers(headers []string) (*UserMapper, error) { - setters := make([]func(*users.UpsertUserParams, string), len(headers)) + setters := make([]func(*subjects.UpsertUserParams, string), len(headers)) data := make([]string, len(headers)) hasExternalID := false @@ -49,13 +49,13 @@ func NewUsers(headers []string) (*UserMapper, error) { } type UserMapper struct { - Setters []func(*users.UpsertUserParams, string) + Setters []func(*subjects.UpsertUserParams, string) Data []string Headers []string } -func (m *UserMapper) MapRecord(record []string) (users.UpsertUserParams, error) { - user := users.UpsertUserParams{} +func (m *UserMapper) MapRecord(record []string) (subjects.UpsertUserParams, error) { + user := subjects.UpsertUserParams{} user.Data = make(map[string]any) for index, value := range record { diff --git a/internal/importer/users_test.go b/internal/importer/users_test.go index 14dc77d9..77b86f92 100644 --- a/internal/importer/users_test.go +++ b/internal/importer/users_test.go @@ -3,7 +3,7 @@ package importer import ( "testing" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/stretchr/testify/require" ) @@ -65,14 +65,14 @@ func TestUserMapperMapRecord(t *testing.T) { type test struct { headers []string record []string - validate func(*testing.T, users.UpsertUserParams) + validate func(*testing.T, subjects.UpsertUserParams) } tests := map[string]test{ "standard fields": { headers: []string{"external_id", "email", "phone", "timezone", "locale"}, record: []string{"user-123", "test@example.com", "+1234567890", "UTC", "en-US"}, - validate: func(t *testing.T, user users.UpsertUserParams) { + validate: func(t *testing.T, user subjects.UpsertUserParams) { require.NotNil(t, user.ExternalID) require.Equal(t, "user-123", *user.ExternalID) require.NotNil(t, user.Email) @@ -89,7 +89,7 @@ func TestUserMapperMapRecord(t *testing.T) { "out of order fields": { headers: []string{"email", "external_id", "timezone"}, record: []string{"test@example.com", "user-456", "America/New_York"}, - validate: func(t *testing.T, user users.UpsertUserParams) { + validate: func(t *testing.T, user subjects.UpsertUserParams) { require.NotNil(t, user.ExternalID) require.Equal(t, "user-456", *user.ExternalID) require.NotNil(t, user.Email) @@ -101,7 +101,7 @@ func TestUserMapperMapRecord(t *testing.T) { "with custom fields": { headers: []string{"external_id", "email", "company", "role"}, record: []string{"user-789", "admin@example.com", "Acme Inc", "Admin"}, - validate: func(t *testing.T, user users.UpsertUserParams) { + validate: func(t *testing.T, user subjects.UpsertUserParams) { require.NotNil(t, user.ExternalID) require.Equal(t, "user-789", *user.ExternalID) require.NotNil(t, user.Email) @@ -114,7 +114,7 @@ func TestUserMapperMapRecord(t *testing.T) { "only custom fields": { headers: []string{"external_id", "department", "employee_id"}, record: []string{"user-999", "Engineering", "EMP-001"}, - validate: func(t *testing.T, user users.UpsertUserParams) { + validate: func(t *testing.T, user subjects.UpsertUserParams) { require.NotNil(t, user.ExternalID) require.Equal(t, "user-999", *user.ExternalID) require.NotNil(t, user.Data) @@ -125,7 +125,7 @@ func TestUserMapperMapRecord(t *testing.T) { "with whitespace": { headers: []string{"external_id", "email", "phone"}, record: []string{" user-111 ", " test@example.com ", " +1234567890 "}, - validate: func(t *testing.T, user users.UpsertUserParams) { + validate: func(t *testing.T, user subjects.UpsertUserParams) { require.NotNil(t, user.ExternalID) require.Equal(t, "user-111", *user.ExternalID) require.NotNil(t, user.Email) @@ -137,7 +137,7 @@ func TestUserMapperMapRecord(t *testing.T) { "minimal record": { headers: []string{"external_id"}, record: []string{"user-minimal"}, - validate: func(t *testing.T, user users.UpsertUserParams) { + validate: func(t *testing.T, user subjects.UpsertUserParams) { require.NotNil(t, user.ExternalID) require.Equal(t, "user-minimal", *user.ExternalID) require.Nil(t, user.Email) @@ -150,7 +150,7 @@ func TestUserMapperMapRecord(t *testing.T) { "empty values": { headers: []string{"external_id", "email", "phone"}, record: []string{"user-empty", "", ""}, - validate: func(t *testing.T, user users.UpsertUserParams) { + validate: func(t *testing.T, user subjects.UpsertUserParams) { require.NotNil(t, user.ExternalID) require.Equal(t, "user-empty", *user.ExternalID) require.NotNil(t, user.Email) @@ -162,7 +162,7 @@ func TestUserMapperMapRecord(t *testing.T) { "mixed standard and custom fields": { headers: []string{"external_id", "email", "subscription_tier", "phone", "join_date"}, record: []string{"user-mixed", "user@example.com", "premium", "+1234567890", "2025-01-01"}, - validate: func(t *testing.T, user users.UpsertUserParams) { + validate: func(t *testing.T, user subjects.UpsertUserParams) { require.NotNil(t, user.ExternalID) require.Equal(t, "user-mixed", *user.ExternalID) require.NotNil(t, user.Email) diff --git a/internal/journeys/event.go b/internal/journeys/event.go index 151f7610..6ea59767 100644 --- a/internal/journeys/event.go +++ b/internal/journeys/event.go @@ -7,7 +7,7 @@ import ( "github.com/lunogram/platform/internal/http/controllers/v1/management/oapi" "github.com/lunogram/platform/internal/pubsub/schemas" "github.com/lunogram/platform/internal/store/journey" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/osteele/liquid" ) @@ -34,7 +34,7 @@ func HandleEvent(ctx HandlerContext, step journey.JourneyVersionStep, state jour } } - usersStore := users.NewUsersStore(ctx.DB) + usersStore := subjects.NewUsersStore(ctx.DB) user, err := usersStore.GetUser(ctx, ctx.ProjectID, ctx.UserID) if err != nil { return state, nil, fmt.Errorf("failed to get user: %w", err) diff --git a/internal/journeys/update.go b/internal/journeys/update.go index c3354f74..74e2c618 100644 --- a/internal/journeys/update.go +++ b/internal/journeys/update.go @@ -7,7 +7,7 @@ import ( "github.com/lunogram/platform/internal/http/controllers/v1/management/oapi" "github.com/lunogram/platform/internal/pubsub/schemas" "github.com/lunogram/platform/internal/store/journey" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/osteele/liquid" ) @@ -36,8 +36,8 @@ func HandleUpdate(ctx HandlerContext, step journey.JourneyVersionStep, state jou updated := json.RawMessage(rendered) - usersStore := users.NewUsersStore(ctx.DB) - err = usersStore.UpdateUser(ctx, ctx.UserID, users.UserUpdate{ + usersStore := subjects.NewUsersStore(ctx.DB) + err = usersStore.UpdateUser(ctx, ctx.UserID, subjects.UserUpdate{ Data: &updated, }) if err != nil { diff --git a/internal/journeys/update_test.go b/internal/journeys/update_test.go index 97eefeb3..eb368dc9 100644 --- a/internal/journeys/update_test.go +++ b/internal/journeys/update_test.go @@ -12,17 +12,17 @@ import ( "github.com/lunogram/platform/internal/store/journey" "github.com/lunogram/platform/internal/store/management" teststore "github.com/lunogram/platform/internal/store/test" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -func setupStore(t *testing.T) (*management.State, *users.State, *sqlx.DB) { +func setupStore(t *testing.T) (*management.State, *subjects.State, *sqlx.DB) { t.Helper() mgmt, usrs, _ := teststore.RunPostgreSQL(t) - return management.NewState(mgmt), users.NewState(usrs), usrs + return management.NewState(mgmt), subjects.NewState(usrs), usrs } func TestHandleUpdate(t *testing.T) { @@ -129,7 +129,7 @@ func TestHandleUpdate(t *testing.T) { for name, tc := range tests { t.Run(name, func(t *testing.T) { initialData, _ := json.Marshal(tc.initialUserData) - userID, err := usersStore.CreateUser(ctx, users.User{ + userID, err := usersStore.CreateUser(ctx, subjects.User{ ProjectID: project, Data: json.RawMessage(initialData), AnonymousID: ptr("anon_" + uuid.New().String()), @@ -247,7 +247,7 @@ func TestHandleUpdateTemplateRendering(t *testing.T) { for name, tc := range tests { t.Run(name, func(t *testing.T) { - userID, err := usersStore.CreateUser(ctx, users.User{ + userID, err := usersStore.CreateUser(ctx, subjects.User{ ProjectID: project, Data: json.RawMessage(`{}`), AnonymousID: ptr("anon_" + uuid.New().String()), diff --git a/internal/providers/channels/channels.go b/internal/providers/channels/channels.go index f6c89fa6..0fcf520e 100644 --- a/internal/providers/channels/channels.go +++ b/internal/providers/channels/channels.go @@ -4,15 +4,15 @@ import ( "fmt" "github.com/lunogram/platform/internal/store/management" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/lunogram/platform/pkg/modules/providers" ) type ComposeOptions struct { - Devices users.Devices + Devices subjects.Devices } -func Compose(channel providers.Channel, config map[string]any, template management.Template, user *users.User, opts *ComposeOptions) (*providers.SendRequest[map[string]any], error) { +func Compose(channel providers.Channel, config map[string]any, template management.Template, user *subjects.User, opts *ComposeOptions) (*providers.SendRequest[map[string]any], error) { switch channel { case providers.ChannelEmail: return ComposeEmail(config, template, user) diff --git a/internal/providers/channels/email.go b/internal/providers/channels/email.go index 686adc28..7b33b052 100644 --- a/internal/providers/channels/email.go +++ b/internal/providers/channels/email.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/lunogram/platform/internal/store/management" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/lunogram/platform/pkg/modules/providers" ) @@ -28,7 +28,7 @@ type EmailTemplateData struct { Bcc string `json:"bcc,omitempty"` } -func ComposeEmail(config map[string]any, template management.Template, user *users.User) (*providers.SendRequest[map[string]any], error) { +func ComposeEmail(config map[string]any, template management.Template, user *subjects.User) (*providers.SendRequest[map[string]any], error) { if user.Email == nil { return nil, fmt.Errorf("user has no email address") } diff --git a/internal/providers/channels/push.go b/internal/providers/channels/push.go index 3e78fe68..8134df73 100644 --- a/internal/providers/channels/push.go +++ b/internal/providers/channels/push.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/lunogram/platform/internal/store/management" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/lunogram/platform/pkg/modules/providers" ) @@ -16,7 +16,7 @@ type PushTemplateData struct { Data map[string]any `json:"data,omitempty"` } -func ComposePush(config map[string]any, template management.Template, user *users.User, devices users.Devices) (*providers.SendRequest[map[string]any], error) { +func ComposePush(config map[string]any, template management.Template, user *subjects.User, devices subjects.Devices) (*providers.SendRequest[map[string]any], error) { if !user.HasPushDevice { return nil, fmt.Errorf("user has no push-enabled device") } diff --git a/internal/providers/channels/sms.go b/internal/providers/channels/sms.go index e572b5fc..9b91bf8a 100644 --- a/internal/providers/channels/sms.go +++ b/internal/providers/channels/sms.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/lunogram/platform/internal/store/management" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/lunogram/platform/pkg/modules/providers" ) @@ -14,7 +14,7 @@ type SMSTemplateData struct { Body string `json:"body"` } -func ComposeSMS(config map[string]any, template management.Template, user *users.User) (*providers.SendRequest[map[string]any], error) { +func ComposeSMS(config map[string]any, template management.Template, user *subjects.User) (*providers.SendRequest[map[string]any], error) { if user.Phone == nil { return nil, fmt.Errorf("user has no phone number") } diff --git a/internal/pubsub/consumer/campaigns.go b/internal/pubsub/consumer/campaigns.go index 96f35e9a..2f6bcc6a 100644 --- a/internal/pubsub/consumer/campaigns.go +++ b/internal/pubsub/consumer/campaigns.go @@ -8,7 +8,7 @@ import ( "github.com/lunogram/platform/internal/providers/channels" "github.com/lunogram/platform/internal/pubsub/schemas" "github.com/lunogram/platform/internal/store/management" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/lunogram/platform/pkg/modules/providers" "github.com/nats-io/nats.go/jetstream" "go.uber.org/zap" @@ -16,7 +16,7 @@ import ( internalProviders "github.com/lunogram/platform/internal/providers" ) -func CampaignsSendHandler(logger *zap.Logger, mgmt *management.State, usrs *users.State, registry *internalProviders.Registry) HandlerFunc { +func CampaignsSendHandler(logger *zap.Logger, mgmt *management.State, usrs *subjects.State, registry *internalProviders.Registry) HandlerFunc { return func(ctx context.Context, msg jetstream.Msg) error { var event schemas.SendCampaign if err := json.Unmarshal(msg.Data(), &event); err != nil { diff --git a/internal/pubsub/consumer/consumer.go b/internal/pubsub/consumer/consumer.go index 645c1ab0..c3a2eb0b 100644 --- a/internal/pubsub/consumer/consumer.go +++ b/internal/pubsub/consumer/consumer.go @@ -7,7 +7,7 @@ import ( "github.com/lunogram/platform/internal/store" "github.com/lunogram/platform/internal/store/journey" "github.com/lunogram/platform/internal/store/management" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/nats-io/nats.go/jetstream" "go.uber.org/zap" ) @@ -33,7 +33,7 @@ const ( ) // Serve starts all JetStream consumers and registers their handlers. -func Serve(ctx graceful.Context, jet jetstream.JetStream, logger *zap.Logger, db *store.Connections, mgmt *management.State, usrs *users.State, jrny *journey.State, registry *providers.Registry) { +func Serve(ctx graceful.Context, jet jetstream.JetStream, logger *zap.Logger, db *store.Connections, mgmt *management.State, usrs *subjects.State, jrny *journey.State, registry *providers.Registry) { pub := pubsub.NewPublisher(jet) router := NewRouter(ctx, jet, logger) @@ -42,6 +42,6 @@ func Serve(ctx graceful.Context, jet jetstream.JetStream, logger *zap.Logger, db router.Handle(StreamEvents, ConsumerEventsProcess, EventsHandler(logger, usrs, jrny, pub)) router.Handle(StreamEvents, ConsumerEventsSchema, EventSchemasHandler(logger, usrs)) router.Handle(StreamLists, ConsumerListsRecompute, RecomputeListHandler(logger, usrs, pub)) - router.Handle(StreamJourneys, ConsumerJourneysAdvance, JourneyStepHandler(logger, db.Users, jrny, pub)) + router.Handle(StreamJourneys, ConsumerJourneysAdvance, JourneyStepHandler(logger, db.Subjects, jrny, pub)) router.Handle(StreamCampaigns, ConsumerCampaignsSend, CampaignsSendHandler(logger, mgmt, usrs, registry)) } diff --git a/internal/pubsub/consumer/events.go b/internal/pubsub/consumer/events.go index 288df945..dcba6b45 100644 --- a/internal/pubsub/consumer/events.go +++ b/internal/pubsub/consumer/events.go @@ -12,7 +12,7 @@ import ( "github.com/lunogram/platform/internal/rules" "github.com/lunogram/platform/internal/rules/eval" "github.com/lunogram/platform/internal/store/journey" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/nats-io/nats.go/jetstream" "go.uber.org/zap" "golang.org/x/sync/errgroup" @@ -29,7 +29,7 @@ type JourneyStep struct { } // EventsHandler creates a handler that processes incoming events and stores them in the database. -func EventsHandler(logger *zap.Logger, usrs *users.State, jrny *journey.State, pub pubsub.Publisher) HandlerFunc { +func EventsHandler(logger *zap.Logger, usrs *subjects.State, jrny *journey.State, pub pubsub.Publisher) HandlerFunc { return func(ctx context.Context, msg jetstream.Msg) error { event := schemas.Event{} err := json.Unmarshal(msg.Data(), &event) @@ -96,7 +96,7 @@ func PublishEventSchema(ctx context.Context, logger *zap.Logger, pub pubsub.Publ // PublishEventListDependencies returns a function that publishes recompute messages for all lists // that depend on the given event through rule conditions. -func PublishEventListDependencies(ctx context.Context, logger *zap.Logger, usrs *users.State, pub pubsub.Publisher, event schemas.Event) func() error { +func PublishEventListDependencies(ctx context.Context, logger *zap.Logger, usrs *subjects.State, pub pubsub.Publisher, event schemas.Event) func() error { return func() error { lists, err := usrs.ListEventListDependencies(ctx, event.ID) if err != nil { @@ -123,7 +123,7 @@ func PublishEventListDependencies(ctx context.Context, logger *zap.Logger, usrs // PublishEventJourneyDependencies returns a function that triggers journey entrance steps // for all journeys configured with event-based entrance conditions matching the given event. -func PublishEventJourneyDependencies(ctx context.Context, logger *zap.Logger, usrs *users.State, jrny *journey.State, pub pubsub.Publisher, event schemas.Event) func() error { +func PublishEventJourneyDependencies(ctx context.Context, logger *zap.Logger, usrs *subjects.State, jrny *journey.State, pub pubsub.Publisher, event schemas.Event) func() error { evaluator := eval.NewEvaluator() return func() error { @@ -208,7 +208,7 @@ func PublishEventJourneyDependencies(ctx context.Context, logger *zap.Logger, us } // EventSchemasHandler creates a handler that extracts and stores event schema information. -func EventSchemasHandler(logger *zap.Logger, usrs *users.State) HandlerFunc { +func EventSchemasHandler(logger *zap.Logger, usrs *subjects.State) HandlerFunc { return func(ctx context.Context, msg jetstream.Msg) error { event := schemas.Event{} err := json.Unmarshal(msg.Data(), &event) diff --git a/internal/pubsub/consumer/events_test.go b/internal/pubsub/consumer/events_test.go index ab015de8..f9cda44d 100644 --- a/internal/pubsub/consumer/events_test.go +++ b/internal/pubsub/consumer/events_test.go @@ -15,7 +15,7 @@ import ( "github.com/lunogram/platform/internal/store/journey" "github.com/lunogram/platform/internal/store/management" teststore "github.com/lunogram/platform/internal/store/test" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/nats-io/nats.go/jetstream" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -65,10 +65,10 @@ func TestEventsProjectHandlerSuccess(t *testing.T) { err := Bootstrap(ctx, logger, jet) require.NoError(t, err) - usersState := users.NewState(usrsDB) + usersState := subjects.NewState(usrsDB) journeyState := journey.NewState(jrnyDB) email := "test@example.com" - userID, err := usersState.UsersStore.UpsertUser(ctx, projectID, users.UpsertUserParams{ + userID, err := usersState.UsersStore.UpsertUser(ctx, projectID, subjects.UpsertUserParams{ Email: &email, }) require.NoError(t, err) @@ -123,10 +123,10 @@ func TestEventsProjectHandlerWithoutData(t *testing.T) { err := Bootstrap(ctx, logger, jet) require.NoError(t, err) - usersState := users.NewState(usrsDB) + usersState := subjects.NewState(usrsDB) journeyState := journey.NewState(jrnyDB) email := "test2@example.com" - userID, err := usersState.UsersStore.UpsertUser(ctx, projectID, users.UpsertUserParams{ + userID, err := usersState.UsersStore.UpsertUser(ctx, projectID, subjects.UpsertUserParams{ Email: &email, }) require.NoError(t, err) @@ -173,12 +173,12 @@ func TestEventsProjectHandlerWithIdentifiers(t *testing.T) { err := Bootstrap(ctx, logger, jet) require.NoError(t, err) - usersState := users.NewState(usrsDB) + usersState := subjects.NewState(usrsDB) journeyState := journey.NewState(jrnyDB) externalID := "user_123" anonymousID := "anon_abc" - _, err = usersState.UsersStore.UpsertUser(ctx, projectID, users.UpsertUserParams{ + _, err = usersState.UsersStore.UpsertUser(ctx, projectID, subjects.UpsertUserParams{ ExternalID: &externalID, AnonymousID: &anonymousID, }) @@ -220,7 +220,7 @@ func TestEventsSchemaHandlerSuccess(t *testing.T) { err := Bootstrap(ctx, logger, jet) require.NoError(t, err) - usersState := users.NewState(usrsDB) + usersState := subjects.NewState(usrsDB) eventID, err := usersState.EventsStore.UpsertEvent(ctx, projectID, "test_event") require.NoError(t, err) @@ -265,7 +265,7 @@ func TestEventsSchemaHandlerComplexNestedData(t *testing.T) { err := Bootstrap(ctx, logger, jet) require.NoError(t, err) - usersState := users.NewState(usrsDB) + usersState := subjects.NewState(usrsDB) eventID, err := usersState.EventsStore.UpsertEvent(ctx, projectID, "complex_event") require.NoError(t, err) diff --git a/internal/pubsub/consumer/recompute.go b/internal/pubsub/consumer/recompute.go index f37e935e..3328f1db 100644 --- a/internal/pubsub/consumer/recompute.go +++ b/internal/pubsub/consumer/recompute.go @@ -7,7 +7,7 @@ import ( "github.com/google/uuid" "github.com/lunogram/platform/internal/pubsub" "github.com/lunogram/platform/internal/pubsub/schemas" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/nats-io/nats.go/jetstream" "go.uber.org/zap" ) @@ -30,7 +30,7 @@ type RecomputeList struct { // // Membership recomputation is idempotent and handled entirely in the database; // the handler itself does not batch, debounce, or persist recompute state. -func RecomputeListHandler(logger *zap.Logger, usrs *users.State, pub pubsub.Publisher) HandlerFunc { +func RecomputeListHandler(logger *zap.Logger, usrs *subjects.State, pub pubsub.Publisher) HandlerFunc { return func(ctx context.Context, msg jetstream.Msg) error { event := RecomputeList{} err := json.Unmarshal(msg.Data(), &event) @@ -70,10 +70,10 @@ func RecomputeListHandler(logger *zap.Logger, usrs *users.State, pub pubsub.Publ } } -func PublishListRecomputeEvents(ctx context.Context, logger *zap.Logger, pub pubsub.Publisher, projectID uuid.UUID, listID uuid.UUID, recomputed []users.Recomputed) (err error) { +func PublishListRecomputeEvents(ctx context.Context, logger *zap.Logger, pub pubsub.Publisher, projectID uuid.UUID, listID uuid.UUID, recomputed []subjects.Recomputed) (err error) { for _, applied := range recomputed { switch applied.Action { - case users.RecomputeActionInserted: + case subjects.RecomputeActionInserted: event := schemas.Event{ Name: schemas.EventListUserAdded, UserID: applied.UserID, @@ -88,7 +88,7 @@ func PublishListRecomputeEvents(ctx context.Context, logger *zap.Logger, pub pub logger.Error("failed to publish user list inserted event", zap.Error(err)) return err } - case users.RecomputeActionDeleted: + case subjects.RecomputeActionDeleted: event := schemas.Event{ Name: schemas.EventListUserRemoved, UserID: applied.UserID, diff --git a/internal/pubsub/consumer/recompute_test.go b/internal/pubsub/consumer/recompute_test.go index ec88c879..6e737885 100644 --- a/internal/pubsub/consumer/recompute_test.go +++ b/internal/pubsub/consumer/recompute_test.go @@ -15,14 +15,14 @@ import ( "github.com/lunogram/platform/internal/store" "github.com/lunogram/platform/internal/store/management" teststore "github.com/lunogram/platform/internal/store/test" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/nats-io/nats.go/jetstream" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" ) -func setupRecomputeTest(t *testing.T) (*users.State, uuid.UUID, jetstream.JetStream) { +func setupRecomputeTest(t *testing.T) (*subjects.State, uuid.UUID, jetstream.JetStream) { t.Helper() ctx := graceful.NewContext(t.Context()) @@ -40,7 +40,7 @@ func setupRecomputeTest(t *testing.T) (*users.State, uuid.UUID, jetstream.JetStr require.NoError(t, err) mgmtState := management.NewState(mgmt) - usersState := users.NewState(usrs) + usersState := subjects.NewState(usrs) orgID, err := mgmtState.OrganizationsStore.CreateOrganization(ctx, "Test Org") require.NoError(t, err) @@ -79,7 +79,7 @@ func TestRecomputeListHandlerSuccess(t *testing.T) { require.NoError(t, err) email := "test@example.com" - userID, err := st.UsersStore.UpsertUser(ctx, projectID, users.UpsertUserParams{ + userID, err := st.UsersStore.UpsertUser(ctx, projectID, subjects.UpsertUserParams{ Email: &email, Data: map[string]any{ "age": 25, @@ -98,7 +98,7 @@ func TestRecomputeListHandlerSuccess(t *testing.T) { }, } - ruleID, err := st.RulesStore.CreateRule(ctx, users.Rule{ + ruleID, err := st.RulesStore.CreateRule(ctx, subjects.Rule{ ProjectID: projectID, Rule: store.JSONB[rules.RuleSet]{Data: ruleset}, DependsOnUsers: true, @@ -107,7 +107,7 @@ func TestRecomputeListHandlerSuccess(t *testing.T) { }) require.NoError(t, err) - listID, err := st.ListsStore.CreateList(ctx, users.List{ + listID, err := st.ListsStore.CreateList(ctx, subjects.List{ ProjectID: projectID, Name: "Test List", Type: "static", @@ -155,7 +155,7 @@ func TestRecomputeListHandlerNoRule(t *testing.T) { err := Bootstrap(ctx, logger, jet) require.NoError(t, err) - listID, err := st.ListsStore.CreateList(ctx, users.List{ + listID, err := st.ListsStore.CreateList(ctx, subjects.List{ ProjectID: projectID, Name: "Test List Without Rule", Type: "static", @@ -195,7 +195,7 @@ func TestRecomputeListHandlerWithUserAddedEvent(t *testing.T) { require.NoError(t, err) email := "test@example.com" - userID, err := st.UsersStore.UpsertUser(ctx, projectID, users.UpsertUserParams{ + userID, err := st.UsersStore.UpsertUser(ctx, projectID, subjects.UpsertUserParams{ Email: &email, Data: map[string]any{ "age": 30, @@ -214,7 +214,7 @@ func TestRecomputeListHandlerWithUserAddedEvent(t *testing.T) { }, } - ruleID, err := st.RulesStore.CreateRule(ctx, users.Rule{ + ruleID, err := st.RulesStore.CreateRule(ctx, subjects.Rule{ ProjectID: projectID, Rule: store.JSONB[rules.RuleSet]{Data: ruleset}, DependsOnUsers: true, @@ -223,7 +223,7 @@ func TestRecomputeListHandlerWithUserAddedEvent(t *testing.T) { }) require.NoError(t, err) - listID, err := st.ListsStore.CreateList(ctx, users.List{ + listID, err := st.ListsStore.CreateList(ctx, subjects.List{ ProjectID: projectID, Name: "Test List", Type: "static", @@ -286,10 +286,10 @@ func TestPublishListRecomputeEventsInserted(t *testing.T) { listID := uuid.New() userID := uuid.New() - recomputed := []users.Recomputed{ + recomputed := []subjects.Recomputed{ { UserID: userID, - Action: users.RecomputeActionInserted, + Action: subjects.RecomputeActionInserted, }, } @@ -315,10 +315,10 @@ func TestPublishListRecomputeEventsDeleted(t *testing.T) { listID := uuid.New() userID := uuid.New() - recomputed := []users.Recomputed{ + recomputed := []subjects.Recomputed{ { UserID: userID, - Action: users.RecomputeActionDeleted, + Action: subjects.RecomputeActionDeleted, }, } @@ -343,18 +343,18 @@ func TestPublishListRecomputeEventsMixed(t *testing.T) { projectID := uuid.New() listID := uuid.New() - recomputed := []users.Recomputed{ + recomputed := []subjects.Recomputed{ { UserID: uuid.New(), - Action: users.RecomputeActionInserted, + Action: subjects.RecomputeActionInserted, }, { UserID: uuid.New(), - Action: users.RecomputeActionDeleted, + Action: subjects.RecomputeActionDeleted, }, { UserID: uuid.New(), - Action: users.RecomputeActionInserted, + Action: subjects.RecomputeActionInserted, }, } diff --git a/internal/pubsub/consumer/users.go b/internal/pubsub/consumer/users.go index 85001c14..7d2503df 100644 --- a/internal/pubsub/consumer/users.go +++ b/internal/pubsub/consumer/users.go @@ -7,13 +7,13 @@ import ( "github.com/lunogram/platform/internal/pubsub" "github.com/lunogram/platform/internal/pubsub/schemas" "github.com/lunogram/platform/internal/rules" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/nats-io/nats.go/jetstream" "go.uber.org/zap" ) // UsersHandler creates a handler that processes incoming users and stores them in the database. -func UsersHandler(logger *zap.Logger, usrs *users.State, pub pubsub.Publisher) HandlerFunc { +func UsersHandler(logger *zap.Logger, usrs *subjects.State, pub pubsub.Publisher) HandlerFunc { return func(ctx context.Context, msg jetstream.Msg) error { user := schemas.User{} err := json.Unmarshal(msg.Data(), &user) @@ -49,7 +49,7 @@ func UsersHandler(logger *zap.Logger, usrs *users.State, pub pubsub.Publisher) H } } -func PublishUserRecomputeLists(ctx context.Context, logger *zap.Logger, usrs *users.State, pub pubsub.Publisher, user schemas.User) error { +func PublishUserRecomputeLists(ctx context.Context, logger *zap.Logger, usrs *subjects.State, pub pubsub.Publisher, user schemas.User) error { result, err := usrs.SelectListUsersDependency(ctx, user.ProjectID) if err != nil { logger.Error("failed to list rule user dependencies", zap.Error(err)) @@ -94,7 +94,7 @@ func PublishUserEvents(ctx context.Context, logger *zap.Logger, pub pubsub.Publi } // UserSchemasHandler creates a handler that extracts and stores event schema information. -func UserSchemasHandler(logger *zap.Logger, usrs *users.State) HandlerFunc { +func UserSchemasHandler(logger *zap.Logger, usrs *subjects.State) HandlerFunc { return func(ctx context.Context, msg jetstream.Msg) error { user := schemas.User{} err := json.Unmarshal(msg.Data(), &user) diff --git a/internal/pubsub/consumer/users_test.go b/internal/pubsub/consumer/users_test.go index 332bfbf5..e5bfe469 100644 --- a/internal/pubsub/consumer/users_test.go +++ b/internal/pubsub/consumer/users_test.go @@ -15,14 +15,14 @@ import ( "github.com/lunogram/platform/internal/store" "github.com/lunogram/platform/internal/store/management" teststore "github.com/lunogram/platform/internal/store/test" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/nats-io/nats.go/jetstream" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" ) -func setupUsersTest(t *testing.T) (*users.State, uuid.UUID, jetstream.JetStream) { +func setupUsersTest(t *testing.T) (*subjects.State, uuid.UUID, jetstream.JetStream) { t.Helper() ctx := graceful.NewContext(t.Context()) @@ -52,7 +52,7 @@ func setupUsersTest(t *testing.T) (*users.State, uuid.UUID, jetstream.JetStream) }) require.NoError(t, err) - usersState := users.NewState(usrs) + usersState := subjects.NewState(usrs) return usersState, projectID, jet } @@ -279,7 +279,7 @@ func TestUsersHandlerWithListDependencies(t *testing.T) { }, } - ruleID, err := usersState.RulesStore.CreateRule(ctx, users.Rule{ + ruleID, err := usersState.RulesStore.CreateRule(ctx, subjects.Rule{ ProjectID: projectID, Rule: store.JSONB[rules.RuleSet]{Data: ruleset}, DependsOnUsers: true, @@ -288,7 +288,7 @@ func TestUsersHandlerWithListDependencies(t *testing.T) { }) require.NoError(t, err) - _, err = usersState.ListsStore.CreateList(ctx, users.List{ + _, err = usersState.ListsStore.CreateList(ctx, subjects.List{ ProjectID: projectID, Name: "Test List", Type: "static", @@ -443,7 +443,7 @@ func TestPublishUserRecomputeListsSuccess(t *testing.T) { }, } - ruleID, err := usersState.RulesStore.CreateRule(ctx, users.Rule{ + ruleID, err := usersState.RulesStore.CreateRule(ctx, subjects.Rule{ ProjectID: projectID, Rule: store.JSONB[rules.RuleSet]{Data: ruleset}, DependsOnUsers: true, @@ -452,7 +452,7 @@ func TestPublishUserRecomputeListsSuccess(t *testing.T) { }) require.NoError(t, err) - listID, err := usersState.ListsStore.CreateList(ctx, users.List{ + listID, err := usersState.ListsStore.CreateList(ctx, subjects.List{ ProjectID: projectID, Name: "Adult List", Type: "static", diff --git a/internal/store/store.go b/internal/store/store.go index a90a04ce..829a75a3 100644 --- a/internal/store/store.go +++ b/internal/store/store.go @@ -21,14 +21,14 @@ import ( // Config contains database connection settings for all databases. type Config struct { ManagementURI string `env:"POSTGRES_MANAGEMENT_URI" envDefault:"postgres://postgres:password@postgres:5432/management?sslmode=disable"` - UsersURI string `env:"POSTGRES_USERS_URI" envDefault:"postgres://postgres:password@postgres:5432/users?sslmode=disable"` + SubjectsURI string `env:"POSTGRES_SUBJECTS_URI" envDefault:"postgres://postgres:password@postgres:5432/subjects?sslmode=disable"` JourneyURI string `env:"POSTGRES_JOURNEY_URI" envDefault:"postgres://postgres:password@postgres:5432/journey?sslmode=disable"` } // Connections holds all database connections. type Connections struct { Management *sqlx.DB - Users *sqlx.DB + Subjects *sqlx.DB Journey *sqlx.DB } @@ -41,22 +41,22 @@ func New(ctx graceful.Context, logger *zap.Logger, config Config) (*Connections, return nil, fmt.Errorf("failed to connect to management database: %w", err) } - users, err := sqlx.Connect("pgx", config.UsersURI) + subjects, err := sqlx.Connect("pgx", config.SubjectsURI) if err != nil { management.Close() - return nil, fmt.Errorf("failed to connect to users database: %w", err) + return nil, fmt.Errorf("failed to connect to subjects database: %w", err) } journey, err := sqlx.Connect("pgx", config.JourneyURI) if err != nil { management.Close() - users.Close() + subjects.Close() return nil, fmt.Errorf("failed to connect to journey database: %w", err) } conns := &Connections{ Management: management, - Users: users, + Subjects: subjects, Journey: journey, } @@ -66,8 +66,8 @@ func New(ctx graceful.Context, logger *zap.Logger, config Config) (*Connections, if err := management.Close(); err != nil { logger.Error("failed to close management database connection", zap.Error(err)) } - if err := users.Close(); err != nil { - logger.Error("failed to close users database connection", zap.Error(err)) + if err := subjects.Close(); err != nil { + logger.Error("failed to close subjects database connection", zap.Error(err)) } if err := journey.Close(); err != nil { logger.Error("failed to close journey database connection", zap.Error(err)) diff --git a/internal/store/users/devices.go b/internal/store/subjects/devices.go similarity index 99% rename from internal/store/users/devices.go rename to internal/store/subjects/devices.go index 3b937231..397e30ee 100644 --- a/internal/store/users/devices.go +++ b/internal/store/subjects/devices.go @@ -1,4 +1,4 @@ -package users +package subjects import ( "context" diff --git a/internal/store/users/events.go b/internal/store/subjects/events.go similarity index 99% rename from internal/store/users/events.go rename to internal/store/subjects/events.go index 36cd93f0..2de23034 100644 --- a/internal/store/users/events.go +++ b/internal/store/subjects/events.go @@ -1,4 +1,4 @@ -package users +package subjects import ( "context" diff --git a/internal/store/users/lists.go b/internal/store/subjects/lists.go similarity index 99% rename from internal/store/users/lists.go rename to internal/store/subjects/lists.go index 4e447d55..e143d5d9 100644 --- a/internal/store/users/lists.go +++ b/internal/store/subjects/lists.go @@ -1,4 +1,4 @@ -package users +package subjects import ( "context" diff --git a/internal/store/users/migrate.go b/internal/store/subjects/migrate.go similarity index 95% rename from internal/store/users/migrate.go rename to internal/store/subjects/migrate.go index 2da18612..d7ea1253 100644 --- a/internal/store/users/migrate.go +++ b/internal/store/subjects/migrate.go @@ -1,4 +1,4 @@ -package users +package subjects import ( "embed" diff --git a/internal/store/users/migrations/1764106028_migration.down.sql b/internal/store/subjects/migrations/1764106028_migration.down.sql similarity index 100% rename from internal/store/users/migrations/1764106028_migration.down.sql rename to internal/store/subjects/migrations/1764106028_migration.down.sql diff --git a/internal/store/users/migrations/1764106028_migration.up.sql b/internal/store/subjects/migrations/1764106028_migration.up.sql similarity index 100% rename from internal/store/users/migrations/1764106028_migration.up.sql rename to internal/store/subjects/migrations/1764106028_migration.up.sql diff --git a/internal/store/subjects/migrations/1771762205_organizations.down.sql b/internal/store/subjects/migrations/1771762205_organizations.down.sql new file mode 100644 index 00000000..1dfec0f6 --- /dev/null +++ b/internal/store/subjects/migrations/1771762205_organizations.down.sql @@ -0,0 +1,5 @@ +-- Drop organization users table first (depends on organizations) +DROP TABLE IF EXISTS organization_users; + +-- Drop organizations table +DROP TABLE IF EXISTS organizations; diff --git a/internal/store/subjects/migrations/1771762205_organizations.up.sql b/internal/store/subjects/migrations/1771762205_organizations.up.sql new file mode 100644 index 00000000..34a87ec1 --- /dev/null +++ b/internal/store/subjects/migrations/1771762205_organizations.up.sql @@ -0,0 +1,37 @@ +-- Organizations table +-- Stores organization/company data that can be used as event subjects +CREATE TABLE organizations ( + id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), + project_id UUID NOT NULL, + external_id VARCHAR(255) NOT NULL, + name VARCHAR(255), + data JSONB NOT NULL DEFAULT '{}'::jsonb, + version INTEGER NOT NULL DEFAULT 0, + created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE UNIQUE INDEX organizations_project_external_uniq ON organizations(project_id, external_id); +CREATE INDEX organizations_project_id_idx ON organizations(project_id); +CREATE INDEX organizations_data_idx ON organizations USING gin(data); + +CREATE TRIGGER set_updated_at_organizations BEFORE UPDATE ON organizations FOR EACH ROW EXECUTE PROCEDURE set_updated_at(); +CREATE TRIGGER increment_version_organizations BEFORE UPDATE ON organizations FOR EACH ROW EXECUTE PROCEDURE increment_version(); + +-- Organization users junction table +-- Links users to organizations with optional org-specific user data +CREATE TABLE organization_users ( + id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), + organization_id UUID NOT NULL REFERENCES organizations(id) ON DELETE CASCADE, + user_id UUID NOT NULL REFERENCES users(id) ON DELETE CASCADE, + data JSONB NOT NULL DEFAULT '{}'::jsonb, + created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE UNIQUE INDEX organization_users_org_user_uniq ON organization_users(organization_id, user_id); +CREATE INDEX organization_users_organization_id_idx ON organization_users(organization_id); +CREATE INDEX organization_users_user_id_idx ON organization_users(user_id); +CREATE INDEX organization_users_data_idx ON organization_users USING gin(data); + +CREATE TRIGGER set_updated_at_organization_users BEFORE UPDATE ON organization_users FOR EACH ROW EXECUTE PROCEDURE set_updated_at(); diff --git a/internal/store/subjects/organizations.go b/internal/store/subjects/organizations.go new file mode 100644 index 00000000..24bab6d7 --- /dev/null +++ b/internal/store/subjects/organizations.go @@ -0,0 +1,282 @@ +package subjects + +import ( + "context" + "encoding/json" + "time" + + "github.com/google/uuid" + "github.com/lunogram/platform/internal/store" +) + +type Organizations []Organization + +type Organization struct { + ID uuid.UUID `db:"id"` + ProjectID uuid.UUID `db:"project_id"` + ExternalID string `db:"external_id"` + Name *string `db:"name"` + Data json.RawMessage `db:"data"` + Version int32 `db:"version"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` +} + +func NewOrganizationsStore(db store.DB) *OrganizationsStore { + return &OrganizationsStore{db: db} +} + +type OrganizationsStore struct { + db store.DB +} + +// GetOrganization retrieves an organization by its internal ID. +func (s *OrganizationsStore) GetOrganization(ctx context.Context, projectID, orgID uuid.UUID) (*Organization, error) { + stmt := ` + SELECT id, project_id, external_id, name, data, version, created_at, updated_at + FROM organizations + WHERE id = $1 AND project_id = $2` + + var org Organization + err := s.db.GetContext(ctx, &org, stmt, orgID, projectID) + if err != nil { + return nil, err + } + + return &org, nil +} + +// GetOrganizationByExternalID retrieves an organization by its external ID. +func (s *OrganizationsStore) GetOrganizationByExternalID(ctx context.Context, projectID uuid.UUID, externalID string) (*Organization, error) { + stmt := ` + SELECT id, project_id, external_id, name, data, version, created_at, updated_at + FROM organizations + WHERE external_id = $1 AND project_id = $2` + + var org Organization + err := s.db.GetContext(ctx, &org, stmt, externalID, projectID) + if err != nil { + return nil, err + } + + return &org, nil +} + +type UpsertOrganizationParams struct { + ExternalID string + Name *string + Data map[string]any +} + +// UpsertOrganization creates or updates an organization by external ID. +func (s *OrganizationsStore) UpsertOrganization(ctx context.Context, projectID uuid.UUID, params UpsertOrganizationParams) (uuid.UUID, error) { + data := params.Data + if data == nil { + data = make(map[string]any) + } + + stmt := ` + INSERT INTO organizations (project_id, external_id, name, data) + VALUES ($1, $2, $3, $4) + ON CONFLICT (project_id, external_id) + DO UPDATE SET + name = COALESCE(EXCLUDED.name, organizations.name), + data = COALESCE(EXCLUDED.data, organizations.data) + RETURNING id` + + var id uuid.UUID + err := s.db.GetContext(ctx, &id, stmt, projectID, params.ExternalID, params.Name, data) + if err != nil { + return uuid.Nil, err + } + + return id, nil +} + +type OrganizationUpdate struct { + Name *string + Data *json.RawMessage +} + +// UpdateOrganization updates an organization's fields. For the data field, new values are merged +// with existing data using PostgreSQL's || operator (shallow merge). +func (s *OrganizationsStore) UpdateOrganization(ctx context.Context, projectID, orgID uuid.UUID, update OrganizationUpdate) error { + stmt := ` + UPDATE organizations + SET + name = COALESCE($3, name), + data = CASE + WHEN $4::jsonb IS NOT NULL THEN data || $4::jsonb + ELSE data + END + WHERE id = $1 AND project_id = $2` + + _, err := s.db.ExecContext(ctx, stmt, orgID, projectID, update.Name, update.Data) + return err +} + +// DeleteOrganization deletes an organization and all its user memberships (via CASCADE). +func (s *OrganizationsStore) DeleteOrganization(ctx context.Context, projectID, orgID uuid.UUID) error { + stmt := `DELETE FROM organizations WHERE id = $1 AND project_id = $2` + _, err := s.db.ExecContext(ctx, stmt, orgID, projectID) + return err +} + +// ListOrganizations lists all organizations for a project with pagination. +func (s *OrganizationsStore) ListOrganizations(ctx context.Context, projectID uuid.UUID, pagination store.Pagination) (Organizations, int, error) { + query := ` + SELECT + id, project_id, external_id, name, data, version, created_at, updated_at, + COUNT(*) OVER () AS total_count + FROM organizations + WHERE project_id = $1 + ORDER BY created_at DESC + LIMIT $2 OFFSET $3` + + type result struct { + Organization + TotalCount int `db:"total_count"` + } + + var results []result + err := s.db.SelectContext(ctx, &results, query, projectID, pagination.Limit, pagination.Offset) + if err != nil { + return nil, 0, err + } + + if len(results) == 0 { + return []Organization{}, 0, nil + } + + total := results[0].TotalCount + orgs := make([]Organization, len(results)) + + for i, r := range results { + orgs[i] = r.Organization + } + + return orgs, total, nil +} + +// OrganizationUser represents a user's membership in an organization. +type OrganizationUser struct { + ID uuid.UUID `db:"id"` + OrganizationID uuid.UUID `db:"organization_id"` + UserID uuid.UUID `db:"user_id"` + Data json.RawMessage `db:"data"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` +} + +// UpsertOrganizationMember adds or updates a user's membership in an organization with optional org-specific data. +func (s *OrganizationsStore) UpsertOrganizationMember(ctx context.Context, orgID, userID uuid.UUID, data map[string]any) error { + if data == nil { + data = make(map[string]any) + } + + stmt := ` + INSERT INTO organization_users (organization_id, user_id, data) + VALUES ($1, $2, $3) + ON CONFLICT (organization_id, user_id) DO UPDATE SET + data = organization_users.data || EXCLUDED.data` + + _, err := s.db.ExecContext(ctx, stmt, orgID, userID, data) + return err +} + +// RemoveUserFromOrganization removes a user from an organization. +func (s *OrganizationsStore) RemoveUserFromOrganization(ctx context.Context, orgID, userID uuid.UUID) error { + stmt := `DELETE FROM organization_users WHERE organization_id = $1 AND user_id = $2` + _, err := s.db.ExecContext(ctx, stmt, orgID, userID) + return err +} + +// UpdateOrganizationUserData updates the org-specific data for a user in an organization. +func (s *OrganizationsStore) UpdateOrganizationUserData(ctx context.Context, orgID, userID uuid.UUID, data json.RawMessage) error { + stmt := ` + UPDATE organization_users + SET data = data || $3::jsonb + WHERE organization_id = $1 AND user_id = $2` + + _, err := s.db.ExecContext(ctx, stmt, orgID, userID, data) + return err +} + +// OrganizationMember represents a user with their org-specific data. +type OrganizationMember struct { + User + OrganizationData json.RawMessage `db:"org_data"` +} + +type OrganizationMembers []OrganizationMember + +// ListOrganizationMembers lists all users belonging to an organization with pagination. +func (s *OrganizationsStore) ListOrganizationMembers(ctx context.Context, projectID, orgID uuid.UUID, pagination store.Pagination) (OrganizationMembers, int, error) { + query := ` + SELECT + u.id, u.project_id, u.anonymous_id, u.external_id, u.email, u.phone, u.data, u.timezone, u.locale, u.version, u.created_at, u.updated_at, + EXISTS( + SELECT 1 FROM devices d + WHERE d.user_id = u.id + AND d.token IS NOT NULL + AND d.token != '' + ) as has_push_device, + ou.data as org_data, + COUNT(*) OVER () AS total_count + FROM users u + INNER JOIN organization_users ou ON u.id = ou.user_id + WHERE ou.organization_id = $1 AND u.project_id = $2 + ORDER BY ou.created_at DESC + LIMIT $3 OFFSET $4` + + type result struct { + OrganizationMember + TotalCount int `db:"total_count"` + } + + var results []result + err := s.db.SelectContext(ctx, &results, query, orgID, projectID, pagination.Limit, pagination.Offset) + if err != nil { + return nil, 0, err + } + + if len(results) == 0 { + return []OrganizationMember{}, 0, nil + } + + total := results[0].TotalCount + members := make([]OrganizationMember, len(results)) + + for i, r := range results { + members[i] = r.OrganizationMember + } + + return members, total, nil +} + +// ListUserOrganizations lists all organizations a user belongs to. +func (s *OrganizationsStore) ListUserOrganizations(ctx context.Context, projectID, userID uuid.UUID) ([]Organization, error) { + query := ` + SELECT o.id, o.project_id, o.external_id, o.name, o.data, o.version, o.created_at, o.updated_at + FROM organizations o + INNER JOIN organization_users ou ON o.id = ou.organization_id + WHERE ou.user_id = $1 AND o.project_id = $2 + ORDER BY ou.created_at DESC` + + var orgs []Organization + err := s.db.SelectContext(ctx, &orgs, query, userID, projectID) + if err != nil { + return nil, err + } + + return orgs, nil +} + +// CountOrganizationMembers returns the number of members in an organization. +func (s *OrganizationsStore) CountOrganizationMembers(ctx context.Context, orgID uuid.UUID) (int, error) { + query := `SELECT COUNT(*) FROM organization_users WHERE organization_id = $1` + + var count int + err := s.db.GetContext(ctx, &count, query, orgID) + return count, err +} diff --git a/internal/store/subjects/organizations_test.go b/internal/store/subjects/organizations_test.go new file mode 100644 index 00000000..83fc9af7 --- /dev/null +++ b/internal/store/subjects/organizations_test.go @@ -0,0 +1,578 @@ +package subjects + +import ( + "context" + "encoding/json" + "testing" + + "github.com/google/uuid" + "github.com/lunogram/platform/internal/store" + "github.com/stretchr/testify/require" +) + +func TestGetOrganizationByExternalID(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + externalID := "org_external_123" + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: externalID, + Name: ptr("Test Organization"), + }) + require.NoError(t, err) + + org, err := db.GetOrganizationByExternalID(ctx, projectID, externalID) + require.NoError(t, err) + require.Equal(t, orgID, org.ID) + require.Equal(t, externalID, org.ExternalID) +} + +func TestListOrganizations(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Create multiple orgs + for i := 0; i < 5; i++ { + _, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: uuid.New().String(), + Name: ptr("Test Org"), + }) + require.NoError(t, err) + } + + type test struct { + pagination store.Pagination + expectedCount int + expectedTotal int + } + + tests := map[string]test{ + "first page": { + pagination: store.Pagination{Limit: 2, Offset: 0}, + expectedCount: 2, + expectedTotal: 5, + }, + "second page": { + pagination: store.Pagination{Limit: 2, Offset: 2}, + expectedCount: 2, + expectedTotal: 5, + }, + "last page partial": { + pagination: store.Pagination{Limit: 2, Offset: 4}, + expectedCount: 1, + expectedTotal: 5, + }, + "all orgs": { + pagination: store.Pagination{Limit: 10, Offset: 0}, + expectedCount: 5, + expectedTotal: 5, + }, + } + + for name, tt := range tests { + t.Run(name, func(t *testing.T) { + orgs, total, err := db.ListOrganizations(ctx, projectID, tt.pagination) + require.NoError(t, err) + require.Equal(t, tt.expectedCount, len(orgs)) + require.Equal(t, tt.expectedTotal, total) + }) + } +} + +func TestUpsertOrganization(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + type test struct { + setupOrg *Organization + upsertData UpsertOrganizationParams + expectedName *string + description string + } + + tests := map[string]test{ + "insert new org": { + upsertData: UpsertOrganizationParams{ + ExternalID: "new_org", + Name: ptr("New Organization"), + Data: map[string]any{"plan": "free"}, + }, + expectedName: ptr("New Organization"), + description: "should create new org", + }, + "update existing org by external_id": { + setupOrg: &Organization{ + ProjectID: projectID, + ExternalID: "existing_org", + Name: ptr("Old Name"), + }, + upsertData: UpsertOrganizationParams{ + ExternalID: "existing_org", + Name: ptr("Updated Name"), + Data: map[string]any{}, + }, + expectedName: ptr("Updated Name"), + description: "should update name on conflict", + }, + } + + for name, tt := range tests { + t.Run(name, func(t *testing.T) { + var existingOrgID uuid.UUID + if tt.setupOrg != nil { + var err error + existingOrgID, err = db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: tt.setupOrg.ExternalID, + Name: tt.setupOrg.Name, + }) + require.NoError(t, err) + } + + orgID, err := db.UpsertOrganization(ctx, projectID, tt.upsertData) + require.NoError(t, err) + require.NotEqual(t, uuid.Nil, orgID) + + if tt.setupOrg != nil { + require.Equal(t, existingOrgID, orgID, "should return existing org ID on conflict") + } + + org, err := db.GetOrganization(ctx, projectID, orgID) + require.NoError(t, err) + require.Equal(t, tt.expectedName, org.Name, tt.description) + }) + } +} + +func TestUpdateOrganizationWithDataMerge(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: "org_merge", + Data: map[string]any{"plan": "free", "seats": 10}, + }) + require.NoError(t, err) + + // Update with merged data + updateData := json.RawMessage(`{"seats":50,"feature_flags":["beta"]}`) + err = db.UpdateOrganization(ctx, projectID, orgID, OrganizationUpdate{ + Data: &updateData, + }) + require.NoError(t, err) + + org, err := db.GetOrganization(ctx, projectID, orgID) + require.NoError(t, err) + + var orgData map[string]any + err = json.Unmarshal(org.Data, &orgData) + require.NoError(t, err) + + // Original key preserved + require.Equal(t, "free", orgData["plan"]) + // Updated key changed + require.Equal(t, float64(50), orgData["seats"]) + // New key added + require.NotNil(t, orgData["feature_flags"]) +} + +func TestDeleteOrganization(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: "org_delete", + }) + require.NoError(t, err) + + err = db.DeleteOrganization(ctx, projectID, orgID) + require.NoError(t, err) + + _, err = db.GetOrganization(ctx, projectID, orgID) + require.Error(t, err, "should return error when org is deleted") +} + +func TestOrganizationVersionAutoIncrement(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: "org_version", + }) + require.NoError(t, err) + + org, err := db.GetOrganization(ctx, projectID, orgID) + require.NoError(t, err) + initialVersion := org.Version + + err = db.UpdateOrganization(ctx, projectID, orgID, OrganizationUpdate{ + Name: ptr("Updated Name"), + }) + require.NoError(t, err) + + org, err = db.GetOrganization(ctx, projectID, orgID) + require.NoError(t, err) + require.Equal(t, initialVersion+1, org.Version, "version should auto-increment on update") +} + +func TestUpsertOrganizationMember(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Create org + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: "org_membership", + }) + require.NoError(t, err) + + // Create user + userID, err := db.CreateUser(ctx, User{ + ProjectID: projectID, + AnonymousID: ptr("anon_org_member"), + Data: json.RawMessage(`{}`), + }) + require.NoError(t, err) + + // Add user to org with org-specific data + err = db.UpsertOrganizationMember(ctx, orgID, userID, map[string]any{ + "role": "admin", + "department": "engineering", + }) + require.NoError(t, err) + + // Verify membership + members, total, err := db.ListOrganizationMembers(ctx, projectID, orgID, store.Pagination{Limit: 10, Offset: 0}) + require.NoError(t, err) + require.Equal(t, 1, total) + require.Equal(t, 1, len(members)) + require.Equal(t, userID, members[0].ID) + + // Verify org-specific data + var orgData map[string]any + err = json.Unmarshal(members[0].OrganizationData, &orgData) + require.NoError(t, err) + require.Equal(t, "admin", orgData["role"]) + require.Equal(t, "engineering", orgData["department"]) +} + +func TestUpsertOrganizationMemberMergesData(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Create org and user + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: "org_data_merge", + }) + require.NoError(t, err) + + userID, err := db.CreateUser(ctx, User{ + ProjectID: projectID, + AnonymousID: ptr("anon_data_merge"), + Data: json.RawMessage(`{}`), + }) + require.NoError(t, err) + + // Add user with initial data + err = db.UpsertOrganizationMember(ctx, orgID, userID, map[string]any{ + "role": "member", + }) + require.NoError(t, err) + + // Add user again with additional data (should merge) + err = db.UpsertOrganizationMember(ctx, orgID, userID, map[string]any{ + "role": "admin", + "department": "sales", + }) + require.NoError(t, err) + + // Verify data was merged + members, _, err := db.ListOrganizationMembers(ctx, projectID, orgID, store.Pagination{Limit: 10, Offset: 0}) + require.NoError(t, err) + require.Equal(t, 1, len(members)) + + var orgData map[string]any + err = json.Unmarshal(members[0].OrganizationData, &orgData) + require.NoError(t, err) + require.Equal(t, "admin", orgData["role"]) + require.Equal(t, "sales", orgData["department"]) +} + +func TestRemoveUserFromOrganization(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Create org and user + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: "org_remove", + }) + require.NoError(t, err) + + userID, err := db.CreateUser(ctx, User{ + ProjectID: projectID, + AnonymousID: ptr("anon_remove"), + Data: json.RawMessage(`{}`), + }) + require.NoError(t, err) + + // Add and then remove user + err = db.UpsertOrganizationMember(ctx, orgID, userID, nil) + require.NoError(t, err) + + err = db.RemoveUserFromOrganization(ctx, orgID, userID) + require.NoError(t, err) + + // Verify user is no longer a member + members, total, err := db.ListOrganizationMembers(ctx, projectID, orgID, store.Pagination{Limit: 10, Offset: 0}) + require.NoError(t, err) + require.Equal(t, 0, total) + require.Equal(t, 0, len(members)) +} + +func TestListOrganizationMembersWithPagination(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Create org + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: "org_pagination", + }) + require.NoError(t, err) + + // Create and add multiple users + for i := 0; i < 5; i++ { + userID, err := db.CreateUser(ctx, User{ + ProjectID: projectID, + AnonymousID: ptr(uuid.New().String()), + Data: json.RawMessage(`{}`), + }) + require.NoError(t, err) + err = db.UpsertOrganizationMember(ctx, orgID, userID, nil) + require.NoError(t, err) + } + + type test struct { + pagination store.Pagination + expectedCount int + expectedTotal int + } + + tests := map[string]test{ + "first page": { + pagination: store.Pagination{Limit: 2, Offset: 0}, + expectedCount: 2, + expectedTotal: 5, + }, + "second page": { + pagination: store.Pagination{Limit: 2, Offset: 2}, + expectedCount: 2, + expectedTotal: 5, + }, + "all members": { + pagination: store.Pagination{Limit: 10, Offset: 0}, + expectedCount: 5, + expectedTotal: 5, + }, + } + + for name, tt := range tests { + t.Run(name, func(t *testing.T) { + members, total, err := db.ListOrganizationMembers(ctx, projectID, orgID, tt.pagination) + require.NoError(t, err) + require.Equal(t, tt.expectedCount, len(members)) + require.Equal(t, tt.expectedTotal, total) + }) + } +} + +func TestListUserOrganizations(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Create user + userID, err := db.CreateUser(ctx, User{ + ProjectID: projectID, + AnonymousID: ptr("anon_multi_org"), + Data: json.RawMessage(`{}`), + }) + require.NoError(t, err) + + // Create multiple orgs and add user to them + orgIDs := make([]uuid.UUID, 3) + for i := 0; i < 3; i++ { + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: uuid.New().String(), + Name: ptr("Test Org"), + }) + require.NoError(t, err) + orgIDs[i] = orgID + err = db.UpsertOrganizationMember(ctx, orgID, userID, nil) + require.NoError(t, err) + } + + // List user's orgs + orgs, err := db.ListUserOrganizations(ctx, projectID, userID) + require.NoError(t, err) + require.Equal(t, 3, len(orgs)) + + // Verify all orgs are returned + returnedIDs := make(map[uuid.UUID]bool) + for _, org := range orgs { + returnedIDs[org.ID] = true + } + for _, id := range orgIDs { + require.True(t, returnedIDs[id], "org should be in user's orgs list") + } +} + +func TestCountOrganizationMembers(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Create org + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: "org_count", + }) + require.NoError(t, err) + + // Initially 0 members + count, err := db.CountOrganizationMembers(ctx, orgID) + require.NoError(t, err) + require.Equal(t, 0, count) + + // Add users + for i := 0; i < 3; i++ { + userID, err := db.CreateUser(ctx, User{ + ProjectID: projectID, + AnonymousID: ptr(uuid.New().String()), + Data: json.RawMessage(`{}`), + }) + require.NoError(t, err) + err = db.UpsertOrganizationMember(ctx, orgID, userID, nil) + require.NoError(t, err) + } + + count, err = db.CountOrganizationMembers(ctx, orgID) + require.NoError(t, err) + require.Equal(t, 3, count) +} + +func TestUpdateOrganizationUserData(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Create org and user + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: "org_user_data", + }) + require.NoError(t, err) + + userID, err := db.CreateUser(ctx, User{ + ProjectID: projectID, + AnonymousID: ptr("anon_user_data"), + Data: json.RawMessage(`{}`), + }) + require.NoError(t, err) + + // Add user with initial data + err = db.UpsertOrganizationMember(ctx, orgID, userID, map[string]any{ + "role": "member", + }) + require.NoError(t, err) + + // Update org user data + updateData := json.RawMessage(`{"role":"admin","permissions":["read","write"]}`) + err = db.UpdateOrganizationUserData(ctx, orgID, userID, updateData) + require.NoError(t, err) + + // Verify update + members, _, err := db.ListOrganizationMembers(ctx, projectID, orgID, store.Pagination{Limit: 10, Offset: 0}) + require.NoError(t, err) + require.Equal(t, 1, len(members)) + + var orgData map[string]any + err = json.Unmarshal(members[0].OrganizationData, &orgData) + require.NoError(t, err) + require.Equal(t, "admin", orgData["role"]) + require.NotNil(t, orgData["permissions"]) +} + +func TestDeleteOrganizationCascadesMembers(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Create org + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: "org_cascade", + }) + require.NoError(t, err) + + // Create user and add to org + userID, err := db.CreateUser(ctx, User{ + ProjectID: projectID, + AnonymousID: ptr("anon_cascade"), + Data: json.RawMessage(`{}`), + }) + require.NoError(t, err) + err = db.UpsertOrganizationMember(ctx, orgID, userID, nil) + require.NoError(t, err) + + // Verify user is member + count, err := db.CountOrganizationMembers(ctx, orgID) + require.NoError(t, err) + require.Equal(t, 1, count) + + // Delete org + err = db.DeleteOrganization(ctx, projectID, orgID) + require.NoError(t, err) + + // User should still exist (not cascaded) + user, err := db.GetUser(ctx, projectID, userID) + require.NoError(t, err) + require.NotNil(t, user) + + // User should no longer be in any orgs + orgs, err := db.ListUserOrganizations(ctx, projectID, userID) + require.NoError(t, err) + require.Equal(t, 0, len(orgs)) +} diff --git a/internal/store/users/rules.go b/internal/store/subjects/rules.go similarity index 99% rename from internal/store/users/rules.go rename to internal/store/subjects/rules.go index 8fe69cf1..458d148a 100644 --- a/internal/store/users/rules.go +++ b/internal/store/subjects/rules.go @@ -1,4 +1,4 @@ -package users +package subjects import ( "context" diff --git a/internal/store/subjects/store.go b/internal/store/subjects/store.go new file mode 100644 index 00000000..154ec32c --- /dev/null +++ b/internal/store/subjects/store.go @@ -0,0 +1,25 @@ +package subjects + +import ( + "github.com/lunogram/platform/internal/store" +) + +func NewState(db store.DB) *State { + return &State{ + UsersStore: NewUsersStore(db), + OrganizationsStore: NewOrganizationsStore(db), + EventsStore: NewEventsStore(db), + DevicesStore: NewDevicesStore(db), + ListsStore: NewListsStore(db), + RulesStore: NewRulesStore(db), + } +} + +type State struct { + *UsersStore + *OrganizationsStore + *EventsStore + *DevicesStore + *ListsStore + *RulesStore +} diff --git a/internal/store/users/users.go b/internal/store/subjects/users.go similarity index 99% rename from internal/store/users/users.go rename to internal/store/subjects/users.go index 264df9ed..c341b018 100644 --- a/internal/store/users/users.go +++ b/internal/store/subjects/users.go @@ -1,4 +1,4 @@ -package users +package subjects import ( "context" diff --git a/internal/store/users/users_test.go b/internal/store/subjects/users_test.go similarity index 99% rename from internal/store/users/users_test.go rename to internal/store/subjects/users_test.go index 746b463f..46fd4900 100644 --- a/internal/store/users/users_test.go +++ b/internal/store/subjects/users_test.go @@ -1,4 +1,4 @@ -package users +package subjects import ( "context" diff --git a/internal/store/test/store.go b/internal/store/test/store.go index 7d17638c..45eb03bf 100644 --- a/internal/store/test/store.go +++ b/internal/store/test/store.go @@ -9,7 +9,7 @@ import ( "github.com/lunogram/platform/internal/store" "github.com/lunogram/platform/internal/store/journey" "github.com/lunogram/platform/internal/store/management" - "github.com/lunogram/platform/internal/store/users" + "github.com/lunogram/platform/internal/store/subjects" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" ) @@ -25,7 +25,7 @@ func RunPostgreSQL(t *testing.T) (mgmt, usrs, jrny *sqlx.DB) { journeyURI := container.CreateSchema(t, uri, "journey") require.NoError(t, management.Migrate(mgmtURI)) - require.NoError(t, users.Migrate(usersURI)) + require.NoError(t, subjects.Migrate(usersURI)) require.NoError(t, journey.Migrate(journeyURI)) ctx := graceful.NewContext(t.Context()) diff --git a/internal/store/users/store.go b/internal/store/users/store.go deleted file mode 100644 index 317ea9e0..00000000 --- a/internal/store/users/store.go +++ /dev/null @@ -1,23 +0,0 @@ -package users - -import ( - "github.com/lunogram/platform/internal/store" -) - -func NewState(db store.DB) *State { - return &State{ - UsersStore: NewUsersStore(db), - EventsStore: NewEventsStore(db), - DevicesStore: NewDevicesStore(db), - ListsStore: NewListsStore(db), - RulesStore: NewRulesStore(db), - } -} - -type State struct { - *UsersStore - *EventsStore - *DevicesStore - *ListsStore - *RulesStore -} From ca48ae95e0b112ee745f8397bef73cd6348cf8b9 Mon Sep 17 00:00:00 2001 From: Jeroen Rinzema Date: Sun, 22 Feb 2026 14:18:44 +0100 Subject: [PATCH 005/230] chore: updated generated files --- internal/http/controllers/v1/client/client_test.go | 2 +- internal/http/controllers/v1/client/subscriptions_test.go | 2 +- internal/http/controllers/v1/management/lists_test.go | 2 +- internal/http/controllers/v1/management/users_test.go | 2 +- internal/journeys/update_test.go | 2 +- internal/pubsub/consumer/events_test.go | 2 +- internal/pubsub/consumer/recompute_test.go | 2 +- internal/pubsub/consumer/users_test.go | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/internal/http/controllers/v1/client/client_test.go b/internal/http/controllers/v1/client/client_test.go index a657fb58..a2918d99 100644 --- a/internal/http/controllers/v1/client/client_test.go +++ b/internal/http/controllers/v1/client/client_test.go @@ -13,8 +13,8 @@ import ( "github.com/lunogram/platform/internal/pubsub" "github.com/lunogram/platform/internal/pubsub/consumer" "github.com/lunogram/platform/internal/store/management" - teststore "github.com/lunogram/platform/internal/store/test" "github.com/lunogram/platform/internal/store/subjects" + teststore "github.com/lunogram/platform/internal/store/test" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" diff --git a/internal/http/controllers/v1/client/subscriptions_test.go b/internal/http/controllers/v1/client/subscriptions_test.go index 4c038ccc..dcd8534f 100644 --- a/internal/http/controllers/v1/client/subscriptions_test.go +++ b/internal/http/controllers/v1/client/subscriptions_test.go @@ -11,8 +11,8 @@ import ( "github.com/lunogram/platform/internal/http/controllers/v1/client/oapi" "github.com/lunogram/platform/internal/http/json" "github.com/lunogram/platform/internal/store/management" - teststore "github.com/lunogram/platform/internal/store/test" "github.com/lunogram/platform/internal/store/subjects" + teststore "github.com/lunogram/platform/internal/store/test" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" ) diff --git a/internal/http/controllers/v1/management/lists_test.go b/internal/http/controllers/v1/management/lists_test.go index c89ba18e..6ab6c07d 100644 --- a/internal/http/controllers/v1/management/lists_test.go +++ b/internal/http/controllers/v1/management/lists_test.go @@ -18,8 +18,8 @@ import ( "github.com/lunogram/platform/internal/pubsub/consumer" "github.com/lunogram/platform/internal/store" "github.com/lunogram/platform/internal/store/management" - teststore "github.com/lunogram/platform/internal/store/test" "github.com/lunogram/platform/internal/store/subjects" + teststore "github.com/lunogram/platform/internal/store/test" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" ) diff --git a/internal/http/controllers/v1/management/users_test.go b/internal/http/controllers/v1/management/users_test.go index 3ff5ab78..ddaa69bd 100644 --- a/internal/http/controllers/v1/management/users_test.go +++ b/internal/http/controllers/v1/management/users_test.go @@ -24,8 +24,8 @@ import ( "github.com/lunogram/platform/internal/store" "github.com/lunogram/platform/internal/store/journey" "github.com/lunogram/platform/internal/store/management" - teststore "github.com/lunogram/platform/internal/store/test" "github.com/lunogram/platform/internal/store/subjects" + teststore "github.com/lunogram/platform/internal/store/test" "github.com/stretchr/testify/require" "go.uber.org/zap/zaptest" ) diff --git a/internal/journeys/update_test.go b/internal/journeys/update_test.go index eb368dc9..2488435f 100644 --- a/internal/journeys/update_test.go +++ b/internal/journeys/update_test.go @@ -11,8 +11,8 @@ import ( "github.com/lunogram/platform/internal/pubsub" "github.com/lunogram/platform/internal/store/journey" "github.com/lunogram/platform/internal/store/management" - teststore "github.com/lunogram/platform/internal/store/test" "github.com/lunogram/platform/internal/store/subjects" + teststore "github.com/lunogram/platform/internal/store/test" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) diff --git a/internal/pubsub/consumer/events_test.go b/internal/pubsub/consumer/events_test.go index f9cda44d..47512105 100644 --- a/internal/pubsub/consumer/events_test.go +++ b/internal/pubsub/consumer/events_test.go @@ -14,8 +14,8 @@ import ( "github.com/lunogram/platform/internal/pubsub/schemas" "github.com/lunogram/platform/internal/store/journey" "github.com/lunogram/platform/internal/store/management" - teststore "github.com/lunogram/platform/internal/store/test" "github.com/lunogram/platform/internal/store/subjects" + teststore "github.com/lunogram/platform/internal/store/test" "github.com/nats-io/nats.go/jetstream" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/internal/pubsub/consumer/recompute_test.go b/internal/pubsub/consumer/recompute_test.go index 6e737885..8b494f40 100644 --- a/internal/pubsub/consumer/recompute_test.go +++ b/internal/pubsub/consumer/recompute_test.go @@ -14,8 +14,8 @@ import ( "github.com/lunogram/platform/internal/rules" "github.com/lunogram/platform/internal/store" "github.com/lunogram/platform/internal/store/management" - teststore "github.com/lunogram/platform/internal/store/test" "github.com/lunogram/platform/internal/store/subjects" + teststore "github.com/lunogram/platform/internal/store/test" "github.com/nats-io/nats.go/jetstream" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" diff --git a/internal/pubsub/consumer/users_test.go b/internal/pubsub/consumer/users_test.go index e5bfe469..e9156db6 100644 --- a/internal/pubsub/consumer/users_test.go +++ b/internal/pubsub/consumer/users_test.go @@ -14,8 +14,8 @@ import ( "github.com/lunogram/platform/internal/rules" "github.com/lunogram/platform/internal/store" "github.com/lunogram/platform/internal/store/management" - teststore "github.com/lunogram/platform/internal/store/test" "github.com/lunogram/platform/internal/store/subjects" + teststore "github.com/lunogram/platform/internal/store/test" "github.com/nats-io/nats.go/jetstream" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" From 4008e17c561d4f63aedf59def383ffabae0e8d66 Mon Sep 17 00:00:00 2001 From: Jeroen Rinzema Date: Sun, 22 Feb 2026 13:32:13 +0100 Subject: [PATCH 006/230] feat: updated the rules package to include organization rules support --- internal/rules/query/organization.go | 141 ++++++++++++++++++ internal/rules/query/query_test.go | 204 +++++++++++++++++++++++++++ internal/rules/query/rule.go | 29 ++++ internal/rules/rules.go | 36 ++++- 4 files changed, 407 insertions(+), 3 deletions(-) create mode 100644 internal/rules/query/organization.go diff --git a/internal/rules/query/organization.go b/internal/rules/query/organization.go new file mode 100644 index 00000000..83309d64 --- /dev/null +++ b/internal/rules/query/organization.go @@ -0,0 +1,141 @@ +package query + +import ( + "fmt" + "strings" + + "github.com/lunogram/platform/internal/rules" +) + +// buildOrganizationRule builds SQL for organization attribute rules. +// This filters users who belong to organizations matching the criteria. +// Example: "get all users in organizations where data.tier = 'gold'" +func (qb *QueryBuilder) buildOrganizationRule(rule *rules.Rule) (string, error) { + column, err := qb.buildColumnPath("o", rule.Path, rule.Type) + if err != nil { + return "", err + } + + condition, err := qb.buildComparison(column, rule.Operator, rule.Value, rule.Type) + if err != nil { + return "", err + } + + // Generate a unique alias for this organization join + alias := qb.nextJoinAlias() + + // Build the JOIN clause that connects users to organizations via organization_users + // and filters by organization attributes + joinClause := fmt.Sprintf( + "JOIN (SELECT DISTINCT ou.user_id FROM organization_users ou JOIN organizations o ON o.id = ou.organization_id WHERE o.project_id = %s AND %s) %s ON %s.user_id = u.id", + qb.arg(qb.projectID), + condition, + alias, + alias, + ) + + qb.joins = append(qb.joins, joinClause) + + // Return empty condition since the filtering is in the JOIN + return "", nil +} + +// buildOrganizationUserRule builds SQL for organization user attribute rules. +// This filters users based on their data within the organization_users table. +// Example: "get all users who have role = 'admin' in any organization" +func (qb *QueryBuilder) buildOrganizationUserRule(rule *rules.Rule) (string, error) { + column, err := qb.buildColumnPath("ou", rule.Path, rule.Type) + if err != nil { + return "", err + } + + condition, err := qb.buildComparison(column, rule.Operator, rule.Value, rule.Type) + if err != nil { + return "", err + } + + // Generate a unique alias for this organization user join + alias := qb.nextJoinAlias() + + // Build the JOIN clause that filters users by their organization_users data + joinClause := fmt.Sprintf( + "JOIN (SELECT DISTINCT ou.user_id FROM organization_users ou JOIN organizations o ON o.id = ou.organization_id WHERE o.project_id = %s AND %s) %s ON %s.user_id = u.id", + qb.arg(qb.projectID), + condition, + alias, + alias, + ) + + qb.joins = append(qb.joins, joinClause) + + // Return empty condition since the filtering is in the JOIN + return "", nil +} + +// buildOrganizationWrapperRule builds SQL for wrapper rules that combine +// organization and organization user conditions. This is used when you need +// to match both organization attributes AND organization user attributes together. +// Example: "get users in orgs where tier = 'gold' AND user has role = 'admin'" +func (qb *QueryBuilder) buildOrganizationWrapperRule(rule *rules.Rule) (string, error) { + if !rule.HasChildren() { + return "", nil + } + + // Collect conditions for organizations and organization users + orgConditions := []string{} + orgUserConditions := []string{} + + for i := range rule.Children { + child := &rule.Children[i] + + switch child.Group { + case rules.RuleGroupOrganization: + column, err := qb.buildColumnPath("o", child.Path, child.Type) + if err != nil { + return "", err + } + condition, err := qb.buildComparison(column, child.Operator, child.Value, child.Type) + if err != nil { + return "", err + } + orgConditions = append(orgConditions, condition) + + case rules.RuleGroupOrganizationUser: + column, err := qb.buildColumnPath("ou", child.Path, child.Type) + if err != nil { + return "", err + } + condition, err := qb.buildComparison(column, child.Operator, child.Value, child.Type) + if err != nil { + return "", err + } + orgUserConditions = append(orgUserConditions, condition) + } + } + + // Combine all conditions + allConditions := append(orgConditions, orgUserConditions...) + if len(allConditions) == 0 { + return "", nil + } + + logicalOp := rule.Operator.SQL() + combinedCondition := strings.Join(allConditions, " "+logicalOp+" ") + + // Generate a unique alias for this combined join + alias := qb.nextJoinAlias() + + // Build the JOIN clause that combines org and organization user conditions + joinClause := fmt.Sprintf( + "JOIN (SELECT DISTINCT ou.user_id FROM organization_users ou JOIN organizations o ON o.id = ou.organization_id WHERE o.project_id = %s AND (%s)) %s ON %s.user_id = u.id", + qb.arg(qb.projectID), + combinedCondition, + alias, + alias, + ) + + qb.joins = append(qb.joins, joinClause) + + // Return empty condition since the filtering is in the JOIN + return "", nil +} diff --git a/internal/rules/query/query_test.go b/internal/rules/query/query_test.go index 82d8b47c..55868230 100644 --- a/internal/rules/query/query_test.go +++ b/internal/rules/query/query_test.go @@ -1148,3 +1148,207 @@ func TestQueryBuilderBuildQuery(t *testing.T) { }) } } + +func TestQueryBuilderOrganizationRules(t *testing.T) { + type test struct { + name string + ruleSet rules.RuleSet + wantSQL string + wantArgs []any + wantErr bool + } + + tests := map[string]test{ + "simple organization attribute": { + name: "simple organization attribute", + ruleSet: rules.RuleSet{ + Rule: rules.Rule{ + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganization, + Path: ".name", + Operator: rules.OperatorEquals, + Value: "Acme Corp", + }, + }, + wantSQL: "SELECT u.id FROM users u JOIN (SELECT DISTINCT ou.user_id FROM organization_users ou JOIN organizations o ON o.id = ou.organization_id WHERE o.project_id = $2 AND o.name = $1) e1 ON e1.user_id = u.id WHERE u.project_id = $3", + wantArgs: []any{"Acme Corp", testProjectID, testProjectID}, + wantErr: false, + }, + "organization nested jsonb data": { + name: "organization nested jsonb data", + ruleSet: rules.RuleSet{ + Rule: rules.Rule{ + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganization, + Path: ".data.tier", + Operator: rules.OperatorEquals, + Value: "gold", + }, + }, + wantSQL: "SELECT u.id FROM users u JOIN (SELECT DISTINCT ou.user_id FROM organization_users ou JOIN organizations o ON o.id = ou.organization_id WHERE o.project_id = $2 AND (o.data->>'tier')::text = $1) e1 ON e1.user_id = u.id WHERE u.project_id = $3", + wantArgs: []any{"gold", testProjectID, testProjectID}, + wantErr: false, + }, + "organization user role": { + name: "organization user role", + ruleSet: rules.RuleSet{ + Rule: rules.Rule{ + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganizationUser, + Path: ".data.role", + Operator: rules.OperatorEquals, + Value: "admin", + }, + }, + wantSQL: "SELECT u.id FROM users u JOIN (SELECT DISTINCT ou.user_id FROM organization_users ou JOIN organizations o ON o.id = ou.organization_id WHERE o.project_id = $2 AND (ou.data->>'role')::text = $1) e1 ON e1.user_id = u.id WHERE u.project_id = $3", + wantArgs: []any{"admin", testProjectID, testProjectID}, + wantErr: false, + }, + "combined organization and organization user with AND": { + name: "combined organization and organization user with AND", + ruleSet: rules.RuleSet{ + Rule: rules.Rule{ + Type: rules.RuleTypeWrapper, + Group: rules.RuleGroupParent, + Operator: rules.OperatorAnd, + Children: []rules.Rule{ + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganization, + Path: ".data.tier", + Operator: rules.OperatorEquals, + Value: "gold", + }, + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganizationUser, + Path: ".data.role", + Operator: rules.OperatorEquals, + Value: "admin", + }, + }, + }, + }, + wantSQL: "SELECT u.id FROM users u JOIN (SELECT DISTINCT ou.user_id FROM organization_users ou JOIN organizations o ON o.id = ou.organization_id WHERE o.project_id = $3 AND ((o.data->>'tier')::text = $1 AND (ou.data->>'role')::text = $2)) e1 ON e1.user_id = u.id WHERE u.project_id = $4", + wantArgs: []any{"gold", "admin", testProjectID, testProjectID}, + wantErr: false, + }, + "combined organization and organization user with OR": { + name: "combined organization and organization user with OR", + ruleSet: rules.RuleSet{ + Rule: rules.Rule{ + Type: rules.RuleTypeWrapper, + Group: rules.RuleGroupParent, + Operator: rules.OperatorOr, + Children: []rules.Rule{ + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganization, + Path: ".data.tier", + Operator: rules.OperatorEquals, + Value: "gold", + }, + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganizationUser, + Path: ".data.role", + Operator: rules.OperatorEquals, + Value: "admin", + }, + }, + }, + }, + wantSQL: "SELECT u.id FROM users u JOIN (SELECT DISTINCT ou.user_id FROM organization_users ou JOIN organizations o ON o.id = ou.organization_id WHERE o.project_id = $3 AND ((o.data->>'tier')::text = $1 OR (ou.data->>'role')::text = $2)) e1 ON e1.user_id = u.id WHERE u.project_id = $4", + wantArgs: []any{"gold", "admin", testProjectID, testProjectID}, + wantErr: false, + }, + "user attribute AND organization attribute": { + name: "user attribute AND organization attribute", + ruleSet: rules.RuleSet{ + Rule: rules.Rule{ + Type: rules.RuleTypeWrapper, + Group: rules.RuleGroupParent, + Operator: rules.OperatorAnd, + Children: []rules.Rule{ + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupUser, + Path: ".email", + Operator: rules.OperatorEndsWith, + Value: "@enterprise.com", + }, + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganization, + Path: ".data.tier", + Operator: rules.OperatorEquals, + Value: "enterprise", + }, + }, + }, + }, + wantSQL: "SELECT u.id FROM users u JOIN (SELECT DISTINCT ou.user_id FROM organization_users ou JOIN organizations o ON o.id = ou.organization_id WHERE o.project_id = $3 AND (o.data->>'tier')::text = $2) e1 ON e1.user_id = u.id WHERE u.project_id = $4 AND u.email ILIKE $1", + wantArgs: []any{"%@enterprise.com", "enterprise", testProjectID, testProjectID}, + wantErr: false, + }, + "multiple organization conditions": { + name: "multiple organization conditions", + ruleSet: rules.RuleSet{ + Rule: rules.Rule{ + Type: rules.RuleTypeWrapper, + Group: rules.RuleGroupParent, + Operator: rules.OperatorAnd, + Children: []rules.Rule{ + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganization, + Path: ".data.tier", + Operator: rules.OperatorEquals, + Value: "gold", + }, + { + Type: rules.RuleTypeNumber, + Group: rules.RuleGroupOrganization, + Path: ".data.seats", + Operator: rules.OperatorGreaterEqual, + Value: 10, + }, + }, + }, + }, + wantSQL: "SELECT u.id FROM users u JOIN (SELECT DISTINCT ou.user_id FROM organization_users ou JOIN organizations o ON o.id = ou.organization_id WHERE o.project_id = $3 AND ((o.data->>'tier')::text = $1 AND (o.data->>'seats')::numeric >= $2)) e1 ON e1.user_id = u.id WHERE u.project_id = $4", + wantArgs: []any{"gold", 10, testProjectID, testProjectID}, + wantErr: false, + }, + "organization with is set operator": { + name: "organization with is set operator", + ruleSet: rules.RuleSet{ + Rule: rules.Rule{ + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganization, + Path: ".data.verified_at", + Operator: rules.OperatorIsSet, + }, + }, + wantSQL: "SELECT u.id FROM users u JOIN (SELECT DISTINCT ou.user_id FROM organization_users ou JOIN organizations o ON o.id = ou.organization_id WHERE o.project_id = $1 AND (o.data->>'verified_at')::text IS NOT NULL) e1 ON e1.user_id = u.id WHERE u.project_id = $2", + wantArgs: []any{testProjectID, testProjectID}, + wantErr: false, + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + qb := NewQueryBuilder(testProjectID, nil) + result, err := qb.Query(tc.ruleSet) + + if tc.wantErr { + require.Error(t, err) + return + } + + require.NoError(t, err) + assert.Equal(t, tc.wantSQL, result.SQL) + assert.Equal(t, tc.wantArgs, result.Args) + }) + } +} diff --git a/internal/rules/query/rule.go b/internal/rules/query/rule.go index 827d12fd..8b85d652 100644 --- a/internal/rules/query/rule.go +++ b/internal/rules/query/rule.go @@ -25,6 +25,11 @@ func (qb *QueryBuilder) buildRule(rule *rules.Rule) (string, error) { return qb.buildEventRule(rule) } + // Check if this is an organization wrapper (contains both org and org_user rules) + if rule.IsWrapper() && qb.isOrganizationWrapper(rule) { + return qb.buildOrganizationWrapperRule(rule) + } + if rule.IsWrapper() { return qb.buildWrapper(rule) } @@ -34,11 +39,35 @@ func (qb *QueryBuilder) buildRule(rule *rules.Rule) (string, error) { return qb.buildUserRule(rule) case rules.RuleGroupEvent: return qb.buildEventRule(rule) + case rules.RuleGroupOrganization: + return qb.buildOrganizationRule(rule) + case rules.RuleGroupOrganizationUser: + return qb.buildOrganizationUserRule(rule) default: return "", fmt.Errorf("unsupported rule group: %s", rule.Group) } } +// isOrganizationWrapper checks if a wrapper rule contains only organization-related rules +// (RuleGroupOrganization and/or RuleGroupOrganizationUser) +func (qb *QueryBuilder) isOrganizationWrapper(rule *rules.Rule) bool { + if !rule.HasChildren() { + return false + } + + hasOrgRules := false + for _, child := range rule.Children { + if child.Group == rules.RuleGroupOrganization || child.Group == rules.RuleGroupOrganizationUser { + hasOrgRules = true + } else if child.Group != rules.RuleGroupParent { + // If there's a non-organization, non-parent rule, this is not a pure org wrapper + return false + } + } + + return hasOrgRules +} + // buildWrapper builds SQL for wrapper nodes with logical operators func (qb *QueryBuilder) buildWrapper(rule *rules.Rule) (string, error) { if !rule.HasChildren() { diff --git a/internal/rules/rules.go b/internal/rules/rules.go index 05aec9a1..a852ba50 100644 --- a/internal/rules/rules.go +++ b/internal/rules/rules.go @@ -36,9 +36,11 @@ func (rt RuleType) SQL() string { type RuleGroup string const ( - RuleGroupParent RuleGroup = "parent" - RuleGroupUser RuleGroup = "user" - RuleGroupEvent RuleGroup = "event" + RuleGroupParent RuleGroup = "parent" + RuleGroupUser RuleGroup = "user" + RuleGroupEvent RuleGroup = "event" + RuleGroupOrganization RuleGroup = "organization" + RuleGroupOrganizationUser RuleGroup = "organization_user" ) // Operator defines logical and comparison operators @@ -203,6 +205,34 @@ func (r Rule) DependsOnUsers() bool { return false } +func (r Rule) DependsOnOrganizations() bool { + if r.Group == RuleGroupOrganization { + return true + } + + for _, child := range r.Children { + if child.DependsOnOrganizations() { + return true + } + } + + return false +} + +func (r Rule) DependsOnOrganizationUsers() bool { + if r.Group == RuleGroupOrganizationUser { + return true + } + + for _, child := range r.Children { + if child.DependsOnOrganizationUsers() { + return true + } + } + + return false +} + // RuleSet represents the complete rule configuration type RuleSet struct { Rule From 3016aef28d438048df5c28dd137a9a4df73455a0 Mon Sep 17 00:00:00 2001 From: Jeroen Rinzema Date: Sun, 22 Feb 2026 14:17:15 +0100 Subject: [PATCH 007/230] feat: include organization and organization event handlers --- internal/http/controllers/v1/client/client.go | 4 +- internal/journeys/event.go | 4 +- internal/journeys/event_test.go | 6 +- internal/pubsub/README.md | 48 +- internal/pubsub/consumer/bootstrap.go | 99 +++- internal/pubsub/consumer/bootstrap_test.go | 20 +- internal/pubsub/consumer/consumer.go | 43 +- .../pubsub/consumer/organization_events.go | 242 +++++++++ .../consumer/organization_events_test.go | 285 ++++++++++ internal/pubsub/consumer/organizations.go | 225 ++++++++ .../pubsub/consumer/organizations_test.go | 488 ++++++++++++++++++ internal/pubsub/consumer/recompute.go | 8 +- internal/pubsub/consumer/recompute_test.go | 16 +- .../consumer/{events.go => user_events.go} | 38 +- .../{events_test.go => user_events_test.go} | 68 +-- internal/pubsub/consumer/users.go | 4 +- internal/pubsub/consumer/users_test.go | 18 +- internal/pubsub/pubsub_test.go | 22 +- internal/pubsub/schemas/events.go | 126 ++++- internal/store/subjects/lists.go | 38 ++ .../1771762205_organizations.down.sql | 13 +- .../1771762205_organizations.up.sql | 52 ++ internal/store/subjects/organizations.go | 145 ++++++ internal/store/subjects/organizations_test.go | 462 +++++++++++++++++ internal/store/subjects/rules.go | 62 ++- 25 files changed, 2352 insertions(+), 184 deletions(-) create mode 100644 internal/pubsub/consumer/organization_events.go create mode 100644 internal/pubsub/consumer/organization_events_test.go create mode 100644 internal/pubsub/consumer/organizations.go create mode 100644 internal/pubsub/consumer/organizations_test.go rename internal/pubsub/consumer/{events.go => user_events.go} (76%) rename internal/pubsub/consumer/{events_test.go => user_events_test.go} (73%) diff --git a/internal/http/controllers/v1/client/client.go b/internal/http/controllers/v1/client/client.go index 238875ae..238848c3 100644 --- a/internal/http/controllers/v1/client/client.go +++ b/internal/http/controllers/v1/client/client.go @@ -59,7 +59,7 @@ func (srv *ClientController) PostEvents(w http.ResponseWriter, r *http.Request) logger.Info("posting events") for _, event := range events { - msg := schemas.Event{ + msg := schemas.UserEvent{ ProjectID: projectID, Name: event.Name, AnonymousId: event.AnonymousId, @@ -67,7 +67,7 @@ func (srv *ClientController) PostEvents(w http.ResponseWriter, r *http.Request) ExternalId: event.ExternalId, } - err = srv.pubsub.Publish(ctx, schemas.Subject(schemas.EventsProcess(projectID)), msg) + err = srv.pubsub.Publish(ctx, schemas.Subject(schemas.UserEventsProcess(projectID)), msg) if err != nil { logger.Error("failed to publish event", zap.Error(err)) oapi.WriteProblem(w, problem.ErrInternal()) diff --git a/internal/journeys/event.go b/internal/journeys/event.go index 6ea59767..42006306 100644 --- a/internal/journeys/event.go +++ b/internal/journeys/event.go @@ -40,7 +40,7 @@ func HandleEvent(ctx HandlerContext, step journey.JourneyVersionStep, state jour return state, nil, fmt.Errorf("failed to get user: %w", err) } - event := schemas.Event{ + event := schemas.UserEvent{ Name: config.EventName, ProjectID: ctx.ProjectID, UserID: ctx.UserID, @@ -49,7 +49,7 @@ func HandleEvent(ctx HandlerContext, step journey.JourneyVersionStep, state jour Data: payload, } - err = ctx.Publisher.Publish(ctx, schemas.Subject(schemas.EventsProcess(ctx.ProjectID)), event) + err = ctx.Publisher.Publish(ctx, schemas.Subject(schemas.UserEventsProcess(ctx.ProjectID)), event) if err != nil { return state, nil, fmt.Errorf("failed to publish event: %w", err) } diff --git a/internal/journeys/event_test.go b/internal/journeys/event_test.go index b7f6f0b6..82ac5ead 100644 --- a/internal/journeys/event_test.go +++ b/internal/journeys/event_test.go @@ -188,8 +188,8 @@ func TestHandleEvent(t *testing.T) { event := mockPub.publishedEvents[0] assert.Equal(t, schemas.Subject("events.process."+projectID.String()), event.subject) - eventData, ok := event.data.(schemas.Event) - require.True(t, ok, "event data should be schemas.Event type") + eventData, ok := event.data.(schemas.UserEvent) + require.True(t, ok, "event data should be schemas.UserEvent type") assert.NotNil(t, eventData.ID) assert.NotEmpty(t, eventData.Name) assert.Equal(t, projectID, eventData.ProjectID) @@ -325,7 +325,7 @@ func TestHandleEventTemplateRendering(t *testing.T) { // Check the event payload event := mockPub.publishedEvents[0] - eventData, ok := event.data.(schemas.Event) + eventData, ok := event.data.(schemas.UserEvent) require.True(t, ok) payloadData := eventData.Data diff --git a/internal/pubsub/README.md b/internal/pubsub/README.md index c9cffc95..bceecb00 100644 --- a/internal/pubsub/README.md +++ b/internal/pubsub/README.md @@ -10,34 +10,52 @@ Events flow through a multi-stage pipeline that handles storage, schema extracti ```mermaid graph TB - Client[Client/API] -->|Submit Event| EventSubject["events.projects.{project_id}"] - Client -->|Submit User| UserSubject[["users.projects.{project_id}"]] + Client[Client/API] -->|Submit User Event| EventSubject["users.events.process.{project_id}"] + Client -->|Submit User| UserSubject["users.process.{project_id}"] + Client -->|Submit Organization| OrgSubject["organizations.process.{project_id}"] + Client -->|Submit Org User| OrgUserSubject["organizations.users.process.{project_id}"] + Client -->|Submit Org Event| OrgEventSubject["organizations.events.process.{project_id}"] - EventSubject -->|Consume| EventHandler["Event Handler"] + EventSubject -->|Consume| EventHandler["User Event Handler"] UserSubject -->|Consume| UserHandler["User Handler"] + OrgSubject -->|Consume| OrgHandler["Organization Handler"] + OrgUserSubject -->|Consume| OrgUserHandler["Organization User Handler"] + OrgEventSubject -->|Consume| OrgEventHandler["Organization Event Handler"] %% Schema publishing - EventHandler --> EventSchemaSubject[["events.schemas.{project_id}"]] - UserHandler --> UserSchemaSubject[["users.schemas.{project_id}"]] + EventHandler --> EventSchemaSubject["users.events.schema.{project_id}"] + UserHandler --> UserSchemaSubject["users.schema.{project_id}"] + OrgHandler --> OrgSchemaSubject["organizations.schema.{project_id}"] + OrgUserHandler --> OrgUserSchemaSubject["organizations.users.schema.{project_id}"] + OrgEventHandler --> OrgEventSchemaSubject["organizations.events.schema.{project_id}"] - %% Recompute triggers from events - EventHandler -->|Affected Lists| ListSubject[["recompute.lists.{project_id}.{list_id}"]] - EventHandler -->|Affected Journeys| JourneySubject[["journeys.state.{project_id}.{journey_id}"]] + %% Recompute triggers from user events + EventHandler -->|Affected Lists| ListSubject["lists.recompute.{project_id}.{list_id}"] + EventHandler -->|Affected Journeys| JourneySubject["journeys.advance.{project_id}.{journey_id}"] %% Recompute triggers from users UserHandler -->|Affected Lists| ListSubject UserHandler -->|User system events| EventSubject + %% Recompute triggers from organizations + OrgHandler -->|Affected Lists| ListSubject + OrgHandler -->|Org system events| OrgEventSubject + OrgUserHandler -->|Affected Lists| ListSubject + OrgUserHandler -->|Org user system events| OrgEventSubject + + %% Recompute triggers from organization events + OrgEventHandler -->|Affected Lists| ListSubject + OrgEventHandler -->|Journeys for all org users| JourneySubject + %% Schema handlers - EventSchemaSubject -->|Consume| EventSchemaHandler["Event Schema Handler"] + EventSchemaSubject -->|Consume| EventSchemaHandler["User Event Schema Handler"] UserSchemaSubject -->|Consume| UserSchemaHandler["User Schema Handler"] + OrgSchemaSubject -->|Consume| OrgSchemaHandler["Organization Schema Handler"] + OrgUserSchemaSubject -->|Consume| OrgUserSchemaHandler["Organization User Schema Handler"] + OrgEventSchemaSubject -->|Consume| OrgEventSchemaHandler["Organization Event Schema Handler"] ListSubject -->|Consume| ListRecompute["List Recomputation"] - JourneySubject -->|Consume| JourneyState["Journey State"] - - ListRecompute -->|Publish Jobs| ListJobSubject[["jobs.lists.{project_id}.{list_id}"]] - ListRecompute -->|List Membership Change| JourneySubject + JourneySubject -->|Consume| JourneyState["Journey State Handler"] - ListJobSubject -->|Consume| ListJobHandler["List Job Handler"] - JourneyState["Journey State Handler"] + ListRecompute -->|List Membership Change| EventSubject ``` diff --git a/internal/pubsub/consumer/bootstrap.go b/internal/pubsub/consumer/bootstrap.go index c7b1fe58..b7d76dbf 100644 --- a/internal/pubsub/consumer/bootstrap.go +++ b/internal/pubsub/consumer/bootstrap.go @@ -16,7 +16,7 @@ func Bootstrap(ctx graceful.Context, logger *zap.Logger, jet jetstream.JetStream bootstrap.EnsureStream(ctx, jetstream.StreamConfig{ Name: StreamUsers, Description: "Responsible for receiving incoming users", - Subjects: []string{"users.>"}, + Subjects: []string{"users.process.>", "users.schema.>"}, Discard: jetstream.DiscardOld, MaxAge: 24 * time.Hour, Replicas: 1, @@ -39,26 +39,26 @@ func Bootstrap(ctx graceful.Context, logger *zap.Logger, jet jetstream.JetStream }) bootstrap.EnsureStream(ctx, jetstream.StreamConfig{ - Name: StreamEvents, - Description: "Responsible for receiving incoming events", - Subjects: []string{"events.>"}, + Name: StreamUserEvents, + Description: "Responsible for receiving incoming user events", + Subjects: []string{"users.events.>"}, Discard: jetstream.DiscardOld, MaxAge: 24 * time.Hour, Replicas: 1, }) - bootstrap.EnsureConsumer(ctx, StreamEvents, jetstream.ConsumerConfig{ - Name: ConsumerEventsProcess, - FilterSubject: "events.process.>", - Description: "Processes incoming events", + bootstrap.EnsureConsumer(ctx, StreamUserEvents, jetstream.ConsumerConfig{ + Name: ConsumerUserEventsProcess, + FilterSubject: "users.events.process.>", + Description: "Processes incoming user events", AckPolicy: jetstream.AckExplicitPolicy, MaxDeliver: 5, }) - bootstrap.EnsureConsumer(ctx, StreamEvents, jetstream.ConsumerConfig{ - Name: ConsumerEventsSchema, - FilterSubject: "events.schema.>", - Description: "Processes event schema definitions", + bootstrap.EnsureConsumer(ctx, StreamUserEvents, jetstream.ConsumerConfig{ + Name: ConsumerUserEventsSchema, + FilterSubject: "users.events.schema.>", + Description: "Processes user event schema definitions", AckPolicy: jetstream.AckExplicitPolicy, MaxDeliver: 5, }) @@ -114,6 +114,81 @@ func Bootstrap(ctx graceful.Context, logger *zap.Logger, jet jetstream.JetStream MaxDeliver: 5, }) + bootstrap.EnsureStream(ctx, jetstream.StreamConfig{ + Name: StreamOrganizations, + Description: "Organization processing and schema extraction", + Subjects: []string{"organizations.process.>", "organizations.schema.>"}, + Discard: jetstream.DiscardOld, + MaxAge: 24 * time.Hour, + Replicas: 1, + }) + + bootstrap.EnsureConsumer(ctx, StreamOrganizations, jetstream.ConsumerConfig{ + Name: ConsumerOrganizationsProcess, + Description: "Processes incoming organizations", + AckPolicy: jetstream.AckExplicitPolicy, + FilterSubject: "organizations.process.>", + MaxDeliver: 5, + }) + + bootstrap.EnsureConsumer(ctx, StreamOrganizations, jetstream.ConsumerConfig{ + Name: ConsumerOrganizationsSchema, + Description: "Processes organization schema definitions", + AckPolicy: jetstream.AckExplicitPolicy, + FilterSubject: "organizations.schema.>", + MaxDeliver: 5, + }) + + bootstrap.EnsureStream(ctx, jetstream.StreamConfig{ + Name: StreamOrganizationUsers, + Description: "Organization user membership processing", + Subjects: []string{"organizations.users.>"}, + Discard: jetstream.DiscardOld, + MaxAge: 24 * time.Hour, + Replicas: 1, + }) + + bootstrap.EnsureConsumer(ctx, StreamOrganizationUsers, jetstream.ConsumerConfig{ + Name: ConsumerOrganizationUsersProcess, + Description: "Processes organization user memberships", + AckPolicy: jetstream.AckExplicitPolicy, + FilterSubject: "organizations.users.process.>", + MaxDeliver: 5, + }) + + bootstrap.EnsureConsumer(ctx, StreamOrganizationUsers, jetstream.ConsumerConfig{ + Name: ConsumerOrganizationUsersSchema, + Description: "Processes organization user schema definitions", + AckPolicy: jetstream.AckExplicitPolicy, + FilterSubject: "organizations.users.schema.>", + MaxDeliver: 5, + }) + + bootstrap.EnsureStream(ctx, jetstream.StreamConfig{ + Name: StreamOrganizationEvents, + Description: "Organization event processing", + Subjects: []string{"organizations.events.>"}, + Discard: jetstream.DiscardOld, + MaxAge: 24 * time.Hour, + Replicas: 1, + }) + + bootstrap.EnsureConsumer(ctx, StreamOrganizationEvents, jetstream.ConsumerConfig{ + Name: ConsumerOrganizationEventsProcess, + Description: "Processes incoming organization events", + AckPolicy: jetstream.AckExplicitPolicy, + FilterSubject: "organizations.events.process.>", + MaxDeliver: 5, + }) + + bootstrap.EnsureConsumer(ctx, StreamOrganizationEvents, jetstream.ConsumerConfig{ + Name: ConsumerOrganizationEventsSchema, + Description: "Processes organization event schema definitions", + AckPolicy: jetstream.AckExplicitPolicy, + FilterSubject: "organizations.events.schema.>", + MaxDeliver: 5, + }) + return bootstrap.Error() } diff --git a/internal/pubsub/consumer/bootstrap_test.go b/internal/pubsub/consumer/bootstrap_test.go index c38a17df..043c6241 100644 --- a/internal/pubsub/consumer/bootstrap_test.go +++ b/internal/pubsub/consumer/bootstrap_test.go @@ -40,23 +40,23 @@ func TestBootstrapCreatesStreamsAndConsumers(t *testing.T) { err := Bootstrap(ctx, logger, jet) require.NoError(t, err) - stream, err := jet.Stream(ctx, StreamEvents) + stream, err := jet.Stream(ctx, StreamUserEvents) require.NoError(t, err) assert.NotNil(t, stream) info, err := stream.Info(ctx) require.NoError(t, err) - assert.Equal(t, StreamEvents, info.Config.Name) - assert.Contains(t, info.Config.Subjects, "events.>") + assert.Equal(t, StreamUserEvents, info.Config.Name) + assert.Contains(t, info.Config.Subjects, "users.events.>") - consumer, err := jet.Consumer(ctx, StreamEvents, ConsumerEventsProcess) + consumer, err := jet.Consumer(ctx, StreamUserEvents, ConsumerUserEventsProcess) require.NoError(t, err) assert.NotNil(t, consumer) consumerInfo, err := consumer.Info(ctx) require.NoError(t, err) - assert.Equal(t, ConsumerEventsProcess, consumerInfo.Name) - assert.Equal(t, "events.process.>", consumerInfo.Config.FilterSubject) + assert.Equal(t, ConsumerUserEventsProcess, consumerInfo.Name) + assert.Equal(t, "users.events.process.>", consumerInfo.Config.FilterSubject) } func TestBootstrapCreatesRecomputeStream(t *testing.T) { @@ -96,8 +96,8 @@ func TestBootstrapCreatesAllConsumers(t *testing.T) { } consumers := []consumer{ - {StreamEvents, ConsumerEventsProcess, "events.process.>"}, - {StreamEvents, ConsumerEventsSchema, "events.schema.>"}, + {StreamUserEvents, ConsumerUserEventsProcess, "users.events.process.>"}, + {StreamUserEvents, ConsumerUserEventsSchema, "users.events.schema.>"}, {StreamJourneys, ConsumerJourneysAdvance, "journeys.advance.>"}, {StreamLists, ConsumerListsRecompute, "lists.recompute.>"}, } @@ -126,7 +126,7 @@ func TestBootstrapIdempotent(t *testing.T) { err = Bootstrap(ctx, logger, jet) require.NoError(t, err) - stream, err := jet.Stream(ctx, StreamEvents) + stream, err := jet.Stream(ctx, StreamUserEvents) require.NoError(t, err) assert.NotNil(t, stream) } @@ -194,7 +194,7 @@ func TestBootstrapperStreamRetention(t *testing.T) { err := Bootstrap(ctx, logger, jet) require.NoError(t, err) - stream, err := jet.Stream(ctx, StreamEvents) + stream, err := jet.Stream(ctx, StreamUserEvents) require.NoError(t, err) info, err := stream.Info(ctx) diff --git a/internal/pubsub/consumer/consumer.go b/internal/pubsub/consumer/consumer.go index c3a2eb0b..5b5d1f23 100644 --- a/internal/pubsub/consumer/consumer.go +++ b/internal/pubsub/consumer/consumer.go @@ -14,22 +14,31 @@ import ( // Stream names for NATS JetStream. const ( - StreamUsers = "users" - StreamEvents = "events" - StreamLists = "lists" - StreamJourneys = "journeys" - StreamCampaigns = "campaigns" + StreamUsers = "users" + StreamUserEvents = "users-events" + StreamLists = "lists" + StreamJourneys = "journeys" + StreamCampaigns = "campaigns" + StreamOrganizations = "organizations" + StreamOrganizationUsers = "organizations-users" + StreamOrganizationEvents = "organizations-events" ) // Consumer names for NATS JetStream subscribers. const ( - ConsumerUsersProcess = "users-process" - ConsumerUsersSchema = "users-schema" - ConsumerEventsProcess = "events-process" - ConsumerEventsSchema = "events-schema" - ConsumerListsRecompute = "lists-recompute" - ConsumerJourneysAdvance = "journeys-advance" - ConsumerCampaignsSend = "campaigns-send" + ConsumerUsersProcess = "users-process" + ConsumerUsersSchema = "users-schema" + ConsumerUserEventsProcess = "users-events-process" + ConsumerUserEventsSchema = "users-events-schema" + ConsumerListsRecompute = "lists-recompute" + ConsumerJourneysAdvance = "journeys-advance" + ConsumerCampaignsSend = "campaigns-send" + ConsumerOrganizationsProcess = "organizations-process" + ConsumerOrganizationsSchema = "organizations-schema" + ConsumerOrganizationUsersProcess = "organizations-users-process" + ConsumerOrganizationUsersSchema = "organizations-users-schema" + ConsumerOrganizationEventsProcess = "organizations-events-process" + ConsumerOrganizationEventsSchema = "organizations-events-schema" ) // Serve starts all JetStream consumers and registers their handlers. @@ -39,9 +48,15 @@ func Serve(ctx graceful.Context, jet jetstream.JetStream, logger *zap.Logger, db router.Handle(StreamUsers, ConsumerUsersProcess, UsersHandler(logger, usrs, pub)) router.Handle(StreamUsers, ConsumerUsersSchema, UserSchemasHandler(logger, usrs)) - router.Handle(StreamEvents, ConsumerEventsProcess, EventsHandler(logger, usrs, jrny, pub)) - router.Handle(StreamEvents, ConsumerEventsSchema, EventSchemasHandler(logger, usrs)) + router.Handle(StreamUserEvents, ConsumerUserEventsProcess, UserEventsHandler(logger, usrs, jrny, pub)) + router.Handle(StreamUserEvents, ConsumerUserEventsSchema, UserEventSchemasHandler(logger, usrs)) router.Handle(StreamLists, ConsumerListsRecompute, RecomputeListHandler(logger, usrs, pub)) router.Handle(StreamJourneys, ConsumerJourneysAdvance, JourneyStepHandler(logger, db.Subjects, jrny, pub)) router.Handle(StreamCampaigns, ConsumerCampaignsSend, CampaignsSendHandler(logger, mgmt, usrs, registry)) + router.Handle(StreamOrganizations, ConsumerOrganizationsProcess, OrganizationsHandler(logger, usrs, pub)) + router.Handle(StreamOrganizations, ConsumerOrganizationsSchema, OrganizationSchemasHandler(logger, usrs)) + router.Handle(StreamOrganizationUsers, ConsumerOrganizationUsersProcess, OrganizationUsersHandler(logger, usrs, pub)) + router.Handle(StreamOrganizationUsers, ConsumerOrganizationUsersSchema, OrganizationUserSchemasHandler(logger, usrs)) + router.Handle(StreamOrganizationEvents, ConsumerOrganizationEventsProcess, OrganizationEventsHandler(logger, usrs, jrny, pub)) + router.Handle(StreamOrganizationEvents, ConsumerOrganizationEventsSchema, OrganizationEventSchemasHandler(logger, usrs)) } diff --git a/internal/pubsub/consumer/organization_events.go b/internal/pubsub/consumer/organization_events.go new file mode 100644 index 00000000..68bb5438 --- /dev/null +++ b/internal/pubsub/consumer/organization_events.go @@ -0,0 +1,242 @@ +package consumer + +import ( + "context" + "encoding/json" + "time" + + "github.com/google/uuid" + "github.com/lunogram/platform/internal/http/controllers/v1/management/oapi" + "github.com/lunogram/platform/internal/pubsub" + "github.com/lunogram/platform/internal/pubsub/schemas" + "github.com/lunogram/platform/internal/rules" + "github.com/lunogram/platform/internal/rules/eval" + "github.com/lunogram/platform/internal/store/journey" + "github.com/lunogram/platform/internal/store/subjects" + "github.com/nats-io/nats.go/jetstream" + "go.uber.org/zap" + "golang.org/x/sync/errgroup" +) + +// OrganizationEventsHandler creates a handler that processes incoming organization events and stores them in the database. +// It also triggers list recomputation and journey advancement for all users in the organization. +func OrganizationEventsHandler(logger *zap.Logger, usrs *subjects.State, jrny *journey.State, pub pubsub.Publisher) HandlerFunc { + return func(ctx context.Context, msg jetstream.Msg) error { + event := schemas.OrganizationEvent{} + err := json.Unmarshal(msg.Data(), &event) + if err != nil { + logger.Error("failed to unmarshal organization event message", zap.Error(err)) + return err + } + + logger.Info("incoming organization event", zap.String("name", event.Name), zap.Stringer("project_id", event.ProjectID)) + + event.ID, err = usrs.UpsertEvent(ctx, event.ProjectID, event.Name) + if err != nil { + logger.Error("failed to upsert event", zap.Error(err)) + return err + } + + if event.OrganizationID == uuid.Nil { + logger.Info("looking up organization ID", zap.String("external_id", event.OrganizationExternalID)) + + event.OrganizationID, err = usrs.LookupOrganizationID(ctx, event.ProjectID, event.OrganizationExternalID) + if err != nil { + logger.Error("failed to lookup organization ID", zap.Error(err)) + return err + } + } + + _, err = usrs.InsertOrganizationEvent(ctx, event.OrganizationID, event.ID, event.Data) + if err != nil { + logger.Error("failed to insert organization event", zap.Error(err)) + return err + } + + wg, ctx := errgroup.WithContext(ctx) + wg.Go(PublishOrganizationEventSchema(ctx, logger, pub, event)) + wg.Go(PublishOrganizationEventListDependencies(ctx, logger, usrs, pub, event)) + wg.Go(PublishOrganizationEventJourneyDependencies(ctx, logger, usrs, jrny, pub, event)) + + err = wg.Wait() + if err != nil { + logger.Error("failed to publish dependent events", zap.Error(err)) + return err + } + + logger.Info("organization event processed successfully", zap.Stringer("event_id", event.ID), zap.Stringer("organization_id", event.OrganizationID)) + return nil + } +} + +// PublishOrganizationEventSchema returns a function that publishes the organization event schema +// if the event contains data properties. +func PublishOrganizationEventSchema(ctx context.Context, logger *zap.Logger, pub pubsub.Publisher, event schemas.OrganizationEvent) func() error { + return func() error { + if event.Data != nil { + err := pub.Publish(ctx, schemas.OrganizationEventsSchema(event.ProjectID), event) + if err != nil { + logger.Error("failed to publish organization event to schema subject", zap.Error(err)) + return err + } + } + return nil + } +} + +// PublishOrganizationEventListDependencies returns a function that publishes recompute messages for all lists +// that depend on the given event through rule conditions. +func PublishOrganizationEventListDependencies(ctx context.Context, logger *zap.Logger, usrs *subjects.State, pub pubsub.Publisher, event schemas.OrganizationEvent) func() error { + return func() error { + lists, err := usrs.ListEventListDependencies(ctx, event.ID) + if err != nil { + logger.Error("failed to list rule event dependencies", zap.Error(err)) + return err + } + + for _, id := range lists { + list := RecomputeList{ + ID: id, + ProjectID: event.ProjectID, + } + + err = pub.Publish(ctx, schemas.ListsRecompute(event.ProjectID, list.ID), list) + if err != nil { + logger.Error("failed to publish list recompute", zap.Error(err)) + return err + } + } + + return nil + } +} + +// PublishOrganizationEventJourneyDependencies returns a function that triggers journey entrance steps +// for all users in the organization when an organization event matches a journey entrance condition. +func PublishOrganizationEventJourneyDependencies(ctx context.Context, logger *zap.Logger, usrs *subjects.State, jrny *journey.State, pub pubsub.Publisher, event schemas.OrganizationEvent) func() error { + evaluator := eval.NewEvaluator() + + return func() error { + deps, err := jrny.ListEventJourneyDependencies(ctx, event.ID) + if err != nil { + logger.Error("failed to list event journey dependencies", zap.Error(err)) + return err + } + + if len(deps) == 0 { + return nil + } + + // Get all users in the organization + userIDs, err := usrs.ListOrganizationUserIDs(ctx, event.OrganizationID) + if err != nil { + logger.Error("failed to list organization user IDs", zap.Error(err)) + return err + } + + if len(userIDs) == 0 { + logger.Info("no users in organization, skipping journey triggers", zap.Stringer("organization_id", event.OrganizationID)) + return nil + } + + for _, dep := range deps { + entrance := oapi.EntranceStepData{} + if dep.Data != nil { + err := json.Unmarshal(*dep.Data, &entrance) + if err != nil { + return err + } + } + + if entrance.Rule != nil { + match, err := evaluator.Evaluate(*entrance.Rule, event.Data) + if err != nil { + logger.Error("failed to evaluate journey entrance rule", zap.Error(err)) + return err + } + + if !match { + continue + } + } + + logger.Info("triggering journey entrance step for organization users", + zap.Stringer("journey_id", dep.JourneyID), + zap.Stringer("step_id", dep.StepID), + zap.Int("user_count", len(userIDs))) + + data, err := json.Marshal(event.Data) + if err != nil { + logger.Error("failed to marshal journey entry data", zap.Error(err)) + return err + } + + // Trigger journey for each user in the organization + for _, userID := range userIDs { + entry, err := uuid.NewRandom() + if err != nil { + logger.Error("failed to generate journey entry ID", zap.Error(err)) + return err + } + + now := time.Now() + result := journey.JourneyUserState{ + JourneyID: dep.JourneyID, + JourneyEntryID: entry, + UserID: userID, + ExternalStepID: dep.ExternalID, + Data: json.RawMessage(data), + CompletedAt: &now, + } + + _, err = jrny.CreateUserJourneyState(ctx, result) + if err != nil { + logger.Error("failed to create journey user state", zap.Error(err), zap.Stringer("user_id", userID)) + return err + } + + for _, child := range dep.Children { + step := JourneyStep{ + ProjectID: event.ProjectID, + JourneyID: dep.JourneyID, + JourneyEntryID: entry, + ExternalStepID: child.ChildExternalID, + UserID: userID, + } + + err = pub.Publish(ctx, schemas.JourneysAdvance(event.ProjectID, dep.JourneyID), step) + if err != nil { + logger.Error("failed to publish journey state", zap.Error(err), zap.Stringer("user_id", userID)) + return err + } + } + } + } + + return nil + } +} + +// OrganizationEventSchemasHandler creates a handler that extracts and stores organization event schema information. +func OrganizationEventSchemasHandler(logger *zap.Logger, usrs *subjects.State) HandlerFunc { + return func(ctx context.Context, msg jetstream.Msg) error { + event := schemas.OrganizationEvent{} + err := json.Unmarshal(msg.Data(), &event) + if err != nil { + logger.Error("failed to unmarshal organization event message", zap.Error(err)) + return err + } + + logger.Info("incoming organization event schema", zap.Stringer("event_id", event.ID), zap.Stringer("project_id", event.ProjectID)) + + paths := rules.ParsePaths(event.Data) + err = usrs.UpsertEventSchema(ctx, event.ProjectID, event.ID, paths) + if err != nil { + logger.Error("failed to upsert event schema", zap.Error(err)) + return err + } + + logger.Info("organization event schema processed successfully", zap.Stringer("event_id", event.ID)) + return nil + } +} diff --git a/internal/pubsub/consumer/organization_events_test.go b/internal/pubsub/consumer/organization_events_test.go new file mode 100644 index 00000000..5b1451e1 --- /dev/null +++ b/internal/pubsub/consumer/organization_events_test.go @@ -0,0 +1,285 @@ +package consumer + +import ( + "encoding/json" + "testing" + "time" + + "github.com/cloudproud/graceful" + "github.com/google/uuid" + "github.com/lunogram/platform/internal/pubsub" + "github.com/lunogram/platform/internal/pubsub/schemas" + "github.com/lunogram/platform/internal/store/journey" + "github.com/lunogram/platform/internal/store/subjects" + "github.com/nats-io/nats.go/jetstream" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" +) + +func TestOrganizationEventsHandlerSuccess(t *testing.T) { + t.Parallel() + + _, usrsDB, jrnyDB, projectID, jet := setupOrganizationsTest(t) + logger := zaptest.NewLogger(t) + ctx := graceful.NewContext(t.Context()) + + err := Bootstrap(ctx, logger, jet) + require.NoError(t, err) + + usersState := subjects.NewState(usrsDB) + journeyState := journey.NewState(jrnyDB) + pub := pubsub.NewPublisher(jet) + + // First, create an organization in the database + orgID, err := usersState.UpsertOrganization(ctx, projectID, subjects.UpsertOrganizationParams{ + ExternalID: "org_event_test", + Name: strPtr("Test Org for Events"), + }) + require.NoError(t, err) + + handler := OrganizationEventsHandler(logger, usersState, journeyState, pub) + + event := schemas.OrganizationEvent{ + Name: "purchase.completed", + ProjectID: projectID, + OrganizationID: orgID, + Data: map[string]any{ + "amount": 999.99, + "currency": "USD", + }, + } + + err = pub.Publish(ctx, schemas.OrganizationEventsProcess(projectID), event) + require.NoError(t, err) + + consumer, err := jet.Consumer(ctx, StreamOrganizationEvents, ConsumerOrganizationEventsProcess) + require.NoError(t, err) + + msg, err := consumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + err = handler(ctx, msg) + require.NoError(t, err) + + err = msg.Ack() + require.NoError(t, err) + + // Verify schema message was published (since Data was provided) + schemaConsumer, err := jet.Consumer(ctx, StreamOrganizationEvents, ConsumerOrganizationEventsSchema) + require.NoError(t, err) + + schemaMsg, err := schemaConsumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + var receivedEvent schemas.OrganizationEvent + err = json.Unmarshal(schemaMsg.Data(), &receivedEvent) + require.NoError(t, err) + assert.NotEqual(t, uuid.Nil, receivedEvent.ID) + assert.Equal(t, "purchase.completed", receivedEvent.Name) +} + +func TestOrganizationEventsHandlerWithExternalID(t *testing.T) { + t.Parallel() + + _, usrsDB, jrnyDB, projectID, jet := setupOrganizationsTest(t) + logger := zaptest.NewLogger(t) + ctx := graceful.NewContext(t.Context()) + + err := Bootstrap(ctx, logger, jet) + require.NoError(t, err) + + usersState := subjects.NewState(usrsDB) + journeyState := journey.NewState(jrnyDB) + pub := pubsub.NewPublisher(jet) + + // Create an organization with a known external ID + externalID := "org_external_123" + _, err = usersState.UpsertOrganization(ctx, projectID, subjects.UpsertOrganizationParams{ + ExternalID: externalID, + Name: strPtr("External ID Org"), + }) + require.NoError(t, err) + + handler := OrganizationEventsHandler(logger, usersState, journeyState, pub) + + // Send event using external ID instead of internal ID + event := schemas.OrganizationEvent{ + Name: "subscription.renewed", + ProjectID: projectID, + OrganizationID: uuid.Nil, // No internal ID + OrganizationExternalID: externalID, + Data: map[string]any{ + "plan": "enterprise", + }, + } + + err = pub.Publish(ctx, schemas.OrganizationEventsProcess(projectID), event) + require.NoError(t, err) + + consumer, err := jet.Consumer(ctx, StreamOrganizationEvents, ConsumerOrganizationEventsProcess) + require.NoError(t, err) + + msg, err := consumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + err = handler(ctx, msg) + require.NoError(t, err) + + err = msg.Ack() + require.NoError(t, err) +} + +func TestOrganizationEventsHandlerWithoutData(t *testing.T) { + t.Parallel() + + _, usrsDB, jrnyDB, projectID, jet := setupOrganizationsTest(t) + logger := zaptest.NewLogger(t) + ctx := graceful.NewContext(t.Context()) + + err := Bootstrap(ctx, logger, jet) + require.NoError(t, err) + + usersState := subjects.NewState(usrsDB) + journeyState := journey.NewState(jrnyDB) + pub := pubsub.NewPublisher(jet) + + // Create an organization + orgID, err := usersState.UpsertOrganization(ctx, projectID, subjects.UpsertOrganizationParams{ + ExternalID: "org_no_data_event", + Name: strPtr("No Data Event Org"), + }) + require.NoError(t, err) + + handler := OrganizationEventsHandler(logger, usersState, journeyState, pub) + + event := schemas.OrganizationEvent{ + Name: "org.activated", + ProjectID: projectID, + OrganizationID: orgID, + Data: nil, // No data + } + + err = pub.Publish(ctx, schemas.OrganizationEventsProcess(projectID), event) + require.NoError(t, err) + + consumer, err := jet.Consumer(ctx, StreamOrganizationEvents, ConsumerOrganizationEventsProcess) + require.NoError(t, err) + + msg, err := consumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + err = handler(ctx, msg) + require.NoError(t, err) + + err = msg.Ack() + require.NoError(t, err) + + // Verify NO schema message was published (since Data is nil) + schemaConsumer, err := jet.Consumer(ctx, StreamOrganizationEvents, ConsumerOrganizationEventsSchema) + require.NoError(t, err) + + _, err = schemaConsumer.Next(jetstream.FetchMaxWait(1 * time.Second)) + assert.Error(t, err) // Should timeout +} + +func TestOrganizationEventSchemasHandlerSuccess(t *testing.T) { + t.Parallel() + + _, usrsDB, _, projectID, jet := setupOrganizationsTest(t) + logger := zaptest.NewLogger(t) + ctx := graceful.NewContext(t.Context()) + + err := Bootstrap(ctx, logger, jet) + require.NoError(t, err) + + usersState := subjects.NewState(usrsDB) + + // First, create the event in the database + eventID, err := usersState.UpsertEvent(ctx, projectID, "org.contract.signed") + require.NoError(t, err) + + handler := OrganizationEventSchemasHandler(logger, usersState) + + event := schemas.OrganizationEvent{ + ID: eventID, + Name: "org.contract.signed", + ProjectID: projectID, + Data: map[string]any{ + "contract": map[string]any{ + "id": "contract_123", + "value": 50000.00, + "duration": "12 months", + }, + "signed_by": "CEO", + }, + } + + err = pubsub.NewPublisher(jet).Publish(ctx, schemas.OrganizationEventsSchema(projectID), event) + require.NoError(t, err) + + consumer, err := jet.Consumer(ctx, StreamOrganizationEvents, ConsumerOrganizationEventsSchema) + require.NoError(t, err) + + msg, err := consumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + err = handler(ctx, msg) + require.NoError(t, err) + + err = msg.Ack() + require.NoError(t, err) +} + +func TestOrganizationEventSchemasHandlerComplexNestedData(t *testing.T) { + t.Parallel() + + _, usrsDB, _, projectID, jet := setupOrganizationsTest(t) + logger := zaptest.NewLogger(t) + ctx := graceful.NewContext(t.Context()) + + err := Bootstrap(ctx, logger, jet) + require.NoError(t, err) + + usersState := subjects.NewState(usrsDB) + + // Create event + eventID, err := usersState.UpsertEvent(ctx, projectID, "org.deal.closed") + require.NoError(t, err) + + handler := OrganizationEventSchemasHandler(logger, usersState) + + event := schemas.OrganizationEvent{ + ID: eventID, + Name: "org.deal.closed", + ProjectID: projectID, + Data: map[string]any{ + "deal": map[string]any{ + "id": "deal_456", + "amount": 100000.00, + "products": []map[string]any{ + {"name": "Enterprise License", "quantity": 10}, + {"name": "Support Package", "quantity": 1}, + }, + "metadata": map[string]any{ + "source": "inbound", + "rep_id": "sales_rep_789", + "closed_at": "2025-02-22T10:00:00Z", + }, + }, + "customer_type": "enterprise", + }, + } + + err = pubsub.NewPublisher(jet).Publish(ctx, schemas.OrganizationEventsSchema(projectID), event) + require.NoError(t, err) + + consumer, err := jet.Consumer(ctx, StreamOrganizationEvents, ConsumerOrganizationEventsSchema) + require.NoError(t, err) + + msg, err := consumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + err = handler(ctx, msg) + require.NoError(t, err) +} diff --git a/internal/pubsub/consumer/organizations.go b/internal/pubsub/consumer/organizations.go new file mode 100644 index 00000000..ac45e7dd --- /dev/null +++ b/internal/pubsub/consumer/organizations.go @@ -0,0 +1,225 @@ +package consumer + +import ( + "context" + "encoding/json" + + "github.com/lunogram/platform/internal/pubsub" + "github.com/lunogram/platform/internal/pubsub/schemas" + "github.com/lunogram/platform/internal/rules" + "github.com/lunogram/platform/internal/store/subjects" + "github.com/nats-io/nats.go/jetstream" + "go.uber.org/zap" +) + +// OrganizationsHandler creates a handler that processes incoming organizations and stores them in the database. +func OrganizationsHandler(logger *zap.Logger, usrs *subjects.State, pub pubsub.Publisher) HandlerFunc { + return func(ctx context.Context, msg jetstream.Msg) error { + org := schemas.Organization{} + err := json.Unmarshal(msg.Data(), &org) + if err != nil { + logger.Error("failed to unmarshal organization message", zap.Error(err)) + return err + } + + logger.Info("incoming organization", zap.Stringer("organization_id", org.ID), zap.Stringer("project_id", org.ProjectID)) + + err = PublishOrganizationRecomputeLists(ctx, logger, usrs, pub, org) + if err != nil { + logger.Error("failed to publish organization recompute lists", zap.Error(err)) + return err + } + + if org.Data != nil { + err = pub.Publish(ctx, schemas.OrganizationsSchema(org.ProjectID), org) + if err != nil { + logger.Error("failed to publish organization to schema subject", zap.Error(err)) + return err + } + } + + err = PublishOrganizationEvents(ctx, logger, pub, org) + if err != nil { + logger.Error("failed to publish organization events", zap.Error(err)) + return err + } + + logger.Info("organization processed successfully", zap.Stringer("organization_id", org.ID)) + return nil + } +} + +// PublishOrganizationRecomputeLists publishes recompute messages for all lists that depend on organization data. +func PublishOrganizationRecomputeLists(ctx context.Context, logger *zap.Logger, usrs *subjects.State, pub pubsub.Publisher, org schemas.Organization) error { + result, err := usrs.SelectListOrganizationsDependency(ctx, org.ProjectID) + if err != nil { + logger.Error("failed to list rule organization dependencies", zap.Error(err)) + return err + } + + for _, id := range result { + list := RecomputeList{ + ID: id, + ProjectID: org.ProjectID, + } + + err = pub.Publish(ctx, schemas.ListsRecompute(org.ProjectID, list.ID), list) + if err != nil { + logger.Error("failed to publish list recompute", zap.Error(err)) + return err + } + } + + return nil +} + +// PublishOrganizationEvents publishes organization system events (organization.created or organization.updated). +func PublishOrganizationEvents(ctx context.Context, logger *zap.Logger, pub pubsub.Publisher, org schemas.Organization) error { + if org.Version == 0 { + err := pub.Publish(ctx, schemas.OrganizationEventsProcess(org.ProjectID), org.OrganizationEvent(schemas.EventOrganizationCreated)) + if err != nil { + logger.Error("failed to publish organization created event", zap.Error(err)) + return err + } + + return nil + } + + err := pub.Publish(ctx, schemas.OrganizationEventsProcess(org.ProjectID), org.OrganizationEvent(schemas.EventOrganizationUpdated)) + if err != nil { + logger.Error("failed to publish organization updated event", zap.Error(err)) + return err + } + + return nil +} + +// OrganizationSchemasHandler creates a handler that extracts and stores organization schema information. +func OrganizationSchemasHandler(logger *zap.Logger, usrs *subjects.State) HandlerFunc { + return func(ctx context.Context, msg jetstream.Msg) error { + org := schemas.Organization{} + err := json.Unmarshal(msg.Data(), &org) + if err != nil { + logger.Error("failed to unmarshal organization message", zap.Error(err)) + return err + } + + logger.Info("incoming organization schema", zap.Stringer("organization_id", org.ID), zap.Stringer("project_id", org.ProjectID)) + + paths := rules.ParsePaths(org.Data) + err = usrs.UpsertOrganizationSchema(ctx, org.ProjectID, paths) + if err != nil { + logger.Error("failed to upsert organization schema", zap.Error(err)) + return err + } + + logger.Info("organization schema processed successfully", zap.Stringer("organization_id", org.ID)) + return nil + } +} + +// OrganizationUsersHandler creates a handler that processes incoming organization user memberships. +func OrganizationUsersHandler(logger *zap.Logger, usrs *subjects.State, pub pubsub.Publisher) HandlerFunc { + return func(ctx context.Context, msg jetstream.Msg) error { + orgUser := schemas.OrganizationUser{} + err := json.Unmarshal(msg.Data(), &orgUser) + if err != nil { + logger.Error("failed to unmarshal organization user message", zap.Error(err)) + return err + } + + logger.Info("incoming organization user", zap.Stringer("organization_id", orgUser.OrganizationID), zap.Stringer("user_id", orgUser.UserID), zap.Stringer("project_id", orgUser.ProjectID)) + + err = PublishOrganizationUserRecomputeLists(ctx, logger, usrs, pub, orgUser) + if err != nil { + logger.Error("failed to publish organization user recompute lists", zap.Error(err)) + return err + } + + if orgUser.Data != nil { + err = pub.Publish(ctx, schemas.OrganizationUsersSchema(orgUser.ProjectID), orgUser) + if err != nil { + logger.Error("failed to publish organization user to schema subject", zap.Error(err)) + return err + } + } + + err = PublishOrganizationUserEvents(ctx, logger, pub, orgUser) + if err != nil { + logger.Error("failed to publish organization user events", zap.Error(err)) + return err + } + + logger.Info("organization user processed successfully", zap.Stringer("organization_id", orgUser.OrganizationID), zap.Stringer("user_id", orgUser.UserID)) + return nil + } +} + +// PublishOrganizationUserRecomputeLists publishes recompute messages for all lists that depend on organization user data. +func PublishOrganizationUserRecomputeLists(ctx context.Context, logger *zap.Logger, usrs *subjects.State, pub pubsub.Publisher, orgUser schemas.OrganizationUser) error { + result, err := usrs.SelectListOrganizationUsersDependency(ctx, orgUser.ProjectID) + if err != nil { + logger.Error("failed to list rule organization user dependencies", zap.Error(err)) + return err + } + + for _, id := range result { + list := RecomputeList{ + ID: id, + ProjectID: orgUser.ProjectID, + } + + err = pub.Publish(ctx, schemas.ListsRecompute(orgUser.ProjectID, list.ID), list) + if err != nil { + logger.Error("failed to publish list recompute", zap.Error(err)) + return err + } + } + + return nil +} + +// PublishOrganizationUserEvents publishes organization user system events (organization.user.added or organization.user.updated). +func PublishOrganizationUserEvents(ctx context.Context, logger *zap.Logger, pub pubsub.Publisher, orgUser schemas.OrganizationUser) error { + if orgUser.Version == 0 { + err := pub.Publish(ctx, schemas.OrganizationEventsProcess(orgUser.ProjectID), orgUser.OrganizationEvent(schemas.EventOrganizationUserAdded)) + if err != nil { + logger.Error("failed to publish organization user added event", zap.Error(err)) + return err + } + + return nil + } + + err := pub.Publish(ctx, schemas.OrganizationEventsProcess(orgUser.ProjectID), orgUser.OrganizationEvent(schemas.EventOrganizationUserUpdated)) + if err != nil { + logger.Error("failed to publish organization user updated event", zap.Error(err)) + return err + } + + return nil +} + +// OrganizationUserSchemasHandler creates a handler that extracts and stores organization user schema information. +func OrganizationUserSchemasHandler(logger *zap.Logger, usrs *subjects.State) HandlerFunc { + return func(ctx context.Context, msg jetstream.Msg) error { + orgUser := schemas.OrganizationUser{} + err := json.Unmarshal(msg.Data(), &orgUser) + if err != nil { + logger.Error("failed to unmarshal organization user message", zap.Error(err)) + return err + } + + logger.Info("incoming organization user schema", zap.Stringer("organization_id", orgUser.OrganizationID), zap.Stringer("user_id", orgUser.UserID), zap.Stringer("project_id", orgUser.ProjectID)) + + paths := rules.ParsePaths(orgUser.Data) + err = usrs.UpsertOrganizationUserSchema(ctx, orgUser.ProjectID, paths) + if err != nil { + logger.Error("failed to upsert organization user schema", zap.Error(err)) + return err + } + + logger.Info("organization user schema processed successfully", zap.Stringer("organization_id", orgUser.OrganizationID), zap.Stringer("user_id", orgUser.UserID)) + return nil + } +} diff --git a/internal/pubsub/consumer/organizations_test.go b/internal/pubsub/consumer/organizations_test.go new file mode 100644 index 00000000..2ad6a7b6 --- /dev/null +++ b/internal/pubsub/consumer/organizations_test.go @@ -0,0 +1,488 @@ +package consumer + +import ( + "encoding/json" + "testing" + "time" + + "github.com/cloudproud/graceful" + "github.com/google/uuid" + "github.com/jmoiron/sqlx" + "github.com/lunogram/platform/internal/config" + "github.com/lunogram/platform/internal/container" + "github.com/lunogram/platform/internal/pubsub" + "github.com/lunogram/platform/internal/pubsub/schemas" + "github.com/lunogram/platform/internal/store/management" + "github.com/lunogram/platform/internal/store/subjects" + teststore "github.com/lunogram/platform/internal/store/test" + "github.com/nats-io/nats.go/jetstream" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" +) + +func setupOrganizationsTest(t *testing.T) (mgmtDB, usrsDB, jrnyDB *sqlx.DB, projectID uuid.UUID, jet jetstream.JetStream) { + t.Helper() + + ctx := graceful.NewContext(t.Context()) + + natsURL := container.RunNATS(t) + mgmtDB, usrsDB, jrnyDB = teststore.RunPostgreSQL(t) + + cfg := config.Node{ + Nats: config.Nats{ + URL: natsURL, + }, + } + + jet, err := pubsub.New(ctx, cfg) + require.NoError(t, err) + + mgmtState := management.NewState(mgmtDB) + + orgID, err := mgmtState.OrganizationsStore.CreateOrganization(ctx, "Test Org") + require.NoError(t, err) + + projectID, err = mgmtState.ProjectsStore.CreateProject(ctx, management.Project{ + OrganizationID: &orgID, + Name: "Test Project", + Timezone: "UTC", + Locale: "en", + }) + require.NoError(t, err) + + return mgmtDB, usrsDB, jrnyDB, projectID, jet +} + +func TestOrganizationsHandlerSuccess(t *testing.T) { + t.Parallel() + + _, usrsDB, _, projectID, jet := setupOrganizationsTest(t) + logger := zaptest.NewLogger(t) + ctx := graceful.NewContext(t.Context()) + + err := Bootstrap(ctx, logger, jet) + require.NoError(t, err) + + usersState := subjects.NewState(usrsDB) + pub := pubsub.NewPublisher(jet) + handler := OrganizationsHandler(logger, usersState, pub) + + orgID := uuid.New() + org := schemas.Organization{ + ID: orgID, + ProjectID: projectID, + ExternalID: "org_123", + Name: strPtr("Test Organization"), + Data: map[string]any{ + "industry": "technology", + }, + Version: 0, // New organization + } + + err = pub.Publish(ctx, schemas.OrganizationsProcess(projectID), org) + require.NoError(t, err) + + consumer, err := jet.Consumer(ctx, StreamOrganizations, ConsumerOrganizationsProcess) + require.NoError(t, err) + + msg, err := consumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + err = handler(ctx, msg) + require.NoError(t, err) + + err = msg.Ack() + require.NoError(t, err) + + // Verify schema message was published (since Data was provided) + schemaConsumer, err := jet.Consumer(ctx, StreamOrganizations, ConsumerOrganizationsSchema) + require.NoError(t, err) + + schemaMsg, err := schemaConsumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + var receivedOrg schemas.Organization + err = json.Unmarshal(schemaMsg.Data(), &receivedOrg) + require.NoError(t, err) + assert.Equal(t, orgID, receivedOrg.ID) + assert.Equal(t, "org_123", receivedOrg.ExternalID) + + // Verify organization.created event was published + orgEventsConsumer, err := jet.Consumer(ctx, StreamOrganizationEvents, ConsumerOrganizationEventsProcess) + require.NoError(t, err) + + orgEventMsg, err := orgEventsConsumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + var receivedEvent schemas.OrganizationEvent + err = json.Unmarshal(orgEventMsg.Data(), &receivedEvent) + require.NoError(t, err) + assert.Equal(t, schemas.EventOrganizationCreated, receivedEvent.Name) + assert.Equal(t, orgID, receivedEvent.OrganizationID) +} + +func TestOrganizationsHandlerUpdatedEvent(t *testing.T) { + t.Parallel() + + _, usrsDB, _, projectID, jet := setupOrganizationsTest(t) + logger := zaptest.NewLogger(t) + ctx := graceful.NewContext(t.Context()) + + err := Bootstrap(ctx, logger, jet) + require.NoError(t, err) + + usersState := subjects.NewState(usrsDB) + pub := pubsub.NewPublisher(jet) + handler := OrganizationsHandler(logger, usersState, pub) + + orgID := uuid.New() + org := schemas.Organization{ + ID: orgID, + ProjectID: projectID, + ExternalID: "org_456", + Name: strPtr("Updated Organization"), + Data: map[string]any{ + "industry": "finance", + }, + Version: 1, // Existing organization (updated) + } + + err = pub.Publish(ctx, schemas.OrganizationsProcess(projectID), org) + require.NoError(t, err) + + consumer, err := jet.Consumer(ctx, StreamOrganizations, ConsumerOrganizationsProcess) + require.NoError(t, err) + + msg, err := consumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + err = handler(ctx, msg) + require.NoError(t, err) + + err = msg.Ack() + require.NoError(t, err) + + // Verify organization.updated event was published (not created) + orgEventsConsumer, err := jet.Consumer(ctx, StreamOrganizationEvents, ConsumerOrganizationEventsProcess) + require.NoError(t, err) + + orgEventMsg, err := orgEventsConsumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + var receivedEvent schemas.OrganizationEvent + err = json.Unmarshal(orgEventMsg.Data(), &receivedEvent) + require.NoError(t, err) + assert.Equal(t, schemas.EventOrganizationUpdated, receivedEvent.Name) +} + +func TestOrganizationsHandlerWithoutData(t *testing.T) { + t.Parallel() + + _, usrsDB, _, projectID, jet := setupOrganizationsTest(t) + logger := zaptest.NewLogger(t) + ctx := graceful.NewContext(t.Context()) + + err := Bootstrap(ctx, logger, jet) + require.NoError(t, err) + + usersState := subjects.NewState(usrsDB) + pub := pubsub.NewPublisher(jet) + handler := OrganizationsHandler(logger, usersState, pub) + + orgID := uuid.New() + org := schemas.Organization{ + ID: orgID, + ProjectID: projectID, + ExternalID: "org_no_data", + Name: strPtr("No Data Org"), + Data: nil, // No data + Version: 0, + } + + err = pub.Publish(ctx, schemas.OrganizationsProcess(projectID), org) + require.NoError(t, err) + + consumer, err := jet.Consumer(ctx, StreamOrganizations, ConsumerOrganizationsProcess) + require.NoError(t, err) + + msg, err := consumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + err = handler(ctx, msg) + require.NoError(t, err) + + err = msg.Ack() + require.NoError(t, err) + + // Verify NO schema message was published (since Data is nil) + schemaConsumer, err := jet.Consumer(ctx, StreamOrganizations, ConsumerOrganizationsSchema) + require.NoError(t, err) + + _, err = schemaConsumer.Next(jetstream.FetchMaxWait(1 * time.Second)) + assert.Error(t, err) // Should timeout +} + +func TestOrganizationSchemasHandlerSuccess(t *testing.T) { + t.Parallel() + + _, usrsDB, _, projectID, jet := setupOrganizationsTest(t) + logger := zaptest.NewLogger(t) + ctx := graceful.NewContext(t.Context()) + + err := Bootstrap(ctx, logger, jet) + require.NoError(t, err) + + usersState := subjects.NewState(usrsDB) + handler := OrganizationSchemasHandler(logger, usersState) + + orgID := uuid.New() + org := schemas.Organization{ + ID: orgID, + ProjectID: projectID, + ExternalID: "org_schema_test", + Data: map[string]any{ + "company": map[string]any{ + "name": "Acme Corp", + "industry": "manufacturing", + }, + "employee_count": 500, + }, + } + + err = pubsub.NewPublisher(jet).Publish(ctx, schemas.OrganizationsSchema(projectID), org) + require.NoError(t, err) + + consumer, err := jet.Consumer(ctx, StreamOrganizations, ConsumerOrganizationsSchema) + require.NoError(t, err) + + msg, err := consumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + err = handler(ctx, msg) + require.NoError(t, err) + + err = msg.Ack() + require.NoError(t, err) +} + +func TestOrganizationUsersHandlerSuccess(t *testing.T) { + t.Parallel() + + _, usrsDB, _, projectID, jet := setupOrganizationsTest(t) + logger := zaptest.NewLogger(t) + ctx := graceful.NewContext(t.Context()) + + err := Bootstrap(ctx, logger, jet) + require.NoError(t, err) + + usersState := subjects.NewState(usrsDB) + pub := pubsub.NewPublisher(jet) + handler := OrganizationUsersHandler(logger, usersState, pub) + + orgID := uuid.New() + userID := uuid.New() + orgUser := schemas.OrganizationUser{ + OrganizationID: orgID, + OrganizationExternalID: "org_user_test", + UserID: userID, + ProjectID: projectID, + Data: map[string]any{ + "role": "admin", + }, + Version: 0, // New membership + } + + err = pub.Publish(ctx, schemas.OrganizationUsersProcess(projectID), orgUser) + require.NoError(t, err) + + consumer, err := jet.Consumer(ctx, StreamOrganizationUsers, ConsumerOrganizationUsersProcess) + require.NoError(t, err) + + msg, err := consumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + err = handler(ctx, msg) + require.NoError(t, err) + + err = msg.Ack() + require.NoError(t, err) + + // Verify schema message was published (since Data was provided) + schemaConsumer, err := jet.Consumer(ctx, StreamOrganizationUsers, ConsumerOrganizationUsersSchema) + require.NoError(t, err) + + schemaMsg, err := schemaConsumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + var receivedOrgUser schemas.OrganizationUser + err = json.Unmarshal(schemaMsg.Data(), &receivedOrgUser) + require.NoError(t, err) + assert.Equal(t, orgID, receivedOrgUser.OrganizationID) + assert.Equal(t, userID, receivedOrgUser.UserID) + + // Verify organization.user.added event was published + orgEventsConsumer, err := jet.Consumer(ctx, StreamOrganizationEvents, ConsumerOrganizationEventsProcess) + require.NoError(t, err) + + orgEventMsg, err := orgEventsConsumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + var receivedEvent schemas.OrganizationEvent + err = json.Unmarshal(orgEventMsg.Data(), &receivedEvent) + require.NoError(t, err) + assert.Equal(t, schemas.EventOrganizationUserAdded, receivedEvent.Name) +} + +func TestOrganizationUsersHandlerUpdatedEvent(t *testing.T) { + t.Parallel() + + _, usrsDB, _, projectID, jet := setupOrganizationsTest(t) + logger := zaptest.NewLogger(t) + ctx := graceful.NewContext(t.Context()) + + err := Bootstrap(ctx, logger, jet) + require.NoError(t, err) + + usersState := subjects.NewState(usrsDB) + pub := pubsub.NewPublisher(jet) + handler := OrganizationUsersHandler(logger, usersState, pub) + + orgID := uuid.New() + userID := uuid.New() + orgUser := schemas.OrganizationUser{ + OrganizationID: orgID, + OrganizationExternalID: "org_user_update", + UserID: userID, + ProjectID: projectID, + Data: map[string]any{ + "role": "member", + }, + Version: 1, // Existing membership (updated) + } + + err = pub.Publish(ctx, schemas.OrganizationUsersProcess(projectID), orgUser) + require.NoError(t, err) + + consumer, err := jet.Consumer(ctx, StreamOrganizationUsers, ConsumerOrganizationUsersProcess) + require.NoError(t, err) + + msg, err := consumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + err = handler(ctx, msg) + require.NoError(t, err) + + err = msg.Ack() + require.NoError(t, err) + + // Verify organization.user.updated event was published (not added) + orgEventsConsumer, err := jet.Consumer(ctx, StreamOrganizationEvents, ConsumerOrganizationEventsProcess) + require.NoError(t, err) + + orgEventMsg, err := orgEventsConsumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + var receivedEvent schemas.OrganizationEvent + err = json.Unmarshal(orgEventMsg.Data(), &receivedEvent) + require.NoError(t, err) + assert.Equal(t, schemas.EventOrganizationUserUpdated, receivedEvent.Name) +} + +func TestOrganizationUsersHandlerWithoutData(t *testing.T) { + t.Parallel() + + _, usrsDB, _, projectID, jet := setupOrganizationsTest(t) + logger := zaptest.NewLogger(t) + ctx := graceful.NewContext(t.Context()) + + err := Bootstrap(ctx, logger, jet) + require.NoError(t, err) + + usersState := subjects.NewState(usrsDB) + pub := pubsub.NewPublisher(jet) + handler := OrganizationUsersHandler(logger, usersState, pub) + + orgID := uuid.New() + userID := uuid.New() + orgUser := schemas.OrganizationUser{ + OrganizationID: orgID, + OrganizationExternalID: "org_user_no_data", + UserID: userID, + ProjectID: projectID, + Data: nil, // No data + Version: 0, + } + + err = pub.Publish(ctx, schemas.OrganizationUsersProcess(projectID), orgUser) + require.NoError(t, err) + + consumer, err := jet.Consumer(ctx, StreamOrganizationUsers, ConsumerOrganizationUsersProcess) + require.NoError(t, err) + + msg, err := consumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + err = handler(ctx, msg) + require.NoError(t, err) + + err = msg.Ack() + require.NoError(t, err) + + // Verify NO schema message was published (since Data is nil) + schemaConsumer, err := jet.Consumer(ctx, StreamOrganizationUsers, ConsumerOrganizationUsersSchema) + require.NoError(t, err) + + _, err = schemaConsumer.Next(jetstream.FetchMaxWait(1 * time.Second)) + assert.Error(t, err) // Should timeout +} + +func TestOrganizationUserSchemasHandlerSuccess(t *testing.T) { + t.Parallel() + + _, usrsDB, _, projectID, jet := setupOrganizationsTest(t) + logger := zaptest.NewLogger(t) + ctx := graceful.NewContext(t.Context()) + + err := Bootstrap(ctx, logger, jet) + require.NoError(t, err) + + usersState := subjects.NewState(usrsDB) + handler := OrganizationUserSchemasHandler(logger, usersState) + + orgID := uuid.New() + userID := uuid.New() + orgUser := schemas.OrganizationUser{ + OrganizationID: orgID, + OrganizationExternalID: "org_user_schema_test", + UserID: userID, + ProjectID: projectID, + Data: map[string]any{ + "role": "owner", + "permissions": []string{"read", "write", "admin"}, + "metadata": map[string]any{ + "joined_via": "invitation", + }, + }, + } + + err = pubsub.NewPublisher(jet).Publish(ctx, schemas.OrganizationUsersSchema(projectID), orgUser) + require.NoError(t, err) + + consumer, err := jet.Consumer(ctx, StreamOrganizationUsers, ConsumerOrganizationUsersSchema) + require.NoError(t, err) + + msg, err := consumer.Next(jetstream.FetchMaxWait(5 * time.Second)) + require.NoError(t, err) + + err = handler(ctx, msg) + require.NoError(t, err) + + err = msg.Ack() + require.NoError(t, err) +} + +// strPtr is a helper function to create a string pointer. +func strPtr(s string) *string { + return &s +} diff --git a/internal/pubsub/consumer/recompute.go b/internal/pubsub/consumer/recompute.go index 3328f1db..3ef2c7e8 100644 --- a/internal/pubsub/consumer/recompute.go +++ b/internal/pubsub/consumer/recompute.go @@ -74,7 +74,7 @@ func PublishListRecomputeEvents(ctx context.Context, logger *zap.Logger, pub pub for _, applied := range recomputed { switch applied.Action { case subjects.RecomputeActionInserted: - event := schemas.Event{ + event := schemas.UserEvent{ Name: schemas.EventListUserAdded, UserID: applied.UserID, ProjectID: projectID, @@ -83,13 +83,13 @@ func PublishListRecomputeEvents(ctx context.Context, logger *zap.Logger, pub pub }, } - err = pub.Publish(ctx, schemas.EventsProcess(event.ProjectID), event) + err = pub.Publish(ctx, schemas.UserEventsProcess(event.ProjectID), event) if err != nil { logger.Error("failed to publish user list inserted event", zap.Error(err)) return err } case subjects.RecomputeActionDeleted: - event := schemas.Event{ + event := schemas.UserEvent{ Name: schemas.EventListUserRemoved, UserID: applied.UserID, ProjectID: projectID, @@ -98,7 +98,7 @@ func PublishListRecomputeEvents(ctx context.Context, logger *zap.Logger, pub pub }, } - err = pub.Publish(ctx, schemas.EventsProcess(event.ProjectID), event) + err = pub.Publish(ctx, schemas.UserEventsProcess(event.ProjectID), event) if err != nil { logger.Error("failed to publish user list removed event", zap.Error(err)) return err diff --git a/internal/pubsub/consumer/recompute_test.go b/internal/pubsub/consumer/recompute_test.go index 8b494f40..167dac97 100644 --- a/internal/pubsub/consumer/recompute_test.go +++ b/internal/pubsub/consumer/recompute_test.go @@ -254,13 +254,13 @@ func TestRecomputeListHandlerWithUserAddedEvent(t *testing.T) { err = msg.Ack() require.NoError(t, err) - eventConsumer, err := jet.Consumer(ctx, StreamEvents, ConsumerEventsProcess) + eventConsumer, err := jet.Consumer(ctx, StreamUserEvents, ConsumerUserEventsProcess) require.NoError(t, err) eventMsg, err := eventConsumer.Next(jetstream.FetchMaxWait(5 * time.Second)) require.NoError(t, err) - var receivedEvent schemas.Event + var receivedEvent schemas.UserEvent err = json.Unmarshal(eventMsg.Data(), &receivedEvent) require.NoError(t, err) assert.Equal(t, schemas.EventListUserAdded, receivedEvent.Name) @@ -276,8 +276,8 @@ func TestPublishListRecomputeEventsInserted(t *testing.T) { ctx := graceful.NewContext(t.Context()) _, err := jet.CreateStream(ctx, jetstream.StreamConfig{ - Name: StreamEvents, - Subjects: []string{"events.>"}, + Name: StreamUserEvents, + Subjects: []string{"users.events.>"}, }) require.NoError(t, err) @@ -305,8 +305,8 @@ func TestPublishListRecomputeEventsDeleted(t *testing.T) { ctx := graceful.NewContext(t.Context()) _, err := jet.CreateStream(ctx, jetstream.StreamConfig{ - Name: StreamEvents, - Subjects: []string{"events.>"}, + Name: StreamUserEvents, + Subjects: []string{"users.events.>"}, }) require.NoError(t, err) @@ -334,8 +334,8 @@ func TestPublishListRecomputeEventsMixed(t *testing.T) { ctx := graceful.NewContext(t.Context()) _, err := jet.CreateStream(ctx, jetstream.StreamConfig{ - Name: StreamEvents, - Subjects: []string{"events.>"}, + Name: StreamUserEvents, + Subjects: []string{"users.events.>"}, }) require.NoError(t, err) diff --git a/internal/pubsub/consumer/events.go b/internal/pubsub/consumer/user_events.go similarity index 76% rename from internal/pubsub/consumer/events.go rename to internal/pubsub/consumer/user_events.go index dcba6b45..af407c1b 100644 --- a/internal/pubsub/consumer/events.go +++ b/internal/pubsub/consumer/user_events.go @@ -28,10 +28,10 @@ type JourneyStep struct { StateID *uuid.UUID `json:"state_id,omitempty"` } -// EventsHandler creates a handler that processes incoming events and stores them in the database. -func EventsHandler(logger *zap.Logger, usrs *subjects.State, jrny *journey.State, pub pubsub.Publisher) HandlerFunc { +// UserEventsHandler creates a handler that processes incoming user events and stores them in the database. +func UserEventsHandler(logger *zap.Logger, usrs *subjects.State, jrny *journey.State, pub pubsub.Publisher) HandlerFunc { return func(ctx context.Context, msg jetstream.Msg) error { - event := schemas.Event{} + event := schemas.UserEvent{} err := json.Unmarshal(msg.Data(), &event) if err != nil { logger.Error("failed to unmarshal event message", zap.Error(err)) @@ -63,9 +63,9 @@ func EventsHandler(logger *zap.Logger, usrs *subjects.State, jrny *journey.State } wg, ctx := errgroup.WithContext(ctx) - wg.Go(PublishEventSchema(ctx, logger, pub, event)) - wg.Go(PublishEventListDependencies(ctx, logger, usrs, pub, event)) - wg.Go(PublishEventJourneyDependencies(ctx, logger, usrs, jrny, pub, event)) + wg.Go(PublishUserEventSchema(ctx, logger, pub, event)) + wg.Go(PublishUserEventListDependencies(ctx, logger, usrs, pub, event)) + wg.Go(PublishUserEventJourneyDependencies(ctx, logger, usrs, jrny, pub, event)) err = wg.Wait() if err != nil { @@ -73,17 +73,17 @@ func EventsHandler(logger *zap.Logger, usrs *subjects.State, jrny *journey.State return err } - logger.Info("event processed successfully", zap.Stringer("event_id", event.ID)) + logger.Info("user event processed successfully", zap.Stringer("event_id", event.ID)) return nil } } -// PublishEventSchema returns a function that publishes the event schema to the schema subject +// PublishUserEventSchema returns a function that publishes the user event schema to the schema subject // if the event contains data properties. -func PublishEventSchema(ctx context.Context, logger *zap.Logger, pub pubsub.Publisher, event schemas.Event) func() error { +func PublishUserEventSchema(ctx context.Context, logger *zap.Logger, pub pubsub.Publisher, event schemas.UserEvent) func() error { return func() error { if event.Data != nil { - err := pub.Publish(ctx, schemas.EventsSchema(event.ProjectID), event) + err := pub.Publish(ctx, schemas.UserEventsSchema(event.ProjectID), event) if err != nil { logger.Error("failed to publish event to project subject", zap.Error(err)) return err @@ -94,9 +94,9 @@ func PublishEventSchema(ctx context.Context, logger *zap.Logger, pub pubsub.Publ } } -// PublishEventListDependencies returns a function that publishes recompute messages for all lists -// that depend on the given event through rule conditions. -func PublishEventListDependencies(ctx context.Context, logger *zap.Logger, usrs *subjects.State, pub pubsub.Publisher, event schemas.Event) func() error { +// PublishUserEventListDependencies returns a function that publishes recompute messages for all lists +// that depend on the given user event through rule conditions. +func PublishUserEventListDependencies(ctx context.Context, logger *zap.Logger, usrs *subjects.State, pub pubsub.Publisher, event schemas.UserEvent) func() error { return func() error { lists, err := usrs.ListEventListDependencies(ctx, event.ID) if err != nil { @@ -121,9 +121,9 @@ func PublishEventListDependencies(ctx context.Context, logger *zap.Logger, usrs } } -// PublishEventJourneyDependencies returns a function that triggers journey entrance steps -// for all journeys configured with event-based entrance conditions matching the given event. -func PublishEventJourneyDependencies(ctx context.Context, logger *zap.Logger, usrs *subjects.State, jrny *journey.State, pub pubsub.Publisher, event schemas.Event) func() error { +// PublishUserEventJourneyDependencies returns a function that triggers journey entrance steps +// for all journeys configured with event-based entrance conditions matching the given user event. +func PublishUserEventJourneyDependencies(ctx context.Context, logger *zap.Logger, usrs *subjects.State, jrny *journey.State, pub pubsub.Publisher, event schemas.UserEvent) func() error { evaluator := eval.NewEvaluator() return func() error { @@ -207,10 +207,10 @@ func PublishEventJourneyDependencies(ctx context.Context, logger *zap.Logger, us } } -// EventSchemasHandler creates a handler that extracts and stores event schema information. -func EventSchemasHandler(logger *zap.Logger, usrs *subjects.State) HandlerFunc { +// UserEventSchemasHandler creates a handler that extracts and stores user event schema information. +func UserEventSchemasHandler(logger *zap.Logger, usrs *subjects.State) HandlerFunc { return func(ctx context.Context, msg jetstream.Msg) error { - event := schemas.Event{} + event := schemas.UserEvent{} err := json.Unmarshal(msg.Data(), &event) if err != nil { logger.Error("failed to unmarshal event message", zap.Error(err)) diff --git a/internal/pubsub/consumer/events_test.go b/internal/pubsub/consumer/user_events_test.go similarity index 73% rename from internal/pubsub/consumer/events_test.go rename to internal/pubsub/consumer/user_events_test.go index 47512105..67e0c84b 100644 --- a/internal/pubsub/consumer/events_test.go +++ b/internal/pubsub/consumer/user_events_test.go @@ -22,7 +22,7 @@ import ( "go.uber.org/zap/zaptest" ) -func setupEventsTest(t *testing.T) (mgmtDB, usrsDB, jrnyDB *sqlx.DB, projectID uuid.UUID, jet jetstream.JetStream) { +func setupUserEventsTest(t *testing.T) (mgmtDB, usrsDB, jrnyDB *sqlx.DB, projectID uuid.UUID, jet jetstream.JetStream) { t.Helper() ctx := graceful.NewContext(t.Context()) @@ -55,10 +55,10 @@ func setupEventsTest(t *testing.T) (mgmtDB, usrsDB, jrnyDB *sqlx.DB, projectID u return mgmtDB, usrsDB, jrnyDB, projectID, jet } -func TestEventsProjectHandlerSuccess(t *testing.T) { +func TestUserEventsProjectHandlerSuccess(t *testing.T) { t.Parallel() - _, usrsDB, jrnyDB, projectID, jet := setupEventsTest(t) + _, usrsDB, jrnyDB, projectID, jet := setupUserEventsTest(t) logger := zaptest.NewLogger(t) ctx := graceful.NewContext(t.Context()) @@ -74,9 +74,9 @@ func TestEventsProjectHandlerSuccess(t *testing.T) { require.NoError(t, err) pub := pubsub.NewPublisher(jet) - handler := EventsHandler(logger, usersState, journeyState, pub) + handler := UserEventsHandler(logger, usersState, journeyState, pub) - event := schemas.Event{ + event := schemas.UserEvent{ Name: "test_event", ProjectID: projectID, UserID: userID, @@ -85,10 +85,10 @@ func TestEventsProjectHandlerSuccess(t *testing.T) { }, } - err = pub.Publish(ctx, schemas.Subject(schemas.EventsProcess(projectID)), event) + err = pub.Publish(ctx, schemas.Subject(schemas.UserEventsProcess(projectID)), event) require.NoError(t, err) - consumer, err := jet.Consumer(ctx, StreamEvents, ConsumerEventsProcess) + consumer, err := jet.Consumer(ctx, StreamUserEvents, ConsumerUserEventsProcess) require.NoError(t, err) msg, err := consumer.Next(jetstream.FetchMaxWait(5 * time.Second)) @@ -100,23 +100,23 @@ func TestEventsProjectHandlerSuccess(t *testing.T) { err = msg.Ack() require.NoError(t, err) - schemaConsumer, err := jet.Consumer(ctx, StreamEvents, ConsumerEventsSchema) + schemaConsumer, err := jet.Consumer(ctx, StreamUserEvents, ConsumerUserEventsSchema) require.NoError(t, err) schemaMsg, err := schemaConsumer.Next(jetstream.FetchMaxWait(5 * time.Second)) require.NoError(t, err) - var receivedEvent schemas.Event + var receivedEvent schemas.UserEvent err = json.Unmarshal(schemaMsg.Data(), &receivedEvent) require.NoError(t, err) assert.NotEqual(t, uuid.Nil, receivedEvent.ID) assert.Equal(t, "test_event", receivedEvent.Name) } -func TestEventsProjectHandlerWithoutData(t *testing.T) { +func TestUserEventsProjectHandlerWithoutData(t *testing.T) { t.Parallel() - _, usrsDB, jrnyDB, projectID, jet := setupEventsTest(t) + _, usrsDB, jrnyDB, projectID, jet := setupUserEventsTest(t) logger := zaptest.NewLogger(t) ctx := graceful.NewContext(t.Context()) @@ -132,19 +132,19 @@ func TestEventsProjectHandlerWithoutData(t *testing.T) { require.NoError(t, err) pub := pubsub.NewPublisher(jet) - handler := EventsHandler(logger, usersState, journeyState, pub) + handler := UserEventsHandler(logger, usersState, journeyState, pub) - event := schemas.Event{ + event := schemas.UserEvent{ Name: "test_event_no_data", ProjectID: projectID, UserID: userID, Data: nil, } - err = pub.Publish(ctx, schemas.Subject(schemas.EventsProcess(projectID)), event) + err = pub.Publish(ctx, schemas.Subject(schemas.UserEventsProcess(projectID)), event) require.NoError(t, err) - consumer, err := jet.Consumer(ctx, StreamEvents, ConsumerEventsProcess) + consumer, err := jet.Consumer(ctx, StreamUserEvents, ConsumerUserEventsProcess) require.NoError(t, err) msg, err := consumer.Next(jetstream.FetchMaxWait(5 * time.Second)) @@ -156,17 +156,17 @@ func TestEventsProjectHandlerWithoutData(t *testing.T) { err = msg.Ack() require.NoError(t, err) - schemaConsumer, err := jet.Consumer(ctx, StreamEvents, ConsumerEventsSchema) + schemaConsumer, err := jet.Consumer(ctx, StreamUserEvents, ConsumerUserEventsSchema) require.NoError(t, err) _, err = schemaConsumer.Next(jetstream.FetchMaxWait(1 * time.Second)) assert.Error(t, err) } -func TestEventsProjectHandlerWithIdentifiers(t *testing.T) { +func TestUserEventsProjectHandlerWithIdentifiers(t *testing.T) { t.Parallel() - _, usrsDB, jrnyDB, projectID, jet := setupEventsTest(t) + _, usrsDB, jrnyDB, projectID, jet := setupUserEventsTest(t) logger := zaptest.NewLogger(t) ctx := graceful.NewContext(t.Context()) @@ -185,9 +185,9 @@ func TestEventsProjectHandlerWithIdentifiers(t *testing.T) { require.NoError(t, err) pub := pubsub.NewPublisher(jet) - handler := EventsHandler(logger, usersState, journeyState, pub) + handler := UserEventsHandler(logger, usersState, journeyState, pub) - event := schemas.Event{ + event := schemas.UserEvent{ Name: "user_action", ProjectID: projectID, ExternalId: &externalID, @@ -197,10 +197,10 @@ func TestEventsProjectHandlerWithIdentifiers(t *testing.T) { }, } - err = pub.Publish(ctx, schemas.Subject(schemas.EventsProcess(projectID)), event) + err = pub.Publish(ctx, schemas.Subject(schemas.UserEventsProcess(projectID)), event) require.NoError(t, err) - consumer, err := jet.Consumer(ctx, StreamEvents, ConsumerEventsProcess) + consumer, err := jet.Consumer(ctx, StreamUserEvents, ConsumerUserEventsProcess) require.NoError(t, err) msg, err := consumer.Next(jetstream.FetchMaxWait(5 * time.Second)) @@ -210,10 +210,10 @@ func TestEventsProjectHandlerWithIdentifiers(t *testing.T) { require.NoError(t, err) } -func TestEventsSchemaHandlerSuccess(t *testing.T) { +func TestUserEventsSchemaHandlerSuccess(t *testing.T) { t.Parallel() - _, usrsDB, _, projectID, jet := setupEventsTest(t) + _, usrsDB, _, projectID, jet := setupUserEventsTest(t) logger := zaptest.NewLogger(t) ctx := graceful.NewContext(t.Context()) @@ -224,9 +224,9 @@ func TestEventsSchemaHandlerSuccess(t *testing.T) { eventID, err := usersState.EventsStore.UpsertEvent(ctx, projectID, "test_event") require.NoError(t, err) - handler := EventSchemasHandler(logger, usersState) + handler := UserEventSchemasHandler(logger, usersState) - event := schemas.Event{ + event := schemas.UserEvent{ ID: eventID, Name: "test_event", ProjectID: projectID, @@ -239,10 +239,10 @@ func TestEventsSchemaHandlerSuccess(t *testing.T) { }, } - err = pubsub.NewPublisher(jet).Publish(ctx, schemas.Subject(schemas.EventsSchema(projectID)), event) + err = pubsub.NewPublisher(jet).Publish(ctx, schemas.Subject(schemas.UserEventsSchema(projectID)), event) require.NoError(t, err) - consumer, err := jet.Consumer(ctx, StreamEvents, ConsumerEventsSchema) + consumer, err := jet.Consumer(ctx, StreamUserEvents, ConsumerUserEventsSchema) require.NoError(t, err) msg, err := consumer.Next(jetstream.FetchMaxWait(5 * time.Second)) @@ -255,10 +255,10 @@ func TestEventsSchemaHandlerSuccess(t *testing.T) { require.NoError(t, err) } -func TestEventsSchemaHandlerComplexNestedData(t *testing.T) { +func TestUserEventsSchemaHandlerComplexNestedData(t *testing.T) { t.Parallel() - _, usrsDB, _, projectID, jet := setupEventsTest(t) + _, usrsDB, _, projectID, jet := setupUserEventsTest(t) logger := zaptest.NewLogger(t) ctx := graceful.NewContext(t.Context()) @@ -269,9 +269,9 @@ func TestEventsSchemaHandlerComplexNestedData(t *testing.T) { eventID, err := usersState.EventsStore.UpsertEvent(ctx, projectID, "complex_event") require.NoError(t, err) - handler := EventSchemasHandler(logger, usersState) + handler := UserEventSchemasHandler(logger, usersState) - event := schemas.Event{ + event := schemas.UserEvent{ ID: eventID, Name: "complex_event", ProjectID: projectID, @@ -290,10 +290,10 @@ func TestEventsSchemaHandlerComplexNestedData(t *testing.T) { }, } - err = pubsub.NewPublisher(jet).Publish(ctx, schemas.Subject(schemas.EventsSchema(projectID)), event) + err = pubsub.NewPublisher(jet).Publish(ctx, schemas.Subject(schemas.UserEventsSchema(projectID)), event) require.NoError(t, err) - consumer, err := jet.Consumer(ctx, StreamEvents, ConsumerEventsSchema) + consumer, err := jet.Consumer(ctx, StreamUserEvents, ConsumerUserEventsSchema) require.NoError(t, err) msg, err := consumer.Next(jetstream.FetchMaxWait(5 * time.Second)) diff --git a/internal/pubsub/consumer/users.go b/internal/pubsub/consumer/users.go index 7d2503df..b35e6f4a 100644 --- a/internal/pubsub/consumer/users.go +++ b/internal/pubsub/consumer/users.go @@ -75,7 +75,7 @@ func PublishUserRecomputeLists(ctx context.Context, logger *zap.Logger, usrs *su func PublishUserEvents(ctx context.Context, logger *zap.Logger, pub pubsub.Publisher, user schemas.User) (err error) { // NOTE: the user is created, let's publish a different event if user.Version == 0 { - err = pub.Publish(ctx, schemas.EventsProcess(user.ProjectID), user.Event(schemas.EventUserCreated)) + err = pub.Publish(ctx, schemas.UserEventsProcess(user.ProjectID), user.UserEvent(schemas.EventUserCreated)) if err != nil { logger.Error("failed to publish user created event", zap.Error(err)) return err @@ -84,7 +84,7 @@ func PublishUserEvents(ctx context.Context, logger *zap.Logger, pub pubsub.Publi return nil } - err = pub.Publish(ctx, schemas.EventsProcess(user.ProjectID), user.Event(schemas.EventUserUpdated)) + err = pub.Publish(ctx, schemas.UserEventsProcess(user.ProjectID), user.UserEvent(schemas.EventUserUpdated)) if err != nil { logger.Error("failed to publish user updated event", zap.Error(err)) return err diff --git a/internal/pubsub/consumer/users_test.go b/internal/pubsub/consumer/users_test.go index e9156db6..7e0e7a5e 100644 --- a/internal/pubsub/consumer/users_test.go +++ b/internal/pubsub/consumer/users_test.go @@ -104,7 +104,7 @@ func TestUserEvent(t *testing.T) { Version: 5, } - event := user.Event("test_event") + event := user.UserEvent("test_event") assert.Equal(t, "test_event", event.Name) assert.Equal(t, projectID, event.ProjectID) @@ -196,13 +196,13 @@ func TestUsersHandlerPublishesUserCreatedEvent(t *testing.T) { err = handler(ctx, msg) require.NoError(t, err) - eventConsumer, err := jet.Consumer(ctx, StreamEvents, ConsumerEventsProcess) + eventConsumer, err := jet.Consumer(ctx, StreamUserEvents, ConsumerUserEventsProcess) require.NoError(t, err) eventMsg, err := eventConsumer.Next(jetstream.FetchMaxWait(5 * time.Second)) require.NoError(t, err) - var receivedEvent schemas.Event + var receivedEvent schemas.UserEvent err = json.Unmarshal(eventMsg.Data(), &receivedEvent) require.NoError(t, err) assert.Equal(t, schemas.EventUserCreated, receivedEvent.Name) @@ -245,13 +245,13 @@ func TestUsersHandlerPublishesUserUpdatedEvent(t *testing.T) { err = handler(ctx, msg) require.NoError(t, err) - eventConsumer, err := jet.Consumer(ctx, StreamEvents, ConsumerEventsProcess) + eventConsumer, err := jet.Consumer(ctx, StreamUserEvents, ConsumerUserEventsProcess) require.NoError(t, err) eventMsg, err := eventConsumer.Next(jetstream.FetchMaxWait(5 * time.Second)) require.NoError(t, err) - var receivedEvent schemas.Event + var receivedEvent schemas.UserEvent err = json.Unmarshal(eventMsg.Data(), &receivedEvent) require.NoError(t, err) assert.Equal(t, schemas.EventUserUpdated, receivedEvent.Name) @@ -532,8 +532,8 @@ func TestPublishUserEventsUserCreated(t *testing.T) { ctx := graceful.NewContext(t.Context()) _, err := jet.CreateStream(ctx, jetstream.StreamConfig{ - Name: StreamEvents, - Subjects: []string{"events.>"}, + Name: StreamUserEvents, + Subjects: []string{"users.events.>"}, }) require.NoError(t, err) @@ -563,8 +563,8 @@ func TestPublishUserEventsUserUpdated(t *testing.T) { ctx := graceful.NewContext(t.Context()) _, err := jet.CreateStream(ctx, jetstream.StreamConfig{ - Name: StreamEvents, - Subjects: []string{"events.>"}, + Name: StreamUserEvents, + Subjects: []string{"users.events.>"}, }) require.NoError(t, err) diff --git a/internal/pubsub/pubsub_test.go b/internal/pubsub/pubsub_test.go index 75d74121..48b937ac 100644 --- a/internal/pubsub/pubsub_test.go +++ b/internal/pubsub/pubsub_test.go @@ -63,7 +63,7 @@ func TestPublisherPublish(t *testing.T) { tests := map[string]test{ "publish event": { subject: "events.process.123", - data: schemas.Event{ + data: schemas.UserEvent{ ID: uuid.New(), Name: "test_event", ProjectID: uuid.New(), @@ -71,7 +71,7 @@ func TestPublisherPublish(t *testing.T) { }, "publish with nil data": { subject: "events.process.456", - data: schemas.Event{ + data: schemas.UserEvent{ ID: uuid.New(), Name: "another_event", ProjectID: uuid.New(), @@ -80,7 +80,7 @@ func TestPublisherPublish(t *testing.T) { }, "publish with event data": { subject: "events.process.789", - data: schemas.Event{ + data: schemas.UserEvent{ ID: uuid.New(), Name: "event_with_data", ProjectID: uuid.New(), @@ -100,23 +100,23 @@ func TestPublisherPublish(t *testing.T) { } } -func TestEventsProject(t *testing.T) { +func TestUserEventsProcess(t *testing.T) { t.Parallel() projectID := uuid.New() - subject := schemas.EventsProcess(projectID) + subject := schemas.UserEventsProcess(projectID) - expected := schemas.Subject("events.process." + projectID.String()) + expected := schemas.Subject("users.events.process." + projectID.String()) assert.Equal(t, expected, subject) } -func TestEventsSchema(t *testing.T) { +func TestUserEventsSchema(t *testing.T) { t.Parallel() projectID := uuid.New() - subject := schemas.EventsSchema(projectID) + subject := schemas.UserEventsSchema(projectID) - expected := schemas.Subject("events.schema." + projectID.String()) + expected := schemas.Subject("users.events.schema." + projectID.String()) assert.Equal(t, expected, subject) } @@ -134,7 +134,7 @@ func TestPublisherPublishAndReceive(t *testing.T) { pub := NewPublisher(jet) - testEvent := schemas.Event{ + testEvent := schemas.UserEvent{ ID: uuid.New(), Name: "test_event", ProjectID: uuid.New(), @@ -155,7 +155,7 @@ func TestPublisherPublishAndReceive(t *testing.T) { msg, err := consumer.Next() require.NoError(t, err) - var received schemas.Event + var received schemas.UserEvent err = json.Unmarshal(msg.Data(), &received) require.NoError(t, err) diff --git a/internal/pubsub/schemas/events.go b/internal/pubsub/schemas/events.go index 933fa961..5f72e132 100644 --- a/internal/pubsub/schemas/events.go +++ b/internal/pubsub/schemas/events.go @@ -14,10 +14,16 @@ const ( EventUserUpdated = "user.updated" EventListUserAdded = "list.user.added" EventListUserRemoved = "list.user.removed" + + EventOrganizationCreated = "organization.created" + EventOrganizationUpdated = "organization.updated" + EventOrganizationUserAdded = "organization.user.added" + EventOrganizationUserUpdated = "organization.user.updated" + EventOrganizationUserRemoved = "organization.user.removed" ) -// Event represents a tracked event with associated user and project information. -type Event struct { +// UserEvent represents a tracked event with associated user and project information. +type UserEvent struct { ID uuid.UUID `json:"id"` Name string `json:"name"` ProjectID uuid.UUID `json:"project_id"` @@ -40,8 +46,8 @@ type User struct { Version int32 `json:"version"` } -func (u User) Event(name string) Event { - return Event{ +func (u User) UserEvent(name string) UserEvent { + return UserEvent{ Name: name, ProjectID: u.ProjectID, AnonymousId: u.AnonymousID, @@ -74,19 +80,73 @@ type JourneyStep struct { StateID *uuid.UUID `json:"state_id,omitempty"` } -// CampaignsSend returns the NATS subject for campaign sending. -func CampaignsSend(projectID uuid.UUID, campaignID uuid.UUID) Subject { - return Subject(fmt.Sprintf("campaigns.send.%s.%s", projectID, campaignID)) +// Organization represents an organization with associated project information. +type Organization struct { + ID uuid.UUID `json:"id"` + ProjectID uuid.UUID `json:"project_id"` + ExternalID string `json:"external_id"` + Name *string `json:"name"` + Data map[string]any `json:"data"` + Version int32 `json:"version"` +} + +// OrganizationEvent creates an OrganizationEvent from this Organization with the given event name. +func (o Organization) OrganizationEvent(name string) OrganizationEvent { + return OrganizationEvent{ + Name: name, + ProjectID: o.ProjectID, + OrganizationID: o.ID, + OrganizationExternalID: o.ExternalID, + Data: map[string]any{ + "id": o.ID, + "external_id": o.ExternalID, + "name": o.Name, + "data": o.Data, + "version": o.Version, + }, + } } -// EventsProcess returns the NATS subject for event processing. -func EventsProcess(projectID uuid.UUID) Subject { - return Subject(fmt.Sprintf("events.process.%s", projectID)) +// OrganizationUser represents a user's membership in an organization. +type OrganizationUser struct { + OrganizationID uuid.UUID `json:"organization_id"` + OrganizationExternalID string `json:"organization_external_id"` + UserID uuid.UUID `json:"user_id"` + ProjectID uuid.UUID `json:"project_id"` + Data map[string]any `json:"data"` + Version int32 `json:"version"` } -// EventsSchema returns the NATS subject for event schema updates. -func EventsSchema(projectID uuid.UUID) Subject { - return Subject(fmt.Sprintf("events.schema.%s", projectID)) +// OrganizationEvent creates an OrganizationEvent from this OrganizationUser with the given event name. +func (ou OrganizationUser) OrganizationEvent(name string) OrganizationEvent { + return OrganizationEvent{ + Name: name, + ProjectID: ou.ProjectID, + OrganizationID: ou.OrganizationID, + OrganizationExternalID: ou.OrganizationExternalID, + Data: map[string]any{ + "organization_id": ou.OrganizationID, + "organization_external_id": ou.OrganizationExternalID, + "user_id": ou.UserID, + "data": ou.Data, + "version": ou.Version, + }, + } +} + +// OrganizationEvent represents an event that occurs on an organization (not a user). +type OrganizationEvent struct { + ID uuid.UUID `json:"id"` + Name string `json:"name"` + ProjectID uuid.UUID `json:"project_id"` + OrganizationID uuid.UUID `json:"organization_id"` + OrganizationExternalID string `json:"organization_external_id"` + Data map[string]any `json:"data"` +} + +// CampaignsSend returns the NATS subject for campaign sending. +func CampaignsSend(projectID uuid.UUID, campaignID uuid.UUID) Subject { + return Subject(fmt.Sprintf("campaigns.send.%s.%s", projectID, campaignID)) } // UsersProcess returns the NATS subject for user processing. @@ -99,6 +159,16 @@ func UsersSchema(projectID uuid.UUID) Subject { return Subject(fmt.Sprintf("users.schema.%s", projectID)) } +// UserEventsProcess returns the NATS subject for user event processing. +func UserEventsProcess(projectID uuid.UUID) Subject { + return Subject(fmt.Sprintf("users.events.process.%s", projectID)) +} + +// UserEventsSchema returns the NATS subject for user event schema updates. +func UserEventsSchema(projectID uuid.UUID) Subject { + return Subject(fmt.Sprintf("users.events.schema.%s", projectID)) +} + // ListsRecompute returns the NATS subject for list recomputation. func ListsRecompute(projectID uuid.UUID, listID uuid.UUID) Subject { return Subject(fmt.Sprintf("lists.recompute.%s.%s", projectID, listID)) @@ -108,3 +178,33 @@ func ListsRecompute(projectID uuid.UUID, listID uuid.UUID) Subject { func JourneysAdvance(projectID uuid.UUID, journeyID uuid.UUID) Subject { return Subject(fmt.Sprintf("journeys.advance.%s.%s", projectID, journeyID)) } + +// OrganizationsProcess returns the NATS subject for organization processing. +func OrganizationsProcess(projectID uuid.UUID) Subject { + return Subject(fmt.Sprintf("organizations.process.%s", projectID)) +} + +// OrganizationsSchema returns the NATS subject for organization schema updates. +func OrganizationsSchema(projectID uuid.UUID) Subject { + return Subject(fmt.Sprintf("organizations.schema.%s", projectID)) +} + +// OrganizationUsersProcess returns the NATS subject for organization user processing. +func OrganizationUsersProcess(projectID uuid.UUID) Subject { + return Subject(fmt.Sprintf("organizations.users.process.%s", projectID)) +} + +// OrganizationUsersSchema returns the NATS subject for organization user schema updates. +func OrganizationUsersSchema(projectID uuid.UUID) Subject { + return Subject(fmt.Sprintf("organizations.users.schema.%s", projectID)) +} + +// OrganizationEventsProcess returns the NATS subject for organization event processing. +func OrganizationEventsProcess(projectID uuid.UUID) Subject { + return Subject(fmt.Sprintf("organizations.events.process.%s", projectID)) +} + +// OrganizationEventsSchema returns the NATS subject for organization event schema updates. +func OrganizationEventsSchema(projectID uuid.UUID) Subject { + return Subject(fmt.Sprintf("organizations.events.schema.%s", projectID)) +} diff --git a/internal/store/subjects/lists.go b/internal/store/subjects/lists.go index e143d5d9..8025ec43 100644 --- a/internal/store/subjects/lists.go +++ b/internal/store/subjects/lists.go @@ -300,6 +300,44 @@ func (s *ListsStore) SelectListUsersDependency(ctx context.Context, projectID uu return result, nil } +// SelectListOrganizationsDependency returns list IDs that have rules depending on organization data. +func (s *ListsStore) SelectListOrganizationsDependency(ctx context.Context, projectID uuid.UUID) ([]uuid.UUID, error) { + query := ` + SELECT l.id + FROM lists l + JOIN rules r ON l.rule_id = r.id + WHERE l.project_id = $1 + AND r.depends_on_organizations = TRUE + AND l.deleted_at IS NULL` + + var result []uuid.UUID + err := s.db.SelectContext(ctx, &result, query, projectID) + if err != nil { + return nil, err + } + + return result, nil +} + +// SelectListOrganizationUsersDependency returns list IDs that have rules depending on organization user data. +func (s *ListsStore) SelectListOrganizationUsersDependency(ctx context.Context, projectID uuid.UUID) ([]uuid.UUID, error) { + query := ` + SELECT l.id + FROM lists l + JOIN rules r ON l.rule_id = r.id + WHERE l.project_id = $1 + AND r.depends_on_organization_users = TRUE + AND l.deleted_at IS NULL` + + var result []uuid.UUID + err := s.db.SelectContext(ctx, &result, query, projectID) + if err != nil { + return nil, err + } + + return result, nil +} + type RecomputeAction string const ( diff --git a/internal/store/subjects/migrations/1771762205_organizations.down.sql b/internal/store/subjects/migrations/1771762205_organizations.down.sql index 1dfec0f6..0155898c 100644 --- a/internal/store/subjects/migrations/1771762205_organizations.down.sql +++ b/internal/store/subjects/migrations/1771762205_organizations.down.sql @@ -1,4 +1,15 @@ --- Drop organization users table first (depends on organizations) +-- Drop organization events table +DROP TABLE IF EXISTS organization_events; + +-- Drop organization dependency columns from rules table +ALTER TABLE rules DROP COLUMN IF EXISTS depends_on_organization_users; +ALTER TABLE rules DROP COLUMN IF EXISTS depends_on_organizations; + +-- Drop schema tables first +DROP TABLE IF EXISTS organization_user_schemas; +DROP TABLE IF EXISTS organization_schemas; + +-- Drop organization users table (depends on organizations) DROP TABLE IF EXISTS organization_users; -- Drop organizations table diff --git a/internal/store/subjects/migrations/1771762205_organizations.up.sql b/internal/store/subjects/migrations/1771762205_organizations.up.sql index 34a87ec1..afdcb65e 100644 --- a/internal/store/subjects/migrations/1771762205_organizations.up.sql +++ b/internal/store/subjects/migrations/1771762205_organizations.up.sql @@ -35,3 +35,55 @@ CREATE INDEX organization_users_user_id_idx ON organization_users(user_id); CREATE INDEX organization_users_data_idx ON organization_users USING gin(data); CREATE TRIGGER set_updated_at_organization_users BEFORE UPDATE ON organization_users FOR EACH ROW EXECUTE PROCEDURE set_updated_at(); + +-- Organization schemas table +-- Stores schema paths extracted from organization data JSONB for autocomplete +CREATE TABLE organization_schemas ( + id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), + project_id UUID NOT NULL, + path VARCHAR(255) NOT NULL, + data_type data_type NOT NULL, + visibility project_rule_paths_visibility NOT NULL DEFAULT 'hidden', + created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE UNIQUE INDEX idx_organization_schemas_project_path ON organization_schemas(project_id, path, data_type); + +CREATE TRIGGER set_updated_at_organization_schemas BEFORE UPDATE ON organization_schemas FOR EACH ROW EXECUTE PROCEDURE set_updated_at(); + +-- Organization user schemas table +-- Stores schema paths extracted from organization_users data JSONB for autocomplete +CREATE TABLE organization_user_schemas ( + id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), + project_id UUID NOT NULL, + path VARCHAR(255) NOT NULL, + data_type data_type NOT NULL, + visibility project_rule_paths_visibility NOT NULL DEFAULT 'hidden', + created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE UNIQUE INDEX idx_organization_user_schemas_project_path ON organization_user_schemas(project_id, path, data_type); + +CREATE TRIGGER set_updated_at_organization_user_schemas BEFORE UPDATE ON organization_user_schemas FOR EACH ROW EXECUTE PROCEDURE set_updated_at(); + +-- Add organization dependency columns to rules table +ALTER TABLE rules ADD COLUMN depends_on_organizations BOOLEAN NOT NULL DEFAULT FALSE; +ALTER TABLE rules ADD COLUMN depends_on_organization_users BOOLEAN NOT NULL DEFAULT FALSE; + +-- Organization events table (event occurrences for organizations) +-- Tracks events that happen to/within organizations (not users) +CREATE TABLE organization_events ( + id UUID PRIMARY KEY DEFAULT uuid_generate_v4(), + organization_id UUID NOT NULL REFERENCES organizations(id) ON DELETE CASCADE, + event_id UUID NOT NULL REFERENCES events(id) ON DELETE CASCADE, + data JSONB, + created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +CREATE INDEX idx_organization_events_organization_id ON organization_events(organization_id); +CREATE INDEX idx_organization_events_event_id ON organization_events(event_id); +CREATE INDEX idx_organization_events_created_at ON organization_events(created_at); +CREATE INDEX idx_organization_events_org_event ON organization_events(organization_id, event_id); +CREATE INDEX idx_organization_events_data ON organization_events USING GIN(data); diff --git a/internal/store/subjects/organizations.go b/internal/store/subjects/organizations.go index 24bab6d7..c41d1a46 100644 --- a/internal/store/subjects/organizations.go +++ b/internal/store/subjects/organizations.go @@ -6,6 +6,8 @@ import ( "time" "github.com/google/uuid" + "github.com/lib/pq" + "github.com/lunogram/platform/internal/rules" "github.com/lunogram/platform/internal/store" ) @@ -280,3 +282,146 @@ func (s *OrganizationsStore) CountOrganizationMembers(ctx context.Context, orgID err := s.db.GetContext(ctx, &count, query, orgID) return count, err } + +// UpsertOrganizationSchema inserts or updates schema paths for organization data. +func (s *OrganizationsStore) UpsertOrganizationSchema(ctx context.Context, projectID uuid.UUID, paths rules.Paths) error { + if len(paths) == 0 { + return nil + } + + stmt := ` + INSERT INTO organization_schemas (project_id, path, data_type) + VALUES ($1, $2, $3) + ON CONFLICT (project_id, path, data_type) DO NOTHING` + + // TODO: optimize with batch insert + for _, path := range paths { + _, err := s.db.ExecContext(ctx, stmt, projectID, path.Path, path.Type) + if err != nil { + return err + } + } + + return nil +} + +// OrganizationSchema represents a schema path for organization data. +type OrganizationSchema struct { + Path string `db:"path"` + Types pq.StringArray `db:"types"` +} + +// ListOrganizationSchemas returns all schema paths for organizations in a project. +func (s *OrganizationsStore) ListOrganizationSchemas(ctx context.Context, projectID uuid.UUID) ([]OrganizationSchema, error) { + stmt := ` + SELECT + path, + array_agg(DISTINCT data_type ORDER BY data_type) as types + FROM organization_schemas + WHERE project_id = $1 + GROUP BY path + ORDER BY path` + + var schemas []OrganizationSchema + err := s.db.SelectContext(ctx, &schemas, stmt, projectID) + if err != nil { + return nil, err + } + + return schemas, nil +} + +// UpsertOrganizationUserSchema inserts or updates schema paths for organization user data. +func (s *OrganizationsStore) UpsertOrganizationUserSchema(ctx context.Context, projectID uuid.UUID, paths rules.Paths) error { + if len(paths) == 0 { + return nil + } + + stmt := ` + INSERT INTO organization_user_schemas (project_id, path, data_type) + VALUES ($1, $2, $3) + ON CONFLICT (project_id, path, data_type) DO NOTHING` + + // TODO: optimize with batch insert + for _, path := range paths { + _, err := s.db.ExecContext(ctx, stmt, projectID, path.Path, path.Type) + if err != nil { + return err + } + } + + return nil +} + +// OrganizationUserSchema represents a schema path for organization user data. +type OrganizationUserSchema struct { + Path string `db:"path"` + Types pq.StringArray `db:"types"` +} + +// ListOrganizationUserSchemas returns all schema paths for organization users in a project. +func (s *OrganizationsStore) ListOrganizationUserSchemas(ctx context.Context, projectID uuid.UUID) ([]OrganizationUserSchema, error) { + stmt := ` + SELECT + path, + array_agg(DISTINCT data_type ORDER BY data_type) as types + FROM organization_user_schemas + WHERE project_id = $1 + GROUP BY path + ORDER BY path` + + var schemas []OrganizationUserSchema + err := s.db.SelectContext(ctx, &schemas, stmt, projectID) + if err != nil { + return nil, err + } + + return schemas, nil +} + +// InsertOrganizationEvent inserts an event occurrence for an organization. +func (s *OrganizationsStore) InsertOrganizationEvent(ctx context.Context, organizationID uuid.UUID, eventID uuid.UUID, data map[string]any) (uuid.UUID, error) { + stmt := ` + INSERT INTO organization_events (organization_id, event_id, data) + VALUES ($1, $2, $3) + RETURNING id` + + var id uuid.UUID + err := s.db.GetContext(ctx, &id, stmt, organizationID, eventID, data) + if err != nil { + return uuid.Nil, err + } + + return id, nil +} + +// LookupOrganizationID looks up an organization's internal ID by external ID. +func (s *OrganizationsStore) LookupOrganizationID(ctx context.Context, projectID uuid.UUID, externalID string) (uuid.UUID, error) { + stmt := ` + SELECT id FROM organizations + WHERE project_id = $1 AND external_id = $2` + + var id uuid.UUID + err := s.db.GetContext(ctx, &id, stmt, projectID, externalID) + if err != nil { + return uuid.Nil, err + } + + return id, nil +} + +// ListOrganizationUserIDs returns all user IDs belonging to an organization. +func (s *OrganizationsStore) ListOrganizationUserIDs(ctx context.Context, orgID uuid.UUID) ([]uuid.UUID, error) { + query := ` + SELECT user_id + FROM organization_users + WHERE organization_id = $1` + + var ids []uuid.UUID + err := s.db.SelectContext(ctx, &ids, query, orgID) + if err != nil { + return nil, err + } + + return ids, nil +} diff --git a/internal/store/subjects/organizations_test.go b/internal/store/subjects/organizations_test.go index 83fc9af7..61de6f5c 100644 --- a/internal/store/subjects/organizations_test.go +++ b/internal/store/subjects/organizations_test.go @@ -6,6 +6,7 @@ import ( "testing" "github.com/google/uuid" + "github.com/lunogram/platform/internal/rules" "github.com/lunogram/platform/internal/store" "github.com/stretchr/testify/require" ) @@ -576,3 +577,464 @@ func TestDeleteOrganizationCascadesMembers(t *testing.T) { require.NoError(t, err) require.Equal(t, 0, len(orgs)) } + +func TestUpsertOrganizationSchema(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + paths := rules.Paths{ + {Path: "plan", Type: rules.TypeString}, + {Path: "seats", Type: rules.TypeNumber}, + {Path: "active", Type: rules.TypeBool}, + } + + err := db.UpsertOrganizationSchema(ctx, projectID, paths) + require.NoError(t, err) + + // Verify schemas were stored + schemas, err := db.ListOrganizationSchemas(ctx, projectID) + require.NoError(t, err) + require.Equal(t, 3, len(schemas)) + + // Verify paths and types + schemaMap := make(map[string][]string) + for _, s := range schemas { + schemaMap[s.Path] = s.Types + } + + require.Contains(t, schemaMap, "plan") + require.Contains(t, schemaMap["plan"], "string") + + require.Contains(t, schemaMap, "seats") + require.Contains(t, schemaMap["seats"], "number") + + require.Contains(t, schemaMap, "active") + require.Contains(t, schemaMap["active"], "boolean") +} + +func TestUpsertOrganizationSchemaDeduplication(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + paths := rules.Paths{ + {Path: "plan", Type: rules.TypeString}, + } + + // Insert same schema twice + err := db.UpsertOrganizationSchema(ctx, projectID, paths) + require.NoError(t, err) + err = db.UpsertOrganizationSchema(ctx, projectID, paths) + require.NoError(t, err) + + // Should still only have one entry + schemas, err := db.ListOrganizationSchemas(ctx, projectID) + require.NoError(t, err) + require.Equal(t, 1, len(schemas)) +} + +func TestUpsertOrganizationSchemaEmptyPaths(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Should not error with empty paths + err := db.UpsertOrganizationSchema(ctx, projectID, rules.Paths{}) + require.NoError(t, err) + + schemas, err := db.ListOrganizationSchemas(ctx, projectID) + require.NoError(t, err) + require.Equal(t, 0, len(schemas)) +} + +func TestUpsertOrganizationUserSchema(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + paths := rules.Paths{ + {Path: "role", Type: rules.TypeString}, + {Path: "permissions", Type: rules.TypeString}, + {Path: "level", Type: rules.TypeNumber}, + } + + err := db.UpsertOrganizationUserSchema(ctx, projectID, paths) + require.NoError(t, err) + + // Verify schemas were stored + schemas, err := db.ListOrganizationUserSchemas(ctx, projectID) + require.NoError(t, err) + require.Equal(t, 3, len(schemas)) + + // Verify paths and types + schemaMap := make(map[string][]string) + for _, s := range schemas { + schemaMap[s.Path] = s.Types + } + + require.Contains(t, schemaMap, "role") + require.Contains(t, schemaMap["role"], "string") + + require.Contains(t, schemaMap, "permissions") + require.Contains(t, schemaMap["permissions"], "string") + + require.Contains(t, schemaMap, "level") + require.Contains(t, schemaMap["level"], "number") +} + +func TestUpsertOrganizationUserSchemaDeduplication(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + paths := rules.Paths{ + {Path: "role", Type: rules.TypeString}, + } + + // Insert same schema twice + err := db.UpsertOrganizationUserSchema(ctx, projectID, paths) + require.NoError(t, err) + err = db.UpsertOrganizationUserSchema(ctx, projectID, paths) + require.NoError(t, err) + + // Should still only have one entry + schemas, err := db.ListOrganizationUserSchemas(ctx, projectID) + require.NoError(t, err) + require.Equal(t, 1, len(schemas)) +} + +func TestUpsertOrganizationUserSchemaEmptyPaths(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Should not error with empty paths + err := db.UpsertOrganizationUserSchema(ctx, projectID, rules.Paths{}) + require.NoError(t, err) + + schemas, err := db.ListOrganizationUserSchemas(ctx, projectID) + require.NoError(t, err) + require.Equal(t, 0, len(schemas)) +} + +func TestSelectListOrganizationsDependency(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Create a rule that depends on organizations + ruleID, err := db.CreateRule(ctx, Rule{ + ProjectID: projectID, + Rule: store.JSONB[rules.RuleSet]{Data: rules.RuleSet{}}, + DependsOnOrganizations: true, + Version: 1, + }) + require.NoError(t, err) + + // Create a list using this rule + listID, err := db.CreateList(ctx, List{ + ProjectID: projectID, + RuleID: &ruleID, + Name: "Org Dependent List", + }) + require.NoError(t, err) + + // Should find the list as a dependency + result, err := db.SelectListOrganizationsDependency(ctx, projectID) + require.NoError(t, err) + require.Contains(t, result, listID) +} + +func TestSelectListOrganizationsDependencyNoMatch(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Create a rule that does NOT depend on organizations + ruleID, err := db.CreateRule(ctx, Rule{ + ProjectID: projectID, + Rule: store.JSONB[rules.RuleSet]{Data: rules.RuleSet{}}, + DependsOnOrganizations: false, + DependsOnUsers: true, + Version: 1, + }) + require.NoError(t, err) + + // Create a list using this rule + listID, err := db.CreateList(ctx, List{ + ProjectID: projectID, + RuleID: &ruleID, + Name: "User Dependent List", + }) + require.NoError(t, err) + + // Should NOT find the list as an organization dependency + result, err := db.SelectListOrganizationsDependency(ctx, projectID) + require.NoError(t, err) + require.NotContains(t, result, listID) +} + +func TestSelectListOrganizationUsersDependency(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Create a rule that depends on organization users + ruleID, err := db.CreateRule(ctx, Rule{ + ProjectID: projectID, + Rule: store.JSONB[rules.RuleSet]{Data: rules.RuleSet{}}, + DependsOnOrganizationUsers: true, + Version: 1, + }) + require.NoError(t, err) + + // Create a list using this rule + listID, err := db.CreateList(ctx, List{ + ProjectID: projectID, + RuleID: &ruleID, + Name: "Org User Dependent List", + }) + require.NoError(t, err) + + // Should find the list as a dependency + result, err := db.SelectListOrganizationUsersDependency(ctx, projectID) + require.NoError(t, err) + require.Contains(t, result, listID) +} + +func TestSelectListOrganizationUsersDependencyNoMatch(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Create a rule that does NOT depend on organization users + ruleID, err := db.CreateRule(ctx, Rule{ + ProjectID: projectID, + Rule: store.JSONB[rules.RuleSet]{Data: rules.RuleSet{}}, + DependsOnOrganizationUsers: false, + DependsOnOrganizations: true, + Version: 1, + }) + require.NoError(t, err) + + // Create a list using this rule + listID, err := db.CreateList(ctx, List{ + ProjectID: projectID, + RuleID: &ruleID, + Name: "Org Dependent List", + }) + require.NoError(t, err) + + // Should NOT find the list as an organization user dependency + result, err := db.SelectListOrganizationUsersDependency(ctx, projectID) + require.NoError(t, err) + require.NotContains(t, result, listID) +} + +func TestLookupOrganizationID(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + externalID := "lookup_org_external_123" + + // Create an organization + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: externalID, + Name: ptr("Lookup Test Organization"), + }) + require.NoError(t, err) + + // Lookup the organization ID by external ID + foundID, err := db.LookupOrganizationID(ctx, projectID, externalID) + require.NoError(t, err) + require.Equal(t, orgID, foundID) +} + +func TestLookupOrganizationIDNotFound(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Lookup a non-existent organization + _, err := db.LookupOrganizationID(ctx, projectID, "non_existent_org") + require.Error(t, err, "should return error when organization not found") +} + +func TestInsertOrganizationEvent(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Create an organization + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: "org_event_test", + Name: ptr("Event Test Organization"), + }) + require.NoError(t, err) + + // Create an event + eventID, err := db.UpsertEvent(ctx, projectID, "subscription.upgraded") + require.NoError(t, err) + + // Insert organization event with data + eventData := map[string]any{ + "plan": "enterprise", + "seats": 100, + "features": []string{"sso", "audit_logs"}, + } + orgEventID, err := db.InsertOrganizationEvent(ctx, orgID, eventID, eventData) + require.NoError(t, err) + require.NotEqual(t, uuid.Nil, orgEventID) +} + +func TestInsertOrganizationEventWithNilData(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Create an organization + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: "org_event_nil_data", + }) + require.NoError(t, err) + + // Create an event + eventID, err := db.UpsertEvent(ctx, projectID, "org.created") + require.NoError(t, err) + + // Insert organization event with nil data + orgEventID, err := db.InsertOrganizationEvent(ctx, orgID, eventID, nil) + require.NoError(t, err) + require.NotEqual(t, uuid.Nil, orgEventID) +} + +func TestInsertMultipleOrganizationEvents(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Create an organization + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: "org_multi_events", + }) + require.NoError(t, err) + + // Create an event + eventID, err := db.UpsertEvent(ctx, projectID, "user.joined") + require.NoError(t, err) + + // Insert multiple events for the same organization + eventIDs := make([]uuid.UUID, 3) + for i := 0; i < 3; i++ { + eventIDs[i], err = db.InsertOrganizationEvent(ctx, orgID, eventID, map[string]any{ + "user_number": i + 1, + }) + require.NoError(t, err) + } + + // All event IDs should be unique + uniqueIDs := make(map[uuid.UUID]bool) + for _, id := range eventIDs { + require.False(t, uniqueIDs[id], "event IDs should be unique") + uniqueIDs[id] = true + } +} + +func TestListOrganizationUserIDs(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Create an organization + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: "org_user_ids", + }) + require.NoError(t, err) + + // Initially should return empty list + userIDs, err := db.ListOrganizationUserIDs(ctx, orgID) + require.NoError(t, err) + require.Empty(t, userIDs) + + // Create users and add them to the organization + expectedUserIDs := make([]uuid.UUID, 3) + for i := 0; i < 3; i++ { + userID, err := db.CreateUser(ctx, User{ + ProjectID: projectID, + AnonymousID: ptr(uuid.New().String()), + Data: json.RawMessage(`{}`), + }) + require.NoError(t, err) + expectedUserIDs[i] = userID + + err = db.UpsertOrganizationMember(ctx, orgID, userID, nil) + require.NoError(t, err) + } + + // Now should return all user IDs + userIDs, err = db.ListOrganizationUserIDs(ctx, orgID) + require.NoError(t, err) + require.Len(t, userIDs, 3) + + // Verify all expected user IDs are present + userIDSet := make(map[uuid.UUID]bool) + for _, id := range userIDs { + userIDSet[id] = true + } + for _, expectedID := range expectedUserIDs { + require.True(t, userIDSet[expectedID], "expected user ID should be in result") + } +} + +func TestListOrganizationUserIDsEmpty(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + // Create an organization with no members + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: "org_empty_users", + }) + require.NoError(t, err) + + // Should return empty list, not error + userIDs, err := db.ListOrganizationUserIDs(ctx, orgID) + require.NoError(t, err) + require.Empty(t, userIDs) +} diff --git a/internal/store/subjects/rules.go b/internal/store/subjects/rules.go index 458d148a..fdcd3703 100644 --- a/internal/store/subjects/rules.go +++ b/internal/store/subjects/rules.go @@ -10,15 +10,17 @@ import ( ) type Rule struct { - ID uuid.UUID `db:"id"` - ProjectID uuid.UUID `db:"project_id"` - Rule store.JSONB[rules.RuleSet] `db:"rule"` - DependsOnEvents bool `db:"depends_on_events"` - DependsOnUsers bool `db:"depends_on_users"` - Events []uuid.UUID `db:"events"` - Version int `db:"version"` - CreatedAt time.Time `db:"created_at"` - UpdatedAt time.Time `db:"updated_at"` + ID uuid.UUID `db:"id"` + ProjectID uuid.UUID `db:"project_id"` + Rule store.JSONB[rules.RuleSet] `db:"rule"` + DependsOnEvents bool `db:"depends_on_events"` + DependsOnUsers bool `db:"depends_on_users"` + DependsOnOrganizations bool `db:"depends_on_organizations"` + DependsOnOrganizationUsers bool `db:"depends_on_organization_users"` + Events []uuid.UUID `db:"events"` + Version int `db:"version"` + CreatedAt time.Time `db:"created_at"` + UpdatedAt time.Time `db:"updated_at"` } func NewRulesStore(db store.DB) *RulesStore { @@ -34,31 +36,35 @@ type RulesStore struct { func (s *RulesStore) CreateOrUpdateRule(ctx context.Context, projectID uuid.UUID, id *uuid.UUID, rule rules.RuleSet) (uuid.UUID, error) { if id != nil { err := s.UpdateRule(ctx, projectID, *id, RuleUpdate{ - Rule: &store.JSONB[rules.RuleSet]{Data: rule}, - DependsOnEvents: rule.DependsOnEvents(), - DependsOnUsers: rule.DependsOnUsers(), + Rule: &store.JSONB[rules.RuleSet]{Data: rule}, + DependsOnEvents: rule.DependsOnEvents(), + DependsOnUsers: rule.DependsOnUsers(), + DependsOnOrganizations: rule.DependsOnOrganizations(), + DependsOnOrganizationUsers: rule.DependsOnOrganizationUsers(), }) return *id, err } return s.CreateRule(ctx, Rule{ - ProjectID: projectID, - Rule: store.JSONB[rules.RuleSet]{Data: rule}, - DependsOnEvents: rule.DependsOnEvents(), - DependsOnUsers: rule.DependsOnUsers(), - Version: 1, + ProjectID: projectID, + Rule: store.JSONB[rules.RuleSet]{Data: rule}, + DependsOnEvents: rule.DependsOnEvents(), + DependsOnUsers: rule.DependsOnUsers(), + DependsOnOrganizations: rule.DependsOnOrganizations(), + DependsOnOrganizationUsers: rule.DependsOnOrganizationUsers(), + Version: 1, }) } func (s *RulesStore) CreateRule(ctx context.Context, rule Rule) (uuid.UUID, error) { stmt := ` - INSERT INTO rules (project_id, rule, depends_on_events, depends_on_users, version) - VALUES ($1, $2, $3, $4, $5) + INSERT INTO rules (project_id, rule, depends_on_events, depends_on_users, depends_on_organizations, depends_on_organization_users, version) + VALUES ($1, $2, $3, $4, $5, $6, $7) RETURNING id` var id uuid.UUID - err := s.db.GetContext(ctx, &id, stmt, rule.ProjectID, rule.Rule, rule.DependsOnEvents, rule.DependsOnUsers, rule.Version) + err := s.db.GetContext(ctx, &id, stmt, rule.ProjectID, rule.Rule, rule.DependsOnEvents, rule.DependsOnUsers, rule.DependsOnOrganizations, rule.DependsOnOrganizationUsers, rule.Version) if err != nil { return uuid.Nil, err } @@ -96,6 +102,8 @@ func (s *RulesStore) GetRule(ctx context.Context, projectID, ruleID uuid.UUID) ( r.rule, r.depends_on_events, r.depends_on_users, + r.depends_on_organizations, + r.depends_on_organization_users, COALESCE( ( SELECT array_agg(re.event_id) @@ -121,9 +129,11 @@ func (s *RulesStore) GetRule(ctx context.Context, projectID, ruleID uuid.UUID) ( } type RuleUpdate struct { - Rule *store.JSONB[rules.RuleSet] - DependsOnEvents bool - DependsOnUsers bool + Rule *store.JSONB[rules.RuleSet] + DependsOnEvents bool + DependsOnUsers bool + DependsOnOrganizations bool + DependsOnOrganizationUsers bool } func (s *RulesStore) UpdateRule(ctx context.Context, projectID, id uuid.UUID, update RuleUpdate) error { @@ -132,11 +142,13 @@ func (s *RulesStore) UpdateRule(ctx context.Context, projectID, id uuid.UUID, up SET rule = COALESCE($3, rule), depends_on_events = $4, - depends_on_users = $5 + depends_on_users = $5, + depends_on_organizations = $6, + depends_on_organization_users = $7 WHERE project_id = $1 AND id = $2` - _, err := s.db.ExecContext(ctx, query, projectID, id, update.Rule, update.DependsOnEvents, update.DependsOnUsers) + _, err := s.db.ExecContext(ctx, query, projectID, id, update.Rule, update.DependsOnEvents, update.DependsOnUsers, update.DependsOnOrganizations, update.DependsOnOrganizationUsers) return err } From 527d63aa5a47ad5cc41e4aad16b82081b6843367 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Sun, 22 Feb 2026 14:41:58 +0100 Subject: [PATCH 008/230] Update event subject path expectation after breaking change --- internal/journeys/event_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/journeys/event_test.go b/internal/journeys/event_test.go index 82ac5ead..8e461f4d 100644 --- a/internal/journeys/event_test.go +++ b/internal/journeys/event_test.go @@ -186,7 +186,7 @@ func TestHandleEvent(t *testing.T) { // Verify event structure event := mockPub.publishedEvents[0] - assert.Equal(t, schemas.Subject("events.process."+projectID.String()), event.subject) + assert.Equal(t, schemas.Subject("users.events.process."+projectID.String()), event.subject) eventData, ok := event.data.(schemas.UserEvent) require.True(t, ok, "event data should be schemas.UserEvent type") From 098c92522ab2b622bc5e7c1370c89e70dfb05af8 Mon Sep 17 00:00:00 2001 From: Jeroen Rinzema Date: Sun, 22 Feb 2026 18:57:43 +0100 Subject: [PATCH 009/230] feat: merge excluded data on update --- internal/store/subjects/organizations.go | 2 +- internal/store/subjects/organizations_test.go | 54 +++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/internal/store/subjects/organizations.go b/internal/store/subjects/organizations.go index 24bab6d7..e45f2ea0 100644 --- a/internal/store/subjects/organizations.go +++ b/internal/store/subjects/organizations.go @@ -81,7 +81,7 @@ func (s *OrganizationsStore) UpsertOrganization(ctx context.Context, projectID u ON CONFLICT (project_id, external_id) DO UPDATE SET name = COALESCE(EXCLUDED.name, organizations.name), - data = COALESCE(EXCLUDED.data, organizations.data) + data = organizations.data || EXCLUDED.data RETURNING id` var id uuid.UUID diff --git a/internal/store/subjects/organizations_test.go b/internal/store/subjects/organizations_test.go index 83fc9af7..739531dd 100644 --- a/internal/store/subjects/organizations_test.go +++ b/internal/store/subjects/organizations_test.go @@ -187,6 +187,60 @@ func TestUpdateOrganizationWithDataMerge(t *testing.T) { require.NotNil(t, orgData["feature_flags"]) } +func TestUpsertOrganizationDataMergeOnConflict(t *testing.T) { + t.Parallel() + + db := NewContainerStore(t) + projectID := uuid.New() + ctx := context.Background() + + orgID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: "org_upsert_merge", + Name: ptr("Original Name"), + Data: map[string]any{"plan": "free", "seats": 10}, + }) + require.NoError(t, err) + + t.Run("preserves data when upserting with nil data", func(t *testing.T) { + upsertedID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: "org_upsert_merge", + Name: ptr("Updated Name"), + Data: nil, + }) + require.NoError(t, err) + require.Equal(t, orgID, upsertedID) + + org, err := db.GetOrganization(ctx, projectID, orgID) + require.NoError(t, err) + require.Equal(t, ptr("Updated Name"), org.Name) + + var orgData map[string]any + err = json.Unmarshal(org.Data, &orgData) + require.NoError(t, err) + require.Equal(t, "free", orgData["plan"], "existing data should be preserved") + require.Equal(t, float64(10), orgData["seats"], "existing data should be preserved") + }) + + t.Run("merges data when upserting with new data", func(t *testing.T) { + upsertedID, err := db.UpsertOrganization(ctx, projectID, UpsertOrganizationParams{ + ExternalID: "org_upsert_merge", + Data: map[string]any{"seats": 50, "feature": "beta"}, + }) + require.NoError(t, err) + require.Equal(t, orgID, upsertedID) + + org, err := db.GetOrganization(ctx, projectID, orgID) + require.NoError(t, err) + + var orgData map[string]any + err = json.Unmarshal(org.Data, &orgData) + require.NoError(t, err) + require.Equal(t, "free", orgData["plan"], "original key should be preserved") + require.Equal(t, float64(50), orgData["seats"], "updated key should be changed") + require.Equal(t, "beta", orgData["feature"], "new key should be added") + }) +} + func TestDeleteOrganization(t *testing.T) { t.Parallel() From e9a4a8717723d129c384ebea0b2c4acb8b9d8814 Mon Sep 17 00:00:00 2001 From: Jeroen Rinzema Date: Sun, 22 Feb 2026 19:04:18 +0100 Subject: [PATCH 010/230] fix: prevent silent data loss in organization rule query building --- internal/rules/query/query_test.go | 245 ++++++++++++++++++++++++ internal/rules/query/rule.go | 88 ++++++++- internal/rules/rules_test.go | 296 +++++++++++++++++++++++++++++ 3 files changed, 622 insertions(+), 7 deletions(-) diff --git a/internal/rules/query/query_test.go b/internal/rules/query/query_test.go index 55868230..5c3a1353 100644 --- a/internal/rules/query/query_test.go +++ b/internal/rules/query/query_test.go @@ -1334,6 +1334,251 @@ func TestQueryBuilderOrganizationRules(t *testing.T) { wantArgs: []any{testProjectID, testProjectID}, wantErr: false, }, + "user OR organization - should error": { + name: "user OR organization - should error", + ruleSet: rules.RuleSet{ + Rule: rules.Rule{ + Type: rules.RuleTypeWrapper, + Group: rules.RuleGroupParent, + Operator: rules.OperatorOr, + Children: []rules.Rule{ + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupUser, + Path: ".email", + Operator: rules.OperatorEndsWith, + Value: "@admin.com", + }, + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganization, + Path: ".data.tier", + Operator: rules.OperatorEquals, + Value: "gold", + }, + }, + }, + }, + wantSQL: "", + wantArgs: nil, + wantErr: true, + }, + "user OR organization_user - should error": { + name: "user OR organization_user - should error", + ruleSet: rules.RuleSet{ + Rule: rules.Rule{ + Type: rules.RuleTypeWrapper, + Group: rules.RuleGroupParent, + Operator: rules.OperatorOr, + Children: []rules.Rule{ + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupUser, + Path: ".email", + Operator: rules.OperatorEndsWith, + Value: "@admin.com", + }, + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganizationUser, + Path: ".data.role", + Operator: rules.OperatorEquals, + Value: "admin", + }, + }, + }, + }, + wantSQL: "", + wantArgs: nil, + wantErr: true, + }, + "nested user OR organization - should error": { + name: "nested user OR organization - should error", + ruleSet: rules.RuleSet{ + Rule: rules.Rule{ + Type: rules.RuleTypeWrapper, + Group: rules.RuleGroupParent, + Operator: rules.OperatorAnd, + Children: []rules.Rule{ + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupUser, + Path: ".name", + Operator: rules.OperatorEquals, + Value: "John", + }, + { + Type: rules.RuleTypeWrapper, + Group: rules.RuleGroupParent, + Operator: rules.OperatorOr, + Children: []rules.Rule{ + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupUser, + Path: ".email", + Operator: rules.OperatorEndsWith, + Value: "@vip.com", + }, + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganization, + Path: ".data.tier", + Operator: rules.OperatorEquals, + Value: "enterprise", + }, + }, + }, + }, + }, + }, + wantSQL: "", + wantArgs: nil, + wantErr: true, + }, + "deeply nested wrapper in OR - should error": { + name: "deeply nested wrapper in OR - should error", + ruleSet: rules.RuleSet{ + Rule: rules.Rule{ + Type: rules.RuleTypeWrapper, + Group: rules.RuleGroupParent, + Operator: rules.OperatorOr, + Children: []rules.Rule{ + { + Type: rules.RuleTypeWrapper, + Group: rules.RuleGroupParent, + Operator: rules.OperatorAnd, + Children: []rules.Rule{ + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupUser, + Path: ".email", + Operator: rules.OperatorContains, + Value: "test", + }, + }, + }, + { + Type: rules.RuleTypeWrapper, + Group: rules.RuleGroupParent, + Operator: rules.OperatorAnd, + Children: []rules.Rule{ + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganization, + Path: ".data.tier", + Operator: rules.OperatorEquals, + Value: "gold", + }, + }, + }, + }, + }, + }, + wantSQL: "", + wantArgs: nil, + wantErr: true, + }, + "organization OR organization_user - should work": { + name: "organization OR organization_user - should work", + ruleSet: rules.RuleSet{ + Rule: rules.Rule{ + Type: rules.RuleTypeWrapper, + Group: rules.RuleGroupParent, + Operator: rules.OperatorOr, + Children: []rules.Rule{ + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganization, + Path: ".data.tier", + Operator: rules.OperatorEquals, + Value: "gold", + }, + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganizationUser, + Path: ".data.role", + Operator: rules.OperatorEquals, + Value: "admin", + }, + }, + }, + }, + wantSQL: "SELECT u.id FROM users u JOIN (SELECT DISTINCT ou.user_id FROM organization_users ou JOIN organizations o ON o.id = ou.organization_id WHERE o.project_id = $3 AND ((o.data->>'tier')::text = $1 OR (ou.data->>'role')::text = $2)) e1 ON e1.user_id = u.id WHERE u.project_id = $4", + wantArgs: []any{"gold", "admin", testProjectID, testProjectID}, + wantErr: false, + }, + "user OR user - should work": { + name: "user OR user - should work", + ruleSet: rules.RuleSet{ + Rule: rules.Rule{ + Type: rules.RuleTypeWrapper, + Group: rules.RuleGroupParent, + Operator: rules.OperatorOr, + Children: []rules.Rule{ + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupUser, + Path: ".email", + Operator: rules.OperatorEndsWith, + Value: "@admin.com", + }, + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupUser, + Path: ".data.role", + Operator: rules.OperatorEquals, + Value: "superuser", + }, + }, + }, + }, + wantSQL: "SELECT u.id FROM users u WHERE u.project_id = $3 AND (u.email ILIKE $1 OR (u.data->>'role')::text = $2)", + wantArgs: []any{"%@admin.com", "superuser", testProjectID}, + wantErr: false, + }, + "nested org wrapper with parent - falls through to buildWrapper": { + name: "nested org wrapper with parent - falls through to buildWrapper", + ruleSet: rules.RuleSet{ + Rule: rules.Rule{ + Type: rules.RuleTypeWrapper, + Group: rules.RuleGroupParent, + Operator: rules.OperatorAnd, + Children: []rules.Rule{ + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganization, + Path: ".data.tier", + Operator: rules.OperatorEquals, + Value: "gold", + }, + { + Type: rules.RuleTypeWrapper, + Group: rules.RuleGroupParent, + Operator: rules.OperatorOr, + Children: []rules.Rule{ + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganizationUser, + Path: ".data.role", + Operator: rules.OperatorEquals, + Value: "admin", + }, + { + Type: rules.RuleTypeString, + Group: rules.RuleGroupOrganizationUser, + Path: ".data.role", + Operator: rules.OperatorEquals, + Value: "owner", + }, + }, + }, + }, + }, + }, + wantSQL: "SELECT u.id FROM users u JOIN (SELECT DISTINCT ou.user_id FROM organization_users ou JOIN organizations o ON o.id = ou.organization_id WHERE o.project_id = $2 AND (o.data->>'tier')::text = $1) e1 ON e1.user_id = u.id JOIN (SELECT DISTINCT ou.user_id FROM organization_users ou JOIN organizations o ON o.id = ou.organization_id WHERE o.project_id = $5 AND ((ou.data->>'role')::text = $3 OR (ou.data->>'role')::text = $4)) e2 ON e2.user_id = u.id WHERE u.project_id = $6", + wantArgs: []any{"gold", testProjectID, "admin", "owner", testProjectID, testProjectID}, + wantErr: false, + }, } for name, tc := range tests { diff --git a/internal/rules/query/rule.go b/internal/rules/query/rule.go index 8b85d652..6f776383 100644 --- a/internal/rules/query/rule.go +++ b/internal/rules/query/rule.go @@ -9,6 +9,10 @@ import ( "github.com/lunogram/platform/internal/rules" ) +// ErrUnsupportedOrWithJoins is returned when OR is used with a mix of join-producing +// rules (organization, organization_user) and condition-producing rules (user). +var ErrUnsupportedOrWithJoins = errors.New("OR operator is not supported when combining organization rules with user rules; use AND or restructure the query") + // pathSegmentRegex matches path segments: // .field - dot notation // ['field'] - bracket with single quotes @@ -49,23 +53,88 @@ func (qb *QueryBuilder) buildRule(rule *rules.Rule) (string, error) { } // isOrganizationWrapper checks if a wrapper rule contains only organization-related rules -// (RuleGroupOrganization and/or RuleGroupOrganizationUser) +// (RuleGroupOrganization and/or RuleGroupOrganizationUser). Nested wrappers (RuleGroupParent) +// are not allowed here - they should be handled by buildWrapper which recurses properly. func (qb *QueryBuilder) isOrganizationWrapper(rule *rules.Rule) bool { if !rule.HasChildren() { return false } - hasOrgRules := false for _, child := range rule.Children { - if child.Group == rules.RuleGroupOrganization || child.Group == rules.RuleGroupOrganizationUser { - hasOrgRules = true - } else if child.Group != rules.RuleGroupParent { - // If there's a non-organization, non-parent rule, this is not a pure org wrapper + if child.Group != rules.RuleGroupOrganization && child.Group != rules.RuleGroupOrganizationUser { + // If there's any non-organization rule (including nested wrappers), this is not a pure org wrapper return false } } - return hasOrgRules + return true +} + +// producesJoin returns true if the rule group produces a JOIN rather than a WHERE condition. +// Organization and OrganizationUser rules use JOINs for filtering. +func (qb *QueryBuilder) producesJoin(group rules.RuleGroup) bool { + return group == rules.RuleGroupOrganization || group == rules.RuleGroupOrganizationUser +} + +// checkOrWithMixedRules validates that OR wrappers don't mix join-producing rules with +// condition-producing rules, as this would produce incorrect AND semantics. +func (qb *QueryBuilder) checkOrWithMixedRules(rule *rules.Rule) error { + if rule.Operator != rules.OperatorOr || !rule.HasChildren() { + return nil + } + + hasJoinRule := false + hasConditionRule := false + + for i := range rule.Children { + child := &rule.Children[i] + + // For nested wrappers, we need to check what they contain + if child.IsWrapper() && child.Group == rules.RuleGroupParent { + // Recursively check if the wrapper contains join or condition rules + containsJoin, containsCondition := qb.analyzeWrapperContents(child) + if containsJoin { + hasJoinRule = true + } + if containsCondition { + hasConditionRule = true + } + } else if qb.producesJoin(child.Group) { + hasJoinRule = true + } else { + hasConditionRule = true + } + + if hasJoinRule && hasConditionRule { + return ErrUnsupportedOrWithJoins + } + } + + return nil +} + +// analyzeWrapperContents recursively checks if a wrapper contains join-producing +// and/or condition-producing rules. +func (qb *QueryBuilder) analyzeWrapperContents(rule *rules.Rule) (containsJoin, containsCondition bool) { + for i := range rule.Children { + child := &rule.Children[i] + + if child.IsWrapper() && child.Group == rules.RuleGroupParent { + cj, cc := qb.analyzeWrapperContents(child) + if cj { + containsJoin = true + } + if cc { + containsCondition = true + } + } else if qb.producesJoin(child.Group) { + containsJoin = true + } else { + containsCondition = true + } + } + + return containsJoin, containsCondition } // buildWrapper builds SQL for wrapper nodes with logical operators @@ -74,6 +143,11 @@ func (qb *QueryBuilder) buildWrapper(rule *rules.Rule) (string, error) { return "", nil } + // Check for unsupported OR with mixed join/condition rules + if err := qb.checkOrWithMixedRules(rule); err != nil { + return "", err + } + conditions := make([]string, 0, len(rule.Children)) for i := range rule.Children { diff --git a/internal/rules/rules_test.go b/internal/rules/rules_test.go index 4f461b04..0b3068fc 100644 --- a/internal/rules/rules_test.go +++ b/internal/rules/rules_test.go @@ -438,6 +438,302 @@ func TestRuleIsRoot(t *testing.T) { } } +func TestRuleDependsOnOrganizations(t *testing.T) { + t.Parallel() + + type test struct { + rule Rule + expected bool + } + + tests := map[string]test{ + "single organization rule": { + rule: Rule{ + Type: RuleTypeString, + Group: RuleGroupOrganization, + Path: ".data.tier", + Operator: OperatorEquals, + Value: "gold", + }, + expected: true, + }, + "nested with organization rule": { + rule: Rule{ + Type: RuleTypeWrapper, + Group: RuleGroupParent, + Operator: OperatorAnd, + Children: []Rule{ + { + Type: RuleTypeString, + Group: RuleGroupUser, + Path: "email", + Operator: OperatorContains, + Value: "test", + }, + { + Type: RuleTypeString, + Group: RuleGroupOrganization, + Path: ".name", + Operator: OperatorEquals, + Value: "Acme", + }, + }, + }, + expected: true, + }, + "deeply nested with organization rule": { + rule: Rule{ + Type: RuleTypeWrapper, + Group: RuleGroupParent, + Operator: OperatorAnd, + Children: []Rule{ + { + Type: RuleTypeString, + Group: RuleGroupUser, + Path: "name", + Operator: OperatorEquals, + Value: "John", + }, + { + Type: RuleTypeWrapper, + Group: RuleGroupParent, + Operator: OperatorOr, + Children: []Rule{ + { + Type: RuleTypeNumber, + Group: RuleGroupUser, + Path: "age", + Operator: OperatorLessThan, + Value: 30, + }, + { + Type: RuleTypeString, + Group: RuleGroupOrganization, + Path: ".data.plan", + Operator: OperatorEquals, + Value: "enterprise", + }, + }, + }, + }, + }, + expected: true, + }, + "only user rules": { + rule: Rule{ + Type: RuleTypeWrapper, + Group: RuleGroupParent, + Operator: OperatorAnd, + Children: []Rule{ + { + Type: RuleTypeString, + Group: RuleGroupUser, + Path: "email", + Operator: OperatorContains, + Value: "example.com", + }, + { + Type: RuleTypeBoolean, + Group: RuleGroupUser, + Path: "data.verified", + Operator: OperatorEquals, + Value: true, + }, + }, + }, + expected: false, + }, + "only organization user rules": { + rule: Rule{ + Type: RuleTypeWrapper, + Group: RuleGroupParent, + Operator: OperatorAnd, + Children: []Rule{ + { + Type: RuleTypeString, + Group: RuleGroupOrganizationUser, + Path: ".data.role", + Operator: OperatorEquals, + Value: "admin", + }, + }, + }, + expected: false, + }, + "empty rule": { + rule: Rule{}, + expected: false, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + result := test.rule.DependsOnOrganizations() + assert.Equal(t, test.expected, result) + }) + } +} + +func TestRuleDependsOnOrganizationUsers(t *testing.T) { + t.Parallel() + + type test struct { + rule Rule + expected bool + } + + tests := map[string]test{ + "single organization user rule": { + rule: Rule{ + Type: RuleTypeString, + Group: RuleGroupOrganizationUser, + Path: ".data.role", + Operator: OperatorEquals, + Value: "admin", + }, + expected: true, + }, + "nested with organization user rule": { + rule: Rule{ + Type: RuleTypeWrapper, + Group: RuleGroupParent, + Operator: OperatorAnd, + Children: []Rule{ + { + Type: RuleTypeString, + Group: RuleGroupUser, + Path: "email", + Operator: OperatorContains, + Value: "test", + }, + { + Type: RuleTypeString, + Group: RuleGroupOrganizationUser, + Path: ".data.role", + Operator: OperatorEquals, + Value: "member", + }, + }, + }, + expected: true, + }, + "deeply nested with organization user rule": { + rule: Rule{ + Type: RuleTypeWrapper, + Group: RuleGroupParent, + Operator: OperatorAnd, + Children: []Rule{ + { + Type: RuleTypeString, + Group: RuleGroupUser, + Path: "name", + Operator: OperatorEquals, + Value: "John", + }, + { + Type: RuleTypeWrapper, + Group: RuleGroupParent, + Operator: OperatorOr, + Children: []Rule{ + { + Type: RuleTypeNumber, + Group: RuleGroupUser, + Path: "age", + Operator: OperatorLessThan, + Value: 30, + }, + { + Type: RuleTypeString, + Group: RuleGroupOrganizationUser, + Path: ".data.permissions", + Operator: OperatorContains, + Value: "write", + }, + }, + }, + }, + }, + expected: true, + }, + "only user rules": { + rule: Rule{ + Type: RuleTypeWrapper, + Group: RuleGroupParent, + Operator: OperatorAnd, + Children: []Rule{ + { + Type: RuleTypeString, + Group: RuleGroupUser, + Path: "email", + Operator: OperatorContains, + Value: "example.com", + }, + { + Type: RuleTypeBoolean, + Group: RuleGroupUser, + Path: "data.verified", + Operator: OperatorEquals, + Value: true, + }, + }, + }, + expected: false, + }, + "only organization rules": { + rule: Rule{ + Type: RuleTypeWrapper, + Group: RuleGroupParent, + Operator: OperatorAnd, + Children: []Rule{ + { + Type: RuleTypeString, + Group: RuleGroupOrganization, + Path: ".data.tier", + Operator: OperatorEquals, + Value: "gold", + }, + }, + }, + expected: false, + }, + "mixed organization and organization user": { + rule: Rule{ + Type: RuleTypeWrapper, + Group: RuleGroupParent, + Operator: OperatorAnd, + Children: []Rule{ + { + Type: RuleTypeString, + Group: RuleGroupOrganization, + Path: ".data.tier", + Operator: OperatorEquals, + Value: "gold", + }, + { + Type: RuleTypeString, + Group: RuleGroupOrganizationUser, + Path: ".data.role", + Operator: OperatorEquals, + Value: "admin", + }, + }, + }, + expected: true, + }, + "empty rule": { + rule: Rule{}, + expected: false, + }, + } + + for name, test := range tests { + t.Run(name, func(t *testing.T) { + result := test.rule.DependsOnOrganizationUsers() + assert.Equal(t, test.expected, result) + }) + } +} + func TestRuleTypeSQL(t *testing.T) { t.Parallel() From c50b6766958829ab899e529eb073b29492976dd5 Mon Sep 17 00:00:00 2001 From: Jeroen Rinzema Date: Sun, 22 Feb 2026 22:42:39 +0100 Subject: [PATCH 011/230] feat: improved user rule scanning --- .../v1/management/oapi/journeys.go | 1 + .../v1/management/oapi/resources.yml | 5 ++ .../pubsub/consumer/organization_events.go | 62 +++++++++++++------ internal/store/subjects/organizations.go | 38 +++++++++++- 4 files changed, 85 insertions(+), 21 deletions(-) diff --git a/internal/http/controllers/v1/management/oapi/journeys.go b/internal/http/controllers/v1/management/oapi/journeys.go index abe4df49..346093e7 100644 --- a/internal/http/controllers/v1/management/oapi/journeys.go +++ b/internal/http/controllers/v1/management/oapi/journeys.go @@ -39,6 +39,7 @@ type EntranceStepData struct { ListId *string `json:"list_id,omitempty"` Schedule *string `json:"schedule,omitempty"` Rule *rules.RuleSet `json:"rule,omitempty"` + UserRule *rules.RuleSet `json:"user_rule,omitempty"` Concurrent *bool `json:"concurrent,omitempty"` Multiple *bool `json:"multiple,omitempty"` } diff --git a/internal/http/controllers/v1/management/oapi/resources.yml b/internal/http/controllers/v1/management/oapi/resources.yml index 297be02b..4a5fb1b8 100644 --- a/internal/http/controllers/v1/management/oapi/resources.yml +++ b/internal/http/controllers/v1/management/oapi/resources.yml @@ -3224,6 +3224,11 @@ components: description: Rule for filtering events additionalProperties: true x-go-type: rules.RuleSet + user_rule: + type: object + description: Rule for filtering users (used with organization events) + additionalProperties: true + x-go-type: rules.RuleSet multiple: type: boolean description: Allow multiple entries diff --git a/internal/pubsub/consumer/organization_events.go b/internal/pubsub/consumer/organization_events.go index 68bb5438..9b7bbc16 100644 --- a/internal/pubsub/consumer/organization_events.go +++ b/internal/pubsub/consumer/organization_events.go @@ -6,6 +6,7 @@ import ( "time" "github.com/google/uuid" + "github.com/jmoiron/sqlx" "github.com/lunogram/platform/internal/http/controllers/v1/management/oapi" "github.com/lunogram/platform/internal/pubsub" "github.com/lunogram/platform/internal/pubsub/schemas" @@ -112,7 +113,9 @@ func PublishOrganizationEventListDependencies(ctx context.Context, logger *zap.L } // PublishOrganizationEventJourneyDependencies returns a function that triggers journey entrance steps -// for all users in the organization when an organization event matches a journey entrance condition. +// for users in the organization when an organization event matches a journey entrance condition. +// It evaluates entrance.Rule against event data in-memory, and uses entrance.UserRule to filter +// users in the database. Users are streamed to avoid loading all IDs into memory. func PublishOrganizationEventJourneyDependencies(ctx context.Context, logger *zap.Logger, usrs *subjects.State, jrny *journey.State, pub pubsub.Publisher, event schemas.OrganizationEvent) func() error { evaluator := eval.NewEvaluator() @@ -127,18 +130,6 @@ func PublishOrganizationEventJourneyDependencies(ctx context.Context, logger *za return nil } - // Get all users in the organization - userIDs, err := usrs.ListOrganizationUserIDs(ctx, event.OrganizationID) - if err != nil { - logger.Error("failed to list organization user IDs", zap.Error(err)) - return err - } - - if len(userIDs) == 0 { - logger.Info("no users in organization, skipping journey triggers", zap.Stringer("organization_id", event.OrganizationID)) - return nil - } - for _, dep := range deps { entrance := oapi.EntranceStepData{} if dep.Data != nil { @@ -148,6 +139,7 @@ func PublishOrganizationEventJourneyDependencies(ctx context.Context, logger *za } } + // Evaluate event conditions in-memory if entrance.Rule != nil { match, err := evaluator.Evaluate(*entrance.Rule, event.Data) if err != nil { @@ -160,10 +152,7 @@ func PublishOrganizationEventJourneyDependencies(ctx context.Context, logger *za } } - logger.Info("triggering journey entrance step for organization users", - zap.Stringer("journey_id", dep.JourneyID), - zap.Stringer("step_id", dep.StepID), - zap.Int("user_count", len(userIDs))) + logger.Info("triggering journey entrance step for organization users", zap.Stringer("journey_id", dep.JourneyID), zap.Stringer("step_id", dep.StepID)) data, err := json.Marshal(event.Data) if err != nil { @@ -171,10 +160,25 @@ func PublishOrganizationEventJourneyDependencies(ctx context.Context, logger *za return err } - // Trigger journey for each user in the organization - for _, userID := range userIDs { + // Query users - either filtered by UserRule or all users in the organization + rows, err := queryUsers(ctx, usrs, event.ProjectID, event.OrganizationID, entrance.UserRule) + if err != nil { + logger.Error("failed to query organization user IDs", zap.Error(err)) + return err + } + + total := 0 + for rows.Next() { + var userID uuid.UUID + if err := rows.Scan(&userID); err != nil { + rows.Close() + logger.Error("failed to scan user ID", zap.Error(err)) + return err + } + entry, err := uuid.NewRandom() if err != nil { + rows.Close() logger.Error("failed to generate journey entry ID", zap.Error(err)) return err } @@ -191,6 +195,7 @@ func PublishOrganizationEventJourneyDependencies(ctx context.Context, logger *za _, err = jrny.CreateUserJourneyState(ctx, result) if err != nil { + rows.Close() logger.Error("failed to create journey user state", zap.Error(err), zap.Stringer("user_id", userID)) return err } @@ -206,17 +211,36 @@ func PublishOrganizationEventJourneyDependencies(ctx context.Context, logger *za err = pub.Publish(ctx, schemas.JourneysAdvance(event.ProjectID, dep.JourneyID), step) if err != nil { + rows.Close() logger.Error("failed to publish journey state", zap.Error(err), zap.Stringer("user_id", userID)) return err } } + + total++ + } + + rows.Close() + if err := rows.Err(); err != nil { + logger.Error("error iterating organization users", zap.Error(err)) + return err } + + logger.Info("completed triggering journey entrance step", zap.Stringer("journey_id", dep.JourneyID), zap.Int("user_count", total)) } return nil } } +func queryUsers(ctx context.Context, usrs *subjects.State, projectID, organizationID uuid.UUID, userRule *rules.RuleSet) (*sqlx.Rows, error) { + if userRule != nil { + return usrs.QueryOrganizationUsersMatchingRule(ctx, projectID, organizationID, *userRule) + } + + return usrs.QueryOrganizationUserIDs(ctx, organizationID) +} + // OrganizationEventSchemasHandler creates a handler that extracts and stores organization event schema information. func OrganizationEventSchemasHandler(logger *zap.Logger, usrs *subjects.State) HandlerFunc { return func(ctx context.Context, msg jetstream.Msg) error { diff --git a/internal/store/subjects/organizations.go b/internal/store/subjects/organizations.go index c41d1a46..122070f8 100644 --- a/internal/store/subjects/organizations.go +++ b/internal/store/subjects/organizations.go @@ -3,11 +3,14 @@ package subjects import ( "context" "encoding/json" + "fmt" "time" "github.com/google/uuid" + "github.com/jmoiron/sqlx" "github.com/lib/pq" "github.com/lunogram/platform/internal/rules" + "github.com/lunogram/platform/internal/rules/query" "github.com/lunogram/platform/internal/store" ) @@ -412,16 +415,47 @@ func (s *OrganizationsStore) LookupOrganizationID(ctx context.Context, projectID // ListOrganizationUserIDs returns all user IDs belonging to an organization. func (s *OrganizationsStore) ListOrganizationUserIDs(ctx context.Context, orgID uuid.UUID) ([]uuid.UUID, error) { - query := ` + q := ` SELECT user_id FROM organization_users WHERE organization_id = $1` var ids []uuid.UUID - err := s.db.SelectContext(ctx, &ids, query, orgID) + err := s.db.SelectContext(ctx, &ids, q, orgID) if err != nil { return nil, err } return ids, nil } + +// QueryOrganizationUserIDs returns a cursor for iterating over user IDs in an organization. +// The caller is responsible for closing the rows. +func (s *OrganizationsStore) QueryOrganizationUserIDs(ctx context.Context, orgID uuid.UUID) (*sqlx.Rows, error) { + q := ` + SELECT user_id + FROM organization_users + WHERE organization_id = $1` + + return s.db.QueryxContext(ctx, q, orgID) +} + +// QueryOrganizationUsersMatchingRule returns a cursor for iterating over user IDs in an organization +// that match the given ruleset. The caller is responsible for closing the rows. +func (s *OrganizationsStore) QueryOrganizationUsersMatchingRule(ctx context.Context, projectID, orgID uuid.UUID, ruleset rules.RuleSet) (*sqlx.Rows, error) { + builder := query.NewQueryBuilder(projectID, nil) + result, err := builder.Query(ruleset) + if err != nil { + return nil, err + } + + // Wrap the ruleset query to filter only users in the specified organization + q := fmt.Sprintf(` + SELECT u.id AS user_id + FROM organization_users ou + JOIN (%s) u ON u.id = ou.user_id + WHERE ou.organization_id = $%d`, result.SQL, len(result.Args)+1) + + args := append(result.Args, orgID) + return s.db.QueryxContext(ctx, q, args...) +} From bcf3d44305dd5d8ecb86f151f1ce103aa65dd3bf Mon Sep 17 00:00:00 2001 From: Jeroen Rinzema Date: Sun, 22 Feb 2026 15:05:43 +0100 Subject: [PATCH 012/230] feat: include client and management organization endpoints --- internal/http/controllers/v1/client/client.go | 364 + .../controllers/v1/client/oapi/resources.yml | 236 + .../v1/client/oapi/resources_gen.go | 787 +- .../controllers/v1/management/controller.go | 32 +- .../v1/management/oapi/resources.yml | 677 +- .../v1/management/oapi/resources_gen.go | 13295 +++++++++------- .../v1/management/organizations.go | 10 +- .../v1/management/organizations_test.go | 34 +- .../v1/management/subject_organizations.go | 564 + .../http/controllers/v1/management/users.go | 47 + internal/store/management/organizations.go | 4 +- internal/store/subjects/organizations.go | 53 + 12 files changed, 10476 insertions(+), 5627 deletions(-) create mode 100644 internal/http/controllers/v1/management/subject_organizations.go diff --git a/internal/http/controllers/v1/client/client.go b/internal/http/controllers/v1/client/client.go index 238848c3..3f98b83d 100644 --- a/internal/http/controllers/v1/client/client.go +++ b/internal/http/controllers/v1/client/client.go @@ -1,6 +1,8 @@ package v1 import ( + "database/sql" + "errors" "net/http" "github.com/google/uuid" @@ -175,3 +177,365 @@ func (srv *ClientController) IdentifyUserClient(w http.ResponseWriter, r *http.R logger.Info("user identified successfully", zap.String("user_id", user.ID.String())) json.Write(w, http.StatusOK, user.OAPI()) } + +func (srv *ClientController) UpsertOrganizationClient(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + scope := rbac.FromContext(ctx) + if scope == nil { + srv.logger.Error("rbac scope not found in context") + oapi.WriteProblem(w, problem.ErrUnauthorized()) + return + } + + projectID := scope.ProjectID + if projectID == uuid.Nil { + srv.logger.Error("project_id is required") + oapi.WriteProblem(w, problem.ErrUnauthorized()) + return + } + + var req oapi.OrganizationRequest + err := json.Decode(r.Body, &req) + if err != nil { + srv.logger.Error("failed to decode request body", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrBadRequest(problem.Describe("invalid request body"))) + return + } + + logger := srv.logger.With( + zap.Stringer("project_id", projectID), + zap.String("external_id", req.ExternalId), + ) + logger.Info("upserting organization") + + var data map[string]any + if req.Data != nil { + data = *req.Data + } + + tx, err := srv.db.BeginTxx(ctx, nil) + if err != nil { + logger.Error("failed to begin transaction", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + defer tx.Rollback() //nolint:errcheck + orgsStore := subjects.NewOrganizationsStore(tx) + + params := subjects.UpsertOrganizationParams{ + ExternalID: req.ExternalId, + Name: req.Name, + Data: data, + } + + orgID, err := orgsStore.UpsertOrganization(ctx, projectID, params) + if err != nil { + logger.Error("failed to upsert organization", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + org, err := orgsStore.GetOrganization(ctx, projectID, orgID) + if err != nil { + logger.Error("failed to get organization after upsert", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + // Publish to pubsub for schema extraction + msg := schemas.Organization{ + ID: org.ID, + ProjectID: projectID, + ExternalID: org.ExternalID, + Name: org.Name, + Data: data, + Version: org.Version, + } + + err = srv.pubsub.Publish(ctx, schemas.OrganizationsProcess(projectID), msg) + if err != nil { + logger.Error("failed to publish organization", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + err = tx.Commit() + if err != nil { + logger.Error("failed to commit transaction", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + logger.Info("organization upserted", zap.String("organization_id", org.ID.String())) + json.Write(w, http.StatusOK, orgToClientOAPI(org)) +} + +func (srv *ClientController) AddOrganizationUserClient(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + scope := rbac.FromContext(ctx) + if scope == nil { + srv.logger.Error("rbac scope not found in context") + oapi.WriteProblem(w, problem.ErrUnauthorized()) + return + } + + projectID := scope.ProjectID + if projectID == uuid.Nil { + srv.logger.Error("project_id is required") + oapi.WriteProblem(w, problem.ErrUnauthorized()) + return + } + + var req oapi.OrganizationUserRequest + err := json.Decode(r.Body, &req) + if err != nil { + srv.logger.Error("failed to decode request body", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrBadRequest(problem.Describe("invalid request body"))) + return + } + + logger := srv.logger.With( + zap.Stringer("project_id", projectID), + zap.String("org_external_id", req.OrganizationExternalId), + zap.String("user_external_id", req.UserExternalId), + ) + logger.Info("adding user to organization") + + tx, err := srv.db.BeginTxx(ctx, nil) + if err != nil { + logger.Error("failed to begin transaction", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + defer tx.Rollback() //nolint:errcheck + orgsStore := subjects.NewOrganizationsStore(tx) + usersStore := subjects.NewUsersStore(tx) + + // Look up organization by external ID + orgID, err := orgsStore.LookupOrganizationID(ctx, projectID, req.OrganizationExternalId) + if errors.Is(err, sql.ErrNoRows) { + logger.Info("organization not found") + oapi.WriteProblem(w, problem.ErrNotFound(problem.Describe("organization not found"))) + return + } + if err != nil { + logger.Error("failed to lookup organization", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + // Look up user by external ID + userID, err := usersStore.LookupUserID(ctx, projectID, &req.UserExternalId, nil) + if errors.Is(err, sql.ErrNoRows) { + logger.Info("user not found") + oapi.WriteProblem(w, problem.ErrNotFound(problem.Describe("user not found"))) + return + } + if err != nil { + logger.Error("failed to lookup user", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + var data map[string]any + if req.Data != nil { + data = *req.Data + } + + err = orgsStore.UpsertOrganizationMember(ctx, orgID, userID, data) + if err != nil { + logger.Error("failed to add user to organization", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + // Publish to pubsub for schema extraction + msg := schemas.OrganizationUser{ + OrganizationID: orgID, + OrganizationExternalID: req.OrganizationExternalId, + UserID: userID, + ProjectID: projectID, + Data: data, + Version: 1, + } + + err = srv.pubsub.Publish(ctx, schemas.OrganizationUsersProcess(projectID), msg) + if err != nil { + logger.Error("failed to publish organization user", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + err = tx.Commit() + if err != nil { + logger.Error("failed to commit transaction", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + logger.Info("user added to organization") + w.WriteHeader(http.StatusOK) +} + +func (srv *ClientController) RemoveOrganizationUserClient(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + scope := rbac.FromContext(ctx) + if scope == nil { + srv.logger.Error("rbac scope not found in context") + oapi.WriteProblem(w, problem.ErrUnauthorized()) + return + } + + projectID := scope.ProjectID + if projectID == uuid.Nil { + srv.logger.Error("project_id is required") + oapi.WriteProblem(w, problem.ErrUnauthorized()) + return + } + + var req oapi.RemoveOrganizationUserRequest + err := json.Decode(r.Body, &req) + if err != nil { + srv.logger.Error("failed to decode request body", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrBadRequest(problem.Describe("invalid request body"))) + return + } + + logger := srv.logger.With( + zap.Stringer("project_id", projectID), + zap.String("org_external_id", req.OrganizationExternalId), + zap.String("user_external_id", req.UserExternalId), + ) + logger.Info("removing user from organization") + + // Look up organization by external ID + orgID, err := srv.users.LookupOrganizationID(ctx, projectID, req.OrganizationExternalId) + if errors.Is(err, sql.ErrNoRows) { + logger.Info("organization not found") + oapi.WriteProblem(w, problem.ErrNotFound(problem.Describe("organization not found"))) + return + } + if err != nil { + logger.Error("failed to lookup organization", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + // Look up user by external ID + userID, err := srv.users.LookupUserID(ctx, projectID, &req.UserExternalId, nil) + if errors.Is(err, sql.ErrNoRows) { + logger.Info("user not found") + oapi.WriteProblem(w, problem.ErrNotFound(problem.Describe("user not found"))) + return + } + if err != nil { + logger.Error("failed to lookup user", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + err = srv.users.RemoveUserFromOrganization(ctx, orgID, userID) + if err != nil { + logger.Error("failed to remove user from organization", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + logger.Info("user removed from organization") + w.WriteHeader(http.StatusNoContent) +} + +func (srv *ClientController) PostOrganizationEventsClient(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() + + scope := rbac.FromContext(ctx) + if scope == nil { + srv.logger.Error("rbac scope not found in context") + oapi.WriteProblem(w, problem.ErrUnauthorized()) + return + } + + projectID := scope.ProjectID + if projectID == uuid.Nil { + srv.logger.Error("project_id is required") + oapi.WriteProblem(w, problem.ErrUnauthorized()) + return + } + + var events oapi.PostOrganizationEventsRequest + err := json.Decode(r.Body, &events) + if err != nil { + srv.logger.Error("failed to decode request body", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrBadRequest(problem.Describe("invalid request body"))) + return + } + + logger := srv.logger.With(zap.Stringer("project_id", projectID), zap.Int("events", len(events))) + logger.Info("posting organization events") + + for _, event := range events { + // Look up organization by external ID + orgID, err := srv.users.LookupOrganizationID(ctx, projectID, event.OrganizationExternalId) + if errors.Is(err, sql.ErrNoRows) { + logger.Warn("organization not found, skipping event", + zap.String("org_external_id", event.OrganizationExternalId), + zap.String("event_name", event.Name)) + continue + } + if err != nil { + logger.Error("failed to lookup organization", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + var data map[string]any + if event.Data != nil { + data = *event.Data + } + + msg := schemas.OrganizationEvent{ + Name: event.Name, + ProjectID: projectID, + OrganizationID: orgID, + OrganizationExternalID: event.OrganizationExternalId, + Data: data, + } + + err = srv.pubsub.Publish(ctx, schemas.OrganizationEventsProcess(projectID), msg) + if err != nil { + logger.Error("failed to publish organization event", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + } + + logger.Info("organization events processed successfully") + w.WriteHeader(http.StatusAccepted) +} + +// orgToClientOAPI converts a subjects.Organization to client oapi.Organization +func orgToClientOAPI(org *subjects.Organization) oapi.Organization { + var data map[string]any + if org.Data != nil { + _ = json.Unmarshal(org.Data, &data) + } + if data == nil { + data = make(map[string]any) + } + + return oapi.Organization{ + Id: org.ID, + ProjectId: org.ProjectID, + ExternalId: org.ExternalID, + Name: org.Name, + Data: data, + Version: org.Version, + CreatedAt: org.CreatedAt, + UpdatedAt: org.UpdatedAt, + } +} diff --git a/internal/http/controllers/v1/client/oapi/resources.yml b/internal/http/controllers/v1/client/oapi/resources.yml index 8b55036d..b1dfc9fe 100644 --- a/internal/http/controllers/v1/client/oapi/resources.yml +++ b/internal/http/controllers/v1/client/oapi/resources.yml @@ -56,6 +56,105 @@ paths: default: $ref: '#/components/responses/Error' + /api/client/organizations: + post: + summary: Upsert organization + description: | + Used by client libraries to create or update an organization by external_id. + The project is determined from the API key. + operationId: upsertOrganizationClient + tags: + - Client + security: + - HttpBearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/OrganizationRequest' + responses: + '200': + description: Organization upserted successfully + content: + application/json: + schema: + $ref: '#/components/schemas/Organization' + default: + $ref: '#/components/responses/Error' + + /api/client/organizations/users: + post: + summary: Add user to organization + description: | + Used by client libraries to add a user to an organization with optional org-specific data. + Both organization and user are identified by their external_id. + The project is determined from the API key. + operationId: addOrganizationUserClient + tags: + - Client + security: + - HttpBearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/OrganizationUserRequest' + responses: + '200': + description: User added to organization successfully + default: + $ref: '#/components/responses/Error' + + delete: + summary: Remove user from organization + description: | + Used by client libraries to remove a user from an organization. + Both organization and user are identified by their external_id. + The project is determined from the API key. + operationId: removeOrganizationUserClient + tags: + - Client + security: + - HttpBearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/RemoveOrganizationUserRequest' + responses: + '204': + description: User removed from organization successfully + default: + $ref: '#/components/responses/Error' + + /api/client/organizations/events: + post: + summary: Post organization events + description: | + Used by client libraries to trigger events on an organization. + The organization is identified by external_id. + Events are processed asynchronously and can trigger journeys for all users in the organization. + The project is determined from the API key. + operationId: postOrganizationEventsClient + tags: + - Client + security: + - HttpBearerAuth: [] + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/PostOrganizationEventsRequest' + responses: + '202': + description: Events accepted for asynchronous processing + default: + $ref: '#/components/responses/Error' + /unsubscribe/email: get: summary: Email unsubscribe page @@ -331,6 +430,143 @@ components: amount: 99.99 description: Event-specific data + Organization: + type: object + required: + - id + - project_id + - external_id + - data + - version + - created_at + - updated_at + properties: + id: + type: string + format: uuid + example: "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d" + project_id: + type: string + format: uuid + example: "4c9d3163-7b64-4f9e-9068-d2e4b96be56b" + external_id: + type: string + example: "org_123" + description: External identifier for the organization from your system + name: + type: string + example: "Acme Corp" + data: + type: object + additionalProperties: true + x-go-type: map[string]any + example: + industry: "technology" + size: "enterprise" + version: + type: integer + example: 1 + x-go-type: int32 + created_at: + type: string + format: date-time + example: "2025-11-19T14:18:42.960Z" + updated_at: + type: string + format: date-time + example: "2025-11-23T17:20:00.021Z" + + OrganizationRequest: + type: object + required: + - external_id + properties: + external_id: + type: string + example: "org_123" + description: External identifier for the organization from your system + name: + type: string + nullable: true + example: "Acme Corp" + data: + type: object + additionalProperties: true + nullable: true + x-go-type: map[string]any + example: + industry: "technology" + size: "enterprise" + + OrganizationUserRequest: + type: object + required: + - organization_external_id + - user_external_id + properties: + organization_external_id: + type: string + example: "org_123" + description: External identifier for the organization + user_external_id: + type: string + example: "user_456" + description: External identifier for the user + data: + type: object + additionalProperties: true + nullable: true + x-go-type: map[string]any + example: + role: "admin" + department: "engineering" + description: Organization-specific data for this user + + RemoveOrganizationUserRequest: + type: object + required: + - organization_external_id + - user_external_id + properties: + organization_external_id: + type: string + example: "org_123" + description: External identifier for the organization + user_external_id: + type: string + example: "user_456" + description: External identifier for the user + + PostOrganizationEventsRequest: + type: array + minItems: 1 + items: + $ref: '#/components/schemas/OrganizationEvent' + + OrganizationEvent: + type: object + required: + - organization_external_id + - name + properties: + organization_external_id: + type: string + example: "org_123" + description: External identifier for the organization + name: + type: string + example: "subscription_upgraded" + description: The name of the event + data: + type: object + additionalProperties: true + nullable: true + x-go-type: map[string]any + example: + plan: "enterprise" + seats: 100 + description: Event-specific data + securitySchemes: HttpBearerAuth: type: http diff --git a/internal/http/controllers/v1/client/oapi/resources_gen.go b/internal/http/controllers/v1/client/oapi/resources_gen.go index 1c7406f6..61041727 100644 --- a/internal/http/controllers/v1/client/oapi/resources_gen.go +++ b/internal/http/controllers/v1/client/oapi/resources_gen.go @@ -56,9 +56,59 @@ type IdentifyRequest struct { Timezone *string `json:"timezone"` } +// Organization defines model for Organization. +type Organization struct { + CreatedAt time.Time `json:"created_at"` + Data map[string]any `json:"data"` + + // ExternalId External identifier for the organization from your system + ExternalId string `json:"external_id"` + Id openapi_types.UUID `json:"id"` + Name *string `json:"name,omitempty"` + ProjectId openapi_types.UUID `json:"project_id"` + UpdatedAt time.Time `json:"updated_at"` + Version int32 `json:"version"` +} + +// OrganizationEvent defines model for OrganizationEvent. +type OrganizationEvent struct { + // Data Event-specific data + Data *map[string]any `json:"data"` + + // Name The name of the event + Name string `json:"name"` + + // OrganizationExternalId External identifier for the organization + OrganizationExternalId string `json:"organization_external_id"` +} + +// OrganizationRequest defines model for OrganizationRequest. +type OrganizationRequest struct { + Data *map[string]any `json:"data"` + + // ExternalId External identifier for the organization from your system + ExternalId string `json:"external_id"` + Name *string `json:"name"` +} + +// OrganizationUserRequest defines model for OrganizationUserRequest. +type OrganizationUserRequest struct { + // Data Organization-specific data for this user + Data *map[string]any `json:"data"` + + // OrganizationExternalId External identifier for the organization + OrganizationExternalId string `json:"organization_external_id"` + + // UserExternalId External identifier for the user + UserExternalId string `json:"user_external_id"` +} + // PostEventsRequest defines model for PostEventsRequest. type PostEventsRequest = []Event +// PostOrganizationEventsRequest defines model for PostOrganizationEventsRequest. +type PostOrganizationEventsRequest = []OrganizationEvent + // Problem defines model for Problem. type Problem struct { // Detail A human readable explanation specific to this occurrence of the problem that is helpful to locate the problem and give advice on how to proceed. Written in English and readable for engineers, usually not suited for non technical stakeholders and not localized. @@ -68,6 +118,15 @@ type Problem struct { Title string `json:"title"` } +// RemoveOrganizationUserRequest defines model for RemoveOrganizationUserRequest. +type RemoveOrganizationUserRequest struct { + // OrganizationExternalId External identifier for the organization + OrganizationExternalId string `json:"organization_external_id"` + + // UserExternalId External identifier for the user + UserExternalId string `json:"user_external_id"` +} + // User defines model for User. type User struct { AnonymousId string `json:"anonymous_id"` @@ -108,6 +167,18 @@ type PostEventsJSONRequestBody = PostEventsRequest // IdentifyUserClientJSONRequestBody defines body for IdentifyUserClient for application/json ContentType. type IdentifyUserClientJSONRequestBody = IdentifyRequest +// UpsertOrganizationClientJSONRequestBody defines body for UpsertOrganizationClient for application/json ContentType. +type UpsertOrganizationClientJSONRequestBody = OrganizationRequest + +// PostOrganizationEventsClientJSONRequestBody defines body for PostOrganizationEventsClient for application/json ContentType. +type PostOrganizationEventsClientJSONRequestBody = PostOrganizationEventsRequest + +// RemoveOrganizationUserClientJSONRequestBody defines body for RemoveOrganizationUserClient for application/json ContentType. +type RemoveOrganizationUserClientJSONRequestBody = RemoveOrganizationUserRequest + +// AddOrganizationUserClientJSONRequestBody defines body for AddOrganizationUserClient for application/json ContentType. +type AddOrganizationUserClientJSONRequestBody = OrganizationUserRequest + // UpdatePreferencesFormdataRequestBody defines body for UpdatePreferences for application/x-www-form-urlencoded ContentType. type UpdatePreferencesFormdataRequestBody UpdatePreferencesFormdataBody @@ -194,6 +265,26 @@ type ClientInterface interface { IdentifyUserClient(ctx context.Context, body IdentifyUserClientJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // UpsertOrganizationClientWithBody request with any body + UpsertOrganizationClientWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + UpsertOrganizationClient(ctx context.Context, body UpsertOrganizationClientJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // PostOrganizationEventsClientWithBody request with any body + PostOrganizationEventsClientWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + PostOrganizationEventsClient(ctx context.Context, body PostOrganizationEventsClientJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RemoveOrganizationUserClientWithBody request with any body + RemoveOrganizationUserClientWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + RemoveOrganizationUserClient(ctx context.Context, body RemoveOrganizationUserClientJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AddOrganizationUserClientWithBody request with any body + AddOrganizationUserClientWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + AddOrganizationUserClient(ctx context.Context, body AddOrganizationUserClientJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetPreferencesPage request GetPreferencesPage(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -254,6 +345,102 @@ func (c *Client) IdentifyUserClient(ctx context.Context, body IdentifyUserClient return c.Client.Do(req) } +func (c *Client) UpsertOrganizationClientWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpsertOrganizationClientRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) UpsertOrganizationClient(ctx context.Context, body UpsertOrganizationClientJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpsertOrganizationClientRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostOrganizationEventsClientWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostOrganizationEventsClientRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) PostOrganizationEventsClient(ctx context.Context, body PostOrganizationEventsClientJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewPostOrganizationEventsClientRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) RemoveOrganizationUserClientWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRemoveOrganizationUserClientRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) RemoveOrganizationUserClient(ctx context.Context, body RemoveOrganizationUserClientJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRemoveOrganizationUserClientRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) AddOrganizationUserClientWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAddOrganizationUserClientRequestWithBody(c.Server, contentType, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) AddOrganizationUserClient(ctx context.Context, body AddOrganizationUserClientJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAddOrganizationUserClientRequest(c.Server, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) GetPreferencesPage(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetPreferencesPageRequest(c.Server, projectID, userID) if err != nil { @@ -382,6 +569,166 @@ func NewIdentifyUserClientRequestWithBody(server string, contentType string, bod return req, nil } +// NewUpsertOrganizationClientRequest calls the generic UpsertOrganizationClient builder with application/json body +func NewUpsertOrganizationClientRequest(server string, body UpsertOrganizationClientJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpsertOrganizationClientRequestWithBody(server, "application/json", bodyReader) +} + +// NewUpsertOrganizationClientRequestWithBody generates requests for UpsertOrganizationClient with any type of body +func NewUpsertOrganizationClientRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/client/organizations") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewPostOrganizationEventsClientRequest calls the generic PostOrganizationEventsClient builder with application/json body +func NewPostOrganizationEventsClientRequest(server string, body PostOrganizationEventsClientJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewPostOrganizationEventsClientRequestWithBody(server, "application/json", bodyReader) +} + +// NewPostOrganizationEventsClientRequestWithBody generates requests for PostOrganizationEventsClient with any type of body +func NewPostOrganizationEventsClientRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/client/organizations/events") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewRemoveOrganizationUserClientRequest calls the generic RemoveOrganizationUserClient builder with application/json body +func NewRemoveOrganizationUserClientRequest(server string, body RemoveOrganizationUserClientJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewRemoveOrganizationUserClientRequestWithBody(server, "application/json", bodyReader) +} + +// NewRemoveOrganizationUserClientRequestWithBody generates requests for RemoveOrganizationUserClient with any type of body +func NewRemoveOrganizationUserClientRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/client/organizations/users") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("DELETE", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + +// NewAddOrganizationUserClientRequest calls the generic AddOrganizationUserClient builder with application/json body +func NewAddOrganizationUserClientRequest(server string, body AddOrganizationUserClientJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewAddOrganizationUserClientRequestWithBody(server, "application/json", bodyReader) +} + +// NewAddOrganizationUserClientRequestWithBody generates requests for AddOrganizationUserClient with any type of body +func NewAddOrganizationUserClientRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/client/organizations/users") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } + + req.Header.Add("Content-Type", contentType) + + return req, nil +} + // NewGetPreferencesPageRequest generates requests for GetPreferencesPage func NewGetPreferencesPageRequest(server string, projectID openapi_types.UUID, userID openapi_types.UUID) (*http.Request, error) { var err error @@ -575,26 +922,136 @@ type ClientWithResponsesInterface interface { IdentifyUserClientWithResponse(ctx context.Context, body IdentifyUserClientJSONRequestBody, reqEditors ...RequestEditorFn) (*IdentifyUserClientResponse, error) + // UpsertOrganizationClientWithBodyWithResponse request with any body + UpsertOrganizationClientWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpsertOrganizationClientResponse, error) + + UpsertOrganizationClientWithResponse(ctx context.Context, body UpsertOrganizationClientJSONRequestBody, reqEditors ...RequestEditorFn) (*UpsertOrganizationClientResponse, error) + + // PostOrganizationEventsClientWithBodyWithResponse request with any body + PostOrganizationEventsClientWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostOrganizationEventsClientResponse, error) + + PostOrganizationEventsClientWithResponse(ctx context.Context, body PostOrganizationEventsClientJSONRequestBody, reqEditors ...RequestEditorFn) (*PostOrganizationEventsClientResponse, error) + + // RemoveOrganizationUserClientWithBodyWithResponse request with any body + RemoveOrganizationUserClientWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RemoveOrganizationUserClientResponse, error) + + RemoveOrganizationUserClientWithResponse(ctx context.Context, body RemoveOrganizationUserClientJSONRequestBody, reqEditors ...RequestEditorFn) (*RemoveOrganizationUserClientResponse, error) + + // AddOrganizationUserClientWithBodyWithResponse request with any body + AddOrganizationUserClientWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AddOrganizationUserClientResponse, error) + + AddOrganizationUserClientWithResponse(ctx context.Context, body AddOrganizationUserClientJSONRequestBody, reqEditors ...RequestEditorFn) (*AddOrganizationUserClientResponse, error) + // GetPreferencesPageWithResponse request GetPreferencesPageWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetPreferencesPageResponse, error) - // UpdatePreferencesWithBodyWithResponse request with any body - UpdatePreferencesWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdatePreferencesResponse, error) + // UpdatePreferencesWithBodyWithResponse request with any body + UpdatePreferencesWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdatePreferencesResponse, error) + + UpdatePreferencesWithFormdataBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, body UpdatePreferencesFormdataRequestBody, reqEditors ...RequestEditorFn) (*UpdatePreferencesResponse, error) + + // EmailUnsubscribeWithResponse request + EmailUnsubscribeWithResponse(ctx context.Context, params *EmailUnsubscribeParams, reqEditors ...RequestEditorFn) (*EmailUnsubscribeResponse, error) +} + +type PostEventsResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *Error +} + +// Status returns HTTPResponse.Status +func (r PostEventsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r PostEventsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type IdentifyUserClientResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *User + JSONDefault *Error +} + +// Status returns HTTPResponse.Status +func (r IdentifyUserClientResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r IdentifyUserClientResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type UpsertOrganizationClientResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Organization + JSONDefault *Error +} + +// Status returns HTTPResponse.Status +func (r UpsertOrganizationClientResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r UpsertOrganizationClientResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + +type PostOrganizationEventsClientResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *Error +} - UpdatePreferencesWithFormdataBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, body UpdatePreferencesFormdataRequestBody, reqEditors ...RequestEditorFn) (*UpdatePreferencesResponse, error) +// Status returns HTTPResponse.Status +func (r PostOrganizationEventsClientResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} - // EmailUnsubscribeWithResponse request - EmailUnsubscribeWithResponse(ctx context.Context, params *EmailUnsubscribeParams, reqEditors ...RequestEditorFn) (*EmailUnsubscribeResponse, error) +// StatusCode returns HTTPResponse.StatusCode +func (r PostOrganizationEventsClientResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 } -type PostEventsResponse struct { +type RemoveOrganizationUserClientResponse struct { Body []byte HTTPResponse *http.Response JSONDefault *Error } // Status returns HTTPResponse.Status -func (r PostEventsResponse) Status() string { +func (r RemoveOrganizationUserClientResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -602,22 +1059,21 @@ func (r PostEventsResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r PostEventsResponse) StatusCode() int { +func (r RemoveOrganizationUserClientResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type IdentifyUserClientResponse struct { +type AddOrganizationUserClientResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *User JSONDefault *Error } // Status returns HTTPResponse.Status -func (r IdentifyUserClientResponse) Status() string { +func (r AddOrganizationUserClientResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -625,7 +1081,7 @@ func (r IdentifyUserClientResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r IdentifyUserClientResponse) StatusCode() int { +func (r AddOrganizationUserClientResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } @@ -729,6 +1185,74 @@ func (c *ClientWithResponses) IdentifyUserClientWithResponse(ctx context.Context return ParseIdentifyUserClientResponse(rsp) } +// UpsertOrganizationClientWithBodyWithResponse request with arbitrary body returning *UpsertOrganizationClientResponse +func (c *ClientWithResponses) UpsertOrganizationClientWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpsertOrganizationClientResponse, error) { + rsp, err := c.UpsertOrganizationClientWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpsertOrganizationClientResponse(rsp) +} + +func (c *ClientWithResponses) UpsertOrganizationClientWithResponse(ctx context.Context, body UpsertOrganizationClientJSONRequestBody, reqEditors ...RequestEditorFn) (*UpsertOrganizationClientResponse, error) { + rsp, err := c.UpsertOrganizationClient(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpsertOrganizationClientResponse(rsp) +} + +// PostOrganizationEventsClientWithBodyWithResponse request with arbitrary body returning *PostOrganizationEventsClientResponse +func (c *ClientWithResponses) PostOrganizationEventsClientWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*PostOrganizationEventsClientResponse, error) { + rsp, err := c.PostOrganizationEventsClientWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostOrganizationEventsClientResponse(rsp) +} + +func (c *ClientWithResponses) PostOrganizationEventsClientWithResponse(ctx context.Context, body PostOrganizationEventsClientJSONRequestBody, reqEditors ...RequestEditorFn) (*PostOrganizationEventsClientResponse, error) { + rsp, err := c.PostOrganizationEventsClient(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParsePostOrganizationEventsClientResponse(rsp) +} + +// RemoveOrganizationUserClientWithBodyWithResponse request with arbitrary body returning *RemoveOrganizationUserClientResponse +func (c *ClientWithResponses) RemoveOrganizationUserClientWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RemoveOrganizationUserClientResponse, error) { + rsp, err := c.RemoveOrganizationUserClientWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRemoveOrganizationUserClientResponse(rsp) +} + +func (c *ClientWithResponses) RemoveOrganizationUserClientWithResponse(ctx context.Context, body RemoveOrganizationUserClientJSONRequestBody, reqEditors ...RequestEditorFn) (*RemoveOrganizationUserClientResponse, error) { + rsp, err := c.RemoveOrganizationUserClient(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseRemoveOrganizationUserClientResponse(rsp) +} + +// AddOrganizationUserClientWithBodyWithResponse request with arbitrary body returning *AddOrganizationUserClientResponse +func (c *ClientWithResponses) AddOrganizationUserClientWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AddOrganizationUserClientResponse, error) { + rsp, err := c.AddOrganizationUserClientWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAddOrganizationUserClientResponse(rsp) +} + +func (c *ClientWithResponses) AddOrganizationUserClientWithResponse(ctx context.Context, body AddOrganizationUserClientJSONRequestBody, reqEditors ...RequestEditorFn) (*AddOrganizationUserClientResponse, error) { + rsp, err := c.AddOrganizationUserClient(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAddOrganizationUserClientResponse(rsp) +} + // GetPreferencesPageWithResponse request returning *GetPreferencesPageResponse func (c *ClientWithResponses) GetPreferencesPageWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetPreferencesPageResponse, error) { rsp, err := c.GetPreferencesPage(ctx, projectID, userID, reqEditors...) @@ -823,6 +1347,117 @@ func ParseIdentifyUserClientResponse(rsp *http.Response) (*IdentifyUserClientRes return response, nil } +// ParseUpsertOrganizationClientResponse parses an HTTP response from a UpsertOrganizationClientWithResponse call +func ParseUpsertOrganizationClientResponse(rsp *http.Response) (*UpsertOrganizationClientResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpsertOrganizationClientResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Organization + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParsePostOrganizationEventsClientResponse parses an HTTP response from a PostOrganizationEventsClientWithResponse call +func ParsePostOrganizationEventsClientResponse(rsp *http.Response) (*PostOrganizationEventsClientResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &PostOrganizationEventsClientResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseRemoveOrganizationUserClientResponse parses an HTTP response from a RemoveOrganizationUserClientWithResponse call +func ParseRemoveOrganizationUserClientResponse(rsp *http.Response) (*RemoveOrganizationUserClientResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RemoveOrganizationUserClientResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseAddOrganizationUserClientResponse parses an HTTP response from a AddOrganizationUserClientWithResponse call +func ParseAddOrganizationUserClientResponse(rsp *http.Response) (*AddOrganizationUserClientResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AddOrganizationUserClientResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + // ParseGetPreferencesPageResponse parses an HTTP response from a GetPreferencesPageWithResponse call func ParseGetPreferencesPageResponse(rsp *http.Response) (*GetPreferencesPageResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -879,6 +1514,18 @@ type ServerInterface interface { // Identify user // (POST /api/client/identify) IdentifyUserClient(w http.ResponseWriter, r *http.Request) + // Upsert organization + // (POST /api/client/organizations) + UpsertOrganizationClient(w http.ResponseWriter, r *http.Request) + // Post organization events + // (POST /api/client/organizations/events) + PostOrganizationEventsClient(w http.ResponseWriter, r *http.Request) + // Remove user from organization + // (DELETE /api/client/organizations/users) + RemoveOrganizationUserClient(w http.ResponseWriter, r *http.Request) + // Add user to organization + // (POST /api/client/organizations/users) + AddOrganizationUserClient(w http.ResponseWriter, r *http.Request) // Subscription preferences page // (GET /preferences/{projectID}/{userID}) GetPreferencesPage(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) @@ -906,6 +1553,30 @@ func (_ Unimplemented) IdentifyUserClient(w http.ResponseWriter, r *http.Request w.WriteHeader(http.StatusNotImplemented) } +// Upsert organization +// (POST /api/client/organizations) +func (_ Unimplemented) UpsertOrganizationClient(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Post organization events +// (POST /api/client/organizations/events) +func (_ Unimplemented) PostOrganizationEventsClient(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Remove user from organization +// (DELETE /api/client/organizations/users) +func (_ Unimplemented) RemoveOrganizationUserClient(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Add user to organization +// (POST /api/client/organizations/users) +func (_ Unimplemented) AddOrganizationUserClient(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusNotImplemented) +} + // Subscription preferences page // (GET /preferences/{projectID}/{userID}) func (_ Unimplemented) GetPreferencesPage(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) { @@ -973,6 +1644,86 @@ func (siw *ServerInterfaceWrapper) IdentifyUserClient(w http.ResponseWriter, r * handler.ServeHTTP(w, r) } +// UpsertOrganizationClient operation middleware +func (siw *ServerInterfaceWrapper) UpsertOrganizationClient(w http.ResponseWriter, r *http.Request) { + + ctx := r.Context() + + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) + + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.UpsertOrganizationClient(w, r) + })) + + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) + } + + handler.ServeHTTP(w, r) +} + +// PostOrganizationEventsClient operation middleware +func (siw *ServerInterfaceWrapper) PostOrganizationEventsClient(w http.ResponseWriter, r *http.Request) { + + ctx := r.Context() + + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) + + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.PostOrganizationEventsClient(w, r) + })) + + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) + } + + handler.ServeHTTP(w, r) +} + +// RemoveOrganizationUserClient operation middleware +func (siw *ServerInterfaceWrapper) RemoveOrganizationUserClient(w http.ResponseWriter, r *http.Request) { + + ctx := r.Context() + + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) + + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.RemoveOrganizationUserClient(w, r) + })) + + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) + } + + handler.ServeHTTP(w, r) +} + +// AddOrganizationUserClient operation middleware +func (siw *ServerInterfaceWrapper) AddOrganizationUserClient(w http.ResponseWriter, r *http.Request) { + + ctx := r.Context() + + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) + + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.AddOrganizationUserClient(w, r) + })) + + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) + } + + handler.ServeHTTP(w, r) +} + // GetPreferencesPage operation middleware func (siw *ServerInterfaceWrapper) GetPreferencesPage(w http.ResponseWriter, r *http.Request) { @@ -1194,6 +1945,18 @@ func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handl r.Group(func(r chi.Router) { r.Post(options.BaseURL+"/api/client/identify", wrapper.IdentifyUserClient) }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/api/client/organizations", wrapper.UpsertOrganizationClient) + }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/api/client/organizations/events", wrapper.PostOrganizationEventsClient) + }) + r.Group(func(r chi.Router) { + r.Delete(options.BaseURL+"/api/client/organizations/users", wrapper.RemoveOrganizationUserClient) + }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/api/client/organizations/users", wrapper.AddOrganizationUserClient) + }) r.Group(func(r chi.Router) { r.Get(options.BaseURL+"/preferences/{projectID}/{userID}", wrapper.GetPreferencesPage) }) diff --git a/internal/http/controllers/v1/management/controller.go b/internal/http/controllers/v1/management/controller.go index 4ec1511a..11a254b2 100644 --- a/internal/http/controllers/v1/management/controller.go +++ b/internal/http/controllers/v1/management/controller.go @@ -15,21 +15,22 @@ func NewController(logger *zap.Logger, managementDB, usersDB, journeyDB *sqlx.DB projects := management.NewProjectsStore(managementDB) controller := &Controller{ - ProjectsController: NewProjectsController(logger, managementDB, usersDB, journeyDB), - CampaignsController: NewCampaignsController(logger, managementDB, usersDB), - TemplatesController: NewTemplatesController(logger, managementDB), - AdminsController: NewAdminsController(logger, managementDB), - UsersController: NewUsersController(logger, pub, usersDB, journeyDB, mgmt, cfg.Storage.MaxUploadSize), - EventsController: NewEventsController(logger, usersDB), - TagsController: NewTagsController(logger, managementDB), - LocalesController: NewLocalesController(logger, managementDB), - JourneysController: NewJourneysController(logger, journeyDB, mgmt), - OrganizationsController: NewOrganizationsController(logger, managementDB), - ListsController: NewListsController(logger, usersDB, projects, pub, cfg.Storage.MaxUploadSize), - DocumentsController: NewDocumentsController(logger, managementDB, storage, cfg.Storage.MaxUploadSize), - ProvidersController: NewProvidersController(logger, managementDB, registry), - SubscriptionsController: NewSubscriptionsController(logger, managementDB), - ApiKeysController: NewApiKeysController(logger, managementDB), + ProjectsController: NewProjectsController(logger, managementDB, usersDB, journeyDB), + CampaignsController: NewCampaignsController(logger, managementDB, usersDB), + TemplatesController: NewTemplatesController(logger, managementDB), + AdminsController: NewAdminsController(logger, managementDB), + UsersController: NewUsersController(logger, pub, usersDB, journeyDB, mgmt, cfg.Storage.MaxUploadSize), + EventsController: NewEventsController(logger, usersDB), + TagsController: NewTagsController(logger, managementDB), + LocalesController: NewLocalesController(logger, managementDB), + JourneysController: NewJourneysController(logger, journeyDB, mgmt), + OrganizationsController: NewOrganizationsController(logger, managementDB), + SubjectOrganizationsController: NewSubjectOrganizationsController(logger, usersDB, pub), + ListsController: NewListsController(logger, usersDB, projects, pub, cfg.Storage.MaxUploadSize), + DocumentsController: NewDocumentsController(logger, managementDB, storage, cfg.Storage.MaxUploadSize), + ProvidersController: NewProvidersController(logger, managementDB, registry), + SubscriptionsController: NewSubscriptionsController(logger, managementDB), + ApiKeysController: NewApiKeysController(logger, managementDB), } controller.AuthController, err = NewAuthController(logger, managementDB, cfg) @@ -51,6 +52,7 @@ type Controller struct { *LocalesController *JourneysController *OrganizationsController + *SubjectOrganizationsController *ListsController *DocumentsController *ProvidersController diff --git a/internal/http/controllers/v1/management/oapi/resources.yml b/internal/http/controllers/v1/management/oapi/resources.yml index 4a5fb1b8..f4aa4522 100644 --- a/internal/http/controllers/v1/management/oapi/resources.yml +++ b/internal/http/controllers/v1/management/oapi/resources.yml @@ -1223,7 +1223,7 @@ paths: default: $ref: "#/components/responses/Error" - /api/admin/organizations/admins: + /api/admin/tenant/admins: get: summary: List organization admins description: Retrieves a paginated list of admins in the organization @@ -1270,7 +1270,7 @@ paths: default: $ref: "#/components/responses/Error" - /api/admin/organizations/admins/{adminID}: + /api/admin/tenant/admins/{adminID}: get: summary: Get admin by ID description: Retrieves a specific admin @@ -1351,7 +1351,7 @@ paths: default: $ref: "#/components/responses/Error" - /api/admin/organizations/whoami: + /api/admin/tenant/whoami: get: summary: Get current admin description: Retrieves the currently authenticated admin's information @@ -1370,31 +1370,31 @@ paths: default: $ref: "#/components/responses/Error" - /api/admin/organizations: + /api/admin/tenant: get: - summary: Get current organization - description: Retrieves the current organization for the authenticated admin - operationId: getOrganization + summary: Get current tenant + description: Retrieves the current tenant for the authenticated admin + operationId: getTenant tags: - - Organizations + - Tenant security: - HttpBearerAuth: [] responses: "200": - description: Organization retrieved successfully + description: Tenant retrieved successfully content: application/json: schema: - $ref: "#/components/schemas/Organization" + $ref: "#/components/schemas/Tenant" default: $ref: "#/components/responses/Error" patch: - summary: Update organization - description: Updates organization properties (requires owner role) - operationId: updateOrganization + summary: Update tenant + description: Updates tenant properties (requires owner role) + operationId: updateTenant tags: - - Organizations + - Tenant security: - HttpBearerAuth: [] requestBody: @@ -1402,38 +1402,38 @@ paths: content: application/json: schema: - $ref: "#/components/schemas/UpdateOrganization" + $ref: "#/components/schemas/UpdateTenant" responses: "200": - description: Organization updated successfully + description: Tenant updated successfully content: application/json: schema: - $ref: "#/components/schemas/Organization" + $ref: "#/components/schemas/Tenant" default: $ref: "#/components/responses/Error" delete: - summary: Delete organization - description: Soft deletes the current organization (requires owner role) - operationId: deleteOrganization + summary: Delete tenant + description: Soft deletes the current tenant (requires owner role) + operationId: deleteTenant tags: - - Organizations + - Tenant security: - HttpBearerAuth: [] responses: "204": - description: Organization deleted successfully + description: Tenant deleted successfully default: $ref: "#/components/responses/Error" - /api/admin/organizations/integrations: + /api/admin/tenant/integrations: get: - summary: Get organization integrations - description: Retrieves all provider integrations for the organization - operationId: getOrganizationIntegrations + summary: Get tenant integrations + description: Retrieves all provider integrations for the tenant + operationId: getTenantIntegrations tags: - - Organizations + - Tenant security: - HttpBearerAuth: [] responses: @@ -1448,13 +1448,13 @@ paths: default: $ref: "#/components/responses/Error" - /api/admin/projects/{projectID}/users: + /api/admin/projects/{projectID}/subjects/users: get: summary: List users description: Retrieves a paginated list of users in a project operationId: listUsers tags: - - Users + - Subjects > Users security: - HttpBearerAuth: [] parameters: @@ -1483,7 +1483,7 @@ paths: description: Creates or updates a user by anonymous_id or external_id operationId: identifyUser tags: - - Users + - Subjects > Users security: - HttpBearerAuth: [] parameters: @@ -1510,13 +1510,13 @@ paths: default: $ref: "#/components/responses/Error" - /api/admin/projects/{projectID}/users/import: + /api/admin/projects/{projectID}/subjects/users/import: post: summary: Bulk import users description: Imports multiple users from a CSV file operationId: importUsers tags: - - Users + - Subjects > Users security: - HttpBearerAuth: [] parameters: @@ -1546,13 +1546,13 @@ paths: default: $ref: "#/components/responses/Error" - /api/admin/projects/{projectID}/users/{userID}: + /api/admin/projects/{projectID}/subjects/users/{userID}: get: summary: Get user by ID description: Retrieves a specific user operationId: getUser tags: - - Users + - Subjects > Users security: - HttpBearerAuth: [] parameters: @@ -1585,7 +1585,7 @@ paths: description: Updates user properties operationId: updateUser tags: - - Users + - Subjects > Users security: - HttpBearerAuth: [] parameters: @@ -1624,7 +1624,7 @@ paths: description: Deletes a user from the project operationId: deleteUser tags: - - Users + - Subjects > Users security: - HttpBearerAuth: [] parameters: @@ -1648,13 +1648,13 @@ paths: default: $ref: "#/components/responses/Error" - /api/admin/projects/{projectID}/users/{userID}/events: + /api/admin/projects/{projectID}/subjects/users/{userID}/events: get: summary: Get user events description: Retrieves events for a specific user operationId: getUserEvents tags: - - Users + - Subjects > Users security: - HttpBearerAuth: [] parameters: @@ -1684,13 +1684,13 @@ paths: default: $ref: "#/components/responses/Error" - /api/admin/projects/{projectID}/users/{userID}/subscriptions: + /api/admin/projects/{projectID}/subjects/users/{userID}/subscriptions: get: summary: Get user subscriptions description: Retrieves subscriptions for a specific user operationId: getUserSubscriptions tags: - - Users + - Subjects > Users security: - HttpBearerAuth: [] parameters: @@ -1725,7 +1725,7 @@ paths: description: Updates subscription states for a user operationId: updateUserSubscriptions tags: - - Users + - Subjects > Users security: - HttpBearerAuth: [] parameters: @@ -1759,13 +1759,13 @@ paths: default: $ref: "#/components/responses/Error" - /api/admin/projects/{projectID}/users/{userID}/journeys: + /api/admin/projects/{projectID}/subjects/users/{userID}/journeys: get: summary: Get user journeys description: Retrieves journey entrances for a specific user operationId: getUserJourneys tags: - - Users + - Subjects > Users security: - HttpBearerAuth: [] parameters: @@ -1795,13 +1795,13 @@ paths: default: $ref: "#/components/responses/Error" - /api/admin/projects/{projectID}/events/schema: + /api/admin/projects/{projectID}/subjects/events/schema: get: summary: List events with schemas description: Retrieves all events and their schema paths for a project operationId: listEvents tags: - - Events + - Subjects > Events security: - HttpBearerAuth: [] parameters: @@ -1818,13 +1818,13 @@ paths: default: $ref: "#/components/responses/Error" - /api/admin/projects/{projectID}/users/schema: + /api/admin/projects/{projectID}/subjects/users/schema: get: summary: List user schemas description: Retrieves all user data schema paths for a project operationId: listUserSchemas tags: - - Users + - Subjects > Users security: - HttpBearerAuth: [] parameters: @@ -1852,6 +1852,387 @@ paths: default: $ref: "#/components/responses/Error" + /api/admin/projects/{projectID}/subjects/organizations: + get: + summary: List subject organizations + description: Retrieves a paginated list of organizations (subjects) in a project + operationId: listOrganizations + tags: + - Subjects > Organizations + security: + - HttpBearerAuth: [] + parameters: + - name: projectID + in: path + required: true + schema: + type: string + format: uuid + description: The project ID + - $ref: "#/components/parameters/Limit" + - $ref: "#/components/parameters/Offset" + - $ref: "#/components/parameters/Search" + responses: + "200": + description: Organizations retrieved successfully + content: + application/json: + schema: + $ref: "#/components/schemas/OrganizationList" + default: + $ref: "#/components/responses/Error" + + post: + summary: Create or update subject organization + description: Creates or updates an organization (subject) by external_id + operationId: upsertOrganization + tags: + - Subjects > Organizations + security: + - HttpBearerAuth: [] + parameters: + - name: projectID + in: path + required: true + schema: + type: string + format: uuid + description: The project ID + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/UpsertOrganization" + responses: + "200": + description: Organization upserted successfully + content: + application/json: + schema: + $ref: "#/components/schemas/Organization" + default: + $ref: "#/components/responses/Error" + + /api/admin/projects/{projectID}/subjects/organizations/{organizationID}: + get: + summary: Get subject organization by ID + description: Retrieves a specific organization (subject) + operationId: getOrganization + tags: + - Subjects > Organizations + security: + - HttpBearerAuth: [] + parameters: + - name: projectID + in: path + required: true + schema: + type: string + format: uuid + description: The project ID + - name: organizationID + in: path + required: true + schema: + type: string + format: uuid + description: The organization ID + responses: + "200": + description: Organization retrieved successfully + content: + application/json: + schema: + $ref: "#/components/schemas/Organization" + default: + $ref: "#/components/responses/Error" + + patch: + summary: Update subject organization + description: Updates organization properties + operationId: updateOrganization + tags: + - Subjects > Organizations + security: + - HttpBearerAuth: [] + parameters: + - name: projectID + in: path + required: true + schema: + type: string + format: uuid + description: The project ID + - name: organizationID + in: path + required: true + schema: + type: string + format: uuid + description: The organization ID + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateOrganization" + responses: + "200": + description: Organization updated successfully + content: + application/json: + schema: + $ref: "#/components/schemas/Organization" + default: + $ref: "#/components/responses/Error" + + delete: + summary: Delete subject organization + description: Deletes an organization and removes all user memberships + operationId: deleteOrganization + tags: + - Subjects > Organizations + security: + - HttpBearerAuth: [] + parameters: + - name: projectID + in: path + required: true + schema: + type: string + format: uuid + description: The project ID + - name: organizationID + in: path + required: true + schema: + type: string + format: uuid + description: The organization ID + responses: + "204": + description: Organization deleted successfully + default: + $ref: "#/components/responses/Error" + + /api/admin/projects/{projectID}/subjects/organizations/{organizationID}/users: + get: + summary: List organization users + description: Retrieves users belonging to an organization with their org-specific data + operationId: listOrganizationMembers + tags: + - Subjects > Organizations + security: + - HttpBearerAuth: [] + parameters: + - name: projectID + in: path + required: true + schema: + type: string + format: uuid + description: The project ID + - name: organizationID + in: path + required: true + schema: + type: string + format: uuid + description: The organization ID + - $ref: "#/components/parameters/Limit" + - $ref: "#/components/parameters/Offset" + responses: + "200": + description: Organization users retrieved successfully + content: + application/json: + schema: + $ref: "#/components/schemas/OrganizationMemberList" + default: + $ref: "#/components/responses/Error" + + post: + summary: Add user to organization + description: Adds a user to an organization with optional org-specific data + operationId: addOrganizationMember + tags: + - Subjects > Organizations + security: + - HttpBearerAuth: [] + parameters: + - name: projectID + in: path + required: true + schema: + type: string + format: uuid + description: The project ID + - name: organizationID + in: path + required: true + schema: + type: string + format: uuid + description: The organization ID + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/AddOrganizationMember" + responses: + "200": + description: User added to organization successfully + default: + $ref: "#/components/responses/Error" + + /api/admin/projects/{projectID}/subjects/organizations/{organizationID}/users/{userID}: + delete: + summary: Remove user from organization + description: Removes a user from an organization + operationId: removeOrganizationMember + tags: + - Subjects > Organizations + security: + - HttpBearerAuth: [] + parameters: + - name: projectID + in: path + required: true + schema: + type: string + format: uuid + description: The project ID + - name: organizationID + in: path + required: true + schema: + type: string + format: uuid + description: The organization ID + - name: userID + in: path + required: true + schema: + type: string + format: uuid + description: The user ID + responses: + "204": + description: User removed from organization successfully + default: + $ref: "#/components/responses/Error" + + /api/admin/projects/{projectID}/subjects/organizations/schema: + get: + summary: List organization schemas + description: Retrieves all organization data schema paths for a project + operationId: listOrganizationSchemas + tags: + - Subjects > Organizations + security: + - HttpBearerAuth: [] + parameters: + - name: projectID + in: path + required: true + schema: + type: string + format: uuid + description: The project ID + responses: + "200": + description: Organization schemas retrieved successfully + content: + application/json: + schema: + type: object + required: + - results + properties: + results: + type: array + items: + $ref: "#/components/schemas/SchemaPath" + default: + $ref: "#/components/responses/Error" + + /api/admin/projects/{projectID}/subjects/organizations/users/schema: + get: + summary: List organization user schemas + description: Retrieves all organization user data schema paths for a project + operationId: listOrganizationMemberSchemas + tags: + - Subjects > Organizations + security: + - HttpBearerAuth: [] + parameters: + - name: projectID + in: path + required: true + schema: + type: string + format: uuid + description: The project ID + responses: + "200": + description: Organization user schemas retrieved successfully + content: + application/json: + schema: + type: object + required: + - results + properties: + results: + type: array + items: + $ref: "#/components/schemas/SchemaPath" + default: + $ref: "#/components/responses/Error" + + /api/admin/projects/{projectID}/subjects/users/{userID}/subject-organizations: + get: + summary: Get user organizations + description: Retrieves all organizations a user belongs to + operationId: getUserOrganizations + tags: + - Subjects > Users + security: + - HttpBearerAuth: [] + parameters: + - name: projectID + in: path + required: true + schema: + type: string + format: uuid + description: The project ID + - name: userID + in: path + required: true + schema: + type: string + format: uuid + description: The user ID + responses: + "200": + description: User organizations retrieved successfully + content: + application/json: + schema: + type: object + required: + - results + properties: + results: + type: array + items: + $ref: "#/components/schemas/Organization" + default: + $ref: "#/components/responses/Error" + /api/admin/projects/{projectID}/tags: get: summary: List tags @@ -4237,7 +4618,7 @@ components: type: string example: "Smith" - Organization: + Tenant: type: object required: - id @@ -4267,7 +4648,7 @@ components: format: date-time example: "2025-11-23T17:20:00.021Z" - UpdateOrganization: + UpdateTenant: type: object properties: tracking_deeplink_mirror_url: @@ -4407,6 +4788,204 @@ components: first_name: "Jane" last_name: "Smith" + Organization: + type: object + required: + - id + - project_id + - external_id + - data + - version + - created_at + - updated_at + properties: + id: + type: string + format: uuid + example: "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d" + project_id: + type: string + format: uuid + example: "4c9d3163-7b64-4f9e-9068-d2e4b96be56b" + external_id: + type: string + example: "org_123" + description: External identifier for the organization from your system + name: + type: string + example: "Acme Corp" + data: + type: object + additionalProperties: true + x-go-type: json.RawMessage + example: + industry: "technology" + size: "enterprise" + version: + type: integer + example: 1 + x-go-type: int32 + created_at: + type: string + format: date-time + example: "2025-11-19T14:18:42.960Z" + updated_at: + type: string + format: date-time + example: "2025-11-23T17:20:00.021Z" + + OrganizationList: + allOf: + - $ref: "#/components/schemas/PaginatedResponse" + - type: object + required: + - results + properties: + results: + type: array + items: + $ref: "#/components/schemas/Organization" + + UpsertOrganization: + type: object + required: + - external_id + properties: + external_id: + type: string + example: "org_123" + description: External identifier for the organization from your system + name: + type: string + example: "Acme Corp" + data: + type: object + additionalProperties: true + x-go-type: map[string]any + example: + industry: "technology" + size: "enterprise" + + UpdateOrganization: + type: object + properties: + name: + type: string + example: "Acme Corporation" + data: + type: object + additionalProperties: true + x-go-type: json.RawMessage + example: + industry: "technology" + size: "enterprise" + + OrganizationMember: + type: object + required: + - id + - project_id + - anonymous_id + - data + - has_push_device + - version + - created_at + - updated_at + - organization_data + properties: + id: + type: string + format: uuid + example: "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d" + project_id: + type: string + format: uuid + example: "4c9d3163-7b64-4f9e-9068-d2e4b96be56b" + anonymous_id: + type: string + example: "anon_abc123xyz" + external_id: + type: string + example: "user_123" + email: + type: string + format: email + example: "user@example.com" + x-go-type: string + phone: + type: string + example: "+1234567890" + format: phone + x-go-type: string + description: E.164 formatted phone number + data: + type: object + additionalProperties: true + x-go-type: json.RawMessage + example: + first_name: "John" + last_name: "Doe" + timezone: + type: string + example: "America/New_York" + locale: + type: string + example: "en-US" + has_push_device: + type: boolean + example: false + version: + type: integer + example: 1 + x-go-type: int32 + created_at: + type: string + format: date-time + example: "2025-11-19T14:18:42.960Z" + updated_at: + type: string + format: date-time + example: "2025-11-23T17:20:00.021Z" + organization_data: + type: object + additionalProperties: true + x-go-type: json.RawMessage + example: + role: "admin" + department: "engineering" + description: Organization-specific data for this user + + OrganizationMemberList: + allOf: + - $ref: "#/components/schemas/PaginatedResponse" + - type: object + required: + - results + properties: + results: + type: array + items: + $ref: "#/components/schemas/OrganizationMember" + + AddOrganizationMember: + type: object + required: + - user_id + properties: + user_id: + type: string + format: uuid + example: "9b1deb4d-3b7d-4bad-9bdd-2b0d7b3dcb6d" + description: The user ID to add to the organization + data: + type: object + additionalProperties: true + x-go-type: map[string]any + example: + role: "member" + department: "sales" + description: Organization-specific data for this user + UserEvent: type: object required: diff --git a/internal/http/controllers/v1/management/oapi/resources_gen.go b/internal/http/controllers/v1/management/oapi/resources_gen.go index a63b7e63..28da6b1e 100644 --- a/internal/http/controllers/v1/management/oapi/resources_gen.go +++ b/internal/http/controllers/v1/management/oapi/resources_gen.go @@ -144,6 +144,15 @@ const ( AuthWebhookParamsDriverClerk AuthWebhookParamsDriver = "clerk" ) +// AddOrganizationMember defines model for AddOrganizationMember. +type AddOrganizationMember struct { + // Data Organization-specific data for this user + Data *map[string]any `json:"data,omitempty"` + + // UserId The user ID to add to the organization + UserId openapi_types.UUID `json:"user_id"` +} + // Admin defines model for Admin. type Admin struct { CreatedAt time.Time `json:"created_at"` @@ -543,12 +552,64 @@ type Locale struct { // Organization defines model for Organization. type Organization struct { - CreatedAt time.Time `json:"created_at"` - Id openapi_types.UUID `json:"id"` - Name string `json:"name"` - NotificationProviderId *openapi_types.UUID `json:"notification_provider_id,omitempty"` - TrackingDeeplinkMirrorUrl *string `json:"tracking_deeplink_mirror_url,omitempty"` - UpdatedAt time.Time `json:"updated_at"` + CreatedAt time.Time `json:"created_at"` + Data json.RawMessage `json:"data"` + + // ExternalId External identifier for the organization from your system + ExternalId string `json:"external_id"` + Id openapi_types.UUID `json:"id"` + Name *string `json:"name,omitempty"` + ProjectId openapi_types.UUID `json:"project_id"` + UpdatedAt time.Time `json:"updated_at"` + Version int32 `json:"version"` +} + +// OrganizationList defines model for OrganizationList. +type OrganizationList struct { + // Limit Maximum number of items returned + Limit int `json:"limit"` + + // Offset Number of items skipped + Offset int `json:"offset"` + Results []Organization `json:"results"` + + // Total Total number of items matching the filters + Total int `json:"total"` +} + +// OrganizationMember defines model for OrganizationMember. +type OrganizationMember struct { + AnonymousId string `json:"anonymous_id"` + CreatedAt time.Time `json:"created_at"` + Data json.RawMessage `json:"data"` + Email *string `json:"email,omitempty"` + ExternalId *string `json:"external_id,omitempty"` + HasPushDevice bool `json:"has_push_device"` + Id openapi_types.UUID `json:"id"` + Locale *string `json:"locale,omitempty"` + + // OrganizationData Organization-specific data for this user + OrganizationData json.RawMessage `json:"organization_data"` + + // Phone E.164 formatted phone number + Phone *string `json:"phone,omitempty"` + ProjectId openapi_types.UUID `json:"project_id"` + Timezone *string `json:"timezone,omitempty"` + UpdatedAt time.Time `json:"updated_at"` + Version int32 `json:"version"` +} + +// OrganizationMemberList defines model for OrganizationMemberList. +type OrganizationMemberList struct { + // Limit Maximum number of items returned + Limit int `json:"limit"` + + // Offset Number of items skipped + Offset int `json:"offset"` + Results []OrganizationMember `json:"results"` + + // Total Total number of items matching the filters + Total int `json:"total"` } // OrganizationRole Role within an organization @@ -744,6 +805,16 @@ type Template struct { UpdatedAt time.Time `json:"updated_at"` } +// Tenant defines model for Tenant. +type Tenant struct { + CreatedAt time.Time `json:"created_at"` + Id openapi_types.UUID `json:"id"` + Name string `json:"name"` + NotificationProviderId *openapi_types.UUID `json:"notification_provider_id,omitempty"` + TrackingDeeplinkMirrorUrl *string `json:"tracking_deeplink_mirror_url,omitempty"` + UpdatedAt time.Time `json:"updated_at"` +} + // UpdateAdmin defines model for UpdateAdmin. type UpdateAdmin struct { Email *string `json:"email,omitempty"` @@ -785,7 +856,8 @@ type UpdateList struct { // UpdateOrganization defines model for UpdateOrganization. type UpdateOrganization struct { - TrackingDeeplinkMirrorUrl *string `json:"tracking_deeplink_mirror_url,omitempty"` + Data *json.RawMessage `json:"data,omitempty"` + Name *string `json:"name,omitempty"` } // UpdateProject defines model for UpdateProject. @@ -836,6 +908,11 @@ type UpdateTemplate struct { Data *json.RawMessage `json:"data"` } +// UpdateTenant defines model for UpdateTenant. +type UpdateTenant struct { + TrackingDeeplinkMirrorUrl *string `json:"tracking_deeplink_mirror_url,omitempty"` +} + // UpdateUser defines model for UpdateUser. type UpdateUser struct { Data *json.RawMessage `json:"data,omitempty"` @@ -854,6 +931,15 @@ type UpdateUserSubscriptions = []struct { SubscriptionId openapi_types.UUID `json:"subscription_id"` } +// UpsertOrganization defines model for UpsertOrganization. +type UpsertOrganization struct { + Data *map[string]any `json:"data,omitempty"` + + // ExternalId External identifier for the organization from your system + ExternalId string `json:"external_id"` + Name *string `json:"name,omitempty"` +} + // User defines model for User. type User struct { AnonymousId string `json:"anonymous_id"` @@ -1078,18 +1164,6 @@ type TagListResponse struct { Total int `json:"total"` } -// ListAdminsParams defines parameters for ListAdmins. -type ListAdminsParams struct { - // Limit Maximum number of items to return - Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"` - - // Offset Number of items to skip - Offset *Offset `form:"offset,omitempty" json:"offset,omitempty"` - - // Search Search query string - Search *Search `form:"search,omitempty" json:"search,omitempty"` -} - // ListProjectsParams defines parameters for ListProjects. type ListProjectsParams struct { // Limit Maximum number of items to return @@ -1207,25 +1281,25 @@ type ListProvidersParams struct { Offset *Offset `form:"offset,omitempty" json:"offset,omitempty"` } -// ListSubscriptionsParams defines parameters for ListSubscriptions. -type ListSubscriptionsParams struct { +// ListOrganizationsParams defines parameters for ListOrganizations. +type ListOrganizationsParams struct { // Limit Maximum number of items to return Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"` // Offset Number of items to skip Offset *Offset `form:"offset,omitempty" json:"offset,omitempty"` + + // Search Search query string + Search *Search `form:"search,omitempty" json:"search,omitempty"` } -// ListTagsParams defines parameters for ListTags. -type ListTagsParams struct { +// ListOrganizationMembersParams defines parameters for ListOrganizationMembers. +type ListOrganizationMembersParams struct { // Limit Maximum number of items to return Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"` // Offset Number of items to skip Offset *Offset `form:"offset,omitempty" json:"offset,omitempty"` - - // Search Search query string - Search *Search `form:"search,omitempty" json:"search,omitempty"` } // ListUsersParams defines parameters for ListUsers. @@ -1273,21 +1347,45 @@ type GetUserSubscriptionsParams struct { Offset *Offset `form:"offset,omitempty" json:"offset,omitempty"` } +// ListSubscriptionsParams defines parameters for ListSubscriptions. +type ListSubscriptionsParams struct { + // Limit Maximum number of items to return + Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"` + + // Offset Number of items to skip + Offset *Offset `form:"offset,omitempty" json:"offset,omitempty"` +} + +// ListTagsParams defines parameters for ListTags. +type ListTagsParams struct { + // Limit Maximum number of items to return + Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"` + + // Offset Number of items to skip + Offset *Offset `form:"offset,omitempty" json:"offset,omitempty"` + + // Search Search query string + Search *Search `form:"search,omitempty" json:"search,omitempty"` +} + +// ListAdminsParams defines parameters for ListAdmins. +type ListAdminsParams struct { + // Limit Maximum number of items to return + Limit *Limit `form:"limit,omitempty" json:"limit,omitempty"` + + // Offset Number of items to skip + Offset *Offset `form:"offset,omitempty" json:"offset,omitempty"` + + // Search Search query string + Search *Search `form:"search,omitempty" json:"search,omitempty"` +} + // AuthCallbackParamsDriver defines parameters for AuthCallback. type AuthCallbackParamsDriver string // AuthWebhookParamsDriver defines parameters for AuthWebhook. type AuthWebhookParamsDriver string -// UpdateOrganizationJSONRequestBody defines body for UpdateOrganization for application/json ContentType. -type UpdateOrganizationJSONRequestBody = UpdateOrganization - -// CreateAdminJSONRequestBody defines body for CreateAdmin for application/json ContentType. -type CreateAdminJSONRequestBody = CreateAdmin - -// UpdateAdminJSONRequestBody defines body for UpdateAdmin for application/json ContentType. -type UpdateAdminJSONRequestBody = UpdateAdmin - // CreateProjectJSONRequestBody defines body for CreateProject for application/json ContentType. type CreateProjectJSONRequestBody = CreateProject @@ -1345,17 +1443,14 @@ type CreateProviderJSONRequestBody = CreateProvider // UpdateProviderJSONRequestBody defines body for UpdateProvider for application/json ContentType. type UpdateProviderJSONRequestBody = UpdateProvider -// CreateSubscriptionJSONRequestBody defines body for CreateSubscription for application/json ContentType. -type CreateSubscriptionJSONRequestBody = CreateSubscription - -// UpdateSubscriptionJSONRequestBody defines body for UpdateSubscription for application/json ContentType. -type UpdateSubscriptionJSONRequestBody = UpdateSubscription +// UpsertOrganizationJSONRequestBody defines body for UpsertOrganization for application/json ContentType. +type UpsertOrganizationJSONRequestBody = UpsertOrganization -// CreateTagJSONRequestBody defines body for CreateTag for application/json ContentType. -type CreateTagJSONRequestBody = CreateTag +// UpdateOrganizationJSONRequestBody defines body for UpdateOrganization for application/json ContentType. +type UpdateOrganizationJSONRequestBody = UpdateOrganization -// UpdateTagJSONRequestBody defines body for UpdateTag for application/json ContentType. -type UpdateTagJSONRequestBody = UpdateTag +// AddOrganizationMemberJSONRequestBody defines body for AddOrganizationMember for application/json ContentType. +type AddOrganizationMemberJSONRequestBody = AddOrganizationMember // IdentifyUserJSONRequestBody defines body for IdentifyUser for application/json ContentType. type IdentifyUserJSONRequestBody = IdentifyUser @@ -1369,6 +1464,27 @@ type UpdateUserJSONRequestBody = UpdateUser // UpdateUserSubscriptionsJSONRequestBody defines body for UpdateUserSubscriptions for application/json ContentType. type UpdateUserSubscriptionsJSONRequestBody = UpdateUserSubscriptions +// CreateSubscriptionJSONRequestBody defines body for CreateSubscription for application/json ContentType. +type CreateSubscriptionJSONRequestBody = CreateSubscription + +// UpdateSubscriptionJSONRequestBody defines body for UpdateSubscription for application/json ContentType. +type UpdateSubscriptionJSONRequestBody = UpdateSubscription + +// CreateTagJSONRequestBody defines body for CreateTag for application/json ContentType. +type CreateTagJSONRequestBody = CreateTag + +// UpdateTagJSONRequestBody defines body for UpdateTag for application/json ContentType. +type UpdateTagJSONRequestBody = UpdateTag + +// UpdateTenantJSONRequestBody defines body for UpdateTenant for application/json ContentType. +type UpdateTenantJSONRequestBody = UpdateTenant + +// CreateAdminJSONRequestBody defines body for CreateAdmin for application/json ContentType. +type CreateAdminJSONRequestBody = CreateAdmin + +// UpdateAdminJSONRequestBody defines body for UpdateAdmin for application/json ContentType. +type UpdateAdminJSONRequestBody = UpdateAdmin + // AuthCallbackJSONRequestBody defines body for AuthCallback for application/json ContentType. type AuthCallbackJSONRequestBody = AuthCallbackRequest @@ -1625,42 +1741,6 @@ func WithRequestEditorFn(fn RequestEditorFn) ClientOption { // The interface specification for the client above. type ClientInterface interface { - // DeleteOrganization request - DeleteOrganization(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetOrganization request - GetOrganization(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) - - // UpdateOrganizationWithBody request with any body - UpdateOrganizationWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - UpdateOrganization(ctx context.Context, body UpdateOrganizationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // ListAdmins request - ListAdmins(ctx context.Context, params *ListAdminsParams, reqEditors ...RequestEditorFn) (*http.Response, error) - - // CreateAdminWithBody request with any body - CreateAdminWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - CreateAdmin(ctx context.Context, body CreateAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // DeleteAdmin request - DeleteAdmin(ctx context.Context, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetAdmin request - GetAdmin(ctx context.Context, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) - - // UpdateAdminWithBody request with any body - UpdateAdminWithBody(ctx context.Context, adminID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - - UpdateAdmin(ctx context.Context, adminID openapi_types.UUID, body UpdateAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - - // GetOrganizationIntegrations request - GetOrganizationIntegrations(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) - - // Whoami request - Whoami(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) - // GetProfile request GetProfile(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1750,9 +1830,6 @@ type ClientInterface interface { // GetDocumentMetadata request GetDocumentMetadata(ctx context.Context, projectID openapi_types.UUID, documentID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) - // ListEvents request - ListEvents(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) - // ListJourneys request ListJourneys(ctx context.Context, projectID openapi_types.UUID, params *ListJourneysParams, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1875,40 +1952,44 @@ type ClientInterface interface { // DeleteProvider request DeleteProvider(ctx context.Context, projectID openapi_types.UUID, providerID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) - // ListSubscriptions request - ListSubscriptions(ctx context.Context, projectID openapi_types.UUID, params *ListSubscriptionsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + // ListEvents request + ListEvents(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) - // CreateSubscriptionWithBody request with any body - CreateSubscriptionWithBody(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + // ListOrganizations request + ListOrganizations(ctx context.Context, projectID openapi_types.UUID, params *ListOrganizationsParams, reqEditors ...RequestEditorFn) (*http.Response, error) - CreateSubscription(ctx context.Context, projectID openapi_types.UUID, body CreateSubscriptionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // UpsertOrganizationWithBody request with any body + UpsertOrganizationWithBody(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - // GetSubscription request - GetSubscription(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) + UpsertOrganization(ctx context.Context, projectID openapi_types.UUID, body UpsertOrganizationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - // UpdateSubscriptionWithBody request with any body - UpdateSubscriptionWithBody(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + // ListOrganizationSchemas request + ListOrganizationSchemas(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) - UpdateSubscription(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, body UpdateSubscriptionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // ListOrganizationMemberSchemas request + ListOrganizationMemberSchemas(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) - // ListTags request - ListTags(ctx context.Context, projectID openapi_types.UUID, params *ListTagsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + // DeleteOrganization request + DeleteOrganization(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) - // CreateTagWithBody request with any body - CreateTagWithBody(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetOrganization request + GetOrganization(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) - CreateTag(ctx context.Context, projectID openapi_types.UUID, body CreateTagJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // UpdateOrganizationWithBody request with any body + UpdateOrganizationWithBody(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - // DeleteTag request - DeleteTag(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) + UpdateOrganization(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, body UpdateOrganizationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - // GetTag request - GetTag(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) + // ListOrganizationMembers request + ListOrganizationMembers(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, params *ListOrganizationMembersParams, reqEditors ...RequestEditorFn) (*http.Response, error) - // UpdateTagWithBody request with any body - UpdateTagWithBody(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + // AddOrganizationMemberWithBody request with any body + AddOrganizationMemberWithBody(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - UpdateTag(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, body UpdateTagJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + AddOrganizationMember(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, body AddOrganizationMemberJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // RemoveOrganizationMember request + RemoveOrganizationMember(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) // ListUsers request ListUsers(ctx context.Context, projectID openapi_types.UUID, params *ListUsersParams, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1941,6 +2022,9 @@ type ClientInterface interface { // GetUserJourneys request GetUserJourneys(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, params *GetUserJourneysParams, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetUserOrganizations request + GetUserOrganizations(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) + // GetUserSubscriptions request GetUserSubscriptions(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, params *GetUserSubscriptionsParams, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -1949,172 +2033,87 @@ type ClientInterface interface { UpdateUserSubscriptions(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, body UpdateUserSubscriptionsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - // AuthCallbackWithBody request with any body - AuthCallbackWithBody(ctx context.Context, driver AuthCallbackParamsDriver, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + // ListSubscriptions request + ListSubscriptions(ctx context.Context, projectID openapi_types.UUID, params *ListSubscriptionsParams, reqEditors ...RequestEditorFn) (*http.Response, error) - AuthCallback(ctx context.Context, driver AuthCallbackParamsDriver, body AuthCallbackJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // CreateSubscriptionWithBody request with any body + CreateSubscriptionWithBody(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) - // GetAuthMethods request - GetAuthMethods(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + CreateSubscription(ctx context.Context, projectID openapi_types.UUID, body CreateSubscriptionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) - // AuthWebhook request - AuthWebhook(ctx context.Context, driver AuthWebhookParamsDriver, reqEditors ...RequestEditorFn) (*http.Response, error) -} + // GetSubscription request + GetSubscription(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) -func (c *Client) DeleteOrganization(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteOrganizationRequest(c.Server) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} + // UpdateSubscriptionWithBody request with any body + UpdateSubscriptionWithBody(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) -func (c *Client) GetOrganization(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetOrganizationRequest(c.Server) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} + UpdateSubscription(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, body UpdateSubscriptionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) -func (c *Client) UpdateOrganizationWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUpdateOrganizationRequestWithBody(c.Server, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} + // ListTags request + ListTags(ctx context.Context, projectID openapi_types.UUID, params *ListTagsParams, reqEditors ...RequestEditorFn) (*http.Response, error) -func (c *Client) UpdateOrganization(ctx context.Context, body UpdateOrganizationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUpdateOrganizationRequest(c.Server, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} + // CreateTagWithBody request with any body + CreateTagWithBody(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) -func (c *Client) ListAdmins(ctx context.Context, params *ListAdminsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewListAdminsRequest(c.Server, params) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} + CreateTag(ctx context.Context, projectID openapi_types.UUID, body CreateTagJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) -func (c *Client) CreateAdminWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateAdminRequestWithBody(c.Server, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} + // DeleteTag request + DeleteTag(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) -func (c *Client) CreateAdmin(ctx context.Context, body CreateAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateAdminRequest(c.Server, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} + // GetTag request + GetTag(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) -func (c *Client) DeleteAdmin(ctx context.Context, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteAdminRequest(c.Server, adminID) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} + // UpdateTagWithBody request with any body + UpdateTagWithBody(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) -func (c *Client) GetAdmin(ctx context.Context, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetAdminRequest(c.Server, adminID) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} + UpdateTag(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, body UpdateTagJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) -func (c *Client) UpdateAdminWithBody(ctx context.Context, adminID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUpdateAdminRequestWithBody(c.Server, adminID, contentType, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} + // DeleteTenant request + DeleteTenant(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) -func (c *Client) UpdateAdmin(ctx context.Context, adminID openapi_types.UUID, body UpdateAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUpdateAdminRequest(c.Server, adminID, body) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} + // GetTenant request + GetTenant(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) -func (c *Client) GetOrganizationIntegrations(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetOrganizationIntegrationsRequest(c.Server) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} + // UpdateTenantWithBody request with any body + UpdateTenantWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) -func (c *Client) Whoami(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewWhoamiRequest(c.Server) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) + UpdateTenant(ctx context.Context, body UpdateTenantJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // ListAdmins request + ListAdmins(ctx context.Context, params *ListAdminsParams, reqEditors ...RequestEditorFn) (*http.Response, error) + + // CreateAdminWithBody request with any body + CreateAdminWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + CreateAdmin(ctx context.Context, body CreateAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // DeleteAdmin request + DeleteAdmin(ctx context.Context, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetAdmin request + GetAdmin(ctx context.Context, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) + + // UpdateAdminWithBody request with any body + UpdateAdminWithBody(ctx context.Context, adminID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + UpdateAdmin(ctx context.Context, adminID openapi_types.UUID, body UpdateAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetTenantIntegrations request + GetTenantIntegrations(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // Whoami request + Whoami(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AuthCallbackWithBody request with any body + AuthCallbackWithBody(ctx context.Context, driver AuthCallbackParamsDriver, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) + + AuthCallback(ctx context.Context, driver AuthCallbackParamsDriver, body AuthCallbackJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + + // GetAuthMethods request + GetAuthMethods(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) + + // AuthWebhook request + AuthWebhook(ctx context.Context, driver AuthWebhookParamsDriver, reqEditors ...RequestEditorFn) (*http.Response, error) } func (c *Client) GetProfile(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { @@ -2501,18 +2500,6 @@ func (c *Client) GetDocumentMetadata(ctx context.Context, projectID openapi_type return c.Client.Do(req) } -func (c *Client) ListEvents(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewListEventsRequest(c.Server, projectID) - if err != nil { - return nil, err - } - req = req.WithContext(ctx) - if err := c.applyEditors(ctx, req, reqEditors); err != nil { - return nil, err - } - return c.Client.Do(req) -} - func (c *Client) ListJourneys(ctx context.Context, projectID openapi_types.UUID, params *ListJourneysParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewListJourneysRequest(c.Server, projectID, params) if err != nil { @@ -3041,8 +3028,8 @@ func (c *Client) DeleteProvider(ctx context.Context, projectID openapi_types.UUI return c.Client.Do(req) } -func (c *Client) ListSubscriptions(ctx context.Context, projectID openapi_types.UUID, params *ListSubscriptionsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewListSubscriptionsRequest(c.Server, projectID, params) +func (c *Client) ListEvents(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListEventsRequest(c.Server, projectID) if err != nil { return nil, err } @@ -3053,8 +3040,8 @@ func (c *Client) ListSubscriptions(ctx context.Context, projectID openapi_types. return c.Client.Do(req) } -func (c *Client) CreateSubscriptionWithBody(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateSubscriptionRequestWithBody(c.Server, projectID, contentType, body) +func (c *Client) ListOrganizations(ctx context.Context, projectID openapi_types.UUID, params *ListOrganizationsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListOrganizationsRequest(c.Server, projectID, params) if err != nil { return nil, err } @@ -3065,8 +3052,8 @@ func (c *Client) CreateSubscriptionWithBody(ctx context.Context, projectID opena return c.Client.Do(req) } -func (c *Client) CreateSubscription(ctx context.Context, projectID openapi_types.UUID, body CreateSubscriptionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateSubscriptionRequest(c.Server, projectID, body) +func (c *Client) UpsertOrganizationWithBody(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpsertOrganizationRequestWithBody(c.Server, projectID, contentType, body) if err != nil { return nil, err } @@ -3077,8 +3064,8 @@ func (c *Client) CreateSubscription(ctx context.Context, projectID openapi_types return c.Client.Do(req) } -func (c *Client) GetSubscription(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetSubscriptionRequest(c.Server, projectID, subscriptionID) +func (c *Client) UpsertOrganization(ctx context.Context, projectID openapi_types.UUID, body UpsertOrganizationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpsertOrganizationRequest(c.Server, projectID, body) if err != nil { return nil, err } @@ -3089,8 +3076,8 @@ func (c *Client) GetSubscription(ctx context.Context, projectID openapi_types.UU return c.Client.Do(req) } -func (c *Client) UpdateSubscriptionWithBody(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUpdateSubscriptionRequestWithBody(c.Server, projectID, subscriptionID, contentType, body) +func (c *Client) ListOrganizationSchemas(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListOrganizationSchemasRequest(c.Server, projectID) if err != nil { return nil, err } @@ -3101,8 +3088,8 @@ func (c *Client) UpdateSubscriptionWithBody(ctx context.Context, projectID opena return c.Client.Do(req) } -func (c *Client) UpdateSubscription(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, body UpdateSubscriptionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUpdateSubscriptionRequest(c.Server, projectID, subscriptionID, body) +func (c *Client) ListOrganizationMemberSchemas(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListOrganizationMemberSchemasRequest(c.Server, projectID) if err != nil { return nil, err } @@ -3113,8 +3100,8 @@ func (c *Client) UpdateSubscription(ctx context.Context, projectID openapi_types return c.Client.Do(req) } -func (c *Client) ListTags(ctx context.Context, projectID openapi_types.UUID, params *ListTagsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewListTagsRequest(c.Server, projectID, params) +func (c *Client) DeleteOrganization(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteOrganizationRequest(c.Server, projectID, organizationID) if err != nil { return nil, err } @@ -3125,8 +3112,8 @@ func (c *Client) ListTags(ctx context.Context, projectID openapi_types.UUID, par return c.Client.Do(req) } -func (c *Client) CreateTagWithBody(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateTagRequestWithBody(c.Server, projectID, contentType, body) +func (c *Client) GetOrganization(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetOrganizationRequest(c.Server, projectID, organizationID) if err != nil { return nil, err } @@ -3137,8 +3124,8 @@ func (c *Client) CreateTagWithBody(ctx context.Context, projectID openapi_types. return c.Client.Do(req) } -func (c *Client) CreateTag(ctx context.Context, projectID openapi_types.UUID, body CreateTagJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewCreateTagRequest(c.Server, projectID, body) +func (c *Client) UpdateOrganizationWithBody(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateOrganizationRequestWithBody(c.Server, projectID, organizationID, contentType, body) if err != nil { return nil, err } @@ -3149,8 +3136,8 @@ func (c *Client) CreateTag(ctx context.Context, projectID openapi_types.UUID, bo return c.Client.Do(req) } -func (c *Client) DeleteTag(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewDeleteTagRequest(c.Server, projectID, tagID) +func (c *Client) UpdateOrganization(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, body UpdateOrganizationJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateOrganizationRequest(c.Server, projectID, organizationID, body) if err != nil { return nil, err } @@ -3161,8 +3148,8 @@ func (c *Client) DeleteTag(ctx context.Context, projectID openapi_types.UUID, ta return c.Client.Do(req) } -func (c *Client) GetTag(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetTagRequest(c.Server, projectID, tagID) +func (c *Client) ListOrganizationMembers(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, params *ListOrganizationMembersParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListOrganizationMembersRequest(c.Server, projectID, organizationID, params) if err != nil { return nil, err } @@ -3173,8 +3160,8 @@ func (c *Client) GetTag(ctx context.Context, projectID openapi_types.UUID, tagID return c.Client.Do(req) } -func (c *Client) UpdateTagWithBody(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUpdateTagRequestWithBody(c.Server, projectID, tagID, contentType, body) +func (c *Client) AddOrganizationMemberWithBody(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAddOrganizationMemberRequestWithBody(c.Server, projectID, organizationID, contentType, body) if err != nil { return nil, err } @@ -3185,8 +3172,20 @@ func (c *Client) UpdateTagWithBody(ctx context.Context, projectID openapi_types. return c.Client.Do(req) } -func (c *Client) UpdateTag(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, body UpdateTagJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewUpdateTagRequest(c.Server, projectID, tagID, body) +func (c *Client) AddOrganizationMember(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, body AddOrganizationMemberJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAddOrganizationMemberRequest(c.Server, projectID, organizationID, body) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + +func (c *Client) RemoveOrganizationMember(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewRemoveOrganizationMemberRequest(c.Server, projectID, organizationID, userID) if err != nil { return nil, err } @@ -3329,6 +3328,18 @@ func (c *Client) GetUserJourneys(ctx context.Context, projectID openapi_types.UU return c.Client.Do(req) } +func (c *Client) GetUserOrganizations(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetUserOrganizationsRequest(c.Server, projectID, userID) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) GetUserSubscriptions(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, params *GetUserSubscriptionsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewGetUserSubscriptionsRequest(c.Server, projectID, userID, params) if err != nil { @@ -3365,8 +3376,8 @@ func (c *Client) UpdateUserSubscriptions(ctx context.Context, projectID openapi_ return c.Client.Do(req) } -func (c *Client) AuthCallbackWithBody(ctx context.Context, driver AuthCallbackParamsDriver, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewAuthCallbackRequestWithBody(c.Server, driver, contentType, body) +func (c *Client) ListSubscriptions(ctx context.Context, projectID openapi_types.UUID, params *ListSubscriptionsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListSubscriptionsRequest(c.Server, projectID, params) if err != nil { return nil, err } @@ -3377,8 +3388,8 @@ func (c *Client) AuthCallbackWithBody(ctx context.Context, driver AuthCallbackPa return c.Client.Do(req) } -func (c *Client) AuthCallback(ctx context.Context, driver AuthCallbackParamsDriver, body AuthCallbackJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewAuthCallbackRequest(c.Server, driver, body) +func (c *Client) CreateSubscriptionWithBody(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateSubscriptionRequestWithBody(c.Server, projectID, contentType, body) if err != nil { return nil, err } @@ -3389,8 +3400,8 @@ func (c *Client) AuthCallback(ctx context.Context, driver AuthCallbackParamsDriv return c.Client.Do(req) } -func (c *Client) GetAuthMethods(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewGetAuthMethodsRequest(c.Server) +func (c *Client) CreateSubscription(ctx context.Context, projectID openapi_types.UUID, body CreateSubscriptionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateSubscriptionRequest(c.Server, projectID, body) if err != nil { return nil, err } @@ -3401,8 +3412,8 @@ func (c *Client) GetAuthMethods(ctx context.Context, reqEditors ...RequestEditor return c.Client.Do(req) } -func (c *Client) AuthWebhook(ctx context.Context, driver AuthWebhookParamsDriver, reqEditors ...RequestEditorFn) (*http.Response, error) { - req, err := NewAuthWebhookRequest(c.Server, driver) +func (c *Client) GetSubscription(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetSubscriptionRequest(c.Server, projectID, subscriptionID) if err != nil { return nil, err } @@ -3413,388 +3424,316 @@ func (c *Client) AuthWebhook(ctx context.Context, driver AuthWebhookParamsDriver return c.Client.Do(req) } -// NewDeleteOrganizationRequest generates requests for DeleteOrganization -func NewDeleteOrganizationRequest(server string) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) +func (c *Client) UpdateSubscriptionWithBody(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateSubscriptionRequestWithBody(c.Server, projectID, subscriptionID, contentType, body) if err != nil { return nil, err } - - operationPath := fmt.Sprintf("/api/admin/organizations") - if operationPath[0] == '/' { - operationPath = "." + operationPath + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err } + return c.Client.Do(req) +} - queryURL, err := serverURL.Parse(operationPath) +func (c *Client) UpdateSubscription(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, body UpdateSubscriptionJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateSubscriptionRequest(c.Server, projectID, subscriptionID, body) if err != nil { return nil, err } - - req, err := http.NewRequest("DELETE", queryURL.String(), nil) - if err != nil { + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } - - return req, nil + return c.Client.Do(req) } -// NewGetOrganizationRequest generates requests for GetOrganization -func NewGetOrganizationRequest(server string) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) +func (c *Client) ListTags(ctx context.Context, projectID openapi_types.UUID, params *ListTagsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListTagsRequest(c.Server, projectID, params) if err != nil { return nil, err } - - operationPath := fmt.Sprintf("/api/admin/organizations") - if operationPath[0] == '/' { - operationPath = "." + operationPath + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err } + return c.Client.Do(req) +} - queryURL, err := serverURL.Parse(operationPath) +func (c *Client) CreateTagWithBody(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateTagRequestWithBody(c.Server, projectID, contentType, body) if err != nil { return nil, err } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } - - return req, nil + return c.Client.Do(req) } -// NewUpdateOrganizationRequest calls the generic UpdateOrganization builder with application/json body -func NewUpdateOrganizationRequest(server string, body UpdateOrganizationJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) +func (c *Client) CreateTag(ctx context.Context, projectID openapi_types.UUID, body CreateTagJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateTagRequest(c.Server, projectID, body) if err != nil { return nil, err } - bodyReader = bytes.NewReader(buf) - return NewUpdateOrganizationRequestWithBody(server, "application/json", bodyReader) + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) } -// NewUpdateOrganizationRequestWithBody generates requests for UpdateOrganization with any type of body -func NewUpdateOrganizationRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) +func (c *Client) DeleteTag(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteTagRequest(c.Server, projectID, tagID) if err != nil { return nil, err } - - operationPath := fmt.Sprintf("/api/admin/organizations") - if operationPath[0] == '/' { - operationPath = "." + operationPath + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err } + return c.Client.Do(req) +} - queryURL, err := serverURL.Parse(operationPath) +func (c *Client) GetTag(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetTagRequest(c.Server, projectID, tagID) if err != nil { return nil, err } - - req, err := http.NewRequest("PATCH", queryURL.String(), body) - if err != nil { + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } - - req.Header.Add("Content-Type", contentType) - - return req, nil + return c.Client.Do(req) } -// NewListAdminsRequest generates requests for ListAdmins -func NewListAdminsRequest(server string, params *ListAdminsParams) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) +func (c *Client) UpdateTagWithBody(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateTagRequestWithBody(c.Server, projectID, tagID, contentType, body) if err != nil { return nil, err } - - operationPath := fmt.Sprintf("/api/admin/organizations/admins") - if operationPath[0] == '/' { - operationPath = "." + operationPath + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err } + return c.Client.Do(req) +} - queryURL, err := serverURL.Parse(operationPath) +func (c *Client) UpdateTag(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, body UpdateTagJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateTagRequest(c.Server, projectID, tagID, body) if err != nil { return nil, err } - - if params != nil { - queryValues := queryURL.Query() - - if params.Limit != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - if params.Offset != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "offset", runtime.ParamLocationQuery, *params.Offset); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - if params.Search != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "search", runtime.ParamLocationQuery, *params.Search); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } - - return req, nil + return c.Client.Do(req) } -// NewCreateAdminRequest calls the generic CreateAdmin builder with application/json body -func NewCreateAdminRequest(server string, body CreateAdminJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) +func (c *Client) DeleteTenant(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteTenantRequest(c.Server) if err != nil { return nil, err } - bodyReader = bytes.NewReader(buf) - return NewCreateAdminRequestWithBody(server, "application/json", bodyReader) + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) } -// NewCreateAdminRequestWithBody generates requests for CreateAdmin with any type of body -func NewCreateAdminRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) +func (c *Client) GetTenant(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetTenantRequest(c.Server) if err != nil { return nil, err } - - operationPath := fmt.Sprintf("/api/admin/organizations/admins") - if operationPath[0] == '/' { - operationPath = "." + operationPath + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err } + return c.Client.Do(req) +} - queryURL, err := serverURL.Parse(operationPath) +func (c *Client) UpdateTenantWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateTenantRequestWithBody(c.Server, contentType, body) if err != nil { return nil, err } - - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } - - req.Header.Add("Content-Type", contentType) - - return req, nil + return c.Client.Do(req) } -// NewDeleteAdminRequest generates requests for DeleteAdmin -func NewDeleteAdminRequest(server string, adminID openapi_types.UUID) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "adminID", runtime.ParamLocationPath, adminID) +func (c *Client) UpdateTenant(ctx context.Context, body UpdateTenantJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateTenantRequest(c.Server, body) if err != nil { return nil, err } - - serverURL, err := url.Parse(server) - if err != nil { + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } + return c.Client.Do(req) +} - operationPath := fmt.Sprintf("/api/admin/organizations/admins/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) +func (c *Client) ListAdmins(ctx context.Context, params *ListAdminsParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewListAdminsRequest(c.Server, params) if err != nil { return nil, err } - - req, err := http.NewRequest("DELETE", queryURL.String(), nil) - if err != nil { + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } - - return req, nil + return c.Client.Do(req) } -// NewGetAdminRequest generates requests for GetAdmin -func NewGetAdminRequest(server string, adminID openapi_types.UUID) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "adminID", runtime.ParamLocationPath, adminID) +func (c *Client) CreateAdminWithBody(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateAdminRequestWithBody(c.Server, contentType, body) if err != nil { return nil, err } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} - serverURL, err := url.Parse(server) +func (c *Client) CreateAdmin(ctx context.Context, body CreateAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewCreateAdminRequest(c.Server, body) if err != nil { return nil, err } - - operationPath := fmt.Sprintf("/api/admin/organizations/admins/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err } + return c.Client.Do(req) +} - queryURL, err := serverURL.Parse(operationPath) +func (c *Client) DeleteAdmin(ctx context.Context, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewDeleteAdminRequest(c.Server, adminID) if err != nil { return nil, err } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } - - return req, nil + return c.Client.Do(req) } -// NewUpdateAdminRequest calls the generic UpdateAdmin builder with application/json body -func NewUpdateAdminRequest(server string, adminID openapi_types.UUID, body UpdateAdminJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) +func (c *Client) GetAdmin(ctx context.Context, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetAdminRequest(c.Server, adminID) if err != nil { return nil, err } - bodyReader = bytes.NewReader(buf) - return NewUpdateAdminRequestWithBody(server, adminID, "application/json", bodyReader) + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) } -// NewUpdateAdminRequestWithBody generates requests for UpdateAdmin with any type of body -func NewUpdateAdminRequestWithBody(server string, adminID openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "adminID", runtime.ParamLocationPath, adminID) +func (c *Client) UpdateAdminWithBody(ctx context.Context, adminID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateAdminRequestWithBody(c.Server, adminID, contentType, body) if err != nil { return nil, err } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} - serverURL, err := url.Parse(server) +func (c *Client) UpdateAdmin(ctx context.Context, adminID openapi_types.UUID, body UpdateAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewUpdateAdminRequest(c.Server, adminID, body) if err != nil { return nil, err } - - operationPath := fmt.Sprintf("/api/admin/organizations/admins/%s", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err } + return c.Client.Do(req) +} - queryURL, err := serverURL.Parse(operationPath) +func (c *Client) GetTenantIntegrations(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetTenantIntegrationsRequest(c.Server) if err != nil { return nil, err } - - req, err := http.NewRequest("PATCH", queryURL.String(), body) - if err != nil { + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } - - req.Header.Add("Content-Type", contentType) - - return req, nil + return c.Client.Do(req) } -// NewGetOrganizationIntegrationsRequest generates requests for GetOrganizationIntegrations -func NewGetOrganizationIntegrationsRequest(server string) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) +func (c *Client) Whoami(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewWhoamiRequest(c.Server) if err != nil { return nil, err } - - operationPath := fmt.Sprintf("/api/admin/organizations/integrations") - if operationPath[0] == '/' { - operationPath = "." + operationPath + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err } + return c.Client.Do(req) +} - queryURL, err := serverURL.Parse(operationPath) +func (c *Client) AuthCallbackWithBody(ctx context.Context, driver AuthCallbackParamsDriver, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAuthCallbackRequestWithBody(c.Server, driver, contentType, body) if err != nil { return nil, err } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { return nil, err } - - return req, nil + return c.Client.Do(req) } -// NewWhoamiRequest generates requests for Whoami -func NewWhoamiRequest(server string) (*http.Request, error) { - var err error - - serverURL, err := url.Parse(server) +func (c *Client) AuthCallback(ctx context.Context, driver AuthCallbackParamsDriver, body AuthCallbackJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAuthCallbackRequest(c.Server, driver, body) if err != nil { return nil, err } - - operationPath := fmt.Sprintf("/api/admin/organizations/whoami") - if operationPath[0] == '/' { - operationPath = "." + operationPath + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err } + return c.Client.Do(req) +} - queryURL, err := serverURL.Parse(operationPath) +func (c *Client) GetAuthMethods(ctx context.Context, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewGetAuthMethodsRequest(c.Server) if err != nil { return nil, err } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} - req, err := http.NewRequest("GET", queryURL.String(), nil) +func (c *Client) AuthWebhook(ctx context.Context, driver AuthWebhookParamsDriver, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewAuthWebhookRequest(c.Server, driver) if err != nil { return nil, err } - - return req, nil + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) } // NewGetProfileRequest generates requests for GetProfile @@ -5067,40 +5006,6 @@ func NewGetDocumentMetadataRequest(server string, projectID openapi_types.UUID, return req, nil } -// NewListEventsRequest generates requests for ListEvents -func NewListEventsRequest(server string, projectID openapi_types.UUID) (*http.Request, error) { - var err error - - var pathParam0 string - - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectID", runtime.ParamLocationPath, projectID) - if err != nil { - return nil, err - } - - serverURL, err := url.Parse(server) - if err != nil { - return nil, err - } - - operationPath := fmt.Sprintf("/api/admin/projects/%s/events/schema", pathParam0) - if operationPath[0] == '/' { - operationPath = "." + operationPath - } - - queryURL, err := serverURL.Parse(operationPath) - if err != nil { - return nil, err - } - - req, err := http.NewRequest("GET", queryURL.String(), nil) - if err != nil { - return nil, err - } - - return req, nil -} - // NewListJourneysRequest generates requests for ListJourneys func NewListJourneysRequest(server string, projectID openapi_types.UUID, params *ListJourneysParams) (*http.Request, error) { var err error @@ -6813,8 +6718,8 @@ func NewDeleteProviderRequest(server string, projectID openapi_types.UUID, provi return req, nil } -// NewListSubscriptionsRequest generates requests for ListSubscriptions -func NewListSubscriptionsRequest(server string, projectID openapi_types.UUID, params *ListSubscriptionsParams) (*http.Request, error) { +// NewListEventsRequest generates requests for ListEvents +func NewListEventsRequest(server string, projectID openapi_types.UUID) (*http.Request, error) { var err error var pathParam0 string @@ -6829,7 +6734,41 @@ func NewListSubscriptionsRequest(server string, projectID openapi_types.UUID, pa return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/subscriptions", pathParam0) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/events/schema", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + +// NewListOrganizationsRequest generates requests for ListOrganizations +func NewListOrganizationsRequest(server string, projectID openapi_types.UUID, params *ListOrganizationsParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectID", runtime.ParamLocationPath, projectID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/organizations", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -6874,6 +6813,22 @@ func NewListSubscriptionsRequest(server string, projectID openapi_types.UUID, pa } + if params.Search != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "search", runtime.ParamLocationQuery, *params.Search); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + queryURL.RawQuery = queryValues.Encode() } @@ -6885,19 +6840,19 @@ func NewListSubscriptionsRequest(server string, projectID openapi_types.UUID, pa return req, nil } -// NewCreateSubscriptionRequest calls the generic CreateSubscription builder with application/json body -func NewCreateSubscriptionRequest(server string, projectID openapi_types.UUID, body CreateSubscriptionJSONRequestBody) (*http.Request, error) { +// NewUpsertOrganizationRequest calls the generic UpsertOrganization builder with application/json body +func NewUpsertOrganizationRequest(server string, projectID openapi_types.UUID, body UpsertOrganizationJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { return nil, err } bodyReader = bytes.NewReader(buf) - return NewCreateSubscriptionRequestWithBody(server, projectID, "application/json", bodyReader) + return NewUpsertOrganizationRequestWithBody(server, projectID, "application/json", bodyReader) } -// NewCreateSubscriptionRequestWithBody generates requests for CreateSubscription with any type of body -func NewCreateSubscriptionRequestWithBody(server string, projectID openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { +// NewUpsertOrganizationRequestWithBody generates requests for UpsertOrganization with any type of body +func NewUpsertOrganizationRequestWithBody(server string, projectID openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string @@ -6912,7 +6867,7 @@ func NewCreateSubscriptionRequestWithBody(server string, projectID openapi_types return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/subscriptions", pathParam0) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/organizations", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -6932,8 +6887,8 @@ func NewCreateSubscriptionRequestWithBody(server string, projectID openapi_types return req, nil } -// NewGetSubscriptionRequest generates requests for GetSubscription -func NewGetSubscriptionRequest(server string, projectID openapi_types.UUID, subscriptionID openapi_types.UUID) (*http.Request, error) { +// NewListOrganizationSchemasRequest generates requests for ListOrganizationSchemas +func NewListOrganizationSchemasRequest(server string, projectID openapi_types.UUID) (*http.Request, error) { var err error var pathParam0 string @@ -6943,19 +6898,12 @@ func NewGetSubscriptionRequest(server string, projectID openapi_types.UUID, subs return nil, err } - var pathParam1 string - - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "subscriptionID", runtime.ParamLocationPath, subscriptionID) - if err != nil { - return nil, err - } - serverURL, err := url.Parse(server) if err != nil { return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/subscriptions/%s", pathParam0, pathParam1) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/organizations/schema", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -6973,19 +6921,42 @@ func NewGetSubscriptionRequest(server string, projectID openapi_types.UUID, subs return req, nil } -// NewUpdateSubscriptionRequest calls the generic UpdateSubscription builder with application/json body -func NewUpdateSubscriptionRequest(server string, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, body UpdateSubscriptionJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) +// NewListOrganizationMemberSchemasRequest generates requests for ListOrganizationMemberSchemas +func NewListOrganizationMemberSchemasRequest(server string, projectID openapi_types.UUID) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectID", runtime.ParamLocationPath, projectID) if err != nil { return nil, err } - bodyReader = bytes.NewReader(buf) - return NewUpdateSubscriptionRequestWithBody(server, projectID, subscriptionID, "application/json", bodyReader) + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/organizations/users/schema", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil } -// NewUpdateSubscriptionRequestWithBody generates requests for UpdateSubscription with any type of body -func NewUpdateSubscriptionRequestWithBody(server string, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { +// NewDeleteOrganizationRequest generates requests for DeleteOrganization +func NewDeleteOrganizationRequest(server string, projectID openapi_types.UUID, organizationID openapi_types.UUID) (*http.Request, error) { var err error var pathParam0 string @@ -6997,7 +6968,7 @@ func NewUpdateSubscriptionRequestWithBody(server string, projectID openapi_types var pathParam1 string - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "subscriptionID", runtime.ParamLocationPath, subscriptionID) + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "organizationID", runtime.ParamLocationPath, organizationID) if err != nil { return nil, err } @@ -7007,7 +6978,7 @@ func NewUpdateSubscriptionRequestWithBody(server string, projectID openapi_types return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/subscriptions/%s", pathParam0, pathParam1) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/organizations/%s", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7017,18 +6988,16 @@ func NewUpdateSubscriptionRequestWithBody(server string, projectID openapi_types return nil, err } - req, err := http.NewRequest("PATCH", queryURL.String(), body) + req, err := http.NewRequest("DELETE", queryURL.String(), nil) if err != nil { return nil, err } - req.Header.Add("Content-Type", contentType) - return req, nil } -// NewListTagsRequest generates requests for ListTags -func NewListTagsRequest(server string, projectID openapi_types.UUID, params *ListTagsParams) (*http.Request, error) { +// NewGetOrganizationRequest generates requests for GetOrganization +func NewGetOrganizationRequest(server string, projectID openapi_types.UUID, organizationID openapi_types.UUID) (*http.Request, error) { var err error var pathParam0 string @@ -7038,12 +7007,19 @@ func NewListTagsRequest(server string, projectID openapi_types.UUID, params *Lis return nil, err } + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "organizationID", runtime.ParamLocationPath, organizationID) + if err != nil { + return nil, err + } + serverURL, err := url.Parse(server) if err != nil { return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/tags", pathParam0) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/organizations/%s", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7053,60 +7029,6 @@ func NewListTagsRequest(server string, projectID openapi_types.UUID, params *Lis return nil, err } - if params != nil { - queryValues := queryURL.Query() - - if params.Limit != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - if params.Offset != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "offset", runtime.ParamLocationQuery, *params.Offset); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - if params.Search != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "search", runtime.ParamLocationQuery, *params.Search); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - - queryURL.RawQuery = queryValues.Encode() - } - req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err @@ -7115,19 +7037,19 @@ func NewListTagsRequest(server string, projectID openapi_types.UUID, params *Lis return req, nil } -// NewCreateTagRequest calls the generic CreateTag builder with application/json body -func NewCreateTagRequest(server string, projectID openapi_types.UUID, body CreateTagJSONRequestBody) (*http.Request, error) { +// NewUpdateOrganizationRequest calls the generic UpdateOrganization builder with application/json body +func NewUpdateOrganizationRequest(server string, projectID openapi_types.UUID, organizationID openapi_types.UUID, body UpdateOrganizationJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader buf, err := json.Marshal(body) if err != nil { return nil, err } bodyReader = bytes.NewReader(buf) - return NewCreateTagRequestWithBody(server, projectID, "application/json", bodyReader) + return NewUpdateOrganizationRequestWithBody(server, projectID, organizationID, "application/json", bodyReader) } -// NewCreateTagRequestWithBody generates requests for CreateTag with any type of body -func NewCreateTagRequestWithBody(server string, projectID openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { +// NewUpdateOrganizationRequestWithBody generates requests for UpdateOrganization with any type of body +func NewUpdateOrganizationRequestWithBody(server string, projectID openapi_types.UUID, organizationID openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string @@ -7137,12 +7059,19 @@ func NewCreateTagRequestWithBody(server string, projectID openapi_types.UUID, co return nil, err } + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "organizationID", runtime.ParamLocationPath, organizationID) + if err != nil { + return nil, err + } + serverURL, err := url.Parse(server) if err != nil { return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/tags", pathParam0) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/organizations/%s", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7152,7 +7081,7 @@ func NewCreateTagRequestWithBody(server string, projectID openapi_types.UUID, co return nil, err } - req, err := http.NewRequest("POST", queryURL.String(), body) + req, err := http.NewRequest("PATCH", queryURL.String(), body) if err != nil { return nil, err } @@ -7162,8 +7091,8 @@ func NewCreateTagRequestWithBody(server string, projectID openapi_types.UUID, co return req, nil } -// NewDeleteTagRequest generates requests for DeleteTag -func NewDeleteTagRequest(server string, projectID openapi_types.UUID, tagID openapi_types.UUID) (*http.Request, error) { +// NewListOrganizationMembersRequest generates requests for ListOrganizationMembers +func NewListOrganizationMembersRequest(server string, projectID openapi_types.UUID, organizationID openapi_types.UUID, params *ListOrganizationMembersParams) (*http.Request, error) { var err error var pathParam0 string @@ -7175,7 +7104,7 @@ func NewDeleteTagRequest(server string, projectID openapi_types.UUID, tagID open var pathParam1 string - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "tagID", runtime.ParamLocationPath, tagID) + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "organizationID", runtime.ParamLocationPath, organizationID) if err != nil { return nil, err } @@ -7185,7 +7114,7 @@ func NewDeleteTagRequest(server string, projectID openapi_types.UUID, tagID open return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/tags/%s", pathParam0, pathParam1) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/organizations/%s/users", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7195,7 +7124,45 @@ func NewDeleteTagRequest(server string, projectID openapi_types.UUID, tagID open return nil, err } - req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if params != nil { + queryValues := queryURL.Query() + + if params.Limit != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + if params.Offset != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "offset", runtime.ParamLocationQuery, *params.Offset); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } @@ -7203,8 +7170,19 @@ func NewDeleteTagRequest(server string, projectID openapi_types.UUID, tagID open return req, nil } -// NewGetTagRequest generates requests for GetTag -func NewGetTagRequest(server string, projectID openapi_types.UUID, tagID openapi_types.UUID) (*http.Request, error) { +// NewAddOrganizationMemberRequest calls the generic AddOrganizationMember builder with application/json body +func NewAddOrganizationMemberRequest(server string, projectID openapi_types.UUID, organizationID openapi_types.UUID, body AddOrganizationMemberJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewAddOrganizationMemberRequestWithBody(server, projectID, organizationID, "application/json", bodyReader) +} + +// NewAddOrganizationMemberRequestWithBody generates requests for AddOrganizationMember with any type of body +func NewAddOrganizationMemberRequestWithBody(server string, projectID openapi_types.UUID, organizationID openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { var err error var pathParam0 string @@ -7216,7 +7194,7 @@ func NewGetTagRequest(server string, projectID openapi_types.UUID, tagID openapi var pathParam1 string - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "tagID", runtime.ParamLocationPath, tagID) + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "organizationID", runtime.ParamLocationPath, organizationID) if err != nil { return nil, err } @@ -7226,7 +7204,7 @@ func NewGetTagRequest(server string, projectID openapi_types.UUID, tagID openapi return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/tags/%s", pathParam0, pathParam1) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/organizations/%s/users", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7236,27 +7214,18 @@ func NewGetTagRequest(server string, projectID openapi_types.UUID, tagID openapi return nil, err } - req, err := http.NewRequest("GET", queryURL.String(), nil) + req, err := http.NewRequest("POST", queryURL.String(), body) if err != nil { return nil, err } - return req, nil -} + req.Header.Add("Content-Type", contentType) -// NewUpdateTagRequest calls the generic UpdateTag builder with application/json body -func NewUpdateTagRequest(server string, projectID openapi_types.UUID, tagID openapi_types.UUID, body UpdateTagJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewUpdateTagRequestWithBody(server, projectID, tagID, "application/json", bodyReader) + return req, nil } -// NewUpdateTagRequestWithBody generates requests for UpdateTag with any type of body -func NewUpdateTagRequestWithBody(server string, projectID openapi_types.UUID, tagID openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { +// NewRemoveOrganizationMemberRequest generates requests for RemoveOrganizationMember +func NewRemoveOrganizationMemberRequest(server string, projectID openapi_types.UUID, organizationID openapi_types.UUID, userID openapi_types.UUID) (*http.Request, error) { var err error var pathParam0 string @@ -7268,7 +7237,14 @@ func NewUpdateTagRequestWithBody(server string, projectID openapi_types.UUID, ta var pathParam1 string - pathParam1, err = runtime.StyleParamWithLocation("simple", false, "tagID", runtime.ParamLocationPath, tagID) + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "organizationID", runtime.ParamLocationPath, organizationID) + if err != nil { + return nil, err + } + + var pathParam2 string + + pathParam2, err = runtime.StyleParamWithLocation("simple", false, "userID", runtime.ParamLocationPath, userID) if err != nil { return nil, err } @@ -7278,7 +7254,7 @@ func NewUpdateTagRequestWithBody(server string, projectID openapi_types.UUID, ta return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/tags/%s", pathParam0, pathParam1) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/organizations/%s/users/%s", pathParam0, pathParam1, pathParam2) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7288,13 +7264,11 @@ func NewUpdateTagRequestWithBody(server string, projectID openapi_types.UUID, ta return nil, err } - req, err := http.NewRequest("PATCH", queryURL.String(), body) + req, err := http.NewRequest("DELETE", queryURL.String(), nil) if err != nil { return nil, err } - req.Header.Add("Content-Type", contentType) - return req, nil } @@ -7314,7 +7288,7 @@ func NewListUsersRequest(server string, projectID openapi_types.UUID, params *Li return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/users", pathParam0) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/users", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7413,7 +7387,7 @@ func NewIdentifyUserRequestWithBody(server string, projectID openapi_types.UUID, return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/users", pathParam0) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/users", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7449,7 +7423,7 @@ func NewImportUsersRequestWithBody(server string, projectID openapi_types.UUID, return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/users/import", pathParam0) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/users/import", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7485,7 +7459,7 @@ func NewListUserSchemasRequest(server string, projectID openapi_types.UUID) (*ht return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/users/schema", pathParam0) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/users/schema", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7526,7 +7500,7 @@ func NewDeleteUserRequest(server string, projectID openapi_types.UUID, userID op return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/users/%s", pathParam0, pathParam1) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/users/%s", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7567,7 +7541,7 @@ func NewGetUserRequest(server string, projectID openapi_types.UUID, userID opena return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/users/%s", pathParam0, pathParam1) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/users/%s", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7619,7 +7593,7 @@ func NewUpdateUserRequestWithBody(server string, projectID openapi_types.UUID, u return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/users/%s", pathParam0, pathParam1) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/users/%s", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7662,7 +7636,7 @@ func NewGetUserEventsRequest(server string, projectID openapi_types.UUID, userID return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/users/%s/events", pathParam0, pathParam1) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/users/%s/events", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7741,7 +7715,7 @@ func NewGetUserJourneysRequest(server string, projectID openapi_types.UUID, user return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/users/%s/journeys", pathParam0, pathParam1) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/users/%s/journeys", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7797,6 +7771,47 @@ func NewGetUserJourneysRequest(server string, projectID openapi_types.UUID, user return req, nil } +// NewGetUserOrganizationsRequest generates requests for GetUserOrganizations +func NewGetUserOrganizationsRequest(server string, projectID openapi_types.UUID, userID openapi_types.UUID) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectID", runtime.ParamLocationPath, projectID) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "userID", runtime.ParamLocationPath, userID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/users/%s/subject-organizations", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + // NewGetUserSubscriptionsRequest generates requests for GetUserSubscriptions func NewGetUserSubscriptionsRequest(server string, projectID openapi_types.UUID, userID openapi_types.UUID, params *GetUserSubscriptionsParams) (*http.Request, error) { var err error @@ -7820,7 +7835,7 @@ func NewGetUserSubscriptionsRequest(server string, projectID openapi_types.UUID, return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/users/%s/subscriptions", pathParam0, pathParam1) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/users/%s/subscriptions", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7910,7 +7925,7 @@ func NewUpdateUserSubscriptionsRequestWithBody(server string, projectID openapi_ return nil, err } - operationPath := fmt.Sprintf("/api/admin/projects/%s/users/%s/subscriptions", pathParam0, pathParam1) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subjects/users/%s/subscriptions", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7930,24 +7945,13 @@ func NewUpdateUserSubscriptionsRequestWithBody(server string, projectID openapi_ return req, nil } -// NewAuthCallbackRequest calls the generic AuthCallback builder with application/json body -func NewAuthCallbackRequest(server string, driver AuthCallbackParamsDriver, body AuthCallbackJSONRequestBody) (*http.Request, error) { - var bodyReader io.Reader - buf, err := json.Marshal(body) - if err != nil { - return nil, err - } - bodyReader = bytes.NewReader(buf) - return NewAuthCallbackRequestWithBody(server, driver, "application/json", bodyReader) -} - -// NewAuthCallbackRequestWithBody generates requests for AuthCallback with any type of body -func NewAuthCallbackRequestWithBody(server string, driver AuthCallbackParamsDriver, contentType string, body io.Reader) (*http.Request, error) { +// NewListSubscriptionsRequest generates requests for ListSubscriptions +func NewListSubscriptionsRequest(server string, projectID openapi_types.UUID, params *ListSubscriptionsParams) (*http.Request, error) { var err error var pathParam0 string - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "driver", runtime.ParamLocationPath, driver) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectID", runtime.ParamLocationPath, projectID) if err != nil { return nil, err } @@ -7957,7 +7961,7 @@ func NewAuthCallbackRequestWithBody(server string, driver AuthCallbackParamsDriv return nil, err } - operationPath := fmt.Sprintf("/api/auth/login/%s/callback", pathParam0) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subscriptions", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7967,26 +7971,80 @@ func NewAuthCallbackRequestWithBody(server string, driver AuthCallbackParamsDriv return nil, err } - req, err := http.NewRequest("POST", queryURL.String(), body) - if err != nil { - return nil, err - } + if params != nil { + queryValues := queryURL.Query() - req.Header.Add("Content-Type", contentType) + if params.Limit != nil { - return req, nil -} + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } -// NewGetAuthMethodsRequest generates requests for GetAuthMethods -func NewGetAuthMethodsRequest(server string) (*http.Request, error) { - var err error + } - serverURL, err := url.Parse(server) + if params.Offset != nil { + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "offset", runtime.ParamLocationQuery, *params.Offset); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } - operationPath := fmt.Sprintf("/api/auth/methods") + return req, nil +} + +// NewCreateSubscriptionRequest calls the generic CreateSubscription builder with application/json body +func NewCreateSubscriptionRequest(server string, projectID openapi_types.UUID, body CreateSubscriptionJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateSubscriptionRequestWithBody(server, projectID, "application/json", bodyReader) +} + +// NewCreateSubscriptionRequestWithBody generates requests for CreateSubscription with any type of body +func NewCreateSubscriptionRequestWithBody(server string, projectID openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectID", runtime.ParamLocationPath, projectID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/admin/projects/%s/subscriptions", pathParam0) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -7996,21 +8054,30 @@ func NewGetAuthMethodsRequest(server string) (*http.Request, error) { return nil, err } - req, err := http.NewRequest("GET", queryURL.String(), nil) + req, err := http.NewRequest("POST", queryURL.String(), body) if err != nil { return nil, err } + req.Header.Add("Content-Type", contentType) + return req, nil } -// NewAuthWebhookRequest generates requests for AuthWebhook -func NewAuthWebhookRequest(server string, driver AuthWebhookParamsDriver) (*http.Request, error) { +// NewGetSubscriptionRequest generates requests for GetSubscription +func NewGetSubscriptionRequest(server string, projectID openapi_types.UUID, subscriptionID openapi_types.UUID) (*http.Request, error) { var err error var pathParam0 string - pathParam0, err = runtime.StyleParamWithLocation("simple", false, "driver", runtime.ParamLocationPath, driver) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectID", runtime.ParamLocationPath, projectID) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "subscriptionID", runtime.ParamLocationPath, subscriptionID) if err != nil { return nil, err } @@ -8020,7 +8087,7 @@ func NewAuthWebhookRequest(server string, driver AuthWebhookParamsDriver) (*http return nil, err } - operationPath := fmt.Sprintf("/api/auth/%s/webhook", pathParam0) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subscriptions/%s", pathParam0, pathParam1) if operationPath[0] == '/' { operationPath = "." + operationPath } @@ -8030,7 +8097,7 @@ func NewAuthWebhookRequest(server string, driver AuthWebhookParamsDriver) (*http return nil, err } - req, err := http.NewRequest("POST", queryURL.String(), nil) + req, err := http.NewRequest("GET", queryURL.String(), nil) if err != nil { return nil, err } @@ -8038,1341 +8105,1250 @@ func NewAuthWebhookRequest(server string, driver AuthWebhookParamsDriver) (*http return req, nil } -func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { - for _, r := range c.RequestEditors { - if err := r(ctx, req); err != nil { - return err - } - } - for _, r := range additionalEditors { - if err := r(ctx, req); err != nil { - return err - } +// NewUpdateSubscriptionRequest calls the generic UpdateSubscription builder with application/json body +func NewUpdateSubscriptionRequest(server string, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, body UpdateSubscriptionJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err } - return nil + bodyReader = bytes.NewReader(buf) + return NewUpdateSubscriptionRequestWithBody(server, projectID, subscriptionID, "application/json", bodyReader) } -// ClientWithResponses builds on ClientInterface to offer response payloads -type ClientWithResponses struct { - ClientInterface -} +// NewUpdateSubscriptionRequestWithBody generates requests for UpdateSubscription with any type of body +func NewUpdateSubscriptionRequestWithBody(server string, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { + var err error -// NewClientWithResponses creates a new ClientWithResponses, which wraps -// Client with return type handling -func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { - client, err := NewClient(server, opts...) + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectID", runtime.ParamLocationPath, projectID) if err != nil { return nil, err } - return &ClientWithResponses{client}, nil -} -// WithBaseURL overrides the baseURL. -func WithBaseURL(baseURL string) ClientOption { - return func(c *Client) error { - newBaseURL, err := url.Parse(baseURL) - if err != nil { - return err - } - c.Server = newBaseURL.String() - return nil + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "subscriptionID", runtime.ParamLocationPath, subscriptionID) + if err != nil { + return nil, err } -} -// ClientWithResponsesInterface is the interface specification for the client with responses above. -type ClientWithResponsesInterface interface { - // DeleteOrganizationWithResponse request - DeleteOrganizationWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DeleteOrganizationResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - // GetOrganizationWithResponse request - GetOrganizationWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetOrganizationResponse, error) + operationPath := fmt.Sprintf("/api/admin/projects/%s/subscriptions/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - // UpdateOrganizationWithBodyWithResponse request with any body - UpdateOrganizationWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateOrganizationResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - UpdateOrganizationWithResponse(ctx context.Context, body UpdateOrganizationJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateOrganizationResponse, error) + req, err := http.NewRequest("PATCH", queryURL.String(), body) + if err != nil { + return nil, err + } - // ListAdminsWithResponse request - ListAdminsWithResponse(ctx context.Context, params *ListAdminsParams, reqEditors ...RequestEditorFn) (*ListAdminsResponse, error) + req.Header.Add("Content-Type", contentType) - // CreateAdminWithBodyWithResponse request with any body - CreateAdminWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateAdminResponse, error) + return req, nil +} - CreateAdminWithResponse(ctx context.Context, body CreateAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAdminResponse, error) +// NewListTagsRequest generates requests for ListTags +func NewListTagsRequest(server string, projectID openapi_types.UUID, params *ListTagsParams) (*http.Request, error) { + var err error - // DeleteAdminWithResponse request - DeleteAdminWithResponse(ctx context.Context, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteAdminResponse, error) + var pathParam0 string - // GetAdminWithResponse request - GetAdminWithResponse(ctx context.Context, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetAdminResponse, error) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectID", runtime.ParamLocationPath, projectID) + if err != nil { + return nil, err + } - // UpdateAdminWithBodyWithResponse request with any body - UpdateAdminWithBodyWithResponse(ctx context.Context, adminID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateAdminResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - UpdateAdminWithResponse(ctx context.Context, adminID openapi_types.UUID, body UpdateAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateAdminResponse, error) + operationPath := fmt.Sprintf("/api/admin/projects/%s/tags", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - // GetOrganizationIntegrationsWithResponse request - GetOrganizationIntegrationsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetOrganizationIntegrationsResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - // WhoamiWithResponse request - WhoamiWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*WhoamiResponse, error) + if params != nil { + queryValues := queryURL.Query() - // GetProfileWithResponse request - GetProfileWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetProfileResponse, error) + if params.Limit != nil { - // ListProjectsWithResponse request - ListProjectsWithResponse(ctx context.Context, params *ListProjectsParams, reqEditors ...RequestEditorFn) (*ListProjectsResponse, error) + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } - // CreateProjectWithBodyWithResponse request with any body - CreateProjectWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateProjectResponse, error) + } - CreateProjectWithResponse(ctx context.Context, body CreateProjectJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateProjectResponse, error) + if params.Offset != nil { - // GetProjectWithResponse request - GetProjectWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetProjectResponse, error) + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "offset", runtime.ParamLocationQuery, *params.Offset); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } - // UpdateProjectWithBodyWithResponse request with any body - UpdateProjectWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateProjectResponse, error) + } - UpdateProjectWithResponse(ctx context.Context, projectID openapi_types.UUID, body UpdateProjectJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateProjectResponse, error) + if params.Search != nil { - // ListProjectAdminsWithResponse request - ListProjectAdminsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListProjectAdminsParams, reqEditors ...RequestEditorFn) (*ListProjectAdminsResponse, error) + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "search", runtime.ParamLocationQuery, *params.Search); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } - // DeleteProjectAdminWithResponse request - DeleteProjectAdminWithResponse(ctx context.Context, projectID openapi_types.UUID, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteProjectAdminResponse, error) + } - // GetProjectAdminWithResponse request - GetProjectAdminWithResponse(ctx context.Context, projectID openapi_types.UUID, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetProjectAdminResponse, error) + queryURL.RawQuery = queryValues.Encode() + } - // UpdateProjectAdminWithBodyWithResponse request with any body - UpdateProjectAdminWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, adminID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateProjectAdminResponse, error) + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } - UpdateProjectAdminWithResponse(ctx context.Context, projectID openapi_types.UUID, adminID openapi_types.UUID, body UpdateProjectAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateProjectAdminResponse, error) + return req, nil +} - // ListCampaignsWithResponse request - ListCampaignsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListCampaignsParams, reqEditors ...RequestEditorFn) (*ListCampaignsResponse, error) +// NewCreateTagRequest calls the generic CreateTag builder with application/json body +func NewCreateTagRequest(server string, projectID openapi_types.UUID, body CreateTagJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateTagRequestWithBody(server, projectID, "application/json", bodyReader) +} - // CreateCampaignWithBodyWithResponse request with any body - CreateCampaignWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateCampaignResponse, error) +// NewCreateTagRequestWithBody generates requests for CreateTag with any type of body +func NewCreateTagRequestWithBody(server string, projectID openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { + var err error - CreateCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateCampaignResponse, error) + var pathParam0 string - // DeleteCampaignWithResponse request - DeleteCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteCampaignResponse, error) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectID", runtime.ParamLocationPath, projectID) + if err != nil { + return nil, err + } - // GetCampaignWithResponse request - GetCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetCampaignResponse, error) - - // UpdateCampaignWithBodyWithResponse request with any body - UpdateCampaignWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateCampaignResponse, error) - - UpdateCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, body UpdateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateCampaignResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - // DuplicateCampaignWithResponse request - DuplicateCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DuplicateCampaignResponse, error) + operationPath := fmt.Sprintf("/api/admin/projects/%s/tags", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - // CreateTemplateWithBodyWithResponse request with any body - CreateTemplateWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateTemplateResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - CreateTemplateWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, body CreateTemplateJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateTemplateResponse, error) + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } - // DeleteTemplateWithResponse request - DeleteTemplateWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteTemplateResponse, error) + req.Header.Add("Content-Type", contentType) - // GetTemplateWithResponse request - GetTemplateWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetTemplateResponse, error) + return req, nil +} - // UpdateTemplateWithBodyWithResponse request with any body - UpdateTemplateWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateTemplateResponse, error) +// NewDeleteTagRequest generates requests for DeleteTag +func NewDeleteTagRequest(server string, projectID openapi_types.UUID, tagID openapi_types.UUID) (*http.Request, error) { + var err error - UpdateTemplateWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID, body UpdateTemplateJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateTemplateResponse, error) + var pathParam0 string - // GetCampaignUsersWithResponse request - GetCampaignUsersWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, params *GetCampaignUsersParams, reqEditors ...RequestEditorFn) (*GetCampaignUsersResponse, error) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectID", runtime.ParamLocationPath, projectID) + if err != nil { + return nil, err + } - // ListDocumentsWithResponse request - ListDocumentsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListDocumentsParams, reqEditors ...RequestEditorFn) (*ListDocumentsResponse, error) + var pathParam1 string - // UploadDocumentsWithBodyWithResponse request with any body - UploadDocumentsWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UploadDocumentsResponse, error) + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "tagID", runtime.ParamLocationPath, tagID) + if err != nil { + return nil, err + } - // DeleteDocumentWithResponse request - DeleteDocumentWithResponse(ctx context.Context, projectID openapi_types.UUID, documentID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteDocumentResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - // GetDocumentWithResponse request - GetDocumentWithResponse(ctx context.Context, projectID openapi_types.UUID, documentID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetDocumentResponse, error) + operationPath := fmt.Sprintf("/api/admin/projects/%s/tags/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - // GetDocumentMetadataWithResponse request - GetDocumentMetadataWithResponse(ctx context.Context, projectID openapi_types.UUID, documentID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetDocumentMetadataResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - // ListEventsWithResponse request - ListEventsWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListEventsResponse, error) + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } - // ListJourneysWithResponse request - ListJourneysWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListJourneysParams, reqEditors ...RequestEditorFn) (*ListJourneysResponse, error) + return req, nil +} - // CreateJourneyWithBodyWithResponse request with any body - CreateJourneyWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateJourneyResponse, error) +// NewGetTagRequest generates requests for GetTag +func NewGetTagRequest(server string, projectID openapi_types.UUID, tagID openapi_types.UUID) (*http.Request, error) { + var err error - CreateJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateJourneyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateJourneyResponse, error) + var pathParam0 string - // DeleteJourneyWithResponse request - DeleteJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteJourneyResponse, error) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectID", runtime.ParamLocationPath, projectID) + if err != nil { + return nil, err + } - // GetJourneyWithResponse request - GetJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetJourneyResponse, error) + var pathParam1 string - // UpdateJourneyWithBodyWithResponse request with any body - UpdateJourneyWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateJourneyResponse, error) + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "tagID", runtime.ParamLocationPath, tagID) + if err != nil { + return nil, err + } - UpdateJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, body UpdateJourneyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateJourneyResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - // DuplicateJourneyWithResponse request - DuplicateJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DuplicateJourneyResponse, error) + operationPath := fmt.Sprintf("/api/admin/projects/%s/tags/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - // PublishJourneyWithResponse request - PublishJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*PublishJourneyResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - // GetJourneyStepsWithResponse request - GetJourneyStepsWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetJourneyStepsResponse, error) + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } - // SetJourneyStepsWithBodyWithResponse request with any body - SetJourneyStepsWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetJourneyStepsResponse, error) + return req, nil +} - SetJourneyStepsWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, body SetJourneyStepsJSONRequestBody, reqEditors ...RequestEditorFn) (*SetJourneyStepsResponse, error) +// NewUpdateTagRequest calls the generic UpdateTag builder with application/json body +func NewUpdateTagRequest(server string, projectID openapi_types.UUID, tagID openapi_types.UUID, body UpdateTagJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateTagRequestWithBody(server, projectID, tagID, "application/json", bodyReader) +} - // VersionJourneyWithResponse request - VersionJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*VersionJourneyResponse, error) +// NewUpdateTagRequestWithBody generates requests for UpdateTag with any type of body +func NewUpdateTagRequestWithBody(server string, projectID openapi_types.UUID, tagID openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { + var err error - // ListApiKeysWithResponse request - ListApiKeysWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListApiKeysParams, reqEditors ...RequestEditorFn) (*ListApiKeysResponse, error) + var pathParam0 string - // CreateApiKeyWithBodyWithResponse request with any body - CreateApiKeyWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectID", runtime.ParamLocationPath, projectID) + if err != nil { + return nil, err + } - CreateApiKeyWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) + var pathParam1 string - // DeleteApiKeyWithResponse request - DeleteApiKeyWithResponse(ctx context.Context, projectID openapi_types.UUID, keyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteApiKeyResponse, error) + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "tagID", runtime.ParamLocationPath, tagID) + if err != nil { + return nil, err + } - // GetApiKeyWithResponse request - GetApiKeyWithResponse(ctx context.Context, projectID openapi_types.UUID, keyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetApiKeyResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - // UpdateApiKeyWithBodyWithResponse request with any body - UpdateApiKeyWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, keyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) + operationPath := fmt.Sprintf("/api/admin/projects/%s/tags/%s", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - UpdateApiKeyWithResponse(ctx context.Context, projectID openapi_types.UUID, keyID openapi_types.UUID, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - // ListListsWithResponse request - ListListsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListListsParams, reqEditors ...RequestEditorFn) (*ListListsResponse, error) + req, err := http.NewRequest("PATCH", queryURL.String(), body) + if err != nil { + return nil, err + } - // CreateListWithBodyWithResponse request with any body - CreateListWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateListResponse, error) + req.Header.Add("Content-Type", contentType) - CreateListWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateListJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateListResponse, error) + return req, nil +} - // DeleteListWithResponse request - DeleteListWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteListResponse, error) +// NewDeleteTenantRequest generates requests for DeleteTenant +func NewDeleteTenantRequest(server string) (*http.Request, error) { + var err error - // GetListWithResponse request - GetListWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetListResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - // UpdateListWithBodyWithResponse request with any body - UpdateListWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateListResponse, error) + operationPath := fmt.Sprintf("/api/admin/tenant") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - UpdateListWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, body UpdateListJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateListResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - // DuplicateListWithResponse request - DuplicateListWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DuplicateListResponse, error) + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } - // GetListUsersWithResponse request - GetListUsersWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, params *GetListUsersParams, reqEditors ...RequestEditorFn) (*GetListUsersResponse, error) + return req, nil +} - // ImportListUsersWithBodyWithResponse request with any body - ImportListUsersWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ImportListUsersResponse, error) +// NewGetTenantRequest generates requests for GetTenant +func NewGetTenantRequest(server string) (*http.Request, error) { + var err error - // ListLocalesWithResponse request - ListLocalesWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListLocalesParams, reqEditors ...RequestEditorFn) (*ListLocalesResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - // CreateLocaleWithBodyWithResponse request with any body - CreateLocaleWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateLocaleResponse, error) + operationPath := fmt.Sprintf("/api/admin/tenant") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - CreateLocaleWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateLocaleJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateLocaleResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - // DeleteLocaleWithResponse request - DeleteLocaleWithResponse(ctx context.Context, projectID openapi_types.UUID, localeID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteLocaleResponse, error) + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } - // GetLocaleWithResponse request - GetLocaleWithResponse(ctx context.Context, projectID openapi_types.UUID, localeID string, reqEditors ...RequestEditorFn) (*GetLocaleResponse, error) + return req, nil +} - // ListProvidersWithResponse request - ListProvidersWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListProvidersParams, reqEditors ...RequestEditorFn) (*ListProvidersResponse, error) +// NewUpdateTenantRequest calls the generic UpdateTenant builder with application/json body +func NewUpdateTenantRequest(server string, body UpdateTenantJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewUpdateTenantRequestWithBody(server, "application/json", bodyReader) +} - // ListAllProvidersWithResponse request - ListAllProvidersWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListAllProvidersResponse, error) +// NewUpdateTenantRequestWithBody generates requests for UpdateTenant with any type of body +func NewUpdateTenantRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error - // ListProviderMetaWithResponse request - ListProviderMetaWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListProviderMetaResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - // CreateProviderWithBodyWithResponse request with any body - CreateProviderWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateProviderResponse, error) + operationPath := fmt.Sprintf("/api/admin/tenant") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - CreateProviderWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, body CreateProviderJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateProviderResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - // GetProviderWithResponse request - GetProviderWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, providerID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetProviderResponse, error) + req, err := http.NewRequest("PATCH", queryURL.String(), body) + if err != nil { + return nil, err + } - // UpdateProviderWithBodyWithResponse request with any body - UpdateProviderWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, providerID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateProviderResponse, error) + req.Header.Add("Content-Type", contentType) - UpdateProviderWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, providerID openapi_types.UUID, body UpdateProviderJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateProviderResponse, error) + return req, nil +} - // DeleteProviderWithResponse request - DeleteProviderWithResponse(ctx context.Context, projectID openapi_types.UUID, providerID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteProviderResponse, error) +// NewListAdminsRequest generates requests for ListAdmins +func NewListAdminsRequest(server string, params *ListAdminsParams) (*http.Request, error) { + var err error - // ListSubscriptionsWithResponse request - ListSubscriptionsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListSubscriptionsParams, reqEditors ...RequestEditorFn) (*ListSubscriptionsResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - // CreateSubscriptionWithBodyWithResponse request with any body - CreateSubscriptionWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateSubscriptionResponse, error) + operationPath := fmt.Sprintf("/api/admin/tenant/admins") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - CreateSubscriptionWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateSubscriptionJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateSubscriptionResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - // GetSubscriptionWithResponse request - GetSubscriptionWithResponse(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetSubscriptionResponse, error) + if params != nil { + queryValues := queryURL.Query() - // UpdateSubscriptionWithBodyWithResponse request with any body - UpdateSubscriptionWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSubscriptionResponse, error) + if params.Limit != nil { - UpdateSubscriptionWithResponse(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, body UpdateSubscriptionJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateSubscriptionResponse, error) + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "limit", runtime.ParamLocationQuery, *params.Limit); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } - // ListTagsWithResponse request - ListTagsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListTagsParams, reqEditors ...RequestEditorFn) (*ListTagsResponse, error) + } - // CreateTagWithBodyWithResponse request with any body - CreateTagWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateTagResponse, error) + if params.Offset != nil { - CreateTagWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateTagJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateTagResponse, error) + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "offset", runtime.ParamLocationQuery, *params.Offset); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } - // DeleteTagWithResponse request - DeleteTagWithResponse(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteTagResponse, error) + } - // GetTagWithResponse request - GetTagWithResponse(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetTagResponse, error) + if params.Search != nil { - // UpdateTagWithBodyWithResponse request with any body - UpdateTagWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateTagResponse, error) + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "search", runtime.ParamLocationQuery, *params.Search); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } - UpdateTagWithResponse(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, body UpdateTagJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateTagResponse, error) + } - // ListUsersWithResponse request - ListUsersWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListUsersParams, reqEditors ...RequestEditorFn) (*ListUsersResponse, error) + queryURL.RawQuery = queryValues.Encode() + } - // IdentifyUserWithBodyWithResponse request with any body - IdentifyUserWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*IdentifyUserResponse, error) + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } - IdentifyUserWithResponse(ctx context.Context, projectID openapi_types.UUID, body IdentifyUserJSONRequestBody, reqEditors ...RequestEditorFn) (*IdentifyUserResponse, error) + return req, nil +} - // ImportUsersWithBodyWithResponse request with any body - ImportUsersWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ImportUsersResponse, error) +// NewCreateAdminRequest calls the generic CreateAdmin builder with application/json body +func NewCreateAdminRequest(server string, body CreateAdminJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err + } + bodyReader = bytes.NewReader(buf) + return NewCreateAdminRequestWithBody(server, "application/json", bodyReader) +} - // ListUserSchemasWithResponse request - ListUserSchemasWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListUserSchemasResponse, error) +// NewCreateAdminRequestWithBody generates requests for CreateAdmin with any type of body +func NewCreateAdminRequestWithBody(server string, contentType string, body io.Reader) (*http.Request, error) { + var err error - // DeleteUserWithResponse request - DeleteUserWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteUserResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - // GetUserWithResponse request - GetUserWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetUserResponse, error) + operationPath := fmt.Sprintf("/api/admin/tenant/admins") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - // UpdateUserWithBodyWithResponse request with any body - UpdateUserWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateUserResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - UpdateUserWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, body UpdateUserJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateUserResponse, error) + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err + } - // GetUserEventsWithResponse request - GetUserEventsWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, params *GetUserEventsParams, reqEditors ...RequestEditorFn) (*GetUserEventsResponse, error) + req.Header.Add("Content-Type", contentType) - // GetUserJourneysWithResponse request - GetUserJourneysWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, params *GetUserJourneysParams, reqEditors ...RequestEditorFn) (*GetUserJourneysResponse, error) + return req, nil +} - // GetUserSubscriptionsWithResponse request - GetUserSubscriptionsWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, params *GetUserSubscriptionsParams, reqEditors ...RequestEditorFn) (*GetUserSubscriptionsResponse, error) +// NewDeleteAdminRequest generates requests for DeleteAdmin +func NewDeleteAdminRequest(server string, adminID openapi_types.UUID) (*http.Request, error) { + var err error - // UpdateUserSubscriptionsWithBodyWithResponse request with any body - UpdateUserSubscriptionsWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateUserSubscriptionsResponse, error) + var pathParam0 string - UpdateUserSubscriptionsWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, body UpdateUserSubscriptionsJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateUserSubscriptionsResponse, error) + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "adminID", runtime.ParamLocationPath, adminID) + if err != nil { + return nil, err + } - // AuthCallbackWithBodyWithResponse request with any body - AuthCallbackWithBodyWithResponse(ctx context.Context, driver AuthCallbackParamsDriver, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AuthCallbackResponse, error) + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } - AuthCallbackWithResponse(ctx context.Context, driver AuthCallbackParamsDriver, body AuthCallbackJSONRequestBody, reqEditors ...RequestEditorFn) (*AuthCallbackResponse, error) + operationPath := fmt.Sprintf("/api/admin/tenant/admins/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } - // GetAuthMethodsWithResponse request - GetAuthMethodsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAuthMethodsResponse, error) + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } - // AuthWebhookWithResponse request - AuthWebhookWithResponse(ctx context.Context, driver AuthWebhookParamsDriver, reqEditors ...RequestEditorFn) (*AuthWebhookResponse, error) -} + req, err := http.NewRequest("DELETE", queryURL.String(), nil) + if err != nil { + return nil, err + } -type DeleteOrganizationResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *Error + return req, nil } -// Status returns HTTPResponse.Status -func (r DeleteOrganizationResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} +// NewGetAdminRequest generates requests for GetAdmin +func NewGetAdminRequest(server string, adminID openapi_types.UUID) (*http.Request, error) { + var err error -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteOrganizationResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "adminID", runtime.ParamLocationPath, adminID) + if err != nil { + return nil, err } - return 0 -} -type GetOrganizationResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Organization - JSONDefault *Error -} + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } -// Status returns HTTPResponse.Status -func (r GetOrganizationResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + operationPath := fmt.Sprintf("/api/admin/tenant/admins/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r GetOrganizationResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err } - return 0 -} - -type UpdateOrganizationResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Organization - JSONDefault *Error -} -// Status returns HTTPResponse.Status -func (r UpdateOrganizationResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err } - return http.StatusText(0) + + return req, nil } -// StatusCode returns HTTPResponse.StatusCode -func (r UpdateOrganizationResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// NewUpdateAdminRequest calls the generic UpdateAdmin builder with application/json body +func NewUpdateAdminRequest(server string, adminID openapi_types.UUID, body UpdateAdminJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err } - return 0 + bodyReader = bytes.NewReader(buf) + return NewUpdateAdminRequestWithBody(server, adminID, "application/json", bodyReader) } -type ListAdminsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *AdminList - JSONDefault *Error -} +// NewUpdateAdminRequestWithBody generates requests for UpdateAdmin with any type of body +func NewUpdateAdminRequestWithBody(server string, adminID openapi_types.UUID, contentType string, body io.Reader) (*http.Request, error) { + var err error -// Status returns HTTPResponse.Status -func (r ListAdminsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "adminID", runtime.ParamLocationPath, adminID) + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r ListAdminsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + serverURL, err := url.Parse(server) + if err != nil { + return nil, err } - return 0 -} -type CreateAdminResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *Admin - JSONDefault *Error -} + operationPath := fmt.Sprintf("/api/admin/tenant/admins/%s", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } -// Status returns HTTPResponse.Status -func (r CreateAdminResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r CreateAdminResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + req, err := http.NewRequest("PATCH", queryURL.String(), body) + if err != nil { + return nil, err } - return 0 -} -type DeleteAdminResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *Error -} + req.Header.Add("Content-Type", contentType) -// Status returns HTTPResponse.Status -func (r DeleteAdminResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) + return req, nil } -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteAdminResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// NewGetTenantIntegrationsRequest generates requests for GetTenantIntegrations +func NewGetTenantIntegrationsRequest(server string) (*http.Request, error) { + var err error + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err } - return 0 -} -type GetAdminResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Admin - JSONDefault *Error -} + operationPath := fmt.Sprintf("/api/admin/tenant/integrations") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } -// Status returns HTTPResponse.Status -func (r GetAdminResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r GetAdminResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err } - return 0 -} -type UpdateAdminResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Admin - JSONDefault *Error + return req, nil } -// Status returns HTTPResponse.Status -func (r UpdateAdminResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} +// NewWhoamiRequest generates requests for Whoami +func NewWhoamiRequest(server string) (*http.Request, error) { + var err error -// StatusCode returns HTTPResponse.StatusCode -func (r UpdateAdminResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + serverURL, err := url.Parse(server) + if err != nil { + return nil, err } - return 0 -} -type GetOrganizationIntegrationsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *[]Provider - JSONDefault *Error -} + operationPath := fmt.Sprintf("/api/admin/tenant/whoami") + if operationPath[0] == '/' { + operationPath = "." + operationPath + } -// Status returns HTTPResponse.Status -func (r GetOrganizationIntegrationsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r GetOrganizationIntegrationsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err } - return 0 -} -type WhoamiResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Admin - JSONDefault *Error + return req, nil } -// Status returns HTTPResponse.Status -func (r WhoamiResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// NewAuthCallbackRequest calls the generic AuthCallback builder with application/json body +func NewAuthCallbackRequest(server string, driver AuthCallbackParamsDriver, body AuthCallbackJSONRequestBody) (*http.Request, error) { + var bodyReader io.Reader + buf, err := json.Marshal(body) + if err != nil { + return nil, err } - return http.StatusText(0) + bodyReader = bytes.NewReader(buf) + return NewAuthCallbackRequestWithBody(server, driver, "application/json", bodyReader) } -// StatusCode returns HTTPResponse.StatusCode -func (r WhoamiResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} +// NewAuthCallbackRequestWithBody generates requests for AuthCallback with any type of body +func NewAuthCallbackRequestWithBody(server string, driver AuthCallbackParamsDriver, contentType string, body io.Reader) (*http.Request, error) { + var err error -type GetProfileResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Admin - JSONDefault *Error -} + var pathParam0 string -// Status returns HTTPResponse.Status -func (r GetProfileResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "driver", runtime.ParamLocationPath, driver) + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r GetProfileResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + serverURL, err := url.Parse(server) + if err != nil { + return nil, err } - return 0 -} - -type ListProjectsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *ProjectList - JSONDefault *Error -} -// Status returns HTTPResponse.Status -func (r ListProjectsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + operationPath := fmt.Sprintf("/api/auth/login/%s/callback", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r ListProjectsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err } - return 0 -} - -type CreateProjectResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *Project - JSONDefault *Error -} -// Status returns HTTPResponse.Status -func (r CreateProjectResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + req, err := http.NewRequest("POST", queryURL.String(), body) + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r CreateProjectResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + req.Header.Add("Content-Type", contentType) -type GetProjectResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Project - JSONDefault *Error + return req, nil } -// Status returns HTTPResponse.Status -func (r GetProjectResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} +// NewGetAuthMethodsRequest generates requests for GetAuthMethods +func NewGetAuthMethodsRequest(server string) (*http.Request, error) { + var err error -// StatusCode returns HTTPResponse.StatusCode -func (r GetProjectResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + serverURL, err := url.Parse(server) + if err != nil { + return nil, err } - return 0 -} - -type UpdateProjectResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Project - JSONDefault *Error -} -// Status returns HTTPResponse.Status -func (r UpdateProjectResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + operationPath := fmt.Sprintf("/api/auth/methods") + if operationPath[0] == '/' { + operationPath = "." + operationPath } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r UpdateProjectResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err } - return 0 -} - -type ListProjectAdminsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *ProjectAdminList - JSONDefault *Error -} -// Status returns HTTPResponse.Status -func (r ListProjectAdminsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r ListProjectAdminsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 + return req, nil } -type DeleteProjectAdminResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *Error -} +// NewAuthWebhookRequest generates requests for AuthWebhook +func NewAuthWebhookRequest(server string, driver AuthWebhookParamsDriver) (*http.Request, error) { + var err error -// Status returns HTTPResponse.Status -func (r DeleteProjectAdminResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + var pathParam0 string -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteProjectAdminResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "driver", runtime.ParamLocationPath, driver) + if err != nil { + return nil, err } - return 0 -} - -type GetProjectAdminResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *ProjectAdmin - JSONDefault *Error -} -// Status returns HTTPResponse.Status -func (r GetProjectAdminResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + serverURL, err := url.Parse(server) + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r GetProjectAdminResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + operationPath := fmt.Sprintf("/api/auth/%s/webhook", pathParam0) + if operationPath[0] == '/' { + operationPath = "." + operationPath } - return 0 -} - -type UpdateProjectAdminResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *ProjectAdmin - JSONDefault *Error -} -// Status returns HTTPResponse.Status -func (r UpdateProjectAdminResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err } - return http.StatusText(0) -} -// StatusCode returns HTTPResponse.StatusCode -func (r UpdateProjectAdminResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + req, err := http.NewRequest("POST", queryURL.String(), nil) + if err != nil { + return nil, err } - return 0 -} -type ListCampaignsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *CampaignListResponse - JSONDefault *Error + return req, nil } -// Status returns HTTPResponse.Status -func (r ListCampaignsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +func (c *Client) applyEditors(ctx context.Context, req *http.Request, additionalEditors []RequestEditorFn) error { + for _, r := range c.RequestEditors { + if err := r(ctx, req); err != nil { + return err + } } - return http.StatusText(0) -} - -// StatusCode returns HTTPResponse.StatusCode -func (r ListCampaignsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode + for _, r := range additionalEditors { + if err := r(ctx, req); err != nil { + return err + } } - return 0 + return nil } -type CreateCampaignResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *Campaign - JSONDefault *Error +// ClientWithResponses builds on ClientInterface to offer response payloads +type ClientWithResponses struct { + ClientInterface } -// Status returns HTTPResponse.Status -func (r CreateCampaignResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status +// NewClientWithResponses creates a new ClientWithResponses, which wraps +// Client with return type handling +func NewClientWithResponses(server string, opts ...ClientOption) (*ClientWithResponses, error) { + client, err := NewClient(server, opts...) + if err != nil { + return nil, err } - return http.StatusText(0) + return &ClientWithResponses{client}, nil } -// StatusCode returns HTTPResponse.StatusCode -func (r CreateCampaignResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode +// WithBaseURL overrides the baseURL. +func WithBaseURL(baseURL string) ClientOption { + return func(c *Client) error { + newBaseURL, err := url.Parse(baseURL) + if err != nil { + return err + } + c.Server = newBaseURL.String() + return nil } - return 0 } -type DeleteCampaignResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *Error -} +// ClientWithResponsesInterface is the interface specification for the client with responses above. +type ClientWithResponsesInterface interface { + // GetProfileWithResponse request + GetProfileWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetProfileResponse, error) -// Status returns HTTPResponse.Status -func (r DeleteCampaignResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + // ListProjectsWithResponse request + ListProjectsWithResponse(ctx context.Context, params *ListProjectsParams, reqEditors ...RequestEditorFn) (*ListProjectsResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteCampaignResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + // CreateProjectWithBodyWithResponse request with any body + CreateProjectWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateProjectResponse, error) -type GetCampaignResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *struct { - Data Campaign `json:"data"` - } - JSONDefault *Error -} + CreateProjectWithResponse(ctx context.Context, body CreateProjectJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateProjectResponse, error) -// Status returns HTTPResponse.Status -func (r GetCampaignResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + // GetProjectWithResponse request + GetProjectWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetProjectResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r GetCampaignResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + // UpdateProjectWithBodyWithResponse request with any body + UpdateProjectWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateProjectResponse, error) -type UpdateCampaignResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Campaign - JSONDefault *Error -} + UpdateProjectWithResponse(ctx context.Context, projectID openapi_types.UUID, body UpdateProjectJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateProjectResponse, error) -// Status returns HTTPResponse.Status -func (r UpdateCampaignResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + // ListProjectAdminsWithResponse request + ListProjectAdminsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListProjectAdminsParams, reqEditors ...RequestEditorFn) (*ListProjectAdminsResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r UpdateCampaignResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + // DeleteProjectAdminWithResponse request + DeleteProjectAdminWithResponse(ctx context.Context, projectID openapi_types.UUID, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteProjectAdminResponse, error) -type DuplicateCampaignResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *Campaign - JSONDefault *Error -} + // GetProjectAdminWithResponse request + GetProjectAdminWithResponse(ctx context.Context, projectID openapi_types.UUID, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetProjectAdminResponse, error) -// Status returns HTTPResponse.Status -func (r DuplicateCampaignResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + // UpdateProjectAdminWithBodyWithResponse request with any body + UpdateProjectAdminWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, adminID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateProjectAdminResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r DuplicateCampaignResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + UpdateProjectAdminWithResponse(ctx context.Context, projectID openapi_types.UUID, adminID openapi_types.UUID, body UpdateProjectAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateProjectAdminResponse, error) -type CreateTemplateResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *Template - JSONDefault *Error -} + // ListCampaignsWithResponse request + ListCampaignsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListCampaignsParams, reqEditors ...RequestEditorFn) (*ListCampaignsResponse, error) -// Status returns HTTPResponse.Status -func (r CreateTemplateResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + // CreateCampaignWithBodyWithResponse request with any body + CreateCampaignWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateCampaignResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r CreateTemplateResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + CreateCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateCampaignResponse, error) -type DeleteTemplateResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *Error -} + // DeleteCampaignWithResponse request + DeleteCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteCampaignResponse, error) -// Status returns HTTPResponse.Status -func (r DeleteTemplateResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + // GetCampaignWithResponse request + GetCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetCampaignResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteTemplateResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + // UpdateCampaignWithBodyWithResponse request with any body + UpdateCampaignWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateCampaignResponse, error) -type GetTemplateResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *struct { - Data Template `json:"data"` - } - JSONDefault *Error -} + UpdateCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, body UpdateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateCampaignResponse, error) -// Status returns HTTPResponse.Status -func (r GetTemplateResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + // DuplicateCampaignWithResponse request + DuplicateCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DuplicateCampaignResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r GetTemplateResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + // CreateTemplateWithBodyWithResponse request with any body + CreateTemplateWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateTemplateResponse, error) -type UpdateTemplateResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Template - JSONDefault *Error -} + CreateTemplateWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, body CreateTemplateJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateTemplateResponse, error) -// Status returns HTTPResponse.Status -func (r UpdateTemplateResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + // DeleteTemplateWithResponse request + DeleteTemplateWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteTemplateResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r UpdateTemplateResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + // GetTemplateWithResponse request + GetTemplateWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetTemplateResponse, error) -type GetCampaignUsersResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *struct { - Data []CampaignUser `json:"data"` - Limit int `json:"limit"` - Offset int `json:"offset"` - Total int `json:"total"` - } - JSONDefault *Error -} + // UpdateTemplateWithBodyWithResponse request with any body + UpdateTemplateWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateTemplateResponse, error) -// Status returns HTTPResponse.Status -func (r GetCampaignUsersResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + UpdateTemplateWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID, body UpdateTemplateJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateTemplateResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r GetCampaignUsersResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + // GetCampaignUsersWithResponse request + GetCampaignUsersWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, params *GetCampaignUsersParams, reqEditors ...RequestEditorFn) (*GetCampaignUsersResponse, error) -type ListDocumentsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *DocumentListResponse - JSONDefault *Error -} + // ListDocumentsWithResponse request + ListDocumentsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListDocumentsParams, reqEditors ...RequestEditorFn) (*ListDocumentsResponse, error) -// Status returns HTTPResponse.Status -func (r ListDocumentsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + // UploadDocumentsWithBodyWithResponse request with any body + UploadDocumentsWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UploadDocumentsResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r ListDocumentsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + // DeleteDocumentWithResponse request + DeleteDocumentWithResponse(ctx context.Context, projectID openapi_types.UUID, documentID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteDocumentResponse, error) -type UploadDocumentsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *struct { - // Documents UUIDs of the uploaded documents - Documents []openapi_types.UUID `json:"documents"` - } - JSONDefault *Error -} + // GetDocumentWithResponse request + GetDocumentWithResponse(ctx context.Context, projectID openapi_types.UUID, documentID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetDocumentResponse, error) -// Status returns HTTPResponse.Status -func (r UploadDocumentsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + // GetDocumentMetadataWithResponse request + GetDocumentMetadataWithResponse(ctx context.Context, projectID openapi_types.UUID, documentID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetDocumentMetadataResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r UploadDocumentsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + // ListJourneysWithResponse request + ListJourneysWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListJourneysParams, reqEditors ...RequestEditorFn) (*ListJourneysResponse, error) -type DeleteDocumentResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *Error -} + // CreateJourneyWithBodyWithResponse request with any body + CreateJourneyWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateJourneyResponse, error) -// Status returns HTTPResponse.Status -func (r DeleteDocumentResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + CreateJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateJourneyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateJourneyResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteDocumentResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + // DeleteJourneyWithResponse request + DeleteJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteJourneyResponse, error) -type GetDocumentResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *Error -} + // GetJourneyWithResponse request + GetJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetJourneyResponse, error) -// Status returns HTTPResponse.Status -func (r GetDocumentResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + // UpdateJourneyWithBodyWithResponse request with any body + UpdateJourneyWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateJourneyResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r GetDocumentResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + UpdateJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, body UpdateJourneyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateJourneyResponse, error) -type GetDocumentMetadataResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Document - JSONDefault *Error -} + // DuplicateJourneyWithResponse request + DuplicateJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DuplicateJourneyResponse, error) -// Status returns HTTPResponse.Status -func (r GetDocumentMetadataResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + // PublishJourneyWithResponse request + PublishJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*PublishJourneyResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r GetDocumentMetadataResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + // GetJourneyStepsWithResponse request + GetJourneyStepsWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetJourneyStepsResponse, error) -type ListEventsResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *EventListResponse - JSONDefault *Error -} + // SetJourneyStepsWithBodyWithResponse request with any body + SetJourneyStepsWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetJourneyStepsResponse, error) -// Status returns HTTPResponse.Status -func (r ListEventsResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + SetJourneyStepsWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, body SetJourneyStepsJSONRequestBody, reqEditors ...RequestEditorFn) (*SetJourneyStepsResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r ListEventsResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + // VersionJourneyWithResponse request + VersionJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*VersionJourneyResponse, error) -type ListJourneysResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *JourneyListResponse - JSONDefault *Error -} + // ListApiKeysWithResponse request + ListApiKeysWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListApiKeysParams, reqEditors ...RequestEditorFn) (*ListApiKeysResponse, error) -// Status returns HTTPResponse.Status -func (r ListJourneysResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + // CreateApiKeyWithBodyWithResponse request with any body + CreateApiKeyWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r ListJourneysResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + CreateApiKeyWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) -type CreateJourneyResponse struct { - Body []byte - HTTPResponse *http.Response - JSON201 *Journey - JSONDefault *Error -} + // DeleteApiKeyWithResponse request + DeleteApiKeyWithResponse(ctx context.Context, projectID openapi_types.UUID, keyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteApiKeyResponse, error) -// Status returns HTTPResponse.Status -func (r CreateJourneyResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + // GetApiKeyWithResponse request + GetApiKeyWithResponse(ctx context.Context, projectID openapi_types.UUID, keyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetApiKeyResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r CreateJourneyResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + // UpdateApiKeyWithBodyWithResponse request with any body + UpdateApiKeyWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, keyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) -type DeleteJourneyResponse struct { - Body []byte - HTTPResponse *http.Response - JSONDefault *Error -} + UpdateApiKeyWithResponse(ctx context.Context, projectID openapi_types.UUID, keyID openapi_types.UUID, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) -// Status returns HTTPResponse.Status -func (r DeleteJourneyResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + // ListListsWithResponse request + ListListsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListListsParams, reqEditors ...RequestEditorFn) (*ListListsResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r DeleteJourneyResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + // CreateListWithBodyWithResponse request with any body + CreateListWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateListResponse, error) -type GetJourneyResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Journey - JSONDefault *Error -} + CreateListWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateListJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateListResponse, error) -// Status returns HTTPResponse.Status -func (r GetJourneyResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + // DeleteListWithResponse request + DeleteListWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteListResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r GetJourneyResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + // GetListWithResponse request + GetListWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetListResponse, error) -type UpdateJourneyResponse struct { - Body []byte - HTTPResponse *http.Response - JSON200 *Journey - JSONDefault *Error -} + // UpdateListWithBodyWithResponse request with any body + UpdateListWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateListResponse, error) -// Status returns HTTPResponse.Status -func (r UpdateJourneyResponse) Status() string { - if r.HTTPResponse != nil { - return r.HTTPResponse.Status - } - return http.StatusText(0) -} + UpdateListWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, body UpdateListJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateListResponse, error) -// StatusCode returns HTTPResponse.StatusCode -func (r UpdateJourneyResponse) StatusCode() int { - if r.HTTPResponse != nil { - return r.HTTPResponse.StatusCode - } - return 0 -} + // DuplicateListWithResponse request + DuplicateListWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DuplicateListResponse, error) -type DuplicateJourneyResponse struct { + // GetListUsersWithResponse request + GetListUsersWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, params *GetListUsersParams, reqEditors ...RequestEditorFn) (*GetListUsersResponse, error) + + // ImportListUsersWithBodyWithResponse request with any body + ImportListUsersWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ImportListUsersResponse, error) + + // ListLocalesWithResponse request + ListLocalesWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListLocalesParams, reqEditors ...RequestEditorFn) (*ListLocalesResponse, error) + + // CreateLocaleWithBodyWithResponse request with any body + CreateLocaleWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateLocaleResponse, error) + + CreateLocaleWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateLocaleJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateLocaleResponse, error) + + // DeleteLocaleWithResponse request + DeleteLocaleWithResponse(ctx context.Context, projectID openapi_types.UUID, localeID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteLocaleResponse, error) + + // GetLocaleWithResponse request + GetLocaleWithResponse(ctx context.Context, projectID openapi_types.UUID, localeID string, reqEditors ...RequestEditorFn) (*GetLocaleResponse, error) + + // ListProvidersWithResponse request + ListProvidersWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListProvidersParams, reqEditors ...RequestEditorFn) (*ListProvidersResponse, error) + + // ListAllProvidersWithResponse request + ListAllProvidersWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListAllProvidersResponse, error) + + // ListProviderMetaWithResponse request + ListProviderMetaWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListProviderMetaResponse, error) + + // CreateProviderWithBodyWithResponse request with any body + CreateProviderWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateProviderResponse, error) + + CreateProviderWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, body CreateProviderJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateProviderResponse, error) + + // GetProviderWithResponse request + GetProviderWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, providerID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetProviderResponse, error) + + // UpdateProviderWithBodyWithResponse request with any body + UpdateProviderWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, providerID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateProviderResponse, error) + + UpdateProviderWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, providerID openapi_types.UUID, body UpdateProviderJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateProviderResponse, error) + + // DeleteProviderWithResponse request + DeleteProviderWithResponse(ctx context.Context, projectID openapi_types.UUID, providerID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteProviderResponse, error) + + // ListEventsWithResponse request + ListEventsWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListEventsResponse, error) + + // ListOrganizationsWithResponse request + ListOrganizationsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListOrganizationsParams, reqEditors ...RequestEditorFn) (*ListOrganizationsResponse, error) + + // UpsertOrganizationWithBodyWithResponse request with any body + UpsertOrganizationWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpsertOrganizationResponse, error) + + UpsertOrganizationWithResponse(ctx context.Context, projectID openapi_types.UUID, body UpsertOrganizationJSONRequestBody, reqEditors ...RequestEditorFn) (*UpsertOrganizationResponse, error) + + // ListOrganizationSchemasWithResponse request + ListOrganizationSchemasWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListOrganizationSchemasResponse, error) + + // ListOrganizationMemberSchemasWithResponse request + ListOrganizationMemberSchemasWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListOrganizationMemberSchemasResponse, error) + + // DeleteOrganizationWithResponse request + DeleteOrganizationWithResponse(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteOrganizationResponse, error) + + // GetOrganizationWithResponse request + GetOrganizationWithResponse(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetOrganizationResponse, error) + + // UpdateOrganizationWithBodyWithResponse request with any body + UpdateOrganizationWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateOrganizationResponse, error) + + UpdateOrganizationWithResponse(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, body UpdateOrganizationJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateOrganizationResponse, error) + + // ListOrganizationMembersWithResponse request + ListOrganizationMembersWithResponse(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, params *ListOrganizationMembersParams, reqEditors ...RequestEditorFn) (*ListOrganizationMembersResponse, error) + + // AddOrganizationMemberWithBodyWithResponse request with any body + AddOrganizationMemberWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AddOrganizationMemberResponse, error) + + AddOrganizationMemberWithResponse(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, body AddOrganizationMemberJSONRequestBody, reqEditors ...RequestEditorFn) (*AddOrganizationMemberResponse, error) + + // RemoveOrganizationMemberWithResponse request + RemoveOrganizationMemberWithResponse(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*RemoveOrganizationMemberResponse, error) + + // ListUsersWithResponse request + ListUsersWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListUsersParams, reqEditors ...RequestEditorFn) (*ListUsersResponse, error) + + // IdentifyUserWithBodyWithResponse request with any body + IdentifyUserWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*IdentifyUserResponse, error) + + IdentifyUserWithResponse(ctx context.Context, projectID openapi_types.UUID, body IdentifyUserJSONRequestBody, reqEditors ...RequestEditorFn) (*IdentifyUserResponse, error) + + // ImportUsersWithBodyWithResponse request with any body + ImportUsersWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ImportUsersResponse, error) + + // ListUserSchemasWithResponse request + ListUserSchemasWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListUserSchemasResponse, error) + + // DeleteUserWithResponse request + DeleteUserWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteUserResponse, error) + + // GetUserWithResponse request + GetUserWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetUserResponse, error) + + // UpdateUserWithBodyWithResponse request with any body + UpdateUserWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateUserResponse, error) + + UpdateUserWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, body UpdateUserJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateUserResponse, error) + + // GetUserEventsWithResponse request + GetUserEventsWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, params *GetUserEventsParams, reqEditors ...RequestEditorFn) (*GetUserEventsResponse, error) + + // GetUserJourneysWithResponse request + GetUserJourneysWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, params *GetUserJourneysParams, reqEditors ...RequestEditorFn) (*GetUserJourneysResponse, error) + + // GetUserOrganizationsWithResponse request + GetUserOrganizationsWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetUserOrganizationsResponse, error) + + // GetUserSubscriptionsWithResponse request + GetUserSubscriptionsWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, params *GetUserSubscriptionsParams, reqEditors ...RequestEditorFn) (*GetUserSubscriptionsResponse, error) + + // UpdateUserSubscriptionsWithBodyWithResponse request with any body + UpdateUserSubscriptionsWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateUserSubscriptionsResponse, error) + + UpdateUserSubscriptionsWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, body UpdateUserSubscriptionsJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateUserSubscriptionsResponse, error) + + // ListSubscriptionsWithResponse request + ListSubscriptionsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListSubscriptionsParams, reqEditors ...RequestEditorFn) (*ListSubscriptionsResponse, error) + + // CreateSubscriptionWithBodyWithResponse request with any body + CreateSubscriptionWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateSubscriptionResponse, error) + + CreateSubscriptionWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateSubscriptionJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateSubscriptionResponse, error) + + // GetSubscriptionWithResponse request + GetSubscriptionWithResponse(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetSubscriptionResponse, error) + + // UpdateSubscriptionWithBodyWithResponse request with any body + UpdateSubscriptionWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSubscriptionResponse, error) + + UpdateSubscriptionWithResponse(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, body UpdateSubscriptionJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateSubscriptionResponse, error) + + // ListTagsWithResponse request + ListTagsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListTagsParams, reqEditors ...RequestEditorFn) (*ListTagsResponse, error) + + // CreateTagWithBodyWithResponse request with any body + CreateTagWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateTagResponse, error) + + CreateTagWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateTagJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateTagResponse, error) + + // DeleteTagWithResponse request + DeleteTagWithResponse(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteTagResponse, error) + + // GetTagWithResponse request + GetTagWithResponse(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetTagResponse, error) + + // UpdateTagWithBodyWithResponse request with any body + UpdateTagWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateTagResponse, error) + + UpdateTagWithResponse(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, body UpdateTagJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateTagResponse, error) + + // DeleteTenantWithResponse request + DeleteTenantWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DeleteTenantResponse, error) + + // GetTenantWithResponse request + GetTenantWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetTenantResponse, error) + + // UpdateTenantWithBodyWithResponse request with any body + UpdateTenantWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateTenantResponse, error) + + UpdateTenantWithResponse(ctx context.Context, body UpdateTenantJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateTenantResponse, error) + + // ListAdminsWithResponse request + ListAdminsWithResponse(ctx context.Context, params *ListAdminsParams, reqEditors ...RequestEditorFn) (*ListAdminsResponse, error) + + // CreateAdminWithBodyWithResponse request with any body + CreateAdminWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateAdminResponse, error) + + CreateAdminWithResponse(ctx context.Context, body CreateAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAdminResponse, error) + + // DeleteAdminWithResponse request + DeleteAdminWithResponse(ctx context.Context, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteAdminResponse, error) + + // GetAdminWithResponse request + GetAdminWithResponse(ctx context.Context, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetAdminResponse, error) + + // UpdateAdminWithBodyWithResponse request with any body + UpdateAdminWithBodyWithResponse(ctx context.Context, adminID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateAdminResponse, error) + + UpdateAdminWithResponse(ctx context.Context, adminID openapi_types.UUID, body UpdateAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateAdminResponse, error) + + // GetTenantIntegrationsWithResponse request + GetTenantIntegrationsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetTenantIntegrationsResponse, error) + + // WhoamiWithResponse request + WhoamiWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*WhoamiResponse, error) + + // AuthCallbackWithBodyWithResponse request with any body + AuthCallbackWithBodyWithResponse(ctx context.Context, driver AuthCallbackParamsDriver, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AuthCallbackResponse, error) + + AuthCallbackWithResponse(ctx context.Context, driver AuthCallbackParamsDriver, body AuthCallbackJSONRequestBody, reqEditors ...RequestEditorFn) (*AuthCallbackResponse, error) + + // GetAuthMethodsWithResponse request + GetAuthMethodsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAuthMethodsResponse, error) + + // AuthWebhookWithResponse request + AuthWebhookWithResponse(ctx context.Context, driver AuthWebhookParamsDriver, reqEditors ...RequestEditorFn) (*AuthWebhookResponse, error) +} + +type GetProfileResponse struct { Body []byte HTTPResponse *http.Response - JSON201 *Journey + JSON200 *Admin JSONDefault *Error } // Status returns HTTPResponse.Status -func (r DuplicateJourneyResponse) Status() string { +func (r GetProfileResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9380,22 +9356,22 @@ func (r DuplicateJourneyResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r DuplicateJourneyResponse) StatusCode() int { +func (r GetProfileResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type PublishJourneyResponse struct { +type ListProjectsResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *Journey + JSON200 *ProjectList JSONDefault *Error } // Status returns HTTPResponse.Status -func (r PublishJourneyResponse) Status() string { +func (r ListProjectsResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9403,22 +9379,22 @@ func (r PublishJourneyResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r PublishJourneyResponse) StatusCode() int { +func (r ListProjectsResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type GetJourneyStepsResponse struct { +type CreateProjectResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *JourneyStepMap + JSON201 *Project JSONDefault *Error } // Status returns HTTPResponse.Status -func (r GetJourneyStepsResponse) Status() string { +func (r CreateProjectResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9426,22 +9402,22 @@ func (r GetJourneyStepsResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r GetJourneyStepsResponse) StatusCode() int { +func (r CreateProjectResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type SetJourneyStepsResponse struct { +type GetProjectResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *JourneyStepMap + JSON200 *Project JSONDefault *Error } // Status returns HTTPResponse.Status -func (r SetJourneyStepsResponse) Status() string { +func (r GetProjectResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9449,22 +9425,22 @@ func (r SetJourneyStepsResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r SetJourneyStepsResponse) StatusCode() int { +func (r GetProjectResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type VersionJourneyResponse struct { +type UpdateProjectResponse struct { Body []byte HTTPResponse *http.Response - JSON201 *Journey + JSON200 *Project JSONDefault *Error } // Status returns HTTPResponse.Status -func (r VersionJourneyResponse) Status() string { +func (r UpdateProjectResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9472,22 +9448,22 @@ func (r VersionJourneyResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r VersionJourneyResponse) StatusCode() int { +func (r UpdateProjectResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type ListApiKeysResponse struct { +type ListProjectAdminsResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *ApiKeyListResponse + JSON200 *ProjectAdminList JSONDefault *Error } // Status returns HTTPResponse.Status -func (r ListApiKeysResponse) Status() string { +func (r ListProjectAdminsResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9495,22 +9471,21 @@ func (r ListApiKeysResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r ListApiKeysResponse) StatusCode() int { +func (r ListProjectAdminsResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type CreateApiKeyResponse struct { +type DeleteProjectAdminResponse struct { Body []byte HTTPResponse *http.Response - JSON201 *ApiKey JSONDefault *Error } // Status returns HTTPResponse.Status -func (r CreateApiKeyResponse) Status() string { +func (r DeleteProjectAdminResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9518,21 +9493,22 @@ func (r CreateApiKeyResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r CreateApiKeyResponse) StatusCode() int { +func (r DeleteProjectAdminResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type DeleteApiKeyResponse struct { +type GetProjectAdminResponse struct { Body []byte HTTPResponse *http.Response + JSON200 *ProjectAdmin JSONDefault *Error } // Status returns HTTPResponse.Status -func (r DeleteApiKeyResponse) Status() string { +func (r GetProjectAdminResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9540,22 +9516,22 @@ func (r DeleteApiKeyResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r DeleteApiKeyResponse) StatusCode() int { +func (r GetProjectAdminResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type GetApiKeyResponse struct { +type UpdateProjectAdminResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *ApiKey + JSON200 *ProjectAdmin JSONDefault *Error } // Status returns HTTPResponse.Status -func (r GetApiKeyResponse) Status() string { +func (r UpdateProjectAdminResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9563,22 +9539,22 @@ func (r GetApiKeyResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r GetApiKeyResponse) StatusCode() int { +func (r UpdateProjectAdminResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type UpdateApiKeyResponse struct { +type ListCampaignsResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *ApiKey + JSON200 *CampaignListResponse JSONDefault *Error } // Status returns HTTPResponse.Status -func (r UpdateApiKeyResponse) Status() string { +func (r ListCampaignsResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9586,22 +9562,22 @@ func (r UpdateApiKeyResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r UpdateApiKeyResponse) StatusCode() int { +func (r ListCampaignsResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type ListListsResponse struct { +type CreateCampaignResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *ListListResponse + JSON201 *Campaign JSONDefault *Error } // Status returns HTTPResponse.Status -func (r ListListsResponse) Status() string { +func (r CreateCampaignResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9609,22 +9585,21 @@ func (r ListListsResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r ListListsResponse) StatusCode() int { +func (r CreateCampaignResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type CreateListResponse struct { +type DeleteCampaignResponse struct { Body []byte HTTPResponse *http.Response - JSON201 *List JSONDefault *Error } // Status returns HTTPResponse.Status -func (r CreateListResponse) Status() string { +func (r DeleteCampaignResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9632,21 +9607,24 @@ func (r CreateListResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r CreateListResponse) StatusCode() int { +func (r DeleteCampaignResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type DeleteListResponse struct { +type GetCampaignResponse struct { Body []byte HTTPResponse *http.Response - JSONDefault *Error + JSON200 *struct { + Data Campaign `json:"data"` + } + JSONDefault *Error } // Status returns HTTPResponse.Status -func (r DeleteListResponse) Status() string { +func (r GetCampaignResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9654,22 +9632,22 @@ func (r DeleteListResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r DeleteListResponse) StatusCode() int { +func (r GetCampaignResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type GetListResponse struct { +type UpdateCampaignResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *List + JSON200 *Campaign JSONDefault *Error } // Status returns HTTPResponse.Status -func (r GetListResponse) Status() string { +func (r UpdateCampaignResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9677,22 +9655,22 @@ func (r GetListResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r GetListResponse) StatusCode() int { +func (r UpdateCampaignResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type UpdateListResponse struct { +type DuplicateCampaignResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *List + JSON201 *Campaign JSONDefault *Error } // Status returns HTTPResponse.Status -func (r UpdateListResponse) Status() string { +func (r DuplicateCampaignResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9700,22 +9678,22 @@ func (r UpdateListResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r UpdateListResponse) StatusCode() int { +func (r DuplicateCampaignResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type DuplicateListResponse struct { +type CreateTemplateResponse struct { Body []byte HTTPResponse *http.Response - JSON201 *List + JSON201 *Template JSONDefault *Error } // Status returns HTTPResponse.Status -func (r DuplicateListResponse) Status() string { +func (r CreateTemplateResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9723,22 +9701,21 @@ func (r DuplicateListResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r DuplicateListResponse) StatusCode() int { +func (r CreateTemplateResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type GetListUsersResponse struct { +type DeleteTemplateResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *UserList JSONDefault *Error } // Status returns HTTPResponse.Status -func (r GetListUsersResponse) Status() string { +func (r DeleteTemplateResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9746,21 +9723,24 @@ func (r GetListUsersResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r GetListUsersResponse) StatusCode() int { +func (r DeleteTemplateResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type ImportListUsersResponse struct { +type GetTemplateResponse struct { Body []byte HTTPResponse *http.Response - JSONDefault *Error + JSON200 *struct { + Data Template `json:"data"` + } + JSONDefault *Error } // Status returns HTTPResponse.Status -func (r ImportListUsersResponse) Status() string { +func (r GetTemplateResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9768,32 +9748,22 @@ func (r ImportListUsersResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r ImportListUsersResponse) StatusCode() int { +func (r GetTemplateResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type ListLocalesResponse struct { +type UpdateTemplateResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *struct { - // Limit Maximum number of items returned - Limit int `json:"limit"` - - // Offset Number of items skipped - Offset int `json:"offset"` - Results []Locale `json:"results"` - - // Total Total number of items matching the filters - Total int `json:"total"` - } - JSONDefault *Error + JSON200 *Template + JSONDefault *Error } // Status returns HTTPResponse.Status -func (r ListLocalesResponse) Status() string { +func (r UpdateTemplateResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9801,22 +9771,27 @@ func (r ListLocalesResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r ListLocalesResponse) StatusCode() int { +func (r UpdateTemplateResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type CreateLocaleResponse struct { +type GetCampaignUsersResponse struct { Body []byte HTTPResponse *http.Response - JSON201 *Locale - JSONDefault *Error + JSON200 *struct { + Data []CampaignUser `json:"data"` + Limit int `json:"limit"` + Offset int `json:"offset"` + Total int `json:"total"` + } + JSONDefault *Error } // Status returns HTTPResponse.Status -func (r CreateLocaleResponse) Status() string { +func (r GetCampaignUsersResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9824,21 +9799,22 @@ func (r CreateLocaleResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r CreateLocaleResponse) StatusCode() int { +func (r GetCampaignUsersResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type DeleteLocaleResponse struct { +type ListDocumentsResponse struct { Body []byte HTTPResponse *http.Response + JSON200 *DocumentListResponse JSONDefault *Error } // Status returns HTTPResponse.Status -func (r DeleteLocaleResponse) Status() string { +func (r ListDocumentsResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9846,22 +9822,25 @@ func (r DeleteLocaleResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r DeleteLocaleResponse) StatusCode() int { +func (r ListDocumentsResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type GetLocaleResponse struct { +type UploadDocumentsResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *Locale - JSONDefault *Error + JSON201 *struct { + // Documents UUIDs of the uploaded documents + Documents []openapi_types.UUID `json:"documents"` + } + JSONDefault *Error } // Status returns HTTPResponse.Status -func (r GetLocaleResponse) Status() string { +func (r UploadDocumentsResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9869,22 +9848,21 @@ func (r GetLocaleResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r GetLocaleResponse) StatusCode() int { +func (r UploadDocumentsResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type ListProvidersResponse struct { +type DeleteDocumentResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *ProviderListResponse JSONDefault *Error } // Status returns HTTPResponse.Status -func (r ListProvidersResponse) Status() string { +func (r DeleteDocumentResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9892,22 +9870,21 @@ func (r ListProvidersResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r ListProvidersResponse) StatusCode() int { +func (r DeleteDocumentResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type ListAllProvidersResponse struct { +type GetDocumentResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *[]Provider JSONDefault *Error } // Status returns HTTPResponse.Status -func (r ListAllProvidersResponse) Status() string { +func (r GetDocumentResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9915,22 +9892,22 @@ func (r ListAllProvidersResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r ListAllProvidersResponse) StatusCode() int { +func (r GetDocumentResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type ListProviderMetaResponse struct { +type GetDocumentMetadataResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *[]ProviderMeta + JSON200 *Document JSONDefault *Error } // Status returns HTTPResponse.Status -func (r ListProviderMetaResponse) Status() string { +func (r GetDocumentMetadataResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9938,22 +9915,22 @@ func (r ListProviderMetaResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r ListProviderMetaResponse) StatusCode() int { +func (r GetDocumentMetadataResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type CreateProviderResponse struct { +type ListJourneysResponse struct { Body []byte HTTPResponse *http.Response - JSON201 *Provider + JSON200 *JourneyListResponse JSONDefault *Error } // Status returns HTTPResponse.Status -func (r CreateProviderResponse) Status() string { +func (r ListJourneysResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9961,22 +9938,22 @@ func (r CreateProviderResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r CreateProviderResponse) StatusCode() int { +func (r ListJourneysResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type GetProviderResponse struct { +type CreateJourneyResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *Provider + JSON201 *Journey JSONDefault *Error } // Status returns HTTPResponse.Status -func (r GetProviderResponse) Status() string { +func (r CreateJourneyResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -9984,22 +9961,21 @@ func (r GetProviderResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r GetProviderResponse) StatusCode() int { +func (r CreateJourneyResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type UpdateProviderResponse struct { +type DeleteJourneyResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *Provider JSONDefault *Error } // Status returns HTTPResponse.Status -func (r UpdateProviderResponse) Status() string { +func (r DeleteJourneyResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10007,21 +9983,22 @@ func (r UpdateProviderResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r UpdateProviderResponse) StatusCode() int { +func (r DeleteJourneyResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type DeleteProviderResponse struct { +type GetJourneyResponse struct { Body []byte HTTPResponse *http.Response + JSON200 *Journey JSONDefault *Error } // Status returns HTTPResponse.Status -func (r DeleteProviderResponse) Status() string { +func (r GetJourneyResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10029,22 +10006,22 @@ func (r DeleteProviderResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r DeleteProviderResponse) StatusCode() int { +func (r GetJourneyResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type ListSubscriptionsResponse struct { +type UpdateJourneyResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *SubscriptionListResponse + JSON200 *Journey JSONDefault *Error } // Status returns HTTPResponse.Status -func (r ListSubscriptionsResponse) Status() string { +func (r UpdateJourneyResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10052,22 +10029,22 @@ func (r ListSubscriptionsResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r ListSubscriptionsResponse) StatusCode() int { +func (r UpdateJourneyResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type CreateSubscriptionResponse struct { +type DuplicateJourneyResponse struct { Body []byte HTTPResponse *http.Response - JSON201 *Subscription + JSON201 *Journey JSONDefault *Error } // Status returns HTTPResponse.Status -func (r CreateSubscriptionResponse) Status() string { +func (r DuplicateJourneyResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10075,22 +10052,22 @@ func (r CreateSubscriptionResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r CreateSubscriptionResponse) StatusCode() int { +func (r DuplicateJourneyResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type GetSubscriptionResponse struct { +type PublishJourneyResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *Subscription + JSON200 *Journey JSONDefault *Error } // Status returns HTTPResponse.Status -func (r GetSubscriptionResponse) Status() string { +func (r PublishJourneyResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10098,22 +10075,22 @@ func (r GetSubscriptionResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r GetSubscriptionResponse) StatusCode() int { +func (r PublishJourneyResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type UpdateSubscriptionResponse struct { +type GetJourneyStepsResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *Subscription + JSON200 *JourneyStepMap JSONDefault *Error } // Status returns HTTPResponse.Status -func (r UpdateSubscriptionResponse) Status() string { +func (r GetJourneyStepsResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10121,22 +10098,22 @@ func (r UpdateSubscriptionResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r UpdateSubscriptionResponse) StatusCode() int { +func (r GetJourneyStepsResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type ListTagsResponse struct { +type SetJourneyStepsResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *TagListResponse + JSON200 *JourneyStepMap JSONDefault *Error } // Status returns HTTPResponse.Status -func (r ListTagsResponse) Status() string { +func (r SetJourneyStepsResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10144,22 +10121,22 @@ func (r ListTagsResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r ListTagsResponse) StatusCode() int { +func (r SetJourneyStepsResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type CreateTagResponse struct { +type VersionJourneyResponse struct { Body []byte HTTPResponse *http.Response - JSON201 *Tag + JSON201 *Journey JSONDefault *Error } // Status returns HTTPResponse.Status -func (r CreateTagResponse) Status() string { +func (r VersionJourneyResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10167,21 +10144,22 @@ func (r CreateTagResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r CreateTagResponse) StatusCode() int { +func (r VersionJourneyResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type DeleteTagResponse struct { +type ListApiKeysResponse struct { Body []byte HTTPResponse *http.Response + JSON200 *ApiKeyListResponse JSONDefault *Error } // Status returns HTTPResponse.Status -func (r DeleteTagResponse) Status() string { +func (r ListApiKeysResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10189,22 +10167,22 @@ func (r DeleteTagResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r DeleteTagResponse) StatusCode() int { +func (r ListApiKeysResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type GetTagResponse struct { +type CreateApiKeyResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *Tag + JSON201 *ApiKey JSONDefault *Error } // Status returns HTTPResponse.Status -func (r GetTagResponse) Status() string { +func (r CreateApiKeyResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10212,22 +10190,21 @@ func (r GetTagResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r GetTagResponse) StatusCode() int { +func (r CreateApiKeyResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type UpdateTagResponse struct { +type DeleteApiKeyResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *Tag JSONDefault *Error } // Status returns HTTPResponse.Status -func (r UpdateTagResponse) Status() string { +func (r DeleteApiKeyResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10235,22 +10212,22 @@ func (r UpdateTagResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r UpdateTagResponse) StatusCode() int { +func (r DeleteApiKeyResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type ListUsersResponse struct { +type GetApiKeyResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *UserList + JSON200 *ApiKey JSONDefault *Error } // Status returns HTTPResponse.Status -func (r ListUsersResponse) Status() string { +func (r GetApiKeyResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10258,22 +10235,22 @@ func (r ListUsersResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r ListUsersResponse) StatusCode() int { +func (r GetApiKeyResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type IdentifyUserResponse struct { +type UpdateApiKeyResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *User + JSON200 *ApiKey JSONDefault *Error } // Status returns HTTPResponse.Status -func (r IdentifyUserResponse) Status() string { +func (r UpdateApiKeyResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10281,21 +10258,22 @@ func (r IdentifyUserResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r IdentifyUserResponse) StatusCode() int { +func (r UpdateApiKeyResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type ImportUsersResponse struct { +type ListListsResponse struct { Body []byte HTTPResponse *http.Response + JSON200 *ListListResponse JSONDefault *Error } // Status returns HTTPResponse.Status -func (r ImportUsersResponse) Status() string { +func (r ListListsResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10303,24 +10281,22 @@ func (r ImportUsersResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r ImportUsersResponse) StatusCode() int { +func (r ListListsResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type ListUserSchemasResponse struct { +type CreateListResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *struct { - Results []SchemaPath `json:"results"` - } - JSONDefault *Error + JSON201 *List + JSONDefault *Error } // Status returns HTTPResponse.Status -func (r ListUserSchemasResponse) Status() string { +func (r CreateListResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10328,21 +10304,21 @@ func (r ListUserSchemasResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r ListUserSchemasResponse) StatusCode() int { +func (r CreateListResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type DeleteUserResponse struct { +type DeleteListResponse struct { Body []byte HTTPResponse *http.Response JSONDefault *Error } // Status returns HTTPResponse.Status -func (r DeleteUserResponse) Status() string { +func (r DeleteListResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10350,22 +10326,22 @@ func (r DeleteUserResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r DeleteUserResponse) StatusCode() int { +func (r DeleteListResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type GetUserResponse struct { +type GetListResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *User + JSON200 *List JSONDefault *Error } // Status returns HTTPResponse.Status -func (r GetUserResponse) Status() string { +func (r GetListResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10373,22 +10349,22 @@ func (r GetUserResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r GetUserResponse) StatusCode() int { +func (r GetListResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type UpdateUserResponse struct { +type UpdateListResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *User + JSON200 *List JSONDefault *Error } // Status returns HTTPResponse.Status -func (r UpdateUserResponse) Status() string { +func (r UpdateListResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10396,22 +10372,22 @@ func (r UpdateUserResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r UpdateUserResponse) StatusCode() int { +func (r UpdateListResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type GetUserEventsResponse struct { +type DuplicateListResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *UserEventList + JSON201 *List JSONDefault *Error } // Status returns HTTPResponse.Status -func (r GetUserEventsResponse) Status() string { +func (r DuplicateListResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10419,22 +10395,22 @@ func (r GetUserEventsResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r GetUserEventsResponse) StatusCode() int { +func (r DuplicateListResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type GetUserJourneysResponse struct { +type GetListUsersResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *UserJourneyList + JSON200 *UserList JSONDefault *Error } // Status returns HTTPResponse.Status -func (r GetUserJourneysResponse) Status() string { +func (r GetListUsersResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10442,22 +10418,21 @@ func (r GetUserJourneysResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r GetUserJourneysResponse) StatusCode() int { +func (r GetListUsersResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type GetUserSubscriptionsResponse struct { +type ImportListUsersResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *UserSubscriptionList JSONDefault *Error } // Status returns HTTPResponse.Status -func (r GetUserSubscriptionsResponse) Status() string { +func (r ImportListUsersResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10465,22 +10440,32 @@ func (r GetUserSubscriptionsResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r GetUserSubscriptionsResponse) StatusCode() int { +func (r ImportListUsersResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type UpdateUserSubscriptionsResponse struct { +type ListLocalesResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *User - JSONDefault *Error + JSON200 *struct { + // Limit Maximum number of items returned + Limit int `json:"limit"` + + // Offset Number of items skipped + Offset int `json:"offset"` + Results []Locale `json:"results"` + + // Total Total number of items matching the filters + Total int `json:"total"` + } + JSONDefault *Error } // Status returns HTTPResponse.Status -func (r UpdateUserSubscriptionsResponse) Status() string { +func (r ListLocalesResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10488,21 +10473,22 @@ func (r UpdateUserSubscriptionsResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r UpdateUserSubscriptionsResponse) StatusCode() int { +func (r ListLocalesResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type AuthCallbackResponse struct { +type CreateLocaleResponse struct { Body []byte HTTPResponse *http.Response + JSON201 *Locale JSONDefault *Error } // Status returns HTTPResponse.Status -func (r AuthCallbackResponse) Status() string { +func (r CreateLocaleResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10510,22 +10496,21 @@ func (r AuthCallbackResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r AuthCallbackResponse) StatusCode() int { +func (r CreateLocaleResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type GetAuthMethodsResponse struct { +type DeleteLocaleResponse struct { Body []byte HTTPResponse *http.Response - JSON200 *[]string JSONDefault *Error } // Status returns HTTPResponse.Status -func (r GetAuthMethodsResponse) Status() string { +func (r DeleteLocaleResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10533,21 +10518,22 @@ func (r GetAuthMethodsResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r GetAuthMethodsResponse) StatusCode() int { +func (r DeleteLocaleResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -type AuthWebhookResponse struct { +type GetLocaleResponse struct { Body []byte HTTPResponse *http.Response + JSON200 *Locale JSONDefault *Error } // Status returns HTTPResponse.Status -func (r AuthWebhookResponse) Status() string { +func (r GetLocaleResponse) Status() string { if r.HTTPResponse != nil { return r.HTTPResponse.Status } @@ -10555,2366 +10541,2406 @@ func (r AuthWebhookResponse) Status() string { } // StatusCode returns HTTPResponse.StatusCode -func (r AuthWebhookResponse) StatusCode() int { +func (r GetLocaleResponse) StatusCode() int { if r.HTTPResponse != nil { return r.HTTPResponse.StatusCode } return 0 } -// DeleteOrganizationWithResponse request returning *DeleteOrganizationResponse -func (c *ClientWithResponses) DeleteOrganizationWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DeleteOrganizationResponse, error) { - rsp, err := c.DeleteOrganization(ctx, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteOrganizationResponse(rsp) +type ListProvidersResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *ProviderListResponse + JSONDefault *Error } -// GetOrganizationWithResponse request returning *GetOrganizationResponse -func (c *ClientWithResponses) GetOrganizationWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetOrganizationResponse, error) { - rsp, err := c.GetOrganization(ctx, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r ListProvidersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseGetOrganizationResponse(rsp) + return http.StatusText(0) } -// UpdateOrganizationWithBodyWithResponse request with arbitrary body returning *UpdateOrganizationResponse -func (c *ClientWithResponses) UpdateOrganizationWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateOrganizationResponse, error) { - rsp, err := c.UpdateOrganizationWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r ListProvidersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseUpdateOrganizationResponse(rsp) + return 0 } -func (c *ClientWithResponses) UpdateOrganizationWithResponse(ctx context.Context, body UpdateOrganizationJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateOrganizationResponse, error) { - rsp, err := c.UpdateOrganization(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseUpdateOrganizationResponse(rsp) +type ListAllProvidersResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *[]Provider + JSONDefault *Error } -// ListAdminsWithResponse request returning *ListAdminsResponse -func (c *ClientWithResponses) ListAdminsWithResponse(ctx context.Context, params *ListAdminsParams, reqEditors ...RequestEditorFn) (*ListAdminsResponse, error) { - rsp, err := c.ListAdmins(ctx, params, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r ListAllProvidersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseListAdminsResponse(rsp) + return http.StatusText(0) } -// CreateAdminWithBodyWithResponse request with arbitrary body returning *CreateAdminResponse -func (c *ClientWithResponses) CreateAdminWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateAdminResponse, error) { - rsp, err := c.CreateAdminWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r ListAllProvidersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseCreateAdminResponse(rsp) + return 0 } -func (c *ClientWithResponses) CreateAdminWithResponse(ctx context.Context, body CreateAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAdminResponse, error) { - rsp, err := c.CreateAdmin(ctx, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateAdminResponse(rsp) +type ListProviderMetaResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *[]ProviderMeta + JSONDefault *Error } -// DeleteAdminWithResponse request returning *DeleteAdminResponse -func (c *ClientWithResponses) DeleteAdminWithResponse(ctx context.Context, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteAdminResponse, error) { - rsp, err := c.DeleteAdmin(ctx, adminID, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r ListProviderMetaResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseDeleteAdminResponse(rsp) + return http.StatusText(0) } -// GetAdminWithResponse request returning *GetAdminResponse -func (c *ClientWithResponses) GetAdminWithResponse(ctx context.Context, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetAdminResponse, error) { - rsp, err := c.GetAdmin(ctx, adminID, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r ListProviderMetaResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseGetAdminResponse(rsp) + return 0 } -// UpdateAdminWithBodyWithResponse request with arbitrary body returning *UpdateAdminResponse -func (c *ClientWithResponses) UpdateAdminWithBodyWithResponse(ctx context.Context, adminID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateAdminResponse, error) { - rsp, err := c.UpdateAdminWithBody(ctx, adminID, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseUpdateAdminResponse(rsp) +type CreateProviderResponse struct { + Body []byte + HTTPResponse *http.Response + JSON201 *Provider + JSONDefault *Error } -func (c *ClientWithResponses) UpdateAdminWithResponse(ctx context.Context, adminID openapi_types.UUID, body UpdateAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateAdminResponse, error) { - rsp, err := c.UpdateAdmin(ctx, adminID, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r CreateProviderResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseUpdateAdminResponse(rsp) + return http.StatusText(0) } -// GetOrganizationIntegrationsWithResponse request returning *GetOrganizationIntegrationsResponse -func (c *ClientWithResponses) GetOrganizationIntegrationsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetOrganizationIntegrationsResponse, error) { - rsp, err := c.GetOrganizationIntegrations(ctx, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r CreateProviderResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseGetOrganizationIntegrationsResponse(rsp) + return 0 } -// WhoamiWithResponse request returning *WhoamiResponse -func (c *ClientWithResponses) WhoamiWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*WhoamiResponse, error) { - rsp, err := c.Whoami(ctx, reqEditors...) - if err != nil { - return nil, err - } - return ParseWhoamiResponse(rsp) +type GetProviderResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Provider + JSONDefault *Error } -// GetProfileWithResponse request returning *GetProfileResponse -func (c *ClientWithResponses) GetProfileWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetProfileResponse, error) { - rsp, err := c.GetProfile(ctx, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r GetProviderResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseGetProfileResponse(rsp) + return http.StatusText(0) } -// ListProjectsWithResponse request returning *ListProjectsResponse -func (c *ClientWithResponses) ListProjectsWithResponse(ctx context.Context, params *ListProjectsParams, reqEditors ...RequestEditorFn) (*ListProjectsResponse, error) { - rsp, err := c.ListProjects(ctx, params, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r GetProviderResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseListProjectsResponse(rsp) + return 0 } -// CreateProjectWithBodyWithResponse request with arbitrary body returning *CreateProjectResponse -func (c *ClientWithResponses) CreateProjectWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateProjectResponse, error) { - rsp, err := c.CreateProjectWithBody(ctx, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateProjectResponse(rsp) +type UpdateProviderResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Provider + JSONDefault *Error } -func (c *ClientWithResponses) CreateProjectWithResponse(ctx context.Context, body CreateProjectJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateProjectResponse, error) { - rsp, err := c.CreateProject(ctx, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r UpdateProviderResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseCreateProjectResponse(rsp) + return http.StatusText(0) } -// GetProjectWithResponse request returning *GetProjectResponse -func (c *ClientWithResponses) GetProjectWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetProjectResponse, error) { - rsp, err := c.GetProject(ctx, projectID, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateProviderResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseGetProjectResponse(rsp) + return 0 } -// UpdateProjectWithBodyWithResponse request with arbitrary body returning *UpdateProjectResponse -func (c *ClientWithResponses) UpdateProjectWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateProjectResponse, error) { - rsp, err := c.UpdateProjectWithBody(ctx, projectID, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseUpdateProjectResponse(rsp) +type DeleteProviderResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *Error } -func (c *ClientWithResponses) UpdateProjectWithResponse(ctx context.Context, projectID openapi_types.UUID, body UpdateProjectJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateProjectResponse, error) { - rsp, err := c.UpdateProject(ctx, projectID, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r DeleteProviderResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseUpdateProjectResponse(rsp) + return http.StatusText(0) } -// ListProjectAdminsWithResponse request returning *ListProjectAdminsResponse -func (c *ClientWithResponses) ListProjectAdminsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListProjectAdminsParams, reqEditors ...RequestEditorFn) (*ListProjectAdminsResponse, error) { - rsp, err := c.ListProjectAdmins(ctx, projectID, params, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteProviderResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseListProjectAdminsResponse(rsp) + return 0 } -// DeleteProjectAdminWithResponse request returning *DeleteProjectAdminResponse -func (c *ClientWithResponses) DeleteProjectAdminWithResponse(ctx context.Context, projectID openapi_types.UUID, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteProjectAdminResponse, error) { - rsp, err := c.DeleteProjectAdmin(ctx, projectID, adminID, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteProjectAdminResponse(rsp) +type ListEventsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *EventListResponse + JSONDefault *Error } -// GetProjectAdminWithResponse request returning *GetProjectAdminResponse -func (c *ClientWithResponses) GetProjectAdminWithResponse(ctx context.Context, projectID openapi_types.UUID, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetProjectAdminResponse, error) { - rsp, err := c.GetProjectAdmin(ctx, projectID, adminID, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r ListEventsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseGetProjectAdminResponse(rsp) + return http.StatusText(0) } -// UpdateProjectAdminWithBodyWithResponse request with arbitrary body returning *UpdateProjectAdminResponse -func (c *ClientWithResponses) UpdateProjectAdminWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, adminID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateProjectAdminResponse, error) { - rsp, err := c.UpdateProjectAdminWithBody(ctx, projectID, adminID, contentType, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r ListEventsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseUpdateProjectAdminResponse(rsp) + return 0 } -func (c *ClientWithResponses) UpdateProjectAdminWithResponse(ctx context.Context, projectID openapi_types.UUID, adminID openapi_types.UUID, body UpdateProjectAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateProjectAdminResponse, error) { - rsp, err := c.UpdateProjectAdmin(ctx, projectID, adminID, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseUpdateProjectAdminResponse(rsp) +type ListOrganizationsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *OrganizationList + JSONDefault *Error } -// ListCampaignsWithResponse request returning *ListCampaignsResponse -func (c *ClientWithResponses) ListCampaignsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListCampaignsParams, reqEditors ...RequestEditorFn) (*ListCampaignsResponse, error) { - rsp, err := c.ListCampaigns(ctx, projectID, params, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r ListOrganizationsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseListCampaignsResponse(rsp) + return http.StatusText(0) } -// CreateCampaignWithBodyWithResponse request with arbitrary body returning *CreateCampaignResponse -func (c *ClientWithResponses) CreateCampaignWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateCampaignResponse, error) { - rsp, err := c.CreateCampaignWithBody(ctx, projectID, contentType, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r ListOrganizationsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseCreateCampaignResponse(rsp) + return 0 } -func (c *ClientWithResponses) CreateCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateCampaignResponse, error) { - rsp, err := c.CreateCampaign(ctx, projectID, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateCampaignResponse(rsp) +type UpsertOrganizationResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Organization + JSONDefault *Error } -// DeleteCampaignWithResponse request returning *DeleteCampaignResponse -func (c *ClientWithResponses) DeleteCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteCampaignResponse, error) { - rsp, err := c.DeleteCampaign(ctx, projectID, campaignID, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r UpsertOrganizationResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseDeleteCampaignResponse(rsp) + return http.StatusText(0) } -// GetCampaignWithResponse request returning *GetCampaignResponse -func (c *ClientWithResponses) GetCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetCampaignResponse, error) { - rsp, err := c.GetCampaign(ctx, projectID, campaignID, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r UpsertOrganizationResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseGetCampaignResponse(rsp) + return 0 } -// UpdateCampaignWithBodyWithResponse request with arbitrary body returning *UpdateCampaignResponse -func (c *ClientWithResponses) UpdateCampaignWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateCampaignResponse, error) { - rsp, err := c.UpdateCampaignWithBody(ctx, projectID, campaignID, contentType, body, reqEditors...) - if err != nil { - return nil, err +type ListOrganizationSchemasResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Results []SchemaPath `json:"results"` } - return ParseUpdateCampaignResponse(rsp) + JSONDefault *Error } -func (c *ClientWithResponses) UpdateCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, body UpdateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateCampaignResponse, error) { - rsp, err := c.UpdateCampaign(ctx, projectID, campaignID, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r ListOrganizationSchemasResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseUpdateCampaignResponse(rsp) + return http.StatusText(0) } -// DuplicateCampaignWithResponse request returning *DuplicateCampaignResponse -func (c *ClientWithResponses) DuplicateCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DuplicateCampaignResponse, error) { - rsp, err := c.DuplicateCampaign(ctx, projectID, campaignID, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r ListOrganizationSchemasResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseDuplicateCampaignResponse(rsp) + return 0 } -// CreateTemplateWithBodyWithResponse request with arbitrary body returning *CreateTemplateResponse -func (c *ClientWithResponses) CreateTemplateWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateTemplateResponse, error) { - rsp, err := c.CreateTemplateWithBody(ctx, projectID, campaignID, contentType, body, reqEditors...) - if err != nil { - return nil, err +type ListOrganizationMemberSchemasResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Results []SchemaPath `json:"results"` } - return ParseCreateTemplateResponse(rsp) + JSONDefault *Error } -func (c *ClientWithResponses) CreateTemplateWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, body CreateTemplateJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateTemplateResponse, error) { - rsp, err := c.CreateTemplate(ctx, projectID, campaignID, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r ListOrganizationMemberSchemasResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseCreateTemplateResponse(rsp) + return http.StatusText(0) } -// DeleteTemplateWithResponse request returning *DeleteTemplateResponse -func (c *ClientWithResponses) DeleteTemplateWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteTemplateResponse, error) { - rsp, err := c.DeleteTemplate(ctx, projectID, campaignID, templateID, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r ListOrganizationMemberSchemasResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseDeleteTemplateResponse(rsp) + return 0 } -// GetTemplateWithResponse request returning *GetTemplateResponse -func (c *ClientWithResponses) GetTemplateWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetTemplateResponse, error) { - rsp, err := c.GetTemplate(ctx, projectID, campaignID, templateID, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetTemplateResponse(rsp) +type DeleteOrganizationResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *Error } -// UpdateTemplateWithBodyWithResponse request with arbitrary body returning *UpdateTemplateResponse -func (c *ClientWithResponses) UpdateTemplateWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateTemplateResponse, error) { - rsp, err := c.UpdateTemplateWithBody(ctx, projectID, campaignID, templateID, contentType, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r DeleteOrganizationResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseUpdateTemplateResponse(rsp) + return http.StatusText(0) } -func (c *ClientWithResponses) UpdateTemplateWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID, body UpdateTemplateJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateTemplateResponse, error) { - rsp, err := c.UpdateTemplate(ctx, projectID, campaignID, templateID, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteOrganizationResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseUpdateTemplateResponse(rsp) + return 0 } -// GetCampaignUsersWithResponse request returning *GetCampaignUsersResponse -func (c *ClientWithResponses) GetCampaignUsersWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, params *GetCampaignUsersParams, reqEditors ...RequestEditorFn) (*GetCampaignUsersResponse, error) { - rsp, err := c.GetCampaignUsers(ctx, projectID, campaignID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetCampaignUsersResponse(rsp) +type GetOrganizationResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Organization + JSONDefault *Error } -// ListDocumentsWithResponse request returning *ListDocumentsResponse -func (c *ClientWithResponses) ListDocumentsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListDocumentsParams, reqEditors ...RequestEditorFn) (*ListDocumentsResponse, error) { - rsp, err := c.ListDocuments(ctx, projectID, params, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r GetOrganizationResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseListDocumentsResponse(rsp) + return http.StatusText(0) } -// UploadDocumentsWithBodyWithResponse request with arbitrary body returning *UploadDocumentsResponse -func (c *ClientWithResponses) UploadDocumentsWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UploadDocumentsResponse, error) { - rsp, err := c.UploadDocumentsWithBody(ctx, projectID, contentType, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r GetOrganizationResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseUploadDocumentsResponse(rsp) + return 0 } -// DeleteDocumentWithResponse request returning *DeleteDocumentResponse -func (c *ClientWithResponses) DeleteDocumentWithResponse(ctx context.Context, projectID openapi_types.UUID, documentID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteDocumentResponse, error) { - rsp, err := c.DeleteDocument(ctx, projectID, documentID, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteDocumentResponse(rsp) +type UpdateOrganizationResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Organization + JSONDefault *Error } -// GetDocumentWithResponse request returning *GetDocumentResponse -func (c *ClientWithResponses) GetDocumentWithResponse(ctx context.Context, projectID openapi_types.UUID, documentID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetDocumentResponse, error) { - rsp, err := c.GetDocument(ctx, projectID, documentID, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r UpdateOrganizationResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseGetDocumentResponse(rsp) + return http.StatusText(0) } -// GetDocumentMetadataWithResponse request returning *GetDocumentMetadataResponse -func (c *ClientWithResponses) GetDocumentMetadataWithResponse(ctx context.Context, projectID openapi_types.UUID, documentID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetDocumentMetadataResponse, error) { - rsp, err := c.GetDocumentMetadata(ctx, projectID, documentID, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateOrganizationResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseGetDocumentMetadataResponse(rsp) + return 0 } -// ListEventsWithResponse request returning *ListEventsResponse -func (c *ClientWithResponses) ListEventsWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListEventsResponse, error) { - rsp, err := c.ListEvents(ctx, projectID, reqEditors...) - if err != nil { - return nil, err - } - return ParseListEventsResponse(rsp) +type ListOrganizationMembersResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *OrganizationMemberList + JSONDefault *Error } -// ListJourneysWithResponse request returning *ListJourneysResponse -func (c *ClientWithResponses) ListJourneysWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListJourneysParams, reqEditors ...RequestEditorFn) (*ListJourneysResponse, error) { - rsp, err := c.ListJourneys(ctx, projectID, params, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r ListOrganizationMembersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseListJourneysResponse(rsp) + return http.StatusText(0) } -// CreateJourneyWithBodyWithResponse request with arbitrary body returning *CreateJourneyResponse -func (c *ClientWithResponses) CreateJourneyWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateJourneyResponse, error) { - rsp, err := c.CreateJourneyWithBody(ctx, projectID, contentType, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r ListOrganizationMembersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseCreateJourneyResponse(rsp) + return 0 } -func (c *ClientWithResponses) CreateJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateJourneyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateJourneyResponse, error) { - rsp, err := c.CreateJourney(ctx, projectID, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateJourneyResponse(rsp) +type AddOrganizationMemberResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *Error } -// DeleteJourneyWithResponse request returning *DeleteJourneyResponse -func (c *ClientWithResponses) DeleteJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteJourneyResponse, error) { - rsp, err := c.DeleteJourney(ctx, projectID, journeyID, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r AddOrganizationMemberResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseDeleteJourneyResponse(rsp) + return http.StatusText(0) } -// GetJourneyWithResponse request returning *GetJourneyResponse -func (c *ClientWithResponses) GetJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetJourneyResponse, error) { - rsp, err := c.GetJourney(ctx, projectID, journeyID, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r AddOrganizationMemberResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseGetJourneyResponse(rsp) + return 0 } -// UpdateJourneyWithBodyWithResponse request with arbitrary body returning *UpdateJourneyResponse -func (c *ClientWithResponses) UpdateJourneyWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateJourneyResponse, error) { - rsp, err := c.UpdateJourneyWithBody(ctx, projectID, journeyID, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseUpdateJourneyResponse(rsp) +type RemoveOrganizationMemberResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *Error } -func (c *ClientWithResponses) UpdateJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, body UpdateJourneyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateJourneyResponse, error) { - rsp, err := c.UpdateJourney(ctx, projectID, journeyID, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r RemoveOrganizationMemberResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseUpdateJourneyResponse(rsp) + return http.StatusText(0) } -// DuplicateJourneyWithResponse request returning *DuplicateJourneyResponse -func (c *ClientWithResponses) DuplicateJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DuplicateJourneyResponse, error) { - rsp, err := c.DuplicateJourney(ctx, projectID, journeyID, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r RemoveOrganizationMemberResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseDuplicateJourneyResponse(rsp) + return 0 } -// PublishJourneyWithResponse request returning *PublishJourneyResponse -func (c *ClientWithResponses) PublishJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*PublishJourneyResponse, error) { - rsp, err := c.PublishJourney(ctx, projectID, journeyID, reqEditors...) - if err != nil { - return nil, err - } - return ParsePublishJourneyResponse(rsp) +type ListUsersResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *UserList + JSONDefault *Error } -// GetJourneyStepsWithResponse request returning *GetJourneyStepsResponse -func (c *ClientWithResponses) GetJourneyStepsWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetJourneyStepsResponse, error) { - rsp, err := c.GetJourneySteps(ctx, projectID, journeyID, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r ListUsersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseGetJourneyStepsResponse(rsp) + return http.StatusText(0) } -// SetJourneyStepsWithBodyWithResponse request with arbitrary body returning *SetJourneyStepsResponse -func (c *ClientWithResponses) SetJourneyStepsWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetJourneyStepsResponse, error) { - rsp, err := c.SetJourneyStepsWithBody(ctx, projectID, journeyID, contentType, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r ListUsersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseSetJourneyStepsResponse(rsp) + return 0 } -func (c *ClientWithResponses) SetJourneyStepsWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, body SetJourneyStepsJSONRequestBody, reqEditors ...RequestEditorFn) (*SetJourneyStepsResponse, error) { - rsp, err := c.SetJourneySteps(ctx, projectID, journeyID, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseSetJourneyStepsResponse(rsp) +type IdentifyUserResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *User + JSONDefault *Error } -// VersionJourneyWithResponse request returning *VersionJourneyResponse -func (c *ClientWithResponses) VersionJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*VersionJourneyResponse, error) { - rsp, err := c.VersionJourney(ctx, projectID, journeyID, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r IdentifyUserResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseVersionJourneyResponse(rsp) + return http.StatusText(0) } -// ListApiKeysWithResponse request returning *ListApiKeysResponse -func (c *ClientWithResponses) ListApiKeysWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListApiKeysParams, reqEditors ...RequestEditorFn) (*ListApiKeysResponse, error) { - rsp, err := c.ListApiKeys(ctx, projectID, params, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r IdentifyUserResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseListApiKeysResponse(rsp) + return 0 } -// CreateApiKeyWithBodyWithResponse request with arbitrary body returning *CreateApiKeyResponse -func (c *ClientWithResponses) CreateApiKeyWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) { - rsp, err := c.CreateApiKeyWithBody(ctx, projectID, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateApiKeyResponse(rsp) +type ImportUsersResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *Error } -func (c *ClientWithResponses) CreateApiKeyWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) { - rsp, err := c.CreateApiKey(ctx, projectID, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r ImportUsersResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseCreateApiKeyResponse(rsp) + return http.StatusText(0) } -// DeleteApiKeyWithResponse request returning *DeleteApiKeyResponse -func (c *ClientWithResponses) DeleteApiKeyWithResponse(ctx context.Context, projectID openapi_types.UUID, keyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteApiKeyResponse, error) { - rsp, err := c.DeleteApiKey(ctx, projectID, keyID, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r ImportUsersResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseDeleteApiKeyResponse(rsp) + return 0 } -// GetApiKeyWithResponse request returning *GetApiKeyResponse -func (c *ClientWithResponses) GetApiKeyWithResponse(ctx context.Context, projectID openapi_types.UUID, keyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetApiKeyResponse, error) { - rsp, err := c.GetApiKey(ctx, projectID, keyID, reqEditors...) - if err != nil { - return nil, err +type ListUserSchemasResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Results []SchemaPath `json:"results"` } - return ParseGetApiKeyResponse(rsp) + JSONDefault *Error } -// UpdateApiKeyWithBodyWithResponse request with arbitrary body returning *UpdateApiKeyResponse -func (c *ClientWithResponses) UpdateApiKeyWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, keyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) { - rsp, err := c.UpdateApiKeyWithBody(ctx, projectID, keyID, contentType, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r ListUserSchemasResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseUpdateApiKeyResponse(rsp) + return http.StatusText(0) } -func (c *ClientWithResponses) UpdateApiKeyWithResponse(ctx context.Context, projectID openapi_types.UUID, keyID openapi_types.UUID, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) { - rsp, err := c.UpdateApiKey(ctx, projectID, keyID, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r ListUserSchemasResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseUpdateApiKeyResponse(rsp) + return 0 } -// ListListsWithResponse request returning *ListListsResponse -func (c *ClientWithResponses) ListListsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListListsParams, reqEditors ...RequestEditorFn) (*ListListsResponse, error) { - rsp, err := c.ListLists(ctx, projectID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseListListsResponse(rsp) +type DeleteUserResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *Error } -// CreateListWithBodyWithResponse request with arbitrary body returning *CreateListResponse -func (c *ClientWithResponses) CreateListWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateListResponse, error) { - rsp, err := c.CreateListWithBody(ctx, projectID, contentType, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r DeleteUserResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseCreateListResponse(rsp) + return http.StatusText(0) } -func (c *ClientWithResponses) CreateListWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateListJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateListResponse, error) { - rsp, err := c.CreateList(ctx, projectID, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteUserResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseCreateListResponse(rsp) + return 0 } -// DeleteListWithResponse request returning *DeleteListResponse -func (c *ClientWithResponses) DeleteListWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteListResponse, error) { - rsp, err := c.DeleteList(ctx, projectID, listID, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteListResponse(rsp) +type GetUserResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *User + JSONDefault *Error } -// GetListWithResponse request returning *GetListResponse -func (c *ClientWithResponses) GetListWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetListResponse, error) { - rsp, err := c.GetList(ctx, projectID, listID, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r GetUserResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseGetListResponse(rsp) + return http.StatusText(0) } -// UpdateListWithBodyWithResponse request with arbitrary body returning *UpdateListResponse -func (c *ClientWithResponses) UpdateListWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateListResponse, error) { - rsp, err := c.UpdateListWithBody(ctx, projectID, listID, contentType, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r GetUserResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseUpdateListResponse(rsp) + return 0 } -func (c *ClientWithResponses) UpdateListWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, body UpdateListJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateListResponse, error) { - rsp, err := c.UpdateList(ctx, projectID, listID, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseUpdateListResponse(rsp) +type UpdateUserResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *User + JSONDefault *Error } -// DuplicateListWithResponse request returning *DuplicateListResponse -func (c *ClientWithResponses) DuplicateListWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DuplicateListResponse, error) { - rsp, err := c.DuplicateList(ctx, projectID, listID, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r UpdateUserResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseDuplicateListResponse(rsp) + return http.StatusText(0) } -// GetListUsersWithResponse request returning *GetListUsersResponse -func (c *ClientWithResponses) GetListUsersWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, params *GetListUsersParams, reqEditors ...RequestEditorFn) (*GetListUsersResponse, error) { - rsp, err := c.GetListUsers(ctx, projectID, listID, params, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateUserResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseGetListUsersResponse(rsp) + return 0 } -// ImportListUsersWithBodyWithResponse request with arbitrary body returning *ImportListUsersResponse -func (c *ClientWithResponses) ImportListUsersWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ImportListUsersResponse, error) { - rsp, err := c.ImportListUsersWithBody(ctx, projectID, listID, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseImportListUsersResponse(rsp) +type GetUserEventsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *UserEventList + JSONDefault *Error } -// ListLocalesWithResponse request returning *ListLocalesResponse -func (c *ClientWithResponses) ListLocalesWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListLocalesParams, reqEditors ...RequestEditorFn) (*ListLocalesResponse, error) { - rsp, err := c.ListLocales(ctx, projectID, params, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r GetUserEventsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseListLocalesResponse(rsp) + return http.StatusText(0) } -// CreateLocaleWithBodyWithResponse request with arbitrary body returning *CreateLocaleResponse -func (c *ClientWithResponses) CreateLocaleWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateLocaleResponse, error) { - rsp, err := c.CreateLocaleWithBody(ctx, projectID, contentType, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r GetUserEventsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseCreateLocaleResponse(rsp) + return 0 } -func (c *ClientWithResponses) CreateLocaleWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateLocaleJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateLocaleResponse, error) { - rsp, err := c.CreateLocale(ctx, projectID, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateLocaleResponse(rsp) +type GetUserJourneysResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *UserJourneyList + JSONDefault *Error } -// DeleteLocaleWithResponse request returning *DeleteLocaleResponse -func (c *ClientWithResponses) DeleteLocaleWithResponse(ctx context.Context, projectID openapi_types.UUID, localeID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteLocaleResponse, error) { - rsp, err := c.DeleteLocale(ctx, projectID, localeID, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r GetUserJourneysResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseDeleteLocaleResponse(rsp) + return http.StatusText(0) } -// GetLocaleWithResponse request returning *GetLocaleResponse -func (c *ClientWithResponses) GetLocaleWithResponse(ctx context.Context, projectID openapi_types.UUID, localeID string, reqEditors ...RequestEditorFn) (*GetLocaleResponse, error) { - rsp, err := c.GetLocale(ctx, projectID, localeID, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r GetUserJourneysResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseGetLocaleResponse(rsp) + return 0 } -// ListProvidersWithResponse request returning *ListProvidersResponse -func (c *ClientWithResponses) ListProvidersWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListProvidersParams, reqEditors ...RequestEditorFn) (*ListProvidersResponse, error) { - rsp, err := c.ListProviders(ctx, projectID, params, reqEditors...) - if err != nil { - return nil, err +type GetUserOrganizationsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + Results []Organization `json:"results"` } - return ParseListProvidersResponse(rsp) + JSONDefault *Error } -// ListAllProvidersWithResponse request returning *ListAllProvidersResponse -func (c *ClientWithResponses) ListAllProvidersWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListAllProvidersResponse, error) { - rsp, err := c.ListAllProviders(ctx, projectID, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r GetUserOrganizationsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseListAllProvidersResponse(rsp) + return http.StatusText(0) } -// ListProviderMetaWithResponse request returning *ListProviderMetaResponse -func (c *ClientWithResponses) ListProviderMetaWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListProviderMetaResponse, error) { - rsp, err := c.ListProviderMeta(ctx, projectID, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r GetUserOrganizationsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseListProviderMetaResponse(rsp) + return 0 } -// CreateProviderWithBodyWithResponse request with arbitrary body returning *CreateProviderResponse -func (c *ClientWithResponses) CreateProviderWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateProviderResponse, error) { - rsp, err := c.CreateProviderWithBody(ctx, projectID, group, pType, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseCreateProviderResponse(rsp) +type GetUserSubscriptionsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *UserSubscriptionList + JSONDefault *Error } -func (c *ClientWithResponses) CreateProviderWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, body CreateProviderJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateProviderResponse, error) { - rsp, err := c.CreateProvider(ctx, projectID, group, pType, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r GetUserSubscriptionsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseCreateProviderResponse(rsp) + return http.StatusText(0) } -// GetProviderWithResponse request returning *GetProviderResponse -func (c *ClientWithResponses) GetProviderWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, providerID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetProviderResponse, error) { - rsp, err := c.GetProvider(ctx, projectID, group, pType, providerID, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r GetUserSubscriptionsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseGetProviderResponse(rsp) + return 0 } -// UpdateProviderWithBodyWithResponse request with arbitrary body returning *UpdateProviderResponse -func (c *ClientWithResponses) UpdateProviderWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, providerID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateProviderResponse, error) { - rsp, err := c.UpdateProviderWithBody(ctx, projectID, group, pType, providerID, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseUpdateProviderResponse(rsp) +type UpdateUserSubscriptionsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *User + JSONDefault *Error } -func (c *ClientWithResponses) UpdateProviderWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, providerID openapi_types.UUID, body UpdateProviderJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateProviderResponse, error) { - rsp, err := c.UpdateProvider(ctx, projectID, group, pType, providerID, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r UpdateUserSubscriptionsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseUpdateProviderResponse(rsp) + return http.StatusText(0) } -// DeleteProviderWithResponse request returning *DeleteProviderResponse -func (c *ClientWithResponses) DeleteProviderWithResponse(ctx context.Context, projectID openapi_types.UUID, providerID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteProviderResponse, error) { - rsp, err := c.DeleteProvider(ctx, projectID, providerID, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateUserSubscriptionsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseDeleteProviderResponse(rsp) + return 0 } -// ListSubscriptionsWithResponse request returning *ListSubscriptionsResponse -func (c *ClientWithResponses) ListSubscriptionsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListSubscriptionsParams, reqEditors ...RequestEditorFn) (*ListSubscriptionsResponse, error) { - rsp, err := c.ListSubscriptions(ctx, projectID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseListSubscriptionsResponse(rsp) +type ListSubscriptionsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *SubscriptionListResponse + JSONDefault *Error } -// CreateSubscriptionWithBodyWithResponse request with arbitrary body returning *CreateSubscriptionResponse -func (c *ClientWithResponses) CreateSubscriptionWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateSubscriptionResponse, error) { - rsp, err := c.CreateSubscriptionWithBody(ctx, projectID, contentType, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r ListSubscriptionsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseCreateSubscriptionResponse(rsp) + return http.StatusText(0) } -func (c *ClientWithResponses) CreateSubscriptionWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateSubscriptionJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateSubscriptionResponse, error) { - rsp, err := c.CreateSubscription(ctx, projectID, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r ListSubscriptionsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseCreateSubscriptionResponse(rsp) + return 0 } -// GetSubscriptionWithResponse request returning *GetSubscriptionResponse -func (c *ClientWithResponses) GetSubscriptionWithResponse(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetSubscriptionResponse, error) { - rsp, err := c.GetSubscription(ctx, projectID, subscriptionID, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetSubscriptionResponse(rsp) +type CreateSubscriptionResponse struct { + Body []byte + HTTPResponse *http.Response + JSON201 *Subscription + JSONDefault *Error } -// UpdateSubscriptionWithBodyWithResponse request with arbitrary body returning *UpdateSubscriptionResponse -func (c *ClientWithResponses) UpdateSubscriptionWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSubscriptionResponse, error) { - rsp, err := c.UpdateSubscriptionWithBody(ctx, projectID, subscriptionID, contentType, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r CreateSubscriptionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseUpdateSubscriptionResponse(rsp) + return http.StatusText(0) } -func (c *ClientWithResponses) UpdateSubscriptionWithResponse(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, body UpdateSubscriptionJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateSubscriptionResponse, error) { - rsp, err := c.UpdateSubscription(ctx, projectID, subscriptionID, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r CreateSubscriptionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseUpdateSubscriptionResponse(rsp) + return 0 } -// ListTagsWithResponse request returning *ListTagsResponse -func (c *ClientWithResponses) ListTagsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListTagsParams, reqEditors ...RequestEditorFn) (*ListTagsResponse, error) { - rsp, err := c.ListTags(ctx, projectID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseListTagsResponse(rsp) +type GetSubscriptionResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Subscription + JSONDefault *Error } -// CreateTagWithBodyWithResponse request with arbitrary body returning *CreateTagResponse -func (c *ClientWithResponses) CreateTagWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateTagResponse, error) { - rsp, err := c.CreateTagWithBody(ctx, projectID, contentType, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r GetSubscriptionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseCreateTagResponse(rsp) + return http.StatusText(0) } -func (c *ClientWithResponses) CreateTagWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateTagJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateTagResponse, error) { - rsp, err := c.CreateTag(ctx, projectID, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r GetSubscriptionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseCreateTagResponse(rsp) + return 0 } -// DeleteTagWithResponse request returning *DeleteTagResponse -func (c *ClientWithResponses) DeleteTagWithResponse(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteTagResponse, error) { - rsp, err := c.DeleteTag(ctx, projectID, tagID, reqEditors...) - if err != nil { - return nil, err - } - return ParseDeleteTagResponse(rsp) +type UpdateSubscriptionResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Subscription + JSONDefault *Error } -// GetTagWithResponse request returning *GetTagResponse -func (c *ClientWithResponses) GetTagWithResponse(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetTagResponse, error) { - rsp, err := c.GetTag(ctx, projectID, tagID, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r UpdateSubscriptionResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseGetTagResponse(rsp) + return http.StatusText(0) } -// UpdateTagWithBodyWithResponse request with arbitrary body returning *UpdateTagResponse -func (c *ClientWithResponses) UpdateTagWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateTagResponse, error) { - rsp, err := c.UpdateTagWithBody(ctx, projectID, tagID, contentType, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateSubscriptionResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseUpdateTagResponse(rsp) + return 0 } -func (c *ClientWithResponses) UpdateTagWithResponse(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, body UpdateTagJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateTagResponse, error) { - rsp, err := c.UpdateTag(ctx, projectID, tagID, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseUpdateTagResponse(rsp) +type ListTagsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *TagListResponse + JSONDefault *Error } -// ListUsersWithResponse request returning *ListUsersResponse -func (c *ClientWithResponses) ListUsersWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListUsersParams, reqEditors ...RequestEditorFn) (*ListUsersResponse, error) { - rsp, err := c.ListUsers(ctx, projectID, params, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r ListTagsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseListUsersResponse(rsp) + return http.StatusText(0) } -// IdentifyUserWithBodyWithResponse request with arbitrary body returning *IdentifyUserResponse -func (c *ClientWithResponses) IdentifyUserWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*IdentifyUserResponse, error) { - rsp, err := c.IdentifyUserWithBody(ctx, projectID, contentType, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r ListTagsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseIdentifyUserResponse(rsp) + return 0 } -func (c *ClientWithResponses) IdentifyUserWithResponse(ctx context.Context, projectID openapi_types.UUID, body IdentifyUserJSONRequestBody, reqEditors ...RequestEditorFn) (*IdentifyUserResponse, error) { - rsp, err := c.IdentifyUser(ctx, projectID, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseIdentifyUserResponse(rsp) +type CreateTagResponse struct { + Body []byte + HTTPResponse *http.Response + JSON201 *Tag + JSONDefault *Error } -// ImportUsersWithBodyWithResponse request with arbitrary body returning *ImportUsersResponse -func (c *ClientWithResponses) ImportUsersWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ImportUsersResponse, error) { - rsp, err := c.ImportUsersWithBody(ctx, projectID, contentType, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r CreateTagResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseImportUsersResponse(rsp) + return http.StatusText(0) } -// ListUserSchemasWithResponse request returning *ListUserSchemasResponse -func (c *ClientWithResponses) ListUserSchemasWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListUserSchemasResponse, error) { - rsp, err := c.ListUserSchemas(ctx, projectID, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r CreateTagResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseListUserSchemasResponse(rsp) + return 0 } -// DeleteUserWithResponse request returning *DeleteUserResponse -func (c *ClientWithResponses) DeleteUserWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteUserResponse, error) { - rsp, err := c.DeleteUser(ctx, projectID, userID, reqEditors...) - if err != nil { - return nil, err +type DeleteTagResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *Error +} + +// Status returns HTTPResponse.Status +func (r DeleteTagResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseDeleteUserResponse(rsp) + return http.StatusText(0) } -// GetUserWithResponse request returning *GetUserResponse -func (c *ClientWithResponses) GetUserWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetUserResponse, error) { - rsp, err := c.GetUser(ctx, projectID, userID, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteTagResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseGetUserResponse(rsp) + return 0 } -// UpdateUserWithBodyWithResponse request with arbitrary body returning *UpdateUserResponse -func (c *ClientWithResponses) UpdateUserWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateUserResponse, error) { - rsp, err := c.UpdateUserWithBody(ctx, projectID, userID, contentType, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseUpdateUserResponse(rsp) +type GetTagResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Tag + JSONDefault *Error } -func (c *ClientWithResponses) UpdateUserWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, body UpdateUserJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateUserResponse, error) { - rsp, err := c.UpdateUser(ctx, projectID, userID, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r GetTagResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseUpdateUserResponse(rsp) + return http.StatusText(0) } -// GetUserEventsWithResponse request returning *GetUserEventsResponse -func (c *ClientWithResponses) GetUserEventsWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, params *GetUserEventsParams, reqEditors ...RequestEditorFn) (*GetUserEventsResponse, error) { - rsp, err := c.GetUserEvents(ctx, projectID, userID, params, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r GetTagResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseGetUserEventsResponse(rsp) + return 0 } -// GetUserJourneysWithResponse request returning *GetUserJourneysResponse -func (c *ClientWithResponses) GetUserJourneysWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, params *GetUserJourneysParams, reqEditors ...RequestEditorFn) (*GetUserJourneysResponse, error) { - rsp, err := c.GetUserJourneys(ctx, projectID, userID, params, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetUserJourneysResponse(rsp) +type UpdateTagResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Tag + JSONDefault *Error } -// GetUserSubscriptionsWithResponse request returning *GetUserSubscriptionsResponse -func (c *ClientWithResponses) GetUserSubscriptionsWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, params *GetUserSubscriptionsParams, reqEditors ...RequestEditorFn) (*GetUserSubscriptionsResponse, error) { - rsp, err := c.GetUserSubscriptions(ctx, projectID, userID, params, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r UpdateTagResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseGetUserSubscriptionsResponse(rsp) + return http.StatusText(0) } -// UpdateUserSubscriptionsWithBodyWithResponse request with arbitrary body returning *UpdateUserSubscriptionsResponse -func (c *ClientWithResponses) UpdateUserSubscriptionsWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateUserSubscriptionsResponse, error) { - rsp, err := c.UpdateUserSubscriptionsWithBody(ctx, projectID, userID, contentType, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateTagResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseUpdateUserSubscriptionsResponse(rsp) + return 0 } -func (c *ClientWithResponses) UpdateUserSubscriptionsWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, body UpdateUserSubscriptionsJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateUserSubscriptionsResponse, error) { - rsp, err := c.UpdateUserSubscriptions(ctx, projectID, userID, body, reqEditors...) - if err != nil { - return nil, err - } - return ParseUpdateUserSubscriptionsResponse(rsp) +type DeleteTenantResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *Error } -// AuthCallbackWithBodyWithResponse request with arbitrary body returning *AuthCallbackResponse -func (c *ClientWithResponses) AuthCallbackWithBodyWithResponse(ctx context.Context, driver AuthCallbackParamsDriver, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AuthCallbackResponse, error) { - rsp, err := c.AuthCallbackWithBody(ctx, driver, contentType, body, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r DeleteTenantResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseAuthCallbackResponse(rsp) + return http.StatusText(0) } -func (c *ClientWithResponses) AuthCallbackWithResponse(ctx context.Context, driver AuthCallbackParamsDriver, body AuthCallbackJSONRequestBody, reqEditors ...RequestEditorFn) (*AuthCallbackResponse, error) { - rsp, err := c.AuthCallback(ctx, driver, body, reqEditors...) - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteTenantResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } - return ParseAuthCallbackResponse(rsp) + return 0 } -// GetAuthMethodsWithResponse request returning *GetAuthMethodsResponse -func (c *ClientWithResponses) GetAuthMethodsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAuthMethodsResponse, error) { - rsp, err := c.GetAuthMethods(ctx, reqEditors...) - if err != nil { - return nil, err - } - return ParseGetAuthMethodsResponse(rsp) +type GetTenantResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Tenant + JSONDefault *Error } -// AuthWebhookWithResponse request returning *AuthWebhookResponse -func (c *ClientWithResponses) AuthWebhookWithResponse(ctx context.Context, driver AuthWebhookParamsDriver, reqEditors ...RequestEditorFn) (*AuthWebhookResponse, error) { - rsp, err := c.AuthWebhook(ctx, driver, reqEditors...) - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r GetTenantResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } - return ParseAuthWebhookResponse(rsp) + return http.StatusText(0) } -// ParseDeleteOrganizationResponse parses an HTTP response from a DeleteOrganizationWithResponse call -func ParseDeleteOrganizationResponse(rsp *http.Response) (*DeleteOrganizationResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err +// StatusCode returns HTTPResponse.StatusCode +func (r GetTenantResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } + return 0 +} - response := &DeleteOrganizationResponse{ - Body: bodyBytes, - HTTPResponse: rsp, - } +type UpdateTenantResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Tenant + JSONDefault *Error +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest +// Status returns HTTPResponse.Status +func (r UpdateTenantResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateTenantResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } + return 0 +} - return response, nil +type ListAdminsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *AdminList + JSONDefault *Error } -// ParseGetOrganizationResponse parses an HTTP response from a GetOrganizationWithResponse call -func ParseGetOrganizationResponse(rsp *http.Response) (*GetOrganizationResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r ListAdminsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } + return http.StatusText(0) +} - response := &GetOrganizationResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// StatusCode returns HTTPResponse.StatusCode +func (r ListAdminsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } + return 0 +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Organization - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest +type CreateAdminResponse struct { + Body []byte + HTTPResponse *http.Response + JSON201 *Admin + JSONDefault *Error +} - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest +// Status returns HTTPResponse.Status +func (r CreateAdminResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} +// StatusCode returns HTTPResponse.StatusCode +func (r CreateAdminResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } + return 0 +} - return response, nil +type DeleteAdminResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *Error } -// ParseUpdateOrganizationResponse parses an HTTP response from a UpdateOrganizationWithResponse call -func ParseUpdateOrganizationResponse(rsp *http.Response) (*UpdateOrganizationResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r DeleteAdminResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } + return http.StatusText(0) +} - response := &UpdateOrganizationResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// StatusCode returns HTTPResponse.StatusCode +func (r DeleteAdminResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } + return 0 +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Organization - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest +type GetAdminResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Admin + JSONDefault *Error +} +// Status returns HTTPResponse.Status +func (r GetAdminResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } + return http.StatusText(0) +} - return response, nil +// StatusCode returns HTTPResponse.StatusCode +func (r GetAdminResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 } -// ParseListAdminsResponse parses an HTTP response from a ListAdminsWithResponse call -func ParseListAdminsResponse(rsp *http.Response) (*ListAdminsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err +type UpdateAdminResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Admin + JSONDefault *Error +} + +// Status returns HTTPResponse.Status +func (r UpdateAdminResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } + return http.StatusText(0) +} - response := &ListAdminsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// StatusCode returns HTTPResponse.StatusCode +func (r UpdateAdminResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } + return 0 +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest AdminList - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest +type GetTenantIntegrationsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *[]Provider + JSONDefault *Error +} - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest +// Status returns HTTPResponse.Status +func (r GetTenantIntegrationsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} +// StatusCode returns HTTPResponse.StatusCode +func (r GetTenantIntegrationsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } + return 0 +} - return response, nil +type WhoamiResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *Admin + JSONDefault *Error } -// ParseCreateAdminResponse parses an HTTP response from a CreateAdminWithResponse call -func ParseCreateAdminResponse(rsp *http.Response) (*CreateAdminResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r WhoamiResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } + return http.StatusText(0) +} - response := &CreateAdminResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// StatusCode returns HTTPResponse.StatusCode +func (r WhoamiResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } + return 0 +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest Admin - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest +type AuthCallbackResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *Error +} - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest +// Status returns HTTPResponse.Status +func (r AuthCallbackResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} +// StatusCode returns HTTPResponse.StatusCode +func (r AuthCallbackResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } + return 0 +} - return response, nil +type GetAuthMethodsResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *[]string + JSONDefault *Error } -// ParseDeleteAdminResponse parses an HTTP response from a DeleteAdminWithResponse call -func ParseDeleteAdminResponse(rsp *http.Response) (*DeleteAdminResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() - if err != nil { - return nil, err +// Status returns HTTPResponse.Status +func (r GetAuthMethodsResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } + return http.StatusText(0) +} - response := &DeleteAdminResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// StatusCode returns HTTPResponse.StatusCode +func (r GetAuthMethodsResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode } + return 0 +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest +type AuthWebhookResponse struct { + Body []byte + HTTPResponse *http.Response + JSONDefault *Error +} +// Status returns HTTPResponse.Status +func (r AuthWebhookResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status } + return http.StatusText(0) +} - return response, nil +// StatusCode returns HTTPResponse.StatusCode +func (r AuthWebhookResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 } -// ParseGetAdminResponse parses an HTTP response from a GetAdminWithResponse call -func ParseGetAdminResponse(rsp *http.Response) (*GetAdminResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// GetProfileWithResponse request returning *GetProfileResponse +func (c *ClientWithResponses) GetProfileWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetProfileResponse, error) { + rsp, err := c.GetProfile(ctx, reqEditors...) if err != nil { return nil, err } + return ParseGetProfileResponse(rsp) +} - response := &GetAdminResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// ListProjectsWithResponse request returning *ListProjectsResponse +func (c *ClientWithResponses) ListProjectsWithResponse(ctx context.Context, params *ListProjectsParams, reqEditors ...RequestEditorFn) (*ListProjectsResponse, error) { + rsp, err := c.ListProjects(ctx, params, reqEditors...) + if err != nil { + return nil, err } + return ParseListProjectsResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Admin - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// CreateProjectWithBodyWithResponse request with arbitrary body returning *CreateProjectResponse +func (c *ClientWithResponses) CreateProjectWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateProjectResponse, error) { + rsp, err := c.CreateProjectWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseCreateProjectResponse(rsp) } -// ParseUpdateAdminResponse parses an HTTP response from a UpdateAdminWithResponse call -func ParseUpdateAdminResponse(rsp *http.Response) (*UpdateAdminResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +func (c *ClientWithResponses) CreateProjectWithResponse(ctx context.Context, body CreateProjectJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateProjectResponse, error) { + rsp, err := c.CreateProject(ctx, body, reqEditors...) if err != nil { return nil, err } + return ParseCreateProjectResponse(rsp) +} - response := &UpdateAdminResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// GetProjectWithResponse request returning *GetProjectResponse +func (c *ClientWithResponses) GetProjectWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetProjectResponse, error) { + rsp, err := c.GetProject(ctx, projectID, reqEditors...) + if err != nil { + return nil, err } + return ParseGetProjectResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Admin - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// UpdateProjectWithBodyWithResponse request with arbitrary body returning *UpdateProjectResponse +func (c *ClientWithResponses) UpdateProjectWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateProjectResponse, error) { + rsp, err := c.UpdateProjectWithBody(ctx, projectID, contentType, body, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseUpdateProjectResponse(rsp) } -// ParseGetOrganizationIntegrationsResponse parses an HTTP response from a GetOrganizationIntegrationsWithResponse call -func ParseGetOrganizationIntegrationsResponse(rsp *http.Response) (*GetOrganizationIntegrationsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +func (c *ClientWithResponses) UpdateProjectWithResponse(ctx context.Context, projectID openapi_types.UUID, body UpdateProjectJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateProjectResponse, error) { + rsp, err := c.UpdateProject(ctx, projectID, body, reqEditors...) if err != nil { return nil, err } + return ParseUpdateProjectResponse(rsp) +} - response := &GetOrganizationIntegrationsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// ListProjectAdminsWithResponse request returning *ListProjectAdminsResponse +func (c *ClientWithResponses) ListProjectAdminsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListProjectAdminsParams, reqEditors ...RequestEditorFn) (*ListProjectAdminsResponse, error) { + rsp, err := c.ListProjectAdmins(ctx, projectID, params, reqEditors...) + if err != nil { + return nil, err } + return ParseListProjectAdminsResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []Provider - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// DeleteProjectAdminWithResponse request returning *DeleteProjectAdminResponse +func (c *ClientWithResponses) DeleteProjectAdminWithResponse(ctx context.Context, projectID openapi_types.UUID, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteProjectAdminResponse, error) { + rsp, err := c.DeleteProjectAdmin(ctx, projectID, adminID, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseDeleteProjectAdminResponse(rsp) } -// ParseWhoamiResponse parses an HTTP response from a WhoamiWithResponse call -func ParseWhoamiResponse(rsp *http.Response) (*WhoamiResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// GetProjectAdminWithResponse request returning *GetProjectAdminResponse +func (c *ClientWithResponses) GetProjectAdminWithResponse(ctx context.Context, projectID openapi_types.UUID, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetProjectAdminResponse, error) { + rsp, err := c.GetProjectAdmin(ctx, projectID, adminID, reqEditors...) if err != nil { return nil, err } + return ParseGetProjectAdminResponse(rsp) +} - response := &WhoamiResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// UpdateProjectAdminWithBodyWithResponse request with arbitrary body returning *UpdateProjectAdminResponse +func (c *ClientWithResponses) UpdateProjectAdminWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, adminID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateProjectAdminResponse, error) { + rsp, err := c.UpdateProjectAdminWithBody(ctx, projectID, adminID, contentType, body, reqEditors...) + if err != nil { + return nil, err } + return ParseUpdateProjectAdminResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Admin - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +func (c *ClientWithResponses) UpdateProjectAdminWithResponse(ctx context.Context, projectID openapi_types.UUID, adminID openapi_types.UUID, body UpdateProjectAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateProjectAdminResponse, error) { + rsp, err := c.UpdateProjectAdmin(ctx, projectID, adminID, body, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseUpdateProjectAdminResponse(rsp) } -// ParseGetProfileResponse parses an HTTP response from a GetProfileWithResponse call -func ParseGetProfileResponse(rsp *http.Response) (*GetProfileResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// ListCampaignsWithResponse request returning *ListCampaignsResponse +func (c *ClientWithResponses) ListCampaignsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListCampaignsParams, reqEditors ...RequestEditorFn) (*ListCampaignsResponse, error) { + rsp, err := c.ListCampaigns(ctx, projectID, params, reqEditors...) if err != nil { return nil, err } + return ParseListCampaignsResponse(rsp) +} - response := &GetProfileResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// CreateCampaignWithBodyWithResponse request with arbitrary body returning *CreateCampaignResponse +func (c *ClientWithResponses) CreateCampaignWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateCampaignResponse, error) { + rsp, err := c.CreateCampaignWithBody(ctx, projectID, contentType, body, reqEditors...) + if err != nil { + return nil, err } + return ParseCreateCampaignResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Admin - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +func (c *ClientWithResponses) CreateCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateCampaignResponse, error) { + rsp, err := c.CreateCampaign(ctx, projectID, body, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseCreateCampaignResponse(rsp) } -// ParseListProjectsResponse parses an HTTP response from a ListProjectsWithResponse call -func ParseListProjectsResponse(rsp *http.Response) (*ListProjectsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// DeleteCampaignWithResponse request returning *DeleteCampaignResponse +func (c *ClientWithResponses) DeleteCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteCampaignResponse, error) { + rsp, err := c.DeleteCampaign(ctx, projectID, campaignID, reqEditors...) if err != nil { return nil, err } + return ParseDeleteCampaignResponse(rsp) +} - response := &ListProjectsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// GetCampaignWithResponse request returning *GetCampaignResponse +func (c *ClientWithResponses) GetCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetCampaignResponse, error) { + rsp, err := c.GetCampaign(ctx, projectID, campaignID, reqEditors...) + if err != nil { + return nil, err } + return ParseGetCampaignResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest ProjectList - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// UpdateCampaignWithBodyWithResponse request with arbitrary body returning *UpdateCampaignResponse +func (c *ClientWithResponses) UpdateCampaignWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateCampaignResponse, error) { + rsp, err := c.UpdateCampaignWithBody(ctx, projectID, campaignID, contentType, body, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseUpdateCampaignResponse(rsp) } -// ParseCreateProjectResponse parses an HTTP response from a CreateProjectWithResponse call -func ParseCreateProjectResponse(rsp *http.Response) (*CreateProjectResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +func (c *ClientWithResponses) UpdateCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, body UpdateCampaignJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateCampaignResponse, error) { + rsp, err := c.UpdateCampaign(ctx, projectID, campaignID, body, reqEditors...) if err != nil { return nil, err } + return ParseUpdateCampaignResponse(rsp) +} - response := &CreateProjectResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// DuplicateCampaignWithResponse request returning *DuplicateCampaignResponse +func (c *ClientWithResponses) DuplicateCampaignWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DuplicateCampaignResponse, error) { + rsp, err := c.DuplicateCampaign(ctx, projectID, campaignID, reqEditors...) + if err != nil { + return nil, err } + return ParseDuplicateCampaignResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest Project - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest +// CreateTemplateWithBodyWithResponse request with arbitrary body returning *CreateTemplateResponse +func (c *ClientWithResponses) CreateTemplateWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateTemplateResponse, error) { + rsp, err := c.CreateTemplateWithBody(ctx, projectID, campaignID, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateTemplateResponse(rsp) +} +func (c *ClientWithResponses) CreateTemplateWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, body CreateTemplateJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateTemplateResponse, error) { + rsp, err := c.CreateTemplate(ctx, projectID, campaignID, body, reqEditors...) + if err != nil { + return nil, err } + return ParseCreateTemplateResponse(rsp) +} - return response, nil +// DeleteTemplateWithResponse request returning *DeleteTemplateResponse +func (c *ClientWithResponses) DeleteTemplateWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteTemplateResponse, error) { + rsp, err := c.DeleteTemplate(ctx, projectID, campaignID, templateID, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteTemplateResponse(rsp) } -// ParseGetProjectResponse parses an HTTP response from a GetProjectWithResponse call -func ParseGetProjectResponse(rsp *http.Response) (*GetProjectResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// GetTemplateWithResponse request returning *GetTemplateResponse +func (c *ClientWithResponses) GetTemplateWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetTemplateResponse, error) { + rsp, err := c.GetTemplate(ctx, projectID, campaignID, templateID, reqEditors...) if err != nil { return nil, err } + return ParseGetTemplateResponse(rsp) +} - response := &GetProjectResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// UpdateTemplateWithBodyWithResponse request with arbitrary body returning *UpdateTemplateResponse +func (c *ClientWithResponses) UpdateTemplateWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateTemplateResponse, error) { + rsp, err := c.UpdateTemplateWithBody(ctx, projectID, campaignID, templateID, contentType, body, reqEditors...) + if err != nil { + return nil, err } + return ParseUpdateTemplateResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Project - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +func (c *ClientWithResponses) UpdateTemplateWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID, body UpdateTemplateJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateTemplateResponse, error) { + rsp, err := c.UpdateTemplate(ctx, projectID, campaignID, templateID, body, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseUpdateTemplateResponse(rsp) } -// ParseUpdateProjectResponse parses an HTTP response from a UpdateProjectWithResponse call -func ParseUpdateProjectResponse(rsp *http.Response) (*UpdateProjectResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// GetCampaignUsersWithResponse request returning *GetCampaignUsersResponse +func (c *ClientWithResponses) GetCampaignUsersWithResponse(ctx context.Context, projectID openapi_types.UUID, campaignID openapi_types.UUID, params *GetCampaignUsersParams, reqEditors ...RequestEditorFn) (*GetCampaignUsersResponse, error) { + rsp, err := c.GetCampaignUsers(ctx, projectID, campaignID, params, reqEditors...) if err != nil { return nil, err } + return ParseGetCampaignUsersResponse(rsp) +} - response := &UpdateProjectResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// ListDocumentsWithResponse request returning *ListDocumentsResponse +func (c *ClientWithResponses) ListDocumentsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListDocumentsParams, reqEditors ...RequestEditorFn) (*ListDocumentsResponse, error) { + rsp, err := c.ListDocuments(ctx, projectID, params, reqEditors...) + if err != nil { + return nil, err } + return ParseListDocumentsResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Project - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// UploadDocumentsWithBodyWithResponse request with arbitrary body returning *UploadDocumentsResponse +func (c *ClientWithResponses) UploadDocumentsWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UploadDocumentsResponse, error) { + rsp, err := c.UploadDocumentsWithBody(ctx, projectID, contentType, body, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseUploadDocumentsResponse(rsp) } -// ParseListProjectAdminsResponse parses an HTTP response from a ListProjectAdminsWithResponse call -func ParseListProjectAdminsResponse(rsp *http.Response) (*ListProjectAdminsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// DeleteDocumentWithResponse request returning *DeleteDocumentResponse +func (c *ClientWithResponses) DeleteDocumentWithResponse(ctx context.Context, projectID openapi_types.UUID, documentID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteDocumentResponse, error) { + rsp, err := c.DeleteDocument(ctx, projectID, documentID, reqEditors...) if err != nil { return nil, err } + return ParseDeleteDocumentResponse(rsp) +} - response := &ListProjectAdminsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// GetDocumentWithResponse request returning *GetDocumentResponse +func (c *ClientWithResponses) GetDocumentWithResponse(ctx context.Context, projectID openapi_types.UUID, documentID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetDocumentResponse, error) { + rsp, err := c.GetDocument(ctx, projectID, documentID, reqEditors...) + if err != nil { + return nil, err } + return ParseGetDocumentResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest ProjectAdminList - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// GetDocumentMetadataWithResponse request returning *GetDocumentMetadataResponse +func (c *ClientWithResponses) GetDocumentMetadataWithResponse(ctx context.Context, projectID openapi_types.UUID, documentID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetDocumentMetadataResponse, error) { + rsp, err := c.GetDocumentMetadata(ctx, projectID, documentID, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseGetDocumentMetadataResponse(rsp) } -// ParseDeleteProjectAdminResponse parses an HTTP response from a DeleteProjectAdminWithResponse call -func ParseDeleteProjectAdminResponse(rsp *http.Response) (*DeleteProjectAdminResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// ListJourneysWithResponse request returning *ListJourneysResponse +func (c *ClientWithResponses) ListJourneysWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListJourneysParams, reqEditors ...RequestEditorFn) (*ListJourneysResponse, error) { + rsp, err := c.ListJourneys(ctx, projectID, params, reqEditors...) if err != nil { return nil, err } + return ParseListJourneysResponse(rsp) +} - response := &DeleteProjectAdminResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// CreateJourneyWithBodyWithResponse request with arbitrary body returning *CreateJourneyResponse +func (c *ClientWithResponses) CreateJourneyWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateJourneyResponse, error) { + rsp, err := c.CreateJourneyWithBody(ctx, projectID, contentType, body, reqEditors...) + if err != nil { + return nil, err } + return ParseCreateJourneyResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +func (c *ClientWithResponses) CreateJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateJourneyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateJourneyResponse, error) { + rsp, err := c.CreateJourney(ctx, projectID, body, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseCreateJourneyResponse(rsp) } -// ParseGetProjectAdminResponse parses an HTTP response from a GetProjectAdminWithResponse call -func ParseGetProjectAdminResponse(rsp *http.Response) (*GetProjectAdminResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// DeleteJourneyWithResponse request returning *DeleteJourneyResponse +func (c *ClientWithResponses) DeleteJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteJourneyResponse, error) { + rsp, err := c.DeleteJourney(ctx, projectID, journeyID, reqEditors...) if err != nil { return nil, err } + return ParseDeleteJourneyResponse(rsp) +} - response := &GetProjectAdminResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// GetJourneyWithResponse request returning *GetJourneyResponse +func (c *ClientWithResponses) GetJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetJourneyResponse, error) { + rsp, err := c.GetJourney(ctx, projectID, journeyID, reqEditors...) + if err != nil { + return nil, err } + return ParseGetJourneyResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest ProjectAdmin - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// UpdateJourneyWithBodyWithResponse request with arbitrary body returning *UpdateJourneyResponse +func (c *ClientWithResponses) UpdateJourneyWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateJourneyResponse, error) { + rsp, err := c.UpdateJourneyWithBody(ctx, projectID, journeyID, contentType, body, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseUpdateJourneyResponse(rsp) } -// ParseUpdateProjectAdminResponse parses an HTTP response from a UpdateProjectAdminWithResponse call -func ParseUpdateProjectAdminResponse(rsp *http.Response) (*UpdateProjectAdminResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +func (c *ClientWithResponses) UpdateJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, body UpdateJourneyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateJourneyResponse, error) { + rsp, err := c.UpdateJourney(ctx, projectID, journeyID, body, reqEditors...) if err != nil { return nil, err } + return ParseUpdateJourneyResponse(rsp) +} - response := &UpdateProjectAdminResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// DuplicateJourneyWithResponse request returning *DuplicateJourneyResponse +func (c *ClientWithResponses) DuplicateJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DuplicateJourneyResponse, error) { + rsp, err := c.DuplicateJourney(ctx, projectID, journeyID, reqEditors...) + if err != nil { + return nil, err } + return ParseDuplicateJourneyResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest ProjectAdmin - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest +// PublishJourneyWithResponse request returning *PublishJourneyResponse +func (c *ClientWithResponses) PublishJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*PublishJourneyResponse, error) { + rsp, err := c.PublishJourney(ctx, projectID, journeyID, reqEditors...) + if err != nil { + return nil, err + } + return ParsePublishJourneyResponse(rsp) +} +// GetJourneyStepsWithResponse request returning *GetJourneyStepsResponse +func (c *ClientWithResponses) GetJourneyStepsWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetJourneyStepsResponse, error) { + rsp, err := c.GetJourneySteps(ctx, projectID, journeyID, reqEditors...) + if err != nil { + return nil, err } + return ParseGetJourneyStepsResponse(rsp) +} - return response, nil +// SetJourneyStepsWithBodyWithResponse request with arbitrary body returning *SetJourneyStepsResponse +func (c *ClientWithResponses) SetJourneyStepsWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*SetJourneyStepsResponse, error) { + rsp, err := c.SetJourneyStepsWithBody(ctx, projectID, journeyID, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseSetJourneyStepsResponse(rsp) } -// ParseListCampaignsResponse parses an HTTP response from a ListCampaignsWithResponse call -func ParseListCampaignsResponse(rsp *http.Response) (*ListCampaignsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +func (c *ClientWithResponses) SetJourneyStepsWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, body SetJourneyStepsJSONRequestBody, reqEditors ...RequestEditorFn) (*SetJourneyStepsResponse, error) { + rsp, err := c.SetJourneySteps(ctx, projectID, journeyID, body, reqEditors...) if err != nil { return nil, err } + return ParseSetJourneyStepsResponse(rsp) +} - response := &ListCampaignsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// VersionJourneyWithResponse request returning *VersionJourneyResponse +func (c *ClientWithResponses) VersionJourneyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*VersionJourneyResponse, error) { + rsp, err := c.VersionJourney(ctx, projectID, journeyID, reqEditors...) + if err != nil { + return nil, err } + return ParseVersionJourneyResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest CampaignListResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// ListApiKeysWithResponse request returning *ListApiKeysResponse +func (c *ClientWithResponses) ListApiKeysWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListApiKeysParams, reqEditors ...RequestEditorFn) (*ListApiKeysResponse, error) { + rsp, err := c.ListApiKeys(ctx, projectID, params, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseListApiKeysResponse(rsp) } -// ParseCreateCampaignResponse parses an HTTP response from a CreateCampaignWithResponse call -func ParseCreateCampaignResponse(rsp *http.Response) (*CreateCampaignResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// CreateApiKeyWithBodyWithResponse request with arbitrary body returning *CreateApiKeyResponse +func (c *ClientWithResponses) CreateApiKeyWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) { + rsp, err := c.CreateApiKeyWithBody(ctx, projectID, contentType, body, reqEditors...) if err != nil { return nil, err } + return ParseCreateApiKeyResponse(rsp) +} - response := &CreateCampaignResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +func (c *ClientWithResponses) CreateApiKeyWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateApiKeyResponse, error) { + rsp, err := c.CreateApiKey(ctx, projectID, body, reqEditors...) + if err != nil { + return nil, err } + return ParseCreateApiKeyResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest Campaign - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// DeleteApiKeyWithResponse request returning *DeleteApiKeyResponse +func (c *ClientWithResponses) DeleteApiKeyWithResponse(ctx context.Context, projectID openapi_types.UUID, keyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteApiKeyResponse, error) { + rsp, err := c.DeleteApiKey(ctx, projectID, keyID, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseDeleteApiKeyResponse(rsp) } -// ParseDeleteCampaignResponse parses an HTTP response from a DeleteCampaignWithResponse call -func ParseDeleteCampaignResponse(rsp *http.Response) (*DeleteCampaignResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// GetApiKeyWithResponse request returning *GetApiKeyResponse +func (c *ClientWithResponses) GetApiKeyWithResponse(ctx context.Context, projectID openapi_types.UUID, keyID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetApiKeyResponse, error) { + rsp, err := c.GetApiKey(ctx, projectID, keyID, reqEditors...) if err != nil { return nil, err } + return ParseGetApiKeyResponse(rsp) +} - response := &DeleteCampaignResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// UpdateApiKeyWithBodyWithResponse request with arbitrary body returning *UpdateApiKeyResponse +func (c *ClientWithResponses) UpdateApiKeyWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, keyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) { + rsp, err := c.UpdateApiKeyWithBody(ctx, projectID, keyID, contentType, body, reqEditors...) + if err != nil { + return nil, err } + return ParseUpdateApiKeyResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +func (c *ClientWithResponses) UpdateApiKeyWithResponse(ctx context.Context, projectID openapi_types.UUID, keyID openapi_types.UUID, body UpdateApiKeyJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateApiKeyResponse, error) { + rsp, err := c.UpdateApiKey(ctx, projectID, keyID, body, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseUpdateApiKeyResponse(rsp) } -// ParseGetCampaignResponse parses an HTTP response from a GetCampaignWithResponse call -func ParseGetCampaignResponse(rsp *http.Response) (*GetCampaignResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// ListListsWithResponse request returning *ListListsResponse +func (c *ClientWithResponses) ListListsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListListsParams, reqEditors ...RequestEditorFn) (*ListListsResponse, error) { + rsp, err := c.ListLists(ctx, projectID, params, reqEditors...) if err != nil { return nil, err } + return ParseListListsResponse(rsp) +} - response := &GetCampaignResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// CreateListWithBodyWithResponse request with arbitrary body returning *CreateListResponse +func (c *ClientWithResponses) CreateListWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateListResponse, error) { + rsp, err := c.CreateListWithBody(ctx, projectID, contentType, body, reqEditors...) + if err != nil { + return nil, err } + return ParseCreateListResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest struct { - Data Campaign `json:"data"` - } - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +func (c *ClientWithResponses) CreateListWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateListJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateListResponse, error) { + rsp, err := c.CreateList(ctx, projectID, body, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseCreateListResponse(rsp) } -// ParseUpdateCampaignResponse parses an HTTP response from a UpdateCampaignWithResponse call -func ParseUpdateCampaignResponse(rsp *http.Response) (*UpdateCampaignResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// DeleteListWithResponse request returning *DeleteListResponse +func (c *ClientWithResponses) DeleteListWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteListResponse, error) { + rsp, err := c.DeleteList(ctx, projectID, listID, reqEditors...) if err != nil { return nil, err } + return ParseDeleteListResponse(rsp) +} - response := &UpdateCampaignResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// GetListWithResponse request returning *GetListResponse +func (c *ClientWithResponses) GetListWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetListResponse, error) { + rsp, err := c.GetList(ctx, projectID, listID, reqEditors...) + if err != nil { + return nil, err } + return ParseGetListResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Campaign - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// UpdateListWithBodyWithResponse request with arbitrary body returning *UpdateListResponse +func (c *ClientWithResponses) UpdateListWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateListResponse, error) { + rsp, err := c.UpdateListWithBody(ctx, projectID, listID, contentType, body, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseUpdateListResponse(rsp) } -// ParseDuplicateCampaignResponse parses an HTTP response from a DuplicateCampaignWithResponse call -func ParseDuplicateCampaignResponse(rsp *http.Response) (*DuplicateCampaignResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +func (c *ClientWithResponses) UpdateListWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, body UpdateListJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateListResponse, error) { + rsp, err := c.UpdateList(ctx, projectID, listID, body, reqEditors...) if err != nil { return nil, err } + return ParseUpdateListResponse(rsp) +} - response := &DuplicateCampaignResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// DuplicateListWithResponse request returning *DuplicateListResponse +func (c *ClientWithResponses) DuplicateListWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DuplicateListResponse, error) { + rsp, err := c.DuplicateList(ctx, projectID, listID, reqEditors...) + if err != nil { + return nil, err } + return ParseDuplicateListResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest Campaign - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest +// GetListUsersWithResponse request returning *GetListUsersResponse +func (c *ClientWithResponses) GetListUsersWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, params *GetListUsersParams, reqEditors ...RequestEditorFn) (*GetListUsersResponse, error) { + rsp, err := c.GetListUsers(ctx, projectID, listID, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetListUsersResponse(rsp) +} +// ImportListUsersWithBodyWithResponse request with arbitrary body returning *ImportListUsersResponse +func (c *ClientWithResponses) ImportListUsersWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, listID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ImportListUsersResponse, error) { + rsp, err := c.ImportListUsersWithBody(ctx, projectID, listID, contentType, body, reqEditors...) + if err != nil { + return nil, err } + return ParseImportListUsersResponse(rsp) +} - return response, nil +// ListLocalesWithResponse request returning *ListLocalesResponse +func (c *ClientWithResponses) ListLocalesWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListLocalesParams, reqEditors ...RequestEditorFn) (*ListLocalesResponse, error) { + rsp, err := c.ListLocales(ctx, projectID, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListLocalesResponse(rsp) } -// ParseCreateTemplateResponse parses an HTTP response from a CreateTemplateWithResponse call -func ParseCreateTemplateResponse(rsp *http.Response) (*CreateTemplateResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// CreateLocaleWithBodyWithResponse request with arbitrary body returning *CreateLocaleResponse +func (c *ClientWithResponses) CreateLocaleWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateLocaleResponse, error) { + rsp, err := c.CreateLocaleWithBody(ctx, projectID, contentType, body, reqEditors...) if err != nil { return nil, err } + return ParseCreateLocaleResponse(rsp) +} - response := &CreateTemplateResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +func (c *ClientWithResponses) CreateLocaleWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateLocaleJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateLocaleResponse, error) { + rsp, err := c.CreateLocale(ctx, projectID, body, reqEditors...) + if err != nil { + return nil, err } + return ParseCreateLocaleResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest Template - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// DeleteLocaleWithResponse request returning *DeleteLocaleResponse +func (c *ClientWithResponses) DeleteLocaleWithResponse(ctx context.Context, projectID openapi_types.UUID, localeID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteLocaleResponse, error) { + rsp, err := c.DeleteLocale(ctx, projectID, localeID, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseDeleteLocaleResponse(rsp) } -// ParseDeleteTemplateResponse parses an HTTP response from a DeleteTemplateWithResponse call -func ParseDeleteTemplateResponse(rsp *http.Response) (*DeleteTemplateResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// GetLocaleWithResponse request returning *GetLocaleResponse +func (c *ClientWithResponses) GetLocaleWithResponse(ctx context.Context, projectID openapi_types.UUID, localeID string, reqEditors ...RequestEditorFn) (*GetLocaleResponse, error) { + rsp, err := c.GetLocale(ctx, projectID, localeID, reqEditors...) if err != nil { return nil, err } + return ParseGetLocaleResponse(rsp) +} - response := &DeleteTemplateResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// ListProvidersWithResponse request returning *ListProvidersResponse +func (c *ClientWithResponses) ListProvidersWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListProvidersParams, reqEditors ...RequestEditorFn) (*ListProvidersResponse, error) { + rsp, err := c.ListProviders(ctx, projectID, params, reqEditors...) + if err != nil { + return nil, err } + return ParseListProvidersResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// ListAllProvidersWithResponse request returning *ListAllProvidersResponse +func (c *ClientWithResponses) ListAllProvidersWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListAllProvidersResponse, error) { + rsp, err := c.ListAllProviders(ctx, projectID, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseListAllProvidersResponse(rsp) } -// ParseGetTemplateResponse parses an HTTP response from a GetTemplateWithResponse call -func ParseGetTemplateResponse(rsp *http.Response) (*GetTemplateResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// ListProviderMetaWithResponse request returning *ListProviderMetaResponse +func (c *ClientWithResponses) ListProviderMetaWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListProviderMetaResponse, error) { + rsp, err := c.ListProviderMeta(ctx, projectID, reqEditors...) if err != nil { return nil, err } + return ParseListProviderMetaResponse(rsp) +} - response := &GetTemplateResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// CreateProviderWithBodyWithResponse request with arbitrary body returning *CreateProviderResponse +func (c *ClientWithResponses) CreateProviderWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateProviderResponse, error) { + rsp, err := c.CreateProviderWithBody(ctx, projectID, group, pType, contentType, body, reqEditors...) + if err != nil { + return nil, err } + return ParseCreateProviderResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest struct { - Data Template `json:"data"` - } - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +func (c *ClientWithResponses) CreateProviderWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, body CreateProviderJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateProviderResponse, error) { + rsp, err := c.CreateProvider(ctx, projectID, group, pType, body, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseCreateProviderResponse(rsp) } -// ParseUpdateTemplateResponse parses an HTTP response from a UpdateTemplateWithResponse call -func ParseUpdateTemplateResponse(rsp *http.Response) (*UpdateTemplateResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// GetProviderWithResponse request returning *GetProviderResponse +func (c *ClientWithResponses) GetProviderWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, providerID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetProviderResponse, error) { + rsp, err := c.GetProvider(ctx, projectID, group, pType, providerID, reqEditors...) if err != nil { return nil, err } + return ParseGetProviderResponse(rsp) +} - response := &UpdateTemplateResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// UpdateProviderWithBodyWithResponse request with arbitrary body returning *UpdateProviderResponse +func (c *ClientWithResponses) UpdateProviderWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, providerID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateProviderResponse, error) { + rsp, err := c.UpdateProviderWithBody(ctx, projectID, group, pType, providerID, contentType, body, reqEditors...) + if err != nil { + return nil, err } + return ParseUpdateProviderResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Template - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +func (c *ClientWithResponses) UpdateProviderWithResponse(ctx context.Context, projectID openapi_types.UUID, group string, pType string, providerID openapi_types.UUID, body UpdateProviderJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateProviderResponse, error) { + rsp, err := c.UpdateProvider(ctx, projectID, group, pType, providerID, body, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseUpdateProviderResponse(rsp) } -// ParseGetCampaignUsersResponse parses an HTTP response from a GetCampaignUsersWithResponse call -func ParseGetCampaignUsersResponse(rsp *http.Response) (*GetCampaignUsersResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// DeleteProviderWithResponse request returning *DeleteProviderResponse +func (c *ClientWithResponses) DeleteProviderWithResponse(ctx context.Context, projectID openapi_types.UUID, providerID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteProviderResponse, error) { + rsp, err := c.DeleteProvider(ctx, projectID, providerID, reqEditors...) if err != nil { return nil, err } + return ParseDeleteProviderResponse(rsp) +} - response := &GetCampaignUsersResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// ListEventsWithResponse request returning *ListEventsResponse +func (c *ClientWithResponses) ListEventsWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListEventsResponse, error) { + rsp, err := c.ListEvents(ctx, projectID, reqEditors...) + if err != nil { + return nil, err } + return ParseListEventsResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest struct { - Data []CampaignUser `json:"data"` - Limit int `json:"limit"` - Offset int `json:"offset"` - Total int `json:"total"` - } - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// ListOrganizationsWithResponse request returning *ListOrganizationsResponse +func (c *ClientWithResponses) ListOrganizationsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListOrganizationsParams, reqEditors ...RequestEditorFn) (*ListOrganizationsResponse, error) { + rsp, err := c.ListOrganizations(ctx, projectID, params, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseListOrganizationsResponse(rsp) } -// ParseListDocumentsResponse parses an HTTP response from a ListDocumentsWithResponse call -func ParseListDocumentsResponse(rsp *http.Response) (*ListDocumentsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// UpsertOrganizationWithBodyWithResponse request with arbitrary body returning *UpsertOrganizationResponse +func (c *ClientWithResponses) UpsertOrganizationWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpsertOrganizationResponse, error) { + rsp, err := c.UpsertOrganizationWithBody(ctx, projectID, contentType, body, reqEditors...) if err != nil { return nil, err } + return ParseUpsertOrganizationResponse(rsp) +} - response := &ListDocumentsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +func (c *ClientWithResponses) UpsertOrganizationWithResponse(ctx context.Context, projectID openapi_types.UUID, body UpsertOrganizationJSONRequestBody, reqEditors ...RequestEditorFn) (*UpsertOrganizationResponse, error) { + rsp, err := c.UpsertOrganization(ctx, projectID, body, reqEditors...) + if err != nil { + return nil, err } + return ParseUpsertOrganizationResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest DocumentListResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// ListOrganizationSchemasWithResponse request returning *ListOrganizationSchemasResponse +func (c *ClientWithResponses) ListOrganizationSchemasWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListOrganizationSchemasResponse, error) { + rsp, err := c.ListOrganizationSchemas(ctx, projectID, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseListOrganizationSchemasResponse(rsp) } -// ParseUploadDocumentsResponse parses an HTTP response from a UploadDocumentsWithResponse call -func ParseUploadDocumentsResponse(rsp *http.Response) (*UploadDocumentsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// ListOrganizationMemberSchemasWithResponse request returning *ListOrganizationMemberSchemasResponse +func (c *ClientWithResponses) ListOrganizationMemberSchemasWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListOrganizationMemberSchemasResponse, error) { + rsp, err := c.ListOrganizationMemberSchemas(ctx, projectID, reqEditors...) if err != nil { return nil, err } + return ParseListOrganizationMemberSchemasResponse(rsp) +} - response := &UploadDocumentsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// DeleteOrganizationWithResponse request returning *DeleteOrganizationResponse +func (c *ClientWithResponses) DeleteOrganizationWithResponse(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteOrganizationResponse, error) { + rsp, err := c.DeleteOrganization(ctx, projectID, organizationID, reqEditors...) + if err != nil { + return nil, err } + return ParseDeleteOrganizationResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest struct { - // Documents UUIDs of the uploaded documents - Documents []openapi_types.UUID `json:"documents"` - } - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// GetOrganizationWithResponse request returning *GetOrganizationResponse +func (c *ClientWithResponses) GetOrganizationWithResponse(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetOrganizationResponse, error) { + rsp, err := c.GetOrganization(ctx, projectID, organizationID, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseGetOrganizationResponse(rsp) } -// ParseDeleteDocumentResponse parses an HTTP response from a DeleteDocumentWithResponse call -func ParseDeleteDocumentResponse(rsp *http.Response) (*DeleteDocumentResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// UpdateOrganizationWithBodyWithResponse request with arbitrary body returning *UpdateOrganizationResponse +func (c *ClientWithResponses) UpdateOrganizationWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateOrganizationResponse, error) { + rsp, err := c.UpdateOrganizationWithBody(ctx, projectID, organizationID, contentType, body, reqEditors...) if err != nil { return nil, err } + return ParseUpdateOrganizationResponse(rsp) +} - response := &DeleteDocumentResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +func (c *ClientWithResponses) UpdateOrganizationWithResponse(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, body UpdateOrganizationJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateOrganizationResponse, error) { + rsp, err := c.UpdateOrganization(ctx, projectID, organizationID, body, reqEditors...) + if err != nil { + return nil, err } + return ParseUpdateOrganizationResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// ListOrganizationMembersWithResponse request returning *ListOrganizationMembersResponse +func (c *ClientWithResponses) ListOrganizationMembersWithResponse(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, params *ListOrganizationMembersParams, reqEditors ...RequestEditorFn) (*ListOrganizationMembersResponse, error) { + rsp, err := c.ListOrganizationMembers(ctx, projectID, organizationID, params, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseListOrganizationMembersResponse(rsp) } -// ParseGetDocumentResponse parses an HTTP response from a GetDocumentWithResponse call -func ParseGetDocumentResponse(rsp *http.Response) (*GetDocumentResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// AddOrganizationMemberWithBodyWithResponse request with arbitrary body returning *AddOrganizationMemberResponse +func (c *ClientWithResponses) AddOrganizationMemberWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AddOrganizationMemberResponse, error) { + rsp, err := c.AddOrganizationMemberWithBody(ctx, projectID, organizationID, contentType, body, reqEditors...) if err != nil { return nil, err } + return ParseAddOrganizationMemberResponse(rsp) +} - response := &GetDocumentResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +func (c *ClientWithResponses) AddOrganizationMemberWithResponse(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, body AddOrganizationMemberJSONRequestBody, reqEditors ...RequestEditorFn) (*AddOrganizationMemberResponse, error) { + rsp, err := c.AddOrganizationMember(ctx, projectID, organizationID, body, reqEditors...) + if err != nil { + return nil, err } + return ParseAddOrganizationMemberResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// RemoveOrganizationMemberWithResponse request returning *RemoveOrganizationMemberResponse +func (c *ClientWithResponses) RemoveOrganizationMemberWithResponse(ctx context.Context, projectID openapi_types.UUID, organizationID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*RemoveOrganizationMemberResponse, error) { + rsp, err := c.RemoveOrganizationMember(ctx, projectID, organizationID, userID, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseRemoveOrganizationMemberResponse(rsp) } -// ParseGetDocumentMetadataResponse parses an HTTP response from a GetDocumentMetadataWithResponse call -func ParseGetDocumentMetadataResponse(rsp *http.Response) (*GetDocumentMetadataResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// ListUsersWithResponse request returning *ListUsersResponse +func (c *ClientWithResponses) ListUsersWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListUsersParams, reqEditors ...RequestEditorFn) (*ListUsersResponse, error) { + rsp, err := c.ListUsers(ctx, projectID, params, reqEditors...) if err != nil { return nil, err } + return ParseListUsersResponse(rsp) +} - response := &GetDocumentMetadataResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// IdentifyUserWithBodyWithResponse request with arbitrary body returning *IdentifyUserResponse +func (c *ClientWithResponses) IdentifyUserWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*IdentifyUserResponse, error) { + rsp, err := c.IdentifyUserWithBody(ctx, projectID, contentType, body, reqEditors...) + if err != nil { + return nil, err } + return ParseIdentifyUserResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Document - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +func (c *ClientWithResponses) IdentifyUserWithResponse(ctx context.Context, projectID openapi_types.UUID, body IdentifyUserJSONRequestBody, reqEditors ...RequestEditorFn) (*IdentifyUserResponse, error) { + rsp, err := c.IdentifyUser(ctx, projectID, body, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseIdentifyUserResponse(rsp) } -// ParseListEventsResponse parses an HTTP response from a ListEventsWithResponse call -func ParseListEventsResponse(rsp *http.Response) (*ListEventsResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// ImportUsersWithBodyWithResponse request with arbitrary body returning *ImportUsersResponse +func (c *ClientWithResponses) ImportUsersWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*ImportUsersResponse, error) { + rsp, err := c.ImportUsersWithBody(ctx, projectID, contentType, body, reqEditors...) if err != nil { return nil, err } + return ParseImportUsersResponse(rsp) +} - response := &ListEventsResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// ListUserSchemasWithResponse request returning *ListUserSchemasResponse +func (c *ClientWithResponses) ListUserSchemasWithResponse(ctx context.Context, projectID openapi_types.UUID, reqEditors ...RequestEditorFn) (*ListUserSchemasResponse, error) { + rsp, err := c.ListUserSchemas(ctx, projectID, reqEditors...) + if err != nil { + return nil, err } + return ParseListUserSchemasResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest EventListResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// DeleteUserWithResponse request returning *DeleteUserResponse +func (c *ClientWithResponses) DeleteUserWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteUserResponse, error) { + rsp, err := c.DeleteUser(ctx, projectID, userID, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseDeleteUserResponse(rsp) } -// ParseListJourneysResponse parses an HTTP response from a ListJourneysWithResponse call -func ParseListJourneysResponse(rsp *http.Response) (*ListJourneysResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// GetUserWithResponse request returning *GetUserResponse +func (c *ClientWithResponses) GetUserWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetUserResponse, error) { + rsp, err := c.GetUser(ctx, projectID, userID, reqEditors...) if err != nil { return nil, err } + return ParseGetUserResponse(rsp) +} - response := &ListJourneysResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// UpdateUserWithBodyWithResponse request with arbitrary body returning *UpdateUserResponse +func (c *ClientWithResponses) UpdateUserWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateUserResponse, error) { + rsp, err := c.UpdateUserWithBody(ctx, projectID, userID, contentType, body, reqEditors...) + if err != nil { + return nil, err } + return ParseUpdateUserResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest JourneyListResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +func (c *ClientWithResponses) UpdateUserWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, body UpdateUserJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateUserResponse, error) { + rsp, err := c.UpdateUser(ctx, projectID, userID, body, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseUpdateUserResponse(rsp) } -// ParseCreateJourneyResponse parses an HTTP response from a CreateJourneyWithResponse call -func ParseCreateJourneyResponse(rsp *http.Response) (*CreateJourneyResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// GetUserEventsWithResponse request returning *GetUserEventsResponse +func (c *ClientWithResponses) GetUserEventsWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, params *GetUserEventsParams, reqEditors ...RequestEditorFn) (*GetUserEventsResponse, error) { + rsp, err := c.GetUserEvents(ctx, projectID, userID, params, reqEditors...) if err != nil { return nil, err } + return ParseGetUserEventsResponse(rsp) +} - response := &CreateJourneyResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// GetUserJourneysWithResponse request returning *GetUserJourneysResponse +func (c *ClientWithResponses) GetUserJourneysWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, params *GetUserJourneysParams, reqEditors ...RequestEditorFn) (*GetUserJourneysResponse, error) { + rsp, err := c.GetUserJourneys(ctx, projectID, userID, params, reqEditors...) + if err != nil { + return nil, err } + return ParseGetUserJourneysResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest Journey - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +// GetUserOrganizationsWithResponse request returning *GetUserOrganizationsResponse +func (c *ClientWithResponses) GetUserOrganizationsWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetUserOrganizationsResponse, error) { + rsp, err := c.GetUserOrganizations(ctx, projectID, userID, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseGetUserOrganizationsResponse(rsp) } -// ParseDeleteJourneyResponse parses an HTTP response from a DeleteJourneyWithResponse call -func ParseDeleteJourneyResponse(rsp *http.Response) (*DeleteJourneyResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// GetUserSubscriptionsWithResponse request returning *GetUserSubscriptionsResponse +func (c *ClientWithResponses) GetUserSubscriptionsWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, params *GetUserSubscriptionsParams, reqEditors ...RequestEditorFn) (*GetUserSubscriptionsResponse, error) { + rsp, err := c.GetUserSubscriptions(ctx, projectID, userID, params, reqEditors...) if err != nil { return nil, err } + return ParseGetUserSubscriptionsResponse(rsp) +} - response := &DeleteJourneyResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// UpdateUserSubscriptionsWithBodyWithResponse request with arbitrary body returning *UpdateUserSubscriptionsResponse +func (c *ClientWithResponses) UpdateUserSubscriptionsWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateUserSubscriptionsResponse, error) { + rsp, err := c.UpdateUserSubscriptionsWithBody(ctx, projectID, userID, contentType, body, reqEditors...) + if err != nil { + return nil, err } + return ParseUpdateUserSubscriptionsResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest - +func (c *ClientWithResponses) UpdateUserSubscriptionsWithResponse(ctx context.Context, projectID openapi_types.UUID, userID openapi_types.UUID, body UpdateUserSubscriptionsJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateUserSubscriptionsResponse, error) { + rsp, err := c.UpdateUserSubscriptions(ctx, projectID, userID, body, reqEditors...) + if err != nil { + return nil, err } - - return response, nil + return ParseUpdateUserSubscriptionsResponse(rsp) } -// ParseGetJourneyResponse parses an HTTP response from a GetJourneyWithResponse call -func ParseGetJourneyResponse(rsp *http.Response) (*GetJourneyResponse, error) { - bodyBytes, err := io.ReadAll(rsp.Body) - defer func() { _ = rsp.Body.Close() }() +// ListSubscriptionsWithResponse request returning *ListSubscriptionsResponse +func (c *ClientWithResponses) ListSubscriptionsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListSubscriptionsParams, reqEditors ...RequestEditorFn) (*ListSubscriptionsResponse, error) { + rsp, err := c.ListSubscriptions(ctx, projectID, params, reqEditors...) if err != nil { return nil, err } + return ParseListSubscriptionsResponse(rsp) +} - response := &GetJourneyResponse{ - Body: bodyBytes, - HTTPResponse: rsp, +// CreateSubscriptionWithBodyWithResponse request with arbitrary body returning *CreateSubscriptionResponse +func (c *ClientWithResponses) CreateSubscriptionWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateSubscriptionResponse, error) { + rsp, err := c.CreateSubscriptionWithBody(ctx, projectID, contentType, body, reqEditors...) + if err != nil { + return nil, err } + return ParseCreateSubscriptionResponse(rsp) +} - switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Journey - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: - var dest Error - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSONDefault = &dest +func (c *ClientWithResponses) CreateSubscriptionWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateSubscriptionJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateSubscriptionResponse, error) { + rsp, err := c.CreateSubscription(ctx, projectID, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateSubscriptionResponse(rsp) +} +// GetSubscriptionWithResponse request returning *GetSubscriptionResponse +func (c *ClientWithResponses) GetSubscriptionWithResponse(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetSubscriptionResponse, error) { + rsp, err := c.GetSubscription(ctx, projectID, subscriptionID, reqEditors...) + if err != nil { + return nil, err } + return ParseGetSubscriptionResponse(rsp) +} - return response, nil +// UpdateSubscriptionWithBodyWithResponse request with arbitrary body returning *UpdateSubscriptionResponse +func (c *ClientWithResponses) UpdateSubscriptionWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateSubscriptionResponse, error) { + rsp, err := c.UpdateSubscriptionWithBody(ctx, projectID, subscriptionID, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateSubscriptionResponse(rsp) } -// ParseUpdateJourneyResponse parses an HTTP response from a UpdateJourneyWithResponse call -func ParseUpdateJourneyResponse(rsp *http.Response) (*UpdateJourneyResponse, error) { +func (c *ClientWithResponses) UpdateSubscriptionWithResponse(ctx context.Context, projectID openapi_types.UUID, subscriptionID openapi_types.UUID, body UpdateSubscriptionJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateSubscriptionResponse, error) { + rsp, err := c.UpdateSubscription(ctx, projectID, subscriptionID, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateSubscriptionResponse(rsp) +} + +// ListTagsWithResponse request returning *ListTagsResponse +func (c *ClientWithResponses) ListTagsWithResponse(ctx context.Context, projectID openapi_types.UUID, params *ListTagsParams, reqEditors ...RequestEditorFn) (*ListTagsResponse, error) { + rsp, err := c.ListTags(ctx, projectID, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListTagsResponse(rsp) +} + +// CreateTagWithBodyWithResponse request with arbitrary body returning *CreateTagResponse +func (c *ClientWithResponses) CreateTagWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateTagResponse, error) { + rsp, err := c.CreateTagWithBody(ctx, projectID, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateTagResponse(rsp) +} + +func (c *ClientWithResponses) CreateTagWithResponse(ctx context.Context, projectID openapi_types.UUID, body CreateTagJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateTagResponse, error) { + rsp, err := c.CreateTag(ctx, projectID, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateTagResponse(rsp) +} + +// DeleteTagWithResponse request returning *DeleteTagResponse +func (c *ClientWithResponses) DeleteTagWithResponse(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteTagResponse, error) { + rsp, err := c.DeleteTag(ctx, projectID, tagID, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteTagResponse(rsp) +} + +// GetTagWithResponse request returning *GetTagResponse +func (c *ClientWithResponses) GetTagWithResponse(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetTagResponse, error) { + rsp, err := c.GetTag(ctx, projectID, tagID, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetTagResponse(rsp) +} + +// UpdateTagWithBodyWithResponse request with arbitrary body returning *UpdateTagResponse +func (c *ClientWithResponses) UpdateTagWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateTagResponse, error) { + rsp, err := c.UpdateTagWithBody(ctx, projectID, tagID, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateTagResponse(rsp) +} + +func (c *ClientWithResponses) UpdateTagWithResponse(ctx context.Context, projectID openapi_types.UUID, tagID openapi_types.UUID, body UpdateTagJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateTagResponse, error) { + rsp, err := c.UpdateTag(ctx, projectID, tagID, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateTagResponse(rsp) +} + +// DeleteTenantWithResponse request returning *DeleteTenantResponse +func (c *ClientWithResponses) DeleteTenantWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*DeleteTenantResponse, error) { + rsp, err := c.DeleteTenant(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteTenantResponse(rsp) +} + +// GetTenantWithResponse request returning *GetTenantResponse +func (c *ClientWithResponses) GetTenantWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetTenantResponse, error) { + rsp, err := c.GetTenant(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetTenantResponse(rsp) +} + +// UpdateTenantWithBodyWithResponse request with arbitrary body returning *UpdateTenantResponse +func (c *ClientWithResponses) UpdateTenantWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateTenantResponse, error) { + rsp, err := c.UpdateTenantWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateTenantResponse(rsp) +} + +func (c *ClientWithResponses) UpdateTenantWithResponse(ctx context.Context, body UpdateTenantJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateTenantResponse, error) { + rsp, err := c.UpdateTenant(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateTenantResponse(rsp) +} + +// ListAdminsWithResponse request returning *ListAdminsResponse +func (c *ClientWithResponses) ListAdminsWithResponse(ctx context.Context, params *ListAdminsParams, reqEditors ...RequestEditorFn) (*ListAdminsResponse, error) { + rsp, err := c.ListAdmins(ctx, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseListAdminsResponse(rsp) +} + +// CreateAdminWithBodyWithResponse request with arbitrary body returning *CreateAdminResponse +func (c *ClientWithResponses) CreateAdminWithBodyWithResponse(ctx context.Context, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*CreateAdminResponse, error) { + rsp, err := c.CreateAdminWithBody(ctx, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateAdminResponse(rsp) +} + +func (c *ClientWithResponses) CreateAdminWithResponse(ctx context.Context, body CreateAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*CreateAdminResponse, error) { + rsp, err := c.CreateAdmin(ctx, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseCreateAdminResponse(rsp) +} + +// DeleteAdminWithResponse request returning *DeleteAdminResponse +func (c *ClientWithResponses) DeleteAdminWithResponse(ctx context.Context, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*DeleteAdminResponse, error) { + rsp, err := c.DeleteAdmin(ctx, adminID, reqEditors...) + if err != nil { + return nil, err + } + return ParseDeleteAdminResponse(rsp) +} + +// GetAdminWithResponse request returning *GetAdminResponse +func (c *ClientWithResponses) GetAdminWithResponse(ctx context.Context, adminID openapi_types.UUID, reqEditors ...RequestEditorFn) (*GetAdminResponse, error) { + rsp, err := c.GetAdmin(ctx, adminID, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetAdminResponse(rsp) +} + +// UpdateAdminWithBodyWithResponse request with arbitrary body returning *UpdateAdminResponse +func (c *ClientWithResponses) UpdateAdminWithBodyWithResponse(ctx context.Context, adminID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*UpdateAdminResponse, error) { + rsp, err := c.UpdateAdminWithBody(ctx, adminID, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateAdminResponse(rsp) +} + +func (c *ClientWithResponses) UpdateAdminWithResponse(ctx context.Context, adminID openapi_types.UUID, body UpdateAdminJSONRequestBody, reqEditors ...RequestEditorFn) (*UpdateAdminResponse, error) { + rsp, err := c.UpdateAdmin(ctx, adminID, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseUpdateAdminResponse(rsp) +} + +// GetTenantIntegrationsWithResponse request returning *GetTenantIntegrationsResponse +func (c *ClientWithResponses) GetTenantIntegrationsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetTenantIntegrationsResponse, error) { + rsp, err := c.GetTenantIntegrations(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetTenantIntegrationsResponse(rsp) +} + +// WhoamiWithResponse request returning *WhoamiResponse +func (c *ClientWithResponses) WhoamiWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*WhoamiResponse, error) { + rsp, err := c.Whoami(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseWhoamiResponse(rsp) +} + +// AuthCallbackWithBodyWithResponse request with arbitrary body returning *AuthCallbackResponse +func (c *ClientWithResponses) AuthCallbackWithBodyWithResponse(ctx context.Context, driver AuthCallbackParamsDriver, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*AuthCallbackResponse, error) { + rsp, err := c.AuthCallbackWithBody(ctx, driver, contentType, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAuthCallbackResponse(rsp) +} + +func (c *ClientWithResponses) AuthCallbackWithResponse(ctx context.Context, driver AuthCallbackParamsDriver, body AuthCallbackJSONRequestBody, reqEditors ...RequestEditorFn) (*AuthCallbackResponse, error) { + rsp, err := c.AuthCallback(ctx, driver, body, reqEditors...) + if err != nil { + return nil, err + } + return ParseAuthCallbackResponse(rsp) +} + +// GetAuthMethodsWithResponse request returning *GetAuthMethodsResponse +func (c *ClientWithResponses) GetAuthMethodsWithResponse(ctx context.Context, reqEditors ...RequestEditorFn) (*GetAuthMethodsResponse, error) { + rsp, err := c.GetAuthMethods(ctx, reqEditors...) + if err != nil { + return nil, err + } + return ParseGetAuthMethodsResponse(rsp) +} + +// AuthWebhookWithResponse request returning *AuthWebhookResponse +func (c *ClientWithResponses) AuthWebhookWithResponse(ctx context.Context, driver AuthWebhookParamsDriver, reqEditors ...RequestEditorFn) (*AuthWebhookResponse, error) { + rsp, err := c.AuthWebhook(ctx, driver, reqEditors...) + if err != nil { + return nil, err + } + return ParseAuthWebhookResponse(rsp) +} + +// ParseGetProfileResponse parses an HTTP response from a GetProfileWithResponse call +func ParseGetProfileResponse(rsp *http.Response) (*GetProfileResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &UpdateJourneyResponse{ + response := &GetProfileResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Journey + var dest Admin if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -12932,26 +12958,26 @@ func ParseUpdateJourneyResponse(rsp *http.Response) (*UpdateJourneyResponse, err return response, nil } -// ParseDuplicateJourneyResponse parses an HTTP response from a DuplicateJourneyWithResponse call -func ParseDuplicateJourneyResponse(rsp *http.Response) (*DuplicateJourneyResponse, error) { +// ParseListProjectsResponse parses an HTTP response from a ListProjectsWithResponse call +func ParseListProjectsResponse(rsp *http.Response) (*ListProjectsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &DuplicateJourneyResponse{ + response := &ListProjectsResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest Journey + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ProjectList if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON201 = &dest + response.JSON200 = &dest case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error @@ -12965,26 +12991,26 @@ func ParseDuplicateJourneyResponse(rsp *http.Response) (*DuplicateJourneyRespons return response, nil } -// ParsePublishJourneyResponse parses an HTTP response from a PublishJourneyWithResponse call -func ParsePublishJourneyResponse(rsp *http.Response) (*PublishJourneyResponse, error) { +// ParseCreateProjectResponse parses an HTTP response from a CreateProjectWithResponse call +func ParseCreateProjectResponse(rsp *http.Response) (*CreateProjectResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &PublishJourneyResponse{ + response := &CreateProjectResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Journey + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Project if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON200 = &dest + response.JSON201 = &dest case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error @@ -12998,22 +13024,22 @@ func ParsePublishJourneyResponse(rsp *http.Response) (*PublishJourneyResponse, e return response, nil } -// ParseGetJourneyStepsResponse parses an HTTP response from a GetJourneyStepsWithResponse call -func ParseGetJourneyStepsResponse(rsp *http.Response) (*GetJourneyStepsResponse, error) { +// ParseGetProjectResponse parses an HTTP response from a GetProjectWithResponse call +func ParseGetProjectResponse(rsp *http.Response) (*GetProjectResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetJourneyStepsResponse{ + response := &GetProjectResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest JourneyStepMap + var dest Project if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -13031,22 +13057,22 @@ func ParseGetJourneyStepsResponse(rsp *http.Response) (*GetJourneyStepsResponse, return response, nil } -// ParseSetJourneyStepsResponse parses an HTTP response from a SetJourneyStepsWithResponse call -func ParseSetJourneyStepsResponse(rsp *http.Response) (*SetJourneyStepsResponse, error) { +// ParseUpdateProjectResponse parses an HTTP response from a UpdateProjectWithResponse call +func ParseUpdateProjectResponse(rsp *http.Response) (*UpdateProjectResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &SetJourneyStepsResponse{ + response := &UpdateProjectResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest JourneyStepMap + var dest Project if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -13064,26 +13090,26 @@ func ParseSetJourneyStepsResponse(rsp *http.Response) (*SetJourneyStepsResponse, return response, nil } -// ParseVersionJourneyResponse parses an HTTP response from a VersionJourneyWithResponse call -func ParseVersionJourneyResponse(rsp *http.Response) (*VersionJourneyResponse, error) { +// ParseListProjectAdminsResponse parses an HTTP response from a ListProjectAdminsWithResponse call +func ParseListProjectAdminsResponse(rsp *http.Response) (*ListProjectAdminsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &VersionJourneyResponse{ + response := &ListProjectAdminsResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest Journey + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ProjectAdminList if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON201 = &dest + response.JSON200 = &dest case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error @@ -13097,27 +13123,20 @@ func ParseVersionJourneyResponse(rsp *http.Response) (*VersionJourneyResponse, e return response, nil } -// ParseListApiKeysResponse parses an HTTP response from a ListApiKeysWithResponse call -func ParseListApiKeysResponse(rsp *http.Response) (*ListApiKeysResponse, error) { +// ParseDeleteProjectAdminResponse parses an HTTP response from a DeleteProjectAdminWithResponse call +func ParseDeleteProjectAdminResponse(rsp *http.Response) (*DeleteProjectAdminResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &ListApiKeysResponse{ + response := &DeleteProjectAdminResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest ApiKeyListResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -13130,26 +13149,26 @@ func ParseListApiKeysResponse(rsp *http.Response) (*ListApiKeysResponse, error) return response, nil } -// ParseCreateApiKeyResponse parses an HTTP response from a CreateApiKeyWithResponse call -func ParseCreateApiKeyResponse(rsp *http.Response) (*CreateApiKeyResponse, error) { +// ParseGetProjectAdminResponse parses an HTTP response from a GetProjectAdminWithResponse call +func ParseGetProjectAdminResponse(rsp *http.Response) (*GetProjectAdminResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &CreateApiKeyResponse{ + response := &GetProjectAdminResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest ApiKey + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ProjectAdmin if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON201 = &dest + response.JSON200 = &dest case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error @@ -13163,20 +13182,27 @@ func ParseCreateApiKeyResponse(rsp *http.Response) (*CreateApiKeyResponse, error return response, nil } -// ParseDeleteApiKeyResponse parses an HTTP response from a DeleteApiKeyWithResponse call -func ParseDeleteApiKeyResponse(rsp *http.Response) (*DeleteApiKeyResponse, error) { +// ParseUpdateProjectAdminResponse parses an HTTP response from a UpdateProjectAdminWithResponse call +func ParseUpdateProjectAdminResponse(rsp *http.Response) (*UpdateProjectAdminResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &DeleteApiKeyResponse{ + response := &UpdateProjectAdminResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest ProjectAdmin + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -13189,22 +13215,22 @@ func ParseDeleteApiKeyResponse(rsp *http.Response) (*DeleteApiKeyResponse, error return response, nil } -// ParseGetApiKeyResponse parses an HTTP response from a GetApiKeyWithResponse call -func ParseGetApiKeyResponse(rsp *http.Response) (*GetApiKeyResponse, error) { +// ParseListCampaignsResponse parses an HTTP response from a ListCampaignsWithResponse call +func ParseListCampaignsResponse(rsp *http.Response) (*ListCampaignsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetApiKeyResponse{ + response := &ListCampaignsResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest ApiKey + var dest CampaignListResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -13222,26 +13248,26 @@ func ParseGetApiKeyResponse(rsp *http.Response) (*GetApiKeyResponse, error) { return response, nil } -// ParseUpdateApiKeyResponse parses an HTTP response from a UpdateApiKeyWithResponse call -func ParseUpdateApiKeyResponse(rsp *http.Response) (*UpdateApiKeyResponse, error) { +// ParseCreateCampaignResponse parses an HTTP response from a CreateCampaignWithResponse call +func ParseCreateCampaignResponse(rsp *http.Response) (*CreateCampaignResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &UpdateApiKeyResponse{ + response := &CreateCampaignResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest ApiKey + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Campaign if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON200 = &dest + response.JSON201 = &dest case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error @@ -13255,27 +13281,20 @@ func ParseUpdateApiKeyResponse(rsp *http.Response) (*UpdateApiKeyResponse, error return response, nil } -// ParseListListsResponse parses an HTTP response from a ListListsWithResponse call -func ParseListListsResponse(rsp *http.Response) (*ListListsResponse, error) { +// ParseDeleteCampaignResponse parses an HTTP response from a DeleteCampaignWithResponse call +func ParseDeleteCampaignResponse(rsp *http.Response) (*DeleteCampaignResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &ListListsResponse{ + response := &DeleteCampaignResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest ListListResponse - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -13288,26 +13307,28 @@ func ParseListListsResponse(rsp *http.Response) (*ListListsResponse, error) { return response, nil } -// ParseCreateListResponse parses an HTTP response from a CreateListWithResponse call -func ParseCreateListResponse(rsp *http.Response) (*CreateListResponse, error) { +// ParseGetCampaignResponse parses an HTTP response from a GetCampaignWithResponse call +func ParseGetCampaignResponse(rsp *http.Response) (*GetCampaignResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &CreateListResponse{ + response := &GetCampaignResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest List + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + Data Campaign `json:"data"` + } if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON201 = &dest + response.JSON200 = &dest case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error @@ -13321,20 +13342,27 @@ func ParseCreateListResponse(rsp *http.Response) (*CreateListResponse, error) { return response, nil } -// ParseDeleteListResponse parses an HTTP response from a DeleteListWithResponse call -func ParseDeleteListResponse(rsp *http.Response) (*DeleteListResponse, error) { +// ParseUpdateCampaignResponse parses an HTTP response from a UpdateCampaignWithResponse call +func ParseUpdateCampaignResponse(rsp *http.Response) (*UpdateCampaignResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &DeleteListResponse{ + response := &UpdateCampaignResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Campaign + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -13347,26 +13375,26 @@ func ParseDeleteListResponse(rsp *http.Response) (*DeleteListResponse, error) { return response, nil } -// ParseGetListResponse parses an HTTP response from a GetListWithResponse call -func ParseGetListResponse(rsp *http.Response) (*GetListResponse, error) { +// ParseDuplicateCampaignResponse parses an HTTP response from a DuplicateCampaignWithResponse call +func ParseDuplicateCampaignResponse(rsp *http.Response) (*DuplicateCampaignResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetListResponse{ + response := &DuplicateCampaignResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest List + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Campaign if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON200 = &dest + response.JSON201 = &dest case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error @@ -13380,26 +13408,26 @@ func ParseGetListResponse(rsp *http.Response) (*GetListResponse, error) { return response, nil } -// ParseUpdateListResponse parses an HTTP response from a UpdateListWithResponse call -func ParseUpdateListResponse(rsp *http.Response) (*UpdateListResponse, error) { +// ParseCreateTemplateResponse parses an HTTP response from a CreateTemplateWithResponse call +func ParseCreateTemplateResponse(rsp *http.Response) (*CreateTemplateResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &UpdateListResponse{ + response := &CreateTemplateResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest List + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Template if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON200 = &dest + response.JSON201 = &dest case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error @@ -13413,27 +13441,20 @@ func ParseUpdateListResponse(rsp *http.Response) (*UpdateListResponse, error) { return response, nil } -// ParseDuplicateListResponse parses an HTTP response from a DuplicateListWithResponse call -func ParseDuplicateListResponse(rsp *http.Response) (*DuplicateListResponse, error) { +// ParseDeleteTemplateResponse parses an HTTP response from a DeleteTemplateWithResponse call +func ParseDeleteTemplateResponse(rsp *http.Response) (*DeleteTemplateResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &DuplicateListResponse{ + response := &DeleteTemplateResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest List - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -13446,22 +13467,24 @@ func ParseDuplicateListResponse(rsp *http.Response) (*DuplicateListResponse, err return response, nil } -// ParseGetListUsersResponse parses an HTTP response from a GetListUsersWithResponse call -func ParseGetListUsersResponse(rsp *http.Response) (*GetListUsersResponse, error) { +// ParseGetTemplateResponse parses an HTTP response from a GetTemplateWithResponse call +func ParseGetTemplateResponse(rsp *http.Response) (*GetTemplateResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetListUsersResponse{ + response := &GetTemplateResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest UserList + var dest struct { + Data Template `json:"data"` + } if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -13479,20 +13502,27 @@ func ParseGetListUsersResponse(rsp *http.Response) (*GetListUsersResponse, error return response, nil } -// ParseImportListUsersResponse parses an HTTP response from a ImportListUsersWithResponse call -func ParseImportListUsersResponse(rsp *http.Response) (*ImportListUsersResponse, error) { +// ParseUpdateTemplateResponse parses an HTTP response from a UpdateTemplateWithResponse call +func ParseUpdateTemplateResponse(rsp *http.Response) (*UpdateTemplateResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &ImportListUsersResponse{ + response := &UpdateTemplateResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Template + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -13505,15 +13535,15 @@ func ParseImportListUsersResponse(rsp *http.Response) (*ImportListUsersResponse, return response, nil } -// ParseListLocalesResponse parses an HTTP response from a ListLocalesWithResponse call -func ParseListLocalesResponse(rsp *http.Response) (*ListLocalesResponse, error) { +// ParseGetCampaignUsersResponse parses an HTTP response from a GetCampaignUsersWithResponse call +func ParseGetCampaignUsersResponse(rsp *http.Response) (*GetCampaignUsersResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &ListLocalesResponse{ + response := &GetCampaignUsersResponse{ Body: bodyBytes, HTTPResponse: rsp, } @@ -13521,15 +13551,10 @@ func ParseListLocalesResponse(rsp *http.Response) (*ListLocalesResponse, error) switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: var dest struct { - // Limit Maximum number of items returned - Limit int `json:"limit"` - - // Offset Number of items skipped - Offset int `json:"offset"` - Results []Locale `json:"results"` - - // Total Total number of items matching the filters - Total int `json:"total"` + Data []CampaignUser `json:"data"` + Limit int `json:"limit"` + Offset int `json:"offset"` + Total int `json:"total"` } if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err @@ -13548,26 +13573,26 @@ func ParseListLocalesResponse(rsp *http.Response) (*ListLocalesResponse, error) return response, nil } -// ParseCreateLocaleResponse parses an HTTP response from a CreateLocaleWithResponse call -func ParseCreateLocaleResponse(rsp *http.Response) (*CreateLocaleResponse, error) { +// ParseListDocumentsResponse parses an HTTP response from a ListDocumentsWithResponse call +func ParseListDocumentsResponse(rsp *http.Response) (*ListDocumentsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &CreateLocaleResponse{ + response := &ListDocumentsResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest Locale + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest DocumentListResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON201 = &dest + response.JSON200 = &dest case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error @@ -13581,20 +13606,30 @@ func ParseCreateLocaleResponse(rsp *http.Response) (*CreateLocaleResponse, error return response, nil } -// ParseDeleteLocaleResponse parses an HTTP response from a DeleteLocaleWithResponse call -func ParseDeleteLocaleResponse(rsp *http.Response) (*DeleteLocaleResponse, error) { +// ParseUploadDocumentsResponse parses an HTTP response from a UploadDocumentsWithResponse call +func ParseUploadDocumentsResponse(rsp *http.Response) (*UploadDocumentsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &DeleteLocaleResponse{ + response := &UploadDocumentsResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest struct { + // Documents UUIDs of the uploaded documents + Documents []openapi_types.UUID `json:"documents"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -13607,27 +13642,46 @@ func ParseDeleteLocaleResponse(rsp *http.Response) (*DeleteLocaleResponse, error return response, nil } -// ParseGetLocaleResponse parses an HTTP response from a GetLocaleWithResponse call -func ParseGetLocaleResponse(rsp *http.Response) (*GetLocaleResponse, error) { +// ParseDeleteDocumentResponse parses an HTTP response from a DeleteDocumentWithResponse call +func ParseDeleteDocumentResponse(rsp *http.Response) (*DeleteDocumentResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetLocaleResponse{ + response := &DeleteDocumentResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Locale + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON200 = &dest + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseGetDocumentResponse parses an HTTP response from a GetDocumentWithResponse call +func ParseGetDocumentResponse(rsp *http.Response) (*GetDocumentResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetDocumentResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -13640,22 +13694,22 @@ func ParseGetLocaleResponse(rsp *http.Response) (*GetLocaleResponse, error) { return response, nil } -// ParseListProvidersResponse parses an HTTP response from a ListProvidersWithResponse call -func ParseListProvidersResponse(rsp *http.Response) (*ListProvidersResponse, error) { +// ParseGetDocumentMetadataResponse parses an HTTP response from a GetDocumentMetadataWithResponse call +func ParseGetDocumentMetadataResponse(rsp *http.Response) (*GetDocumentMetadataResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &ListProvidersResponse{ + response := &GetDocumentMetadataResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest ProviderListResponse + var dest Document if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -13673,22 +13727,22 @@ func ParseListProvidersResponse(rsp *http.Response) (*ListProvidersResponse, err return response, nil } -// ParseListAllProvidersResponse parses an HTTP response from a ListAllProvidersWithResponse call -func ParseListAllProvidersResponse(rsp *http.Response) (*ListAllProvidersResponse, error) { +// ParseListJourneysResponse parses an HTTP response from a ListJourneysWithResponse call +func ParseListJourneysResponse(rsp *http.Response) (*ListJourneysResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &ListAllProvidersResponse{ + response := &ListJourneysResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []Provider + var dest JourneyListResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -13706,26 +13760,26 @@ func ParseListAllProvidersResponse(rsp *http.Response) (*ListAllProvidersRespons return response, nil } -// ParseListProviderMetaResponse parses an HTTP response from a ListProviderMetaWithResponse call -func ParseListProviderMetaResponse(rsp *http.Response) (*ListProviderMetaResponse, error) { +// ParseCreateJourneyResponse parses an HTTP response from a CreateJourneyWithResponse call +func ParseCreateJourneyResponse(rsp *http.Response) (*CreateJourneyResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &ListProviderMetaResponse{ + response := &CreateJourneyResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []ProviderMeta + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Journey if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON200 = &dest + response.JSON201 = &dest case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error @@ -13739,27 +13793,20 @@ func ParseListProviderMetaResponse(rsp *http.Response) (*ListProviderMetaRespons return response, nil } -// ParseCreateProviderResponse parses an HTTP response from a CreateProviderWithResponse call -func ParseCreateProviderResponse(rsp *http.Response) (*CreateProviderResponse, error) { +// ParseDeleteJourneyResponse parses an HTTP response from a DeleteJourneyWithResponse call +func ParseDeleteJourneyResponse(rsp *http.Response) (*DeleteJourneyResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &CreateProviderResponse{ + response := &DeleteJourneyResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest Provider - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON201 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -13772,22 +13819,22 @@ func ParseCreateProviderResponse(rsp *http.Response) (*CreateProviderResponse, e return response, nil } -// ParseGetProviderResponse parses an HTTP response from a GetProviderWithResponse call -func ParseGetProviderResponse(rsp *http.Response) (*GetProviderResponse, error) { +// ParseGetJourneyResponse parses an HTTP response from a GetJourneyWithResponse call +func ParseGetJourneyResponse(rsp *http.Response) (*GetJourneyResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetProviderResponse{ + response := &GetJourneyResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Provider + var dest Journey if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -13805,22 +13852,22 @@ func ParseGetProviderResponse(rsp *http.Response) (*GetProviderResponse, error) return response, nil } -// ParseUpdateProviderResponse parses an HTTP response from a UpdateProviderWithResponse call -func ParseUpdateProviderResponse(rsp *http.Response) (*UpdateProviderResponse, error) { +// ParseUpdateJourneyResponse parses an HTTP response from a UpdateJourneyWithResponse call +func ParseUpdateJourneyResponse(rsp *http.Response) (*UpdateJourneyResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &UpdateProviderResponse{ + response := &UpdateJourneyResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Provider + var dest Journey if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -13838,20 +13885,27 @@ func ParseUpdateProviderResponse(rsp *http.Response) (*UpdateProviderResponse, e return response, nil } -// ParseDeleteProviderResponse parses an HTTP response from a DeleteProviderWithResponse call -func ParseDeleteProviderResponse(rsp *http.Response) (*DeleteProviderResponse, error) { +// ParseDuplicateJourneyResponse parses an HTTP response from a DuplicateJourneyWithResponse call +func ParseDuplicateJourneyResponse(rsp *http.Response) (*DuplicateJourneyResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &DeleteProviderResponse{ + response := &DuplicateJourneyResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Journey + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -13864,22 +13918,22 @@ func ParseDeleteProviderResponse(rsp *http.Response) (*DeleteProviderResponse, e return response, nil } -// ParseListSubscriptionsResponse parses an HTTP response from a ListSubscriptionsWithResponse call -func ParseListSubscriptionsResponse(rsp *http.Response) (*ListSubscriptionsResponse, error) { +// ParsePublishJourneyResponse parses an HTTP response from a PublishJourneyWithResponse call +func ParsePublishJourneyResponse(rsp *http.Response) (*PublishJourneyResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &ListSubscriptionsResponse{ + response := &PublishJourneyResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest SubscriptionListResponse + var dest Journey if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -13897,26 +13951,26 @@ func ParseListSubscriptionsResponse(rsp *http.Response) (*ListSubscriptionsRespo return response, nil } -// ParseCreateSubscriptionResponse parses an HTTP response from a CreateSubscriptionWithResponse call -func ParseCreateSubscriptionResponse(rsp *http.Response) (*CreateSubscriptionResponse, error) { +// ParseGetJourneyStepsResponse parses an HTTP response from a GetJourneyStepsWithResponse call +func ParseGetJourneyStepsResponse(rsp *http.Response) (*GetJourneyStepsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &CreateSubscriptionResponse{ + response := &GetJourneyStepsResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest Subscription + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest JourneyStepMap if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON201 = &dest + response.JSON200 = &dest case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error @@ -13930,22 +13984,22 @@ func ParseCreateSubscriptionResponse(rsp *http.Response) (*CreateSubscriptionRes return response, nil } -// ParseGetSubscriptionResponse parses an HTTP response from a GetSubscriptionWithResponse call -func ParseGetSubscriptionResponse(rsp *http.Response) (*GetSubscriptionResponse, error) { +// ParseSetJourneyStepsResponse parses an HTTP response from a SetJourneyStepsWithResponse call +func ParseSetJourneyStepsResponse(rsp *http.Response) (*SetJourneyStepsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetSubscriptionResponse{ + response := &SetJourneyStepsResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Subscription + var dest JourneyStepMap if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -13963,26 +14017,26 @@ func ParseGetSubscriptionResponse(rsp *http.Response) (*GetSubscriptionResponse, return response, nil } -// ParseUpdateSubscriptionResponse parses an HTTP response from a UpdateSubscriptionWithResponse call -func ParseUpdateSubscriptionResponse(rsp *http.Response) (*UpdateSubscriptionResponse, error) { +// ParseVersionJourneyResponse parses an HTTP response from a VersionJourneyWithResponse call +func ParseVersionJourneyResponse(rsp *http.Response) (*VersionJourneyResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &UpdateSubscriptionResponse{ + response := &VersionJourneyResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Subscription + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Journey if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON200 = &dest + response.JSON201 = &dest case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error @@ -13996,22 +14050,22 @@ func ParseUpdateSubscriptionResponse(rsp *http.Response) (*UpdateSubscriptionRes return response, nil } -// ParseListTagsResponse parses an HTTP response from a ListTagsWithResponse call -func ParseListTagsResponse(rsp *http.Response) (*ListTagsResponse, error) { +// ParseListApiKeysResponse parses an HTTP response from a ListApiKeysWithResponse call +func ParseListApiKeysResponse(rsp *http.Response) (*ListApiKeysResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &ListTagsResponse{ + response := &ListApiKeysResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest TagListResponse + var dest ApiKeyListResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -14029,22 +14083,22 @@ func ParseListTagsResponse(rsp *http.Response) (*ListTagsResponse, error) { return response, nil } -// ParseCreateTagResponse parses an HTTP response from a CreateTagWithResponse call -func ParseCreateTagResponse(rsp *http.Response) (*CreateTagResponse, error) { +// ParseCreateApiKeyResponse parses an HTTP response from a CreateApiKeyWithResponse call +func ParseCreateApiKeyResponse(rsp *http.Response) (*CreateApiKeyResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &CreateTagResponse{ + response := &CreateApiKeyResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: - var dest Tag + var dest ApiKey if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -14062,15 +14116,15 @@ func ParseCreateTagResponse(rsp *http.Response) (*CreateTagResponse, error) { return response, nil } -// ParseDeleteTagResponse parses an HTTP response from a DeleteTagWithResponse call -func ParseDeleteTagResponse(rsp *http.Response) (*DeleteTagResponse, error) { +// ParseDeleteApiKeyResponse parses an HTTP response from a DeleteApiKeyWithResponse call +func ParseDeleteApiKeyResponse(rsp *http.Response) (*DeleteApiKeyResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &DeleteTagResponse{ + response := &DeleteApiKeyResponse{ Body: bodyBytes, HTTPResponse: rsp, } @@ -14088,22 +14142,22 @@ func ParseDeleteTagResponse(rsp *http.Response) (*DeleteTagResponse, error) { return response, nil } -// ParseGetTagResponse parses an HTTP response from a GetTagWithResponse call -func ParseGetTagResponse(rsp *http.Response) (*GetTagResponse, error) { +// ParseGetApiKeyResponse parses an HTTP response from a GetApiKeyWithResponse call +func ParseGetApiKeyResponse(rsp *http.Response) (*GetApiKeyResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetTagResponse{ + response := &GetApiKeyResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Tag + var dest ApiKey if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -14121,22 +14175,22 @@ func ParseGetTagResponse(rsp *http.Response) (*GetTagResponse, error) { return response, nil } -// ParseUpdateTagResponse parses an HTTP response from a UpdateTagWithResponse call -func ParseUpdateTagResponse(rsp *http.Response) (*UpdateTagResponse, error) { +// ParseUpdateApiKeyResponse parses an HTTP response from a UpdateApiKeyWithResponse call +func ParseUpdateApiKeyResponse(rsp *http.Response) (*UpdateApiKeyResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &UpdateTagResponse{ + response := &UpdateApiKeyResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest Tag + var dest ApiKey if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -14154,22 +14208,22 @@ func ParseUpdateTagResponse(rsp *http.Response) (*UpdateTagResponse, error) { return response, nil } -// ParseListUsersResponse parses an HTTP response from a ListUsersWithResponse call -func ParseListUsersResponse(rsp *http.Response) (*ListUsersResponse, error) { +// ParseListListsResponse parses an HTTP response from a ListListsWithResponse call +func ParseListListsResponse(rsp *http.Response) (*ListListsResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &ListUsersResponse{ + response := &ListListsResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest UserList + var dest ListListResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -14187,26 +14241,26 @@ func ParseListUsersResponse(rsp *http.Response) (*ListUsersResponse, error) { return response, nil } -// ParseIdentifyUserResponse parses an HTTP response from a IdentifyUserWithResponse call -func ParseIdentifyUserResponse(rsp *http.Response) (*IdentifyUserResponse, error) { +// ParseCreateListResponse parses an HTTP response from a CreateListWithResponse call +func ParseCreateListResponse(rsp *http.Response) (*CreateListResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &IdentifyUserResponse{ + response := &CreateListResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest User + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest List if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON200 = &dest + response.JSON201 = &dest case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error @@ -14220,15 +14274,15 @@ func ParseIdentifyUserResponse(rsp *http.Response) (*IdentifyUserResponse, error return response, nil } -// ParseImportUsersResponse parses an HTTP response from a ImportUsersWithResponse call -func ParseImportUsersResponse(rsp *http.Response) (*ImportUsersResponse, error) { +// ParseDeleteListResponse parses an HTTP response from a DeleteListWithResponse call +func ParseDeleteListResponse(rsp *http.Response) (*DeleteListResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &ImportUsersResponse{ + response := &DeleteListResponse{ Body: bodyBytes, HTTPResponse: rsp, } @@ -14246,24 +14300,22 @@ func ParseImportUsersResponse(rsp *http.Response) (*ImportUsersResponse, error) return response, nil } -// ParseListUserSchemasResponse parses an HTTP response from a ListUserSchemasWithResponse call -func ParseListUserSchemasResponse(rsp *http.Response) (*ListUserSchemasResponse, error) { +// ParseGetListResponse parses an HTTP response from a GetListWithResponse call +func ParseGetListResponse(rsp *http.Response) (*GetListResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &ListUserSchemasResponse{ + response := &GetListResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest struct { - Results []SchemaPath `json:"results"` - } + var dest List if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -14281,20 +14333,27 @@ func ParseListUserSchemasResponse(rsp *http.Response) (*ListUserSchemasResponse, return response, nil } -// ParseDeleteUserResponse parses an HTTP response from a DeleteUserWithResponse call -func ParseDeleteUserResponse(rsp *http.Response) (*DeleteUserResponse, error) { +// ParseUpdateListResponse parses an HTTP response from a UpdateListWithResponse call +func ParseUpdateListResponse(rsp *http.Response) (*UpdateListResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &DeleteUserResponse{ + response := &UpdateListResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest List + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -14307,26 +14366,26 @@ func ParseDeleteUserResponse(rsp *http.Response) (*DeleteUserResponse, error) { return response, nil } -// ParseGetUserResponse parses an HTTP response from a GetUserWithResponse call -func ParseGetUserResponse(rsp *http.Response) (*GetUserResponse, error) { +// ParseDuplicateListResponse parses an HTTP response from a DuplicateListWithResponse call +func ParseDuplicateListResponse(rsp *http.Response) (*DuplicateListResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetUserResponse{ + response := &DuplicateListResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest User + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest List if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } - response.JSON200 = &dest + response.JSON201 = &dest case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error @@ -14340,22 +14399,22 @@ func ParseGetUserResponse(rsp *http.Response) (*GetUserResponse, error) { return response, nil } -// ParseUpdateUserResponse parses an HTTP response from a UpdateUserWithResponse call -func ParseUpdateUserResponse(rsp *http.Response) (*UpdateUserResponse, error) { +// ParseGetListUsersResponse parses an HTTP response from a GetListUsersWithResponse call +func ParseGetListUsersResponse(rsp *http.Response) (*GetListUsersResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &UpdateUserResponse{ + response := &GetListUsersResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest User + var dest UserList if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -14373,27 +14432,20 @@ func ParseUpdateUserResponse(rsp *http.Response) (*UpdateUserResponse, error) { return response, nil } -// ParseGetUserEventsResponse parses an HTTP response from a GetUserEventsWithResponse call -func ParseGetUserEventsResponse(rsp *http.Response) (*GetUserEventsResponse, error) { +// ParseImportListUsersResponse parses an HTTP response from a ImportListUsersWithResponse call +func ParseImportListUsersResponse(rsp *http.Response) (*ImportListUsersResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetUserEventsResponse{ + response := &ImportListUsersResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest UserEventList - if err := json.Unmarshal(bodyBytes, &dest); err != nil { - return nil, err - } - response.JSON200 = &dest - case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -14406,22 +14458,32 @@ func ParseGetUserEventsResponse(rsp *http.Response) (*GetUserEventsResponse, err return response, nil } -// ParseGetUserJourneysResponse parses an HTTP response from a GetUserJourneysWithResponse call -func ParseGetUserJourneysResponse(rsp *http.Response) (*GetUserJourneysResponse, error) { +// ParseListLocalesResponse parses an HTTP response from a ListLocalesWithResponse call +func ParseListLocalesResponse(rsp *http.Response) (*ListLocalesResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetUserJourneysResponse{ + response := &ListLocalesResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest UserJourneyList + var dest struct { + // Limit Maximum number of items returned + Limit int `json:"limit"` + + // Offset Number of items skipped + Offset int `json:"offset"` + Results []Locale `json:"results"` + + // Total Total number of items matching the filters + Total int `json:"total"` + } if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -14439,22 +14501,81 @@ func ParseGetUserJourneysResponse(rsp *http.Response) (*GetUserJourneysResponse, return response, nil } -// ParseGetUserSubscriptionsResponse parses an HTTP response from a GetUserSubscriptionsWithResponse call -func ParseGetUserSubscriptionsResponse(rsp *http.Response) (*GetUserSubscriptionsResponse, error) { +// ParseCreateLocaleResponse parses an HTTP response from a CreateLocaleWithResponse call +func ParseCreateLocaleResponse(rsp *http.Response) (*CreateLocaleResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetUserSubscriptionsResponse{ + response := &CreateLocaleResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Locale + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseDeleteLocaleResponse parses an HTTP response from a DeleteLocaleWithResponse call +func ParseDeleteLocaleResponse(rsp *http.Response) (*DeleteLocaleResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteLocaleResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseGetLocaleResponse parses an HTTP response from a GetLocaleWithResponse call +func ParseGetLocaleResponse(rsp *http.Response) (*GetLocaleResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetLocaleResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest UserSubscriptionList + var dest Locale if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -14472,22 +14593,22 @@ func ParseGetUserSubscriptionsResponse(rsp *http.Response) (*GetUserSubscription return response, nil } -// ParseUpdateUserSubscriptionsResponse parses an HTTP response from a UpdateUserSubscriptionsWithResponse call -func ParseUpdateUserSubscriptionsResponse(rsp *http.Response) (*UpdateUserSubscriptionsResponse, error) { +// ParseListProvidersResponse parses an HTTP response from a ListProvidersWithResponse call +func ParseListProvidersResponse(rsp *http.Response) (*ListProvidersResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &UpdateUserSubscriptionsResponse{ + response := &ListProvidersResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest User + var dest ProviderListResponse if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -14505,20 +14626,27 @@ func ParseUpdateUserSubscriptionsResponse(rsp *http.Response) (*UpdateUserSubscr return response, nil } -// ParseAuthCallbackResponse parses an HTTP response from a AuthCallbackWithResponse call -func ParseAuthCallbackResponse(rsp *http.Response) (*AuthCallbackResponse, error) { +// ParseListAllProvidersResponse parses an HTTP response from a ListAllProvidersWithResponse call +func ParseListAllProvidersResponse(rsp *http.Response) (*ListAllProvidersResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &AuthCallbackResponse{ + response := &ListAllProvidersResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []Provider + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -14531,22 +14659,22 @@ func ParseAuthCallbackResponse(rsp *http.Response) (*AuthCallbackResponse, error return response, nil } -// ParseGetAuthMethodsResponse parses an HTTP response from a GetAuthMethodsWithResponse call -func ParseGetAuthMethodsResponse(rsp *http.Response) (*GetAuthMethodsResponse, error) { +// ParseListProviderMetaResponse parses an HTTP response from a ListProviderMetaWithResponse call +func ParseListProviderMetaResponse(rsp *http.Response) (*ListProviderMetaResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &GetAuthMethodsResponse{ + response := &ListProviderMetaResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: - var dest []string + var dest []ProviderMeta if err := json.Unmarshal(bodyBytes, &dest); err != nil { return nil, err } @@ -14564,20 +14692,27 @@ func ParseGetAuthMethodsResponse(rsp *http.Response) (*GetAuthMethodsResponse, e return response, nil } -// ParseAuthWebhookResponse parses an HTTP response from a AuthWebhookWithResponse call -func ParseAuthWebhookResponse(rsp *http.Response) (*AuthWebhookResponse, error) { +// ParseCreateProviderResponse parses an HTTP response from a CreateProviderWithResponse call +func ParseCreateProviderResponse(rsp *http.Response) (*CreateProviderResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) defer func() { _ = rsp.Body.Close() }() if err != nil { return nil, err } - response := &AuthWebhookResponse{ + response := &CreateProviderResponse{ Body: bodyBytes, HTTPResponse: rsp, } switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Provider + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: var dest Error if err := json.Unmarshal(bodyBytes, &dest); err != nil { @@ -14590,160 +14725,1642 @@ func ParseAuthWebhookResponse(rsp *http.Response) (*AuthWebhookResponse, error) return response, nil } -// ServerInterface represents all server handlers. -type ServerInterface interface { - // Delete organization - // (DELETE /api/admin/organizations) - DeleteOrganization(w http.ResponseWriter, r *http.Request) - // Get current organization - // (GET /api/admin/organizations) - GetOrganization(w http.ResponseWriter, r *http.Request) - // Update organization - // (PATCH /api/admin/organizations) - UpdateOrganization(w http.ResponseWriter, r *http.Request) - // List organization admins - // (GET /api/admin/organizations/admins) - ListAdmins(w http.ResponseWriter, r *http.Request, params ListAdminsParams) - // Create or update admin - // (POST /api/admin/organizations/admins) - CreateAdmin(w http.ResponseWriter, r *http.Request) - // Delete admin - // (DELETE /api/admin/organizations/admins/{adminID}) - DeleteAdmin(w http.ResponseWriter, r *http.Request, adminID openapi_types.UUID) - // Get admin by ID - // (GET /api/admin/organizations/admins/{adminID}) - GetAdmin(w http.ResponseWriter, r *http.Request, adminID openapi_types.UUID) - // Update admin - // (PATCH /api/admin/organizations/admins/{adminID}) - UpdateAdmin(w http.ResponseWriter, r *http.Request, adminID openapi_types.UUID) - // Get organization integrations - // (GET /api/admin/organizations/integrations) - GetOrganizationIntegrations(w http.ResponseWriter, r *http.Request) - // Get current admin - // (GET /api/admin/organizations/whoami) - Whoami(w http.ResponseWriter, r *http.Request) - // Get current admin profile - // (GET /api/admin/profile) - GetProfile(w http.ResponseWriter, r *http.Request) - // List projects - // (GET /api/admin/projects) - ListProjects(w http.ResponseWriter, r *http.Request, params ListProjectsParams) - // Create project - // (POST /api/admin/projects) - CreateProject(w http.ResponseWriter, r *http.Request) - // Get project by ID - // (GET /api/admin/projects/{projectID}) - GetProject(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) - // Update project - // (PATCH /api/admin/projects/{projectID}) - UpdateProject(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) - // List project admins - // (GET /api/admin/projects/{projectID}/admins) - ListProjectAdmins(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListProjectAdminsParams) - // Remove admin from project - // (DELETE /api/admin/projects/{projectID}/admins/{adminID}) - DeleteProjectAdmin(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, adminID openapi_types.UUID) - // Get project admin - // (GET /api/admin/projects/{projectID}/admins/{adminID}) - GetProjectAdmin(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, adminID openapi_types.UUID) - // Update project admin role - // (PATCH /api/admin/projects/{projectID}/admins/{adminID}) - UpdateProjectAdmin(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, adminID openapi_types.UUID) - // List campaigns - // (GET /api/admin/projects/{projectID}/campaigns) - ListCampaigns(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListCampaignsParams) - // Create campaign - // (POST /api/admin/projects/{projectID}/campaigns) - CreateCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) - // Delete campaign - // (DELETE /api/admin/projects/{projectID}/campaigns/{campaignID}) - DeleteCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) - // Get campaign by ID - // (GET /api/admin/projects/{projectID}/campaigns/{campaignID}) - GetCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) - // Update campaign - // (PATCH /api/admin/projects/{projectID}/campaigns/{campaignID}) - UpdateCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) - // Duplicate campaign - // (POST /api/admin/projects/{projectID}/campaigns/{campaignID}/duplicate) - DuplicateCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) - // Create template - // (POST /api/admin/projects/{projectID}/campaigns/{campaignID}/templates) - CreateTemplate(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) - // Delete template - // (DELETE /api/admin/projects/{projectID}/campaigns/{campaignID}/templates/{templateID}) - DeleteTemplate(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID) - // Get template by ID - // (GET /api/admin/projects/{projectID}/campaigns/{campaignID}/templates/{templateID}) - GetTemplate(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID) - // Update template - // (PATCH /api/admin/projects/{projectID}/campaigns/{campaignID}/templates/{templateID}) - UpdateTemplate(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID) - // Get campaign users - // (GET /api/admin/projects/{projectID}/campaigns/{campaignID}/users) - GetCampaignUsers(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID, params GetCampaignUsersParams) - // List documents - // (GET /api/admin/projects/{projectID}/documents) - ListDocuments(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListDocumentsParams) - // Upload documents - // (POST /api/admin/projects/{projectID}/documents) - UploadDocuments(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) - // Delete document - // (DELETE /api/admin/projects/{projectID}/documents/{documentID}) - DeleteDocument(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, documentID openapi_types.UUID) - // Retrieve a document - // (GET /api/admin/projects/{projectID}/documents/{documentID}) - GetDocument(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, documentID openapi_types.UUID) - // Get document metadata - // (GET /api/admin/projects/{projectID}/documents/{documentID}/metadata) - GetDocumentMetadata(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, documentID openapi_types.UUID) - // List events with schemas - // (GET /api/admin/projects/{projectID}/events/schema) - ListEvents(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) - // List journeys - // (GET /api/admin/projects/{projectID}/journeys) - ListJourneys(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListJourneysParams) - // Create journey - // (POST /api/admin/projects/{projectID}/journeys) - CreateJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) - // Delete journey - // (DELETE /api/admin/projects/{projectID}/journeys/{journeyID}) - DeleteJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) - // Get journey by ID - // (GET /api/admin/projects/{projectID}/journeys/{journeyID}) - GetJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) - // Update journey - // (PATCH /api/admin/projects/{projectID}/journeys/{journeyID}) - UpdateJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) - // Duplicate journey - // (POST /api/admin/projects/{projectID}/journeys/{journeyID}/duplicate) - DuplicateJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) - // Publish journey - // (POST /api/admin/projects/{projectID}/journeys/{journeyID}/publish) - PublishJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) - // Get journey steps - // (GET /api/admin/projects/{projectID}/journeys/{journeyID}/steps) - GetJourneySteps(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) - // Set journey steps - // (PUT /api/admin/projects/{projectID}/journeys/{journeyID}/steps) - SetJourneySteps(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) - // Create journey version - // (POST /api/admin/projects/{projectID}/journeys/{journeyID}/version) - VersionJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) - // List API keys - // (GET /api/admin/projects/{projectID}/keys) - ListApiKeys(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListApiKeysParams) - // Create API key - // (POST /api/admin/projects/{projectID}/keys) - CreateApiKey(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) - // Delete API key - // (DELETE /api/admin/projects/{projectID}/keys/{keyID}) - DeleteApiKey(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, keyID openapi_types.UUID) - // Get API key by ID - // (GET /api/admin/projects/{projectID}/keys/{keyID}) - GetApiKey(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, keyID openapi_types.UUID) - // Update API key - // (PATCH /api/admin/projects/{projectID}/keys/{keyID}) +// ParseGetProviderResponse parses an HTTP response from a GetProviderWithResponse call +func ParseGetProviderResponse(rsp *http.Response) (*GetProviderResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetProviderResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Provider + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseUpdateProviderResponse parses an HTTP response from a UpdateProviderWithResponse call +func ParseUpdateProviderResponse(rsp *http.Response) (*UpdateProviderResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateProviderResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Provider + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseDeleteProviderResponse parses an HTTP response from a DeleteProviderWithResponse call +func ParseDeleteProviderResponse(rsp *http.Response) (*DeleteProviderResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteProviderResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseListEventsResponse parses an HTTP response from a ListEventsWithResponse call +func ParseListEventsResponse(rsp *http.Response) (*ListEventsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListEventsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest EventListResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseListOrganizationsResponse parses an HTTP response from a ListOrganizationsWithResponse call +func ParseListOrganizationsResponse(rsp *http.Response) (*ListOrganizationsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListOrganizationsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest OrganizationList + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseUpsertOrganizationResponse parses an HTTP response from a UpsertOrganizationWithResponse call +func ParseUpsertOrganizationResponse(rsp *http.Response) (*UpsertOrganizationResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpsertOrganizationResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Organization + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseListOrganizationSchemasResponse parses an HTTP response from a ListOrganizationSchemasWithResponse call +func ParseListOrganizationSchemasResponse(rsp *http.Response) (*ListOrganizationSchemasResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListOrganizationSchemasResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + Results []SchemaPath `json:"results"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseListOrganizationMemberSchemasResponse parses an HTTP response from a ListOrganizationMemberSchemasWithResponse call +func ParseListOrganizationMemberSchemasResponse(rsp *http.Response) (*ListOrganizationMemberSchemasResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListOrganizationMemberSchemasResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + Results []SchemaPath `json:"results"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseDeleteOrganizationResponse parses an HTTP response from a DeleteOrganizationWithResponse call +func ParseDeleteOrganizationResponse(rsp *http.Response) (*DeleteOrganizationResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteOrganizationResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseGetOrganizationResponse parses an HTTP response from a GetOrganizationWithResponse call +func ParseGetOrganizationResponse(rsp *http.Response) (*GetOrganizationResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetOrganizationResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Organization + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseUpdateOrganizationResponse parses an HTTP response from a UpdateOrganizationWithResponse call +func ParseUpdateOrganizationResponse(rsp *http.Response) (*UpdateOrganizationResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateOrganizationResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Organization + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseListOrganizationMembersResponse parses an HTTP response from a ListOrganizationMembersWithResponse call +func ParseListOrganizationMembersResponse(rsp *http.Response) (*ListOrganizationMembersResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListOrganizationMembersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest OrganizationMemberList + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseAddOrganizationMemberResponse parses an HTTP response from a AddOrganizationMemberWithResponse call +func ParseAddOrganizationMemberResponse(rsp *http.Response) (*AddOrganizationMemberResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AddOrganizationMemberResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseRemoveOrganizationMemberResponse parses an HTTP response from a RemoveOrganizationMemberWithResponse call +func ParseRemoveOrganizationMemberResponse(rsp *http.Response) (*RemoveOrganizationMemberResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &RemoveOrganizationMemberResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseListUsersResponse parses an HTTP response from a ListUsersWithResponse call +func ParseListUsersResponse(rsp *http.Response) (*ListUsersResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListUsersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest UserList + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseIdentifyUserResponse parses an HTTP response from a IdentifyUserWithResponse call +func ParseIdentifyUserResponse(rsp *http.Response) (*IdentifyUserResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &IdentifyUserResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest User + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseImportUsersResponse parses an HTTP response from a ImportUsersWithResponse call +func ParseImportUsersResponse(rsp *http.Response) (*ImportUsersResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ImportUsersResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseListUserSchemasResponse parses an HTTP response from a ListUserSchemasWithResponse call +func ParseListUserSchemasResponse(rsp *http.Response) (*ListUserSchemasResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListUserSchemasResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + Results []SchemaPath `json:"results"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseDeleteUserResponse parses an HTTP response from a DeleteUserWithResponse call +func ParseDeleteUserResponse(rsp *http.Response) (*DeleteUserResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteUserResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseGetUserResponse parses an HTTP response from a GetUserWithResponse call +func ParseGetUserResponse(rsp *http.Response) (*GetUserResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetUserResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest User + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseUpdateUserResponse parses an HTTP response from a UpdateUserWithResponse call +func ParseUpdateUserResponse(rsp *http.Response) (*UpdateUserResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateUserResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest User + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseGetUserEventsResponse parses an HTTP response from a GetUserEventsWithResponse call +func ParseGetUserEventsResponse(rsp *http.Response) (*GetUserEventsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetUserEventsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest UserEventList + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseGetUserJourneysResponse parses an HTTP response from a GetUserJourneysWithResponse call +func ParseGetUserJourneysResponse(rsp *http.Response) (*GetUserJourneysResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetUserJourneysResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest UserJourneyList + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseGetUserOrganizationsResponse parses an HTTP response from a GetUserOrganizationsWithResponse call +func ParseGetUserOrganizationsResponse(rsp *http.Response) (*GetUserOrganizationsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetUserOrganizationsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + Results []Organization `json:"results"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseGetUserSubscriptionsResponse parses an HTTP response from a GetUserSubscriptionsWithResponse call +func ParseGetUserSubscriptionsResponse(rsp *http.Response) (*GetUserSubscriptionsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetUserSubscriptionsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest UserSubscriptionList + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseUpdateUserSubscriptionsResponse parses an HTTP response from a UpdateUserSubscriptionsWithResponse call +func ParseUpdateUserSubscriptionsResponse(rsp *http.Response) (*UpdateUserSubscriptionsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateUserSubscriptionsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest User + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseListSubscriptionsResponse parses an HTTP response from a ListSubscriptionsWithResponse call +func ParseListSubscriptionsResponse(rsp *http.Response) (*ListSubscriptionsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListSubscriptionsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest SubscriptionListResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseCreateSubscriptionResponse parses an HTTP response from a CreateSubscriptionWithResponse call +func ParseCreateSubscriptionResponse(rsp *http.Response) (*CreateSubscriptionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateSubscriptionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Subscription + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseGetSubscriptionResponse parses an HTTP response from a GetSubscriptionWithResponse call +func ParseGetSubscriptionResponse(rsp *http.Response) (*GetSubscriptionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetSubscriptionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Subscription + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseUpdateSubscriptionResponse parses an HTTP response from a UpdateSubscriptionWithResponse call +func ParseUpdateSubscriptionResponse(rsp *http.Response) (*UpdateSubscriptionResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateSubscriptionResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Subscription + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseListTagsResponse parses an HTTP response from a ListTagsWithResponse call +func ParseListTagsResponse(rsp *http.Response) (*ListTagsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListTagsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest TagListResponse + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseCreateTagResponse parses an HTTP response from a CreateTagWithResponse call +func ParseCreateTagResponse(rsp *http.Response) (*CreateTagResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateTagResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Tag + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseDeleteTagResponse parses an HTTP response from a DeleteTagWithResponse call +func ParseDeleteTagResponse(rsp *http.Response) (*DeleteTagResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteTagResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseGetTagResponse parses an HTTP response from a GetTagWithResponse call +func ParseGetTagResponse(rsp *http.Response) (*GetTagResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetTagResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Tag + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseUpdateTagResponse parses an HTTP response from a UpdateTagWithResponse call +func ParseUpdateTagResponse(rsp *http.Response) (*UpdateTagResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateTagResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Tag + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseDeleteTenantResponse parses an HTTP response from a DeleteTenantWithResponse call +func ParseDeleteTenantResponse(rsp *http.Response) (*DeleteTenantResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteTenantResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseGetTenantResponse parses an HTTP response from a GetTenantWithResponse call +func ParseGetTenantResponse(rsp *http.Response) (*GetTenantResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetTenantResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Tenant + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseUpdateTenantResponse parses an HTTP response from a UpdateTenantWithResponse call +func ParseUpdateTenantResponse(rsp *http.Response) (*UpdateTenantResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateTenantResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Tenant + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseListAdminsResponse parses an HTTP response from a ListAdminsWithResponse call +func ParseListAdminsResponse(rsp *http.Response) (*ListAdminsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &ListAdminsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest AdminList + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseCreateAdminResponse parses an HTTP response from a CreateAdminWithResponse call +func ParseCreateAdminResponse(rsp *http.Response) (*CreateAdminResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &CreateAdminResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 201: + var dest Admin + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON201 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseDeleteAdminResponse parses an HTTP response from a DeleteAdminWithResponse call +func ParseDeleteAdminResponse(rsp *http.Response) (*DeleteAdminResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &DeleteAdminResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseGetAdminResponse parses an HTTP response from a GetAdminWithResponse call +func ParseGetAdminResponse(rsp *http.Response) (*GetAdminResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetAdminResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Admin + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseUpdateAdminResponse parses an HTTP response from a UpdateAdminWithResponse call +func ParseUpdateAdminResponse(rsp *http.Response) (*UpdateAdminResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &UpdateAdminResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Admin + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseGetTenantIntegrationsResponse parses an HTTP response from a GetTenantIntegrationsWithResponse call +func ParseGetTenantIntegrationsResponse(rsp *http.Response) (*GetTenantIntegrationsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetTenantIntegrationsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []Provider + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseWhoamiResponse parses an HTTP response from a WhoamiWithResponse call +func ParseWhoamiResponse(rsp *http.Response) (*WhoamiResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &WhoamiResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest Admin + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseAuthCallbackResponse parses an HTTP response from a AuthCallbackWithResponse call +func ParseAuthCallbackResponse(rsp *http.Response) (*AuthCallbackResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AuthCallbackResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseGetAuthMethodsResponse parses an HTTP response from a GetAuthMethodsWithResponse call +func ParseGetAuthMethodsResponse(rsp *http.Response) (*GetAuthMethodsResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &GetAuthMethodsResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest []string + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ParseAuthWebhookResponse parses an HTTP response from a AuthWebhookWithResponse call +func ParseAuthWebhookResponse(rsp *http.Response) (*AuthWebhookResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &AuthWebhookResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + +// ServerInterface represents all server handlers. +type ServerInterface interface { + // Get current admin profile + // (GET /api/admin/profile) + GetProfile(w http.ResponseWriter, r *http.Request) + // List projects + // (GET /api/admin/projects) + ListProjects(w http.ResponseWriter, r *http.Request, params ListProjectsParams) + // Create project + // (POST /api/admin/projects) + CreateProject(w http.ResponseWriter, r *http.Request) + // Get project by ID + // (GET /api/admin/projects/{projectID}) + GetProject(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) + // Update project + // (PATCH /api/admin/projects/{projectID}) + UpdateProject(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) + // List project admins + // (GET /api/admin/projects/{projectID}/admins) + ListProjectAdmins(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListProjectAdminsParams) + // Remove admin from project + // (DELETE /api/admin/projects/{projectID}/admins/{adminID}) + DeleteProjectAdmin(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, adminID openapi_types.UUID) + // Get project admin + // (GET /api/admin/projects/{projectID}/admins/{adminID}) + GetProjectAdmin(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, adminID openapi_types.UUID) + // Update project admin role + // (PATCH /api/admin/projects/{projectID}/admins/{adminID}) + UpdateProjectAdmin(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, adminID openapi_types.UUID) + // List campaigns + // (GET /api/admin/projects/{projectID}/campaigns) + ListCampaigns(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListCampaignsParams) + // Create campaign + // (POST /api/admin/projects/{projectID}/campaigns) + CreateCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) + // Delete campaign + // (DELETE /api/admin/projects/{projectID}/campaigns/{campaignID}) + DeleteCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) + // Get campaign by ID + // (GET /api/admin/projects/{projectID}/campaigns/{campaignID}) + GetCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) + // Update campaign + // (PATCH /api/admin/projects/{projectID}/campaigns/{campaignID}) + UpdateCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) + // Duplicate campaign + // (POST /api/admin/projects/{projectID}/campaigns/{campaignID}/duplicate) + DuplicateCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) + // Create template + // (POST /api/admin/projects/{projectID}/campaigns/{campaignID}/templates) + CreateTemplate(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) + // Delete template + // (DELETE /api/admin/projects/{projectID}/campaigns/{campaignID}/templates/{templateID}) + DeleteTemplate(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID) + // Get template by ID + // (GET /api/admin/projects/{projectID}/campaigns/{campaignID}/templates/{templateID}) + GetTemplate(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID) + // Update template + // (PATCH /api/admin/projects/{projectID}/campaigns/{campaignID}/templates/{templateID}) + UpdateTemplate(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID) + // Get campaign users + // (GET /api/admin/projects/{projectID}/campaigns/{campaignID}/users) + GetCampaignUsers(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID, params GetCampaignUsersParams) + // List documents + // (GET /api/admin/projects/{projectID}/documents) + ListDocuments(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListDocumentsParams) + // Upload documents + // (POST /api/admin/projects/{projectID}/documents) + UploadDocuments(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) + // Delete document + // (DELETE /api/admin/projects/{projectID}/documents/{documentID}) + DeleteDocument(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, documentID openapi_types.UUID) + // Retrieve a document + // (GET /api/admin/projects/{projectID}/documents/{documentID}) + GetDocument(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, documentID openapi_types.UUID) + // Get document metadata + // (GET /api/admin/projects/{projectID}/documents/{documentID}/metadata) + GetDocumentMetadata(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, documentID openapi_types.UUID) + // List journeys + // (GET /api/admin/projects/{projectID}/journeys) + ListJourneys(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListJourneysParams) + // Create journey + // (POST /api/admin/projects/{projectID}/journeys) + CreateJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) + // Delete journey + // (DELETE /api/admin/projects/{projectID}/journeys/{journeyID}) + DeleteJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) + // Get journey by ID + // (GET /api/admin/projects/{projectID}/journeys/{journeyID}) + GetJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) + // Update journey + // (PATCH /api/admin/projects/{projectID}/journeys/{journeyID}) + UpdateJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) + // Duplicate journey + // (POST /api/admin/projects/{projectID}/journeys/{journeyID}/duplicate) + DuplicateJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) + // Publish journey + // (POST /api/admin/projects/{projectID}/journeys/{journeyID}/publish) + PublishJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) + // Get journey steps + // (GET /api/admin/projects/{projectID}/journeys/{journeyID}/steps) + GetJourneySteps(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) + // Set journey steps + // (PUT /api/admin/projects/{projectID}/journeys/{journeyID}/steps) + SetJourneySteps(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) + // Create journey version + // (POST /api/admin/projects/{projectID}/journeys/{journeyID}/version) + VersionJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) + // List API keys + // (GET /api/admin/projects/{projectID}/keys) + ListApiKeys(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListApiKeysParams) + // Create API key + // (POST /api/admin/projects/{projectID}/keys) + CreateApiKey(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) + // Delete API key + // (DELETE /api/admin/projects/{projectID}/keys/{keyID}) + DeleteApiKey(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, keyID openapi_types.UUID) + // Get API key by ID + // (GET /api/admin/projects/{projectID}/keys/{keyID}) + GetApiKey(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, keyID openapi_types.UUID) + // Update API key + // (PATCH /api/admin/projects/{projectID}/keys/{keyID}) UpdateApiKey(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, keyID openapi_types.UUID) // List lists // (GET /api/admin/projects/{projectID}/lists) @@ -14802,6 +16419,75 @@ type ServerInterface interface { // Delete provider // (DELETE /api/admin/projects/{projectID}/providers/{providerID}) DeleteProvider(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, providerID openapi_types.UUID) + // List events with schemas + // (GET /api/admin/projects/{projectID}/subjects/events/schema) + ListEvents(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) + // List subject organizations + // (GET /api/admin/projects/{projectID}/subjects/organizations) + ListOrganizations(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListOrganizationsParams) + // Create or update subject organization + // (POST /api/admin/projects/{projectID}/subjects/organizations) + UpsertOrganization(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) + // List organization schemas + // (GET /api/admin/projects/{projectID}/subjects/organizations/schema) + ListOrganizationSchemas(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) + // List organization user schemas + // (GET /api/admin/projects/{projectID}/subjects/organizations/users/schema) + ListOrganizationMemberSchemas(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) + // Delete subject organization + // (DELETE /api/admin/projects/{projectID}/subjects/organizations/{organizationID}) + DeleteOrganization(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, organizationID openapi_types.UUID) + // Get subject organization by ID + // (GET /api/admin/projects/{projectID}/subjects/organizations/{organizationID}) + GetOrganization(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, organizationID openapi_types.UUID) + // Update subject organization + // (PATCH /api/admin/projects/{projectID}/subjects/organizations/{organizationID}) + UpdateOrganization(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, organizationID openapi_types.UUID) + // List organization users + // (GET /api/admin/projects/{projectID}/subjects/organizations/{organizationID}/users) + ListOrganizationMembers(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, organizationID openapi_types.UUID, params ListOrganizationMembersParams) + // Add user to organization + // (POST /api/admin/projects/{projectID}/subjects/organizations/{organizationID}/users) + AddOrganizationMember(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, organizationID openapi_types.UUID) + // Remove user from organization + // (DELETE /api/admin/projects/{projectID}/subjects/organizations/{organizationID}/users/{userID}) + RemoveOrganizationMember(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, organizationID openapi_types.UUID, userID openapi_types.UUID) + // List users + // (GET /api/admin/projects/{projectID}/subjects/users) + ListUsers(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListUsersParams) + // Identify user + // (POST /api/admin/projects/{projectID}/subjects/users) + IdentifyUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) + // Bulk import users + // (POST /api/admin/projects/{projectID}/subjects/users/import) + ImportUsers(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) + // List user schemas + // (GET /api/admin/projects/{projectID}/subjects/users/schema) + ListUserSchemas(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) + // Delete user + // (DELETE /api/admin/projects/{projectID}/subjects/users/{userID}) + DeleteUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) + // Get user by ID + // (GET /api/admin/projects/{projectID}/subjects/users/{userID}) + GetUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) + // Update user + // (PATCH /api/admin/projects/{projectID}/subjects/users/{userID}) + UpdateUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) + // Get user events + // (GET /api/admin/projects/{projectID}/subjects/users/{userID}/events) + GetUserEvents(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID, params GetUserEventsParams) + // Get user journeys + // (GET /api/admin/projects/{projectID}/subjects/users/{userID}/journeys) + GetUserJourneys(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID, params GetUserJourneysParams) + // Get user organizations + // (GET /api/admin/projects/{projectID}/subjects/users/{userID}/subject-organizations) + GetUserOrganizations(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) + // Get user subscriptions + // (GET /api/admin/projects/{projectID}/subjects/users/{userID}/subscriptions) + GetUserSubscriptions(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID, params GetUserSubscriptionsParams) + // Update user subscriptions + // (PATCH /api/admin/projects/{projectID}/subjects/users/{userID}/subscriptions) + UpdateUserSubscriptions(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) // List subscriptions // (GET /api/admin/projects/{projectID}/subscriptions) ListSubscriptions(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListSubscriptionsParams) @@ -14829,39 +16515,36 @@ type ServerInterface interface { // Update tag // (PATCH /api/admin/projects/{projectID}/tags/{tagID}) UpdateTag(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, tagID openapi_types.UUID) - // List users - // (GET /api/admin/projects/{projectID}/users) - ListUsers(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListUsersParams) - // Identify user - // (POST /api/admin/projects/{projectID}/users) - IdentifyUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) - // Bulk import users - // (POST /api/admin/projects/{projectID}/users/import) - ImportUsers(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) - // List user schemas - // (GET /api/admin/projects/{projectID}/users/schema) - ListUserSchemas(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) - // Delete user - // (DELETE /api/admin/projects/{projectID}/users/{userID}) - DeleteUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) - // Get user by ID - // (GET /api/admin/projects/{projectID}/users/{userID}) - GetUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) - // Update user - // (PATCH /api/admin/projects/{projectID}/users/{userID}) - UpdateUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) - // Get user events - // (GET /api/admin/projects/{projectID}/users/{userID}/events) - GetUserEvents(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID, params GetUserEventsParams) - // Get user journeys - // (GET /api/admin/projects/{projectID}/users/{userID}/journeys) - GetUserJourneys(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID, params GetUserJourneysParams) - // Get user subscriptions - // (GET /api/admin/projects/{projectID}/users/{userID}/subscriptions) - GetUserSubscriptions(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID, params GetUserSubscriptionsParams) - // Update user subscriptions - // (PATCH /api/admin/projects/{projectID}/users/{userID}/subscriptions) - UpdateUserSubscriptions(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) + // Delete tenant + // (DELETE /api/admin/tenant) + DeleteTenant(w http.ResponseWriter, r *http.Request) + // Get current tenant + // (GET /api/admin/tenant) + GetTenant(w http.ResponseWriter, r *http.Request) + // Update tenant + // (PATCH /api/admin/tenant) + UpdateTenant(w http.ResponseWriter, r *http.Request) + // List organization admins + // (GET /api/admin/tenant/admins) + ListAdmins(w http.ResponseWriter, r *http.Request, params ListAdminsParams) + // Create or update admin + // (POST /api/admin/tenant/admins) + CreateAdmin(w http.ResponseWriter, r *http.Request) + // Delete admin + // (DELETE /api/admin/tenant/admins/{adminID}) + DeleteAdmin(w http.ResponseWriter, r *http.Request, adminID openapi_types.UUID) + // Get admin by ID + // (GET /api/admin/tenant/admins/{adminID}) + GetAdmin(w http.ResponseWriter, r *http.Request, adminID openapi_types.UUID) + // Update admin + // (PATCH /api/admin/tenant/admins/{adminID}) + UpdateAdmin(w http.ResponseWriter, r *http.Request, adminID openapi_types.UUID) + // Get tenant integrations + // (GET /api/admin/tenant/integrations) + GetTenantIntegrations(w http.ResponseWriter, r *http.Request) + // Get current admin + // (GET /api/admin/tenant/whoami) + Whoami(w http.ResponseWriter, r *http.Request) // Complete authentication // (POST /api/auth/login/{driver}/callback) AuthCallback(w http.ResponseWriter, r *http.Request, driver AuthCallbackParamsDriver) @@ -14873,579 +16556,1035 @@ type ServerInterface interface { AuthWebhook(w http.ResponseWriter, r *http.Request, driver AuthWebhookParamsDriver) } -// Unimplemented server implementation that returns http.StatusNotImplemented for each endpoint. +// Unimplemented server implementation that returns http.StatusNotImplemented for each endpoint. + +type Unimplemented struct{} + +// Get current admin profile +// (GET /api/admin/profile) +func (_ Unimplemented) GetProfile(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List projects +// (GET /api/admin/projects) +func (_ Unimplemented) ListProjects(w http.ResponseWriter, r *http.Request, params ListProjectsParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Create project +// (POST /api/admin/projects) +func (_ Unimplemented) CreateProject(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get project by ID +// (GET /api/admin/projects/{projectID}) +func (_ Unimplemented) GetProject(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Update project +// (PATCH /api/admin/projects/{projectID}) +func (_ Unimplemented) UpdateProject(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List project admins +// (GET /api/admin/projects/{projectID}/admins) +func (_ Unimplemented) ListProjectAdmins(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListProjectAdminsParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Remove admin from project +// (DELETE /api/admin/projects/{projectID}/admins/{adminID}) +func (_ Unimplemented) DeleteProjectAdmin(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, adminID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get project admin +// (GET /api/admin/projects/{projectID}/admins/{adminID}) +func (_ Unimplemented) GetProjectAdmin(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, adminID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Update project admin role +// (PATCH /api/admin/projects/{projectID}/admins/{adminID}) +func (_ Unimplemented) UpdateProjectAdmin(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, adminID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List campaigns +// (GET /api/admin/projects/{projectID}/campaigns) +func (_ Unimplemented) ListCampaigns(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListCampaignsParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Create campaign +// (POST /api/admin/projects/{projectID}/campaigns) +func (_ Unimplemented) CreateCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Delete campaign +// (DELETE /api/admin/projects/{projectID}/campaigns/{campaignID}) +func (_ Unimplemented) DeleteCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get campaign by ID +// (GET /api/admin/projects/{projectID}/campaigns/{campaignID}) +func (_ Unimplemented) GetCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Update campaign +// (PATCH /api/admin/projects/{projectID}/campaigns/{campaignID}) +func (_ Unimplemented) UpdateCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Duplicate campaign +// (POST /api/admin/projects/{projectID}/campaigns/{campaignID}/duplicate) +func (_ Unimplemented) DuplicateCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Create template +// (POST /api/admin/projects/{projectID}/campaigns/{campaignID}/templates) +func (_ Unimplemented) CreateTemplate(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Delete template +// (DELETE /api/admin/projects/{projectID}/campaigns/{campaignID}/templates/{templateID}) +func (_ Unimplemented) DeleteTemplate(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get template by ID +// (GET /api/admin/projects/{projectID}/campaigns/{campaignID}/templates/{templateID}) +func (_ Unimplemented) GetTemplate(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Update template +// (PATCH /api/admin/projects/{projectID}/campaigns/{campaignID}/templates/{templateID}) +func (_ Unimplemented) UpdateTemplate(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get campaign users +// (GET /api/admin/projects/{projectID}/campaigns/{campaignID}/users) +func (_ Unimplemented) GetCampaignUsers(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID, params GetCampaignUsersParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List documents +// (GET /api/admin/projects/{projectID}/documents) +func (_ Unimplemented) ListDocuments(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListDocumentsParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Upload documents +// (POST /api/admin/projects/{projectID}/documents) +func (_ Unimplemented) UploadDocuments(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Delete document +// (DELETE /api/admin/projects/{projectID}/documents/{documentID}) +func (_ Unimplemented) DeleteDocument(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, documentID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Retrieve a document +// (GET /api/admin/projects/{projectID}/documents/{documentID}) +func (_ Unimplemented) GetDocument(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, documentID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get document metadata +// (GET /api/admin/projects/{projectID}/documents/{documentID}/metadata) +func (_ Unimplemented) GetDocumentMetadata(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, documentID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List journeys +// (GET /api/admin/projects/{projectID}/journeys) +func (_ Unimplemented) ListJourneys(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListJourneysParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Create journey +// (POST /api/admin/projects/{projectID}/journeys) +func (_ Unimplemented) CreateJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Delete journey +// (DELETE /api/admin/projects/{projectID}/journeys/{journeyID}) +func (_ Unimplemented) DeleteJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get journey by ID +// (GET /api/admin/projects/{projectID}/journeys/{journeyID}) +func (_ Unimplemented) GetJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Update journey +// (PATCH /api/admin/projects/{projectID}/journeys/{journeyID}) +func (_ Unimplemented) UpdateJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Duplicate journey +// (POST /api/admin/projects/{projectID}/journeys/{journeyID}/duplicate) +func (_ Unimplemented) DuplicateJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Publish journey +// (POST /api/admin/projects/{projectID}/journeys/{journeyID}/publish) +func (_ Unimplemented) PublishJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get journey steps +// (GET /api/admin/projects/{projectID}/journeys/{journeyID}/steps) +func (_ Unimplemented) GetJourneySteps(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Set journey steps +// (PUT /api/admin/projects/{projectID}/journeys/{journeyID}/steps) +func (_ Unimplemented) SetJourneySteps(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Create journey version +// (POST /api/admin/projects/{projectID}/journeys/{journeyID}/version) +func (_ Unimplemented) VersionJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List API keys +// (GET /api/admin/projects/{projectID}/keys) +func (_ Unimplemented) ListApiKeys(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListApiKeysParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Create API key +// (POST /api/admin/projects/{projectID}/keys) +func (_ Unimplemented) CreateApiKey(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Delete API key +// (DELETE /api/admin/projects/{projectID}/keys/{keyID}) +func (_ Unimplemented) DeleteApiKey(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, keyID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get API key by ID +// (GET /api/admin/projects/{projectID}/keys/{keyID}) +func (_ Unimplemented) GetApiKey(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, keyID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Update API key +// (PATCH /api/admin/projects/{projectID}/keys/{keyID}) +func (_ Unimplemented) UpdateApiKey(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, keyID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List lists +// (GET /api/admin/projects/{projectID}/lists) +func (_ Unimplemented) ListLists(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListListsParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Create list +// (POST /api/admin/projects/{projectID}/lists) +func (_ Unimplemented) CreateList(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Delete list +// (DELETE /api/admin/projects/{projectID}/lists/{listID}) +func (_ Unimplemented) DeleteList(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, listID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get list by ID +// (GET /api/admin/projects/{projectID}/lists/{listID}) +func (_ Unimplemented) GetList(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, listID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Update list +// (PATCH /api/admin/projects/{projectID}/lists/{listID}) +func (_ Unimplemented) UpdateList(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, listID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Duplicate list +// (POST /api/admin/projects/{projectID}/lists/{listID}/duplicate) +func (_ Unimplemented) DuplicateList(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, listID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get list users +// (GET /api/admin/projects/{projectID}/lists/{listID}/users) +func (_ Unimplemented) GetListUsers(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, listID openapi_types.UUID, params GetListUsersParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Import list users +// (POST /api/admin/projects/{projectID}/lists/{listID}/users) +func (_ Unimplemented) ImportListUsers(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, listID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List locales +// (GET /api/admin/projects/{projectID}/locales) +func (_ Unimplemented) ListLocales(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListLocalesParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Create locale +// (POST /api/admin/projects/{projectID}/locales) +func (_ Unimplemented) CreateLocale(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Delete locale +// (DELETE /api/admin/projects/{projectID}/locales/{localeID}) +func (_ Unimplemented) DeleteLocale(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, localeID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get locale by ID +// (GET /api/admin/projects/{projectID}/locales/{localeID}) +func (_ Unimplemented) GetLocale(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, localeID string) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List providers +// (GET /api/admin/projects/{projectID}/providers) +func (_ Unimplemented) ListProviders(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListProvidersParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List all providers +// (GET /api/admin/projects/{projectID}/providers/all) +func (_ Unimplemented) ListAllProviders(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List available provider modules +// (GET /api/admin/projects/{projectID}/providers/meta) +func (_ Unimplemented) ListProviderMeta(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Create provider +// (POST /api/admin/projects/{projectID}/providers/{group}/{type}) +func (_ Unimplemented) CreateProvider(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, group string, pType string) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get provider by ID +// (GET /api/admin/projects/{projectID}/providers/{group}/{type}/{providerID}) +func (_ Unimplemented) GetProvider(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, group string, pType string, providerID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Update provider +// (PATCH /api/admin/projects/{projectID}/providers/{group}/{type}/{providerID}) +func (_ Unimplemented) UpdateProvider(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, group string, pType string, providerID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Delete provider +// (DELETE /api/admin/projects/{projectID}/providers/{providerID}) +func (_ Unimplemented) DeleteProvider(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, providerID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List events with schemas +// (GET /api/admin/projects/{projectID}/subjects/events/schema) +func (_ Unimplemented) ListEvents(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List subject organizations +// (GET /api/admin/projects/{projectID}/subjects/organizations) +func (_ Unimplemented) ListOrganizations(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListOrganizationsParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Create or update subject organization +// (POST /api/admin/projects/{projectID}/subjects/organizations) +func (_ Unimplemented) UpsertOrganization(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List organization schemas +// (GET /api/admin/projects/{projectID}/subjects/organizations/schema) +func (_ Unimplemented) ListOrganizationSchemas(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List organization user schemas +// (GET /api/admin/projects/{projectID}/subjects/organizations/users/schema) +func (_ Unimplemented) ListOrganizationMemberSchemas(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Delete subject organization +// (DELETE /api/admin/projects/{projectID}/subjects/organizations/{organizationID}) +func (_ Unimplemented) DeleteOrganization(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, organizationID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get subject organization by ID +// (GET /api/admin/projects/{projectID}/subjects/organizations/{organizationID}) +func (_ Unimplemented) GetOrganization(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, organizationID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Update subject organization +// (PATCH /api/admin/projects/{projectID}/subjects/organizations/{organizationID}) +func (_ Unimplemented) UpdateOrganization(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, organizationID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List organization users +// (GET /api/admin/projects/{projectID}/subjects/organizations/{organizationID}/users) +func (_ Unimplemented) ListOrganizationMembers(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, organizationID openapi_types.UUID, params ListOrganizationMembersParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Add user to organization +// (POST /api/admin/projects/{projectID}/subjects/organizations/{organizationID}/users) +func (_ Unimplemented) AddOrganizationMember(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, organizationID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Remove user from organization +// (DELETE /api/admin/projects/{projectID}/subjects/organizations/{organizationID}/users/{userID}) +func (_ Unimplemented) RemoveOrganizationMember(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, organizationID openapi_types.UUID, userID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List users +// (GET /api/admin/projects/{projectID}/subjects/users) +func (_ Unimplemented) ListUsers(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListUsersParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Identify user +// (POST /api/admin/projects/{projectID}/subjects/users) +func (_ Unimplemented) IdentifyUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} -type Unimplemented struct{} +// Bulk import users +// (POST /api/admin/projects/{projectID}/subjects/users/import) +func (_ Unimplemented) ImportUsers(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List user schemas +// (GET /api/admin/projects/{projectID}/subjects/users/schema) +func (_ Unimplemented) ListUserSchemas(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Delete user +// (DELETE /api/admin/projects/{projectID}/subjects/users/{userID}) +func (_ Unimplemented) DeleteUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get user by ID +// (GET /api/admin/projects/{projectID}/subjects/users/{userID}) +func (_ Unimplemented) GetUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Update user +// (PATCH /api/admin/projects/{projectID}/subjects/users/{userID}) +func (_ Unimplemented) UpdateUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get user events +// (GET /api/admin/projects/{projectID}/subjects/users/{userID}/events) +func (_ Unimplemented) GetUserEvents(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID, params GetUserEventsParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get user journeys +// (GET /api/admin/projects/{projectID}/subjects/users/{userID}/journeys) +func (_ Unimplemented) GetUserJourneys(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID, params GetUserJourneysParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get user organizations +// (GET /api/admin/projects/{projectID}/subjects/users/{userID}/subject-organizations) +func (_ Unimplemented) GetUserOrganizations(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get user subscriptions +// (GET /api/admin/projects/{projectID}/subjects/users/{userID}/subscriptions) +func (_ Unimplemented) GetUserSubscriptions(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID, params GetUserSubscriptionsParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Update user subscriptions +// (PATCH /api/admin/projects/{projectID}/subjects/users/{userID}/subscriptions) +func (_ Unimplemented) UpdateUserSubscriptions(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List subscriptions +// (GET /api/admin/projects/{projectID}/subscriptions) +func (_ Unimplemented) ListSubscriptions(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListSubscriptionsParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Create subscription type +// (POST /api/admin/projects/{projectID}/subscriptions) +func (_ Unimplemented) CreateSubscription(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get subscription by ID +// (GET /api/admin/projects/{projectID}/subscriptions/{subscriptionID}) +func (_ Unimplemented) GetSubscription(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, subscriptionID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Update subscription type +// (PATCH /api/admin/projects/{projectID}/subscriptions/{subscriptionID}) +func (_ Unimplemented) UpdateSubscription(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, subscriptionID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// List tags +// (GET /api/admin/projects/{projectID}/tags) +func (_ Unimplemented) ListTags(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListTagsParams) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Create tag +// (POST /api/admin/projects/{projectID}/tags) +func (_ Unimplemented) CreateTag(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Delete tag +// (DELETE /api/admin/projects/{projectID}/tags/{tagID}) +func (_ Unimplemented) DeleteTag(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, tagID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Get tag by ID +// (GET /api/admin/projects/{projectID}/tags/{tagID}) +func (_ Unimplemented) GetTag(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, tagID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} -// Delete organization -// (DELETE /api/admin/organizations) -func (_ Unimplemented) DeleteOrganization(w http.ResponseWriter, r *http.Request) { +// Update tag +// (PATCH /api/admin/projects/{projectID}/tags/{tagID}) +func (_ Unimplemented) UpdateTag(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, tagID openapi_types.UUID) { + w.WriteHeader(http.StatusNotImplemented) +} + +// Delete tenant +// (DELETE /api/admin/tenant) +func (_ Unimplemented) DeleteTenant(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotImplemented) } -// Get current organization -// (GET /api/admin/organizations) -func (_ Unimplemented) GetOrganization(w http.ResponseWriter, r *http.Request) { +// Get current tenant +// (GET /api/admin/tenant) +func (_ Unimplemented) GetTenant(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotImplemented) } -// Update organization -// (PATCH /api/admin/organizations) -func (_ Unimplemented) UpdateOrganization(w http.ResponseWriter, r *http.Request) { +// Update tenant +// (PATCH /api/admin/tenant) +func (_ Unimplemented) UpdateTenant(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotImplemented) } // List organization admins -// (GET /api/admin/organizations/admins) +// (GET /api/admin/tenant/admins) func (_ Unimplemented) ListAdmins(w http.ResponseWriter, r *http.Request, params ListAdminsParams) { w.WriteHeader(http.StatusNotImplemented) } // Create or update admin -// (POST /api/admin/organizations/admins) +// (POST /api/admin/tenant/admins) func (_ Unimplemented) CreateAdmin(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotImplemented) } // Delete admin -// (DELETE /api/admin/organizations/admins/{adminID}) +// (DELETE /api/admin/tenant/admins/{adminID}) func (_ Unimplemented) DeleteAdmin(w http.ResponseWriter, r *http.Request, adminID openapi_types.UUID) { w.WriteHeader(http.StatusNotImplemented) } // Get admin by ID -// (GET /api/admin/organizations/admins/{adminID}) +// (GET /api/admin/tenant/admins/{adminID}) func (_ Unimplemented) GetAdmin(w http.ResponseWriter, r *http.Request, adminID openapi_types.UUID) { w.WriteHeader(http.StatusNotImplemented) } // Update admin -// (PATCH /api/admin/organizations/admins/{adminID}) +// (PATCH /api/admin/tenant/admins/{adminID}) func (_ Unimplemented) UpdateAdmin(w http.ResponseWriter, r *http.Request, adminID openapi_types.UUID) { w.WriteHeader(http.StatusNotImplemented) } -// Get organization integrations -// (GET /api/admin/organizations/integrations) -func (_ Unimplemented) GetOrganizationIntegrations(w http.ResponseWriter, r *http.Request) { +// Get tenant integrations +// (GET /api/admin/tenant/integrations) +func (_ Unimplemented) GetTenantIntegrations(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotImplemented) } // Get current admin -// (GET /api/admin/organizations/whoami) +// (GET /api/admin/tenant/whoami) func (_ Unimplemented) Whoami(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotImplemented) } -// Get current admin profile -// (GET /api/admin/profile) -func (_ Unimplemented) GetProfile(w http.ResponseWriter, r *http.Request) { +// Complete authentication +// (POST /api/auth/login/{driver}/callback) +func (_ Unimplemented) AuthCallback(w http.ResponseWriter, r *http.Request, driver AuthCallbackParamsDriver) { w.WriteHeader(http.StatusNotImplemented) } -// List projects -// (GET /api/admin/projects) -func (_ Unimplemented) ListProjects(w http.ResponseWriter, r *http.Request, params ListProjectsParams) { +// Get available auth methods +// (GET /api/auth/methods) +func (_ Unimplemented) GetAuthMethods(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusNotImplemented) } -// Create project -// (POST /api/admin/projects) -func (_ Unimplemented) CreateProject(w http.ResponseWriter, r *http.Request) { +// Auth provider webhook +// (POST /api/auth/{driver}/webhook) +func (_ Unimplemented) AuthWebhook(w http.ResponseWriter, r *http.Request, driver AuthWebhookParamsDriver) { w.WriteHeader(http.StatusNotImplemented) } -// Get project by ID -// (GET /api/admin/projects/{projectID}) -func (_ Unimplemented) GetProject(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) +// ServerInterfaceWrapper converts contexts to parameters. +type ServerInterfaceWrapper struct { + Handler ServerInterface + HandlerMiddlewares []MiddlewareFunc + ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error) } -// Update project -// (PATCH /api/admin/projects/{projectID}) -func (_ Unimplemented) UpdateProject(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) +type MiddlewareFunc func(http.Handler) http.Handler + +// GetProfile operation middleware +func (siw *ServerInterfaceWrapper) GetProfile(w http.ResponseWriter, r *http.Request) { + + ctx := r.Context() + + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) + + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetProfile(w, r) + })) + + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) + } + + handler.ServeHTTP(w, r) +} + +// ListProjects operation middleware +func (siw *ServerInterfaceWrapper) ListProjects(w http.ResponseWriter, r *http.Request) { + + var err error + + ctx := r.Context() + + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) + + // Parameter object where we will unmarshal all parameters from the context + var params ListProjectsParams + + // ------------- Optional query parameter "limit" ------------- + + err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) + return + } + + // ------------- Optional query parameter "offset" ------------- + + err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) + return + } + + // ------------- Optional query parameter "search" ------------- + + err = runtime.BindQueryParameter("form", true, false, "search", r.URL.Query(), ¶ms.Search) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "search", Err: err}) + return + } + + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.ListProjects(w, r, params) + })) + + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) + } + + handler.ServeHTTP(w, r) +} + +// CreateProject operation middleware +func (siw *ServerInterfaceWrapper) CreateProject(w http.ResponseWriter, r *http.Request) { + + ctx := r.Context() + + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) + + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.CreateProject(w, r) + })) + + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) + } + + handler.ServeHTTP(w, r) } -// List project admins -// (GET /api/admin/projects/{projectID}/admins) -func (_ Unimplemented) ListProjectAdmins(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListProjectAdminsParams) { - w.WriteHeader(http.StatusNotImplemented) +// GetProject operation middleware +func (siw *ServerInterfaceWrapper) GetProject(w http.ResponseWriter, r *http.Request) { + + var err error + + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return + } + + ctx := r.Context() + + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) + + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetProject(w, r, projectID) + })) + + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) + } + + handler.ServeHTTP(w, r) } -// Remove admin from project -// (DELETE /api/admin/projects/{projectID}/admins/{adminID}) -func (_ Unimplemented) DeleteProjectAdmin(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, adminID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} +// UpdateProject operation middleware +func (siw *ServerInterfaceWrapper) UpdateProject(w http.ResponseWriter, r *http.Request) { -// Get project admin -// (GET /api/admin/projects/{projectID}/admins/{adminID}) -func (_ Unimplemented) GetProjectAdmin(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, adminID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + var err error -// Update project admin role -// (PATCH /api/admin/projects/{projectID}/admins/{adminID}) -func (_ Unimplemented) UpdateProjectAdmin(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, adminID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID -// List campaigns -// (GET /api/admin/projects/{projectID}/campaigns) -func (_ Unimplemented) ListCampaigns(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListCampaignsParams) { - w.WriteHeader(http.StatusNotImplemented) -} + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return + } -// Create campaign -// (POST /api/admin/projects/{projectID}/campaigns) -func (_ Unimplemented) CreateCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + ctx := r.Context() -// Delete campaign -// (DELETE /api/admin/projects/{projectID}/campaigns/{campaignID}) -func (_ Unimplemented) DeleteCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) -// Get campaign by ID -// (GET /api/admin/projects/{projectID}/campaigns/{campaignID}) -func (_ Unimplemented) GetCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + r = r.WithContext(ctx) -// Update campaign -// (PATCH /api/admin/projects/{projectID}/campaigns/{campaignID}) -func (_ Unimplemented) UpdateCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.UpdateProject(w, r, projectID) + })) -// Duplicate campaign -// (POST /api/admin/projects/{projectID}/campaigns/{campaignID}/duplicate) -func (_ Unimplemented) DuplicateCampaign(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) + } -// Create template -// (POST /api/admin/projects/{projectID}/campaigns/{campaignID}/templates) -func (_ Unimplemented) CreateTemplate(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) + handler.ServeHTTP(w, r) } -// Delete template -// (DELETE /api/admin/projects/{projectID}/campaigns/{campaignID}/templates/{templateID}) -func (_ Unimplemented) DeleteTemplate(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} +// ListProjectAdmins operation middleware +func (siw *ServerInterfaceWrapper) ListProjectAdmins(w http.ResponseWriter, r *http.Request) { -// Get template by ID -// (GET /api/admin/projects/{projectID}/campaigns/{campaignID}/templates/{templateID}) -func (_ Unimplemented) GetTemplate(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + var err error -// Update template -// (PATCH /api/admin/projects/{projectID}/campaigns/{campaignID}/templates/{templateID}) -func (_ Unimplemented) UpdateTemplate(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID, templateID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID -// Get campaign users -// (GET /api/admin/projects/{projectID}/campaigns/{campaignID}/users) -func (_ Unimplemented) GetCampaignUsers(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, campaignID openapi_types.UUID, params GetCampaignUsersParams) { - w.WriteHeader(http.StatusNotImplemented) -} + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return + } -// List documents -// (GET /api/admin/projects/{projectID}/documents) -func (_ Unimplemented) ListDocuments(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListDocumentsParams) { - w.WriteHeader(http.StatusNotImplemented) -} + ctx := r.Context() -// Upload documents -// (POST /api/admin/projects/{projectID}/documents) -func (_ Unimplemented) UploadDocuments(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) -// Delete document -// (DELETE /api/admin/projects/{projectID}/documents/{documentID}) -func (_ Unimplemented) DeleteDocument(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, documentID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + r = r.WithContext(ctx) -// Retrieve a document -// (GET /api/admin/projects/{projectID}/documents/{documentID}) -func (_ Unimplemented) GetDocument(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, documentID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + // Parameter object where we will unmarshal all parameters from the context + var params ListProjectAdminsParams -// Get document metadata -// (GET /api/admin/projects/{projectID}/documents/{documentID}/metadata) -func (_ Unimplemented) GetDocumentMetadata(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, documentID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + // ------------- Optional query parameter "limit" ------------- -// List events with schemas -// (GET /api/admin/projects/{projectID}/events/schema) -func (_ Unimplemented) ListEvents(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) + return + } -// List journeys -// (GET /api/admin/projects/{projectID}/journeys) -func (_ Unimplemented) ListJourneys(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListJourneysParams) { - w.WriteHeader(http.StatusNotImplemented) -} + // ------------- Optional query parameter "offset" ------------- -// Create journey -// (POST /api/admin/projects/{projectID}/journeys) -func (_ Unimplemented) CreateJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) + return + } -// Delete journey -// (DELETE /api/admin/projects/{projectID}/journeys/{journeyID}) -func (_ Unimplemented) DeleteJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + // ------------- Optional query parameter "search" ------------- -// Get journey by ID -// (GET /api/admin/projects/{projectID}/journeys/{journeyID}) -func (_ Unimplemented) GetJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + err = runtime.BindQueryParameter("form", true, false, "search", r.URL.Query(), ¶ms.Search) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "search", Err: err}) + return + } -// Update journey -// (PATCH /api/admin/projects/{projectID}/journeys/{journeyID}) -func (_ Unimplemented) UpdateJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.ListProjectAdmins(w, r, projectID, params) + })) -// Duplicate journey -// (POST /api/admin/projects/{projectID}/journeys/{journeyID}/duplicate) -func (_ Unimplemented) DuplicateJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) + } -// Publish journey -// (POST /api/admin/projects/{projectID}/journeys/{journeyID}/publish) -func (_ Unimplemented) PublishJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) + handler.ServeHTTP(w, r) } -// Get journey steps -// (GET /api/admin/projects/{projectID}/journeys/{journeyID}/steps) -func (_ Unimplemented) GetJourneySteps(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} +// DeleteProjectAdmin operation middleware +func (siw *ServerInterfaceWrapper) DeleteProjectAdmin(w http.ResponseWriter, r *http.Request) { -// Set journey steps -// (PUT /api/admin/projects/{projectID}/journeys/{journeyID}/steps) -func (_ Unimplemented) SetJourneySteps(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + var err error -// Create journey version -// (POST /api/admin/projects/{projectID}/journeys/{journeyID}/version) -func (_ Unimplemented) VersionJourney(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID -// List API keys -// (GET /api/admin/projects/{projectID}/keys) -func (_ Unimplemented) ListApiKeys(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListApiKeysParams) { - w.WriteHeader(http.StatusNotImplemented) -} + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return + } -// Create API key -// (POST /api/admin/projects/{projectID}/keys) -func (_ Unimplemented) CreateApiKey(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + // ------------- Path parameter "adminID" ------------- + var adminID openapi_types.UUID -// Delete API key -// (DELETE /api/admin/projects/{projectID}/keys/{keyID}) -func (_ Unimplemented) DeleteApiKey(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, keyID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + err = runtime.BindStyledParameterWithOptions("simple", "adminID", chi.URLParam(r, "adminID"), &adminID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "adminID", Err: err}) + return + } -// Get API key by ID -// (GET /api/admin/projects/{projectID}/keys/{keyID}) -func (_ Unimplemented) GetApiKey(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, keyID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + ctx := r.Context() + + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) -// Update API key -// (PATCH /api/admin/projects/{projectID}/keys/{keyID}) -func (_ Unimplemented) UpdateApiKey(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, keyID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.DeleteProjectAdmin(w, r, projectID, adminID) + })) -// List lists -// (GET /api/admin/projects/{projectID}/lists) -func (_ Unimplemented) ListLists(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListListsParams) { - w.WriteHeader(http.StatusNotImplemented) -} + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) + } -// Create list -// (POST /api/admin/projects/{projectID}/lists) -func (_ Unimplemented) CreateList(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) + handler.ServeHTTP(w, r) } -// Delete list -// (DELETE /api/admin/projects/{projectID}/lists/{listID}) -func (_ Unimplemented) DeleteList(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, listID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} +// GetProjectAdmin operation middleware +func (siw *ServerInterfaceWrapper) GetProjectAdmin(w http.ResponseWriter, r *http.Request) { -// Get list by ID -// (GET /api/admin/projects/{projectID}/lists/{listID}) -func (_ Unimplemented) GetList(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, listID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + var err error -// Update list -// (PATCH /api/admin/projects/{projectID}/lists/{listID}) -func (_ Unimplemented) UpdateList(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, listID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID -// Duplicate list -// (POST /api/admin/projects/{projectID}/lists/{listID}/duplicate) -func (_ Unimplemented) DuplicateList(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, listID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return + } -// Get list users -// (GET /api/admin/projects/{projectID}/lists/{listID}/users) -func (_ Unimplemented) GetListUsers(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, listID openapi_types.UUID, params GetListUsersParams) { - w.WriteHeader(http.StatusNotImplemented) -} + // ------------- Path parameter "adminID" ------------- + var adminID openapi_types.UUID -// Import list users -// (POST /api/admin/projects/{projectID}/lists/{listID}/users) -func (_ Unimplemented) ImportListUsers(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, listID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + err = runtime.BindStyledParameterWithOptions("simple", "adminID", chi.URLParam(r, "adminID"), &adminID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "adminID", Err: err}) + return + } -// List locales -// (GET /api/admin/projects/{projectID}/locales) -func (_ Unimplemented) ListLocales(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListLocalesParams) { - w.WriteHeader(http.StatusNotImplemented) -} + ctx := r.Context() -// Create locale -// (POST /api/admin/projects/{projectID}/locales) -func (_ Unimplemented) CreateLocale(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) -// Delete locale -// (DELETE /api/admin/projects/{projectID}/locales/{localeID}) -func (_ Unimplemented) DeleteLocale(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, localeID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + r = r.WithContext(ctx) -// Get locale by ID -// (GET /api/admin/projects/{projectID}/locales/{localeID}) -func (_ Unimplemented) GetLocale(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, localeID string) { - w.WriteHeader(http.StatusNotImplemented) -} + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetProjectAdmin(w, r, projectID, adminID) + })) -// List providers -// (GET /api/admin/projects/{projectID}/providers) -func (_ Unimplemented) ListProviders(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListProvidersParams) { - w.WriteHeader(http.StatusNotImplemented) -} + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) + } -// List all providers -// (GET /api/admin/projects/{projectID}/providers/all) -func (_ Unimplemented) ListAllProviders(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) + handler.ServeHTTP(w, r) } -// List available provider modules -// (GET /api/admin/projects/{projectID}/providers/meta) -func (_ Unimplemented) ListProviderMeta(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} +// UpdateProjectAdmin operation middleware +func (siw *ServerInterfaceWrapper) UpdateProjectAdmin(w http.ResponseWriter, r *http.Request) { -// Create provider -// (POST /api/admin/projects/{projectID}/providers/{group}/{type}) -func (_ Unimplemented) CreateProvider(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, group string, pType string) { - w.WriteHeader(http.StatusNotImplemented) -} + var err error -// Get provider by ID -// (GET /api/admin/projects/{projectID}/providers/{group}/{type}/{providerID}) -func (_ Unimplemented) GetProvider(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, group string, pType string, providerID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID -// Update provider -// (PATCH /api/admin/projects/{projectID}/providers/{group}/{type}/{providerID}) -func (_ Unimplemented) UpdateProvider(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, group string, pType string, providerID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return + } -// Delete provider -// (DELETE /api/admin/projects/{projectID}/providers/{providerID}) -func (_ Unimplemented) DeleteProvider(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, providerID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + // ------------- Path parameter "adminID" ------------- + var adminID openapi_types.UUID -// List subscriptions -// (GET /api/admin/projects/{projectID}/subscriptions) -func (_ Unimplemented) ListSubscriptions(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListSubscriptionsParams) { - w.WriteHeader(http.StatusNotImplemented) -} + err = runtime.BindStyledParameterWithOptions("simple", "adminID", chi.URLParam(r, "adminID"), &adminID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "adminID", Err: err}) + return + } -// Create subscription type -// (POST /api/admin/projects/{projectID}/subscriptions) -func (_ Unimplemented) CreateSubscription(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + ctx := r.Context() -// Get subscription by ID -// (GET /api/admin/projects/{projectID}/subscriptions/{subscriptionID}) -func (_ Unimplemented) GetSubscription(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, subscriptionID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) -// Update subscription type -// (PATCH /api/admin/projects/{projectID}/subscriptions/{subscriptionID}) -func (_ Unimplemented) UpdateSubscription(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, subscriptionID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + r = r.WithContext(ctx) -// List tags -// (GET /api/admin/projects/{projectID}/tags) -func (_ Unimplemented) ListTags(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListTagsParams) { - w.WriteHeader(http.StatusNotImplemented) -} + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.UpdateProjectAdmin(w, r, projectID, adminID) + })) -// Create tag -// (POST /api/admin/projects/{projectID}/tags) -func (_ Unimplemented) CreateTag(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) + } -// Delete tag -// (DELETE /api/admin/projects/{projectID}/tags/{tagID}) -func (_ Unimplemented) DeleteTag(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, tagID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) + handler.ServeHTTP(w, r) } -// Get tag by ID -// (GET /api/admin/projects/{projectID}/tags/{tagID}) -func (_ Unimplemented) GetTag(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, tagID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} +// ListCampaigns operation middleware +func (siw *ServerInterfaceWrapper) ListCampaigns(w http.ResponseWriter, r *http.Request) { -// Update tag -// (PATCH /api/admin/projects/{projectID}/tags/{tagID}) -func (_ Unimplemented) UpdateTag(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, tagID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + var err error -// List users -// (GET /api/admin/projects/{projectID}/users) -func (_ Unimplemented) ListUsers(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, params ListUsersParams) { - w.WriteHeader(http.StatusNotImplemented) -} + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID -// Identify user -// (POST /api/admin/projects/{projectID}/users) -func (_ Unimplemented) IdentifyUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return + } -// Bulk import users -// (POST /api/admin/projects/{projectID}/users/import) -func (_ Unimplemented) ImportUsers(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + ctx := r.Context() -// List user schemas -// (GET /api/admin/projects/{projectID}/users/schema) -func (_ Unimplemented) ListUserSchemas(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) -// Delete user -// (DELETE /api/admin/projects/{projectID}/users/{userID}) -func (_ Unimplemented) DeleteUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + r = r.WithContext(ctx) -// Get user by ID -// (GET /api/admin/projects/{projectID}/users/{userID}) -func (_ Unimplemented) GetUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + // Parameter object where we will unmarshal all parameters from the context + var params ListCampaignsParams -// Update user -// (PATCH /api/admin/projects/{projectID}/users/{userID}) -func (_ Unimplemented) UpdateUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + // ------------- Optional query parameter "limit" ------------- -// Get user events -// (GET /api/admin/projects/{projectID}/users/{userID}/events) -func (_ Unimplemented) GetUserEvents(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID, params GetUserEventsParams) { - w.WriteHeader(http.StatusNotImplemented) -} + err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) + return + } -// Get user journeys -// (GET /api/admin/projects/{projectID}/users/{userID}/journeys) -func (_ Unimplemented) GetUserJourneys(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID, params GetUserJourneysParams) { - w.WriteHeader(http.StatusNotImplemented) -} + // ------------- Optional query parameter "offset" ------------- -// Get user subscriptions -// (GET /api/admin/projects/{projectID}/users/{userID}/subscriptions) -func (_ Unimplemented) GetUserSubscriptions(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID, params GetUserSubscriptionsParams) { - w.WriteHeader(http.StatusNotImplemented) -} + err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) + return + } -// Update user subscriptions -// (PATCH /api/admin/projects/{projectID}/users/{userID}/subscriptions) -func (_ Unimplemented) UpdateUserSubscriptions(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, userID openapi_types.UUID) { - w.WriteHeader(http.StatusNotImplemented) -} + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.ListCampaigns(w, r, projectID, params) + })) -// Complete authentication -// (POST /api/auth/login/{driver}/callback) -func (_ Unimplemented) AuthCallback(w http.ResponseWriter, r *http.Request, driver AuthCallbackParamsDriver) { - w.WriteHeader(http.StatusNotImplemented) -} + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) + } -// Get available auth methods -// (GET /api/auth/methods) -func (_ Unimplemented) GetAuthMethods(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusNotImplemented) + handler.ServeHTTP(w, r) } -// Auth provider webhook -// (POST /api/auth/{driver}/webhook) -func (_ Unimplemented) AuthWebhook(w http.ResponseWriter, r *http.Request, driver AuthWebhookParamsDriver) { - w.WriteHeader(http.StatusNotImplemented) -} +// CreateCampaign operation middleware +func (siw *ServerInterfaceWrapper) CreateCampaign(w http.ResponseWriter, r *http.Request) { -// ServerInterfaceWrapper converts contexts to parameters. -type ServerInterfaceWrapper struct { - Handler ServerInterface - HandlerMiddlewares []MiddlewareFunc - ErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error) -} + var err error -type MiddlewareFunc func(http.Handler) http.Handler + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID -// DeleteOrganization operation middleware -func (siw *ServerInterfaceWrapper) DeleteOrganization(w http.ResponseWriter, r *http.Request) { + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return + } ctx := r.Context() @@ -15454,7 +17593,7 @@ func (siw *ServerInterfaceWrapper) DeleteOrganization(w http.ResponseWriter, r * r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.DeleteOrganization(w, r) + siw.Handler.CreateCampaign(w, r, projectID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -15464,8 +17603,28 @@ func (siw *ServerInterfaceWrapper) DeleteOrganization(w http.ResponseWriter, r * handler.ServeHTTP(w, r) } -// GetOrganization operation middleware -func (siw *ServerInterfaceWrapper) GetOrganization(w http.ResponseWriter, r *http.Request) { +// DeleteCampaign operation middleware +func (siw *ServerInterfaceWrapper) DeleteCampaign(w http.ResponseWriter, r *http.Request) { + + var err error + + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return + } + + // ------------- Path parameter "campaignID" ------------- + var campaignID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "campaignID", chi.URLParam(r, "campaignID"), &campaignID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "campaignID", Err: err}) + return + } ctx := r.Context() @@ -15474,7 +17633,7 @@ func (siw *ServerInterfaceWrapper) GetOrganization(w http.ResponseWriter, r *htt r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetOrganization(w, r) + siw.Handler.DeleteCampaign(w, r, projectID, campaignID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -15484,8 +17643,28 @@ func (siw *ServerInterfaceWrapper) GetOrganization(w http.ResponseWriter, r *htt handler.ServeHTTP(w, r) } -// UpdateOrganization operation middleware -func (siw *ServerInterfaceWrapper) UpdateOrganization(w http.ResponseWriter, r *http.Request) { +// GetCampaign operation middleware +func (siw *ServerInterfaceWrapper) GetCampaign(w http.ResponseWriter, r *http.Request) { + + var err error + + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return + } + + // ------------- Path parameter "campaignID" ------------- + var campaignID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "campaignID", chi.URLParam(r, "campaignID"), &campaignID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "campaignID", Err: err}) + return + } ctx := r.Context() @@ -15494,7 +17673,7 @@ func (siw *ServerInterfaceWrapper) UpdateOrganization(w http.ResponseWriter, r * r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.UpdateOrganization(w, r) + siw.Handler.GetCampaign(w, r, projectID, campaignID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -15504,46 +17683,77 @@ func (siw *ServerInterfaceWrapper) UpdateOrganization(w http.ResponseWriter, r * handler.ServeHTTP(w, r) } -// ListAdmins operation middleware -func (siw *ServerInterfaceWrapper) ListAdmins(w http.ResponseWriter, r *http.Request) { +// UpdateCampaign operation middleware +func (siw *ServerInterfaceWrapper) UpdateCampaign(w http.ResponseWriter, r *http.Request) { var err error + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return + } + + // ------------- Path parameter "campaignID" ------------- + var campaignID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "campaignID", chi.URLParam(r, "campaignID"), &campaignID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "campaignID", Err: err}) + return + } + ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) r = r.WithContext(ctx) - // Parameter object where we will unmarshal all parameters from the context - var params ListAdminsParams - - // ------------- Optional query parameter "limit" ------------- + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.UpdateCampaign(w, r, projectID, campaignID) + })) - err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) - return + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) } - // ------------- Optional query parameter "offset" ------------- + handler.ServeHTTP(w, r) +} - err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) +// DuplicateCampaign operation middleware +func (siw *ServerInterfaceWrapper) DuplicateCampaign(w http.ResponseWriter, r *http.Request) { + + var err error + + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) return } - // ------------- Optional query parameter "search" ------------- + // ------------- Path parameter "campaignID" ------------- + var campaignID openapi_types.UUID - err = runtime.BindQueryParameter("form", true, false, "search", r.URL.Query(), ¶ms.Search) + err = runtime.BindStyledParameterWithOptions("simple", "campaignID", chi.URLParam(r, "campaignID"), &campaignID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "search", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "campaignID", Err: err}) return } + ctx := r.Context() + + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ListAdmins(w, r, params) + siw.Handler.DuplicateCampaign(w, r, projectID, campaignID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -15553,8 +17763,28 @@ func (siw *ServerInterfaceWrapper) ListAdmins(w http.ResponseWriter, r *http.Req handler.ServeHTTP(w, r) } -// CreateAdmin operation middleware -func (siw *ServerInterfaceWrapper) CreateAdmin(w http.ResponseWriter, r *http.Request) { +// CreateTemplate operation middleware +func (siw *ServerInterfaceWrapper) CreateTemplate(w http.ResponseWriter, r *http.Request) { + + var err error + + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return + } + + // ------------- Path parameter "campaignID" ------------- + var campaignID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "campaignID", chi.URLParam(r, "campaignID"), &campaignID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "campaignID", Err: err}) + return + } ctx := r.Context() @@ -15563,7 +17793,7 @@ func (siw *ServerInterfaceWrapper) CreateAdmin(w http.ResponseWriter, r *http.Re r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.CreateAdmin(w, r) + siw.Handler.CreateTemplate(w, r, projectID, campaignID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -15573,17 +17803,35 @@ func (siw *ServerInterfaceWrapper) CreateAdmin(w http.ResponseWriter, r *http.Re handler.ServeHTTP(w, r) } -// DeleteAdmin operation middleware -func (siw *ServerInterfaceWrapper) DeleteAdmin(w http.ResponseWriter, r *http.Request) { +// DeleteTemplate operation middleware +func (siw *ServerInterfaceWrapper) DeleteTemplate(w http.ResponseWriter, r *http.Request) { var err error - // ------------- Path parameter "adminID" ------------- - var adminID openapi_types.UUID + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "adminID", chi.URLParam(r, "adminID"), &adminID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "adminID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return + } + + // ------------- Path parameter "campaignID" ------------- + var campaignID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "campaignID", chi.URLParam(r, "campaignID"), &campaignID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "campaignID", Err: err}) + return + } + + // ------------- Path parameter "templateID" ------------- + var templateID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "templateID", chi.URLParam(r, "templateID"), &templateID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "templateID", Err: err}) return } @@ -15594,7 +17842,7 @@ func (siw *ServerInterfaceWrapper) DeleteAdmin(w http.ResponseWriter, r *http.Re r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.DeleteAdmin(w, r, adminID) + siw.Handler.DeleteTemplate(w, r, projectID, campaignID, templateID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -15604,17 +17852,35 @@ func (siw *ServerInterfaceWrapper) DeleteAdmin(w http.ResponseWriter, r *http.Re handler.ServeHTTP(w, r) } -// GetAdmin operation middleware -func (siw *ServerInterfaceWrapper) GetAdmin(w http.ResponseWriter, r *http.Request) { +// GetTemplate operation middleware +func (siw *ServerInterfaceWrapper) GetTemplate(w http.ResponseWriter, r *http.Request) { var err error - // ------------- Path parameter "adminID" ------------- - var adminID openapi_types.UUID + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return + } + + // ------------- Path parameter "campaignID" ------------- + var campaignID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "campaignID", chi.URLParam(r, "campaignID"), &campaignID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "campaignID", Err: err}) + return + } + + // ------------- Path parameter "templateID" ------------- + var templateID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "adminID", chi.URLParam(r, "adminID"), &adminID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "templateID", chi.URLParam(r, "templateID"), &templateID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "adminID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "templateID", Err: err}) return } @@ -15625,7 +17891,7 @@ func (siw *ServerInterfaceWrapper) GetAdmin(w http.ResponseWriter, r *http.Reque r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetAdmin(w, r, adminID) + siw.Handler.GetTemplate(w, r, projectID, campaignID, templateID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -15635,39 +17901,37 @@ func (siw *ServerInterfaceWrapper) GetAdmin(w http.ResponseWriter, r *http.Reque handler.ServeHTTP(w, r) } -// UpdateAdmin operation middleware -func (siw *ServerInterfaceWrapper) UpdateAdmin(w http.ResponseWriter, r *http.Request) { +// UpdateTemplate operation middleware +func (siw *ServerInterfaceWrapper) UpdateTemplate(w http.ResponseWriter, r *http.Request) { var err error - // ------------- Path parameter "adminID" ------------- - var adminID openapi_types.UUID + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "adminID", chi.URLParam(r, "adminID"), &adminID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "adminID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) return } - ctx := r.Context() - - ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) - - r = r.WithContext(ctx) - - handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.UpdateAdmin(w, r, adminID) - })) + // ------------- Path parameter "campaignID" ------------- + var campaignID openapi_types.UUID - for _, middleware := range siw.HandlerMiddlewares { - handler = middleware(handler) + err = runtime.BindStyledParameterWithOptions("simple", "campaignID", chi.URLParam(r, "campaignID"), &campaignID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "campaignID", Err: err}) + return } - handler.ServeHTTP(w, r) -} + // ------------- Path parameter "templateID" ------------- + var templateID openapi_types.UUID -// GetOrganizationIntegrations operation middleware -func (siw *ServerInterfaceWrapper) GetOrganizationIntegrations(w http.ResponseWriter, r *http.Request) { + err = runtime.BindStyledParameterWithOptions("simple", "templateID", chi.URLParam(r, "templateID"), &templateID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "templateID", Err: err}) + return + } ctx := r.Context() @@ -15676,7 +17940,7 @@ func (siw *ServerInterfaceWrapper) GetOrganizationIntegrations(w http.ResponseWr r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetOrganizationIntegrations(w, r) + siw.Handler.UpdateTemplate(w, r, projectID, campaignID, templateID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -15686,28 +17950,28 @@ func (siw *ServerInterfaceWrapper) GetOrganizationIntegrations(w http.ResponseWr handler.ServeHTTP(w, r) } -// Whoami operation middleware -func (siw *ServerInterfaceWrapper) Whoami(w http.ResponseWriter, r *http.Request) { - - ctx := r.Context() - - ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) +// GetCampaignUsers operation middleware +func (siw *ServerInterfaceWrapper) GetCampaignUsers(w http.ResponseWriter, r *http.Request) { - r = r.WithContext(ctx) + var err error - handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.Whoami(w, r) - })) + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID - for _, middleware := range siw.HandlerMiddlewares { - handler = middleware(handler) + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return } - handler.ServeHTTP(w, r) -} + // ------------- Path parameter "campaignID" ------------- + var campaignID openapi_types.UUID -// GetProfile operation middleware -func (siw *ServerInterfaceWrapper) GetProfile(w http.ResponseWriter, r *http.Request) { + err = runtime.BindStyledParameterWithOptions("simple", "campaignID", chi.URLParam(r, "campaignID"), &campaignID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "campaignID", Err: err}) + return + } ctx := r.Context() @@ -15715,8 +17979,27 @@ func (siw *ServerInterfaceWrapper) GetProfile(w http.ResponseWriter, r *http.Req r = r.WithContext(ctx) + // Parameter object where we will unmarshal all parameters from the context + var params GetCampaignUsersParams + + // ------------- Optional query parameter "limit" ------------- + + err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) + return + } + + // ------------- Optional query parameter "offset" ------------- + + err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) + return + } + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetProfile(w, r) + siw.Handler.GetCampaignUsers(w, r, projectID, campaignID, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -15726,11 +18009,20 @@ func (siw *ServerInterfaceWrapper) GetProfile(w http.ResponseWriter, r *http.Req handler.ServeHTTP(w, r) } -// ListProjects operation middleware -func (siw *ServerInterfaceWrapper) ListProjects(w http.ResponseWriter, r *http.Request) { +// ListDocuments operation middleware +func (siw *ServerInterfaceWrapper) ListDocuments(w http.ResponseWriter, r *http.Request) { var err error + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return + } + ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -15738,7 +18030,7 @@ func (siw *ServerInterfaceWrapper) ListProjects(w http.ResponseWriter, r *http.R r = r.WithContext(ctx) // Parameter object where we will unmarshal all parameters from the context - var params ListProjectsParams + var params ListDocumentsParams // ------------- Optional query parameter "limit" ------------- @@ -15756,16 +18048,8 @@ func (siw *ServerInterfaceWrapper) ListProjects(w http.ResponseWriter, r *http.R return } - // ------------- Optional query parameter "search" ------------- - - err = runtime.BindQueryParameter("form", true, false, "search", r.URL.Query(), ¶ms.Search) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "search", Err: err}) - return - } - handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ListProjects(w, r, params) + siw.Handler.ListDocuments(w, r, projectID, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -15775,8 +18059,19 @@ func (siw *ServerInterfaceWrapper) ListProjects(w http.ResponseWriter, r *http.R handler.ServeHTTP(w, r) } -// CreateProject operation middleware -func (siw *ServerInterfaceWrapper) CreateProject(w http.ResponseWriter, r *http.Request) { +// UploadDocuments operation middleware +func (siw *ServerInterfaceWrapper) UploadDocuments(w http.ResponseWriter, r *http.Request) { + + var err error + + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return + } ctx := r.Context() @@ -15785,7 +18080,7 @@ func (siw *ServerInterfaceWrapper) CreateProject(w http.ResponseWriter, r *http. r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.CreateProject(w, r) + siw.Handler.UploadDocuments(w, r, projectID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -15795,8 +18090,8 @@ func (siw *ServerInterfaceWrapper) CreateProject(w http.ResponseWriter, r *http. handler.ServeHTTP(w, r) } -// GetProject operation middleware -func (siw *ServerInterfaceWrapper) GetProject(w http.ResponseWriter, r *http.Request) { +// DeleteDocument operation middleware +func (siw *ServerInterfaceWrapper) DeleteDocument(w http.ResponseWriter, r *http.Request) { var err error @@ -15809,6 +18104,15 @@ func (siw *ServerInterfaceWrapper) GetProject(w http.ResponseWriter, r *http.Req return } + // ------------- Path parameter "documentID" ------------- + var documentID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "documentID", chi.URLParam(r, "documentID"), &documentID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "documentID", Err: err}) + return + } + ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -15816,7 +18120,7 @@ func (siw *ServerInterfaceWrapper) GetProject(w http.ResponseWriter, r *http.Req r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetProject(w, r, projectID) + siw.Handler.DeleteDocument(w, r, projectID, documentID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -15826,8 +18130,8 @@ func (siw *ServerInterfaceWrapper) GetProject(w http.ResponseWriter, r *http.Req handler.ServeHTTP(w, r) } -// UpdateProject operation middleware -func (siw *ServerInterfaceWrapper) UpdateProject(w http.ResponseWriter, r *http.Request) { +// GetDocument operation middleware +func (siw *ServerInterfaceWrapper) GetDocument(w http.ResponseWriter, r *http.Request) { var err error @@ -15840,6 +18144,15 @@ func (siw *ServerInterfaceWrapper) UpdateProject(w http.ResponseWriter, r *http. return } + // ------------- Path parameter "documentID" ------------- + var documentID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "documentID", chi.URLParam(r, "documentID"), &documentID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "documentID", Err: err}) + return + } + ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -15847,7 +18160,7 @@ func (siw *ServerInterfaceWrapper) UpdateProject(w http.ResponseWriter, r *http. r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.UpdateProject(w, r, projectID) + siw.Handler.GetDocument(w, r, projectID, documentID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -15857,8 +18170,8 @@ func (siw *ServerInterfaceWrapper) UpdateProject(w http.ResponseWriter, r *http. handler.ServeHTTP(w, r) } -// ListProjectAdmins operation middleware -func (siw *ServerInterfaceWrapper) ListProjectAdmins(w http.ResponseWriter, r *http.Request) { +// GetDocumentMetadata operation middleware +func (siw *ServerInterfaceWrapper) GetDocumentMetadata(w http.ResponseWriter, r *http.Request) { var err error @@ -15871,41 +18184,23 @@ func (siw *ServerInterfaceWrapper) ListProjectAdmins(w http.ResponseWriter, r *h return } - ctx := r.Context() - - ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) - - r = r.WithContext(ctx) - - // Parameter object where we will unmarshal all parameters from the context - var params ListProjectAdminsParams - - // ------------- Optional query parameter "limit" ------------- + // ------------- Path parameter "documentID" ------------- + var documentID openapi_types.UUID - err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) + err = runtime.BindStyledParameterWithOptions("simple", "documentID", chi.URLParam(r, "documentID"), &documentID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "documentID", Err: err}) return } - // ------------- Optional query parameter "offset" ------------- - - err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) - return - } + ctx := r.Context() - // ------------- Optional query parameter "search" ------------- + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) - err = runtime.BindQueryParameter("form", true, false, "search", r.URL.Query(), ¶ms.Search) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "search", Err: err}) - return - } + r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ListProjectAdmins(w, r, projectID, params) + siw.Handler.GetDocumentMetadata(w, r, projectID, documentID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -15915,8 +18210,8 @@ func (siw *ServerInterfaceWrapper) ListProjectAdmins(w http.ResponseWriter, r *h handler.ServeHTTP(w, r) } -// DeleteProjectAdmin operation middleware -func (siw *ServerInterfaceWrapper) DeleteProjectAdmin(w http.ResponseWriter, r *http.Request) { +// ListJourneys operation middleware +func (siw *ServerInterfaceWrapper) ListJourneys(w http.ResponseWriter, r *http.Request) { var err error @@ -15929,23 +18224,33 @@ func (siw *ServerInterfaceWrapper) DeleteProjectAdmin(w http.ResponseWriter, r * return } - // ------------- Path parameter "adminID" ------------- - var adminID openapi_types.UUID + ctx := r.Context() - err = runtime.BindStyledParameterWithOptions("simple", "adminID", chi.URLParam(r, "adminID"), &adminID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) + + // Parameter object where we will unmarshal all parameters from the context + var params ListJourneysParams + + // ------------- Optional query parameter "limit" ------------- + + err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "adminID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) return } - ctx := r.Context() - - ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + // ------------- Optional query parameter "offset" ------------- - r = r.WithContext(ctx) + err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) + return + } handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.DeleteProjectAdmin(w, r, projectID, adminID) + siw.Handler.ListJourneys(w, r, projectID, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -15955,26 +18260,17 @@ func (siw *ServerInterfaceWrapper) DeleteProjectAdmin(w http.ResponseWriter, r * handler.ServeHTTP(w, r) } -// GetProjectAdmin operation middleware -func (siw *ServerInterfaceWrapper) GetProjectAdmin(w http.ResponseWriter, r *http.Request) { +// CreateJourney operation middleware +func (siw *ServerInterfaceWrapper) CreateJourney(w http.ResponseWriter, r *http.Request) { var err error // ------------- Path parameter "projectID" ------------- var projectID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) - return - } - - // ------------- Path parameter "adminID" ------------- - var adminID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "adminID", chi.URLParam(r, "adminID"), &adminID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "adminID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) return } @@ -15985,7 +18281,7 @@ func (siw *ServerInterfaceWrapper) GetProjectAdmin(w http.ResponseWriter, r *htt r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetProjectAdmin(w, r, projectID, adminID) + siw.Handler.CreateJourney(w, r, projectID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -15995,8 +18291,8 @@ func (siw *ServerInterfaceWrapper) GetProjectAdmin(w http.ResponseWriter, r *htt handler.ServeHTTP(w, r) } -// UpdateProjectAdmin operation middleware -func (siw *ServerInterfaceWrapper) UpdateProjectAdmin(w http.ResponseWriter, r *http.Request) { +// DeleteJourney operation middleware +func (siw *ServerInterfaceWrapper) DeleteJourney(w http.ResponseWriter, r *http.Request) { var err error @@ -16009,12 +18305,12 @@ func (siw *ServerInterfaceWrapper) UpdateProjectAdmin(w http.ResponseWriter, r * return } - // ------------- Path parameter "adminID" ------------- - var adminID openapi_types.UUID + // ------------- Path parameter "journeyID" ------------- + var journeyID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "adminID", chi.URLParam(r, "adminID"), &adminID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "journeyID", chi.URLParam(r, "journeyID"), &journeyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "adminID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "journeyID", Err: err}) return } @@ -16025,7 +18321,7 @@ func (siw *ServerInterfaceWrapper) UpdateProjectAdmin(w http.ResponseWriter, r * r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.UpdateProjectAdmin(w, r, projectID, adminID) + siw.Handler.DeleteJourney(w, r, projectID, journeyID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16035,8 +18331,8 @@ func (siw *ServerInterfaceWrapper) UpdateProjectAdmin(w http.ResponseWriter, r * handler.ServeHTTP(w, r) } -// ListCampaigns operation middleware -func (siw *ServerInterfaceWrapper) ListCampaigns(w http.ResponseWriter, r *http.Request) { +// GetJourney operation middleware +func (siw *ServerInterfaceWrapper) GetJourney(w http.ResponseWriter, r *http.Request) { var err error @@ -16049,33 +18345,23 @@ func (siw *ServerInterfaceWrapper) ListCampaigns(w http.ResponseWriter, r *http. return } - ctx := r.Context() - - ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) - - r = r.WithContext(ctx) - - // Parameter object where we will unmarshal all parameters from the context - var params ListCampaignsParams - - // ------------- Optional query parameter "limit" ------------- + // ------------- Path parameter "journeyID" ------------- + var journeyID openapi_types.UUID - err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) + err = runtime.BindStyledParameterWithOptions("simple", "journeyID", chi.URLParam(r, "journeyID"), &journeyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "journeyID", Err: err}) return } - // ------------- Optional query parameter "offset" ------------- + ctx := r.Context() - err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) - return - } + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ListCampaigns(w, r, projectID, params) + siw.Handler.GetJourney(w, r, projectID, journeyID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16085,8 +18371,8 @@ func (siw *ServerInterfaceWrapper) ListCampaigns(w http.ResponseWriter, r *http. handler.ServeHTTP(w, r) } -// CreateCampaign operation middleware -func (siw *ServerInterfaceWrapper) CreateCampaign(w http.ResponseWriter, r *http.Request) { +// UpdateJourney operation middleware +func (siw *ServerInterfaceWrapper) UpdateJourney(w http.ResponseWriter, r *http.Request) { var err error @@ -16099,6 +18385,15 @@ func (siw *ServerInterfaceWrapper) CreateCampaign(w http.ResponseWriter, r *http return } + // ------------- Path parameter "journeyID" ------------- + var journeyID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "journeyID", chi.URLParam(r, "journeyID"), &journeyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "journeyID", Err: err}) + return + } + ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -16106,7 +18401,7 @@ func (siw *ServerInterfaceWrapper) CreateCampaign(w http.ResponseWriter, r *http r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.CreateCampaign(w, r, projectID) + siw.Handler.UpdateJourney(w, r, projectID, journeyID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16116,8 +18411,8 @@ func (siw *ServerInterfaceWrapper) CreateCampaign(w http.ResponseWriter, r *http handler.ServeHTTP(w, r) } -// DeleteCampaign operation middleware -func (siw *ServerInterfaceWrapper) DeleteCampaign(w http.ResponseWriter, r *http.Request) { +// DuplicateJourney operation middleware +func (siw *ServerInterfaceWrapper) DuplicateJourney(w http.ResponseWriter, r *http.Request) { var err error @@ -16130,12 +18425,12 @@ func (siw *ServerInterfaceWrapper) DeleteCampaign(w http.ResponseWriter, r *http return } - // ------------- Path parameter "campaignID" ------------- - var campaignID openapi_types.UUID + // ------------- Path parameter "journeyID" ------------- + var journeyID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "campaignID", chi.URLParam(r, "campaignID"), &campaignID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "journeyID", chi.URLParam(r, "journeyID"), &journeyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "campaignID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "journeyID", Err: err}) return } @@ -16146,7 +18441,7 @@ func (siw *ServerInterfaceWrapper) DeleteCampaign(w http.ResponseWriter, r *http r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.DeleteCampaign(w, r, projectID, campaignID) + siw.Handler.DuplicateJourney(w, r, projectID, journeyID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16156,8 +18451,8 @@ func (siw *ServerInterfaceWrapper) DeleteCampaign(w http.ResponseWriter, r *http handler.ServeHTTP(w, r) } -// GetCampaign operation middleware -func (siw *ServerInterfaceWrapper) GetCampaign(w http.ResponseWriter, r *http.Request) { +// PublishJourney operation middleware +func (siw *ServerInterfaceWrapper) PublishJourney(w http.ResponseWriter, r *http.Request) { var err error @@ -16170,12 +18465,12 @@ func (siw *ServerInterfaceWrapper) GetCampaign(w http.ResponseWriter, r *http.Re return } - // ------------- Path parameter "campaignID" ------------- - var campaignID openapi_types.UUID + // ------------- Path parameter "journeyID" ------------- + var journeyID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "campaignID", chi.URLParam(r, "campaignID"), &campaignID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "journeyID", chi.URLParam(r, "journeyID"), &journeyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "campaignID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "journeyID", Err: err}) return } @@ -16186,7 +18481,7 @@ func (siw *ServerInterfaceWrapper) GetCampaign(w http.ResponseWriter, r *http.Re r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetCampaign(w, r, projectID, campaignID) + siw.Handler.PublishJourney(w, r, projectID, journeyID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16196,8 +18491,8 @@ func (siw *ServerInterfaceWrapper) GetCampaign(w http.ResponseWriter, r *http.Re handler.ServeHTTP(w, r) } -// UpdateCampaign operation middleware -func (siw *ServerInterfaceWrapper) UpdateCampaign(w http.ResponseWriter, r *http.Request) { +// GetJourneySteps operation middleware +func (siw *ServerInterfaceWrapper) GetJourneySteps(w http.ResponseWriter, r *http.Request) { var err error @@ -16210,12 +18505,12 @@ func (siw *ServerInterfaceWrapper) UpdateCampaign(w http.ResponseWriter, r *http return } - // ------------- Path parameter "campaignID" ------------- - var campaignID openapi_types.UUID + // ------------- Path parameter "journeyID" ------------- + var journeyID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "campaignID", chi.URLParam(r, "campaignID"), &campaignID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "journeyID", chi.URLParam(r, "journeyID"), &journeyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "campaignID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "journeyID", Err: err}) return } @@ -16226,7 +18521,7 @@ func (siw *ServerInterfaceWrapper) UpdateCampaign(w http.ResponseWriter, r *http r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.UpdateCampaign(w, r, projectID, campaignID) + siw.Handler.GetJourneySteps(w, r, projectID, journeyID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16236,8 +18531,8 @@ func (siw *ServerInterfaceWrapper) UpdateCampaign(w http.ResponseWriter, r *http handler.ServeHTTP(w, r) } -// DuplicateCampaign operation middleware -func (siw *ServerInterfaceWrapper) DuplicateCampaign(w http.ResponseWriter, r *http.Request) { +// SetJourneySteps operation middleware +func (siw *ServerInterfaceWrapper) SetJourneySteps(w http.ResponseWriter, r *http.Request) { var err error @@ -16250,12 +18545,12 @@ func (siw *ServerInterfaceWrapper) DuplicateCampaign(w http.ResponseWriter, r *h return } - // ------------- Path parameter "campaignID" ------------- - var campaignID openapi_types.UUID + // ------------- Path parameter "journeyID" ------------- + var journeyID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "campaignID", chi.URLParam(r, "campaignID"), &campaignID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "journeyID", chi.URLParam(r, "journeyID"), &journeyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "campaignID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "journeyID", Err: err}) return } @@ -16266,7 +18561,7 @@ func (siw *ServerInterfaceWrapper) DuplicateCampaign(w http.ResponseWriter, r *h r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.DuplicateCampaign(w, r, projectID, campaignID) + siw.Handler.SetJourneySteps(w, r, projectID, journeyID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16276,8 +18571,8 @@ func (siw *ServerInterfaceWrapper) DuplicateCampaign(w http.ResponseWriter, r *h handler.ServeHTTP(w, r) } -// CreateTemplate operation middleware -func (siw *ServerInterfaceWrapper) CreateTemplate(w http.ResponseWriter, r *http.Request) { +// VersionJourney operation middleware +func (siw *ServerInterfaceWrapper) VersionJourney(w http.ResponseWriter, r *http.Request) { var err error @@ -16290,12 +18585,12 @@ func (siw *ServerInterfaceWrapper) CreateTemplate(w http.ResponseWriter, r *http return } - // ------------- Path parameter "campaignID" ------------- - var campaignID openapi_types.UUID + // ------------- Path parameter "journeyID" ------------- + var journeyID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "campaignID", chi.URLParam(r, "campaignID"), &campaignID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "journeyID", chi.URLParam(r, "journeyID"), &journeyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "campaignID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "journeyID", Err: err}) return } @@ -16306,7 +18601,7 @@ func (siw *ServerInterfaceWrapper) CreateTemplate(w http.ResponseWriter, r *http r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.CreateTemplate(w, r, projectID, campaignID) + siw.Handler.VersionJourney(w, r, projectID, journeyID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16316,8 +18611,8 @@ func (siw *ServerInterfaceWrapper) CreateTemplate(w http.ResponseWriter, r *http handler.ServeHTTP(w, r) } -// DeleteTemplate operation middleware -func (siw *ServerInterfaceWrapper) DeleteTemplate(w http.ResponseWriter, r *http.Request) { +// ListApiKeys operation middleware +func (siw *ServerInterfaceWrapper) ListApiKeys(w http.ResponseWriter, r *http.Request) { var err error @@ -16330,32 +18625,33 @@ func (siw *ServerInterfaceWrapper) DeleteTemplate(w http.ResponseWriter, r *http return } - // ------------- Path parameter "campaignID" ------------- - var campaignID openapi_types.UUID + ctx := r.Context() - err = runtime.BindStyledParameterWithOptions("simple", "campaignID", chi.URLParam(r, "campaignID"), &campaignID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) + + // Parameter object where we will unmarshal all parameters from the context + var params ListApiKeysParams + + // ------------- Optional query parameter "limit" ------------- + + err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "campaignID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) return } - // ------------- Path parameter "templateID" ------------- - var templateID openapi_types.UUID + // ------------- Optional query parameter "offset" ------------- - err = runtime.BindStyledParameterWithOptions("simple", "templateID", chi.URLParam(r, "templateID"), &templateID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "templateID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) return } - ctx := r.Context() - - ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) - - r = r.WithContext(ctx) - handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.DeleteTemplate(w, r, projectID, campaignID, templateID) + siw.Handler.ListApiKeys(w, r, projectID, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16365,8 +18661,8 @@ func (siw *ServerInterfaceWrapper) DeleteTemplate(w http.ResponseWriter, r *http handler.ServeHTTP(w, r) } -// GetTemplate operation middleware -func (siw *ServerInterfaceWrapper) GetTemplate(w http.ResponseWriter, r *http.Request) { +// CreateApiKey operation middleware +func (siw *ServerInterfaceWrapper) CreateApiKey(w http.ResponseWriter, r *http.Request) { var err error @@ -16379,24 +18675,6 @@ func (siw *ServerInterfaceWrapper) GetTemplate(w http.ResponseWriter, r *http.Re return } - // ------------- Path parameter "campaignID" ------------- - var campaignID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "campaignID", chi.URLParam(r, "campaignID"), &campaignID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "campaignID", Err: err}) - return - } - - // ------------- Path parameter "templateID" ------------- - var templateID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "templateID", chi.URLParam(r, "templateID"), &templateID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "templateID", Err: err}) - return - } - ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -16404,7 +18682,7 @@ func (siw *ServerInterfaceWrapper) GetTemplate(w http.ResponseWriter, r *http.Re r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetTemplate(w, r, projectID, campaignID, templateID) + siw.Handler.CreateApiKey(w, r, projectID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16414,8 +18692,8 @@ func (siw *ServerInterfaceWrapper) GetTemplate(w http.ResponseWriter, r *http.Re handler.ServeHTTP(w, r) } -// UpdateTemplate operation middleware -func (siw *ServerInterfaceWrapper) UpdateTemplate(w http.ResponseWriter, r *http.Request) { +// DeleteApiKey operation middleware +func (siw *ServerInterfaceWrapper) DeleteApiKey(w http.ResponseWriter, r *http.Request) { var err error @@ -16428,21 +18706,12 @@ func (siw *ServerInterfaceWrapper) UpdateTemplate(w http.ResponseWriter, r *http return } - // ------------- Path parameter "campaignID" ------------- - var campaignID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "campaignID", chi.URLParam(r, "campaignID"), &campaignID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "campaignID", Err: err}) - return - } - - // ------------- Path parameter "templateID" ------------- - var templateID openapi_types.UUID + // ------------- Path parameter "keyID" ------------- + var keyID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "templateID", chi.URLParam(r, "templateID"), &templateID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "keyID", chi.URLParam(r, "keyID"), &keyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "templateID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "keyID", Err: err}) return } @@ -16453,7 +18722,7 @@ func (siw *ServerInterfaceWrapper) UpdateTemplate(w http.ResponseWriter, r *http r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.UpdateTemplate(w, r, projectID, campaignID, templateID) + siw.Handler.DeleteApiKey(w, r, projectID, keyID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16463,8 +18732,8 @@ func (siw *ServerInterfaceWrapper) UpdateTemplate(w http.ResponseWriter, r *http handler.ServeHTTP(w, r) } -// GetCampaignUsers operation middleware -func (siw *ServerInterfaceWrapper) GetCampaignUsers(w http.ResponseWriter, r *http.Request) { +// GetApiKey operation middleware +func (siw *ServerInterfaceWrapper) GetApiKey(w http.ResponseWriter, r *http.Request) { var err error @@ -16477,12 +18746,12 @@ func (siw *ServerInterfaceWrapper) GetCampaignUsers(w http.ResponseWriter, r *ht return } - // ------------- Path parameter "campaignID" ------------- - var campaignID openapi_types.UUID + // ------------- Path parameter "keyID" ------------- + var keyID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "campaignID", chi.URLParam(r, "campaignID"), &campaignID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "keyID", chi.URLParam(r, "keyID"), &keyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "campaignID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "keyID", Err: err}) return } @@ -16492,27 +18761,48 @@ func (siw *ServerInterfaceWrapper) GetCampaignUsers(w http.ResponseWriter, r *ht r = r.WithContext(ctx) - // Parameter object where we will unmarshal all parameters from the context - var params GetCampaignUsersParams + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetApiKey(w, r, projectID, keyID) + })) - // ------------- Optional query parameter "limit" ------------- + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) + } - err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) + handler.ServeHTTP(w, r) +} + +// UpdateApiKey operation middleware +func (siw *ServerInterfaceWrapper) UpdateApiKey(w http.ResponseWriter, r *http.Request) { + + var err error + + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) return } - // ------------- Optional query parameter "offset" ------------- + // ------------- Path parameter "keyID" ------------- + var keyID openapi_types.UUID - err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) + err = runtime.BindStyledParameterWithOptions("simple", "keyID", chi.URLParam(r, "keyID"), &keyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "keyID", Err: err}) return } + ctx := r.Context() + + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetCampaignUsers(w, r, projectID, campaignID, params) + siw.Handler.UpdateApiKey(w, r, projectID, keyID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16522,8 +18812,8 @@ func (siw *ServerInterfaceWrapper) GetCampaignUsers(w http.ResponseWriter, r *ht handler.ServeHTTP(w, r) } -// ListDocuments operation middleware -func (siw *ServerInterfaceWrapper) ListDocuments(w http.ResponseWriter, r *http.Request) { +// ListLists operation middleware +func (siw *ServerInterfaceWrapper) ListLists(w http.ResponseWriter, r *http.Request) { var err error @@ -16543,7 +18833,7 @@ func (siw *ServerInterfaceWrapper) ListDocuments(w http.ResponseWriter, r *http. r = r.WithContext(ctx) // Parameter object where we will unmarshal all parameters from the context - var params ListDocumentsParams + var params ListListsParams // ------------- Optional query parameter "limit" ------------- @@ -16562,7 +18852,7 @@ func (siw *ServerInterfaceWrapper) ListDocuments(w http.ResponseWriter, r *http. } handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ListDocuments(w, r, projectID, params) + siw.Handler.ListLists(w, r, projectID, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16572,8 +18862,8 @@ func (siw *ServerInterfaceWrapper) ListDocuments(w http.ResponseWriter, r *http. handler.ServeHTTP(w, r) } -// UploadDocuments operation middleware -func (siw *ServerInterfaceWrapper) UploadDocuments(w http.ResponseWriter, r *http.Request) { +// CreateList operation middleware +func (siw *ServerInterfaceWrapper) CreateList(w http.ResponseWriter, r *http.Request) { var err error @@ -16593,7 +18883,7 @@ func (siw *ServerInterfaceWrapper) UploadDocuments(w http.ResponseWriter, r *htt r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.UploadDocuments(w, r, projectID) + siw.Handler.CreateList(w, r, projectID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16603,8 +18893,8 @@ func (siw *ServerInterfaceWrapper) UploadDocuments(w http.ResponseWriter, r *htt handler.ServeHTTP(w, r) } -// DeleteDocument operation middleware -func (siw *ServerInterfaceWrapper) DeleteDocument(w http.ResponseWriter, r *http.Request) { +// DeleteList operation middleware +func (siw *ServerInterfaceWrapper) DeleteList(w http.ResponseWriter, r *http.Request) { var err error @@ -16617,12 +18907,12 @@ func (siw *ServerInterfaceWrapper) DeleteDocument(w http.ResponseWriter, r *http return } - // ------------- Path parameter "documentID" ------------- - var documentID openapi_types.UUID + // ------------- Path parameter "listID" ------------- + var listID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "documentID", chi.URLParam(r, "documentID"), &documentID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "listID", chi.URLParam(r, "listID"), &listID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "documentID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "listID", Err: err}) return } @@ -16633,7 +18923,7 @@ func (siw *ServerInterfaceWrapper) DeleteDocument(w http.ResponseWriter, r *http r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.DeleteDocument(w, r, projectID, documentID) + siw.Handler.DeleteList(w, r, projectID, listID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16643,8 +18933,8 @@ func (siw *ServerInterfaceWrapper) DeleteDocument(w http.ResponseWriter, r *http handler.ServeHTTP(w, r) } -// GetDocument operation middleware -func (siw *ServerInterfaceWrapper) GetDocument(w http.ResponseWriter, r *http.Request) { +// GetList operation middleware +func (siw *ServerInterfaceWrapper) GetList(w http.ResponseWriter, r *http.Request) { var err error @@ -16657,12 +18947,12 @@ func (siw *ServerInterfaceWrapper) GetDocument(w http.ResponseWriter, r *http.Re return } - // ------------- Path parameter "documentID" ------------- - var documentID openapi_types.UUID + // ------------- Path parameter "listID" ------------- + var listID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "documentID", chi.URLParam(r, "documentID"), &documentID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "listID", chi.URLParam(r, "listID"), &listID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "documentID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "listID", Err: err}) return } @@ -16673,7 +18963,7 @@ func (siw *ServerInterfaceWrapper) GetDocument(w http.ResponseWriter, r *http.Re r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetDocument(w, r, projectID, documentID) + siw.Handler.GetList(w, r, projectID, listID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16683,8 +18973,8 @@ func (siw *ServerInterfaceWrapper) GetDocument(w http.ResponseWriter, r *http.Re handler.ServeHTTP(w, r) } -// GetDocumentMetadata operation middleware -func (siw *ServerInterfaceWrapper) GetDocumentMetadata(w http.ResponseWriter, r *http.Request) { +// UpdateList operation middleware +func (siw *ServerInterfaceWrapper) UpdateList(w http.ResponseWriter, r *http.Request) { var err error @@ -16697,12 +18987,12 @@ func (siw *ServerInterfaceWrapper) GetDocumentMetadata(w http.ResponseWriter, r return } - // ------------- Path parameter "documentID" ------------- - var documentID openapi_types.UUID + // ------------- Path parameter "listID" ------------- + var listID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "documentID", chi.URLParam(r, "documentID"), &documentID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "listID", chi.URLParam(r, "listID"), &listID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "documentID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "listID", Err: err}) return } @@ -16713,7 +19003,7 @@ func (siw *ServerInterfaceWrapper) GetDocumentMetadata(w http.ResponseWriter, r r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetDocumentMetadata(w, r, projectID, documentID) + siw.Handler.UpdateList(w, r, projectID, listID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16723,8 +19013,8 @@ func (siw *ServerInterfaceWrapper) GetDocumentMetadata(w http.ResponseWriter, r handler.ServeHTTP(w, r) } -// ListEvents operation middleware -func (siw *ServerInterfaceWrapper) ListEvents(w http.ResponseWriter, r *http.Request) { +// DuplicateList operation middleware +func (siw *ServerInterfaceWrapper) DuplicateList(w http.ResponseWriter, r *http.Request) { var err error @@ -16737,6 +19027,15 @@ func (siw *ServerInterfaceWrapper) ListEvents(w http.ResponseWriter, r *http.Req return } + // ------------- Path parameter "listID" ------------- + var listID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "listID", chi.URLParam(r, "listID"), &listID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "listID", Err: err}) + return + } + ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -16744,7 +19043,7 @@ func (siw *ServerInterfaceWrapper) ListEvents(w http.ResponseWriter, r *http.Req r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ListEvents(w, r, projectID) + siw.Handler.DuplicateList(w, r, projectID, listID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16754,8 +19053,8 @@ func (siw *ServerInterfaceWrapper) ListEvents(w http.ResponseWriter, r *http.Req handler.ServeHTTP(w, r) } -// ListJourneys operation middleware -func (siw *ServerInterfaceWrapper) ListJourneys(w http.ResponseWriter, r *http.Request) { +// GetListUsers operation middleware +func (siw *ServerInterfaceWrapper) GetListUsers(w http.ResponseWriter, r *http.Request) { var err error @@ -16768,6 +19067,15 @@ func (siw *ServerInterfaceWrapper) ListJourneys(w http.ResponseWriter, r *http.R return } + // ------------- Path parameter "listID" ------------- + var listID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "listID", chi.URLParam(r, "listID"), &listID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "listID", Err: err}) + return + } + ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -16775,7 +19083,7 @@ func (siw *ServerInterfaceWrapper) ListJourneys(w http.ResponseWriter, r *http.R r = r.WithContext(ctx) // Parameter object where we will unmarshal all parameters from the context - var params ListJourneysParams + var params GetListUsersParams // ------------- Optional query parameter "limit" ------------- @@ -16794,7 +19102,7 @@ func (siw *ServerInterfaceWrapper) ListJourneys(w http.ResponseWriter, r *http.R } handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ListJourneys(w, r, projectID, params) + siw.Handler.GetListUsers(w, r, projectID, listID, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16804,8 +19112,8 @@ func (siw *ServerInterfaceWrapper) ListJourneys(w http.ResponseWriter, r *http.R handler.ServeHTTP(w, r) } -// CreateJourney operation middleware -func (siw *ServerInterfaceWrapper) CreateJourney(w http.ResponseWriter, r *http.Request) { +// ImportListUsers operation middleware +func (siw *ServerInterfaceWrapper) ImportListUsers(w http.ResponseWriter, r *http.Request) { var err error @@ -16818,6 +19126,15 @@ func (siw *ServerInterfaceWrapper) CreateJourney(w http.ResponseWriter, r *http. return } + // ------------- Path parameter "listID" ------------- + var listID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "listID", chi.URLParam(r, "listID"), &listID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "listID", Err: err}) + return + } + ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -16825,7 +19142,7 @@ func (siw *ServerInterfaceWrapper) CreateJourney(w http.ResponseWriter, r *http. r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.CreateJourney(w, r, projectID) + siw.Handler.ImportListUsers(w, r, projectID, listID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16835,8 +19152,8 @@ func (siw *ServerInterfaceWrapper) CreateJourney(w http.ResponseWriter, r *http. handler.ServeHTTP(w, r) } -// DeleteJourney operation middleware -func (siw *ServerInterfaceWrapper) DeleteJourney(w http.ResponseWriter, r *http.Request) { +// ListLocales operation middleware +func (siw *ServerInterfaceWrapper) ListLocales(w http.ResponseWriter, r *http.Request) { var err error @@ -16849,63 +19166,33 @@ func (siw *ServerInterfaceWrapper) DeleteJourney(w http.ResponseWriter, r *http. return } - // ------------- Path parameter "journeyID" ------------- - var journeyID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "journeyID", chi.URLParam(r, "journeyID"), &journeyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "journeyID", Err: err}) - return - } - ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) r = r.WithContext(ctx) - handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.DeleteJourney(w, r, projectID, journeyID) - })) - - for _, middleware := range siw.HandlerMiddlewares { - handler = middleware(handler) - } - - handler.ServeHTTP(w, r) -} - -// GetJourney operation middleware -func (siw *ServerInterfaceWrapper) GetJourney(w http.ResponseWriter, r *http.Request) { - - var err error + // Parameter object where we will unmarshal all parameters from the context + var params ListLocalesParams - // ------------- Path parameter "projectID" ------------- - var projectID openapi_types.UUID + // ------------- Optional query parameter "limit" ------------- - err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) return } - // ------------- Path parameter "journeyID" ------------- - var journeyID openapi_types.UUID + // ------------- Optional query parameter "offset" ------------- - err = runtime.BindStyledParameterWithOptions("simple", "journeyID", chi.URLParam(r, "journeyID"), &journeyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "journeyID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) return } - ctx := r.Context() - - ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) - - r = r.WithContext(ctx) - handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetJourney(w, r, projectID, journeyID) + siw.Handler.ListLocales(w, r, projectID, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16915,8 +19202,8 @@ func (siw *ServerInterfaceWrapper) GetJourney(w http.ResponseWriter, r *http.Req handler.ServeHTTP(w, r) } -// UpdateJourney operation middleware -func (siw *ServerInterfaceWrapper) UpdateJourney(w http.ResponseWriter, r *http.Request) { +// CreateLocale operation middleware +func (siw *ServerInterfaceWrapper) CreateLocale(w http.ResponseWriter, r *http.Request) { var err error @@ -16929,15 +19216,6 @@ func (siw *ServerInterfaceWrapper) UpdateJourney(w http.ResponseWriter, r *http. return } - // ------------- Path parameter "journeyID" ------------- - var journeyID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "journeyID", chi.URLParam(r, "journeyID"), &journeyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "journeyID", Err: err}) - return - } - ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -16945,7 +19223,7 @@ func (siw *ServerInterfaceWrapper) UpdateJourney(w http.ResponseWriter, r *http. r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.UpdateJourney(w, r, projectID, journeyID) + siw.Handler.CreateLocale(w, r, projectID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16955,8 +19233,8 @@ func (siw *ServerInterfaceWrapper) UpdateJourney(w http.ResponseWriter, r *http. handler.ServeHTTP(w, r) } -// DuplicateJourney operation middleware -func (siw *ServerInterfaceWrapper) DuplicateJourney(w http.ResponseWriter, r *http.Request) { +// DeleteLocale operation middleware +func (siw *ServerInterfaceWrapper) DeleteLocale(w http.ResponseWriter, r *http.Request) { var err error @@ -16969,12 +19247,12 @@ func (siw *ServerInterfaceWrapper) DuplicateJourney(w http.ResponseWriter, r *ht return } - // ------------- Path parameter "journeyID" ------------- - var journeyID openapi_types.UUID + // ------------- Path parameter "localeID" ------------- + var localeID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "journeyID", chi.URLParam(r, "journeyID"), &journeyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "localeID", chi.URLParam(r, "localeID"), &localeID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "journeyID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "localeID", Err: err}) return } @@ -16985,7 +19263,7 @@ func (siw *ServerInterfaceWrapper) DuplicateJourney(w http.ResponseWriter, r *ht r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.DuplicateJourney(w, r, projectID, journeyID) + siw.Handler.DeleteLocale(w, r, projectID, localeID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -16995,8 +19273,8 @@ func (siw *ServerInterfaceWrapper) DuplicateJourney(w http.ResponseWriter, r *ht handler.ServeHTTP(w, r) } -// PublishJourney operation middleware -func (siw *ServerInterfaceWrapper) PublishJourney(w http.ResponseWriter, r *http.Request) { +// GetLocale operation middleware +func (siw *ServerInterfaceWrapper) GetLocale(w http.ResponseWriter, r *http.Request) { var err error @@ -17009,12 +19287,12 @@ func (siw *ServerInterfaceWrapper) PublishJourney(w http.ResponseWriter, r *http return } - // ------------- Path parameter "journeyID" ------------- - var journeyID openapi_types.UUID + // ------------- Path parameter "localeID" ------------- + var localeID string - err = runtime.BindStyledParameterWithOptions("simple", "journeyID", chi.URLParam(r, "journeyID"), &journeyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "localeID", chi.URLParam(r, "localeID"), &localeID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "journeyID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "localeID", Err: err}) return } @@ -17025,7 +19303,7 @@ func (siw *ServerInterfaceWrapper) PublishJourney(w http.ResponseWriter, r *http r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.PublishJourney(w, r, projectID, journeyID) + siw.Handler.GetLocale(w, r, projectID, localeID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17035,8 +19313,8 @@ func (siw *ServerInterfaceWrapper) PublishJourney(w http.ResponseWriter, r *http handler.ServeHTTP(w, r) } -// GetJourneySteps operation middleware -func (siw *ServerInterfaceWrapper) GetJourneySteps(w http.ResponseWriter, r *http.Request) { +// ListProviders operation middleware +func (siw *ServerInterfaceWrapper) ListProviders(w http.ResponseWriter, r *http.Request) { var err error @@ -17049,23 +19327,33 @@ func (siw *ServerInterfaceWrapper) GetJourneySteps(w http.ResponseWriter, r *htt return } - // ------------- Path parameter "journeyID" ------------- - var journeyID openapi_types.UUID + ctx := r.Context() - err = runtime.BindStyledParameterWithOptions("simple", "journeyID", chi.URLParam(r, "journeyID"), &journeyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) + + // Parameter object where we will unmarshal all parameters from the context + var params ListProvidersParams + + // ------------- Optional query parameter "limit" ------------- + + err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "journeyID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) return } - ctx := r.Context() - - ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + // ------------- Optional query parameter "offset" ------------- - r = r.WithContext(ctx) + err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) + return + } handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetJourneySteps(w, r, projectID, journeyID) + siw.Handler.ListProviders(w, r, projectID, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17075,8 +19363,8 @@ func (siw *ServerInterfaceWrapper) GetJourneySteps(w http.ResponseWriter, r *htt handler.ServeHTTP(w, r) } -// SetJourneySteps operation middleware -func (siw *ServerInterfaceWrapper) SetJourneySteps(w http.ResponseWriter, r *http.Request) { +// ListAllProviders operation middleware +func (siw *ServerInterfaceWrapper) ListAllProviders(w http.ResponseWriter, r *http.Request) { var err error @@ -17089,15 +19377,6 @@ func (siw *ServerInterfaceWrapper) SetJourneySteps(w http.ResponseWriter, r *htt return } - // ------------- Path parameter "journeyID" ------------- - var journeyID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "journeyID", chi.URLParam(r, "journeyID"), &journeyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "journeyID", Err: err}) - return - } - ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -17105,7 +19384,7 @@ func (siw *ServerInterfaceWrapper) SetJourneySteps(w http.ResponseWriter, r *htt r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.SetJourneySteps(w, r, projectID, journeyID) + siw.Handler.ListAllProviders(w, r, projectID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17115,8 +19394,8 @@ func (siw *ServerInterfaceWrapper) SetJourneySteps(w http.ResponseWriter, r *htt handler.ServeHTTP(w, r) } -// VersionJourney operation middleware -func (siw *ServerInterfaceWrapper) VersionJourney(w http.ResponseWriter, r *http.Request) { +// ListProviderMeta operation middleware +func (siw *ServerInterfaceWrapper) ListProviderMeta(w http.ResponseWriter, r *http.Request) { var err error @@ -17129,15 +19408,6 @@ func (siw *ServerInterfaceWrapper) VersionJourney(w http.ResponseWriter, r *http return } - // ------------- Path parameter "journeyID" ------------- - var journeyID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "journeyID", chi.URLParam(r, "journeyID"), &journeyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "journeyID", Err: err}) - return - } - ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -17145,7 +19415,7 @@ func (siw *ServerInterfaceWrapper) VersionJourney(w http.ResponseWriter, r *http r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.VersionJourney(w, r, projectID, journeyID) + siw.Handler.ListProviderMeta(w, r, projectID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17155,8 +19425,8 @@ func (siw *ServerInterfaceWrapper) VersionJourney(w http.ResponseWriter, r *http handler.ServeHTTP(w, r) } -// ListApiKeys operation middleware -func (siw *ServerInterfaceWrapper) ListApiKeys(w http.ResponseWriter, r *http.Request) { +// CreateProvider operation middleware +func (siw *ServerInterfaceWrapper) CreateProvider(w http.ResponseWriter, r *http.Request) { var err error @@ -17169,33 +19439,32 @@ func (siw *ServerInterfaceWrapper) ListApiKeys(w http.ResponseWriter, r *http.Re return } - ctx := r.Context() - - ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) - - r = r.WithContext(ctx) - - // Parameter object where we will unmarshal all parameters from the context - var params ListApiKeysParams - - // ------------- Optional query parameter "limit" ------------- + // ------------- Path parameter "group" ------------- + var group string - err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) + err = runtime.BindStyledParameterWithOptions("simple", "group", chi.URLParam(r, "group"), &group, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "group", Err: err}) return } - // ------------- Optional query parameter "offset" ------------- + // ------------- Path parameter "type" ------------- + var pType string - err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) + err = runtime.BindStyledParameterWithOptions("simple", "type", chi.URLParam(r, "type"), &pType, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "type", Err: err}) return } + ctx := r.Context() + + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ListApiKeys(w, r, projectID, params) + siw.Handler.CreateProvider(w, r, projectID, group, pType) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17205,8 +19474,8 @@ func (siw *ServerInterfaceWrapper) ListApiKeys(w http.ResponseWriter, r *http.Re handler.ServeHTTP(w, r) } -// CreateApiKey operation middleware -func (siw *ServerInterfaceWrapper) CreateApiKey(w http.ResponseWriter, r *http.Request) { +// GetProvider operation middleware +func (siw *ServerInterfaceWrapper) GetProvider(w http.ResponseWriter, r *http.Request) { var err error @@ -17219,6 +19488,33 @@ func (siw *ServerInterfaceWrapper) CreateApiKey(w http.ResponseWriter, r *http.R return } + // ------------- Path parameter "group" ------------- + var group string + + err = runtime.BindStyledParameterWithOptions("simple", "group", chi.URLParam(r, "group"), &group, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "group", Err: err}) + return + } + + // ------------- Path parameter "type" ------------- + var pType string + + err = runtime.BindStyledParameterWithOptions("simple", "type", chi.URLParam(r, "type"), &pType, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "type", Err: err}) + return + } + + // ------------- Path parameter "providerID" ------------- + var providerID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "providerID", chi.URLParam(r, "providerID"), &providerID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "providerID", Err: err}) + return + } + ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -17226,7 +19522,7 @@ func (siw *ServerInterfaceWrapper) CreateApiKey(w http.ResponseWriter, r *http.R r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.CreateApiKey(w, r, projectID) + siw.Handler.GetProvider(w, r, projectID, group, pType, providerID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17236,8 +19532,8 @@ func (siw *ServerInterfaceWrapper) CreateApiKey(w http.ResponseWriter, r *http.R handler.ServeHTTP(w, r) } -// DeleteApiKey operation middleware -func (siw *ServerInterfaceWrapper) DeleteApiKey(w http.ResponseWriter, r *http.Request) { +// UpdateProvider operation middleware +func (siw *ServerInterfaceWrapper) UpdateProvider(w http.ResponseWriter, r *http.Request) { var err error @@ -17250,12 +19546,30 @@ func (siw *ServerInterfaceWrapper) DeleteApiKey(w http.ResponseWriter, r *http.R return } - // ------------- Path parameter "keyID" ------------- - var keyID openapi_types.UUID + // ------------- Path parameter "group" ------------- + var group string - err = runtime.BindStyledParameterWithOptions("simple", "keyID", chi.URLParam(r, "keyID"), &keyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "group", chi.URLParam(r, "group"), &group, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "keyID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "group", Err: err}) + return + } + + // ------------- Path parameter "type" ------------- + var pType string + + err = runtime.BindStyledParameterWithOptions("simple", "type", chi.URLParam(r, "type"), &pType, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "type", Err: err}) + return + } + + // ------------- Path parameter "providerID" ------------- + var providerID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "providerID", chi.URLParam(r, "providerID"), &providerID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "providerID", Err: err}) return } @@ -17266,7 +19580,7 @@ func (siw *ServerInterfaceWrapper) DeleteApiKey(w http.ResponseWriter, r *http.R r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.DeleteApiKey(w, r, projectID, keyID) + siw.Handler.UpdateProvider(w, r, projectID, group, pType, providerID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17276,8 +19590,8 @@ func (siw *ServerInterfaceWrapper) DeleteApiKey(w http.ResponseWriter, r *http.R handler.ServeHTTP(w, r) } -// GetApiKey operation middleware -func (siw *ServerInterfaceWrapper) GetApiKey(w http.ResponseWriter, r *http.Request) { +// DeleteProvider operation middleware +func (siw *ServerInterfaceWrapper) DeleteProvider(w http.ResponseWriter, r *http.Request) { var err error @@ -17290,12 +19604,12 @@ func (siw *ServerInterfaceWrapper) GetApiKey(w http.ResponseWriter, r *http.Requ return } - // ------------- Path parameter "keyID" ------------- - var keyID openapi_types.UUID + // ------------- Path parameter "providerID" ------------- + var providerID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "keyID", chi.URLParam(r, "keyID"), &keyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "providerID", chi.URLParam(r, "providerID"), &providerID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "keyID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "providerID", Err: err}) return } @@ -17306,7 +19620,7 @@ func (siw *ServerInterfaceWrapper) GetApiKey(w http.ResponseWriter, r *http.Requ r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetApiKey(w, r, projectID, keyID) + siw.Handler.DeleteProvider(w, r, projectID, providerID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17316,8 +19630,8 @@ func (siw *ServerInterfaceWrapper) GetApiKey(w http.ResponseWriter, r *http.Requ handler.ServeHTTP(w, r) } -// UpdateApiKey operation middleware -func (siw *ServerInterfaceWrapper) UpdateApiKey(w http.ResponseWriter, r *http.Request) { +// ListEvents operation middleware +func (siw *ServerInterfaceWrapper) ListEvents(w http.ResponseWriter, r *http.Request) { var err error @@ -17330,15 +19644,6 @@ func (siw *ServerInterfaceWrapper) UpdateApiKey(w http.ResponseWriter, r *http.R return } - // ------------- Path parameter "keyID" ------------- - var keyID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "keyID", chi.URLParam(r, "keyID"), &keyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "keyID", Err: err}) - return - } - ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -17346,7 +19651,7 @@ func (siw *ServerInterfaceWrapper) UpdateApiKey(w http.ResponseWriter, r *http.R r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.UpdateApiKey(w, r, projectID, keyID) + siw.Handler.ListEvents(w, r, projectID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17356,8 +19661,8 @@ func (siw *ServerInterfaceWrapper) UpdateApiKey(w http.ResponseWriter, r *http.R handler.ServeHTTP(w, r) } -// ListLists operation middleware -func (siw *ServerInterfaceWrapper) ListLists(w http.ResponseWriter, r *http.Request) { +// ListOrganizations operation middleware +func (siw *ServerInterfaceWrapper) ListOrganizations(w http.ResponseWriter, r *http.Request) { var err error @@ -17377,7 +19682,7 @@ func (siw *ServerInterfaceWrapper) ListLists(w http.ResponseWriter, r *http.Requ r = r.WithContext(ctx) // Parameter object where we will unmarshal all parameters from the context - var params ListListsParams + var params ListOrganizationsParams // ------------- Optional query parameter "limit" ------------- @@ -17395,39 +19700,16 @@ func (siw *ServerInterfaceWrapper) ListLists(w http.ResponseWriter, r *http.Requ return } - handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ListLists(w, r, projectID, params) - })) - - for _, middleware := range siw.HandlerMiddlewares { - handler = middleware(handler) - } - - handler.ServeHTTP(w, r) -} - -// CreateList operation middleware -func (siw *ServerInterfaceWrapper) CreateList(w http.ResponseWriter, r *http.Request) { - - var err error - - // ------------- Path parameter "projectID" ------------- - var projectID openapi_types.UUID + // ------------- Optional query parameter "search" ------------- - err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindQueryParameter("form", true, false, "search", r.URL.Query(), ¶ms.Search) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "search", Err: err}) return } - ctx := r.Context() - - ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) - - r = r.WithContext(ctx) - handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.CreateList(w, r, projectID) + siw.Handler.ListOrganizations(w, r, projectID, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17437,8 +19719,8 @@ func (siw *ServerInterfaceWrapper) CreateList(w http.ResponseWriter, r *http.Req handler.ServeHTTP(w, r) } -// DeleteList operation middleware -func (siw *ServerInterfaceWrapper) DeleteList(w http.ResponseWriter, r *http.Request) { +// UpsertOrganization operation middleware +func (siw *ServerInterfaceWrapper) UpsertOrganization(w http.ResponseWriter, r *http.Request) { var err error @@ -17451,15 +19733,6 @@ func (siw *ServerInterfaceWrapper) DeleteList(w http.ResponseWriter, r *http.Req return } - // ------------- Path parameter "listID" ------------- - var listID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "listID", chi.URLParam(r, "listID"), &listID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "listID", Err: err}) - return - } - ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -17467,7 +19740,7 @@ func (siw *ServerInterfaceWrapper) DeleteList(w http.ResponseWriter, r *http.Req r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.DeleteList(w, r, projectID, listID) + siw.Handler.UpsertOrganization(w, r, projectID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17477,8 +19750,8 @@ func (siw *ServerInterfaceWrapper) DeleteList(w http.ResponseWriter, r *http.Req handler.ServeHTTP(w, r) } -// GetList operation middleware -func (siw *ServerInterfaceWrapper) GetList(w http.ResponseWriter, r *http.Request) { +// ListOrganizationSchemas operation middleware +func (siw *ServerInterfaceWrapper) ListOrganizationSchemas(w http.ResponseWriter, r *http.Request) { var err error @@ -17491,15 +19764,6 @@ func (siw *ServerInterfaceWrapper) GetList(w http.ResponseWriter, r *http.Reques return } - // ------------- Path parameter "listID" ------------- - var listID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "listID", chi.URLParam(r, "listID"), &listID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "listID", Err: err}) - return - } - ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -17507,7 +19771,7 @@ func (siw *ServerInterfaceWrapper) GetList(w http.ResponseWriter, r *http.Reques r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetList(w, r, projectID, listID) + siw.Handler.ListOrganizationSchemas(w, r, projectID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17517,8 +19781,8 @@ func (siw *ServerInterfaceWrapper) GetList(w http.ResponseWriter, r *http.Reques handler.ServeHTTP(w, r) } -// UpdateList operation middleware -func (siw *ServerInterfaceWrapper) UpdateList(w http.ResponseWriter, r *http.Request) { +// ListOrganizationMemberSchemas operation middleware +func (siw *ServerInterfaceWrapper) ListOrganizationMemberSchemas(w http.ResponseWriter, r *http.Request) { var err error @@ -17531,15 +19795,6 @@ func (siw *ServerInterfaceWrapper) UpdateList(w http.ResponseWriter, r *http.Req return } - // ------------- Path parameter "listID" ------------- - var listID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "listID", chi.URLParam(r, "listID"), &listID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "listID", Err: err}) - return - } - ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -17547,7 +19802,7 @@ func (siw *ServerInterfaceWrapper) UpdateList(w http.ResponseWriter, r *http.Req r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.UpdateList(w, r, projectID, listID) + siw.Handler.ListOrganizationMemberSchemas(w, r, projectID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17557,8 +19812,8 @@ func (siw *ServerInterfaceWrapper) UpdateList(w http.ResponseWriter, r *http.Req handler.ServeHTTP(w, r) } -// DuplicateList operation middleware -func (siw *ServerInterfaceWrapper) DuplicateList(w http.ResponseWriter, r *http.Request) { +// DeleteOrganization operation middleware +func (siw *ServerInterfaceWrapper) DeleteOrganization(w http.ResponseWriter, r *http.Request) { var err error @@ -17571,12 +19826,12 @@ func (siw *ServerInterfaceWrapper) DuplicateList(w http.ResponseWriter, r *http. return } - // ------------- Path parameter "listID" ------------- - var listID openapi_types.UUID + // ------------- Path parameter "organizationID" ------------- + var organizationID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "listID", chi.URLParam(r, "listID"), &listID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "organizationID", chi.URLParam(r, "organizationID"), &organizationID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "listID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "organizationID", Err: err}) return } @@ -17587,7 +19842,7 @@ func (siw *ServerInterfaceWrapper) DuplicateList(w http.ResponseWriter, r *http. r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.DuplicateList(w, r, projectID, listID) + siw.Handler.DeleteOrganization(w, r, projectID, organizationID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17597,8 +19852,8 @@ func (siw *ServerInterfaceWrapper) DuplicateList(w http.ResponseWriter, r *http. handler.ServeHTTP(w, r) } -// GetListUsers operation middleware -func (siw *ServerInterfaceWrapper) GetListUsers(w http.ResponseWriter, r *http.Request) { +// GetOrganization operation middleware +func (siw *ServerInterfaceWrapper) GetOrganization(w http.ResponseWriter, r *http.Request) { var err error @@ -17611,42 +19866,23 @@ func (siw *ServerInterfaceWrapper) GetListUsers(w http.ResponseWriter, r *http.R return } - // ------------- Path parameter "listID" ------------- - var listID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "listID", chi.URLParam(r, "listID"), &listID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "listID", Err: err}) - return - } - - ctx := r.Context() - - ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) - - r = r.WithContext(ctx) - - // Parameter object where we will unmarshal all parameters from the context - var params GetListUsersParams - - // ------------- Optional query parameter "limit" ------------- + // ------------- Path parameter "organizationID" ------------- + var organizationID openapi_types.UUID - err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) + err = runtime.BindStyledParameterWithOptions("simple", "organizationID", chi.URLParam(r, "organizationID"), &organizationID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "organizationID", Err: err}) return } - // ------------- Optional query parameter "offset" ------------- - - err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) - return - } + ctx := r.Context() + + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetListUsers(w, r, projectID, listID, params) + siw.Handler.GetOrganization(w, r, projectID, organizationID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17656,8 +19892,8 @@ func (siw *ServerInterfaceWrapper) GetListUsers(w http.ResponseWriter, r *http.R handler.ServeHTTP(w, r) } -// ImportListUsers operation middleware -func (siw *ServerInterfaceWrapper) ImportListUsers(w http.ResponseWriter, r *http.Request) { +// UpdateOrganization operation middleware +func (siw *ServerInterfaceWrapper) UpdateOrganization(w http.ResponseWriter, r *http.Request) { var err error @@ -17670,12 +19906,12 @@ func (siw *ServerInterfaceWrapper) ImportListUsers(w http.ResponseWriter, r *htt return } - // ------------- Path parameter "listID" ------------- - var listID openapi_types.UUID + // ------------- Path parameter "organizationID" ------------- + var organizationID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "listID", chi.URLParam(r, "listID"), &listID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "organizationID", chi.URLParam(r, "organizationID"), &organizationID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "listID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "organizationID", Err: err}) return } @@ -17686,7 +19922,7 @@ func (siw *ServerInterfaceWrapper) ImportListUsers(w http.ResponseWriter, r *htt r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ImportListUsers(w, r, projectID, listID) + siw.Handler.UpdateOrganization(w, r, projectID, organizationID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17696,8 +19932,8 @@ func (siw *ServerInterfaceWrapper) ImportListUsers(w http.ResponseWriter, r *htt handler.ServeHTTP(w, r) } -// ListLocales operation middleware -func (siw *ServerInterfaceWrapper) ListLocales(w http.ResponseWriter, r *http.Request) { +// ListOrganizationMembers operation middleware +func (siw *ServerInterfaceWrapper) ListOrganizationMembers(w http.ResponseWriter, r *http.Request) { var err error @@ -17710,6 +19946,15 @@ func (siw *ServerInterfaceWrapper) ListLocales(w http.ResponseWriter, r *http.Re return } + // ------------- Path parameter "organizationID" ------------- + var organizationID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "organizationID", chi.URLParam(r, "organizationID"), &organizationID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "organizationID", Err: err}) + return + } + ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -17717,7 +19962,7 @@ func (siw *ServerInterfaceWrapper) ListLocales(w http.ResponseWriter, r *http.Re r = r.WithContext(ctx) // Parameter object where we will unmarshal all parameters from the context - var params ListLocalesParams + var params ListOrganizationMembersParams // ------------- Optional query parameter "limit" ------------- @@ -17736,7 +19981,7 @@ func (siw *ServerInterfaceWrapper) ListLocales(w http.ResponseWriter, r *http.Re } handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ListLocales(w, r, projectID, params) + siw.Handler.ListOrganizationMembers(w, r, projectID, organizationID, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17746,8 +19991,8 @@ func (siw *ServerInterfaceWrapper) ListLocales(w http.ResponseWriter, r *http.Re handler.ServeHTTP(w, r) } -// CreateLocale operation middleware -func (siw *ServerInterfaceWrapper) CreateLocale(w http.ResponseWriter, r *http.Request) { +// AddOrganizationMember operation middleware +func (siw *ServerInterfaceWrapper) AddOrganizationMember(w http.ResponseWriter, r *http.Request) { var err error @@ -17760,6 +20005,15 @@ func (siw *ServerInterfaceWrapper) CreateLocale(w http.ResponseWriter, r *http.R return } + // ------------- Path parameter "organizationID" ------------- + var organizationID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "organizationID", chi.URLParam(r, "organizationID"), &organizationID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "organizationID", Err: err}) + return + } + ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -17767,7 +20021,7 @@ func (siw *ServerInterfaceWrapper) CreateLocale(w http.ResponseWriter, r *http.R r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.CreateLocale(w, r, projectID) + siw.Handler.AddOrganizationMember(w, r, projectID, organizationID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17777,8 +20031,8 @@ func (siw *ServerInterfaceWrapper) CreateLocale(w http.ResponseWriter, r *http.R handler.ServeHTTP(w, r) } -// DeleteLocale operation middleware -func (siw *ServerInterfaceWrapper) DeleteLocale(w http.ResponseWriter, r *http.Request) { +// RemoveOrganizationMember operation middleware +func (siw *ServerInterfaceWrapper) RemoveOrganizationMember(w http.ResponseWriter, r *http.Request) { var err error @@ -17791,12 +20045,21 @@ func (siw *ServerInterfaceWrapper) DeleteLocale(w http.ResponseWriter, r *http.R return } - // ------------- Path parameter "localeID" ------------- - var localeID openapi_types.UUID + // ------------- Path parameter "organizationID" ------------- + var organizationID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "localeID", chi.URLParam(r, "localeID"), &localeID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "organizationID", chi.URLParam(r, "organizationID"), &organizationID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "localeID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "organizationID", Err: err}) + return + } + + // ------------- Path parameter "userID" ------------- + var userID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "userID", chi.URLParam(r, "userID"), &userID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "userID", Err: err}) return } @@ -17807,7 +20070,7 @@ func (siw *ServerInterfaceWrapper) DeleteLocale(w http.ResponseWriter, r *http.R r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.DeleteLocale(w, r, projectID, localeID) + siw.Handler.RemoveOrganizationMember(w, r, projectID, organizationID, userID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17817,8 +20080,8 @@ func (siw *ServerInterfaceWrapper) DeleteLocale(w http.ResponseWriter, r *http.R handler.ServeHTTP(w, r) } -// GetLocale operation middleware -func (siw *ServerInterfaceWrapper) GetLocale(w http.ResponseWriter, r *http.Request) { +// ListUsers operation middleware +func (siw *ServerInterfaceWrapper) ListUsers(w http.ResponseWriter, r *http.Request) { var err error @@ -17831,23 +20094,41 @@ func (siw *ServerInterfaceWrapper) GetLocale(w http.ResponseWriter, r *http.Requ return } - // ------------- Path parameter "localeID" ------------- - var localeID string + ctx := r.Context() - err = runtime.BindStyledParameterWithOptions("simple", "localeID", chi.URLParam(r, "localeID"), &localeID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) + + // Parameter object where we will unmarshal all parameters from the context + var params ListUsersParams + + // ------------- Optional query parameter "limit" ------------- + + err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "localeID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) return } - ctx := r.Context() + // ------------- Optional query parameter "offset" ------------- - ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) + return + } - r = r.WithContext(ctx) + // ------------- Optional query parameter "search" ------------- + + err = runtime.BindQueryParameter("form", true, false, "search", r.URL.Query(), ¶ms.Search) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "search", Err: err}) + return + } handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetLocale(w, r, projectID, localeID) + siw.Handler.ListUsers(w, r, projectID, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17857,8 +20138,8 @@ func (siw *ServerInterfaceWrapper) GetLocale(w http.ResponseWriter, r *http.Requ handler.ServeHTTP(w, r) } -// ListProviders operation middleware -func (siw *ServerInterfaceWrapper) ListProviders(w http.ResponseWriter, r *http.Request) { +// IdentifyUser operation middleware +func (siw *ServerInterfaceWrapper) IdentifyUser(w http.ResponseWriter, r *http.Request) { var err error @@ -17877,27 +20158,8 @@ func (siw *ServerInterfaceWrapper) ListProviders(w http.ResponseWriter, r *http. r = r.WithContext(ctx) - // Parameter object where we will unmarshal all parameters from the context - var params ListProvidersParams - - // ------------- Optional query parameter "limit" ------------- - - err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) - return - } - - // ------------- Optional query parameter "offset" ------------- - - err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) - return - } - handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ListProviders(w, r, projectID, params) + siw.Handler.IdentifyUser(w, r, projectID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17907,8 +20169,8 @@ func (siw *ServerInterfaceWrapper) ListProviders(w http.ResponseWriter, r *http. handler.ServeHTTP(w, r) } -// ListAllProviders operation middleware -func (siw *ServerInterfaceWrapper) ListAllProviders(w http.ResponseWriter, r *http.Request) { +// ImportUsers operation middleware +func (siw *ServerInterfaceWrapper) ImportUsers(w http.ResponseWriter, r *http.Request) { var err error @@ -17928,7 +20190,7 @@ func (siw *ServerInterfaceWrapper) ListAllProviders(w http.ResponseWriter, r *ht r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ListAllProviders(w, r, projectID) + siw.Handler.ImportUsers(w, r, projectID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17938,8 +20200,8 @@ func (siw *ServerInterfaceWrapper) ListAllProviders(w http.ResponseWriter, r *ht handler.ServeHTTP(w, r) } -// ListProviderMeta operation middleware -func (siw *ServerInterfaceWrapper) ListProviderMeta(w http.ResponseWriter, r *http.Request) { +// ListUserSchemas operation middleware +func (siw *ServerInterfaceWrapper) ListUserSchemas(w http.ResponseWriter, r *http.Request) { var err error @@ -17959,7 +20221,7 @@ func (siw *ServerInterfaceWrapper) ListProviderMeta(w http.ResponseWriter, r *ht r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ListProviderMeta(w, r, projectID) + siw.Handler.ListUserSchemas(w, r, projectID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -17969,8 +20231,8 @@ func (siw *ServerInterfaceWrapper) ListProviderMeta(w http.ResponseWriter, r *ht handler.ServeHTTP(w, r) } -// CreateProvider operation middleware -func (siw *ServerInterfaceWrapper) CreateProvider(w http.ResponseWriter, r *http.Request) { +// DeleteUser operation middleware +func (siw *ServerInterfaceWrapper) DeleteUser(w http.ResponseWriter, r *http.Request) { var err error @@ -17983,21 +20245,12 @@ func (siw *ServerInterfaceWrapper) CreateProvider(w http.ResponseWriter, r *http return } - // ------------- Path parameter "group" ------------- - var group string - - err = runtime.BindStyledParameterWithOptions("simple", "group", chi.URLParam(r, "group"), &group, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "group", Err: err}) - return - } - - // ------------- Path parameter "type" ------------- - var pType string + // ------------- Path parameter "userID" ------------- + var userID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "type", chi.URLParam(r, "type"), &pType, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "userID", chi.URLParam(r, "userID"), &userID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "type", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "userID", Err: err}) return } @@ -18008,7 +20261,7 @@ func (siw *ServerInterfaceWrapper) CreateProvider(w http.ResponseWriter, r *http r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.CreateProvider(w, r, projectID, group, pType) + siw.Handler.DeleteUser(w, r, projectID, userID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18018,8 +20271,8 @@ func (siw *ServerInterfaceWrapper) CreateProvider(w http.ResponseWriter, r *http handler.ServeHTTP(w, r) } -// GetProvider operation middleware -func (siw *ServerInterfaceWrapper) GetProvider(w http.ResponseWriter, r *http.Request) { +// GetUser operation middleware +func (siw *ServerInterfaceWrapper) GetUser(w http.ResponseWriter, r *http.Request) { var err error @@ -18032,30 +20285,12 @@ func (siw *ServerInterfaceWrapper) GetProvider(w http.ResponseWriter, r *http.Re return } - // ------------- Path parameter "group" ------------- - var group string - - err = runtime.BindStyledParameterWithOptions("simple", "group", chi.URLParam(r, "group"), &group, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "group", Err: err}) - return - } - - // ------------- Path parameter "type" ------------- - var pType string - - err = runtime.BindStyledParameterWithOptions("simple", "type", chi.URLParam(r, "type"), &pType, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "type", Err: err}) - return - } - - // ------------- Path parameter "providerID" ------------- - var providerID openapi_types.UUID + // ------------- Path parameter "userID" ------------- + var userID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "providerID", chi.URLParam(r, "providerID"), &providerID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "userID", chi.URLParam(r, "userID"), &userID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "providerID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "userID", Err: err}) return } @@ -18066,7 +20301,7 @@ func (siw *ServerInterfaceWrapper) GetProvider(w http.ResponseWriter, r *http.Re r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetProvider(w, r, projectID, group, pType, providerID) + siw.Handler.GetUser(w, r, projectID, userID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18076,8 +20311,8 @@ func (siw *ServerInterfaceWrapper) GetProvider(w http.ResponseWriter, r *http.Re handler.ServeHTTP(w, r) } -// UpdateProvider operation middleware -func (siw *ServerInterfaceWrapper) UpdateProvider(w http.ResponseWriter, r *http.Request) { +// UpdateUser operation middleware +func (siw *ServerInterfaceWrapper) UpdateUser(w http.ResponseWriter, r *http.Request) { var err error @@ -18090,30 +20325,12 @@ func (siw *ServerInterfaceWrapper) UpdateProvider(w http.ResponseWriter, r *http return } - // ------------- Path parameter "group" ------------- - var group string - - err = runtime.BindStyledParameterWithOptions("simple", "group", chi.URLParam(r, "group"), &group, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "group", Err: err}) - return - } - - // ------------- Path parameter "type" ------------- - var pType string - - err = runtime.BindStyledParameterWithOptions("simple", "type", chi.URLParam(r, "type"), &pType, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "type", Err: err}) - return - } - - // ------------- Path parameter "providerID" ------------- - var providerID openapi_types.UUID + // ------------- Path parameter "userID" ------------- + var userID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "providerID", chi.URLParam(r, "providerID"), &providerID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "userID", chi.URLParam(r, "userID"), &userID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "providerID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "userID", Err: err}) return } @@ -18124,7 +20341,7 @@ func (siw *ServerInterfaceWrapper) UpdateProvider(w http.ResponseWriter, r *http r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.UpdateProvider(w, r, projectID, group, pType, providerID) + siw.Handler.UpdateUser(w, r, projectID, userID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18134,8 +20351,8 @@ func (siw *ServerInterfaceWrapper) UpdateProvider(w http.ResponseWriter, r *http handler.ServeHTTP(w, r) } -// DeleteProvider operation middleware -func (siw *ServerInterfaceWrapper) DeleteProvider(w http.ResponseWriter, r *http.Request) { +// GetUserEvents operation middleware +func (siw *ServerInterfaceWrapper) GetUserEvents(w http.ResponseWriter, r *http.Request) { var err error @@ -18148,12 +20365,12 @@ func (siw *ServerInterfaceWrapper) DeleteProvider(w http.ResponseWriter, r *http return } - // ------------- Path parameter "providerID" ------------- - var providerID openapi_types.UUID + // ------------- Path parameter "userID" ------------- + var userID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "providerID", chi.URLParam(r, "providerID"), &providerID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "userID", chi.URLParam(r, "userID"), &userID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "providerID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "userID", Err: err}) return } @@ -18163,8 +20380,27 @@ func (siw *ServerInterfaceWrapper) DeleteProvider(w http.ResponseWriter, r *http r = r.WithContext(ctx) + // Parameter object where we will unmarshal all parameters from the context + var params GetUserEventsParams + + // ------------- Optional query parameter "limit" ------------- + + err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) + return + } + + // ------------- Optional query parameter "offset" ------------- + + err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) + return + } + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.DeleteProvider(w, r, projectID, providerID) + siw.Handler.GetUserEvents(w, r, projectID, userID, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18174,8 +20410,8 @@ func (siw *ServerInterfaceWrapper) DeleteProvider(w http.ResponseWriter, r *http handler.ServeHTTP(w, r) } -// ListSubscriptions operation middleware -func (siw *ServerInterfaceWrapper) ListSubscriptions(w http.ResponseWriter, r *http.Request) { +// GetUserJourneys operation middleware +func (siw *ServerInterfaceWrapper) GetUserJourneys(w http.ResponseWriter, r *http.Request) { var err error @@ -18188,6 +20424,15 @@ func (siw *ServerInterfaceWrapper) ListSubscriptions(w http.ResponseWriter, r *h return } + // ------------- Path parameter "userID" ------------- + var userID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "userID", chi.URLParam(r, "userID"), &userID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "userID", Err: err}) + return + } + ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -18195,7 +20440,7 @@ func (siw *ServerInterfaceWrapper) ListSubscriptions(w http.ResponseWriter, r *h r = r.WithContext(ctx) // Parameter object where we will unmarshal all parameters from the context - var params ListSubscriptionsParams + var params GetUserJourneysParams // ------------- Optional query parameter "limit" ------------- @@ -18214,7 +20459,7 @@ func (siw *ServerInterfaceWrapper) ListSubscriptions(w http.ResponseWriter, r *h } handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ListSubscriptions(w, r, projectID, params) + siw.Handler.GetUserJourneys(w, r, projectID, userID, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18224,8 +20469,8 @@ func (siw *ServerInterfaceWrapper) ListSubscriptions(w http.ResponseWriter, r *h handler.ServeHTTP(w, r) } -// CreateSubscription operation middleware -func (siw *ServerInterfaceWrapper) CreateSubscription(w http.ResponseWriter, r *http.Request) { +// GetUserOrganizations operation middleware +func (siw *ServerInterfaceWrapper) GetUserOrganizations(w http.ResponseWriter, r *http.Request) { var err error @@ -18238,6 +20483,15 @@ func (siw *ServerInterfaceWrapper) CreateSubscription(w http.ResponseWriter, r * return } + // ------------- Path parameter "userID" ------------- + var userID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "userID", chi.URLParam(r, "userID"), &userID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "userID", Err: err}) + return + } + ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -18245,7 +20499,7 @@ func (siw *ServerInterfaceWrapper) CreateSubscription(w http.ResponseWriter, r * r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.CreateSubscription(w, r, projectID) + siw.Handler.GetUserOrganizations(w, r, projectID, userID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18255,8 +20509,8 @@ func (siw *ServerInterfaceWrapper) CreateSubscription(w http.ResponseWriter, r * handler.ServeHTTP(w, r) } -// GetSubscription operation middleware -func (siw *ServerInterfaceWrapper) GetSubscription(w http.ResponseWriter, r *http.Request) { +// GetUserSubscriptions operation middleware +func (siw *ServerInterfaceWrapper) GetUserSubscriptions(w http.ResponseWriter, r *http.Request) { var err error @@ -18269,12 +20523,12 @@ func (siw *ServerInterfaceWrapper) GetSubscription(w http.ResponseWriter, r *htt return } - // ------------- Path parameter "subscriptionID" ------------- - var subscriptionID openapi_types.UUID + // ------------- Path parameter "userID" ------------- + var userID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "subscriptionID", chi.URLParam(r, "subscriptionID"), &subscriptionID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "userID", chi.URLParam(r, "userID"), &userID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "subscriptionID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "userID", Err: err}) return } @@ -18284,8 +20538,27 @@ func (siw *ServerInterfaceWrapper) GetSubscription(w http.ResponseWriter, r *htt r = r.WithContext(ctx) + // Parameter object where we will unmarshal all parameters from the context + var params GetUserSubscriptionsParams + + // ------------- Optional query parameter "limit" ------------- + + err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) + return + } + + // ------------- Optional query parameter "offset" ------------- + + err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) + return + } + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetSubscription(w, r, projectID, subscriptionID) + siw.Handler.GetUserSubscriptions(w, r, projectID, userID, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18295,8 +20568,8 @@ func (siw *ServerInterfaceWrapper) GetSubscription(w http.ResponseWriter, r *htt handler.ServeHTTP(w, r) } -// UpdateSubscription operation middleware -func (siw *ServerInterfaceWrapper) UpdateSubscription(w http.ResponseWriter, r *http.Request) { +// UpdateUserSubscriptions operation middleware +func (siw *ServerInterfaceWrapper) UpdateUserSubscriptions(w http.ResponseWriter, r *http.Request) { var err error @@ -18309,12 +20582,12 @@ func (siw *ServerInterfaceWrapper) UpdateSubscription(w http.ResponseWriter, r * return } - // ------------- Path parameter "subscriptionID" ------------- - var subscriptionID openapi_types.UUID + // ------------- Path parameter "userID" ------------- + var userID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "subscriptionID", chi.URLParam(r, "subscriptionID"), &subscriptionID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "userID", chi.URLParam(r, "userID"), &userID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "subscriptionID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "userID", Err: err}) return } @@ -18325,7 +20598,7 @@ func (siw *ServerInterfaceWrapper) UpdateSubscription(w http.ResponseWriter, r * r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.UpdateSubscription(w, r, projectID, subscriptionID) + siw.Handler.UpdateUserSubscriptions(w, r, projectID, userID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18335,8 +20608,8 @@ func (siw *ServerInterfaceWrapper) UpdateSubscription(w http.ResponseWriter, r * handler.ServeHTTP(w, r) } -// ListTags operation middleware -func (siw *ServerInterfaceWrapper) ListTags(w http.ResponseWriter, r *http.Request) { +// ListSubscriptions operation middleware +func (siw *ServerInterfaceWrapper) ListSubscriptions(w http.ResponseWriter, r *http.Request) { var err error @@ -18356,7 +20629,7 @@ func (siw *ServerInterfaceWrapper) ListTags(w http.ResponseWriter, r *http.Reque r = r.WithContext(ctx) // Parameter object where we will unmarshal all parameters from the context - var params ListTagsParams + var params ListSubscriptionsParams // ------------- Optional query parameter "limit" ------------- @@ -18374,47 +20647,8 @@ func (siw *ServerInterfaceWrapper) ListTags(w http.ResponseWriter, r *http.Reque return } - // ------------- Optional query parameter "search" ------------- - - err = runtime.BindQueryParameter("form", true, false, "search", r.URL.Query(), ¶ms.Search) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "search", Err: err}) - return - } - - handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ListTags(w, r, projectID, params) - })) - - for _, middleware := range siw.HandlerMiddlewares { - handler = middleware(handler) - } - - handler.ServeHTTP(w, r) -} - -// CreateTag operation middleware -func (siw *ServerInterfaceWrapper) CreateTag(w http.ResponseWriter, r *http.Request) { - - var err error - - // ------------- Path parameter "projectID" ------------- - var projectID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) - return - } - - ctx := r.Context() - - ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) - - r = r.WithContext(ctx) - handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.CreateTag(w, r, projectID) + siw.Handler.ListSubscriptions(w, r, projectID, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18424,8 +20658,8 @@ func (siw *ServerInterfaceWrapper) CreateTag(w http.ResponseWriter, r *http.Requ handler.ServeHTTP(w, r) } -// DeleteTag operation middleware -func (siw *ServerInterfaceWrapper) DeleteTag(w http.ResponseWriter, r *http.Request) { +// CreateSubscription operation middleware +func (siw *ServerInterfaceWrapper) CreateSubscription(w http.ResponseWriter, r *http.Request) { var err error @@ -18438,15 +20672,6 @@ func (siw *ServerInterfaceWrapper) DeleteTag(w http.ResponseWriter, r *http.Requ return } - // ------------- Path parameter "tagID" ------------- - var tagID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "tagID", chi.URLParam(r, "tagID"), &tagID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "tagID", Err: err}) - return - } - ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -18454,7 +20679,7 @@ func (siw *ServerInterfaceWrapper) DeleteTag(w http.ResponseWriter, r *http.Requ r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.DeleteTag(w, r, projectID, tagID) + siw.Handler.CreateSubscription(w, r, projectID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18464,8 +20689,8 @@ func (siw *ServerInterfaceWrapper) DeleteTag(w http.ResponseWriter, r *http.Requ handler.ServeHTTP(w, r) } -// GetTag operation middleware -func (siw *ServerInterfaceWrapper) GetTag(w http.ResponseWriter, r *http.Request) { +// GetSubscription operation middleware +func (siw *ServerInterfaceWrapper) GetSubscription(w http.ResponseWriter, r *http.Request) { var err error @@ -18478,12 +20703,12 @@ func (siw *ServerInterfaceWrapper) GetTag(w http.ResponseWriter, r *http.Request return } - // ------------- Path parameter "tagID" ------------- - var tagID openapi_types.UUID + // ------------- Path parameter "subscriptionID" ------------- + var subscriptionID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "tagID", chi.URLParam(r, "tagID"), &tagID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "subscriptionID", chi.URLParam(r, "subscriptionID"), &subscriptionID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "tagID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "subscriptionID", Err: err}) return } @@ -18494,7 +20719,7 @@ func (siw *ServerInterfaceWrapper) GetTag(w http.ResponseWriter, r *http.Request r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetTag(w, r, projectID, tagID) + siw.Handler.GetSubscription(w, r, projectID, subscriptionID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18504,8 +20729,8 @@ func (siw *ServerInterfaceWrapper) GetTag(w http.ResponseWriter, r *http.Request handler.ServeHTTP(w, r) } -// UpdateTag operation middleware -func (siw *ServerInterfaceWrapper) UpdateTag(w http.ResponseWriter, r *http.Request) { +// UpdateSubscription operation middleware +func (siw *ServerInterfaceWrapper) UpdateSubscription(w http.ResponseWriter, r *http.Request) { var err error @@ -18518,12 +20743,12 @@ func (siw *ServerInterfaceWrapper) UpdateTag(w http.ResponseWriter, r *http.Requ return } - // ------------- Path parameter "tagID" ------------- - var tagID openapi_types.UUID + // ------------- Path parameter "subscriptionID" ------------- + var subscriptionID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "tagID", chi.URLParam(r, "tagID"), &tagID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "subscriptionID", chi.URLParam(r, "subscriptionID"), &subscriptionID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "tagID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "subscriptionID", Err: err}) return } @@ -18534,7 +20759,7 @@ func (siw *ServerInterfaceWrapper) UpdateTag(w http.ResponseWriter, r *http.Requ r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.UpdateTag(w, r, projectID, tagID) + siw.Handler.UpdateSubscription(w, r, projectID, subscriptionID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18544,8 +20769,8 @@ func (siw *ServerInterfaceWrapper) UpdateTag(w http.ResponseWriter, r *http.Requ handler.ServeHTTP(w, r) } -// ListUsers operation middleware -func (siw *ServerInterfaceWrapper) ListUsers(w http.ResponseWriter, r *http.Request) { +// ListTags operation middleware +func (siw *ServerInterfaceWrapper) ListTags(w http.ResponseWriter, r *http.Request) { var err error @@ -18565,7 +20790,7 @@ func (siw *ServerInterfaceWrapper) ListUsers(w http.ResponseWriter, r *http.Requ r = r.WithContext(ctx) // Parameter object where we will unmarshal all parameters from the context - var params ListUsersParams + var params ListTagsParams // ------------- Optional query parameter "limit" ------------- @@ -18592,7 +20817,7 @@ func (siw *ServerInterfaceWrapper) ListUsers(w http.ResponseWriter, r *http.Requ } handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ListUsers(w, r, projectID, params) + siw.Handler.ListTags(w, r, projectID, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18602,8 +20827,8 @@ func (siw *ServerInterfaceWrapper) ListUsers(w http.ResponseWriter, r *http.Requ handler.ServeHTTP(w, r) } -// IdentifyUser operation middleware -func (siw *ServerInterfaceWrapper) IdentifyUser(w http.ResponseWriter, r *http.Request) { +// CreateTag operation middleware +func (siw *ServerInterfaceWrapper) CreateTag(w http.ResponseWriter, r *http.Request) { var err error @@ -18623,7 +20848,7 @@ func (siw *ServerInterfaceWrapper) IdentifyUser(w http.ResponseWriter, r *http.R r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.IdentifyUser(w, r, projectID) + siw.Handler.CreateTag(w, r, projectID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18633,8 +20858,8 @@ func (siw *ServerInterfaceWrapper) IdentifyUser(w http.ResponseWriter, r *http.R handler.ServeHTTP(w, r) } -// ImportUsers operation middleware -func (siw *ServerInterfaceWrapper) ImportUsers(w http.ResponseWriter, r *http.Request) { +// DeleteTag operation middleware +func (siw *ServerInterfaceWrapper) DeleteTag(w http.ResponseWriter, r *http.Request) { var err error @@ -18647,6 +20872,15 @@ func (siw *ServerInterfaceWrapper) ImportUsers(w http.ResponseWriter, r *http.Re return } + // ------------- Path parameter "tagID" ------------- + var tagID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "tagID", chi.URLParam(r, "tagID"), &tagID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "tagID", Err: err}) + return + } + ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -18654,7 +20888,7 @@ func (siw *ServerInterfaceWrapper) ImportUsers(w http.ResponseWriter, r *http.Re r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ImportUsers(w, r, projectID) + siw.Handler.DeleteTag(w, r, projectID, tagID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18664,8 +20898,8 @@ func (siw *ServerInterfaceWrapper) ImportUsers(w http.ResponseWriter, r *http.Re handler.ServeHTTP(w, r) } -// ListUserSchemas operation middleware -func (siw *ServerInterfaceWrapper) ListUserSchemas(w http.ResponseWriter, r *http.Request) { +// GetTag operation middleware +func (siw *ServerInterfaceWrapper) GetTag(w http.ResponseWriter, r *http.Request) { var err error @@ -18678,6 +20912,15 @@ func (siw *ServerInterfaceWrapper) ListUserSchemas(w http.ResponseWriter, r *htt return } + // ------------- Path parameter "tagID" ------------- + var tagID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "tagID", chi.URLParam(r, "tagID"), &tagID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "tagID", Err: err}) + return + } + ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -18685,7 +20928,7 @@ func (siw *ServerInterfaceWrapper) ListUserSchemas(w http.ResponseWriter, r *htt r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.ListUserSchemas(w, r, projectID) + siw.Handler.GetTag(w, r, projectID, tagID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18695,8 +20938,8 @@ func (siw *ServerInterfaceWrapper) ListUserSchemas(w http.ResponseWriter, r *htt handler.ServeHTTP(w, r) } -// DeleteUser operation middleware -func (siw *ServerInterfaceWrapper) DeleteUser(w http.ResponseWriter, r *http.Request) { +// UpdateTag operation middleware +func (siw *ServerInterfaceWrapper) UpdateTag(w http.ResponseWriter, r *http.Request) { var err error @@ -18709,12 +20952,12 @@ func (siw *ServerInterfaceWrapper) DeleteUser(w http.ResponseWriter, r *http.Req return } - // ------------- Path parameter "userID" ------------- - var userID openapi_types.UUID + // ------------- Path parameter "tagID" ------------- + var tagID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "userID", chi.URLParam(r, "userID"), &userID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "tagID", chi.URLParam(r, "tagID"), &tagID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "userID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "tagID", Err: err}) return } @@ -18725,7 +20968,7 @@ func (siw *ServerInterfaceWrapper) DeleteUser(w http.ResponseWriter, r *http.Req r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.DeleteUser(w, r, projectID, userID) + siw.Handler.UpdateTag(w, r, projectID, tagID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18735,28 +20978,8 @@ func (siw *ServerInterfaceWrapper) DeleteUser(w http.ResponseWriter, r *http.Req handler.ServeHTTP(w, r) } -// GetUser operation middleware -func (siw *ServerInterfaceWrapper) GetUser(w http.ResponseWriter, r *http.Request) { - - var err error - - // ------------- Path parameter "projectID" ------------- - var projectID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) - return - } - - // ------------- Path parameter "userID" ------------- - var userID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "userID", chi.URLParam(r, "userID"), &userID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "userID", Err: err}) - return - } +// DeleteTenant operation middleware +func (siw *ServerInterfaceWrapper) DeleteTenant(w http.ResponseWriter, r *http.Request) { ctx := r.Context() @@ -18765,7 +20988,7 @@ func (siw *ServerInterfaceWrapper) GetUser(w http.ResponseWriter, r *http.Reques r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetUser(w, r, projectID, userID) + siw.Handler.DeleteTenant(w, r) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18775,29 +20998,29 @@ func (siw *ServerInterfaceWrapper) GetUser(w http.ResponseWriter, r *http.Reques handler.ServeHTTP(w, r) } -// UpdateUser operation middleware -func (siw *ServerInterfaceWrapper) UpdateUser(w http.ResponseWriter, r *http.Request) { - - var err error +// GetTenant operation middleware +func (siw *ServerInterfaceWrapper) GetTenant(w http.ResponseWriter, r *http.Request) { - // ------------- Path parameter "projectID" ------------- - var projectID openapi_types.UUID + ctx := r.Context() - err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) - return - } + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) - // ------------- Path parameter "userID" ------------- - var userID openapi_types.UUID + r = r.WithContext(ctx) - err = runtime.BindStyledParameterWithOptions("simple", "userID", chi.URLParam(r, "userID"), &userID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "userID", Err: err}) - return + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetTenant(w, r) + })) + + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) } + handler.ServeHTTP(w, r) +} + +// UpdateTenant operation middleware +func (siw *ServerInterfaceWrapper) UpdateTenant(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -18805,7 +21028,7 @@ func (siw *ServerInterfaceWrapper) UpdateUser(w http.ResponseWriter, r *http.Req r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.UpdateUser(w, r, projectID, userID) + siw.Handler.UpdateTenant(w, r) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18815,29 +21038,11 @@ func (siw *ServerInterfaceWrapper) UpdateUser(w http.ResponseWriter, r *http.Req handler.ServeHTTP(w, r) } -// GetUserEvents operation middleware -func (siw *ServerInterfaceWrapper) GetUserEvents(w http.ResponseWriter, r *http.Request) { +// ListAdmins operation middleware +func (siw *ServerInterfaceWrapper) ListAdmins(w http.ResponseWriter, r *http.Request) { var err error - // ------------- Path parameter "projectID" ------------- - var projectID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) - return - } - - // ------------- Path parameter "userID" ------------- - var userID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "userID", chi.URLParam(r, "userID"), &userID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "userID", Err: err}) - return - } - ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -18845,7 +21050,7 @@ func (siw *ServerInterfaceWrapper) GetUserEvents(w http.ResponseWriter, r *http. r = r.WithContext(ctx) // Parameter object where we will unmarshal all parameters from the context - var params GetUserEventsParams + var params ListAdminsParams // ------------- Optional query parameter "limit" ------------- @@ -18863,8 +21068,16 @@ func (siw *ServerInterfaceWrapper) GetUserEvents(w http.ResponseWriter, r *http. return } + // ------------- Optional query parameter "search" ------------- + + err = runtime.BindQueryParameter("form", true, false, "search", r.URL.Query(), ¶ms.Search) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "search", Err: err}) + return + } + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetUserEvents(w, r, projectID, userID, params) + siw.Handler.ListAdmins(w, r, params) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18874,56 +21087,48 @@ func (siw *ServerInterfaceWrapper) GetUserEvents(w http.ResponseWriter, r *http. handler.ServeHTTP(w, r) } -// GetUserJourneys operation middleware -func (siw *ServerInterfaceWrapper) GetUserJourneys(w http.ResponseWriter, r *http.Request) { +// CreateAdmin operation middleware +func (siw *ServerInterfaceWrapper) CreateAdmin(w http.ResponseWriter, r *http.Request) { - var err error + ctx := r.Context() - // ------------- Path parameter "projectID" ------------- - var projectID openapi_types.UUID + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) - err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) - return - } + r = r.WithContext(ctx) - // ------------- Path parameter "userID" ------------- - var userID openapi_types.UUID + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.CreateAdmin(w, r) + })) - err = runtime.BindStyledParameterWithOptions("simple", "userID", chi.URLParam(r, "userID"), &userID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "userID", Err: err}) - return + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) } - ctx := r.Context() - - ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + handler.ServeHTTP(w, r) +} - r = r.WithContext(ctx) +// DeleteAdmin operation middleware +func (siw *ServerInterfaceWrapper) DeleteAdmin(w http.ResponseWriter, r *http.Request) { - // Parameter object where we will unmarshal all parameters from the context - var params GetUserJourneysParams + var err error - // ------------- Optional query parameter "limit" ------------- + // ------------- Path parameter "adminID" ------------- + var adminID openapi_types.UUID - err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) + err = runtime.BindStyledParameterWithOptions("simple", "adminID", chi.URLParam(r, "adminID"), &adminID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "adminID", Err: err}) return } - // ------------- Optional query parameter "offset" ------------- + ctx := r.Context() - err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) - return - } + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetUserJourneys(w, r, projectID, userID, params) + siw.Handler.DeleteAdmin(w, r, adminID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18933,26 +21138,17 @@ func (siw *ServerInterfaceWrapper) GetUserJourneys(w http.ResponseWriter, r *htt handler.ServeHTTP(w, r) } -// GetUserSubscriptions operation middleware -func (siw *ServerInterfaceWrapper) GetUserSubscriptions(w http.ResponseWriter, r *http.Request) { +// GetAdmin operation middleware +func (siw *ServerInterfaceWrapper) GetAdmin(w http.ResponseWriter, r *http.Request) { var err error - // ------------- Path parameter "projectID" ------------- - var projectID openapi_types.UUID - - err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) - return - } - - // ------------- Path parameter "userID" ------------- - var userID openapi_types.UUID + // ------------- Path parameter "adminID" ------------- + var adminID openapi_types.UUID - err = runtime.BindStyledParameterWithOptions("simple", "userID", chi.URLParam(r, "userID"), &userID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + err = runtime.BindStyledParameterWithOptions("simple", "adminID", chi.URLParam(r, "adminID"), &adminID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "userID", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "adminID", Err: err}) return } @@ -18962,27 +21158,39 @@ func (siw *ServerInterfaceWrapper) GetUserSubscriptions(w http.ResponseWriter, r r = r.WithContext(ctx) - // Parameter object where we will unmarshal all parameters from the context - var params GetUserSubscriptionsParams - - // ------------- Optional query parameter "limit" ------------- + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetAdmin(w, r, adminID) + })) - err = runtime.BindQueryParameter("form", true, false, "limit", r.URL.Query(), ¶ms.Limit) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "limit", Err: err}) - return + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) } - // ------------- Optional query parameter "offset" ------------- + handler.ServeHTTP(w, r) +} - err = runtime.BindQueryParameter("form", true, false, "offset", r.URL.Query(), ¶ms.Offset) +// UpdateAdmin operation middleware +func (siw *ServerInterfaceWrapper) UpdateAdmin(w http.ResponseWriter, r *http.Request) { + + var err error + + // ------------- Path parameter "adminID" ------------- + var adminID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "adminID", chi.URLParam(r, "adminID"), &adminID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "offset", Err: err}) + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "adminID", Err: err}) return } + ctx := r.Context() + + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.GetUserSubscriptions(w, r, projectID, userID, params) + siw.Handler.UpdateAdmin(w, r, adminID) })) for _, middleware := range siw.HandlerMiddlewares { @@ -18992,29 +21200,29 @@ func (siw *ServerInterfaceWrapper) GetUserSubscriptions(w http.ResponseWriter, r handler.ServeHTTP(w, r) } -// UpdateUserSubscriptions operation middleware -func (siw *ServerInterfaceWrapper) UpdateUserSubscriptions(w http.ResponseWriter, r *http.Request) { +// GetTenantIntegrations operation middleware +func (siw *ServerInterfaceWrapper) GetTenantIntegrations(w http.ResponseWriter, r *http.Request) { - var err error + ctx := r.Context() - // ------------- Path parameter "projectID" ------------- - var projectID openapi_types.UUID + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) - err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) - return - } + r = r.WithContext(ctx) - // ------------- Path parameter "userID" ------------- - var userID openapi_types.UUID + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.GetTenantIntegrations(w, r) + })) - err = runtime.BindStyledParameterWithOptions("simple", "userID", chi.URLParam(r, "userID"), &userID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "userID", Err: err}) - return + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) } + handler.ServeHTTP(w, r) +} + +// Whoami operation middleware +func (siw *ServerInterfaceWrapper) Whoami(w http.ResponseWriter, r *http.Request) { + ctx := r.Context() ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) @@ -19022,7 +21230,7 @@ func (siw *ServerInterfaceWrapper) UpdateUserSubscriptions(w http.ResponseWriter r = r.WithContext(ctx) handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - siw.Handler.UpdateUserSubscriptions(w, r, projectID, userID) + siw.Handler.Whoami(w, r) })) for _, middleware := range siw.HandlerMiddlewares { @@ -19209,36 +21417,6 @@ func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handl ErrorHandlerFunc: options.ErrorHandlerFunc, } - r.Group(func(r chi.Router) { - r.Delete(options.BaseURL+"/api/admin/organizations", wrapper.DeleteOrganization) - }) - r.Group(func(r chi.Router) { - r.Get(options.BaseURL+"/api/admin/organizations", wrapper.GetOrganization) - }) - r.Group(func(r chi.Router) { - r.Patch(options.BaseURL+"/api/admin/organizations", wrapper.UpdateOrganization) - }) - r.Group(func(r chi.Router) { - r.Get(options.BaseURL+"/api/admin/organizations/admins", wrapper.ListAdmins) - }) - r.Group(func(r chi.Router) { - r.Post(options.BaseURL+"/api/admin/organizations/admins", wrapper.CreateAdmin) - }) - r.Group(func(r chi.Router) { - r.Delete(options.BaseURL+"/api/admin/organizations/admins/{adminID}", wrapper.DeleteAdmin) - }) - r.Group(func(r chi.Router) { - r.Get(options.BaseURL+"/api/admin/organizations/admins/{adminID}", wrapper.GetAdmin) - }) - r.Group(func(r chi.Router) { - r.Patch(options.BaseURL+"/api/admin/organizations/admins/{adminID}", wrapper.UpdateAdmin) - }) - r.Group(func(r chi.Router) { - r.Get(options.BaseURL+"/api/admin/organizations/integrations", wrapper.GetOrganizationIntegrations) - }) - r.Group(func(r chi.Router) { - r.Get(options.BaseURL+"/api/admin/organizations/whoami", wrapper.Whoami) - }) r.Group(func(r chi.Router) { r.Get(options.BaseURL+"/api/admin/profile", wrapper.GetProfile) }) @@ -19314,9 +21492,6 @@ func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handl r.Group(func(r chi.Router) { r.Get(options.BaseURL+"/api/admin/projects/{projectID}/documents/{documentID}/metadata", wrapper.GetDocumentMetadata) }) - r.Group(func(r chi.Router) { - r.Get(options.BaseURL+"/api/admin/projects/{projectID}/events/schema", wrapper.ListEvents) - }) r.Group(func(r chi.Router) { r.Get(options.BaseURL+"/api/admin/projects/{projectID}/journeys", wrapper.ListJourneys) }) @@ -19419,6 +21594,75 @@ func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handl r.Group(func(r chi.Router) { r.Delete(options.BaseURL+"/api/admin/projects/{projectID}/providers/{providerID}", wrapper.DeleteProvider) }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/api/admin/projects/{projectID}/subjects/events/schema", wrapper.ListEvents) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/api/admin/projects/{projectID}/subjects/organizations", wrapper.ListOrganizations) + }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/api/admin/projects/{projectID}/subjects/organizations", wrapper.UpsertOrganization) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/api/admin/projects/{projectID}/subjects/organizations/schema", wrapper.ListOrganizationSchemas) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/api/admin/projects/{projectID}/subjects/organizations/users/schema", wrapper.ListOrganizationMemberSchemas) + }) + r.Group(func(r chi.Router) { + r.Delete(options.BaseURL+"/api/admin/projects/{projectID}/subjects/organizations/{organizationID}", wrapper.DeleteOrganization) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/api/admin/projects/{projectID}/subjects/organizations/{organizationID}", wrapper.GetOrganization) + }) + r.Group(func(r chi.Router) { + r.Patch(options.BaseURL+"/api/admin/projects/{projectID}/subjects/organizations/{organizationID}", wrapper.UpdateOrganization) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/api/admin/projects/{projectID}/subjects/organizations/{organizationID}/users", wrapper.ListOrganizationMembers) + }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/api/admin/projects/{projectID}/subjects/organizations/{organizationID}/users", wrapper.AddOrganizationMember) + }) + r.Group(func(r chi.Router) { + r.Delete(options.BaseURL+"/api/admin/projects/{projectID}/subjects/organizations/{organizationID}/users/{userID}", wrapper.RemoveOrganizationMember) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/api/admin/projects/{projectID}/subjects/users", wrapper.ListUsers) + }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/api/admin/projects/{projectID}/subjects/users", wrapper.IdentifyUser) + }) + r.Group(func(r chi.Router) { + r.Post(options.BaseURL+"/api/admin/projects/{projectID}/subjects/users/import", wrapper.ImportUsers) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/api/admin/projects/{projectID}/subjects/users/schema", wrapper.ListUserSchemas) + }) + r.Group(func(r chi.Router) { + r.Delete(options.BaseURL+"/api/admin/projects/{projectID}/subjects/users/{userID}", wrapper.DeleteUser) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/api/admin/projects/{projectID}/subjects/users/{userID}", wrapper.GetUser) + }) + r.Group(func(r chi.Router) { + r.Patch(options.BaseURL+"/api/admin/projects/{projectID}/subjects/users/{userID}", wrapper.UpdateUser) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/api/admin/projects/{projectID}/subjects/users/{userID}/events", wrapper.GetUserEvents) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/api/admin/projects/{projectID}/subjects/users/{userID}/journeys", wrapper.GetUserJourneys) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/api/admin/projects/{projectID}/subjects/users/{userID}/subject-organizations", wrapper.GetUserOrganizations) + }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/api/admin/projects/{projectID}/subjects/users/{userID}/subscriptions", wrapper.GetUserSubscriptions) + }) + r.Group(func(r chi.Router) { + r.Patch(options.BaseURL+"/api/admin/projects/{projectID}/subjects/users/{userID}/subscriptions", wrapper.UpdateUserSubscriptions) + }) r.Group(func(r chi.Router) { r.Get(options.BaseURL+"/api/admin/projects/{projectID}/subscriptions", wrapper.ListSubscriptions) }) @@ -19447,37 +21691,34 @@ func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handl r.Patch(options.BaseURL+"/api/admin/projects/{projectID}/tags/{tagID}", wrapper.UpdateTag) }) r.Group(func(r chi.Router) { - r.Get(options.BaseURL+"/api/admin/projects/{projectID}/users", wrapper.ListUsers) - }) - r.Group(func(r chi.Router) { - r.Post(options.BaseURL+"/api/admin/projects/{projectID}/users", wrapper.IdentifyUser) + r.Delete(options.BaseURL+"/api/admin/tenant", wrapper.DeleteTenant) }) r.Group(func(r chi.Router) { - r.Post(options.BaseURL+"/api/admin/projects/{projectID}/users/import", wrapper.ImportUsers) + r.Get(options.BaseURL+"/api/admin/tenant", wrapper.GetTenant) }) r.Group(func(r chi.Router) { - r.Get(options.BaseURL+"/api/admin/projects/{projectID}/users/schema", wrapper.ListUserSchemas) + r.Patch(options.BaseURL+"/api/admin/tenant", wrapper.UpdateTenant) }) r.Group(func(r chi.Router) { - r.Delete(options.BaseURL+"/api/admin/projects/{projectID}/users/{userID}", wrapper.DeleteUser) + r.Get(options.BaseURL+"/api/admin/tenant/admins", wrapper.ListAdmins) }) r.Group(func(r chi.Router) { - r.Get(options.BaseURL+"/api/admin/projects/{projectID}/users/{userID}", wrapper.GetUser) + r.Post(options.BaseURL+"/api/admin/tenant/admins", wrapper.CreateAdmin) }) r.Group(func(r chi.Router) { - r.Patch(options.BaseURL+"/api/admin/projects/{projectID}/users/{userID}", wrapper.UpdateUser) + r.Delete(options.BaseURL+"/api/admin/tenant/admins/{adminID}", wrapper.DeleteAdmin) }) r.Group(func(r chi.Router) { - r.Get(options.BaseURL+"/api/admin/projects/{projectID}/users/{userID}/events", wrapper.GetUserEvents) + r.Get(options.BaseURL+"/api/admin/tenant/admins/{adminID}", wrapper.GetAdmin) }) r.Group(func(r chi.Router) { - r.Get(options.BaseURL+"/api/admin/projects/{projectID}/users/{userID}/journeys", wrapper.GetUserJourneys) + r.Patch(options.BaseURL+"/api/admin/tenant/admins/{adminID}", wrapper.UpdateAdmin) }) r.Group(func(r chi.Router) { - r.Get(options.BaseURL+"/api/admin/projects/{projectID}/users/{userID}/subscriptions", wrapper.GetUserSubscriptions) + r.Get(options.BaseURL+"/api/admin/tenant/integrations", wrapper.GetTenantIntegrations) }) r.Group(func(r chi.Router) { - r.Patch(options.BaseURL+"/api/admin/projects/{projectID}/users/{userID}/subscriptions", wrapper.UpdateUserSubscriptions) + r.Get(options.BaseURL+"/api/admin/tenant/whoami", wrapper.Whoami) }) r.Group(func(r chi.Router) { r.Post(options.BaseURL+"/api/auth/login/{driver}/callback", wrapper.AuthCallback) diff --git a/internal/http/controllers/v1/management/organizations.go b/internal/http/controllers/v1/management/organizations.go index f467a171..6296579c 100644 --- a/internal/http/controllers/v1/management/organizations.go +++ b/internal/http/controllers/v1/management/organizations.go @@ -28,7 +28,7 @@ type OrganizationsController struct { store *management.State } -func (srv *OrganizationsController) GetOrganization(w http.ResponseWriter, r *http.Request) { +func (srv *OrganizationsController) GetTenant(w http.ResponseWriter, r *http.Request) { ctx := r.Context() scope := rbac.FromContext(ctx) @@ -58,7 +58,7 @@ func (srv *OrganizationsController) GetOrganization(w http.ResponseWriter, r *ht json.Write(w, http.StatusOK, organization.OAPI()) } -func (srv *OrganizationsController) UpdateOrganization(w http.ResponseWriter, r *http.Request) { +func (srv *OrganizationsController) UpdateTenant(w http.ResponseWriter, r *http.Request) { ctx := r.Context() scope := rbac.FromContext(ctx) @@ -70,7 +70,7 @@ func (srv *OrganizationsController) UpdateOrganization(w http.ResponseWriter, r logger := srv.logger.With(zap.Stringer("organization_id", scope.OrganizationID)) - body := oapi.UpdateOrganizationJSONRequestBody{} + body := oapi.UpdateTenantJSONRequestBody{} err := json.Decode(r.Body, &body) if err != nil { oapi.WriteProblem(w, err) @@ -101,7 +101,7 @@ func (srv *OrganizationsController) UpdateOrganization(w http.ResponseWriter, r json.Write(w, http.StatusOK, organization.OAPI()) } -func (srv *OrganizationsController) DeleteOrganization(w http.ResponseWriter, r *http.Request) { +func (srv *OrganizationsController) DeleteTenant(w http.ResponseWriter, r *http.Request) { ctx := r.Context() scope := rbac.FromContext(ctx) @@ -125,7 +125,7 @@ func (srv *OrganizationsController) DeleteOrganization(w http.ResponseWriter, r w.WriteHeader(http.StatusNoContent) } -func (srv *OrganizationsController) GetOrganizationIntegrations(w http.ResponseWriter, r *http.Request) { +func (srv *OrganizationsController) GetTenantIntegrations(w http.ResponseWriter, r *http.Request) { ctx := r.Context() scope := rbac.FromContext(ctx) diff --git a/internal/http/controllers/v1/management/organizations_test.go b/internal/http/controllers/v1/management/organizations_test.go index 80e7ac0e..fde7f9cf 100644 --- a/internal/http/controllers/v1/management/organizations_test.go +++ b/internal/http/controllers/v1/management/organizations_test.go @@ -16,7 +16,7 @@ import ( "go.uber.org/zap/zaptest" ) -func TestGetOrganization(t *testing.T) { +func TestGetTenant(t *testing.T) { t.Parallel() logger := zaptest.NewLogger(t) @@ -53,19 +53,19 @@ func TestGetOrganization(t *testing.T) { for name, test := range tests { t.Run(name, func(t *testing.T) { res := httptest.NewRecorder() - req := httptest.NewRequest("GET", "/api/admin/organizations", nil) + req := httptest.NewRequest("GET", "/api/admin/tenant", nil) claimAdmin := &rbac.Scope{ OrganizationID: admin.OrganizationID, } req = req.WithContext(rbac.WithScope(req.Context(), claimAdmin)) - organizations.GetOrganization(res, req) + organizations.GetTenant(res, req) require.Equal(t, test.code, res.Code, res.Body.String()) if res.Code == http.StatusOK { - var org oapi.Organization + var org oapi.Tenant err := json.NewDecoder(res.Body).Decode(&org) require.NoError(t, err) require.Equal(t, orgID, org.Id) @@ -75,7 +75,7 @@ func TestGetOrganization(t *testing.T) { } } -func TestUpdateOrganization(t *testing.T) { +func TestUpdateTenant(t *testing.T) { t.Parallel() logger := zaptest.NewLogger(t) @@ -100,19 +100,19 @@ func TestUpdateOrganization(t *testing.T) { organizations := NewOrganizationsController(logger, mgmt) type test struct { - body oapi.UpdateOrganizationJSONRequestBody + body oapi.UpdateTenantJSONRequestBody code int } tests := map[string]test{ "success with tracking url": { - body: oapi.UpdateOrganizationJSONRequestBody{ + body: oapi.UpdateTenantJSONRequestBody{ TrackingDeeplinkMirrorUrl: ptr("https://example.com/track"), }, code: http.StatusOK, }, "success with empty body": { - body: oapi.UpdateOrganizationJSONRequestBody{}, + body: oapi.UpdateTenantJSONRequestBody{}, code: http.StatusOK, }, } @@ -123,19 +123,19 @@ func TestUpdateOrganization(t *testing.T) { require.NoError(t, err) res := httptest.NewRecorder() - req := httptest.NewRequest("PATCH", "/api/admin/organizations", bytes.NewReader(bb)) + req := httptest.NewRequest("PATCH", "/api/admin/tenant", bytes.NewReader(bb)) claimAdmin := &rbac.Scope{ OrganizationID: admin.OrganizationID, } req = req.WithContext(rbac.WithScope(req.Context(), claimAdmin)) - organizations.UpdateOrganization(res, req) + organizations.UpdateTenant(res, req) require.Equal(t, test.code, res.Code, res.Body.String()) if res.Code == http.StatusOK { - var org oapi.Organization + var org oapi.Tenant err := json.NewDecoder(res.Body).Decode(&org) require.NoError(t, err) require.Equal(t, orgID, org.Id) @@ -149,7 +149,7 @@ func TestUpdateOrganization(t *testing.T) { } } -func TestDeleteOrganization(t *testing.T) { +func TestDeleteTenant(t *testing.T) { t.Parallel() logger := zaptest.NewLogger(t) @@ -186,14 +186,14 @@ func TestDeleteOrganization(t *testing.T) { for name, test := range tests { t.Run(name, func(t *testing.T) { res := httptest.NewRecorder() - req := httptest.NewRequest("DELETE", "/api/admin/organizations", nil) + req := httptest.NewRequest("DELETE", "/api/admin/tenant", nil) claimAdmin := &rbac.Scope{ OrganizationID: admin.OrganizationID, } req = req.WithContext(rbac.WithScope(req.Context(), claimAdmin)) - organizations.DeleteOrganization(res, req) + organizations.DeleteTenant(res, req) require.Equal(t, test.code, res.Code, res.Body.String()) @@ -207,7 +207,7 @@ func TestDeleteOrganization(t *testing.T) { } } -func TestGetOrganizationIntegrations(t *testing.T) { +func TestGetTenantIntegrations(t *testing.T) { t.Parallel() logger := zaptest.NewLogger(t) @@ -267,14 +267,14 @@ func TestGetOrganizationIntegrations(t *testing.T) { for name, test := range tests { t.Run(name, func(t *testing.T) { res := httptest.NewRecorder() - req := httptest.NewRequest("GET", "/api/admin/organizations/integrations", nil) + req := httptest.NewRequest("GET", "/api/admin/tenant/integrations", nil) claimAdmin := &rbac.Scope{ OrganizationID: admin.OrganizationID, } req = req.WithContext(rbac.WithScope(req.Context(), claimAdmin)) - organizations.GetOrganizationIntegrations(res, req) + organizations.GetTenantIntegrations(res, req) require.Equal(t, test.code, res.Code, res.Body.String()) diff --git a/internal/http/controllers/v1/management/subject_organizations.go b/internal/http/controllers/v1/management/subject_organizations.go new file mode 100644 index 00000000..8b707c91 --- /dev/null +++ b/internal/http/controllers/v1/management/subject_organizations.go @@ -0,0 +1,564 @@ +package v1 + +import ( + "database/sql" + "errors" + "net/http" + + "github.com/google/uuid" + "github.com/jmoiron/sqlx" + "github.com/lunogram/platform/internal/claim" + "github.com/lunogram/platform/internal/http/controllers/v1/management/oapi" + "github.com/lunogram/platform/internal/http/json" + "github.com/lunogram/platform/internal/http/problem" + "github.com/lunogram/platform/internal/pubsub" + "github.com/lunogram/platform/internal/pubsub/schemas" + "github.com/lunogram/platform/internal/store" + "github.com/lunogram/platform/internal/store/subjects" + "go.uber.org/zap" +) + +func NewSubjectOrganizationsController(logger *zap.Logger, db *sqlx.DB, pub pubsub.Publisher) *SubjectOrganizationsController { + return &SubjectOrganizationsController{ + logger: logger, + db: db, + orgs: subjects.NewState(db), + pubsub: pub, + } +} + +type SubjectOrganizationsController struct { + logger *zap.Logger + db *sqlx.DB + orgs *subjects.State + pubsub pubsub.Publisher +} + +func (srv *SubjectOrganizationsController) ListOrganizations(w http.ResponseWriter, r *http.Request, projectID uuid.UUID, params oapi.ListOrganizationsParams) { + ctx := r.Context() + _, ok := claim.FromContext(ctx) + if !ok { + srv.logger.Error("session not found in context") + oapi.WriteProblem(w, problem.ErrUnauthorized(problem.Describe("unauthorized"))) + return + } + + logger := srv.logger.With(zap.String("project_id", projectID.String())) + + pagination := store.Pagination{ + Limit: params.Limit.ToInt(), + Offset: params.Offset.ToInt(), + } + + logger.Info("listing subject organizations", zap.Int("limit", pagination.Limit), zap.Int("offset", pagination.Offset)) + + orgs, total, err := srv.orgs.ListOrganizations(ctx, projectID, pagination) + if err != nil { + logger.Error("failed to list organizations", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + logger.Info("organizations listed", zap.Int("total", total), zap.Int("count", len(orgs))) + + response := oapi.OrganizationList{ + Results: orgs.OAPI(), + Total: total, + Limit: pagination.Limit, + Offset: pagination.Offset, + } + + json.Write(w, http.StatusOK, response) +} + +func (srv *SubjectOrganizationsController) UpsertOrganization(w http.ResponseWriter, r *http.Request, projectID uuid.UUID) { + ctx := r.Context() + _, ok := claim.FromContext(ctx) + if !ok { + srv.logger.Error("session not found in context") + oapi.WriteProblem(w, problem.ErrUnauthorized(problem.Describe("unauthorized"))) + return + } + + body := oapi.UpsertOrganization{} + err := json.Decode(r.Body, &body) + if err != nil { + srv.logger.Error("failed to decode request body", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrBadRequest(problem.Describe("invalid request body"))) + return + } + + logger := srv.logger.With( + zap.String("project_id", projectID.String()), + zap.String("external_id", body.ExternalId), + ) + + logger.Info("upserting subject organization") + + var data map[string]any + if body.Data != nil { + data = *body.Data + } + + tx, err := srv.db.BeginTxx(ctx, nil) + if err != nil { + logger.Error("failed to begin transaction", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + defer tx.Rollback() //nolint:errcheck + orgsStore := subjects.NewOrganizationsStore(tx) + + params := subjects.UpsertOrganizationParams{ + ExternalID: body.ExternalId, + Name: body.Name, + Data: data, + } + + orgID, err := orgsStore.UpsertOrganization(ctx, projectID, params) + if err != nil { + logger.Error("failed to upsert organization", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + org, err := orgsStore.GetOrganization(ctx, projectID, orgID) + if err != nil { + logger.Error("failed to get organization after upsert", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + // Publish to pubsub for schema extraction + msg := schemas.Organization{ + ID: org.ID, + ProjectID: projectID, + ExternalID: org.ExternalID, + Name: org.Name, + Data: data, + Version: org.Version, + } + + err = srv.pubsub.Publish(ctx, schemas.OrganizationsProcess(projectID), msg) + if err != nil { + logger.Error("failed to publish organization", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + err = tx.Commit() + if err != nil { + logger.Error("failed to commit transaction", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + logger.Info("organization upserted", zap.String("organization_id", org.ID.String())) + json.Write(w, http.StatusOK, org.OAPI()) +} + +func (srv *SubjectOrganizationsController) GetOrganization(w http.ResponseWriter, r *http.Request, projectID, organizationID uuid.UUID) { + ctx := r.Context() + _, ok := claim.FromContext(ctx) + if !ok { + srv.logger.Error("session not found in context") + oapi.WriteProblem(w, problem.ErrUnauthorized(problem.Describe("unauthorized"))) + return + } + + logger := srv.logger.With( + zap.String("project_id", projectID.String()), + zap.String("organization_id", organizationID.String()), + ) + + logger.Info("getting subject organization") + + org, err := srv.orgs.GetOrganization(ctx, projectID, organizationID) + if errors.Is(err, sql.ErrNoRows) { + logger.Info("organization not found") + oapi.WriteProblem(w, problem.ErrNotFound(problem.Describe("organization not found"))) + return + } + + if err != nil { + logger.Error("failed to get organization", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + logger.Info("organization retrieved") + json.Write(w, http.StatusOK, org.OAPI()) +} + +func (srv *SubjectOrganizationsController) UpdateOrganization(w http.ResponseWriter, r *http.Request, projectID, organizationID uuid.UUID) { + ctx := r.Context() + _, ok := claim.FromContext(ctx) + if !ok { + srv.logger.Error("session not found in context") + oapi.WriteProblem(w, problem.ErrUnauthorized(problem.Describe("unauthorized"))) + return + } + + _, err := srv.orgs.GetOrganization(ctx, projectID, organizationID) + if errors.Is(err, sql.ErrNoRows) { + srv.logger.Info("organization not found") + oapi.WriteProblem(w, problem.ErrNotFound(problem.Describe("organization not found"))) + return + } + + if err != nil { + srv.logger.Error("failed to get organization", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + body := oapi.UpdateOrganization{} + err = json.Decode(r.Body, &body) + if err != nil { + srv.logger.Error("failed to decode request body", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrBadRequest(problem.Describe("invalid request body"))) + return + } + + logger := srv.logger.With( + zap.String("project_id", projectID.String()), + zap.String("organization_id", organizationID.String()), + ) + + logger.Info("updating subject organization") + + update := subjects.OrganizationUpdate{ + Name: body.Name, + Data: body.Data, + } + + err = srv.orgs.UpdateOrganization(ctx, projectID, organizationID, update) + if err != nil { + logger.Error("failed to update organization", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + updatedOrg, err := srv.orgs.GetOrganization(ctx, projectID, organizationID) + if err != nil { + logger.Error("failed to get updated organization", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + logger.Info("organization updated") + json.Write(w, http.StatusOK, updatedOrg.OAPI()) +} + +func (srv *SubjectOrganizationsController) DeleteOrganization(w http.ResponseWriter, r *http.Request, projectID, organizationID uuid.UUID) { + ctx := r.Context() + _, ok := claim.FromContext(ctx) + if !ok { + srv.logger.Error("session not found in context") + oapi.WriteProblem(w, problem.ErrUnauthorized(problem.Describe("unauthorized"))) + return + } + + _, err := srv.orgs.GetOrganization(ctx, projectID, organizationID) + if errors.Is(err, sql.ErrNoRows) { + srv.logger.Info("organization not found") + oapi.WriteProblem(w, problem.ErrNotFound(problem.Describe("organization not found"))) + return + } + + if err != nil { + srv.logger.Error("failed to get organization", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + logger := srv.logger.With( + zap.String("project_id", projectID.String()), + zap.String("organization_id", organizationID.String()), + ) + + logger.Info("deleting subject organization") + + err = srv.orgs.DeleteOrganization(ctx, projectID, organizationID) + if err != nil { + logger.Error("failed to delete organization", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + logger.Info("organization deleted") + w.WriteHeader(http.StatusNoContent) +} + +func (srv *SubjectOrganizationsController) ListOrganizationMembers(w http.ResponseWriter, r *http.Request, projectID, organizationID uuid.UUID, params oapi.ListOrganizationMembersParams) { + ctx := r.Context() + _, ok := claim.FromContext(ctx) + if !ok { + srv.logger.Error("session not found in context") + oapi.WriteProblem(w, problem.ErrUnauthorized(problem.Describe("unauthorized"))) + return + } + + _, err := srv.orgs.GetOrganization(ctx, projectID, organizationID) + if errors.Is(err, sql.ErrNoRows) { + srv.logger.Info("organization not found") + oapi.WriteProblem(w, problem.ErrNotFound(problem.Describe("organization not found"))) + return + } + + if err != nil { + srv.logger.Error("failed to get organization", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + logger := srv.logger.With( + zap.String("project_id", projectID.String()), + zap.String("organization_id", organizationID.String()), + ) + + pagination := store.Pagination{ + Limit: params.Limit.ToInt(), + Offset: params.Offset.ToInt(), + } + + logger.Info("listing organization users", zap.Int("limit", pagination.Limit), zap.Int("offset", pagination.Offset)) + + members, total, err := srv.orgs.ListOrganizationMembers(ctx, projectID, organizationID, pagination) + if err != nil { + logger.Error("failed to list organization members", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + logger.Info("organization users listed", zap.Int("total", total), zap.Int("count", len(members))) + + response := oapi.OrganizationMemberList{ + Results: members.OAPI(), + Total: total, + Limit: pagination.Limit, + Offset: pagination.Offset, + } + + json.Write(w, http.StatusOK, response) +} + +func (srv *SubjectOrganizationsController) AddOrganizationMember(w http.ResponseWriter, r *http.Request, projectID, organizationID uuid.UUID) { + ctx := r.Context() + _, ok := claim.FromContext(ctx) + if !ok { + srv.logger.Error("session not found in context") + oapi.WriteProblem(w, problem.ErrUnauthorized(problem.Describe("unauthorized"))) + return + } + + org, err := srv.orgs.GetOrganization(ctx, projectID, organizationID) + if errors.Is(err, sql.ErrNoRows) { + srv.logger.Info("organization not found") + oapi.WriteProblem(w, problem.ErrNotFound(problem.Describe("organization not found"))) + return + } + + if err != nil { + srv.logger.Error("failed to get organization", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + body := oapi.AddOrganizationMember{} + err = json.Decode(r.Body, &body) + if err != nil { + srv.logger.Error("failed to decode request body", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrBadRequest(problem.Describe("invalid request body"))) + return + } + + logger := srv.logger.With( + zap.String("project_id", projectID.String()), + zap.String("organization_id", organizationID.String()), + zap.String("user_id", body.UserId.String()), + ) + + logger.Info("adding user to organization") + + // Verify user exists + _, err = srv.orgs.GetUser(ctx, projectID, body.UserId) + if errors.Is(err, sql.ErrNoRows) { + logger.Info("user not found") + oapi.WriteProblem(w, problem.ErrNotFound(problem.Describe("user not found"))) + return + } + + if err != nil { + logger.Error("failed to get user", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + var data map[string]any + if body.Data != nil { + data = *body.Data + } + + tx, err := srv.db.BeginTxx(ctx, nil) + if err != nil { + logger.Error("failed to begin transaction", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + defer tx.Rollback() //nolint:errcheck + orgsStore := subjects.NewOrganizationsStore(tx) + + err = orgsStore.UpsertOrganizationMember(ctx, organizationID, body.UserId, data) + if err != nil { + logger.Error("failed to add user to organization", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + // Publish to pubsub for schema extraction + msg := schemas.OrganizationUser{ + OrganizationID: organizationID, + OrganizationExternalID: org.ExternalID, + UserID: body.UserId, + ProjectID: projectID, + Data: data, + Version: 1, + } + + err = srv.pubsub.Publish(ctx, schemas.OrganizationUsersProcess(projectID), msg) + if err != nil { + logger.Error("failed to publish organization user", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + err = tx.Commit() + if err != nil { + logger.Error("failed to commit transaction", zap.Error(err)) + oapi.WriteProblem(w, problem.ErrInternal()) + return + } + + logger.Info("user added to organization") + w.WriteHeader(http.StatusOK) +} + +func (srv *SubjectOrganizationsController) RemoveOrganizationMember(w http.ResponseWriter, r *http.Request, projectID, organizationID, userID uuid.UUID) { + ctx := r.Context() + _, ok := claim.FromContext(ctx) + if !ok { + srv.logger.Error("session not found in context") + oapi.WriteProblem(w, problem.ErrUnauthorized(problem.Describe("unauthorized"))) + return + } + + _, err := srv.orgs.GetOrganization(ctx, projectID, organizationID) + if errors.Is(err, sql.ErrNoRows) { + srv.logger.Info("organization not found") + oapi.WriteProblem(w, problem.ErrNotFound(problem.Describe("organization not found"))) + return + } + + if err != nil { + srv.logger.Error("failed to get organization", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + logger := srv.logger.With( + zap.String("project_id", projectID.String()), + zap.String("organization_id", organizationID.String()), + zap.String("user_id", userID.String()), + ) + + logger.Info("removing user from organization") + + err = srv.orgs.RemoveUserFromOrganization(ctx, organizationID, userID) + if err != nil { + logger.Error("failed to remove user from organization", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + logger.Info("user removed from organization") + w.WriteHeader(http.StatusNoContent) +} + +func (srv *SubjectOrganizationsController) ListOrganizationSchemas(w http.ResponseWriter, r *http.Request, projectID uuid.UUID) { + ctx := r.Context() + _, ok := claim.FromContext(ctx) + if !ok { + srv.logger.Error("session not found in context") + oapi.WriteProblem(w, problem.ErrUnauthorized(problem.Describe("unauthorized"))) + return + } + + logger := srv.logger.With(zap.String("project_id", projectID.String())) + logger.Info("listing organization schemas") + + schemas, err := srv.orgs.ListOrganizationSchemas(ctx, projectID) + if err != nil { + logger.Error("failed to list organization schemas", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + logger.Info("organization schemas listed", zap.Int("count", len(schemas))) + + results := make([]oapi.SchemaPath, len(schemas)) + for i, schema := range schemas { + results[i] = oapi.SchemaPath{ + Path: schema.Path, + Types: []string(schema.Types), + } + } + + response := struct { + Results []oapi.SchemaPath `json:"results"` + }{ + Results: results, + } + + json.Write(w, http.StatusOK, response) +} + +func (srv *SubjectOrganizationsController) ListOrganizationMemberSchemas(w http.ResponseWriter, r *http.Request, projectID uuid.UUID) { + ctx := r.Context() + _, ok := claim.FromContext(ctx) + if !ok { + srv.logger.Error("session not found in context") + oapi.WriteProblem(w, problem.ErrUnauthorized(problem.Describe("unauthorized"))) + return + } + + logger := srv.logger.With(zap.String("project_id", projectID.String())) + logger.Info("listing organization user schemas") + + schemas, err := srv.orgs.ListOrganizationUserSchemas(ctx, projectID) + if err != nil { + logger.Error("failed to list organization user schemas", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + logger.Info("organization user schemas listed", zap.Int("count", len(schemas))) + + results := make([]oapi.SchemaPath, len(schemas)) + for i, schema := range schemas { + results[i] = oapi.SchemaPath{ + Path: schema.Path, + Types: []string(schema.Types), + } + } + + response := struct { + Results []oapi.SchemaPath `json:"results"` + }{ + Results: results, + } + + json.Write(w, http.StatusOK, response) +} diff --git a/internal/http/controllers/v1/management/users.go b/internal/http/controllers/v1/management/users.go index 84994d88..c98f95d3 100644 --- a/internal/http/controllers/v1/management/users.go +++ b/internal/http/controllers/v1/management/users.go @@ -671,3 +671,50 @@ func (srv *UsersController) processUserImport(ctx context.Context, logger *zap.L logger.Info("import completed", zap.Int("users_imported", imported)) return tx.Commit() } + +func (srv *UsersController) GetUserOrganizations(w http.ResponseWriter, r *http.Request, projectID, userID uuid.UUID) { + ctx := r.Context() + _, ok := claim.FromContext(ctx) + if !ok { + srv.logger.Error("session not found in context") + oapi.WriteProblem(w, problem.ErrUnauthorized(problem.Describe("unauthorized"))) + return + } + + _, err := srv.users.GetUser(ctx, projectID, userID) + if errors.Is(err, sql.ErrNoRows) { + srv.logger.Info("user not found") + oapi.WriteProblem(w, problem.ErrNotFound(problem.Describe("user not found"))) + return + } + + if err != nil { + srv.logger.Error("failed to get user", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + logger := srv.logger.With( + zap.String("project_id", projectID.String()), + zap.String("user_id", userID.String()), + ) + + logger.Info("listing user organizations") + + orgs, err := srv.users.ListUserOrganizations(ctx, projectID, userID) + if err != nil { + logger.Error("failed to list user organizations", zap.Error(err)) + oapi.WriteProblem(w, err) + return + } + + logger.Info("user organizations listed", zap.Int("count", len(orgs))) + + response := struct { + Results []oapi.Organization `json:"results"` + }{ + Results: subjects.Organizations(orgs).OAPI(), + } + + json.Write(w, http.StatusOK, response) +} diff --git a/internal/store/management/organizations.go b/internal/store/management/organizations.go index 7a3408ff..e0588d6d 100644 --- a/internal/store/management/organizations.go +++ b/internal/store/management/organizations.go @@ -18,8 +18,8 @@ type Organization struct { UpdatedAt time.Time `db:"updated_at"` } -func (o *Organization) OAPI() oapi.Organization { - return oapi.Organization{ +func (o *Organization) OAPI() oapi.Tenant { + return oapi.Tenant{ Id: o.ID, Name: o.Name, TrackingDeeplinkMirrorUrl: o.TrackingDeeplinkMirrorURL, diff --git a/internal/store/subjects/organizations.go b/internal/store/subjects/organizations.go index 122070f8..9b67ec3d 100644 --- a/internal/store/subjects/organizations.go +++ b/internal/store/subjects/organizations.go @@ -9,6 +9,7 @@ import ( "github.com/google/uuid" "github.com/jmoiron/sqlx" "github.com/lib/pq" + "github.com/lunogram/platform/internal/http/controllers/v1/management/oapi" "github.com/lunogram/platform/internal/rules" "github.com/lunogram/platform/internal/rules/query" "github.com/lunogram/platform/internal/store" @@ -16,6 +17,14 @@ import ( type Organizations []Organization +func (o Organizations) OAPI() []oapi.Organization { + results := make([]oapi.Organization, len(o)) + for i, org := range o { + results[i] = org.OAPI() + } + return results +} + type Organization struct { ID uuid.UUID `db:"id"` ProjectID uuid.UUID `db:"project_id"` @@ -27,6 +36,19 @@ type Organization struct { UpdatedAt time.Time `db:"updated_at"` } +func (o *Organization) OAPI() oapi.Organization { + return oapi.Organization{ + Id: o.ID, + ProjectId: o.ProjectID, + ExternalId: o.ExternalID, + Name: o.Name, + Data: o.Data, + Version: o.Version, + CreatedAt: o.CreatedAt, + UpdatedAt: o.UpdatedAt, + } +} + func NewOrganizationsStore(db store.DB) *OrganizationsStore { return &OrganizationsStore{db: db} } @@ -213,8 +235,39 @@ type OrganizationMember struct { OrganizationData json.RawMessage `db:"org_data"` } +func (m *OrganizationMember) OAPI() oapi.OrganizationMember { + anonID := "" + if m.AnonymousID != nil { + anonID = *m.AnonymousID + } + return oapi.OrganizationMember{ + Id: m.ID, + ProjectId: m.ProjectID, + AnonymousId: anonID, + ExternalId: m.ExternalID, + Email: m.Email, + Phone: m.Phone, + Data: m.Data, + Timezone: m.Timezone, + Locale: m.Locale, + HasPushDevice: m.HasPushDevice, + Version: m.Version, + CreatedAt: m.CreatedAt, + UpdatedAt: m.UpdatedAt, + OrganizationData: m.OrganizationData, + } +} + type OrganizationMembers []OrganizationMember +func (m OrganizationMembers) OAPI() []oapi.OrganizationMember { + results := make([]oapi.OrganizationMember, len(m)) + for i, member := range m { + results[i] = member.OAPI() + } + return results +} + // ListOrganizationMembers lists all users belonging to an organization with pagination. func (s *OrganizationsStore) ListOrganizationMembers(ctx context.Context, projectID, orgID uuid.UUID, pagination store.Pagination) (OrganizationMembers, int, error) { query := ` From 002db1bd80a35abf17899e3d0fc9e506423049de Mon Sep 17 00:00:00 2001 From: Jeroen Rinzema Date: Sun, 22 Feb 2026 15:12:32 +0100 Subject: [PATCH 013/230] fix: updated api implementation to reflect new endpoints --- console/src/api.ts | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/console/src/api.ts b/console/src/api.ts index efa73a82..8ced0ad3 100644 --- a/console/src/api.ts +++ b/console/src/api.ts @@ -215,10 +215,10 @@ const api = { }, admins: { - ...createEntityPath("/admin/organizations/admins"), + ...createEntityPath("/admin/tenant/admins"), whoami: async () => await client - .get("/admin/organizations/whoami") + .get("/admin/tenant/whoami") .then((r) => r.data), }, @@ -230,7 +230,7 @@ const api = { .then((r) => r.data), pathSuggestions: async (projectId: UUID) => { let eventSuggestions = await client - .get<{ results: VariableSuggestions['eventPaths'] }>(`${projectUrl(projectId)}/events/schema`) + .get<{ results: VariableSuggestions['eventPaths'] }>(`${projectUrl(projectId)}/subjects/events/schema`) .then((r) => r.data.results); eventSuggestions = eventSuggestions.map((event) => { @@ -246,7 +246,7 @@ const api = { }) const userSuggestions = await client - .get<{ results: VariableSuggestions['userPaths'] }>(`${projectUrl(projectId)}/users/schema`) + .get<{ results: VariableSuggestions['userPaths'] }>(`${projectUrl(projectId)}/subjects/users/schema`) .then((r) => r.data.results); return { @@ -449,18 +449,18 @@ const api = { }, users: { - ...createProjectEntityPath("users"), + ...createProjectEntityPath("subjects/users"), lists: async (projectId: UUID, userId: UUID, params: SearchParams) => await client .get< SearchResult - >(`${projectUrl(projectId)}/users/${userId}/lists`, { params }) + >(`${projectUrl(projectId)}/subjects/users/${userId}/lists`, { params }) .then((r) => r.data), events: async (projectId: UUID, userId: UUID, params: SearchParams) => await client .get< SearchResult - >(`${projectUrl(projectId)}/users/${userId}/events`, { params }) + >(`${projectUrl(projectId)}/subjects/users/${userId}/events`, { params }) .then((r) => r.data), subscriptions: async ( projectId: UUID, @@ -470,7 +470,7 @@ const api = { await client .get< SearchResult - >(`${projectUrl(projectId)}/users/${userId}/subscriptions`, { params }) + >(`${projectUrl(projectId)}/subjects/users/${userId}/subscriptions`, { params }) .then((r) => r.data), updateSubscriptions: async ( projectId: UUID, @@ -479,19 +479,19 @@ const api = { ) => await client .patch( - `${projectUrl(projectId)}/users/${userId}/subscriptions`, + `${projectUrl(projectId)}/subjects/users/${userId}/subscriptions`, subscriptions, ) .then((r) => r.data), addImport: async (projectId: UUID, file: File) => { const formData = new FormData(); formData.append("file", file); - await client.post(`${projectUrl(projectId)}/users/import`, formData); + await client.post(`${projectUrl(projectId)}/subjects/users/import`, formData); }, deleteImport: async (projectId: UUID, file: File) => { const formData = new FormData(); formData.append("file", file); - await client.post(`${projectUrl(projectId)}/users/bulk/delete`, formData); + await client.post(`${projectUrl(projectId)}/subjects/users/bulk/delete`, formData); }, journeys: { @@ -499,7 +499,7 @@ const api = { await client .get< SearchResult - >(`${projectUrl(projectId)}/users/${userId}/journeys`, { params }) + >(`${projectUrl(projectId)}/subjects/users/${userId}/journeys`, { params }) .then((r) => r.data), }, }, @@ -663,17 +663,17 @@ const api = { .then((r) => r.data), }, - organizations: { + tenant: { get: async () => await client - .get("/admin/organizations") + .get("/admin/tenant") .then((r) => r.data), update: async (id: UUID, params: OrganizationUpdateParams) => await client - .patch(`/admin/organizations/${id}`, params) + .patch(`/admin/tenant`, params) .then((r) => r.data), delete: async () => - await client.delete("/admin/organizations").then((r) => r.data), + await client.delete("/admin/tenant").then((r) => r.data), }, locales: { From 119f259e9be674415c2bbcb0ee664475bba3eee2 Mon Sep 17 00:00:00 2001 From: Jeroen Rinzema Date: Sun, 22 Feb 2026 15:31:26 +0100 Subject: [PATCH 014/230] chore: removed unused variables --- console/src/api.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/console/src/api.ts b/console/src/api.ts index 8ced0ad3..a16f77da 100644 --- a/console/src/api.ts +++ b/console/src/api.ts @@ -40,8 +40,6 @@ import type { Tag, Template, TemplateCreateParams, - TemplatePreviewParams, - TemplateProofParams, TemplateUpdateParams, User, UserEvent, From 5605ccab1b61acdae1494783a34611c6bcac304f Mon Sep 17 00:00:00 2001 From: Jeroen Rinzema Date: Sun, 22 Feb 2026 22:56:18 +0100 Subject: [PATCH 015/230] feat: add test coverage for client and management organization endpoints --- console/src/api.ts | 80 +- console/src/types.ts | 86 +- .../http/controllers/v1/client/client_test.go | 920 ++++++++++++++ .../controllers/v1/client/oapi/resources.yml | 62 +- .../v1/client/oapi/resources_gen.go | 8 +- .../v1/management/oapi/resources.yml | 1 - .../v1/management/oapi/resources_gen.go | 27 - .../management/subject_organizations_test.go | 1109 +++++++++++++++++ 8 files changed, 2187 insertions(+), 106 deletions(-) create mode 100644 internal/http/controllers/v1/management/subject_organizations_test.go diff --git a/console/src/api.ts b/console/src/api.ts index a16f77da..a3fb7568 100644 --- a/console/src/api.ts +++ b/console/src/api.ts @@ -36,6 +36,11 @@ import type { Subscription, SubscriptionCreateParams, SubscriptionParams, + SubjectOrganization, + SubjectOrganizationCreateParams, + SubjectOrganizationMember, + SubjectOrganizationMemberParams, + SubjectOrganizationUpdateParams, SubscriptionUpdateParams, Tag, Template, @@ -215,9 +220,7 @@ const api = { admins: { ...createEntityPath("/admin/tenant/admins"), whoami: async () => - await client - .get("/admin/tenant/whoami") - .then((r) => r.data), + await client.get("/admin/tenant/whoami").then((r) => r.data), }, projects: { @@ -228,7 +231,9 @@ const api = { .then((r) => r.data), pathSuggestions: async (projectId: UUID) => { let eventSuggestions = await client - .get<{ results: VariableSuggestions['eventPaths'] }>(`${projectUrl(projectId)}/subjects/events/schema`) + .get<{ + results: VariableSuggestions["eventPaths"]; + }>(`${projectUrl(projectId)}/subjects/events/schema`) .then((r) => r.data.results); eventSuggestions = eventSuggestions.map((event) => { @@ -236,22 +241,24 @@ const api = { event.schema = event.schema.map((schemaPath) => { return { ...schemaPath, - path: `.data${schemaPath.path}` - } - }) + path: `.data${schemaPath.path}`, + }; + }); return event; - }) + }); const userSuggestions = await client - .get<{ results: VariableSuggestions['userPaths'] }>(`${projectUrl(projectId)}/subjects/users/schema`) + .get<{ + results: VariableSuggestions["userPaths"]; + }>(`${projectUrl(projectId)}/subjects/users/schema`) .then((r) => r.data.results); return { eventPaths: eventSuggestions, userPaths: userSuggestions, - } - } + }; + }, }, data: { @@ -484,12 +491,18 @@ const api = { addImport: async (projectId: UUID, file: File) => { const formData = new FormData(); formData.append("file", file); - await client.post(`${projectUrl(projectId)}/subjects/users/import`, formData); + await client.post( + `${projectUrl(projectId)}/subjects/users/import`, + formData, + ); }, deleteImport: async (projectId: UUID, file: File) => { const formData = new FormData(); formData.append("file", file); - await client.post(`${projectUrl(projectId)}/subjects/users/bulk/delete`, formData); + await client.post( + `${projectUrl(projectId)}/subjects/users/bulk/delete`, + formData, + ); }, journeys: { @@ -502,6 +515,43 @@ const api = { }, }, + organizations: { + ...createProjectEntityPath< + SubjectOrganization, + SubjectOrganizationCreateParams, + SubjectOrganizationUpdateParams + >("subjects/organizations"), + members: { + search: async ( + projectId: UUID, + organizationId: UUID, + params: SearchParams, + ) => + await client + .get< + SearchResult + >(`${projectUrl(projectId)}/subjects/organizations/${organizationId}/members`, { params }) + .then((r) => r.data), + add: async ( + projectId: UUID, + organizationId: UUID, + params: SubjectOrganizationMemberParams, + ) => + await client + .post( + `${projectUrl(projectId)}/subjects/organizations/${organizationId}/members`, + params, + ) + .then((r) => r.data), + remove: async (projectId: UUID, organizationId: UUID, userId: UUID) => + await client + .delete( + `${projectUrl(projectId)}/subjects/organizations/${organizationId}/members/${userId}`, + ) + .then((r) => r.data), + }, + }, + lists: { ...createProjectEntityPath( "lists", @@ -663,9 +713,7 @@ const api = { tenant: { get: async () => - await client - .get("/admin/tenant") - .then((r) => r.data), + await client.get("/admin/tenant").then((r) => r.data), update: async (id: UUID, params: OrganizationUpdateParams) => await client .patch(`/admin/tenant`, params) diff --git a/console/src/types.ts b/console/src/types.ts index 3c412bb7..5aacb98b 100644 --- a/console/src/types.ts +++ b/console/src/types.ts @@ -27,8 +27,10 @@ export interface CommonInputProps { export type ControlledInputProps = ControlledProps & CommonInputProps; -export interface FieldProps> - extends CommonInputProps { +export interface FieldProps< + X extends FieldValues, + P extends FieldPath, +> extends CommonInputProps { form: UseFormReturn; name: P; } @@ -102,13 +104,13 @@ export type Rule = { operator: Operator; value?: string; } & ( - | { type: "wrapper" } - | { type: "string" } - | { type: "number" } - | { type: "boolean" } - | { type: "date" } - | { type: "array" } - ); + | { type: "wrapper" } + | { type: "string" } + | { type: "number" } + | { type: "boolean" } + | { type: "date" } + | { type: "array" } +); export function defaultOperator(type: RuleType): Operator { switch (type) { @@ -169,15 +171,15 @@ export type WrapperRule = Rule & { type: "wrapper"; children: Rule[] }; export type EventRulePeriod = | { - type: "rolling"; - unit: "minute" | "hour" | "day" | "week" | "month"; - value: number; - } + type: "rolling"; + unit: "minute" | "hour" | "day" | "week" | "month"; + value: number; + } | { - type: "fixed"; - start_date: string; - end_date?: string; - }; + type: "fixed"; + start_date: string; + end_date?: string; + }; export interface EventRuleFrequency { period: EventRulePeriod; @@ -353,6 +355,40 @@ export interface User { created_at?: Date; } +export interface SubjectOrganization { + id: UUID; + project_id: UUID; + external_id: string; + name?: string; + data: Record; + version: number; + created_at: string; + updated_at: string; +} + +export type SubjectOrganizationCreateParams = Pick< + SubjectOrganization, + "external_id" | "name" | "data" +>; +export type SubjectOrganizationUpdateParams = Pick< + SubjectOrganization, + "name" | "data" +>; + +export interface SubjectOrganizationMember { + user_id: UUID; + organization_id: UUID; + data: Record; + created_at: string; + updated_at: string; + user?: User; +} + +export type SubjectOrganizationMemberParams = Pick< + SubjectOrganizationMember, + "data" +> & { user_id: UUID }; + export interface Device { device_id: string; token?: string; @@ -389,12 +425,12 @@ export type List = { created_at: string; updated_at: string; } & ( - | { + | { type: "dynamic"; rule: WrapperRule; } - | { type: "static" } - ); + | { type: "static" } +); export type DynamicList = List & { type: "dynamic" }; @@ -633,23 +669,23 @@ export type Template = { created_at: string; updated_at: string; } & ( - | { + | { type: "email"; data: EmailTemplateData; } - | { + | { type: "text"; data: TextTemplateData; } - | { + | { type: "push"; data: PushTemplateData; } - | { + | { type: "webhook"; data: WebhookTemplateData; } - ); +); export type TemplateCreateParams = Pick; export type TemplateUpdateParams = Pick; diff --git a/internal/http/controllers/v1/client/client_test.go b/internal/http/controllers/v1/client/client_test.go index a2918d99..cb652ca6 100644 --- a/internal/http/controllers/v1/client/client_test.go +++ b/internal/http/controllers/v1/client/client_test.go @@ -641,3 +641,923 @@ func TestClientIdentifyUserWithBothIdentifiers(t *testing.T) { require.NoError(t, err) assert.NotEmpty(t, response["id"]) } + +func TestUpsertOrganizationClient(t *testing.T) { + t.Parallel() + + type test struct { + body map[string]any + statusCode int + } + + tests := map[string]test{ + "create organization with all fields": { + body: map[string]any{ + "external_id": "org_123", + "name": "Acme Corp", + "data": map[string]any{ + "industry": "technology", + "size": "enterprise", + }, + }, + statusCode: 200, + }, + "create organization with minimal data": { + body: map[string]any{ + "external_id": "org_456", + }, + statusCode: 200, + }, + "create organization with name only": { + body: map[string]any{ + "external_id": "org_789", + "name": "Simple Corp", + }, + statusCode: 200, + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + orgID, err := controller.mgmt.OrganizationsStore.CreateOrganization(t.Context(), "Test Org") + require.NoError(t, err) + + projectID, err := controller.mgmt.ProjectsStore.CreateProject(t.Context(), management.Project{ + OrganizationID: &orgID, + Name: "Test Project", + Timezone: "UTC", + Locale: "en", + }) + require.NoError(t, err) + + body, err := json.Marshal(tc.body) + require.NoError(t, err) + + req := httptest.NewRequest("POST", "/api/client/organizations", bytes.NewReader(body)) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(rbac.WithScope(req.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + w := httptest.NewRecorder() + + controller.UpsertOrganizationClient(w, req) + + assert.Equal(t, tc.statusCode, w.Code) + if w.Code == 200 { + var response map[string]any + err = json.Unmarshal(w.Body.Bytes(), &response) + require.NoError(t, err) + assert.NotEmpty(t, response["id"]) + assert.Equal(t, tc.body["external_id"], response["external_id"]) + } + }) + } +} + +func TestUpsertOrganizationClientUpdate(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + orgID, err := controller.mgmt.OrganizationsStore.CreateOrganization(t.Context(), "Test Org") + require.NoError(t, err) + + projectID, err := controller.mgmt.ProjectsStore.CreateProject(t.Context(), management.Project{ + OrganizationID: &orgID, + Name: "Test Project", + Timezone: "UTC", + Locale: "en", + }) + require.NoError(t, err) + + // First upsert - create + body1, err := json.Marshal(map[string]any{ + "external_id": "org_123", + "name": "Original Name", + "data": map[string]any{ + "plan": "basic", + }, + }) + require.NoError(t, err) + + req1 := httptest.NewRequest("POST", "/api/client/organizations", bytes.NewReader(body1)) + req1.Header.Set("Content-Type", "application/json") + req1 = req1.WithContext(rbac.WithScope(req1.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + w1 := httptest.NewRecorder() + + controller.UpsertOrganizationClient(w1, req1) + assert.Equal(t, 200, w1.Code) + + var response1 map[string]any + err = json.Unmarshal(w1.Body.Bytes(), &response1) + require.NoError(t, err) + orgInternalID := response1["id"] + + // Second upsert - update + body2, err := json.Marshal(map[string]any{ + "external_id": "org_123", + "name": "Updated Name", + "data": map[string]any{ + "plan": "enterprise", + }, + }) + require.NoError(t, err) + + req2 := httptest.NewRequest("POST", "/api/client/organizations", bytes.NewReader(body2)) + req2.Header.Set("Content-Type", "application/json") + req2 = req2.WithContext(rbac.WithScope(req2.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + w2 := httptest.NewRecorder() + + controller.UpsertOrganizationClient(w2, req2) + assert.Equal(t, 200, w2.Code) + + var response2 map[string]any + err = json.Unmarshal(w2.Body.Bytes(), &response2) + require.NoError(t, err) + + assert.Equal(t, orgInternalID, response2["id"]) + assert.Equal(t, "Updated Name", response2["name"]) +} + +func TestUpsertOrganizationClientMissingRBACScope(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + body, err := json.Marshal(map[string]any{ + "external_id": "org_123", + "name": "Test Org", + }) + require.NoError(t, err) + + req := httptest.NewRequest("POST", "/api/client/organizations", bytes.NewReader(body)) + req.Header.Set("Content-Type", "application/json") + w := httptest.NewRecorder() + + controller.UpsertOrganizationClient(w, req) + + assert.Equal(t, 401, w.Code) +} + +func TestUpsertOrganizationClientMissingProjectID(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + orgID, err := controller.mgmt.OrganizationsStore.CreateOrganization(t.Context(), "Test Org") + require.NoError(t, err) + + body, err := json.Marshal(map[string]any{ + "external_id": "org_123", + "name": "Test Org", + }) + require.NoError(t, err) + + req := httptest.NewRequest("POST", "/api/client/organizations", bytes.NewReader(body)) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(rbac.WithScope(req.Context(), &rbac.Scope{ + OrganizationID: orgID, + })) + w := httptest.NewRecorder() + + controller.UpsertOrganizationClient(w, req) + + assert.Equal(t, 401, w.Code) +} + +func TestUpsertOrganizationClientInvalidRequest(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + orgID, err := controller.mgmt.OrganizationsStore.CreateOrganization(t.Context(), "Test Org") + require.NoError(t, err) + + projectID, err := controller.mgmt.ProjectsStore.CreateProject(t.Context(), management.Project{ + OrganizationID: &orgID, + Name: "Test Project", + Timezone: "UTC", + Locale: "en", + }) + require.NoError(t, err) + + req := httptest.NewRequest("POST", "/api/client/organizations", bytes.NewReader([]byte("invalid json"))) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(rbac.WithScope(req.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + w := httptest.NewRecorder() + + controller.UpsertOrganizationClient(w, req) + + assert.Equal(t, 400, w.Code) +} + +func TestAddOrganizationUserClient(t *testing.T) { + t.Parallel() + + type test struct { + body map[string]any + statusCode int + } + + tests := map[string]test{ + "add user with data": { + body: map[string]any{ + "organization_external_id": "org_123", + "user_external_id": "user_456", + "data": map[string]any{ + "role": "admin", + "department": "engineering", + }, + }, + statusCode: 200, + }, + "add user without data": { + body: map[string]any{ + "organization_external_id": "org_123", + "user_external_id": "user_789", + }, + statusCode: 200, + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + orgID, err := controller.mgmt.OrganizationsStore.CreateOrganization(t.Context(), "Test Org") + require.NoError(t, err) + + projectID, err := controller.mgmt.ProjectsStore.CreateProject(t.Context(), management.Project{ + OrganizationID: &orgID, + Name: "Test Project", + Timezone: "UTC", + Locale: "en", + }) + require.NoError(t, err) + + // Create the subject organization first + orgBody, err := json.Marshal(map[string]any{ + "external_id": "org_123", + "name": "Test Subject Org", + }) + require.NoError(t, err) + + orgReq := httptest.NewRequest("POST", "/api/client/organizations", bytes.NewReader(orgBody)) + orgReq.Header.Set("Content-Type", "application/json") + orgReq = orgReq.WithContext(rbac.WithScope(orgReq.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + orgW := httptest.NewRecorder() + controller.UpsertOrganizationClient(orgW, orgReq) + require.Equal(t, 200, orgW.Code) + + // Create the user + userExternalID := tc.body["user_external_id"].(string) + userBody, err := json.Marshal(map[string]any{ + "external_id": userExternalID, + "email": userExternalID + "@example.com", + }) + require.NoError(t, err) + + userReq := httptest.NewRequest("POST", "/api/client/identify", bytes.NewReader(userBody)) + userReq.Header.Set("Content-Type", "application/json") + userReq = userReq.WithContext(rbac.WithScope(userReq.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + userW := httptest.NewRecorder() + controller.IdentifyUserClient(userW, userReq) + require.Equal(t, 200, userW.Code) + + // Add user to organization + body, err := json.Marshal(tc.body) + require.NoError(t, err) + + req := httptest.NewRequest("POST", "/api/client/organizations/users", bytes.NewReader(body)) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(rbac.WithScope(req.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + w := httptest.NewRecorder() + + controller.AddOrganizationUserClient(w, req) + + assert.Equal(t, tc.statusCode, w.Code) + }) + } +} + +func TestAddOrganizationUserClientOrganizationNotFound(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + orgID, err := controller.mgmt.OrganizationsStore.CreateOrganization(t.Context(), "Test Org") + require.NoError(t, err) + + projectID, err := controller.mgmt.ProjectsStore.CreateProject(t.Context(), management.Project{ + OrganizationID: &orgID, + Name: "Test Project", + Timezone: "UTC", + Locale: "en", + }) + require.NoError(t, err) + + body, err := json.Marshal(map[string]any{ + "organization_external_id": "nonexistent_org", + "user_external_id": "user_123", + }) + require.NoError(t, err) + + req := httptest.NewRequest("POST", "/api/client/organizations/users", bytes.NewReader(body)) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(rbac.WithScope(req.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + w := httptest.NewRecorder() + + controller.AddOrganizationUserClient(w, req) + + assert.Equal(t, 404, w.Code) +} + +func TestAddOrganizationUserClientUserNotFound(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + orgID, err := controller.mgmt.OrganizationsStore.CreateOrganization(t.Context(), "Test Org") + require.NoError(t, err) + + projectID, err := controller.mgmt.ProjectsStore.CreateProject(t.Context(), management.Project{ + OrganizationID: &orgID, + Name: "Test Project", + Timezone: "UTC", + Locale: "en", + }) + require.NoError(t, err) + + // Create the subject organization first + orgBody, err := json.Marshal(map[string]any{ + "external_id": "org_123", + "name": "Test Subject Org", + }) + require.NoError(t, err) + + orgReq := httptest.NewRequest("POST", "/api/client/organizations", bytes.NewReader(orgBody)) + orgReq.Header.Set("Content-Type", "application/json") + orgReq = orgReq.WithContext(rbac.WithScope(orgReq.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + orgW := httptest.NewRecorder() + controller.UpsertOrganizationClient(orgW, orgReq) + require.Equal(t, 200, orgW.Code) + + body, err := json.Marshal(map[string]any{ + "organization_external_id": "org_123", + "user_external_id": "nonexistent_user", + }) + require.NoError(t, err) + + req := httptest.NewRequest("POST", "/api/client/organizations/users", bytes.NewReader(body)) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(rbac.WithScope(req.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + w := httptest.NewRecorder() + + controller.AddOrganizationUserClient(w, req) + + assert.Equal(t, 404, w.Code) +} + +func TestAddOrganizationUserClientMissingRBACScope(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + body, err := json.Marshal(map[string]any{ + "organization_external_id": "org_123", + "user_external_id": "user_456", + }) + require.NoError(t, err) + + req := httptest.NewRequest("POST", "/api/client/organizations/users", bytes.NewReader(body)) + req.Header.Set("Content-Type", "application/json") + w := httptest.NewRecorder() + + controller.AddOrganizationUserClient(w, req) + + assert.Equal(t, 401, w.Code) +} + +func TestRemoveOrganizationUserClient(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + orgID, err := controller.mgmt.OrganizationsStore.CreateOrganization(t.Context(), "Test Org") + require.NoError(t, err) + + projectID, err := controller.mgmt.ProjectsStore.CreateProject(t.Context(), management.Project{ + OrganizationID: &orgID, + Name: "Test Project", + Timezone: "UTC", + Locale: "en", + }) + require.NoError(t, err) + + // Create the subject organization + orgBody, err := json.Marshal(map[string]any{ + "external_id": "org_123", + "name": "Test Subject Org", + }) + require.NoError(t, err) + + orgReq := httptest.NewRequest("POST", "/api/client/organizations", bytes.NewReader(orgBody)) + orgReq.Header.Set("Content-Type", "application/json") + orgReq = orgReq.WithContext(rbac.WithScope(orgReq.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + orgW := httptest.NewRecorder() + controller.UpsertOrganizationClient(orgW, orgReq) + require.Equal(t, 200, orgW.Code) + + // Create the user + userBody, err := json.Marshal(map[string]any{ + "external_id": "user_456", + "email": "user@example.com", + }) + require.NoError(t, err) + + userReq := httptest.NewRequest("POST", "/api/client/identify", bytes.NewReader(userBody)) + userReq.Header.Set("Content-Type", "application/json") + userReq = userReq.WithContext(rbac.WithScope(userReq.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + userW := httptest.NewRecorder() + controller.IdentifyUserClient(userW, userReq) + require.Equal(t, 200, userW.Code) + + // Add user to organization + addBody, err := json.Marshal(map[string]any{ + "organization_external_id": "org_123", + "user_external_id": "user_456", + }) + require.NoError(t, err) + + addReq := httptest.NewRequest("POST", "/api/client/organizations/users", bytes.NewReader(addBody)) + addReq.Header.Set("Content-Type", "application/json") + addReq = addReq.WithContext(rbac.WithScope(addReq.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + addW := httptest.NewRecorder() + controller.AddOrganizationUserClient(addW, addReq) + require.Equal(t, 200, addW.Code) + + // Remove user from organization + removeBody, err := json.Marshal(map[string]any{ + "organization_external_id": "org_123", + "user_external_id": "user_456", + }) + require.NoError(t, err) + + removeReq := httptest.NewRequest("DELETE", "/api/client/organizations/users", bytes.NewReader(removeBody)) + removeReq.Header.Set("Content-Type", "application/json") + removeReq = removeReq.WithContext(rbac.WithScope(removeReq.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + removeW := httptest.NewRecorder() + + controller.RemoveOrganizationUserClient(removeW, removeReq) + + assert.Equal(t, 204, removeW.Code) +} + +func TestRemoveOrganizationUserClientOrganizationNotFound(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + orgID, err := controller.mgmt.OrganizationsStore.CreateOrganization(t.Context(), "Test Org") + require.NoError(t, err) + + projectID, err := controller.mgmt.ProjectsStore.CreateProject(t.Context(), management.Project{ + OrganizationID: &orgID, + Name: "Test Project", + Timezone: "UTC", + Locale: "en", + }) + require.NoError(t, err) + + body, err := json.Marshal(map[string]any{ + "organization_external_id": "nonexistent_org", + "user_external_id": "user_123", + }) + require.NoError(t, err) + + req := httptest.NewRequest("DELETE", "/api/client/organizations/users", bytes.NewReader(body)) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(rbac.WithScope(req.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + w := httptest.NewRecorder() + + controller.RemoveOrganizationUserClient(w, req) + + assert.Equal(t, 404, w.Code) +} + +func TestRemoveOrganizationUserClientUserNotFound(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + orgID, err := controller.mgmt.OrganizationsStore.CreateOrganization(t.Context(), "Test Org") + require.NoError(t, err) + + projectID, err := controller.mgmt.ProjectsStore.CreateProject(t.Context(), management.Project{ + OrganizationID: &orgID, + Name: "Test Project", + Timezone: "UTC", + Locale: "en", + }) + require.NoError(t, err) + + // Create the subject organization + orgBody, err := json.Marshal(map[string]any{ + "external_id": "org_123", + "name": "Test Subject Org", + }) + require.NoError(t, err) + + orgReq := httptest.NewRequest("POST", "/api/client/organizations", bytes.NewReader(orgBody)) + orgReq.Header.Set("Content-Type", "application/json") + orgReq = orgReq.WithContext(rbac.WithScope(orgReq.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + orgW := httptest.NewRecorder() + controller.UpsertOrganizationClient(orgW, orgReq) + require.Equal(t, 200, orgW.Code) + + body, err := json.Marshal(map[string]any{ + "organization_external_id": "org_123", + "user_external_id": "nonexistent_user", + }) + require.NoError(t, err) + + req := httptest.NewRequest("DELETE", "/api/client/organizations/users", bytes.NewReader(body)) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(rbac.WithScope(req.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + w := httptest.NewRecorder() + + controller.RemoveOrganizationUserClient(w, req) + + assert.Equal(t, 404, w.Code) +} + +func TestRemoveOrganizationUserClientMissingRBACScope(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + body, err := json.Marshal(map[string]any{ + "organization_external_id": "org_123", + "user_external_id": "user_456", + }) + require.NoError(t, err) + + req := httptest.NewRequest("DELETE", "/api/client/organizations/users", bytes.NewReader(body)) + req.Header.Set("Content-Type", "application/json") + w := httptest.NewRecorder() + + controller.RemoveOrganizationUserClient(w, req) + + assert.Equal(t, 401, w.Code) +} + +func TestPostOrganizationEventsClient(t *testing.T) { + t.Parallel() + + type test struct { + events []map[string]any + statusCode int + } + + tests := map[string]test{ + "single event with data": { + events: []map[string]any{ + { + "organization_external_id": "org_123", + "name": "subscription_upgraded", + "data": map[string]any{ + "plan": "enterprise", + "seats": 100, + }, + }, + }, + statusCode: 202, + }, + "single event without data": { + events: []map[string]any{ + { + "organization_external_id": "org_123", + "name": "account_activated", + }, + }, + statusCode: 202, + }, + "multiple events": { + events: []map[string]any{ + { + "organization_external_id": "org_123", + "name": "feature_enabled", + "data": map[string]any{ + "feature": "advanced_analytics", + }, + }, + { + "organization_external_id": "org_123", + "name": "user_invited", + "data": map[string]any{ + "invitee_email": "new@example.com", + }, + }, + }, + statusCode: 202, + }, + } + + for name, tc := range tests { + t.Run(name, func(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + orgID, err := controller.mgmt.OrganizationsStore.CreateOrganization(t.Context(), "Test Org") + require.NoError(t, err) + + projectID, err := controller.mgmt.ProjectsStore.CreateProject(t.Context(), management.Project{ + OrganizationID: &orgID, + Name: "Test Project", + Timezone: "UTC", + Locale: "en", + }) + require.NoError(t, err) + + // Create the subject organization first + orgBody, err := json.Marshal(map[string]any{ + "external_id": "org_123", + "name": "Test Subject Org", + }) + require.NoError(t, err) + + orgReq := httptest.NewRequest("POST", "/api/client/organizations", bytes.NewReader(orgBody)) + orgReq.Header.Set("Content-Type", "application/json") + orgReq = orgReq.WithContext(rbac.WithScope(orgReq.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + orgW := httptest.NewRecorder() + controller.UpsertOrganizationClient(orgW, orgReq) + require.Equal(t, 200, orgW.Code) + + // Post organization events + body, err := json.Marshal(tc.events) + require.NoError(t, err) + + req := httptest.NewRequest("POST", "/api/client/organizations/events", bytes.NewReader(body)) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(rbac.WithScope(req.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + w := httptest.NewRecorder() + + controller.PostOrganizationEventsClient(w, req) + + assert.Equal(t, tc.statusCode, w.Code) + }) + } +} + +func TestPostOrganizationEventsClientNonexistentOrg(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + orgID, err := controller.mgmt.OrganizationsStore.CreateOrganization(t.Context(), "Test Org") + require.NoError(t, err) + + projectID, err := controller.mgmt.ProjectsStore.CreateProject(t.Context(), management.Project{ + OrganizationID: &orgID, + Name: "Test Project", + Timezone: "UTC", + Locale: "en", + }) + require.NoError(t, err) + + events := []map[string]any{ + { + "organization_external_id": "nonexistent_org", + "name": "test_event", + }, + } + + body, err := json.Marshal(events) + require.NoError(t, err) + + req := httptest.NewRequest("POST", "/api/client/organizations/events", bytes.NewReader(body)) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(rbac.WithScope(req.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + w := httptest.NewRecorder() + + controller.PostOrganizationEventsClient(w, req) + + // Events for nonexistent orgs are skipped, not rejected + assert.Equal(t, 202, w.Code) +} + +func TestPostOrganizationEventsClientMissingRBACScope(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + events := []map[string]any{ + { + "organization_external_id": "org_123", + "name": "test_event", + }, + } + + body, err := json.Marshal(events) + require.NoError(t, err) + + req := httptest.NewRequest("POST", "/api/client/organizations/events", bytes.NewReader(body)) + req.Header.Set("Content-Type", "application/json") + w := httptest.NewRecorder() + + controller.PostOrganizationEventsClient(w, req) + + assert.Equal(t, 401, w.Code) +} + +func TestPostOrganizationEventsClientMissingProjectID(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + orgID, err := controller.mgmt.OrganizationsStore.CreateOrganization(t.Context(), "Test Org") + require.NoError(t, err) + + events := []map[string]any{ + { + "organization_external_id": "org_123", + "name": "test_event", + }, + } + + body, err := json.Marshal(events) + require.NoError(t, err) + + req := httptest.NewRequest("POST", "/api/client/organizations/events", bytes.NewReader(body)) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(rbac.WithScope(req.Context(), &rbac.Scope{ + OrganizationID: orgID, + })) + w := httptest.NewRecorder() + + controller.PostOrganizationEventsClient(w, req) + + assert.Equal(t, 401, w.Code) +} + +func TestPostOrganizationEventsClientInvalidRequest(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + orgID, err := controller.mgmt.OrganizationsStore.CreateOrganization(t.Context(), "Test Org") + require.NoError(t, err) + + projectID, err := controller.mgmt.ProjectsStore.CreateProject(t.Context(), management.Project{ + OrganizationID: &orgID, + Name: "Test Project", + Timezone: "UTC", + Locale: "en", + }) + require.NoError(t, err) + + req := httptest.NewRequest("POST", "/api/client/organizations/events", bytes.NewReader([]byte("invalid json"))) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(rbac.WithScope(req.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + w := httptest.NewRecorder() + + controller.PostOrganizationEventsClient(w, req) + + assert.Equal(t, 400, w.Code) +} + +func TestPostOrganizationEventsClientWithNestedData(t *testing.T) { + t.Parallel() + + controller := setupClientController(t) + + orgID, err := controller.mgmt.OrganizationsStore.CreateOrganization(t.Context(), "Test Org") + require.NoError(t, err) + + projectID, err := controller.mgmt.ProjectsStore.CreateProject(t.Context(), management.Project{ + OrganizationID: &orgID, + Name: "Test Project", + Timezone: "UTC", + Locale: "en", + }) + require.NoError(t, err) + + // Create the subject organization first + orgBody, err := json.Marshal(map[string]any{ + "external_id": "org_123", + "name": "Test Subject Org", + }) + require.NoError(t, err) + + orgReq := httptest.NewRequest("POST", "/api/client/organizations", bytes.NewReader(orgBody)) + orgReq.Header.Set("Content-Type", "application/json") + orgReq = orgReq.WithContext(rbac.WithScope(orgReq.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + orgW := httptest.NewRecorder() + controller.UpsertOrganizationClient(orgW, orgReq) + require.Equal(t, 200, orgW.Code) + + events := []map[string]any{ + { + "organization_external_id": "org_123", + "name": "complex_event", + "data": map[string]any{ + "subscription": map[string]any{ + "plan": "enterprise", + "features": []string{"analytics", "api", "support"}, + "billing": map[string]any{ + "amount": 999.99, + "currency": "USD", + "interval": "monthly", + }, + }, + "users_count": 50, + }, + }, + } + + body, err := json.Marshal(events) + require.NoError(t, err) + + req := httptest.NewRequest("POST", "/api/client/organizations/events", bytes.NewReader(body)) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(rbac.WithScope(req.Context(), &rbac.Scope{ + OrganizationID: orgID, + ProjectID: projectID, + })) + w := httptest.NewRecorder() + + controller.PostOrganizationEventsClient(w, req) + + assert.Equal(t, 202, w.Code) +} diff --git a/internal/http/controllers/v1/client/oapi/resources.yml b/internal/http/controllers/v1/client/oapi/resources.yml index b1dfc9fe..8dfb2797 100644 --- a/internal/http/controllers/v1/client/oapi/resources.yml +++ b/internal/http/controllers/v1/client/oapi/resources.yml @@ -19,16 +19,16 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/IdentifyRequest' + $ref: "#/components/schemas/IdentifyRequest" responses: - '200': + "200": description: User identified successfully content: application/json: schema: - $ref: '#/components/schemas/User' + $ref: "#/components/schemas/User" default: - $ref: '#/components/responses/Error' + $ref: "#/components/responses/Error" /api/client/events: post: @@ -49,12 +49,12 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/PostEventsRequest' + $ref: "#/components/schemas/PostEventsRequest" responses: - '202': + "202": description: Events accepted for asynchronous processing default: - $ref: '#/components/responses/Error' + $ref: "#/components/responses/Error" /api/client/organizations: post: @@ -72,16 +72,16 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/OrganizationRequest' + $ref: "#/components/schemas/OrganizationRequest" responses: - '200': + "200": description: Organization upserted successfully content: application/json: schema: - $ref: '#/components/schemas/Organization' + $ref: "#/components/schemas/Organization" default: - $ref: '#/components/responses/Error' + $ref: "#/components/responses/Error" /api/client/organizations/users: post: @@ -100,12 +100,12 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/OrganizationUserRequest' + $ref: "#/components/schemas/OrganizationUserRequest" responses: - '200': + "200": description: User added to organization successfully default: - $ref: '#/components/responses/Error' + $ref: "#/components/responses/Error" delete: summary: Remove user from organization @@ -123,12 +123,12 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/RemoveOrganizationUserRequest' + $ref: "#/components/schemas/RemoveOrganizationUserRequest" responses: - '204': + "204": description: User removed from organization successfully default: - $ref: '#/components/responses/Error' + $ref: "#/components/responses/Error" /api/client/organizations/events: post: @@ -148,12 +148,12 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/PostOrganizationEventsRequest' + $ref: "#/components/schemas/PostOrganizationEventsRequest" responses: - '202': + "202": description: Events accepted for asynchronous processing default: - $ref: '#/components/responses/Error' + $ref: "#/components/responses/Error" /unsubscribe/email: get: @@ -172,7 +172,7 @@ paths: type: string description: Encoded unsubscribe link with user and campaign data responses: - '200': + "200": description: Unsubscribe confirmation page content: text/html: @@ -204,7 +204,7 @@ paths: format: uuid description: The user ID responses: - '200': + "200": description: Subscription preferences page content: text/html: @@ -248,9 +248,9 @@ paths: format: uuid description: Array of subscription IDs to keep subscribed responses: - '302': + "302": description: Redirect to preferences page with success indicator - '200': + "200": description: Success response (for htmx partial updates) content: text/html: @@ -264,7 +264,7 @@ components: content: application/json: schema: - $ref: '#/components/schemas/Problem' + $ref: "#/components/schemas/Problem" schemas: Problem: @@ -283,7 +283,7 @@ components: description: | A human readable explanation specific to this occurrence of the problem that is helpful to locate the problem and give advice on how to proceed. Written in English and readable for engineers, usually not suited for non technical stakeholders and not localized. example: some description for the error situation - + User: type: object required: @@ -399,7 +399,7 @@ components: type: array minItems: 1 items: - $ref: '#/components/schemas/Event' + $ref: "#/components/schemas/Event" Event: type: object @@ -487,12 +487,10 @@ components: description: External identifier for the organization from your system name: type: string - nullable: true example: "Acme Corp" data: type: object additionalProperties: true - nullable: true x-go-type: map[string]any example: industry: "technology" @@ -515,7 +513,6 @@ components: data: type: object additionalProperties: true - nullable: true x-go-type: map[string]any example: role: "admin" @@ -541,7 +538,7 @@ components: type: array minItems: 1 items: - $ref: '#/components/schemas/OrganizationEvent' + $ref: "#/components/schemas/OrganizationEvent" OrganizationEvent: type: object @@ -560,7 +557,6 @@ components: data: type: object additionalProperties: true - nullable: true x-go-type: map[string]any example: plan: "enterprise" @@ -572,4 +568,4 @@ components: type: http scheme: bearer bearerFormat: JWT - description: JWT token for API authentication \ No newline at end of file + description: JWT token for API authentication diff --git a/internal/http/controllers/v1/client/oapi/resources_gen.go b/internal/http/controllers/v1/client/oapi/resources_gen.go index 61041727..7f9d90c3 100644 --- a/internal/http/controllers/v1/client/oapi/resources_gen.go +++ b/internal/http/controllers/v1/client/oapi/resources_gen.go @@ -73,7 +73,7 @@ type Organization struct { // OrganizationEvent defines model for OrganizationEvent. type OrganizationEvent struct { // Data Event-specific data - Data *map[string]any `json:"data"` + Data *map[string]any `json:"data,omitempty"` // Name The name of the event Name string `json:"name"` @@ -84,17 +84,17 @@ type OrganizationEvent struct { // OrganizationRequest defines model for OrganizationRequest. type OrganizationRequest struct { - Data *map[string]any `json:"data"` + Data *map[string]any `json:"data,omitempty"` // ExternalId External identifier for the organization from your system ExternalId string `json:"external_id"` - Name *string `json:"name"` + Name *string `json:"name,omitempty"` } // OrganizationUserRequest defines model for OrganizationUserRequest. type OrganizationUserRequest struct { // Data Organization-specific data for this user - Data *map[string]any `json:"data"` + Data *map[string]any `json:"data,omitempty"` // OrganizationExternalId External identifier for the organization OrganizationExternalId string `json:"organization_external_id"` diff --git a/internal/http/controllers/v1/management/oapi/resources.yml b/internal/http/controllers/v1/management/oapi/resources.yml index f4aa4522..c4d67f1a 100644 --- a/internal/http/controllers/v1/management/oapi/resources.yml +++ b/internal/http/controllers/v1/management/oapi/resources.yml @@ -1871,7 +1871,6 @@ paths: description: The project ID - $ref: "#/components/parameters/Limit" - $ref: "#/components/parameters/Offset" - - $ref: "#/components/parameters/Search" responses: "200": description: Organizations retrieved successfully diff --git a/internal/http/controllers/v1/management/oapi/resources_gen.go b/internal/http/controllers/v1/management/oapi/resources_gen.go index 28da6b1e..d9f8f704 100644 --- a/internal/http/controllers/v1/management/oapi/resources_gen.go +++ b/internal/http/controllers/v1/management/oapi/resources_gen.go @@ -1288,9 +1288,6 @@ type ListOrganizationsParams struct { // Offset Number of items to skip Offset *Offset `form:"offset,omitempty" json:"offset,omitempty"` - - // Search Search query string - Search *Search `form:"search,omitempty" json:"search,omitempty"` } // ListOrganizationMembersParams defines parameters for ListOrganizationMembers. @@ -6813,22 +6810,6 @@ func NewListOrganizationsRequest(server string, projectID openapi_types.UUID, pa } - if params.Search != nil { - - if queryFrag, err := runtime.StyleParamWithLocation("form", true, "search", runtime.ParamLocationQuery, *params.Search); err != nil { - return nil, err - } else if parsed, err := url.ParseQuery(queryFrag); err != nil { - return nil, err - } else { - for k, v := range parsed { - for _, v2 := range v { - queryValues.Add(k, v2) - } - } - } - - } - queryURL.RawQuery = queryValues.Encode() } @@ -19700,14 +19681,6 @@ func (siw *ServerInterfaceWrapper) ListOrganizations(w http.ResponseWriter, r *h return } - // ------------- Optional query parameter "search" ------------- - - err = runtime.BindQueryParameter("form", true, false, "search", r.URL.Query(), ¶ms.Search) - if err != nil { - siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "search", Err: err}) - return - } - handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { siw.Handler.ListOrganizations(w, r, projectID, params) })) diff --git a/internal/http/controllers/v1/management/subject_organizations_test.go b/internal/http/controllers/v1/management/subject_organizations_test.go new file mode 100644 index 00000000..9418290e --- /dev/null +++ b/internal/http/controllers/v1/management/subject_organizations_test.go @@ -0,0 +1,1109 @@ +package v1 + +import ( + "bytes" + "context" + "encoding/json" + "net/http/httptest" + "testing" + + "github.com/cloudproud/graceful" + "github.com/google/uuid" + "github.com/lunogram/platform/internal/claim" + "github.com/lunogram/platform/internal/config" + "github.com/lunogram/platform/internal/container" + "github.com/lunogram/platform/internal/http/controllers/v1/management/oapi" + "github.com/lunogram/platform/internal/pubsub" + "github.com/lunogram/platform/internal/pubsub/consumer" + "github.com/lunogram/platform/internal/rules" + "github.com/lunogram/platform/internal/store/management" + "github.com/lunogram/platform/internal/store/subjects" + teststore "github.com/lunogram/platform/internal/store/test" + "github.com/stretchr/testify/require" + "go.uber.org/zap/zaptest" +) + +type testSubjectOrganizationsController struct { + controller *SubjectOrganizationsController + projectID uuid.UUID + usersDB *subjects.State +} + +func setupSubjectOrganizationsController(t *testing.T) *testSubjectOrganizationsController { + t.Helper() + + logger := zaptest.NewLogger(t) + ctx := t.Context() + gracefulCtx := graceful.NewContext(ctx) + mgmtDB, usrsDB, _ := teststore.RunPostgreSQL(t) + cfg := config.Node{ + Nats: config.Nats{ + URL: container.RunNATS(t), + }, + } + + jet, err := pubsub.New(gracefulCtx, cfg) + require.NoError(t, err) + + err = consumer.Bootstrap(gracefulCtx, logger, jet) + require.NoError(t, err) + + pub := pubsub.NewPublisher(jet) + + orgsStore := management.NewOrganizationsStore(mgmtDB) + orgID, err := orgsStore.CreateOrganization(ctx, "Test Org") + require.NoError(t, err) + + projectsStore := management.NewProjectsStore(mgmtDB) + projectID, err := projectsStore.CreateProject(ctx, management.Project{ + OrganizationID: &orgID, + Name: DefaultProject.Name, + Timezone: DefaultProject.Timezone, + Locale: DefaultProject.Locale, + }) + require.NoError(t, err) + + controller := NewSubjectOrganizationsController(logger, usrsDB, pub) + usersState := subjects.NewState(usrsDB) + + return &testSubjectOrganizationsController{ + controller: controller, + projectID: projectID, + usersDB: usersState, + } +} + +func TestListOrganizations(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + for i := 0; i < 5; i++ { + _, err := tc.usersDB.OrganizationsStore.UpsertOrganization(ctx, tc.projectID, subjects.UpsertOrganizationParams{ + ExternalID: "org_" + uuid.New().String(), + Name: ptr("Test Org"), + }) + require.NoError(t, err) + } + + res := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations", nil) + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.ListOrganizations(res, req, tc.projectID, oapi.ListOrganizationsParams{}) + + require.Equal(t, 200, res.Code) + + var response oapi.OrganizationList + err := json.Unmarshal(res.Body.Bytes(), &response) + require.NoError(t, err) + require.Equal(t, 5, response.Total) + require.Len(t, response.Results, 5) +} + +func TestListOrganizationsPagination(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + for i := 0; i < 10; i++ { + _, err := tc.usersDB.OrganizationsStore.UpsertOrganization(ctx, tc.projectID, subjects.UpsertOrganizationParams{ + ExternalID: "org_" + uuid.New().String(), + Name: ptr("Test Org"), + }) + require.NoError(t, err) + } + + limit := 3 + offset := 2 + + res := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations", nil) + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.ListOrganizations(res, req, tc.projectID, oapi.ListOrganizationsParams{ + Limit: (*oapi.Limit)(&limit), + Offset: (*oapi.Offset)(&offset), + }) + + require.Equal(t, 200, res.Code) + + var response oapi.OrganizationList + err := json.Unmarshal(res.Body.Bytes(), &response) + require.NoError(t, err) + require.Equal(t, 10, response.Total) + require.Len(t, response.Results, 3) + require.Equal(t, 3, response.Limit) + require.Equal(t, 2, response.Offset) +} + +func TestListOrganizationsUnauthorized(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + + res := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations", nil) + + tc.controller.ListOrganizations(res, req, tc.projectID, oapi.ListOrganizationsParams{}) + + require.Equal(t, 401, res.Code) +} + +func TestUpsertOrganization(t *testing.T) { + t.Parallel() + + type test struct { + body oapi.UpsertOrganization + statusCode int + } + + tests := map[string]test{ + "create with all fields": { + body: oapi.UpsertOrganization{ + ExternalId: "org_123", + Name: ptr("Acme Corp"), + Data: &map[string]any{ + "industry": "technology", + "size": "enterprise", + }, + }, + statusCode: 200, + }, + "create with minimal data": { + body: oapi.UpsertOrganization{ + ExternalId: "org_456", + }, + statusCode: 200, + }, + "create with name only": { + body: oapi.UpsertOrganization{ + ExternalId: "org_789", + Name: ptr("Simple Corp"), + }, + statusCode: 200, + }, + } + + for name, tt := range tests { + t.Run(name, func(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + + body, err := json.Marshal(tt.body) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("POST", "/api/admin/projects/"+tc.projectID.String()+"/organizations", bytes.NewReader(body)) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.UpsertOrganization(res, req, tc.projectID) + + require.Equal(t, tt.statusCode, res.Code, res.Body.String()) + + if res.Code == 200 { + var response oapi.Organization + err = json.Unmarshal(res.Body.Bytes(), &response) + require.NoError(t, err) + require.NotEmpty(t, response.Id) + require.Equal(t, tt.body.ExternalId, response.ExternalId) + } + }) + } +} + +func TestUpsertOrganizationUpdate(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + + // First upsert - create + body1 := oapi.UpsertOrganization{ + ExternalId: "org_123", + Name: ptr("Original Name"), + Data: &map[string]any{ + "plan": "basic", + }, + } + + bodyBytes1, err := json.Marshal(body1) + require.NoError(t, err) + + res1 := httptest.NewRecorder() + req1 := httptest.NewRequest("POST", "/api/admin/projects/"+tc.projectID.String()+"/organizations", bytes.NewReader(bodyBytes1)) + req1.Header.Set("Content-Type", "application/json") + req1 = req1.WithContext(claim.WithSession(req1.Context(), validSession())) + + tc.controller.UpsertOrganization(res1, req1, tc.projectID) + require.Equal(t, 200, res1.Code) + + var response1 oapi.Organization + err = json.Unmarshal(res1.Body.Bytes(), &response1) + require.NoError(t, err) + orgID := response1.Id + + // Second upsert - update + body2 := oapi.UpsertOrganization{ + ExternalId: "org_123", + Name: ptr("Updated Name"), + Data: &map[string]any{ + "plan": "enterprise", + }, + } + + bodyBytes2, err := json.Marshal(body2) + require.NoError(t, err) + + res2 := httptest.NewRecorder() + req2 := httptest.NewRequest("POST", "/api/admin/projects/"+tc.projectID.String()+"/organizations", bytes.NewReader(bodyBytes2)) + req2.Header.Set("Content-Type", "application/json") + req2 = req2.WithContext(claim.WithSession(req2.Context(), validSession())) + + tc.controller.UpsertOrganization(res2, req2, tc.projectID) + require.Equal(t, 200, res2.Code) + + var response2 oapi.Organization + err = json.Unmarshal(res2.Body.Bytes(), &response2) + require.NoError(t, err) + + require.Equal(t, orgID, response2.Id) + require.Equal(t, "Updated Name", *response2.Name) +} + +func TestUpsertOrganizationUnauthorized(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + + body := oapi.UpsertOrganization{ + ExternalId: "org_123", + Name: ptr("Test Org"), + } + + bodyBytes, err := json.Marshal(body) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("POST", "/api/admin/projects/"+tc.projectID.String()+"/organizations", bytes.NewReader(bodyBytes)) + req.Header.Set("Content-Type", "application/json") + + tc.controller.UpsertOrganization(res, req, tc.projectID) + + require.Equal(t, 401, res.Code) +} + +func TestUpsertOrganizationInvalidRequest(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + + res := httptest.NewRecorder() + req := httptest.NewRequest("POST", "/api/admin/projects/"+tc.projectID.String()+"/organizations", bytes.NewReader([]byte("invalid json"))) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.UpsertOrganization(res, req, tc.projectID) + + require.Equal(t, 400, res.Code) +} + +func TestGetOrganization(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + orgID, err := tc.usersDB.OrganizationsStore.UpsertOrganization(ctx, tc.projectID, subjects.UpsertOrganizationParams{ + ExternalID: "org_123", + Name: ptr("Test Org"), + Data: map[string]any{ + "industry": "technology", + }, + }) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+orgID.String(), nil) + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.GetOrganization(res, req, tc.projectID, orgID) + + require.Equal(t, 200, res.Code) + + var response oapi.Organization + err = json.Unmarshal(res.Body.Bytes(), &response) + require.NoError(t, err) + require.Equal(t, orgID, response.Id) + require.Equal(t, "org_123", response.ExternalId) + require.Equal(t, "Test Org", *response.Name) +} + +func TestGetOrganizationNotFound(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + nonExistentID := uuid.New() + + res := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+nonExistentID.String(), nil) + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.GetOrganization(res, req, tc.projectID, nonExistentID) + + require.Equal(t, 404, res.Code) +} + +func TestGetOrganizationUnauthorized(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + orgID, err := tc.usersDB.OrganizationsStore.UpsertOrganization(ctx, tc.projectID, subjects.UpsertOrganizationParams{ + ExternalID: "org_123", + Name: ptr("Test Org"), + }) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+orgID.String(), nil) + + tc.controller.GetOrganization(res, req, tc.projectID, orgID) + + require.Equal(t, 401, res.Code) +} + +func TestUpdateOrganization(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + orgID, err := tc.usersDB.OrganizationsStore.UpsertOrganization(ctx, tc.projectID, subjects.UpsertOrganizationParams{ + ExternalID: "org_123", + Name: ptr("Original Name"), + }) + require.NoError(t, err) + + dataBytes := json.RawMessage(`{"plan": "premium"}`) + body := oapi.UpdateOrganization{ + Name: ptr("Updated Name"), + Data: &dataBytes, + } + + bodyBytes, err := json.Marshal(body) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("PATCH", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+orgID.String(), bytes.NewReader(bodyBytes)) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.UpdateOrganization(res, req, tc.projectID, orgID) + + require.Equal(t, 200, res.Code) + + var response oapi.Organization + err = json.Unmarshal(res.Body.Bytes(), &response) + require.NoError(t, err) + require.Equal(t, orgID, response.Id) + require.Equal(t, "Updated Name", *response.Name) +} + +func TestUpdateOrganizationNotFound(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + nonExistentID := uuid.New() + + body := oapi.UpdateOrganization{ + Name: ptr("Updated Name"), + } + + bodyBytes, err := json.Marshal(body) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("PATCH", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+nonExistentID.String(), bytes.NewReader(bodyBytes)) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.UpdateOrganization(res, req, tc.projectID, nonExistentID) + + require.Equal(t, 404, res.Code) +} + +func TestUpdateOrganizationUnauthorized(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + orgID, err := tc.usersDB.OrganizationsStore.UpsertOrganization(ctx, tc.projectID, subjects.UpsertOrganizationParams{ + ExternalID: "org_123", + Name: ptr("Original Name"), + }) + require.NoError(t, err) + + body := oapi.UpdateOrganization{ + Name: ptr("Updated Name"), + } + + bodyBytes, err := json.Marshal(body) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("PATCH", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+orgID.String(), bytes.NewReader(bodyBytes)) + req.Header.Set("Content-Type", "application/json") + + tc.controller.UpdateOrganization(res, req, tc.projectID, orgID) + + require.Equal(t, 401, res.Code) +} + +func TestDeleteOrganization(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + orgID, err := tc.usersDB.OrganizationsStore.UpsertOrganization(ctx, tc.projectID, subjects.UpsertOrganizationParams{ + ExternalID: "org_123", + Name: ptr("Test Org"), + }) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("DELETE", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+orgID.String(), nil) + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.DeleteOrganization(res, req, tc.projectID, orgID) + + require.Equal(t, 204, res.Code) + + // Verify organization is deleted + getRes := httptest.NewRecorder() + getReq := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+orgID.String(), nil) + getReq = getReq.WithContext(claim.WithSession(getReq.Context(), validSession())) + + tc.controller.GetOrganization(getRes, getReq, tc.projectID, orgID) + require.Equal(t, 404, getRes.Code) +} + +func TestDeleteOrganizationNotFound(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + nonExistentID := uuid.New() + + res := httptest.NewRecorder() + req := httptest.NewRequest("DELETE", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+nonExistentID.String(), nil) + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.DeleteOrganization(res, req, tc.projectID, nonExistentID) + + require.Equal(t, 404, res.Code) +} + +func TestDeleteOrganizationUnauthorized(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + orgID, err := tc.usersDB.OrganizationsStore.UpsertOrganization(ctx, tc.projectID, subjects.UpsertOrganizationParams{ + ExternalID: "org_123", + Name: ptr("Test Org"), + }) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("DELETE", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+orgID.String(), nil) + + tc.controller.DeleteOrganization(res, req, tc.projectID, orgID) + + require.Equal(t, 401, res.Code) +} + +func TestListOrganizationMembers(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + orgID, err := tc.usersDB.OrganizationsStore.UpsertOrganization(ctx, tc.projectID, subjects.UpsertOrganizationParams{ + ExternalID: "org_123", + Name: ptr("Test Org"), + }) + require.NoError(t, err) + + // Create users and add them to the organization + for i := 0; i < 3; i++ { + userID, err := tc.usersDB.UsersStore.CreateUser(ctx, subjects.User{ + ProjectID: tc.projectID, + AnonymousID: ptr(uuid.New().String()), + Data: json.RawMessage(`{}`), + }) + require.NoError(t, err) + + err = tc.usersDB.OrganizationsStore.UpsertOrganizationMember(ctx, orgID, userID, map[string]any{"role": "member"}) + require.NoError(t, err) + } + + res := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+orgID.String()+"/members", nil) + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.ListOrganizationMembers(res, req, tc.projectID, orgID, oapi.ListOrganizationMembersParams{}) + + require.Equal(t, 200, res.Code) + + var response oapi.OrganizationMemberList + err = json.Unmarshal(res.Body.Bytes(), &response) + require.NoError(t, err) + require.Equal(t, 3, response.Total) + require.Len(t, response.Results, 3) +} + +func TestListOrganizationMembersOrganizationNotFound(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + nonExistentID := uuid.New() + + res := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+nonExistentID.String()+"/members", nil) + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.ListOrganizationMembers(res, req, tc.projectID, nonExistentID, oapi.ListOrganizationMembersParams{}) + + require.Equal(t, 404, res.Code) +} + +func TestListOrganizationMembersUnauthorized(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + orgID, err := tc.usersDB.OrganizationsStore.UpsertOrganization(ctx, tc.projectID, subjects.UpsertOrganizationParams{ + ExternalID: "org_123", + Name: ptr("Test Org"), + }) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+orgID.String()+"/members", nil) + + tc.controller.ListOrganizationMembers(res, req, tc.projectID, orgID, oapi.ListOrganizationMembersParams{}) + + require.Equal(t, 401, res.Code) +} + +func TestAddOrganizationMember(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + orgID, err := tc.usersDB.OrganizationsStore.UpsertOrganization(ctx, tc.projectID, subjects.UpsertOrganizationParams{ + ExternalID: "org_123", + Name: ptr("Test Org"), + }) + require.NoError(t, err) + + userID, err := tc.usersDB.UsersStore.CreateUser(ctx, subjects.User{ + ProjectID: tc.projectID, + AnonymousID: ptr(uuid.New().String()), + Data: json.RawMessage(`{}`), + }) + require.NoError(t, err) + + body := oapi.AddOrganizationMember{ + UserId: userID, + Data: &map[string]any{ + "role": "admin", + "department": "engineering", + }, + } + + bodyBytes, err := json.Marshal(body) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("POST", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+orgID.String()+"/members", bytes.NewReader(bodyBytes)) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.AddOrganizationMember(res, req, tc.projectID, orgID) + + require.Equal(t, 200, res.Code) + + // Verify user was added + listRes := httptest.NewRecorder() + listReq := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+orgID.String()+"/members", nil) + listReq = listReq.WithContext(claim.WithSession(listReq.Context(), validSession())) + + tc.controller.ListOrganizationMembers(listRes, listReq, tc.projectID, orgID, oapi.ListOrganizationMembersParams{}) + require.Equal(t, 200, listRes.Code) + + var listResponse oapi.OrganizationMemberList + err = json.Unmarshal(listRes.Body.Bytes(), &listResponse) + require.NoError(t, err) + require.Equal(t, 1, listResponse.Total) +} + +func TestAddOrganizationMemberOrganizationNotFound(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + userID, err := tc.usersDB.UsersStore.CreateUser(ctx, subjects.User{ + ProjectID: tc.projectID, + AnonymousID: ptr(uuid.New().String()), + Data: json.RawMessage(`{}`), + }) + require.NoError(t, err) + + nonExistentOrgID := uuid.New() + + body := oapi.AddOrganizationMember{ + UserId: userID, + } + + bodyBytes, err := json.Marshal(body) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("POST", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+nonExistentOrgID.String()+"/members", bytes.NewReader(bodyBytes)) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.AddOrganizationMember(res, req, tc.projectID, nonExistentOrgID) + + require.Equal(t, 404, res.Code) +} + +func TestAddOrganizationMemberUserNotFound(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + orgID, err := tc.usersDB.OrganizationsStore.UpsertOrganization(ctx, tc.projectID, subjects.UpsertOrganizationParams{ + ExternalID: "org_123", + Name: ptr("Test Org"), + }) + require.NoError(t, err) + + nonExistentUserID := uuid.New() + + body := oapi.AddOrganizationMember{ + UserId: nonExistentUserID, + } + + bodyBytes, err := json.Marshal(body) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("POST", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+orgID.String()+"/members", bytes.NewReader(bodyBytes)) + req.Header.Set("Content-Type", "application/json") + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.AddOrganizationMember(res, req, tc.projectID, orgID) + + require.Equal(t, 404, res.Code) +} + +func TestAddOrganizationMemberUnauthorized(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + orgID, err := tc.usersDB.OrganizationsStore.UpsertOrganization(ctx, tc.projectID, subjects.UpsertOrganizationParams{ + ExternalID: "org_123", + Name: ptr("Test Org"), + }) + require.NoError(t, err) + + body := oapi.AddOrganizationMember{ + UserId: uuid.New(), + } + + bodyBytes, err := json.Marshal(body) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("POST", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+orgID.String()+"/members", bytes.NewReader(bodyBytes)) + req.Header.Set("Content-Type", "application/json") + + tc.controller.AddOrganizationMember(res, req, tc.projectID, orgID) + + require.Equal(t, 401, res.Code) +} + +func TestRemoveOrganizationMember(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + orgID, err := tc.usersDB.OrganizationsStore.UpsertOrganization(ctx, tc.projectID, subjects.UpsertOrganizationParams{ + ExternalID: "org_123", + Name: ptr("Test Org"), + }) + require.NoError(t, err) + + userID, err := tc.usersDB.UsersStore.CreateUser(ctx, subjects.User{ + ProjectID: tc.projectID, + AnonymousID: ptr(uuid.New().String()), + Data: json.RawMessage(`{}`), + }) + require.NoError(t, err) + + err = tc.usersDB.OrganizationsStore.UpsertOrganizationMember(ctx, orgID, userID, nil) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("DELETE", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+orgID.String()+"/members/"+userID.String(), nil) + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.RemoveOrganizationMember(res, req, tc.projectID, orgID, userID) + + require.Equal(t, 204, res.Code) + + // Verify user was removed + listRes := httptest.NewRecorder() + listReq := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+orgID.String()+"/members", nil) + listReq = listReq.WithContext(claim.WithSession(listReq.Context(), validSession())) + + tc.controller.ListOrganizationMembers(listRes, listReq, tc.projectID, orgID, oapi.ListOrganizationMembersParams{}) + require.Equal(t, 200, listRes.Code) + + var listResponse oapi.OrganizationMemberList + err = json.Unmarshal(listRes.Body.Bytes(), &listResponse) + require.NoError(t, err) + require.Equal(t, 0, listResponse.Total) +} + +func TestRemoveOrganizationMemberOrganizationNotFound(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + nonExistentOrgID := uuid.New() + userID := uuid.New() + + res := httptest.NewRecorder() + req := httptest.NewRequest("DELETE", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+nonExistentOrgID.String()+"/members/"+userID.String(), nil) + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.RemoveOrganizationMember(res, req, tc.projectID, nonExistentOrgID, userID) + + require.Equal(t, 404, res.Code) +} + +func TestRemoveOrganizationMemberUnauthorized(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + orgID, err := tc.usersDB.OrganizationsStore.UpsertOrganization(ctx, tc.projectID, subjects.UpsertOrganizationParams{ + ExternalID: "org_123", + Name: ptr("Test Org"), + }) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("DELETE", "/api/admin/projects/"+tc.projectID.String()+"/organizations/"+orgID.String()+"/members/"+uuid.New().String(), nil) + + tc.controller.RemoveOrganizationMember(res, req, tc.projectID, orgID, uuid.New()) + + require.Equal(t, 401, res.Code) +} + +func TestListOrganizationSchemas(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + paths := rules.Paths{ + {Path: ".plan", Type: "string"}, + {Path: ".seats", Type: "number"}, + {Path: ".active", Type: "boolean"}, + {Path: ".metadata", Type: "object"}, + {Path: ".metadata.industry", Type: "string"}, + } + err := tc.usersDB.OrganizationsStore.UpsertOrganizationSchema(ctx, tc.projectID, paths) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations/schema", nil) + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.ListOrganizationSchemas(res, req, tc.projectID) + + require.Equal(t, 200, res.Code) + + var response struct { + Results []oapi.SchemaPath `json:"results"` + } + err = json.Unmarshal(res.Body.Bytes(), &response) + require.NoError(t, err) + require.Len(t, response.Results, 5) + + pathMap := make(map[string][]string) + for _, schema := range response.Results { + pathMap[schema.Path] = schema.Types + } + + require.Contains(t, pathMap[".plan"], "string") + require.Contains(t, pathMap[".seats"], "number") + require.Contains(t, pathMap[".active"], "boolean") + require.Contains(t, pathMap[".metadata"], "object") + require.Contains(t, pathMap[".metadata.industry"], "string") +} + +func TestListOrganizationSchemasEmpty(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + + res := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations/schema", nil) + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.ListOrganizationSchemas(res, req, tc.projectID) + + require.Equal(t, 200, res.Code) + + var response struct { + Results []oapi.SchemaPath `json:"results"` + } + err := json.Unmarshal(res.Body.Bytes(), &response) + require.NoError(t, err) + require.Empty(t, response.Results) +} + +func TestListOrganizationSchemasUnauthorized(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + + res := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations/schema", nil) + + tc.controller.ListOrganizationSchemas(res, req, tc.projectID) + + require.Equal(t, 401, res.Code) +} + +func TestListOrganizationSchemasWithMultipleTypes(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + paths := rules.Paths{ + {Path: ".seats", Type: "number"}, + {Path: ".seats", Type: "string"}, + {Path: ".active", Type: "boolean"}, + {Path: ".active", Type: "string"}, + {Path: ".tags", Type: "array"}, + {Path: ".tags", Type: "string"}, + {Path: ".metadata", Type: "object"}, + {Path: ".plan", Type: "string"}, + } + err := tc.usersDB.OrganizationsStore.UpsertOrganizationSchema(ctx, tc.projectID, paths) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations/schema", nil) + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.ListOrganizationSchemas(res, req, tc.projectID) + + require.Equal(t, 200, res.Code) + + var response struct { + Results []oapi.SchemaPath `json:"results"` + } + err = json.Unmarshal(res.Body.Bytes(), &response) + require.NoError(t, err) + require.Len(t, response.Results, 5) + + pathMap := make(map[string][]string) + for _, schema := range response.Results { + pathMap[schema.Path] = schema.Types + } + + require.Contains(t, pathMap, ".seats") + require.Len(t, pathMap[".seats"], 2) + require.Contains(t, pathMap[".seats"], "number") + require.Contains(t, pathMap[".seats"], "string") + + require.Contains(t, pathMap, ".active") + require.Len(t, pathMap[".active"], 2) + require.Contains(t, pathMap[".active"], "boolean") + require.Contains(t, pathMap[".active"], "string") + + require.Contains(t, pathMap, ".tags") + require.Len(t, pathMap[".tags"], 2) + require.Contains(t, pathMap[".tags"], "array") + require.Contains(t, pathMap[".tags"], "string") + + require.Contains(t, pathMap, ".metadata") + require.Len(t, pathMap[".metadata"], 1) + require.Contains(t, pathMap[".metadata"], "object") + + require.Contains(t, pathMap, ".plan") + require.Len(t, pathMap[".plan"], 1) + require.Contains(t, pathMap[".plan"], "string") +} + +func TestListOrganizationMemberSchemas(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + paths := rules.Paths{ + {Path: ".role", Type: "string"}, + {Path: ".level", Type: "number"}, + {Path: ".permissions", Type: "array"}, + {Path: ".metadata", Type: "object"}, + {Path: ".metadata.department", Type: "string"}, + } + err := tc.usersDB.OrganizationsStore.UpsertOrganizationUserSchema(ctx, tc.projectID, paths) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations/members/schema", nil) + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.ListOrganizationMemberSchemas(res, req, tc.projectID) + + require.Equal(t, 200, res.Code) + + var response struct { + Results []oapi.SchemaPath `json:"results"` + } + err = json.Unmarshal(res.Body.Bytes(), &response) + require.NoError(t, err) + require.Len(t, response.Results, 5) + + pathMap := make(map[string][]string) + for _, schema := range response.Results { + pathMap[schema.Path] = schema.Types + } + + require.Contains(t, pathMap[".role"], "string") + require.Contains(t, pathMap[".level"], "number") + require.Contains(t, pathMap[".permissions"], "array") + require.Contains(t, pathMap[".metadata"], "object") + require.Contains(t, pathMap[".metadata.department"], "string") +} + +func TestListOrganizationMemberSchemasEmpty(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + + res := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations/members/schema", nil) + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.ListOrganizationMemberSchemas(res, req, tc.projectID) + + require.Equal(t, 200, res.Code) + + var response struct { + Results []oapi.SchemaPath `json:"results"` + } + err := json.Unmarshal(res.Body.Bytes(), &response) + require.NoError(t, err) + require.Empty(t, response.Results) +} + +func TestListOrganizationMemberSchemasUnauthorized(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + + res := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations/members/schema", nil) + + tc.controller.ListOrganizationMemberSchemas(res, req, tc.projectID) + + require.Equal(t, 401, res.Code) +} + +func TestListOrganizationMemberSchemasWithMultipleTypes(t *testing.T) { + t.Parallel() + + tc := setupSubjectOrganizationsController(t) + ctx := context.Background() + + paths := rules.Paths{ + {Path: ".level", Type: "number"}, + {Path: ".level", Type: "string"}, + {Path: ".active", Type: "boolean"}, + {Path: ".active", Type: "string"}, + {Path: ".permissions", Type: "array"}, + {Path: ".permissions", Type: "string"}, + {Path: ".metadata", Type: "object"}, + {Path: ".role", Type: "string"}, + } + err := tc.usersDB.OrganizationsStore.UpsertOrganizationUserSchema(ctx, tc.projectID, paths) + require.NoError(t, err) + + res := httptest.NewRecorder() + req := httptest.NewRequest("GET", "/api/admin/projects/"+tc.projectID.String()+"/organizations/members/schema", nil) + req = req.WithContext(claim.WithSession(req.Context(), validSession())) + + tc.controller.ListOrganizationMemberSchemas(res, req, tc.projectID) + + require.Equal(t, 200, res.Code) + + var response struct { + Results []oapi.SchemaPath `json:"results"` + } + err = json.Unmarshal(res.Body.Bytes(), &response) + require.NoError(t, err) + require.Len(t, response.Results, 5) + + pathMap := make(map[string][]string) + for _, schema := range response.Results { + pathMap[schema.Path] = schema.Types + } + + require.Contains(t, pathMap, ".level") + require.Len(t, pathMap[".level"], 2) + require.Contains(t, pathMap[".level"], "number") + require.Contains(t, pathMap[".level"], "string") + + require.Contains(t, pathMap, ".active") + require.Len(t, pathMap[".active"], 2) + require.Contains(t, pathMap[".active"], "boolean") + require.Contains(t, pathMap[".active"], "string") + + require.Contains(t, pathMap, ".permissions") + require.Len(t, pathMap[".permissions"], 2) + require.Contains(t, pathMap[".permissions"], "array") + require.Contains(t, pathMap[".permissions"], "string") + + require.Contains(t, pathMap, ".metadata") + require.Len(t, pathMap[".metadata"], 1) + require.Contains(t, pathMap[".metadata"], "object") + + require.Contains(t, pathMap, ".role") + require.Len(t, pathMap[".role"], 1) + require.Contains(t, pathMap[".role"], "string") +} From 58843216de43646ca5138869502149911678cb37 Mon Sep 17 00:00:00 2001 From: IAmKirbki Date: Mon, 23 Feb 2026 10:11:00 +0100 Subject: [PATCH 016/230] feat: add FollowUserJourneyStatus endpoint and parameters for user journey tracking --- .../controllers/v1/management/journeys.go | 10 +- .../v1/management/oapi/resources_gen.go | 233 ++++++++++++++++++ 2 files changed, 236 insertions(+), 7 deletions(-) diff --git a/internal/http/controllers/v1/management/journeys.go b/internal/http/controllers/v1/management/journeys.go index 7c799e6f..e938a3c2 100644 --- a/internal/http/controllers/v1/management/journeys.go +++ b/internal/http/controllers/v1/management/journeys.go @@ -318,15 +318,11 @@ func (srv *JourneysController) DeleteJourney(w http.ResponseWriter, r *http.Requ w.WriteHeader(http.StatusNoContent) } -func (srv *JourneysController) FollowUserJourneyStatus(w http.ResponseWriter, r *http.Request, projectID, journeyID uuid.UUID) { +func (srv *JourneysController) FollowUserJourneyStatus(w http.ResponseWriter, r *http.Request, projectID uuid.UUID, journeyID uuid.UUID, params oapi.FollowUserJourneyStatusParams) { ctx := r.Context() enc := sse.NewEncoder(w) - userID, err := uuid.Parse(r.URL.Query().Get("user_id")) - if err != nil { - oapi.WriteProblem(w, problem.ErrBadRequest(problem.Describe("invalid user_id format"))) - return - } + userID := params.UserID logger := srv.logger.With( zap.Stringer("project_id", projectID), @@ -348,7 +344,7 @@ func (srv *JourneysController) FollowUserJourneyStatus(w http.ResponseWriter, r } subject := schemas.JourneysAdvance(projectID, journeyID, userID) - _, err = nconn.Subscribe(string(subject), handler) + _, err := nconn.Subscribe(string(subject), handler) if err != nil { logger.Error("failed to subscribe to journey updates", zap.Error(err)) oapi.WriteProblem(w, err) diff --git a/internal/http/controllers/v1/management/oapi/resources_gen.go b/internal/http/controllers/v1/management/oapi/resources_gen.go index 4a0faede..078d2624 100644 --- a/internal/http/controllers/v1/management/oapi/resources_gen.go +++ b/internal/http/controllers/v1/management/oapi/resources_gen.go @@ -1156,6 +1156,12 @@ type ListJourneysParams struct { Offset *Offset `form:"offset,omitempty" json:"offset,omitempty"` } +// FollowUserJourneyStatusParams defines parameters for FollowUserJourneyStatus. +type FollowUserJourneyStatusParams struct { + // UserID The user ID to check journey status for + UserID openapi_types.UUID `form:"userID" json:"userID"` +} + // RunJourneyForUserJSONBody defines parameters for RunJourneyForUser. type RunJourneyForUserJSONBody struct { // JourneyEntryID The ID of the journey entry to run @@ -1798,6 +1804,9 @@ type ClientInterface interface { SetJourneySteps(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, body SetJourneyStepsJSONRequestBody, reqEditors ...RequestEditorFn) (*http.Response, error) + // FollowUserJourneyStatus request + FollowUserJourneyStatus(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, params *FollowUserJourneyStatusParams, reqEditors ...RequestEditorFn) (*http.Response, error) + // RunJourneyForUserWithBody request with any body RunJourneyForUserWithBody(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) @@ -2674,6 +2683,18 @@ func (c *Client) SetJourneySteps(ctx context.Context, projectID openapi_types.UU return c.Client.Do(req) } +func (c *Client) FollowUserJourneyStatus(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, params *FollowUserJourneyStatusParams, reqEditors ...RequestEditorFn) (*http.Response, error) { + req, err := NewFollowUserJourneyStatusRequest(c.Server, projectID, journeyID, params) + if err != nil { + return nil, err + } + req = req.WithContext(ctx) + if err := c.applyEditors(ctx, req, reqEditors); err != nil { + return nil, err + } + return c.Client.Do(req) +} + func (c *Client) RunJourneyForUserWithBody(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*http.Response, error) { req, err := NewRunJourneyForUserRequestWithBody(c.Server, projectID, journeyID, contentType, body) if err != nil { @@ -5574,6 +5595,65 @@ func NewSetJourneyStepsRequestWithBody(server string, projectID openapi_types.UU return req, nil } +// NewFollowUserJourneyStatusRequest generates requests for FollowUserJourneyStatus +func NewFollowUserJourneyStatusRequest(server string, projectID openapi_types.UUID, journeyID openapi_types.UUID, params *FollowUserJourneyStatusParams) (*http.Request, error) { + var err error + + var pathParam0 string + + pathParam0, err = runtime.StyleParamWithLocation("simple", false, "projectID", runtime.ParamLocationPath, projectID) + if err != nil { + return nil, err + } + + var pathParam1 string + + pathParam1, err = runtime.StyleParamWithLocation("simple", false, "journeyID", runtime.ParamLocationPath, journeyID) + if err != nil { + return nil, err + } + + serverURL, err := url.Parse(server) + if err != nil { + return nil, err + } + + operationPath := fmt.Sprintf("/api/admin/projects/%s/journeys/%s/users", pathParam0, pathParam1) + if operationPath[0] == '/' { + operationPath = "." + operationPath + } + + queryURL, err := serverURL.Parse(operationPath) + if err != nil { + return nil, err + } + + if params != nil { + queryValues := queryURL.Query() + + if queryFrag, err := runtime.StyleParamWithLocation("form", true, "userID", runtime.ParamLocationQuery, params.UserID); err != nil { + return nil, err + } else if parsed, err := url.ParseQuery(queryFrag); err != nil { + return nil, err + } else { + for k, v := range parsed { + for _, v2 := range v { + queryValues.Add(k, v2) + } + } + } + + queryURL.RawQuery = queryValues.Encode() + } + + req, err := http.NewRequest("GET", queryURL.String(), nil) + if err != nil { + return nil, err + } + + return req, nil +} + // NewRunJourneyForUserRequest calls the generic RunJourneyForUser builder with application/json body func NewRunJourneyForUserRequest(server string, projectID openapi_types.UUID, journeyID openapi_types.UUID, body RunJourneyForUserJSONRequestBody) (*http.Request, error) { var bodyReader io.Reader @@ -8337,6 +8417,9 @@ type ClientWithResponsesInterface interface { SetJourneyStepsWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, body SetJourneyStepsJSONRequestBody, reqEditors ...RequestEditorFn) (*SetJourneyStepsResponse, error) + // FollowUserJourneyStatusWithResponse request + FollowUserJourneyStatusWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, params *FollowUserJourneyStatusParams, reqEditors ...RequestEditorFn) (*FollowUserJourneyStatusResponse, error) + // RunJourneyForUserWithBodyWithResponse request with any body RunJourneyForUserWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RunJourneyForUserResponse, error) @@ -9556,6 +9639,37 @@ func (r SetJourneyStepsResponse) StatusCode() int { return 0 } +type FollowUserJourneyStatusResponse struct { + Body []byte + HTTPResponse *http.Response + JSON200 *struct { + CurrentStepId *string `json:"current_step_id"` + JourneyId *openapi_types.UUID `json:"journey_id,omitempty"` + StartedAt *time.Time `json:"started_at,omitempty"` + Status *FollowUserJourneyStatus200Status `json:"status,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` + UserId *openapi_types.UUID `json:"user_id,omitempty"` + } + JSONDefault *Error +} +type FollowUserJourneyStatus200Status string + +// Status returns HTTPResponse.Status +func (r FollowUserJourneyStatusResponse) Status() string { + if r.HTTPResponse != nil { + return r.HTTPResponse.Status + } + return http.StatusText(0) +} + +// StatusCode returns HTTPResponse.StatusCode +func (r FollowUserJourneyStatusResponse) StatusCode() int { + if r.HTTPResponse != nil { + return r.HTTPResponse.StatusCode + } + return 0 +} + type RunJourneyForUserResponse struct { Body []byte HTTPResponse *http.Response @@ -11193,6 +11307,15 @@ func (c *ClientWithResponses) SetJourneyStepsWithResponse(ctx context.Context, p return ParseSetJourneyStepsResponse(rsp) } +// FollowUserJourneyStatusWithResponse request returning *FollowUserJourneyStatusResponse +func (c *ClientWithResponses) FollowUserJourneyStatusWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, params *FollowUserJourneyStatusParams, reqEditors ...RequestEditorFn) (*FollowUserJourneyStatusResponse, error) { + rsp, err := c.FollowUserJourneyStatus(ctx, projectID, journeyID, params, reqEditors...) + if err != nil { + return nil, err + } + return ParseFollowUserJourneyStatusResponse(rsp) +} + // RunJourneyForUserWithBodyWithResponse request with arbitrary body returning *RunJourneyForUserResponse func (c *ClientWithResponses) RunJourneyForUserWithBodyWithResponse(ctx context.Context, projectID openapi_types.UUID, journeyID openapi_types.UUID, contentType string, body io.Reader, reqEditors ...RequestEditorFn) (*RunJourneyForUserResponse, error) { rsp, err := c.RunJourneyForUserWithBody(ctx, projectID, journeyID, contentType, body, reqEditors...) @@ -13203,6 +13326,46 @@ func ParseSetJourneyStepsResponse(rsp *http.Response) (*SetJourneyStepsResponse, return response, nil } +// ParseFollowUserJourneyStatusResponse parses an HTTP response from a FollowUserJourneyStatusWithResponse call +func ParseFollowUserJourneyStatusResponse(rsp *http.Response) (*FollowUserJourneyStatusResponse, error) { + bodyBytes, err := io.ReadAll(rsp.Body) + defer func() { _ = rsp.Body.Close() }() + if err != nil { + return nil, err + } + + response := &FollowUserJourneyStatusResponse{ + Body: bodyBytes, + HTTPResponse: rsp, + } + + switch { + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && rsp.StatusCode == 200: + var dest struct { + CurrentStepId *string `json:"current_step_id"` + JourneyId *openapi_types.UUID `json:"journey_id,omitempty"` + StartedAt *time.Time `json:"started_at,omitempty"` + Status *FollowUserJourneyStatus200Status `json:"status,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` + UserId *openapi_types.UUID `json:"user_id,omitempty"` + } + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSON200 = &dest + + case strings.Contains(rsp.Header.Get("Content-Type"), "json") && true: + var dest Error + if err := json.Unmarshal(bodyBytes, &dest); err != nil { + return nil, err + } + response.JSONDefault = &dest + + } + + return response, nil +} + // ParseRunJourneyForUserResponse parses an HTTP response from a RunJourneyForUserWithResponse call func ParseRunJourneyForUserResponse(rsp *http.Response) (*RunJourneyForUserResponse, error) { bodyBytes, err := io.ReadAll(rsp.Body) @@ -14892,6 +15055,9 @@ type ServerInterface interface { // Set journey steps // (PUT /api/admin/projects/{projectID}/journeys/{journeyID}/steps) SetJourneySteps(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) + // Get user journey status + // (GET /api/admin/projects/{projectID}/journeys/{journeyID}/users) + FollowUserJourneyStatus(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID, params FollowUserJourneyStatusParams) // Manually runs a journey for a user // (POST /api/admin/projects/{projectID}/journeys/{journeyID}/users) RunJourneyForUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) @@ -15315,6 +15481,12 @@ func (_ Unimplemented) SetJourneySteps(w http.ResponseWriter, r *http.Request, p w.WriteHeader(http.StatusNotImplemented) } +// Get user journey status +// (GET /api/admin/projects/{projectID}/journeys/{journeyID}/users) +func (_ Unimplemented) FollowUserJourneyStatus(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID, params FollowUserJourneyStatusParams) { + w.WriteHeader(http.StatusNotImplemented) +} + // Manually runs a journey for a user // (POST /api/admin/projects/{projectID}/journeys/{journeyID}/users) func (_ Unimplemented) RunJourneyForUser(w http.ResponseWriter, r *http.Request, projectID openapi_types.UUID, journeyID openapi_types.UUID) { @@ -17289,6 +17461,64 @@ func (siw *ServerInterfaceWrapper) SetJourneySteps(w http.ResponseWriter, r *htt handler.ServeHTTP(w, r) } +// FollowUserJourneyStatus operation middleware +func (siw *ServerInterfaceWrapper) FollowUserJourneyStatus(w http.ResponseWriter, r *http.Request) { + + var err error + + // ------------- Path parameter "projectID" ------------- + var projectID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "projectID", chi.URLParam(r, "projectID"), &projectID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "projectID", Err: err}) + return + } + + // ------------- Path parameter "journeyID" ------------- + var journeyID openapi_types.UUID + + err = runtime.BindStyledParameterWithOptions("simple", "journeyID", chi.URLParam(r, "journeyID"), &journeyID, runtime.BindStyledParameterOptions{ParamLocation: runtime.ParamLocationPath, Explode: false, Required: true}) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "journeyID", Err: err}) + return + } + + ctx := r.Context() + + ctx = context.WithValue(ctx, HttpBearerAuthScopes, []string{}) + + r = r.WithContext(ctx) + + // Parameter object where we will unmarshal all parameters from the context + var params FollowUserJourneyStatusParams + + // ------------- Required query parameter "userID" ------------- + + if paramValue := r.URL.Query().Get("userID"); paramValue != "" { + + } else { + siw.ErrorHandlerFunc(w, r, &RequiredParamError{ParamName: "userID"}) + return + } + + err = runtime.BindQueryParameter("form", true, true, "userID", r.URL.Query(), ¶ms.UserID) + if err != nil { + siw.ErrorHandlerFunc(w, r, &InvalidParamFormatError{ParamName: "userID", Err: err}) + return + } + + handler := http.Handler(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + siw.Handler.FollowUserJourneyStatus(w, r, projectID, journeyID, params) + })) + + for _, middleware := range siw.HandlerMiddlewares { + handler = middleware(handler) + } + + handler.ServeHTTP(w, r) +} + // RunJourneyForUser operation middleware func (siw *ServerInterfaceWrapper) RunJourneyForUser(w http.ResponseWriter, r *http.Request) { @@ -19558,6 +19788,9 @@ func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handl r.Group(func(r chi.Router) { r.Put(options.BaseURL+"/api/admin/projects/{projectID}/journeys/{journeyID}/steps", wrapper.SetJourneySteps) }) + r.Group(func(r chi.Router) { + r.Get(options.BaseURL+"/api/admin/projects/{projectID}/journeys/{journeyID}/users", wrapper.FollowUserJourneyStatus) + }) r.Group(func(r chi.Router) { r.Post(options.BaseURL+"/api/admin/projects/{projectID}/journeys/{journeyID}/users", wrapper.RunJourneyForUser) }) From 435856ebc1aa794707731cbbe74d98b347621e11 Mon Sep 17 00:00:00 2001 From: IAmKirbki Date: Mon, 23 Feb 2026 18:22:21 +0100 Subject: [PATCH 017/230] feat: add UserSelectionModal component for user selection in journeys (Not finished) --- console/pnpm-lock.yaml | 54 +- console/pnpm-workspace.yaml | 3 + console/src/api.ts | 1394 ++++++------ console/src/components/ui/dialog.tsx | 240 +-- console/src/components/ui/scroll-area.tsx | 46 + console/src/views/journey/JourneyEditor.tsx | 1892 +++++++++-------- .../journey/JourneyUserSelectionModal.tsx | 159 ++ 7 files changed, 2110 insertions(+), 1678 deletions(-) create mode 100644 console/pnpm-workspace.yaml create mode 100644 console/src/components/ui/scroll-area.tsx create mode 100644 console/src/views/journey/JourneyUserSelectionModal.tsx diff --git a/console/pnpm-lock.yaml b/console/pnpm-lock.yaml index 43e2cffc..772f3bd6 100644 --- a/console/pnpm-lock.yaml +++ b/console/pnpm-lock.yaml @@ -47,6 +47,9 @@ importers: '@radix-ui/react-popover': specifier: ^1.1.15 version: 1.1.15(@types/react-dom@19.2.3(@types/react@19.2.10))(@types/react@19.2.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@radix-ui/react-scroll-area': + specifier: ^1.2.10 + version: 1.2.10(@types/react-dom@19.2.3(@types/react@19.2.10))(@types/react@19.2.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) '@radix-ui/react-select': specifier: ^2.2.6 version: 2.2.6(@types/react-dom@19.2.3(@types/react@19.2.10))(@types/react@19.2.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -1226,6 +1229,19 @@ packages: '@types/react-dom': optional: true + '@radix-ui/react-scroll-area@1.2.10': + resolution: {integrity: sha512-tAXIa1g3sM5CGpVT0uIbUx/U3Gs5N8T52IICuCtObaos1S8fzsrPXG5WObkQN3S6NVl6wKgPhAIiBGbWnvc97A==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + '@radix-ui/react-select@2.2.6': resolution: {integrity: sha512-I30RydO+bnn2PQztvo25tswPH+wFBjehVGtmagkU78yMdwTwVf12wnAOF+AeP8S2N8xD+5UPbGhkUfPyvT+mwQ==} peerDependencies: @@ -1740,79 +1756,66 @@ packages: resolution: {integrity: sha512-F8sWbhZ7tyuEfsmOxwc2giKDQzN3+kuBLPwwZGyVkLlKGdV1nvnNwYD0fKQ8+XS6hp9nY7B+ZeK01EBUE7aHaw==} cpu: [arm] os: [linux] - libc: [glibc] '@rollup/rollup-linux-arm-musleabihf@4.57.1': resolution: {integrity: sha512-rGfNUfn0GIeXtBP1wL5MnzSj98+PZe/AXaGBCRmT0ts80lU5CATYGxXukeTX39XBKsxzFpEeK+Mrp9faXOlmrw==} cpu: [arm] os: [linux] - libc: [musl] '@rollup/rollup-linux-arm64-gnu@4.57.1': resolution: {integrity: sha512-MMtej3YHWeg/0klK2Qodf3yrNzz6CGjo2UntLvk2RSPlhzgLvYEB3frRvbEF2wRKh1Z2fDIg9KRPe1fawv7C+g==} cpu: [arm64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-arm64-musl@4.57.1': resolution: {integrity: sha512-1a/qhaaOXhqXGpMFMET9VqwZakkljWHLmZOX48R0I/YLbhdxr1m4gtG1Hq7++VhVUmf+L3sTAf9op4JlhQ5u1Q==} cpu: [arm64] os: [linux] - libc: [musl] '@rollup/rollup-linux-loong64-gnu@4.57.1': resolution: {integrity: sha512-QWO6RQTZ/cqYtJMtxhkRkidoNGXc7ERPbZN7dVW5SdURuLeVU7lwKMpo18XdcmpWYd0qsP1bwKPf7DNSUinhvA==} cpu: [loong64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-loong64-musl@4.57.1': resolution: {integrity: sha512-xpObYIf+8gprgWaPP32xiN5RVTi/s5FCR+XMXSKmhfoJjrpRAjCuuqQXyxUa/eJTdAE6eJ+KDKaoEqjZQxh3Gw==} cpu: [loong64] os: [linux] - libc: [musl] '@rollup/rollup-linux-ppc64-gnu@4.57.1': resolution: {integrity: sha512-4BrCgrpZo4hvzMDKRqEaW1zeecScDCR+2nZ86ATLhAoJ5FQ+lbHVD3ttKe74/c7tNT9c6F2viwB3ufwp01Oh2w==} cpu: [ppc64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-ppc64-musl@4.57.1': resolution: {integrity: sha512-NOlUuzesGauESAyEYFSe3QTUguL+lvrN1HtwEEsU2rOwdUDeTMJdO5dUYl/2hKf9jWydJrO9OL/XSSf65R5+Xw==} cpu: [ppc64] os: [linux] - libc: [musl] '@rollup/rollup-linux-riscv64-gnu@4.57.1': resolution: {integrity: sha512-ptA88htVp0AwUUqhVghwDIKlvJMD/fmL/wrQj99PRHFRAG6Z5nbWoWG4o81Nt9FT+IuqUQi+L31ZKAFeJ5Is+A==} cpu: [riscv64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-riscv64-musl@4.57.1': resolution: {integrity: sha512-S51t7aMMTNdmAMPpBg7OOsTdn4tySRQvklmL3RpDRyknk87+Sp3xaumlatU+ppQ+5raY7sSTcC2beGgvhENfuw==} cpu: [riscv64] os: [linux] - libc: [musl] '@rollup/rollup-linux-s390x-gnu@4.57.1': resolution: {integrity: sha512-Bl00OFnVFkL82FHbEqy3k5CUCKH6OEJL54KCyx2oqsmZnFTR8IoNqBF+mjQVcRCT5sB6yOvK8A37LNm/kPJiZg==} cpu: [s390x] os: [linux] - libc: [glibc] '@rollup/rollup-linux-x64-gnu@4.57.1': resolution: {integrity: sha512-ABca4ceT4N+Tv/GtotnWAeXZUZuM/9AQyCyKYyKnpk4yoA7QIAuBt6Hkgpw8kActYlew2mvckXkvx0FfoInnLg==} cpu: [x64] os: [linux] - libc: [glibc] '@rollup/rollup-linux-x64-musl@4.57.1': resolution: {integrity: sha512-HFps0JeGtuOR2convgRRkHCekD7j+gdAuXM+/i6kGzQtFhlCtQkpwtNzkNj6QhCDp7DRJ7+qC/1Vg2jt5iSOFw==} cpu: [x64] os: [linux] - libc: [musl] '@rollup/rollup-openbsd-x64@4.57.1': resolution: {integrity: sha512-H+hXEv9gdVQuDTgnqD+SQffoWoc0Of59AStSzTEj/feWTBAnSfSD3+Dql1ZruJQxmykT/JVY0dE8Ka7z0DH1hw==} @@ -1894,28 +1897,24 @@ packages: engines: {node: '>= 10'} cpu: [arm64] os: [linux] - libc: [glibc] '@tailwindcss/oxide-linux-arm64-musl@4.1.18': resolution: {integrity: sha512-1px92582HkPQlaaCkdRcio71p8bc8i/ap5807tPRDK/uw953cauQBT8c5tVGkOwrHMfc2Yh6UuxaH4vtTjGvHg==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - libc: [musl] '@tailwindcss/oxide-linux-x64-gnu@4.1.18': resolution: {integrity: sha512-v3gyT0ivkfBLoZGF9LyHmts0Isc8jHZyVcbzio6Wpzifg/+5ZJpDiRiUhDLkcr7f/r38SWNe7ucxmGW3j3Kb/g==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - libc: [glibc] '@tailwindcss/oxide-linux-x64-musl@4.1.18': resolution: {integrity: sha512-bhJ2y2OQNlcRwwgOAGMY0xTFStt4/wyU6pvI6LSuZpRgKQwxTec0/3Scu91O8ir7qCR3AuepQKLU/kX99FouqQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - libc: [musl] '@tailwindcss/oxide-wasm32-wasi@4.1.18': resolution: {integrity: sha512-LffYTvPjODiP6PT16oNeUQJzNVyJl1cjIebq/rWWBF+3eDst5JGEFSc5cWxyRCJ0Mxl+KyIkqRxk1XPEs9x8TA==} @@ -3587,28 +3586,24 @@ packages: engines: {node: '>= 12.0.0'} cpu: [arm64] os: [linux] - libc: [glibc] lightningcss-linux-arm64-musl@1.30.2: resolution: {integrity: sha512-5Vh9dGeblpTxWHpOx8iauV02popZDsCYMPIgiuw97OJ5uaDsL86cnqSFs5LZkG3ghHoX5isLgWzMs+eD1YzrnA==} engines: {node: '>= 12.0.0'} cpu: [arm64] os: [linux] - libc: [musl] lightningcss-linux-x64-gnu@1.30.2: resolution: {integrity: sha512-Cfd46gdmj1vQ+lR6VRTTadNHu6ALuw2pKR9lYq4FnhvgBc4zWY1EtZcAc6EffShbb1MFrIPfLDXD6Xprbnni4w==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [linux] - libc: [glibc] lightningcss-linux-x64-musl@1.30.2: resolution: {integrity: sha512-XJaLUUFXb6/QG2lGIW6aIk6jKdtjtcffUT0NKvIqhSBY3hh9Ch+1LCeH80dR9q9LBjG3ewbDjnumefsLsP6aiA==} engines: {node: '>= 12.0.0'} cpu: [x64] os: [linux] - libc: [musl] lightningcss-win32-arm64-msvc@1.30.2: resolution: {integrity: sha512-FZn+vaj7zLv//D/192WFFVA0RgHawIcHqLX9xuWiQt7P0PtdFEVaxgF9rjM/IRYHQXNnk61/H/gb2Ei+kUQ4xQ==} @@ -5933,6 +5928,23 @@ snapshots: '@types/react': 19.2.10 '@types/react-dom': 19.2.3(@types/react@19.2.10) + '@radix-ui/react-scroll-area@1.2.10(@types/react-dom@19.2.3(@types/react@19.2.10))(@types/react@19.2.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': + dependencies: + '@radix-ui/number': 1.1.1 + '@radix-ui/primitive': 1.1.3 + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.2.10)(react@18.3.1) + '@radix-ui/react-context': 1.1.2(@types/react@19.2.10)(react@18.3.1) + '@radix-ui/react-direction': 1.1.1(@types/react@19.2.10)(react@18.3.1) + '@radix-ui/react-presence': 1.1.5(@types/react-dom@19.2.3(@types/react@19.2.10))(@types/react@19.2.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@radix-ui/react-primitive': 2.1.3(@types/react-dom@19.2.3(@types/react@19.2.10))(@types/react@19.2.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + '@radix-ui/react-use-callback-ref': 1.1.1(@types/react@19.2.10)(react@18.3.1) + '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.2.10)(react@18.3.1) + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + optionalDependencies: + '@types/react': 19.2.10 + '@types/react-dom': 19.2.3(@types/react@19.2.10) + '@radix-ui/react-select@2.2.6(@types/react-dom@19.2.3(@types/react@19.2.10))(@types/react@19.2.10)(react-dom@18.3.1(react@18.3.1))(react@18.3.1)': dependencies: '@radix-ui/number': 1.1.1 diff --git a/console/pnpm-workspace.yaml b/console/pnpm-workspace.yaml new file mode 100644 index 00000000..25c0d18a --- /dev/null +++ b/console/pnpm-workspace.yaml @@ -0,0 +1,3 @@ +onlyBuiltDependencies: + - '@clerk/shared' + - esbuild diff --git a/console/src/api.ts b/console/src/api.ts index efa73a82..5d40f8af 100644 --- a/console/src/api.ts +++ b/console/src/api.ts @@ -1,696 +1,698 @@ -import Axios from "axios"; -import { env } from "./config/env"; -import type { - Admin, - AuthDriver, - Campaign, - CampaignCreateParams, - CampaignLaunchParams, - CampaignUpdateParams, - CampaignUser, - Image, - Journey, - JourneyEntranceDetail, - JourneyStepMap, - JourneyUserStep, - List, - ListCreateParams, - ListUpdateParams, - Locale, - Organization, - OrganizationUpdateParams, - Project, - ProjectAdmin, - ProjectAdminInviteParams, - ProjectAdminParams, - ProjectApiKey, - ProjectApiKeyParams, - Provider, - ProviderCreateParams, - ProviderMeta, - ProviderUpdateParams, - Resource, - RulePath, - SearchParams, - SearchResult, - Subscription, - SubscriptionCreateParams, - SubscriptionParams, - SubscriptionUpdateParams, - Tag, - Template, - TemplateCreateParams, - TemplatePreviewParams, - TemplateProofParams, - TemplateUpdateParams, - User, - UserEvent, - UserSubscription, - VariableSuggestions, -} from "./types"; -import type { UUID } from "@/types/common"; - -function appendValue(params: URLSearchParams, name: string, value: unknown) { - if ( - typeof value === "undefined" || - value === null || - typeof value === "function" - ) - return; - if (typeof value === "object") value = JSON.stringify(value); - params.append(name, value + ""); -} - -export const client = Axios.create({ - ...env.api, - paramsSerializer: (params) => { - const s = new URLSearchParams(); - for (const [name, value] of Object.entries(params)) { - if (Array.isArray(value)) { - for (const item of value) { - appendValue(s, name, item); - } - } else { - appendValue(s, name, value); - } - } - return s.toString(); - }, -}); - -client.interceptors.response.use( - (response) => response, - async (error) => { - const isLoginPage = window.location.pathname.startsWith("/login"); - if (error.response.status === 401 && !isLoginPage) { - api.auth.login(); - } - throw error; - }, -); - -export interface NetworkError { - response: { - data: unknown; - status: number; - }; -} - -type OmitFields = - | "id" - | "created_at" - | "updated_at" - | "deleted_at" - | "stats" - | "stats_at"; - -export interface EntityApi { - basePath: string; - search: (params: Partial) => Promise>; - create: (params: Omit) => Promise; - get: (id: UUID | string) => Promise; - update: (id: UUID | string, params: Omit) => Promise; - delete: (id: UUID | string) => Promise; -} - -function createEntityPath(basePath: string): EntityApi { - return { - basePath, - search: async (params) => - await client - .get>(basePath, { params }) - .then((r) => r.data), - create: async (params) => - await client.post(basePath, params).then((r) => r.data), - get: async (id) => - await client.get(`${basePath}/${id}`).then((r) => r.data), - update: async (id, params) => - await client.patch(`${basePath}/${id}`, params).then((r) => r.data), - delete: async (id) => - await client.delete(`${basePath}/${id}`).then((r) => r.data), - }; -} - -export interface ProjectEntityPath< - T, - C = Omit, - U = Omit, -> { - prefix: string; - search: (projectId: UUID, params: SearchParams) => Promise>; - create: (projectId: UUID, params: C) => Promise; - get: (projectId: UUID, id: UUID) => Promise; - update: (projectId: UUID, id: UUID, params: U) => Promise; - delete: (projectId: UUID, id: UUID) => Promise; -} - -const projectUrl = (projectId: UUID) => `/admin/projects/${projectId}`; -export const apiUrl = (projectId: UUID, path: string) => - `${env.api.baseURL}/admin/projects/${projectId}/${path}`; - -function createProjectEntityPath< - T, - C = Omit, - U = Omit, ->(prefix: string): ProjectEntityPath { - return { - prefix, - search: async (projectId, params) => - await client - .get>(`${projectUrl(projectId)}/${prefix}`, { params }) - .then((r) => r.data), - create: async (projectId, params) => - await client - .post(`${projectUrl(projectId)}/${prefix}`, params) - .then((r) => r.data), - get: async (projectId, entityId) => - await client - .get(`${projectUrl(projectId)}/${prefix}/${entityId}`) - .then((r) => r.data), - update: async (projectId, entityId, params) => - await client - .patch(`${projectUrl(projectId)}/${prefix}/${entityId}`, params) - .then((r) => r.data), - delete: async (projectId, entityId) => - await client - .delete(`${projectUrl(projectId)}/${prefix}/${entityId}`) - .then((r) => r.data), - }; -} - -const cache: { - profile: null | Admin; -} = { - profile: null, -}; - -const api = { - auth: { - methods: async () => - await client.get("/auth/methods").then((r) => r.data), - basicAuth: async (email: string, password: string) => { - await client.post("/auth/login/basic/callback", { email, password }); - }, - clerkAuth: async (token: string, redirect: string = "/") => { - await client.post( - "/auth/login/clerk/callback", - { redirect }, - { headers: { Authorization: `Bearer ${token}` } }, - ); - }, - login() { - window.location.href = `/login?r=${encodeURIComponent(window.location.href)}`; - }, - }, - - profile: { - get: async () => { - if (!cache.profile) { - cache.profile = await client - .get("/admin/profile") - .then((r) => r.data); - } - return cache.profile!; - }, - }, - - admins: { - ...createEntityPath("/admin/organizations/admins"), - whoami: async () => - await client - .get("/admin/organizations/whoami") - .then((r) => r.data), - }, - - projects: { - ...createEntityPath("/admin/projects"), - all: async () => - await client - .get>("/admin/projects") - .then((r) => r.data), - pathSuggestions: async (projectId: UUID) => { - let eventSuggestions = await client - .get<{ results: VariableSuggestions['eventPaths'] }>(`${projectUrl(projectId)}/events/schema`) - .then((r) => r.data.results); - - eventSuggestions = eventSuggestions.map((event) => { - event.schema ??= []; - event.schema = event.schema.map((schemaPath) => { - return { - ...schemaPath, - path: `.data${schemaPath.path}` - } - }) - - return event; - }) - - const userSuggestions = await client - .get<{ results: VariableSuggestions['userPaths'] }>(`${projectUrl(projectId)}/users/schema`) - .then((r) => r.data.results); - - return { - eventPaths: eventSuggestions, - userPaths: userSuggestions, - } - } - }, - - data: { - userPaths: { - search: async (projectId: UUID, params: SearchParams) => - await client - .get< - SearchResult - >(`${projectUrl(projectId)}/data/paths/users`, { params }) - .then((r) => r.data), - update: async ( - projectId: UUID, - entityId: UUID, - params: Partial, - ) => - await client - .put( - `${projectUrl(projectId)}/data/paths/users/${entityId}`, - params, - ) - .then((r) => r.data), - }, - rebuild: async (projectId: UUID) => - await client - .post(`${projectUrl(projectId)}/data/paths/sync`) - .then((r) => r.data), - }, - - apiKeys: createProjectEntityPath< - ProjectApiKey, - ProjectApiKeyParams, - Omit - >("keys"), - - campaigns: { - ...createProjectEntityPath< - Campaign, - CampaignCreateParams, - CampaignUpdateParams | CampaignLaunchParams - >("campaigns"), - users: async (projectId: UUID, campaignId: UUID, params: SearchParams) => - await client - .get< - SearchResult - >(`${projectUrl(projectId)}/campaigns/${campaignId}/users`, { params }) - .then((r) => r.data), - duplicate: async (projectId: UUID, campaignId: UUID) => - await client - .post( - `${projectUrl(projectId)}/campaigns/${campaignId}/duplicate`, - ) - .then((r) => r.data), - templates: { - search: async (projectId: UUID, campaignId: UUID, params: SearchParams) => - await client - .get< - SearchResult