diff --git a/Justfile b/Justfile index 886b31d3..8cce2946 100644 --- a/Justfile +++ b/Justfile @@ -12,25 +12,17 @@ lint: tidy: go mod tidy -generate: - openapi-generator-cli generate \ - -i ./membership-swagger.yaml \ - -g go \ - -o ./membershipclient \ - --git-user-id=formancehq \ - --git-repo-id=fctl \ - -p packageVersion=latest \ - -p isGoSubmodule=true \ - -p packageName=membershipclient \ - -p disallowAdditionalPropertiesIfNotPresent=false - rm -rf ./membershipclient/test - rm -rf ./membershipclient/docs +generate: generate-deploy-server-client generate-membership-client + @go generate ./... g: generate [group('generate')] -generate-client: +generate-deploy-server-client: @cd internal/deployserverclient && speakeasy run --skip-versioning +generate-membership-client: + @cd internal/membershipclient && speakeasy run --skip-versioning + tests: echo "not implemented" diff --git a/cmd/auth/clients/create.go b/cmd/auth/clients/create.go index cb217fc6..f659bc00 100644 --- a/cmd/auth/clients/create.go +++ b/cmd/auth/clients/create.go @@ -76,9 +76,18 @@ func (c *CreateController) GetStore() *CreateStore { } func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to create a new OAuth2 client") { + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + if !fctl.CheckStackApprobation(cmd, "You are about to create a new OAuth2 client") { return nil, fctl.ErrMissingApproval } @@ -95,7 +104,7 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab PostLogoutRedirectUris: fctl.GetStringSlice(cmd, c.postLogoutRedirectUriFlag), Scopes: fctl.GetStringSlice(cmd, c.scopes), } - response, err := store.Client().Auth.V1.CreateClient(cmd.Context(), &request) + response, err := stackClient.Auth.V1.CreateClient(cmd.Context(), &request) if err != nil { return nil, err } diff --git a/cmd/auth/clients/delete.go b/cmd/auth/clients/delete.go index 09fea472..3da9bb9d 100644 --- a/cmd/auth/clients/delete.go +++ b/cmd/auth/clients/delete.go @@ -46,16 +46,25 @@ func (c *DeleteController) GetStore() *DeleteStore { } func (c *DeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to delete an OAuth2 client") { + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + if !fctl.CheckStackApprobation(cmd, "You are about to delete an OAuth2 client") { return nil, fctl.ErrMissingApproval } request := operations.DeleteClientRequest{ ClientID: args[0], } - response, err := store.Client().Auth.V1.DeleteClient(cmd.Context(), request) + response, err := stackClient.Auth.V1.DeleteClient(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/auth/clients/list.go b/cmd/auth/clients/list.go index cf7d5c4b..6c99e687 100644 --- a/cmd/auth/clients/list.go +++ b/cmd/auth/clients/list.go @@ -53,9 +53,18 @@ func (c *ListController) GetStore() *ListStore { } func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - clients, err := store.Client().Auth.V1.ListClients(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + clients, err := stackClient.Auth.V1.ListClients(cmd.Context()) if err != nil { return nil, err } diff --git a/cmd/auth/clients/secrets/create.go b/cmd/auth/clients/secrets/create.go index 63552bd7..3094fc19 100644 --- a/cmd/auth/clients/secrets/create.go +++ b/cmd/auth/clients/secrets/create.go @@ -49,9 +49,17 @@ func (c *CreateController) GetStore() *CreateStore { func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to create a new client secret") { + if !fctl.CheckStackApprobation(cmd, "You are about to create a new client secret") { return nil, fctl.ErrMissingApproval } @@ -62,7 +70,7 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab Metadata: nil, }, } - response, err := store.Client().Auth.V1.CreateSecret(cmd.Context(), request) + response, err := stackClient.Auth.V1.CreateSecret(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/auth/clients/secrets/delete.go b/cmd/auth/clients/secrets/delete.go index 96453c05..efc5e9e3 100644 --- a/cmd/auth/clients/secrets/delete.go +++ b/cmd/auth/clients/secrets/delete.go @@ -47,9 +47,17 @@ func (c *DeleteController) GetStore() *DeleteStore { func (c *DeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to delete a client secret") { + if !fctl.CheckStackApprobation(cmd, "You are about to delete a client secret") { return nil, fctl.ErrMissingApproval } @@ -57,7 +65,7 @@ func (c *DeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderab ClientID: args[0], SecretID: args[1], } - response, err := store.Client().Auth.V1.DeleteSecret(cmd.Context(), request) + response, err := stackClient.Auth.V1.DeleteSecret(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/auth/clients/show.go b/cmd/auth/clients/show.go index 6d319ae7..79fbc41f 100644 --- a/cmd/auth/clients/show.go +++ b/cmd/auth/clients/show.go @@ -47,12 +47,21 @@ func (c *ShowController) GetStore() *ShowStore { } func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } request := operations.ReadClientRequest{ ClientID: args[0], } - response, err := store.Client().Auth.V1.ReadClient(cmd.Context(), request) + response, err := stackClient.Auth.V1.ReadClient(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/auth/clients/update.go b/cmd/auth/clients/update.go index 81eaaa67..d34cb562 100644 --- a/cmd/auth/clients/update.go +++ b/cmd/auth/clients/update.go @@ -84,9 +84,17 @@ func (c *UpdateController) GetStore() *UpdateStore { func (c *UpdateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to delete an OAuth2 client") { + if !fctl.CheckStackApprobation(cmd, "You are about to update an OAuth2 client") { return nil, fctl.ErrMissingApproval } @@ -106,7 +114,7 @@ func (c *UpdateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab Scopes: fctl.GetStringSlice(cmd, c.scopes), }, } - response, err := store.Client().Auth.V1.UpdateClient(cmd.Context(), request) + response, err := stackClient.Auth.V1.UpdateClient(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/auth/root.go b/cmd/auth/root.go index 3cb4c1b3..aa8fcdaf 100644 --- a/cmd/auth/root.go +++ b/cmd/auth/root.go @@ -15,8 +15,5 @@ func NewCommand() *cobra.Command { clients.NewCommand(), users.NewCommand(), ), - fctl.WithPersistentPreRunE(func(cmd *cobra.Command, args []string) error { - return fctl.NewStackStore(cmd) - }), ) } diff --git a/cmd/auth/users/list.go b/cmd/auth/users/list.go index eaf398e0..c7b3370b 100644 --- a/cmd/auth/users/list.go +++ b/cmd/auth/users/list.go @@ -50,8 +50,18 @@ func (c *ListController) GetStore() *ListStore { } func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - listUsersResponse, err := store.Client().Auth.V1.ListUsers(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + listUsersResponse, err := stackClient.Auth.V1.ListUsers(cmd.Context()) if err != nil { return nil, err } diff --git a/cmd/auth/users/show.go b/cmd/auth/users/show.go index f663e43e..678de836 100644 --- a/cmd/auth/users/show.go +++ b/cmd/auth/users/show.go @@ -44,12 +44,21 @@ func (c *ShowController) GetStore() *ShowStore { } func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } request := operations.ReadUserRequest{ UserID: args[0], } - readUserResponse, err := store.Client().Auth.V1.ReadUser(cmd.Context(), request) + readUserResponse, err := stackClient.Auth.V1.ReadUser(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/cloud/apps/create.go b/cmd/cloud/apps/create.go index 6d866e58..24aea1c3 100644 --- a/cmd/cloud/apps/create.go +++ b/cmd/cloud/apps/create.go @@ -41,18 +41,24 @@ func (c *CreateCtrl) GetStore() *Create { return c.store } -func (c *CreateCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - cfg, err := fctl.GetConfig(cmd) +func (c *CreateCtrl) Run(cmd *cobra.Command, _ []string) (fctl.Renderable, error) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) if err != nil { return nil, err } - membershipStore := fctl.GetMembershipStore(cmd.Context()) - organizationID, err := fctl.ResolveOrganizationID(cmd, cfg, membershipStore.Client()) + + organizationID, apiClient, err := fctl.NewAppDeployClientFromFlags( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + ) if err != nil { return nil, err } - store := fctl.GetDeployServerStore(cmd.Context()) - apps, err := store.Cli.CreateApp(cmd.Context(), components.CreateAppRequest{ + apps, err := apiClient.CreateApp(cmd.Context(), components.CreateAppRequest{ OrganizationID: organizationID, }) if err != nil { diff --git a/cmd/cloud/apps/delete.go b/cmd/cloud/apps/delete.go index ac63a3fa..617f404c 100644 --- a/cmd/cloud/apps/delete.go +++ b/cmd/cloud/apps/delete.go @@ -42,12 +42,26 @@ func (c *DeleteCtrl) GetStore() *Delete { } func (c *DeleteCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetDeployServerStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + _, apiClient, err := fctl.NewAppDeployClientFromFlags( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + ) + if err != nil { + return nil, err + } id := fctl.GetString(cmd, "id") if id == "" { return nil, fmt.Errorf("id is required") } - _, err := store.Cli.DeleteApp(cmd.Context(), id) + _, err = apiClient.DeleteApp(cmd.Context(), id) if err != nil { return nil, err } diff --git a/cmd/cloud/apps/deploy.go b/cmd/cloud/apps/deploy.go index b5b5404b..2f909c2a 100644 --- a/cmd/cloud/apps/deploy.go +++ b/cmd/cloud/apps/deploy.go @@ -36,11 +36,6 @@ func NewDeployCtrl() *DeployCtrl { } } -const ( - IdFlag = "id" - PathFlag = "path" -) - func NewDeploy() *cobra.Command { return fctl.NewCommand("deploy", fctl.WithShortDescription("Deploy apps"), @@ -56,7 +51,21 @@ func (c *DeployCtrl) GetStore() *Deploy { } func (c *DeployCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetDeployServerStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + _, apiClient, err := fctl.NewAppDeployClientFromFlags( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + ) + if err != nil { + return nil, err + } id := fctl.GetString(cmd, "id") if id == "" { return nil, fmt.Errorf("id is required") @@ -71,7 +80,7 @@ func (c *DeployCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, er } cmd.SilenceUsage = true - deployment, err := store.Cli.DeployAppConfigurationRaw(cmd.Context(), id, data) + deployment, err := apiClient.DeployAppConfigurationRaw(cmd.Context(), id, data) if err != nil { return nil, err } @@ -87,7 +96,22 @@ func (c *DeployCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, er } func (c *DeployCtrl) waitRunCompletion(cmd *cobra.Command) error { - store := fctl.GetDeployServerStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return err + } + + _, apiClient, err := fctl.NewAppDeployClientFromFlags( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + ) + if err != nil { + return err + } spinner := &pterm.DefaultSpinner if s := fctl.GetString(cmd, "output"); s == "plain" { @@ -103,8 +127,10 @@ func (c *DeployCtrl) waitRunCompletion(cmd *cobra.Command) error { }() } else { spinner.SetWriter(io.Discard) - } + defer func() { + _ = spinner.Stop() + }() waitFor := 0 * time.Second for { @@ -113,7 +139,7 @@ func (c *DeployCtrl) waitRunCompletion(cmd *cobra.Command) error { return cmd.Context().Err() case <-time.After(waitFor): waitFor = 2 * time.Second - r, err := store.Cli.ReadRun(cmd.Context(), c.store.ID) + r, err := apiClient.ReadRun(cmd.Context(), c.store.ID) if err != nil { return err } @@ -128,7 +154,7 @@ func (c *DeployCtrl) waitRunCompletion(cmd *cobra.Command) error { spinner.UpdateText("Deployment completed successfully, no changes to apply") return nil case "errored": - l, err := store.Cli.ReadRunLogs(cmd.Context(), c.store.ID) + l, err := apiClient.ReadRunLogs(cmd.Context(), c.store.ID) if err != nil { return err } @@ -152,29 +178,58 @@ func (c *DeployCtrl) Render(cmd *cobra.Command, args []string) error { } pterm.Info.Println("App Deployment accepted", c.store.ID) - store := fctl.GetDeployServerStore(cmd.Context()) + wait := fctl.GetBool(cmd, "wait") + if !wait { + return nil + } + if err := c.waitRunCompletion(cmd); err != nil { + return err + } + + cfg, err := fctl.LoadConfig(cmd) + if err != nil { + return err + } + + profile, profileName, err := fctl.LoadCurrentProfile(cmd, *cfg) + if err != nil { + return err + } + + relyingParty, err := fctl.GetAuthRelyingParty(cmd.Context(), fctl.GetHttpClient(cmd), profile.MembershipURI) + if err != nil { + return err + } + + organizationID, apiClient, err := fctl.NewAppDeployClientFromFlags( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + ) + if err != nil { + return err + } id := fctl.GetString(cmd, "id") - currentStateRes, err := store.Cli.ReadAppCurrentStateVersion(cmd.Context(), id) + currentStateRes, err := apiClient.ReadAppCurrentStateVersion(cmd.Context(), id) if err != nil { return err } if state := currentStateRes.GetReadStateResponse().Data.Stack; state != nil { - cfg, err := fctl.GetConfig(cmd) + + apiClient, err := fctl.NewMembershipClientForOrganization(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile, organizationID) if err != nil { return err } - membershipStore := fctl.GetMembershipStore(cmd.Context()) - organizationID, err := fctl.ResolveOrganizationID(cmd, cfg, membershipStore.Client()) - if err != nil { - return nil - } - info, _, err := membershipStore.Client().GetServerInfo(cmd.Context()).Execute() + + info, err := apiClient.GetServerInfo(cmd.Context()) if err != nil { return err } - if info.ConsoleURL != nil { - pterm.Success.Printfln("View stack in console: %s/%s/%s?region=%s", *info.ConsoleURL, organizationID, state["id"], state["region_id"]) + if info.ServerInfo.ConsoleURL != nil { + pterm.Success.Printfln("View stack in console: %s/%s/%s?region=%s", *info.ServerInfo.ConsoleURL, organizationID, state["id"], state["region_id"]) } } return nil diff --git a/cmd/cloud/apps/list.go b/cmd/cloud/apps/list.go index 8f7c2842..833f9396 100644 --- a/cmd/cloud/apps/list.go +++ b/cmd/cloud/apps/list.go @@ -4,7 +4,7 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/go-libs/pointer" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/fctl/internal/deployserverclient/models/components" fctl "github.com/formancehq/fctl/pkg" @@ -46,20 +46,27 @@ func (c *ListCtrl) GetStore() *List { return c.store } -func (c *ListCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - cfg, err := fctl.GetConfig(cmd) +func (c *ListCtrl) Run(cmd *cobra.Command, _ []string) (fctl.Renderable, error) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) if err != nil { return nil, err } - membershipStore := fctl.GetMembershipStore(cmd.Context()) - organizationID, err := fctl.ResolveOrganizationID(cmd, cfg, membershipStore.Client()) + + pageSize := fctl.GetInt(cmd, "page-size") + page := fctl.GetInt(cmd, "page") + + organizationID, apiClient, err := fctl.NewAppDeployClientFromFlags( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + ) if err != nil { return nil, err } - pageSize := fctl.GetInt(cmd, "page-size") - page := fctl.GetInt(cmd, "page") - store := fctl.GetDeployServerStore(cmd.Context()) - apps, err := store.Cli.ListApps( + apps, err := apiClient.ListApps( cmd.Context(), organizationID, pointer.For(int64(page)), @@ -74,7 +81,7 @@ func (c *ListCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, erro return c, nil } -func (c *ListCtrl) Render(cmd *cobra.Command, args []string) error { +func (c *ListCtrl) Render(cmd *cobra.Command, _ []string) error { data := [][]string{ {"Name", "ID", "Run Status", "Has Configuration Version"}, } @@ -87,7 +94,7 @@ func (c *ListCtrl) Render(cmd *cobra.Command, args []string) error { if w.CurrentRun == nil { return "N/A" } - return string(w.CurrentRun.Status) + return w.CurrentRun.Status }(), func() string { if w.CurrentConfigurationVersion != nil { diff --git a/cmd/cloud/apps/root.go b/cmd/cloud/apps/root.go index 0d7acd79..4d72e2ff 100644 --- a/cmd/cloud/apps/root.go +++ b/cmd/cloud/apps/root.go @@ -15,7 +15,6 @@ func NewCommand() *cobra.Command { cmd := fctl.NewMembershipCommand("apps", fctl.WithShortDescription("* New * Apps manifests management"), fctl.WithPersistentBoolFlag("experimental", false, "Enable experimental commands"), - fctl.WithPersistentStringFlag(fctl.FrameworkURIFlag, "https://deploy-server.staging.formance.cloud", "Framework URI"), fctl.WithPersistentPreRunE(func(cmd *cobra.Command, args []string) error { ok, err := cmd.Flags().GetBool("experimental") if err != nil { @@ -26,10 +25,6 @@ func NewCommand() *cobra.Command { return fmt.Errorf("the apps command is experimental, please use the --experimental flag to enable it") } - if err := fctl.NewDeployServerStore(cmd); err != nil { - return err - } - return nil }), fctl.WithAliases("app"), diff --git a/cmd/cloud/apps/runs/list.go b/cmd/cloud/apps/runs/list.go index 6e7f014b..f7b1d238 100644 --- a/cmd/cloud/apps/runs/list.go +++ b/cmd/cloud/apps/runs/list.go @@ -6,7 +6,7 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/go-libs/pointer" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/fctl/internal/deployserverclient/models/components" fctl "github.com/formancehq/fctl/pkg" @@ -50,12 +50,27 @@ func (c *ListCtrl) GetStore() *List { } func (c *ListCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetDeployServerStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + _, apiClient, err := fctl.NewAppDeployClientFromFlags( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + ) + if err != nil { + return nil, err + } id := fctl.GetString(cmd, "id") if id == "" { return nil, fmt.Errorf("id is required") } - runs, err := store.Cli.ReadAppRuns(cmd.Context(), id, pointer.For(int64(fctl.GetInt(cmd, "page"))), pointer.For(int64(fctl.GetInt(cmd, "page-size")))) + runs, err := apiClient.ReadAppRuns(cmd.Context(), id, pointer.For(int64(fctl.GetInt(cmd, "page"))), pointer.For(int64(fctl.GetInt(cmd, "page-size")))) if err != nil { return nil, err } @@ -74,8 +89,8 @@ func (c *ListCtrl) Render(cmd *cobra.Command, args []string) error { data = append(data, []string{ run.CreatedAt.String(), run.ID, - string(run.ConfigurationVersion.ID), - string(run.Status), + run.ConfigurationVersion.ID, + run.Status, run.Message, }) } diff --git a/cmd/cloud/apps/runs/logs.go b/cmd/cloud/apps/runs/logs.go index a6b06c19..4fff2711 100644 --- a/cmd/cloud/apps/runs/logs.go +++ b/cmd/cloud/apps/runs/logs.go @@ -41,12 +41,27 @@ func (c *LogsCtrl) GetStore() Logs { } func (c *LogsCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetDeployServerStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + _, apiClient, err := fctl.NewAppDeployClientFromFlags( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + ) + if err != nil { + return nil, err + } id := fctl.GetString(cmd, "id") if id == "" { return nil, fmt.Errorf("id is required") } - logs, err := store.Cli.ReadRunLogs(cmd.Context(), id) + logs, err := apiClient.ReadRunLogs(cmd.Context(), id) if err != nil { return nil, err } diff --git a/cmd/cloud/apps/runs/show.go b/cmd/cloud/apps/runs/show.go index f08cc7bc..d0eb6e2e 100644 --- a/cmd/cloud/apps/runs/show.go +++ b/cmd/cloud/apps/runs/show.go @@ -44,13 +44,27 @@ func (c *ShowCtrl) GetStore() *Show { return c.store } -func (c *ShowCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetDeployServerStore(cmd.Context()) +func (c *ShowCtrl) Run(cmd *cobra.Command, _ []string) (fctl.Renderable, error) { + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + _, apiClient, err := fctl.NewAppDeployClientFromFlags( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + ) + if err != nil { + return nil, err + } id := fctl.GetString(cmd, "id") if id == "" { return nil, fmt.Errorf("id is required") } - app, err := store.Cli.ReadRun(cmd.Context(), id) + app, err := apiClient.ReadRun(cmd.Context(), id) if err != nil { return nil, err } diff --git a/cmd/cloud/apps/show.go b/cmd/cloud/apps/show.go index 5074ce11..aa4882cf 100644 --- a/cmd/cloud/apps/show.go +++ b/cmd/cloud/apps/show.go @@ -49,18 +49,32 @@ func (c *ShowCtrl) GetStore() *Show { } func (c *ShowCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetDeployServerStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + _, apiClient, err := fctl.NewAppDeployClientFromFlags( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + ) + if err != nil { + return nil, err + } id := fctl.GetString(cmd, "id") if id == "" { return nil, fmt.Errorf("id is required") } - app, err := store.Cli.ReadApp(cmd.Context(), id) + app, err := apiClient.ReadApp(cmd.Context(), id) if err != nil { return nil, err } c.store.App = app.AppResponse.Data - stateVersion, err := store.Cli.ReadAppCurrentStateVersion(cmd.Context(), id) + stateVersion, err := apiClient.ReadAppCurrentStateVersion(cmd.Context(), id) if err == nil { c.store.State = stateVersion.ReadStateResponse.Data } @@ -71,22 +85,22 @@ func (c *ShowCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, erro func (c *ShowCtrl) Render(cmd *cobra.Command, args []string) error { if c.store.State.Stack != nil { - cfg, err := fctl.GetConfig(cmd) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) if err != nil { return err } - membershipStore := fctl.GetMembershipStore(cmd.Context()) - organizationID, err := fctl.ResolveOrganizationID(cmd, cfg, membershipStore.Client()) + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return err } - info, _, err := membershipStore.Client().GetServerInfo(cmd.Context()).Execute() + info, err := fctl.MembershipServerInfo(cmd.Context(), apiClient) if err != nil { return err } - if info.ConsoleURL != nil { - pterm.Info.Printfln("View stack in console: %s/%s/%s?region=%s", *info.ConsoleURL, organizationID, c.store.State.Stack["id"], c.store.State.Stack["region_id"]) + if consoleURL := info.GetConsoleURL(); consoleURL != nil { + pterm.Info.Printfln("View stack in console: %s/%s/%s?region=%s", *consoleURL, organizationID, c.store.State.Stack["id"], c.store.State.Stack["region_id"]) } } diff --git a/cmd/cloud/apps/variables/create.go b/cmd/cloud/apps/variables/create.go index 84ab650d..6f496d07 100644 --- a/cmd/cloud/apps/variables/create.go +++ b/cmd/cloud/apps/variables/create.go @@ -49,9 +49,23 @@ func (c *CreateCtrl) GetStore() *Create { return c.store } -func (c *CreateCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetDeployServerStore(cmd.Context()) - v, err := store.Cli.CreateAppVariable(cmd.Context(), fctl.GetString(cmd, "id"), components.CreateVariableRequest{ +func (c *CreateCtrl) Run(cmd *cobra.Command, _ []string) (fctl.Renderable, error) { + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + _, apiClient, err := fctl.NewAppDeployClientFromFlags( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + ) + if err != nil { + return nil, err + } + v, err := apiClient.CreateAppVariable(cmd.Context(), fctl.GetString(cmd, "id"), components.CreateVariableRequest{ Variable: components.VariableData{ Key: fctl.GetString(cmd, "key"), Value: fctl.GetString(cmd, "value"), diff --git a/cmd/cloud/apps/variables/delete.go b/cmd/cloud/apps/variables/delete.go index 212845bf..576d1341 100644 --- a/cmd/cloud/apps/variables/delete.go +++ b/cmd/cloud/apps/variables/delete.go @@ -43,7 +43,21 @@ func (c *DeleteCtrl) GetStore() *Delete { } func (c *DeleteCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetDeployServerStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + _, apiClient, err := fctl.NewAppDeployClientFromFlags( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + ) + if err != nil { + return nil, err + } id := fctl.GetString(cmd, "id") if id == "" { return nil, fmt.Errorf("id is required") @@ -52,7 +66,7 @@ func (c *DeleteCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, er if appID == "" { return nil, fmt.Errorf("app-id is required") } - _, err := store.Cli.DeleteAppVariable(cmd.Context(), appID, id) + _, err = apiClient.DeleteAppVariable(cmd.Context(), appID, id) if err != nil { return nil, err } diff --git a/cmd/cloud/apps/variables/list.go b/cmd/cloud/apps/variables/list.go index 4644e214..0a33f87b 100644 --- a/cmd/cloud/apps/variables/list.go +++ b/cmd/cloud/apps/variables/list.go @@ -6,7 +6,7 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/go-libs/pointer" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/fctl/internal/deployserverclient/models/components" fctl "github.com/formancehq/fctl/pkg" @@ -50,13 +50,27 @@ func (c *ListCtrl) GetStore() *List { } func (c *ListCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetDeployServerStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + _, apiClient, err := fctl.NewAppDeployClientFromFlags( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + ) + if err != nil { + return nil, err + } id := fctl.GetString(cmd, "id") if id == "" { return nil, fmt.Errorf("id is required") } - vars, err := store.Cli.ReadAppVariables(cmd.Context(), id, pointer.For(int64(fctl.GetInt(cmd, "page"))), pointer.For(int64(fctl.GetInt(cmd, "page-size")))) + vars, err := apiClient.ReadAppVariables(cmd.Context(), id, pointer.For(int64(fctl.GetInt(cmd, "page"))), pointer.For(int64(fctl.GetInt(cmd, "page-size")))) if err != nil { return nil, err } diff --git a/cmd/cloud/apps/versions/archive.go b/cmd/cloud/apps/versions/archive.go index bb973ebb..2859ae48 100644 --- a/cmd/cloud/apps/versions/archive.go +++ b/cmd/cloud/apps/versions/archive.go @@ -41,12 +41,26 @@ func (c *ArchiveCtrl) GetStore() Archive { } func (c *ArchiveCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetDeployServerStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + _, apiClient, err := fctl.NewAppDeployClientFromFlags( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + ) + if err != nil { + return nil, err + } id := fctl.GetString(cmd, "id") if id == "" { return nil, fmt.Errorf("id is required") } - versions, err := store.Cli.ReadVersion(cmd.Context(), id, operations.WithAcceptHeaderOverride(operations.AcceptHeaderEnumApplicationGzip)) + versions, err := apiClient.ReadVersion(cmd.Context(), id, operations.WithAcceptHeaderOverride(operations.AcceptHeaderEnumApplicationGzip)) if err != nil { return nil, err } diff --git a/cmd/cloud/apps/versions/list.go b/cmd/cloud/apps/versions/list.go index 1774ce3a..3c0491ab 100644 --- a/cmd/cloud/apps/versions/list.go +++ b/cmd/cloud/apps/versions/list.go @@ -7,7 +7,7 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/go-libs/pointer" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/fctl/internal/deployserverclient/models/components" fctl "github.com/formancehq/fctl/pkg" @@ -51,13 +51,27 @@ func (c *ListCtrl) GetStore() *List { } func (c *ListCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetDeployServerStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + _, apiClient, err := fctl.NewAppDeployClientFromFlags( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + ) + if err != nil { + return nil, err + } id := fctl.GetString(cmd, "id") if id == "" { return nil, fmt.Errorf("id is required") } - versions, err := store.Cli.ReadAppVersions(cmd.Context(), id, pointer.For(int64(fctl.GetInt(cmd, "page"))), pointer.For(int64(fctl.GetInt(cmd, "page-size")))) + versions, err := apiClient.ReadAppVersions(cmd.Context(), id, pointer.For(int64(fctl.GetInt(cmd, "page"))), pointer.For(int64(fctl.GetInt(cmd, "page-size")))) if err != nil { return nil, err } diff --git a/cmd/cloud/apps/versions/manifest.go b/cmd/cloud/apps/versions/manifest.go index 37691aaa..9413a4d9 100644 --- a/cmd/cloud/apps/versions/manifest.go +++ b/cmd/cloud/apps/versions/manifest.go @@ -35,12 +35,26 @@ func (c *ManifestCtrl) GetStore() any { } func (c *ManifestCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetDeployServerStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + _, apiClient, err := fctl.NewAppDeployClientFromFlags( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + ) + if err != nil { + return nil, err + } id := fctl.GetString(cmd, "id") if id == "" { return nil, fmt.Errorf("id is required") } - versions, err := store.Cli.ReadVersion(cmd.Context(), id, operations.WithAcceptHeaderOverride(operations.AcceptHeaderEnumApplicationYaml)) + versions, err := apiClient.ReadVersion(cmd.Context(), id, operations.WithAcceptHeaderOverride(operations.AcceptHeaderEnumApplicationYaml)) if err != nil { return nil, err } diff --git a/cmd/cloud/apps/versions/show.go b/cmd/cloud/apps/versions/show.go index 6f3be5cb..f634db39 100644 --- a/cmd/cloud/apps/versions/show.go +++ b/cmd/cloud/apps/versions/show.go @@ -44,13 +44,27 @@ func (c *ShowCtrl) GetStore() *Show { return c.store } -func (c *ShowCtrl) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetDeployServerStore(cmd.Context()) +func (c *ShowCtrl) Run(cmd *cobra.Command, _ []string) (fctl.Renderable, error) { + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + _, apiClient, err := fctl.NewAppDeployClientFromFlags( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + ) + if err != nil { + return nil, err + } id := fctl.GetString(cmd, "id") if id == "" { return nil, fmt.Errorf("id is required") } - version, err := store.Cli.ReadVersion(cmd.Context(), id) + version, err := apiClient.ReadVersion(cmd.Context(), id) if err != nil { return nil, err } diff --git a/cmd/cloud/generate_personal_token.go b/cmd/cloud/generate_personal_token.go index b818b428..c850233b 100644 --- a/cmd/cloud/generate_personal_token.go +++ b/cmd/cloud/generate_personal_token.go @@ -40,22 +40,35 @@ func (c *GeneratePersonalTokenController) GetStore() *GeneratePersonalTokenStore return c.store } -func (c *GeneratePersonalTokenController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { +func (c *GeneratePersonalTokenController) Run(cmd *cobra.Command, _ []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - profile := fctl.GetCurrentProfile(cmd, store.Config) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + organizationID, stackID, err := fctl.ResolveStackID(cmd, *profile) if err != nil { return nil, err } - stack, err := fctl.ResolveStack(cmd, store.Config, organizationID) + access, _, err := fctl.EnsureStackAccess( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + organizationID, + stackID, + ) if err != nil { return nil, err } + stackAccess := profile.RootTokens.ID.Claims. + GetOrganizationAccess(organizationID). + GetStackAccess(stackID) - token, err := profile.GetStackToken(cmd.Context(), fctl.GetHttpClient(cmd, map[string][]string{}), stack) + token, err := fctl.FetchStackToken(cmd.Context(), relyingParty.HttpClient(), stackAccess.URI, access.Token) if err != nil { return nil, err } @@ -65,8 +78,7 @@ func (c *GeneratePersonalTokenController) Run(cmd *cobra.Command, args []string) return c, nil } -func (c *GeneratePersonalTokenController) Render(cmd *cobra.Command, args []string) error { - - fmt.Fprintln(cmd.OutOrStdout(), c.store.Token) +func (c *GeneratePersonalTokenController) Render(cmd *cobra.Command, _ []string) error { + _, _ = fmt.Fprintln(cmd.OutOrStdout(), c.store.Token) return nil } diff --git a/cmd/cloud/me/info.go b/cmd/cloud/me/info.go index 05a78798..ee9fbb3c 100644 --- a/cmd/cloud/me/info.go +++ b/cmd/cloud/me/info.go @@ -42,14 +42,17 @@ func (c *InfoController) GetStore() *InfoStore { return c.store } -func (c *InfoController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - profile := fctl.GetCurrentProfile(cmd, store.Config) +func (c *InfoController) Run(cmd *cobra.Command, _ []string) (fctl.Renderable, error) { + + _, profile, _, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } if !profile.IsConnected() { return nil, errors.New("not logged. use 'login' command before") } - userInfo, err := profile.GetUserInfo(cmd) + userInfo, err := fctl.UserInfo(cmd, relyingParty, profile.RootTokens.Access) if err != nil { return nil, err } diff --git a/cmd/cloud/me/invitations/accept.go b/cmd/cloud/me/invitations/accept.go index 00dcfa21..138c2689 100644 --- a/cmd/cloud/me/invitations/accept.go +++ b/cmd/cloud/me/invitations/accept.go @@ -4,6 +4,7 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -43,12 +44,24 @@ func (c *AcceptController) GetStore() *AcceptStore { func (c *AcceptController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + apiClient, err := fctl.NewMembershipClient(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if !fctl.CheckOrganizationApprobation(cmd, "You are about to accept an invitation") { return nil, fctl.ErrMissingApproval } - _, err := store.Client().AcceptInvitation(cmd.Context(), args[0]).Execute() + request := operations.AcceptInvitationRequest{ + InvitationID: args[0], + } + + _, err = apiClient.AcceptInvitation(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/cloud/me/invitations/decline.go b/cmd/cloud/me/invitations/decline.go index a5e37902..e493e8a9 100644 --- a/cmd/cloud/me/invitations/decline.go +++ b/cmd/cloud/me/invitations/decline.go @@ -4,6 +4,7 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -42,13 +43,26 @@ func (c *DeclineController) GetStore() *DeclineStore { } func (c *DeclineController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + apiClient, err := fctl.NewMembershipClient(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if !fctl.CheckOrganizationApprobation(cmd, "You are about to decline an invitation") { return nil, fctl.ErrMissingApproval } - _, err := store.Client().DeclineInvitation(cmd.Context(), args[0]).Execute() + request := operations.DeclineInvitationRequest{ + InvitationID: args[0], + } + + _, err = apiClient.DeclineInvitation(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/cloud/me/invitations/list.go b/cmd/cloud/me/invitations/list.go index e0b95398..7014705e 100644 --- a/cmd/cloud/me/invitations/list.go +++ b/cmd/cloud/me/invitations/list.go @@ -1,12 +1,14 @@ package invitations import ( + "fmt" "time" "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -57,22 +59,43 @@ func (c *ListController) GetStore() *ListStore { } func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - listInvitationsResponse, _, err := store.Client(). - ListInvitations(cmd.Context()). - Status(fctl.GetString(cmd, c.statusFlag)). - Organization(fctl.GetString(cmd, c.organizationFlag)). - Execute() + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + apiClient, err := fctl.NewMembershipClient(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return nil, err } - c.store.Invitations = fctl.Map(listInvitationsResponse.Data, func(i membershipclient.Invitation) Invitations { + status := fctl.GetString(cmd, c.statusFlag) + organization := fctl.GetString(cmd, c.organizationFlag) + + request := operations.ListInvitationsRequest{} + if status != "" { + request.Status = &status + } + if organization != "" { + request.Organization = &organization + } + + response, err := apiClient.ListInvitations(cmd.Context(), request) + if err != nil { + return nil, err + } + + if response.ListInvitationsResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.Invitations = fctl.Map(response.ListInvitationsResponse.GetData(), func(i components.Invitation) Invitations { return Invitations{ - Id: i.Id, - UserEmail: i.UserEmail, - Status: i.Status, - CreationDate: i.CreationDate, + Id: i.GetID(), + UserEmail: i.GetUserEmail(), + Status: string(i.GetStatus()), + CreationDate: i.GetCreationDate(), } }) diff --git a/cmd/cloud/organizations/applications/list.go b/cmd/cloud/organizations/applications/list.go new file mode 100644 index 00000000..b1b54a1d --- /dev/null +++ b/cmd/cloud/organizations/applications/list.go @@ -0,0 +1,154 @@ +package applications + +import ( + "fmt" + + "github.com/pterm/pterm" + "github.com/spf13/cobra" + + "github.com/formancehq/go-libs/time" + "github.com/formancehq/go-libs/v3/pointer" + + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + fctl "github.com/formancehq/fctl/pkg" +) + +type ListStore struct { + Applications []components.Application `json:"applications"` + Cursor *components.Cursor `json:"cursor"` +} + +type ListController struct { + store *ListStore +} + +var _ fctl.Controller[*ListStore] = (*ListController)(nil) + +func NewDefaultListStore() *ListStore { + return &ListStore{ + Applications: []components.Application{}, + } +} + +func NewListController() *ListController { + return &ListController{ + store: NewDefaultListStore(), + } +} + +func NewListCommand() *cobra.Command { + return fctl.NewCommand(`list`, + fctl.WithAliases("ls", "l"), + fctl.WithShortDescription("List applications available for organization"), + fctl.WithArgs(cobra.ExactArgs(0)), + fctl.WithIntFlag("page", 0, "Page number"), + fctl.WithIntFlag("page-size", 15, "Page size"), + fctl.WithValidArgsFunction(cobra.NoFileCompletions), + fctl.WithController(NewListController()), + ) +} + +func (c *ListController) GetStore() *ListStore { + return c.store +} + +func (c *ListController) Run(cmd *cobra.Command, _ []string) (fctl.Renderable, error) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + page := fctl.GetInt(cmd, "page") + pageSize := fctl.GetInt(cmd, "page-size") + + request := operations.ListOrganizationApplicationsRequest{ + OrganizationID: organizationID, + Page: pointer.For(int64(page)), + PageSize: pointer.For(int64(pageSize)), + } + + response, err := apiClient.ListOrganizationApplications(cmd.Context(), request) + if err != nil { + return nil, err + } + + if response.ListApplicationsResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + cursor := response.ListApplicationsResponse.GetCursor() + if cursor == nil { + return nil, fmt.Errorf("unexpected response: no cursor data") + } + + c.store.Applications = cursor.GetData() + c.store.Cursor = cursor + + return c, nil +} + +func (c *ListController) Render(cmd *cobra.Command, _ []string) error { + if len(c.store.Applications) == 0 { + fmt.Fprintln(cmd.OutOrStdout(), "No applications found.") + return nil + } + + header := []string{"ID", "Name", "Alias", "URL", "Description", "Created At", "Updated At"} + tableData := fctl.Map(c.store.Applications, func(app components.Application) []string { + return []string{ + app.GetID(), + app.GetName(), + app.GetAlias(), + app.GetURL(), + func() string { + if desc := app.GetDescription(); desc != nil { + return *desc + } + return "" + }(), + time.Time{Time: app.GetCreatedAt()}.String(), + time.Time{Time: app.GetUpdatedAt()}.String(), + } + }) + + tableData = fctl.Prepend(tableData, header) + + if err := pterm.DefaultTable. + WithHasHeader(). + WithWriter(cmd.OutOrStdout()). + WithData(tableData). + Render(); err != nil { + return err + } + + // Display cursor information if available + if c.store.Cursor != nil { + cursorInfo := [][]string{ + {"Has More", fctl.BoolToString(c.store.Cursor.GetHasMore())}, + {"Page Size", fmt.Sprintf("%d", c.store.Cursor.GetPageSize())}, + } + if next := c.store.Cursor.GetNext(); next != nil { + cursorInfo = append(cursorInfo, []string{"Next", *next}) + } + if previous := c.store.Cursor.GetPrevious(); previous != nil { + cursorInfo = append(cursorInfo, []string{"Previous", *previous}) + } + + fmt.Fprintln(cmd.OutOrStdout(), "") + if err := pterm.DefaultTable. + WithWriter(cmd.OutOrStdout()). + WithData(cursorInfo). + Render(); err != nil { + return err + } + } + + return nil +} diff --git a/cmd/cloud/organizations/applications/root.go b/cmd/cloud/organizations/applications/root.go new file mode 100644 index 00000000..5c80a5fa --- /dev/null +++ b/cmd/cloud/organizations/applications/root.go @@ -0,0 +1,18 @@ +package applications + +import ( + "github.com/spf13/cobra" + + fctl "github.com/formancehq/fctl/pkg" +) + +func NewCommand() *cobra.Command { + return fctl.NewMembershipCommand("applications", + fctl.WithAliases("apps", "app"), + fctl.WithShortDescription("Applications management"), + fctl.WithChildCommands( + NewListCommand(), + NewShowCommand(), + ), + ) +} diff --git a/cmd/cloud/organizations/applications/show.go b/cmd/cloud/organizations/applications/show.go new file mode 100644 index 00000000..8bc370f7 --- /dev/null +++ b/cmd/cloud/organizations/applications/show.go @@ -0,0 +1,121 @@ +package applications + +import ( + "fmt" + + "github.com/pterm/pterm" + "github.com/spf13/cobra" + + "github.com/formancehq/go-libs/time" + + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + fctl "github.com/formancehq/fctl/pkg" +) + +type ShowStore struct { + Application *components.ApplicationWithScope `json:"application"` +} + +type ShowController struct { + store *ShowStore +} + +var _ fctl.Controller[*ShowStore] = (*ShowController)(nil) + +func NewDefaultShowStore() *ShowStore { + return &ShowStore{} +} + +func NewShowController() *ShowController { + return &ShowController{ + store: NewDefaultShowStore(), + } +} + +func NewShowCommand() *cobra.Command { + return fctl.NewCommand(`show `, + fctl.WithAliases("s", "sh"), + fctl.WithShortDescription("Show application details"), + fctl.WithArgs(cobra.ExactArgs(1)), + fctl.WithValidArgsFunction(cobra.NoFileCompletions), + fctl.WithController(NewShowController()), + ) +} + +func (c *ShowController) GetStore() *ShowStore { + return c.store +} + +func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + request := operations.GetOrganizationApplicationRequest{ + OrganizationID: organizationID, + ApplicationID: args[0], + } + + response, err := apiClient.GetOrganizationApplication(cmd.Context(), request) + if err != nil { + return nil, err + } + + if response.GetApplicationResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.Application = response.GetApplicationResponse.GetData() + + return c, nil +} + +func (c *ShowController) Render(cmd *cobra.Command, _ []string) error { + if c.store.Application == nil { + return fmt.Errorf("no application data") + } + + app := c.store.Application + + data := [][]string{ + {"ID", app.GetID()}, + {"Name", app.GetName()}, + {"Alias", app.GetAlias()}, + {"URL", app.GetURL()}, + {"Description", func() string { + if desc := app.GetDescription(); desc != nil { + return *desc + } + return "" + }()}, + {"Created At", time.Time{Time: app.GetCreatedAt()}.String()}, + {"Updated At", time.Time{Time: app.GetUpdatedAt()}.String()}, + } + + if scopes := app.GetScopes(); len(scopes) > 0 { + data = append(data, []string{"Scopes", ""}) + for _, scope := range scopes { + data = append(data, []string{ + "", + fmt.Sprintf(" - %s (ID: %d)", scope.GetLabel(), scope.GetID()), + }) + if desc := scope.GetDescription(); desc != nil && *desc != "" { + data = append(data, []string{"", fmt.Sprintf(" Description: %s", *desc)}) + } + } + } + + return pterm.DefaultTable. + WithHasHeader(). + WithWriter(cmd.OutOrStdout()). + WithData(data). + Render() +} diff --git a/cmd/cloud/organizations/authentication-provider/configure.go b/cmd/cloud/organizations/authentication-provider/configure.go index 9ec69a52..a243af16 100644 --- a/cmd/cloud/organizations/authentication-provider/configure.go +++ b/cmd/cloud/organizations/authentication-provider/configure.go @@ -6,9 +6,10 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/go-libs/pointer" + "github.com/formancehq/go-libs/v3/pointer" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -48,55 +49,96 @@ func (c *ConfigureController) GetStore() *Configure { func (c *ConfigureController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) if err != nil { return nil, err } - requestData := membershipclient.AuthenticationProviderData{} + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + var requestData components.AuthenticationProviderData switch args[0] { case "github": - requestData.GithubIDPConfig = &membershipclient.GithubIDPConfig{ + config := components.AuthenticationProviderDataGithubIDPConfig{ + Type: components.AuthenticationProviderDataGithubIDPConfigTypeGithub, Name: args[1], ClientID: args[2], ClientSecret: args[3], + Config: components.AuthenticationProviderDataGithubIDPConfigConfig{}, } + requestData = components.CreateAuthenticationProviderDataAuthenticationProviderDataGithubIDPConfig(config) case "google": - requestData.GoogleIDPConfig = &membershipclient.GoogleIDPConfig{ + config := components.AuthenticationProviderDataGoogleIDPConfig{ + Type: components.AuthenticationProviderDataGoogleIDPConfigTypeGoogle, Name: args[1], ClientID: args[2], ClientSecret: args[3], + Config: components.AuthenticationProviderDataGoogleIDPConfigConfig{}, } + requestData = components.CreateAuthenticationProviderDataAuthenticationProviderDataGoogleIDPConfig(config) case "microsoft": - requestData.MicrosoftIDPConfig = &membershipclient.MicrosoftIDPConfig{ + config := components.AuthenticationProviderDataMicrosoftIDPConfig{ + Type: components.AuthenticationProviderDataMicrosoftIDPConfigTypeMicrosoft, Name: args[1], ClientID: args[2], ClientSecret: args[3], - Config: membershipclient.MicrosoftIDPConfigAllOfConfig{ + Config: components.AuthenticationProviderDataMicrosoftIDPConfigConfig{ Tenant: pointer.For(fctl.GetString(cmd, "microsoft-tenant")), }, } + requestData = components.CreateAuthenticationProviderDataAuthenticationProviderDataMicrosoftIDPConfig(config) case "oidc": - requestData.OIDCConfig = &membershipclient.OIDCConfig{ + config := components.AuthenticationProviderDataOIDCConfig{ + Type: components.AuthenticationProviderDataOIDCConfigTypeOidc, Name: args[1], ClientID: args[2], ClientSecret: args[3], - Config: membershipclient.OIDCConfigAllOfConfig{ + Config: components.AuthenticationProviderDataOIDCConfigConfig{ Issuer: fctl.GetString(cmd, "oidc-issuer"), }, } + requestData = components.CreateAuthenticationProviderDataAuthenticationProviderDataOIDCConfig(config) + default: + return nil, fmt.Errorf("unknown provider type: %s", args[0]) } - res, _, err := store.Client(). - UpsertAuthenticationProvider(cmd.Context(), organizationID). - Body(requestData). - Execute() + request := operations.UpsertAuthenticationProviderRequest{ + OrganizationID: organizationID, + Body: &requestData, + } + + response, err := apiClient.UpsertAuthenticationProvider(cmd.Context(), request) if err != nil { return nil, err } - c.store.RedirectURI = res.Data.RedirectURI + + if response.AuthenticationProviderResponse == nil || response.AuthenticationProviderResponse.GetData() == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + data := response.AuthenticationProviderResponse.GetData() + switch data.Type { + case components.DataTypeAuthenticationProviderResponseGithubIDPConfig: + if p := data.AuthenticationProviderResponseGithubIDPConfig; p != nil { + c.store.RedirectURI = p.GetRedirectURI() + } + case components.DataTypeAuthenticationProviderResponseGoogleIDPConfig: + if p := data.AuthenticationProviderResponseGoogleIDPConfig; p != nil { + c.store.RedirectURI = p.GetRedirectURI() + } + case components.DataTypeAuthenticationProviderResponseMicrosoftIDPConfig: + if p := data.AuthenticationProviderResponseMicrosoftIDPConfig; p != nil { + c.store.RedirectURI = p.GetRedirectURI() + } + case components.DataTypeAuthenticationProviderResponseOIDCConfig: + if p := data.AuthenticationProviderResponseOIDCConfig; p != nil { + c.store.RedirectURI = p.GetRedirectURI() + } + } return c, nil } diff --git a/cmd/cloud/organizations/authentication-provider/delete.go b/cmd/cloud/organizations/authentication-provider/delete.go index 0d298bd4..842a72ee 100644 --- a/cmd/cloud/organizations/authentication-provider/delete.go +++ b/cmd/cloud/organizations/authentication-provider/delete.go @@ -4,6 +4,7 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -37,15 +38,21 @@ func (c *DeleteController) GetStore() *Delete { func (c *DeleteController) Run(cmd *cobra.Command, _ []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) if err != nil { return nil, err } - _, err = store.Client(). - DeleteAuthenticationProvider(cmd.Context(), organizationID). - Execute() + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + request := operations.DeleteAuthenticationProviderRequest{ + OrganizationID: organizationID, + } + + _, err = apiClient.DeleteAuthenticationProvider(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/cloud/organizations/authentication-provider/show.go b/cmd/cloud/organizations/authentication-provider/show.go index 540912e6..947c4bfd 100644 --- a/cmd/cloud/organizations/authentication-provider/show.go +++ b/cmd/cloud/organizations/authentication-provider/show.go @@ -1,15 +1,18 @@ package authentication_provider import ( + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) type Show struct { - provider *membershipclient.AuthenticationProviderResponseData + provider *components.Data } type ShowController struct { store *Show @@ -40,32 +43,93 @@ func (c *ShowController) GetStore() *Show { func (c *ShowController) Run(cmd *cobra.Command, _ []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return nil, err } - res, _, err := store.Client(). - ReadAuthenticationProvider(cmd.Context(), organizationID). - Execute() + request := operations.ReadAuthenticationProviderRequest{ + OrganizationID: organizationID, + } + + response, err := apiClient.ReadAuthenticationProvider(cmd.Context(), request) if err != nil { return nil, err } - c.store.provider = res.Data + + if response.AuthenticationProviderResponse == nil || response.AuthenticationProviderResponse.GetData() == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.provider = response.AuthenticationProviderResponse.GetData() return c, nil } func (c *ShowController) Render(_ *cobra.Command, _ []string) error { + var providerType, name, clientID, clientSecret, redirectURI string + var createdAt, updatedAt interface{} + + if c.store.provider == nil { + return fmt.Errorf("no provider data") + } + + switch c.store.provider.Type { + case components.DataTypeAuthenticationProviderResponseGithubIDPConfig: + if p := c.store.provider.AuthenticationProviderResponseGithubIDPConfig; p != nil { + providerType = string(p.GetType()) + name = p.GetName() + clientID = p.GetClientID() + clientSecret = p.GetClientSecret() + createdAt = p.GetCreatedAt() + updatedAt = p.GetUpdatedAt() + redirectURI = p.GetRedirectURI() + } + case components.DataTypeAuthenticationProviderResponseGoogleIDPConfig: + if p := c.store.provider.AuthenticationProviderResponseGoogleIDPConfig; p != nil { + providerType = string(p.GetType()) + name = p.GetName() + clientID = p.GetClientID() + clientSecret = p.GetClientSecret() + createdAt = p.GetCreatedAt() + updatedAt = p.GetUpdatedAt() + redirectURI = p.GetRedirectURI() + } + case components.DataTypeAuthenticationProviderResponseMicrosoftIDPConfig: + if p := c.store.provider.AuthenticationProviderResponseMicrosoftIDPConfig; p != nil { + providerType = string(p.GetType()) + name = p.GetName() + clientID = p.GetClientID() + clientSecret = p.GetClientSecret() + createdAt = p.GetCreatedAt() + updatedAt = p.GetUpdatedAt() + redirectURI = p.GetRedirectURI() + } + case components.DataTypeAuthenticationProviderResponseOIDCConfig: + if p := c.store.provider.AuthenticationProviderResponseOIDCConfig; p != nil { + providerType = string(p.GetType()) + name = p.GetName() + clientID = p.GetClientID() + clientSecret = p.GetClientSecret() + createdAt = p.GetCreatedAt() + updatedAt = p.GetUpdatedAt() + redirectURI = p.GetRedirectURI() + } + } + data := [][]string{ - {"Provider", c.store.provider.Type}, - {"Name", c.store.provider.Name}, - {"Client ID", c.store.provider.ClientID}, - {"Client secret", c.store.provider.ClientSecret}, - {"Created at", c.store.provider.CreatedAt.String()}, - {"Updated at", c.store.provider.UpdatedAt.String()}, - {"Redirect URI", c.store.provider.RedirectURI}, + {"Provider", providerType}, + {"Name", name}, + {"Client ID", clientID}, + {"Client secret", clientSecret}, + {"Created at", fmt.Sprintf("%v", createdAt)}, + {"Updated at", fmt.Sprintf("%v", updatedAt)}, + {"Redirect URI", redirectURI}, } return pterm.DefaultTable.WithHasHeader().WithData(data).Render() } diff --git a/cmd/cloud/organizations/create.go b/cmd/cloud/organizations/create.go index 36146941..ffa3fa46 100644 --- a/cmd/cloud/organizations/create.go +++ b/cmd/cloud/organizations/create.go @@ -1,17 +1,19 @@ package organizations import ( + "fmt" + "github.com/spf13/cobra" - "github.com/formancehq/go-libs/pointer" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/fctl/cmd/cloud/organizations/internal" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" fctl "github.com/formancehq/fctl/pkg" ) type CreateStore struct { - Organization *membershipclient.OrganizationExpanded `json:"organization"` + Organization *components.OrganizationExpanded `json:"organization"` } type CreateController struct { store *CreateStore @@ -35,9 +37,8 @@ func NewCreateCommand() *cobra.Command { fctl.WithShortDescription("Create organization"), fctl.WithArgs(cobra.ExactArgs(1)), fctl.WithValidArgsFunction(cobra.NoFileCompletions), - fctl.WithStringFlag("default-stack-role", "", "Default Stack Role roles: (ADMIN,GUEST,NONE)"), + fctl.WithIntFlag("default-policy-id", 0, "Default policy id"), fctl.WithStringFlag("domain", "", "Organization Domain"), - fctl.WithStringFlag("default-organization-role", "", "Default Organization Role roles: (ADMIN,GUEST)"), fctl.WithConfirmFlag(), fctl.WithController(NewCreateController()), ) @@ -49,39 +50,44 @@ func (c *CreateController) GetStore() *CreateStore { func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + _, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if !fctl.CheckOrganizationApprobation(cmd, "You are about to create a new organization") { return nil, fctl.ErrMissingApproval } - defaultStackRole := fctl.GetString(cmd, "default-stack-role") - defaultOrganizationRole := fctl.GetString(cmd, "default-organization-role") + defaultPolicyID := fctl.GetInt(cmd, "default-policy-id") domain := fctl.GetString(cmd, "domain") - orgData := membershipclient.OrganizationData{ + orgData := components.CreateOrganizationRequest{ Name: args[0], } - if defaultOrganizationRole != "" { - orgData.DefaultOrganizationAccess = membershipclient.Role(defaultOrganizationRole).Ptr() - } - - if defaultStackRole != "" { - orgData.DefaultStackAccess = membershipclient.Role(defaultStackRole).Ptr() + if defaultPolicyID != 0 { + orgData.DefaultPolicyID = pointer.For(int64(defaultPolicyID)) } if domain != "" { orgData.Domain = pointer.For(domain) } - response, _, err := store.Client(). - CreateOrganization(cmd.Context()). - Body(orgData).Execute() + response, err := apiClient.CreateOrganization(cmd.Context(), &orgData) if err != nil { return nil, err } - c.store.Organization = response.Data + if response.CreateOrganizationResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.Organization = response.CreateOrganizationResponse.GetData() return c, nil } diff --git a/cmd/cloud/organizations/delete.go b/cmd/cloud/organizations/delete.go index 3c85059e..754712fc 100644 --- a/cmd/cloud/organizations/delete.go +++ b/cmd/cloud/organizations/delete.go @@ -4,6 +4,7 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -43,14 +44,26 @@ func (c *DeleteController) GetStore() *DeleteStore { } func (c *DeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + apiClient, err := fctl.NewMembershipClientForOrganization(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile, args[0]) + if err != nil { + return nil, err + } if !fctl.CheckOrganizationApprobation(cmd, "You are about to delete an organization") { return nil, fctl.ErrMissingApproval } - _, err := store.Client().DeleteOrganization(cmd.Context(), args[0]). - Execute() + request := operations.DeleteOrganizationRequest{ + OrganizationID: args[0], + } + + _, err = apiClient.DeleteOrganization(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/cloud/organizations/describe.go b/cmd/cloud/organizations/describe.go index 84fda369..9c2e2a3b 100644 --- a/cmd/cloud/organizations/describe.go +++ b/cmd/cloud/organizations/describe.go @@ -1,15 +1,20 @@ package organizations import ( + "fmt" + "github.com/spf13/cobra" + "github.com/formancehq/go-libs/v3/pointer" + "github.com/formancehq/fctl/cmd/cloud/organizations/internal" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) type DescribeStore struct { - *membershipclient.OrganizationExpanded + *components.OrganizationExpanded } type DescribeController struct { store *DescribeStore @@ -44,16 +49,32 @@ func (c *DescribeController) GetStore() *DescribeStore { func (c *DescribeController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + apiClient, err := fctl.NewMembershipClientForOrganization(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile, args[0]) + if err != nil { + return nil, err + } expand := fctl.GetBool(cmd, "expand") - response, _, err := store.Client(). - ReadOrganization(cmd.Context(), args[0]).Expand(expand).Execute() + request := operations.ReadOrganizationRequest{ + OrganizationID: args[0], + Expand: pointer.For(expand), + } + + response, err := apiClient.ReadOrganization(cmd.Context(), request) if err != nil { return nil, err } - c.store.OrganizationExpanded = response.Data + if response.ReadOrganizationResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.OrganizationExpanded = response.ReadOrganizationResponse.GetData() return c, nil } diff --git a/cmd/cloud/organizations/history.go b/cmd/cloud/organizations/history.go index decf850d..354ec84b 100644 --- a/cmd/cloud/organizations/history.go +++ b/cmd/cloud/organizations/history.go @@ -2,11 +2,15 @@ package organizations import ( "errors" + "fmt" "strings" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/go-libs/v3/pointer" + + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" "github.com/formancehq/fctl/pkg/printer" ) @@ -22,7 +26,7 @@ const ( ) type HistoryStore struct { - Cursor *membershipclient.LogCursorData `json:"cursor"` + Cursor *components.LogCursorData `json:"cursor"` } type HistoryController struct { @@ -33,7 +37,7 @@ var _ fctl.Controller[*HistoryStore] = (*HistoryController)(nil) func NewDefaultHistoryStore() *HistoryStore { return &HistoryStore{ - Cursor: &membershipclient.LogCursorData{}, + Cursor: &components.LogCursorData{}, } } func NewHistoryController() *HistoryController { @@ -56,9 +60,6 @@ func NewHistoryCommand() *cobra.Command { fctl.WithStringFlag(cursorFlag, "", "Cursor"), fctl.WithIntFlag(pageSizeFlag, 10, "Page size"), - fctl.WithPreRunE(func(cmd *cobra.Command, args []string) error { - return fctl.CheckMembershipVersion("v0.29.0")(cmd, args) - }), fctl.WithController(NewHistoryController()), ) } @@ -67,33 +68,50 @@ func (c *HistoryController) GetStore() *HistoryStore { } func (c *HistoryController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + apiClient, err := fctl.NewMembershipClientForOrganization(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile, args[0]) + if err != nil { + return nil, err + } pageSize := fctl.GetInt(cmd, pageSizeFlag) orgId := args[0] - req := store.Client().ListLogs(cmd.Context(), orgId).PageSize(int32(pageSize)) cursor := fctl.GetString(cmd, cursorFlag) userID := fctl.GetString(cmd, userIdFlag) action := fctl.GetString(cmd, actionFlag) data := fctl.GetString(cmd, dataFlag) + if cursor != "" { if userID != "" || action != "" || data != "" { return nil, errors.New("cursor can't be used with other flags") } - - req = req.Cursor(cursor) } if orgId == "" && cursor == "" { return nil, errors.New("org-id or cursor is required") } + request := operations.ListLogsRequest{ + OrganizationID: orgId, + PageSize: pointer.For(int64(pageSize)), + } + + if cursor != "" { + request.Cursor = &cursor + } + if userID != "" { - req = req.UserId(userID) + request.UserID = &userID } if action != "" { - req = req.Action(membershipclient.Action(action)) + actionEnum := components.Action(action) + request.Action = &actionEnum } if data != "" { @@ -101,20 +119,21 @@ func (c *HistoryController) Run(cmd *cobra.Command, args []string) (fctl.Rendera if len(keyVal) != 2 { return nil, errors.New("data filter must be in the form key=value") } - - req = req.Key(keyVal[0]).Value(keyVal[1]) + request.Key = &keyVal[0] + request.Value = &keyVal[1] } - log, res, err := req.Execute() + response, err := apiClient.ListLogs(cmd.Context(), request) if err != nil { return nil, err } - if res.StatusCode >= 300 { - return nil, errors.New("error listing stack logs") + if response.LogCursor == nil { + return nil, fmt.Errorf("unexpected response: no data") } - c.store.Cursor = &log.Data + cursorData := response.LogCursor.GetData() + c.store.Cursor = &cursorData return c, nil } diff --git a/cmd/cloud/organizations/internal/print.go b/cmd/cloud/organizations/internal/print.go index 171d4ae5..a2a60a45 100644 --- a/cmd/cloud/organizations/internal/print.go +++ b/cmd/cloud/organizations/internal/print.go @@ -1,49 +1,44 @@ package internal import ( + "fmt" "strconv" "github.com/pterm/pterm" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" ) -func PrintOrganization(store *membershipclient.OrganizationExpanded) error { +func PrintOrganization(organization *components.OrganizationExpanded) error { pterm.DefaultSection.Println("Organization") data := [][]string{ - {"ID", store.Id}, - {"Name", store.Name}, + {"ID", organization.ID}, + {"Name", organization.Name}, {"Domain", func() string { - if store.Domain == nil { + if organization.Domain == nil { return "" } - return *store.Domain + return *organization.Domain }()}, - {"Default Stack Role", func() string { - if store.DefaultStackAccess == nil { + {"Default Policy", func() string { + if organization.DefaultPolicyID == nil { return "None" } - return string(*store.DefaultStackAccess) - }()}, - {"Default Organization Role", func() string { - if store.DefaultOrganizationAccess == nil { - return "None" - } - return string(*store.DefaultOrganizationAccess) + return fmt.Sprintf("%d", *organization.DefaultPolicyID) }()}, } - if store.Owner != nil { - data = append(data, []string{"Owner", store.Owner.Email}) + if organization.Owner != nil { + data = append(data, []string{"Owner", organization.Owner.Email}) } - if store.TotalUsers != nil { - data = append(data, []string{"Total Users", strconv.Itoa(int(*store.TotalUsers))}) + if organization.TotalUsers != nil { + data = append(data, []string{"Total Users", strconv.Itoa(int(*organization.TotalUsers))}) } - if store.TotalStacks != nil { - data = append(data, []string{"Total Stacks", strconv.Itoa(int(*store.TotalStacks))}) + if organization.TotalStacks != nil { + data = append(data, []string{"Total Stacks", strconv.Itoa(int(*organization.TotalStacks))}) } return pterm.DefaultTable.WithHasHeader().WithData(data).Render() diff --git a/cmd/cloud/organizations/invitations/delete.go b/cmd/cloud/organizations/invitations/delete.go index aa9fe62c..7bccf934 100644 --- a/cmd/cloud/organizations/invitations/delete.go +++ b/cmd/cloud/organizations/invitations/delete.go @@ -4,6 +4,7 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -46,9 +47,13 @@ func (c *DeleteController) GetStore() *DeleteStore { } func (c *DeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return nil, err } @@ -57,9 +62,12 @@ func (c *DeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderab return nil, fctl.ErrMissingApproval } - _, err = store.Client(). - DeleteInvitation(cmd.Context(), organizationID, args[0]). - Execute() + request := operations.DeleteInvitationRequest{ + OrganizationID: organizationID, + InvitationID: args[0], + } + + _, err = apiClient.DeleteInvitation(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/cloud/organizations/invitations/list.go b/cmd/cloud/organizations/invitations/list.go index fea4c700..c9ad5c34 100644 --- a/cmd/cloud/organizations/invitations/list.go +++ b/cmd/cloud/organizations/invitations/list.go @@ -1,12 +1,14 @@ package invitations import ( + "fmt" "time" "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -15,7 +17,6 @@ type Invitations struct { UserEmail string `json:"userEmail"` Status string `json:"status"` CreationDate time.Time `json:"creationDate"` - OrgClaim string `json:"orgClaim"` } type ListStore struct { @@ -56,41 +57,53 @@ func (c *ListController) GetStore() *ListStore { } func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return nil, err } - listInvitationsResponse, _, err := store.Client(). - ListOrganizationInvitations(cmd.Context(), organizationID). - Status(fctl.GetString(cmd, c.statusFlag)). - Execute() + status := fctl.GetString(cmd, c.statusFlag) + request := operations.ListOrganizationInvitationsRequest{ + OrganizationID: organizationID, + } + if status != "" { + request.Status = &status + } + + response, err := apiClient.ListOrganizationInvitations(cmd.Context(), request) if err != nil { return nil, err } - c.store.Invitations = fctl.Map(listInvitationsResponse.Data, func(i membershipclient.Invitation) Invitations { + if response.ListInvitationsResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.Invitations = fctl.Map(response.ListInvitationsResponse.GetData(), func(i components.Invitation) Invitations { return Invitations{ - Id: i.Id, - UserEmail: i.UserEmail, - Status: i.Status, - CreationDate: i.CreationDate, - OrgClaim: string(i.Role), + Id: i.GetID(), + UserEmail: i.GetUserEmail(), + Status: string(i.GetStatus()), + CreationDate: i.GetCreationDate(), } }) return c, nil } -func (c *ListController) Render(cmd *cobra.Command, args []string) error { +func (c *ListController) Render(cmd *cobra.Command, _ []string) error { tableData := fctl.Map(c.store.Invitations, func(i Invitations) []string { return []string{ i.Id, i.UserEmail, i.Status, i.CreationDate.Format(time.RFC3339), - i.OrgClaim, } }) diff --git a/cmd/cloud/organizations/invitations/send.go b/cmd/cloud/organizations/invitations/send.go index d9ed3f59..78493b95 100644 --- a/cmd/cloud/organizations/invitations/send.go +++ b/cmd/cloud/organizations/invitations/send.go @@ -1,16 +1,17 @@ package invitations import ( + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) type InvitationSend struct { - Email string `json:"email"` - OrgClaim membershipclient.Role `json:"orgClaim"` + Email string `json:"email"` } type SendStore struct { @@ -39,7 +40,6 @@ func NewSendCommand() *cobra.Command { fctl.WithArgs(cobra.ExactArgs(1)), fctl.WithShortDescription("Invite a user by email"), fctl.WithAliases("s"), - fctl.WithStringFlag("org-claim", "", "Pre assign organization role e.g. 'ADMIN'"), fctl.WithConfirmFlag(), fctl.WithController[*SendStore](NewSendController()), ) @@ -50,9 +50,13 @@ func (c *SendController) GetStore() *SendStore { } func (c *SendController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return nil, err } @@ -61,21 +65,21 @@ func (c *SendController) Run(cmd *cobra.Command, args []string) (fctl.Renderable return nil, fctl.ErrMissingApproval } - invitationClaim := membershipclient.InvitationClaim{} - orgClaimString := fctl.GetString(cmd, "org-claim") - if orgClaimString != "" { - invitationClaim.Role = membershipclient.Role(orgClaimString).Ptr() + request := operations.CreateInvitationRequest{ + OrganizationID: organizationID, + Email: args[0], } - invitations, _, err := store.Client(). - CreateInvitation(cmd.Context(), organizationID). - Email(args[0]).InvitationClaim(invitationClaim).Execute() + response, err := apiClient.CreateInvitation(cmd.Context(), request) if err != nil { return nil, err } - c.store.Invitation.Email = invitations.Data.UserEmail - c.store.Invitation.OrgClaim = invitations.Data.Role + if response.CreateInvitationResponse == nil || response.CreateInvitationResponse.GetData() == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.Invitation.Email = response.CreateInvitationResponse.GetData().GetUserEmail() return c, nil } diff --git a/cmd/cloud/organizations/list.go b/cmd/cloud/organizations/list.go index eb58b7c1..2a01ef4f 100644 --- a/cmd/cloud/organizations/list.go +++ b/cmd/cloud/organizations/list.go @@ -1,10 +1,15 @@ package organizations import ( + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/go-libs/v3/pointer" + + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -51,39 +56,55 @@ func (c *ListController) GetStore() *ListStore { return c.store } -func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) +func (c *ListController) Run(cmd *cobra.Command, _ []string) (fctl.Renderable, error) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + apiClient, err := fctl.NewMembershipClient(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } expand := fctl.GetBool(cmd, "expand") - organizations, _, err := store.Client().ListOrganizations(cmd.Context()).Expand(expand).Execute() + request := operations.ListOrganizationsRequest{ + Expand: pointer.For(expand), + } + + response, err := apiClient.ListOrganizations(cmd.Context(), request) if err != nil { return nil, err } - currentProfile := fctl.GetCurrentProfile(cmd, store.Config) - claims, err := currentProfile.GetClaims() + if response.ListOrganizationExpandedResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + claims, err := profile.GetClaims() if err != nil { return nil, err } - c.store.Organizations = fctl.Map(organizations.Data, func(o membershipclient.OrganizationExpanded) *OrgRow { - isMine := fctl.BoolToString(o.OwnerId == claims["sub"].(string)) + c.store.Organizations = fctl.Map(response.ListOrganizationExpandedResponse.GetData(), func(o components.OrganizationExpanded) *OrgRow { + isMine := fctl.BoolToString(o.GetOwnerID() == claims.Subject) return &OrgRow{ - ID: o.Id, - Name: o.Name, - OwnerID: o.OwnerId, + ID: o.GetID(), + Name: o.GetName(), + OwnerID: o.GetOwnerID(), OwnerEmail: func() string { - if o.Owner == nil { - return "" + if owner := o.GetOwner(); owner != nil { + return owner.GetEmail() } - return o.Owner.Email + return "" }(), Domain: func() string { - if o.Domain == nil { - return "" + if domain := o.GetDomain(); domain != nil { + return *domain } - return *o.Domain + return "" }(), IsMine: isMine, } diff --git a/cmd/cloud/organizations/oauth-clients/create.go b/cmd/cloud/organizations/oauth-clients/create.go index d1e9f413..615bc381 100644 --- a/cmd/cloud/organizations/oauth-clients/create.go +++ b/cmd/cloud/organizations/oauth-clients/create.go @@ -1,11 +1,14 @@ package oauth_clients import ( + "fmt" + "github.com/spf13/cobra" - "github.com/formancehq/go-libs/pointer" + "github.com/formancehq/go-libs/v3/pointer" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -15,7 +18,7 @@ var ( ) type Create struct { - Client membershipclient.OrganizationClient `json:"organizationClient"` + Client components.OrganizationClient `json:"organizationClient"` } type CreateController struct { store *Create @@ -49,15 +52,18 @@ func (c *CreateController) GetStore() *Create { func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - if !fctl.CheckOrganizationApprobation(cmd, "You are about to create a new organization OAuth client") { - return nil, fctl.ErrMissingApproval + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err } - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return nil, err } + if !fctl.CheckOrganizationApprobation(cmd, "You are about to create a new organization OAuth client") { + return nil, fctl.ErrMissingApproval + } description, err := cmd.Flags().GetString(descriptionFlag) if err != nil { @@ -69,8 +75,7 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab return nil, err } - req := store.Client().OrganizationClientCreate(cmd.Context(), organizationID) - reqBody := membershipclient.CreateOrganizationClientRequest{} + reqBody := components.CreateOrganizationClientRequest{} if description != "" { reqBody.Description = pointer.For(description) } @@ -79,16 +84,21 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab reqBody.Name = pointer.For(name) } - if description != "" || name != "" { - req = req.CreateOrganizationClientRequest(reqBody) + request := operations.OrganizationClientCreateRequest{ + OrganizationID: organizationID, + Body: &reqBody, } - response, _, err := req.Execute() + response, err := apiClient.OrganizationClientCreate(cmd.Context(), request) if err != nil { return nil, err } - c.store.Client = response.Data + if response.CreateOrganizationClientResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.Client = response.CreateOrganizationClientResponse.GetData() return c, nil } diff --git a/cmd/cloud/organizations/oauth-clients/delete.go b/cmd/cloud/organizations/oauth-clients/delete.go index 3135f899..4ca8b64a 100644 --- a/cmd/cloud/organizations/oauth-clients/delete.go +++ b/cmd/cloud/organizations/oauth-clients/delete.go @@ -4,6 +4,7 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -38,22 +39,31 @@ func (c *DeleteController) GetStore() *Delete { } func (c *DeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - if !fctl.CheckOrganizationApprobation(cmd, "You are about to delete an OAuth client") { - return nil, fctl.ErrMissingApproval + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err } - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return nil, err } + if !fctl.CheckOrganizationApprobation(cmd, "You are about to delete an OAuth client") { + return nil, fctl.ErrMissingApproval + } clientID := args[0] if clientID == "" { return nil, ErrMissingClientID } - _, err = store.Client().OrganizationClientDelete(cmd.Context(), organizationID, clientID).Execute() + request := operations.OrganizationClientDeleteRequest{ + OrganizationID: organizationID, + ClientID: clientID, + } + + _, err = apiClient.OrganizationClientDelete(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/cloud/organizations/oauth-clients/list.go b/cmd/cloud/organizations/oauth-clients/list.go index fc83494a..f916116e 100644 --- a/cmd/cloud/organizations/oauth-clients/list.go +++ b/cmd/cloud/organizations/oauth-clients/list.go @@ -1,14 +1,17 @@ package oauth_clients import ( + "fmt" + "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) type List struct { - Cursor membershipclient.ReadOrganizationClientsResponseData `json:"cursor"` + Cursor components.ReadOrganizationClientsResponseData `json:"cursor"` } type ListController struct { @@ -41,21 +44,20 @@ func (c *ListController) GetStore() *List { } func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) if err != nil { return nil, err } - req := store.Client().OrganizationClientsRead(cmd.Context(), organizationID) - - pageSize, err := fctl.GetPageSize(cmd) + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return nil, err } - if pageSize > 0 { - req = req.PageSize(pageSize) + pageSize, err := fctl.GetPageSize(cmd) + if err != nil { + return nil, err } cursor, err := fctl.GetCursor(cmd) @@ -63,16 +65,29 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable return nil, err } + request := operations.OrganizationClientsReadRequest{ + OrganizationID: organizationID, + } + + if pageSize > 0 { + pageSizeInt64 := int64(pageSize) + request.PageSize = &pageSizeInt64 + } + if cursor != "" { - req = req.Cursor(cursor) + request.Cursor = &cursor } - response, _, err := req.Execute() + response, err := apiClient.OrganizationClientsRead(cmd.Context(), request) if err != nil { return nil, err } - c.store.Cursor = response.Data + if response.ReadOrganizationClientsResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.Cursor = response.ReadOrganizationClientsResponse.GetData() return c, nil } diff --git a/cmd/cloud/organizations/oauth-clients/print.go b/cmd/cloud/organizations/oauth-clients/print.go index 794913ea..f71a9f07 100644 --- a/cmd/cloud/organizations/oauth-clients/print.go +++ b/cmd/cloud/organizations/oauth-clients/print.go @@ -6,40 +6,52 @@ import ( "github.com/pterm/pterm" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" fctl "github.com/formancehq/fctl/pkg" ) -func onCreateShow(writer io.Writer, client membershipclient.OrganizationClient) error { +func onCreateShow(writer io.Writer, client components.OrganizationClient) error { data := [][]string{ - {"Client ID", fmt.Sprintf("organization_%s", client.Id)}, - {"Name", client.Name}, - {"Secret", *client.Secret.Clear}, - {"Secret last digits", client.Secret.LastDigits}, - {"Description", client.Description}, - {"CreatedAt", client.CreatedAt.String()}, + {"Client ID", fmt.Sprintf("organization_%s", client.GetID())}, + {"Name", client.GetName()}, + {"Secret", func() string { + secret := client.GetSecret() + if clear := secret.GetClear(); clear != nil { + return *clear + } + return "" + }()}, + {"Secret last digits", func() string { + secret := client.GetSecret() + return secret.GetLastDigits() + }()}, + {"Description", client.GetDescription()}, + {"CreatedAt", client.GetCreatedAt().String()}, } return pterm.DefaultTable.WithHasHeader().WithWriter(writer).WithData(data).Render() } -func showOrganizationClient(writer io.Writer, client membershipclient.OrganizationClient) error { +func showOrganizationClient(writer io.Writer, client components.OrganizationClient) error { data := [][]string{ - {"Client ID", fmt.Sprintf("organization_%s", client.Id)}, - {"Name", client.Name}, - {"Secret last digits", client.Secret.LastDigits}, - {"Description", client.Description}, - {"CreatedAt", client.CreatedAt.String()}, - {"UpdatedAt", client.UpdatedAt.String()}, + {"Client ID", fmt.Sprintf("organization_%s", client.GetID())}, + {"Name", client.GetName()}, + {"Secret last digits", func() string { + secret := client.GetSecret() + return secret.GetLastDigits() + }()}, + {"Description", client.GetDescription()}, + {"CreatedAt", client.GetCreatedAt().String()}, + {"UpdatedAt", client.GetUpdatedAt().String()}, } return pterm.DefaultTable.WithHasHeader().WithWriter(writer).WithData(data).Render() } -func showOrganizationClients(writer io.Writer, clientsCursor membershipclient.ReadOrganizationClientsResponseData) error { +func showOrganizationClients(writer io.Writer, clientsCursor components.ReadOrganizationClientsResponseData) error { cursor := fctl.Cursor{ - HasMore: clientsCursor.HasMore, - PageSize: clientsCursor.PageSize, - Next: clientsCursor.Next, - Previous: clientsCursor.Previous, + HasMore: clientsCursor.GetHasMore(), + PageSize: clientsCursor.GetPageSize(), + Next: clientsCursor.GetNext(), + Previous: clientsCursor.GetPrevious(), } if err := fctl.RenderCursor(writer, cursor); err != nil { @@ -49,14 +61,15 @@ func showOrganizationClients(writer io.Writer, clientsCursor membershipclient.Re data := [][]string{ {"Client ID", "Name", "Secret last digits", "Description", "CreatedAt", "UpdatedAt"}, } - for _, client := range clientsCursor.Data { + for _, client := range clientsCursor.GetData() { + secret := client.GetSecret() data = append(data, []string{ - fmt.Sprintf("organization_%s", client.Id), - client.Name, - client.Secret.LastDigits, - client.Description, - client.CreatedAt.String(), - client.UpdatedAt.String(), + fmt.Sprintf("organization_%s", client.GetID()), + client.GetName(), + secret.GetLastDigits(), + client.GetDescription(), + client.GetCreatedAt().String(), + client.GetUpdatedAt().String(), }) } return pterm.DefaultTable.WithHasHeader().WithWriter(writer).WithData(data).Render() diff --git a/cmd/cloud/organizations/oauth-clients/show.go b/cmd/cloud/organizations/oauth-clients/show.go index 560fddb2..02d0da46 100644 --- a/cmd/cloud/organizations/oauth-clients/show.go +++ b/cmd/cloud/organizations/oauth-clients/show.go @@ -1,14 +1,17 @@ package oauth_clients import ( + "fmt" + "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) type Show struct { - Client membershipclient.OrganizationClient `json:"organizationClient"` + Client components.OrganizationClient `json:"organizationClient"` } type ShowController struct { store *Show @@ -40,8 +43,12 @@ func (c *ShowController) GetStore() *Show { func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return nil, err } @@ -51,12 +58,21 @@ func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable return nil, ErrMissingClientID } - response, _, err := store.Client().OrganizationClientRead(cmd.Context(), organizationID, clientID).Execute() + request := operations.OrganizationClientReadRequest{ + OrganizationID: organizationID, + ClientID: clientID, + } + + response, err := apiClient.OrganizationClientRead(cmd.Context(), request) if err != nil { return nil, err } - c.store.Client = response.Data + if response.ReadOrganizationClientResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.Client = response.ReadOrganizationClientResponse.GetData() return c, nil } diff --git a/cmd/cloud/organizations/oauth-clients/update.go b/cmd/cloud/organizations/oauth-clients/update.go index 7bc86814..18512bfc 100644 --- a/cmd/cloud/organizations/oauth-clients/update.go +++ b/cmd/cloud/organizations/oauth-clients/update.go @@ -6,14 +6,15 @@ import ( "github.com/spf13/cobra" - "github.com/formancehq/go-libs/pointer" + "github.com/formancehq/go-libs/v3/pointer" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) type Update struct { - Client membershipclient.OrganizationClient `json:"organizationClient"` + Client components.OrganizationClient `json:"organizationClient"` } type UpdateController struct { store *Update @@ -66,46 +67,69 @@ func (c *UpdateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab return nil, fmt.Errorf("invalid client_id: %s", args[0]) } - store := fctl.GetMembershipStore(cmd.Context()) - if !fctl.CheckOrganizationApprobation(cmd, "You are about to update an existing organization OAuth client") { - return nil, fctl.ErrMissingApproval + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err } - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return nil, err } + if !fctl.CheckOrganizationApprobation(cmd, "You are about to update an existing organization OAuth client") { + return nil, fctl.ErrMissingApproval + } - actualClient, _, err := store.Client().OrganizationClientRead(cmd.Context(), organizationID, clientId).Execute() + readRequest := operations.OrganizationClientReadRequest{ + OrganizationID: organizationID, + ClientID: clientId, + } + + actualClientResponse, err := apiClient.OrganizationClientRead(cmd.Context(), readRequest) if err != nil { return nil, fmt.Errorf("failed to read organization client: %w", err) } - req := store.Client().OrganizationClientUpdate(cmd.Context(), organizationID, clientId) - reqBody := membershipclient.UpdateOrganizationClientRequest{} + if actualClientResponse.ReadOrganizationClientResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + actualClient := actualClientResponse.ReadOrganizationClientResponse.GetData() + + reqBody := components.UpdateOrganizationClientRequest{} if description != "" { reqBody.Description = pointer.For(description) } else { - reqBody.Description = pointer.For(actualClient.Data.Description) + reqBody.Description = pointer.For(actualClient.GetDescription()) } if name != "" { reqBody.Name = name } else { - reqBody.Name = actualClient.Data.Name + reqBody.Name = actualClient.GetName() } - req = req.UpdateOrganizationClientRequest(reqBody) - _, err = req.Execute() + updateRequest := operations.OrganizationClientUpdateRequest{ + OrganizationID: organizationID, + ClientID: clientId, + Body: &reqBody, + } + + _, err = apiClient.OrganizationClientUpdate(cmd.Context(), updateRequest) if err != nil { return nil, err } - updatedClient, _, err := store.Client().OrganizationClientRead(cmd.Context(), organizationID, clientId).Execute() + updatedClientResponse, err := apiClient.OrganizationClientRead(cmd.Context(), readRequest) if err != nil { return nil, fmt.Errorf("failed to read organization client: %w", err) } - c.store.Client = updatedClient.Data + if updatedClientResponse.ReadOrganizationClientResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.Client = updatedClientResponse.ReadOrganizationClientResponse.GetData() return c, nil } diff --git a/cmd/cloud/organizations/oauth/create.go b/cmd/cloud/organizations/oauth/create.go deleted file mode 100644 index 33d6c677..00000000 --- a/cmd/cloud/organizations/oauth/create.go +++ /dev/null @@ -1,74 +0,0 @@ -package oauth - -import ( - "fmt" - - "github.com/pterm/pterm" - "github.com/spf13/cobra" - - "github.com/formancehq/fctl/membershipclient" - fctl "github.com/formancehq/fctl/pkg" -) - -type Create struct { - Organization *membershipclient.CreateClientResponseResponse `json:"organization"` -} -type CreateController struct { - store *Create -} - -var _ fctl.Controller[*Create] = (*CreateController)(nil) - -func NewDefaultCreate() *Create { - return &Create{} -} - -func NewCreateController() *CreateController { - return &CreateController{ - store: NewDefaultCreate(), - } -} - -func NewCreateCommand() *cobra.Command { - return fctl.NewCommand(`create`, - fctl.WithShortDescription("Create organization OAuth client"), - fctl.WithConfirmFlag(), - fctl.WithDeprecated("Use `fctl cloud organizations clients create` instead"), - fctl.WithController(NewCreateController()), - ) -} - -func (c *CreateController) GetStore() *Create { - return c.store -} - -func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - - store := fctl.GetMembershipStore(cmd.Context()) - if !fctl.CheckOrganizationApprobation(cmd, "You are about to create a new organization OAuth client") { - return nil, fctl.ErrMissingApproval - } - - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) - if err != nil { - return nil, err - } - - response, _, err := store.Client().CreateOrganizationClient(cmd.Context(), organizationID).Execute() - if err != nil { - return nil, err - } - - c.store.Organization = response - - return c, nil -} - -func (c *CreateController) Render(cmd *cobra.Command, args []string) error { - data := [][]string{ - {"Client ID", fmt.Sprintf("organization_%s", c.store.Organization.Data.Id)}, - {"Client Secret", *c.store.Organization.Data.Secret.Clear}, - } - - return pterm.DefaultTable.WithHasHeader().WithData(data).Render() -} diff --git a/cmd/cloud/organizations/oauth/delete.go b/cmd/cloud/organizations/oauth/delete.go deleted file mode 100644 index 24531611..00000000 --- a/cmd/cloud/organizations/oauth/delete.go +++ /dev/null @@ -1,62 +0,0 @@ -package oauth - -import ( - "github.com/pterm/pterm" - "github.com/spf13/cobra" - - fctl "github.com/formancehq/fctl/pkg" -) - -type Delete struct{} -type DeleteController struct { - store *Delete -} - -var _ fctl.Controller[*Delete] = (*DeleteController)(nil) - -func NewDefaultDelete() *Delete { - return &Delete{} -} - -func NewDeleteController() *DeleteController { - return &DeleteController{ - store: NewDefaultDelete(), - } -} - -func NewDeleteCommand() *cobra.Command { - return fctl.NewCommand(`delete`, - fctl.WithShortDescription("Delete organization OAuth client"), - fctl.WithConfirmFlag(), - fctl.WithDeprecated("Use `fctl cloud organizations clients delete` instead"), - fctl.WithController(NewDeleteController()), - ) -} - -func (c *DeleteController) GetStore() *Delete { - return c.store -} - -func (c *DeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - if !fctl.CheckOrganizationApprobation(cmd, "You are about to delete a new organization OAuth client") { - return nil, fctl.ErrMissingApproval - } - - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) - if err != nil { - return nil, err - } - - _, err = store.Client().DeleteOrganizationClient(cmd.Context(), organizationID).Execute() - if err != nil { - return nil, err - } - - return c, nil -} - -func (c *DeleteController) Render(cmd *cobra.Command, args []string) error { - pterm.Success.Println("Organization client deleted successfully") - return nil -} diff --git a/cmd/cloud/organizations/oauth/show.go b/cmd/cloud/organizations/oauth/show.go deleted file mode 100644 index 8bbed5e5..00000000 --- a/cmd/cloud/organizations/oauth/show.go +++ /dev/null @@ -1,69 +0,0 @@ -package oauth - -import ( - "fmt" - - "github.com/pterm/pterm" - "github.com/spf13/cobra" - - "github.com/formancehq/fctl/membershipclient" - fctl "github.com/formancehq/fctl/pkg" -) - -type Show struct { - Organization *membershipclient.CreateClientResponseResponse `json:"organization"` -} -type ShowController struct { - store *Show -} - -var _ fctl.Controller[*Show] = (*ShowController)(nil) - -func NewDefaultShow() *Show { - return &Show{} -} - -func NewShowController() *ShowController { - return &ShowController{ - store: NewDefaultShow(), - } -} - -func NewShowCommand() *cobra.Command { - return fctl.NewCommand(`show`, - fctl.WithShortDescription("Show organization OAuth client"), - fctl.WithDeprecated("Use `fctl cloud organizations clients show` instead"), - fctl.WithController(NewShowController()), - ) -} - -func (c *ShowController) GetStore() *Show { - return c.store -} - -func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - - store := fctl.GetMembershipStore(cmd.Context()) - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) - if err != nil { - return nil, err - } - - response, _, err := store.Client().ReadOrganizationClient(cmd.Context(), organizationID).Execute() - if err != nil { - return nil, err - } - - c.store.Organization = response - - return c, nil -} - -func (c *ShowController) Render(cmd *cobra.Command, args []string) error { - data := [][]string{ - {"Client ID", fmt.Sprintf("organization_%s", c.store.Organization.Data.Id)}, - {"Client Last Digits", c.store.Organization.Data.Secret.LastDigits}, - } - - return pterm.DefaultTable.WithHasHeader().WithData(data).Render() -} diff --git a/cmd/cloud/organizations/policies/add-scope.go b/cmd/cloud/organizations/policies/add-scope.go new file mode 100644 index 00000000..768cf406 --- /dev/null +++ b/cmd/cloud/organizations/policies/add-scope.go @@ -0,0 +1,94 @@ +package policies + +import ( + "fmt" + "strconv" + + "github.com/pterm/pterm" + "github.com/spf13/cobra" + + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + fctl "github.com/formancehq/fctl/pkg" +) + +type AddScopeStore struct { + Success bool `json:"success"` +} + +type AddScopeController struct { + store *AddScopeStore +} + +var _ fctl.Controller[*AddScopeStore] = (*AddScopeController)(nil) + +func NewDefaultAddScopeStore() *AddScopeStore { + return &AddScopeStore{} +} + +func NewAddScopeController() *AddScopeController { + return &AddScopeController{ + store: NewDefaultAddScopeStore(), + } +} + +func NewAddScopeCommand() *cobra.Command { + return fctl.NewCommand(`add-scope `, + fctl.WithAliases("add", "a"), + fctl.WithShortDescription("Add a scope to a policy"), + fctl.WithArgs(cobra.ExactArgs(2)), + fctl.WithConfirmFlag(), + fctl.WithValidArgsFunction(cobra.NoFileCompletions), + fctl.WithController(NewAddScopeController()), + ) +} + +func (c *AddScopeController) GetStore() *AddScopeStore { + return c.store +} + +func (c *AddScopeController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + policyID, err := strconv.ParseInt(args[0], 10, 64) + if err != nil { + return nil, fmt.Errorf("invalid policy ID: %w", err) + } + + scopeID, err := strconv.ParseInt(args[1], 10, 64) + if err != nil { + return nil, fmt.Errorf("invalid scope ID: %w", err) + } + + if !fctl.CheckOrganizationApprobation(cmd, "You are about to add a scope to a policy") { + return nil, fctl.ErrMissingApproval + } + + request := operations.AddScopeToPolicyRequest{ + OrganizationID: organizationID, + PolicyID: policyID, + ScopeID: scopeID, + } + + _, err = apiClient.AddScopeToPolicy(cmd.Context(), request) + if err != nil { + return nil, err + } + + c.store.Success = true + + return c, nil +} + +func (c *AddScopeController) Render(_ *cobra.Command, _ []string) error { + pterm.Success.Println("Scope added to policy successfully") + return nil +} diff --git a/cmd/cloud/organizations/policies/create.go b/cmd/cloud/organizations/policies/create.go new file mode 100644 index 00000000..13fb62ba --- /dev/null +++ b/cmd/cloud/organizations/policies/create.go @@ -0,0 +1,98 @@ +package policies + +import ( + "fmt" + + "github.com/pterm/pterm" + "github.com/spf13/cobra" + + "github.com/formancehq/go-libs/v3/pointer" + + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + fctl "github.com/formancehq/fctl/pkg" +) + +type CreateStore struct { + Policy *components.Policy `json:"policy"` +} + +type CreateController struct { + store *CreateStore +} + +var _ fctl.Controller[*CreateStore] = (*CreateController)(nil) + +func NewDefaultCreateStore() *CreateStore { + return &CreateStore{} +} + +func NewCreateController() *CreateController { + return &CreateController{ + store: NewDefaultCreateStore(), + } +} + +func NewCreateCommand() *cobra.Command { + return fctl.NewCommand(`create `, + fctl.WithAliases("c", "cr"), + fctl.WithShortDescription("Create a policy"), + fctl.WithArgs(cobra.ExactArgs(1)), + fctl.WithStringFlag("description", "", "Policy description"), + fctl.WithConfirmFlag(), + fctl.WithValidArgsFunction(cobra.NoFileCompletions), + fctl.WithController(NewCreateController()), + ) +} + +func (c *CreateController) GetStore() *CreateStore { + return c.store +} + +func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + if !fctl.CheckOrganizationApprobation(cmd, "You are about to create a new policy") { + return nil, fctl.ErrMissingApproval + } + + description := fctl.GetString(cmd, "description") + policyData := components.PolicyData{ + Name: args[0], + } + if description != "" { + policyData.Description = pointer.For(description) + } + + request := operations.CreatePolicyRequest{ + OrganizationID: organizationID, + Body: &policyData, + } + + response, err := apiClient.CreatePolicy(cmd.Context(), request) + if err != nil { + return nil, err + } + + if response.CreatePolicyResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.Policy = response.CreatePolicyResponse.GetData() + + return c, nil +} + +func (c *CreateController) Render(_ *cobra.Command, _ []string) error { + pterm.Success.Println("Policy created successfully") + return nil +} diff --git a/cmd/cloud/organizations/policies/delete.go b/cmd/cloud/organizations/policies/delete.go new file mode 100644 index 00000000..bbb96b24 --- /dev/null +++ b/cmd/cloud/organizations/policies/delete.go @@ -0,0 +1,88 @@ +package policies + +import ( + "fmt" + "strconv" + + "github.com/pterm/pterm" + "github.com/spf13/cobra" + + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + fctl "github.com/formancehq/fctl/pkg" +) + +type DeleteStore struct { + Success bool `json:"success"` +} + +type DeleteController struct { + store *DeleteStore +} + +var _ fctl.Controller[*DeleteStore] = (*DeleteController)(nil) + +func NewDefaultDeleteStore() *DeleteStore { + return &DeleteStore{} +} + +func NewDeleteController() *DeleteController { + return &DeleteController{ + store: NewDefaultDeleteStore(), + } +} + +func NewDeleteCommand() *cobra.Command { + return fctl.NewCommand(`delete `, + fctl.WithAliases("del", "d"), + fctl.WithShortDescription("Delete a policy"), + fctl.WithArgs(cobra.ExactArgs(1)), + fctl.WithConfirmFlag(), + fctl.WithValidArgsFunction(cobra.NoFileCompletions), + fctl.WithController(NewDeleteController()), + ) +} + +func (c *DeleteController) GetStore() *DeleteStore { + return c.store +} + +func (c *DeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + policyID, err := strconv.ParseInt(args[0], 10, 64) + if err != nil { + return nil, fmt.Errorf("invalid policy ID: %w", err) + } + + if !fctl.CheckOrganizationApprobation(cmd, "You are about to delete a policy") { + return nil, fctl.ErrMissingApproval + } + + request := operations.DeletePolicyRequest{ + OrganizationID: organizationID, + PolicyID: policyID, + } + + _, err = apiClient.DeletePolicy(cmd.Context(), request) + if err != nil { + return nil, err + } + + c.store.Success = true + + return c, nil +} + +func (c *DeleteController) Render(_ *cobra.Command, _ []string) error { + pterm.Success.Println("Policy deleted successfully") + return nil +} diff --git a/cmd/cloud/organizations/policies/list.go b/cmd/cloud/organizations/policies/list.go new file mode 100644 index 00000000..d5f7c4a6 --- /dev/null +++ b/cmd/cloud/organizations/policies/list.go @@ -0,0 +1,112 @@ +package policies + +import ( + "fmt" + + "github.com/pterm/pterm" + "github.com/spf13/cobra" + + "github.com/formancehq/go-libs/time" + + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + fctl "github.com/formancehq/fctl/pkg" +) + +type ListStore struct { + Policies []components.Policy `json:"policies"` +} + +type ListController struct { + store *ListStore +} + +var _ fctl.Controller[*ListStore] = (*ListController)(nil) + +func NewDefaultListStore() *ListStore { + return &ListStore{ + Policies: []components.Policy{}, + } +} + +func NewListController() *ListController { + return &ListController{ + store: NewDefaultListStore(), + } +} + +func NewListCommand() *cobra.Command { + return fctl.NewCommand(`list`, + fctl.WithAliases("ls", "l"), + fctl.WithShortDescription("List organization policies"), + fctl.WithArgs(cobra.ExactArgs(0)), + fctl.WithValidArgsFunction(cobra.NoFileCompletions), + fctl.WithController(NewListController()), + ) +} + +func (c *ListController) GetStore() *ListStore { + return c.store +} + +func (c *ListController) Run(cmd *cobra.Command, _ []string) (fctl.Renderable, error) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + request := operations.ListPoliciesRequest{ + OrganizationID: organizationID, + } + + response, err := apiClient.ListPolicies(cmd.Context(), request) + if err != nil { + return nil, err + } + + if response.ListPoliciesResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.Policies = response.ListPoliciesResponse.GetData() + + return c, nil +} + +func (c *ListController) Render(cmd *cobra.Command, _ []string) error { + if len(c.store.Policies) == 0 { + fmt.Fprintln(cmd.OutOrStdout(), "No policies found.") + return nil + } + + header := []string{"ID", "Name", "Description", "Protected", "Created At", "Updated At"} + tableData := fctl.Map(c.store.Policies, func(policy components.Policy) []string { + return []string{ + fmt.Sprintf("%d", policy.GetID()), + policy.GetName(), + func() string { + if desc := policy.GetDescription(); desc != nil { + return *desc + } + return "" + }(), + fctl.BoolToString(policy.GetProtected()), + time.Time{Time: policy.GetCreatedAt()}.String(), + time.Time{Time: policy.GetUpdatedAt()}.String(), + } + }) + + tableData = fctl.Prepend(tableData, header) + + return pterm.DefaultTable. + WithHasHeader(). + WithWriter(cmd.OutOrStdout()). + WithData(tableData). + Render() +} diff --git a/cmd/cloud/organizations/policies/remove-scope.go b/cmd/cloud/organizations/policies/remove-scope.go new file mode 100644 index 00000000..0ab83914 --- /dev/null +++ b/cmd/cloud/organizations/policies/remove-scope.go @@ -0,0 +1,94 @@ +package policies + +import ( + "fmt" + "strconv" + + "github.com/pterm/pterm" + "github.com/spf13/cobra" + + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + fctl "github.com/formancehq/fctl/pkg" +) + +type RemoveScopeStore struct { + Success bool `json:"success"` +} + +type RemoveScopeController struct { + store *RemoveScopeStore +} + +var _ fctl.Controller[*RemoveScopeStore] = (*RemoveScopeController)(nil) + +func NewDefaultRemoveScopeStore() *RemoveScopeStore { + return &RemoveScopeStore{} +} + +func NewRemoveScopeController() *RemoveScopeController { + return &RemoveScopeController{ + store: NewDefaultRemoveScopeStore(), + } +} + +func NewRemoveScopeCommand() *cobra.Command { + return fctl.NewCommand(`remove-scope `, + fctl.WithAliases("remove", "rm", "r"), + fctl.WithShortDescription("Remove a scope from a policy"), + fctl.WithArgs(cobra.ExactArgs(2)), + fctl.WithConfirmFlag(), + fctl.WithValidArgsFunction(cobra.NoFileCompletions), + fctl.WithController(NewRemoveScopeController()), + ) +} + +func (c *RemoveScopeController) GetStore() *RemoveScopeStore { + return c.store +} + +func (c *RemoveScopeController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + policyID, err := strconv.ParseInt(args[0], 10, 64) + if err != nil { + return nil, fmt.Errorf("invalid policy ID: %w", err) + } + + scopeID, err := strconv.ParseInt(args[1], 10, 64) + if err != nil { + return nil, fmt.Errorf("invalid scope ID: %w", err) + } + + if !fctl.CheckOrganizationApprobation(cmd, "You are about to remove a scope from a policy") { + return nil, fctl.ErrMissingApproval + } + + request := operations.RemoveScopeFromPolicyRequest{ + OrganizationID: organizationID, + PolicyID: policyID, + ScopeID: scopeID, + } + + _, err = apiClient.RemoveScopeFromPolicy(cmd.Context(), request) + if err != nil { + return nil, err + } + + c.store.Success = true + + return c, nil +} + +func (c *RemoveScopeController) Render(_ *cobra.Command, _ []string) error { + pterm.Success.Println("Scope removed from policy successfully") + return nil +} diff --git a/cmd/cloud/organizations/oauth/root.go b/cmd/cloud/organizations/policies/root.go similarity index 50% rename from cmd/cloud/organizations/oauth/root.go rename to cmd/cloud/organizations/policies/root.go index 02af2cdb..65d498df 100644 --- a/cmd/cloud/organizations/oauth/root.go +++ b/cmd/cloud/organizations/policies/root.go @@ -1,4 +1,4 @@ -package oauth +package policies import ( "github.com/spf13/cobra" @@ -7,13 +7,16 @@ import ( ) func NewCommand() *cobra.Command { - return fctl.NewMembershipCommand("oauth", - fctl.WithShortDescription("client management"), - fctl.WithDeprecated("Use `fctl cloud organizations clients` instead"), + return fctl.NewMembershipCommand("policies", + fctl.WithShortDescription("Policies management"), fctl.WithChildCommands( + NewListCommand(), NewCreateCommand(), NewShowCommand(), + NewUpdateCommand(), NewDeleteCommand(), + NewAddScopeCommand(), + NewRemoveScopeCommand(), ), ) } diff --git a/cmd/cloud/organizations/policies/show.go b/cmd/cloud/organizations/policies/show.go new file mode 100644 index 00000000..052ad552 --- /dev/null +++ b/cmd/cloud/organizations/policies/show.go @@ -0,0 +1,129 @@ +package policies + +import ( + "fmt" + "strconv" + + "github.com/pterm/pterm" + "github.com/spf13/cobra" + + "github.com/formancehq/go-libs/time" + + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + fctl "github.com/formancehq/fctl/pkg" +) + +type ShowStore struct { + Policy *components.Policy `json:"policy"` +} + +type ShowController struct { + store *ShowStore +} + +var _ fctl.Controller[*ShowStore] = (*ShowController)(nil) + +func NewDefaultShowStore() *ShowStore { + return &ShowStore{} +} + +func NewShowController() *ShowController { + return &ShowController{ + store: NewDefaultShowStore(), + } +} + +func NewShowCommand() *cobra.Command { + return fctl.NewCommand(`show `, + fctl.WithAliases("s", "sh"), + fctl.WithShortDescription("Show policy details"), + fctl.WithArgs(cobra.ExactArgs(1)), + fctl.WithValidArgsFunction(cobra.NoFileCompletions), + fctl.WithController(NewShowController()), + ) +} + +func (c *ShowController) GetStore() *ShowStore { + return c.store +} + +func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + policyID, err := strconv.ParseInt(args[0], 10, 64) + if err != nil { + return nil, fmt.Errorf("invalid policy ID: %w", err) + } + + request := operations.ReadPolicyRequest{ + OrganizationID: organizationID, + PolicyID: policyID, + } + + response, err := apiClient.ReadPolicy(cmd.Context(), request) + if err != nil { + return nil, err + } + + if response.ReadPolicyResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.Policy = response.ReadPolicyResponse.GetData() + + return c, nil +} + +func (c *ShowController) Render(cmd *cobra.Command, _ []string) error { + if c.store.Policy == nil { + return fmt.Errorf("no policy data") + } + + policy := c.store.Policy + + data := [][]string{ + {"ID", fmt.Sprintf("%d", policy.GetID())}, + {"Name", policy.GetName()}, + {"Description", func() string { + if desc := policy.GetDescription(); desc != nil { + return *desc + } + return "" + }()}, + {"Protected", fctl.BoolToString(policy.GetProtected())}, + {"Created At", time.Time{Time: policy.GetCreatedAt()}.String()}, + {"Updated At", time.Time{Time: policy.GetUpdatedAt()}.String()}, + } + + if scopes := policy.GetScopes(); len(scopes) > 0 { + data = append(data, []string{"Scopes", ""}) + for _, scope := range scopes { + data = append(data, []string{ + "", + fmt.Sprintf(" - %s (ID: %d)", scope.GetLabel(), scope.GetID()), + }) + if app := scope.GetApplicationID(); app != nil { + data = append(data, []string{"", fmt.Sprintf(" Application: %s", *app)}) + } + if desc := scope.GetDescription(); desc != nil && *desc != "" { + data = append(data, []string{"", fmt.Sprintf(" Description: %s", *desc)}) + } + } + } + + return pterm.DefaultTable. + WithHasHeader(). + WithWriter(cmd.OutOrStdout()). + WithData(data). + Render() +} diff --git a/cmd/cloud/organizations/policies/update.go b/cmd/cloud/organizations/policies/update.go new file mode 100644 index 00000000..3cac659f --- /dev/null +++ b/cmd/cloud/organizations/policies/update.go @@ -0,0 +1,135 @@ +package policies + +import ( + "fmt" + "strconv" + + "github.com/pterm/pterm" + "github.com/spf13/cobra" + + "github.com/formancehq/go-libs/v3/pointer" + + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + fctl "github.com/formancehq/fctl/pkg" +) + +type UpdateStore struct { + Policy *components.Policy `json:"policy"` +} + +type UpdateController struct { + store *UpdateStore +} + +var _ fctl.Controller[*UpdateStore] = (*UpdateController)(nil) + +func NewDefaultUpdateStore() *UpdateStore { + return &UpdateStore{} +} + +func NewUpdateController() *UpdateController { + return &UpdateController{ + store: NewDefaultUpdateStore(), + } +} + +func NewUpdateCommand() *cobra.Command { + return fctl.NewCommand(`update `, + fctl.WithAliases("u", "up"), + fctl.WithShortDescription("Update a policy"), + fctl.WithArgs(cobra.ExactArgs(1)), + fctl.WithStringFlag("name", "", "Policy name"), + fctl.WithStringFlag("description", "", "Policy description"), + fctl.WithConfirmFlag(), + fctl.WithValidArgsFunction(cobra.NoFileCompletions), + fctl.WithController(NewUpdateController()), + ) +} + +func (c *UpdateController) GetStore() *UpdateStore { + return c.store +} + +func (c *UpdateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + policyID, err := strconv.ParseInt(args[0], 10, 64) + if err != nil { + return nil, fmt.Errorf("invalid policy ID: %w", err) + } + + // Read current policy to get existing values + readRequest := operations.ReadPolicyRequest{ + OrganizationID: organizationID, + PolicyID: policyID, + } + + readResponse, err := apiClient.ReadPolicy(cmd.Context(), readRequest) + if err != nil { + return nil, err + } + + if readResponse.ReadPolicyResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + currentPolicy := readResponse.ReadPolicyResponse.GetData() + + if !fctl.CheckOrganizationApprobation(cmd, "You are about to update a policy") { + return nil, fctl.ErrMissingApproval + } + + // Prepare update data + name := fctl.GetString(cmd, "name") + if name == "" { + name = currentPolicy.GetName() + } + + description := fctl.GetString(cmd, "description") + policyData := components.PolicyData{ + Name: name, + } + if description != "" || cmd.Flags().Changed("description") { + if description != "" { + policyData.Description = pointer.For(description) + } else { + policyData.Description = currentPolicy.GetDescription() + } + } else { + policyData.Description = currentPolicy.GetDescription() + } + + updateRequest := operations.UpdatePolicyRequest{ + OrganizationID: organizationID, + PolicyID: policyID, + Body: &policyData, + } + + response, err := apiClient.UpdatePolicy(cmd.Context(), updateRequest) + if err != nil { + return nil, err + } + + if response.UpdatePolicyResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.Policy = response.UpdatePolicyResponse.GetData() + + return c, nil +} + +func (c *UpdateController) Render(_ *cobra.Command, _ []string) error { + pterm.Success.Println("Policy updated successfully") + return nil +} diff --git a/cmd/cloud/organizations/root.go b/cmd/cloud/organizations/root.go index d4305fc9..8522ecdf 100644 --- a/cmd/cloud/organizations/root.go +++ b/cmd/cloud/organizations/root.go @@ -3,10 +3,11 @@ package organizations import ( "github.com/spf13/cobra" + "github.com/formancehq/fctl/cmd/cloud/organizations/applications" authorization_provider "github.com/formancehq/fctl/cmd/cloud/organizations/authentication-provider" "github.com/formancehq/fctl/cmd/cloud/organizations/invitations" - "github.com/formancehq/fctl/cmd/cloud/organizations/oauth" oauth_clients "github.com/formancehq/fctl/cmd/cloud/organizations/oauth-clients" + "github.com/formancehq/fctl/cmd/cloud/organizations/policies" "github.com/formancehq/fctl/cmd/cloud/organizations/users" fctl "github.com/formancehq/fctl/pkg" ) @@ -24,9 +25,10 @@ func NewCommand() *cobra.Command { NewHistoryCommand(), users.NewCommand(), invitations.NewCommand(), - oauth.NewCommand(), oauth_clients.NewCommand(), authorization_provider.NewCommand(), + policies.NewCommand(), + applications.NewCommand(), ), ) } diff --git a/cmd/cloud/organizations/update.go b/cmd/cloud/organizations/update.go index d8e1a8b5..936181f2 100644 --- a/cmd/cloud/organizations/update.go +++ b/cmd/cloud/organizations/update.go @@ -1,10 +1,15 @@ package organizations import ( + "fmt" + "github.com/spf13/cobra" + "github.com/formancehq/go-libs/v3/pointer" + "github.com/formancehq/fctl/cmd/cloud/organizations/internal" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -25,16 +30,15 @@ func NewUpdateController() *UpdateController { } func NewUpdateCommand() *cobra.Command { - return fctl.NewCommand("update --name --default-stack-role --default-organization-role ", + return fctl.NewCommand("update --name --default-policy-id ", fctl.WithAliases("update"), fctl.WithShortDescription("Update organization"), fctl.WithArgs(cobra.ExactArgs(1)), fctl.WithValidArgsFunction(fctl.OrganizationCompletion), fctl.WithConfirmFlag(), fctl.WithStringFlag("name", "", "Organization Name"), - fctl.WithStringFlag("default-stack-role", "", "Default Stack Role"), + fctl.WithIntFlag("default-policy-id", 0, "Default policy id"), fctl.WithStringFlag("domain", "", "Organization Domain"), - fctl.WithStringFlag("default-organization-role", "", "Default Organization Role"), fctl.WithController(NewUpdateController()), ) } @@ -44,54 +48,72 @@ func (c *UpdateController) GetStore() *DescribeStore { } func (c *UpdateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + apiClient, err := fctl.NewMembershipClientForOrganization(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile, args[0]) + if err != nil { + return nil, err + } if !fctl.CheckOrganizationApprobation(cmd, "You are about to update an organization") { return nil, fctl.ErrMissingApproval } - org, _, err := store.Client().ReadOrganization(cmd.Context(), args[0]).Execute() + readRequest := operations.ReadOrganizationRequest{ + OrganizationID: args[0], + } + + org, err := apiClient.ReadOrganization(cmd.Context(), readRequest) if err != nil { return nil, err } - preparedData := membershipclient.OrganizationData{ + if org.ReadOrganizationResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + orgData := org.ReadOrganizationResponse.GetData() + + preparedData := components.OrganizationData{ Name: func() string { if cmd.Flags().Changed("name") { return cmd.Flag("name").Value.String() } - return org.Data.Name + return orgData.GetName() }(), - DefaultOrganizationAccess: func() *membershipclient.Role { - if cmd.Flags().Changed("default-organization-role") { - s := fctl.GetString(cmd, "default-organization-role") - return membershipclient.Role(s).Ptr() + DefaultPolicyID: func() *int64 { + if cmd.Flags().Changed("default-policy-id") { + return pointer.For(int64(fctl.GetInt(cmd, "default-policy-id"))) } - return org.Data.DefaultOrganizationAccess - }(), - DefaultStackAccess: func() *membershipclient.Role { - if cmd.Flags().Changed("default-stack-role") { - s := fctl.GetString(cmd, "default-stack-role") - return membershipclient.Role(s).Ptr() - } - return org.Data.DefaultStackAccess + return orgData.GetDefaultPolicyID() }(), Domain: func() *string { str := fctl.GetString(cmd, "domain") if str != "" { return &str } - return org.Data.Domain + return orgData.GetDomain() }(), } - response, _, err := store.Client(). - UpdateOrganization(cmd.Context(), args[0]).OrganizationData(preparedData).Execute() + updateRequest := operations.UpdateOrganizationRequest{ + OrganizationID: args[0], + Body: &preparedData, + } + response, err := apiClient.UpdateOrganization(cmd.Context(), updateRequest) if err != nil { return nil, err } - c.store.OrganizationExpanded = response.Data + if response.ReadOrganizationResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.OrganizationExpanded = response.ReadOrganizationResponse.GetData() return c, nil } diff --git a/cmd/cloud/organizations/users/link.go b/cmd/cloud/organizations/users/link.go index a775fd96..47874a2e 100644 --- a/cmd/cloud/organizations/users/link.go +++ b/cmd/cloud/organizations/users/link.go @@ -6,7 +6,10 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/go-libs/v3/pointer" + + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -33,13 +36,10 @@ func NewLinkController() *LinkController { func NewLinkCommand() *cobra.Command { return fctl.NewCommand("link ", - fctl.WithStringFlag("role", "", "Roles: (ADMIN, GUEST, NONE)"), + fctl.WithIntFlag("policy-id", 0, "Policy ID"), fctl.WithShortDescription("Link user to an organization with properties"), fctl.WithArgs(cobra.ExactArgs(1)), fctl.WithValidArgsFunction(cobra.NoFileCompletions), - fctl.WithPreRunE(func(cmd *cobra.Command, args []string) error { - return fctl.CheckMembershipVersion("v0.26.1")(cmd, args) - }), fctl.WithController(NewLinkController()), ) } @@ -49,30 +49,44 @@ func (c *LinkController) GetStore() *LinkStore { } func (c *LinkController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return nil, err } - role := fctl.GetString(cmd, "role") - req := membershipclient.UpdateOrganizationUserRequest{} - if role != "" { - req.Role = membershipclient.Role(role) - } else { - return nil, fmt.Errorf("role is required") + policyID := fctl.GetInt(cmd, "policy-id") + if policyID == 0 { + return nil, fmt.Errorf("policy id is required") } - response, err := store.Client().UpsertOrganizationUser( - cmd.Context(), - organizationID, - args[0]). - UpdateOrganizationUserRequest(req).Execute() + + reqBody := components.UpdateOrganizationUserRequest{ + PolicyID: pointer.For(int64(policyID)), + } + + request := operations.UpsertOrganizationUserRequest{ + OrganizationID: organizationID, + UserID: args[0], + Body: &reqBody, + } + + response, err := apiClient.UpsertOrganizationUser(cmd.Context(), request) if err != nil { return nil, err } - if response.StatusCode > 300 { - return nil, fmt.Errorf("error updating user: %s", response.Status) + // Vérifier s'il y a une erreur dans la réponse + if response.Error != nil { + errMsg := "unknown error" + if msg := response.Error.GetErrorMessage(); msg != nil { + errMsg = *msg + } + return nil, fmt.Errorf("error updating user: %s", errMsg) } return c, nil diff --git a/cmd/cloud/organizations/users/list.go b/cmd/cloud/organizations/users/list.go index 7ec7f044..b6b3d798 100644 --- a/cmd/cloud/organizations/users/list.go +++ b/cmd/cloud/organizations/users/list.go @@ -1,17 +1,20 @@ package users import ( + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) type User struct { - ID string `json:"id"` - Email string `json:"email"` - Role membershipclient.Role `json:"role"` + ID string `json:"id"` + Email string `json:"email"` + PolicyID int64 `json:"policyID"` } type ListStore struct { @@ -47,23 +50,35 @@ func (c *ListController) GetStore() *ListStore { } func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return nil, err } - usersResponse, _, err := store.Client().ListUsersOfOrganization(cmd.Context(), organizationID).Execute() + request := operations.ListUsersOfOrganizationRequest{ + OrganizationID: organizationID, + } + + response, err := apiClient.ListUsersOfOrganization(cmd.Context(), request) if err != nil { return nil, err } - c.store.Users = fctl.Map(usersResponse.Data, func(i membershipclient.OrganizationUser) User { + if response.ListUsersResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.Users = fctl.Map(response.ListUsersResponse.GetData(), func(i components.OrganizationUser) User { return User{ - i.Id, - i.Email, - i.Role, + ID: i.GetID(), + Email: i.GetEmail(), + PolicyID: i.GetPolicyID(), } }) @@ -76,11 +91,11 @@ func (c *ListController) Render(cmd *cobra.Command, args []string) error { return []string{ i.ID, i.Email, - string(i.Role), + fmt.Sprint(i.PolicyID), } }) - tableData := fctl.Prepend(usersRow, []string{"ID", "Email", "Role"}) + tableData := fctl.Prepend(usersRow, []string{"ID", "Email", "Policy ID"}) return pterm.DefaultTable. WithHasHeader(). WithWriter(cmd.OutOrStdout()). diff --git a/cmd/cloud/organizations/users/show.go b/cmd/cloud/organizations/users/show.go index be37f906..edd8184f 100644 --- a/cmd/cloud/organizations/users/show.go +++ b/cmd/cloud/organizations/users/show.go @@ -1,17 +1,19 @@ package users import ( + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) type ShowStore struct { - Id string `json:"id"` - Email string `json:"email"` - Role membershipclient.Role `json:"role"` + Id string `json:"id"` + Email string `json:"email"` + PolicyID int64 `json:"policyID"` } type ShowController struct { store *ShowStore @@ -44,20 +46,35 @@ func (c *ShowController) GetStore() *ShowStore { } func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return nil, err } - userResponse, _, err := store.Client().ReadUserOfOrganization(cmd.Context(), organizationID, args[0]).Execute() + request := operations.ReadUserOfOrganizationRequest{ + OrganizationID: organizationID, + UserID: args[0], + } + + response, err := apiClient.ReadUserOfOrganization(cmd.Context(), request) if err != nil { return nil, err } - c.store.Id = userResponse.Data.Id - c.store.Email = userResponse.Data.Email - c.store.Role = userResponse.Data.Role + if response.ReadOrganizationUserResponse == nil || response.ReadOrganizationUserResponse.GetData() == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + data := response.ReadOrganizationUserResponse.GetData() + c.store.Id = data.GetID() + c.store.Email = data.GetEmail() + c.store.PolicyID = data.GetPolicyID() return c, nil } @@ -68,7 +85,7 @@ func (c *ShowController) Render(cmd *cobra.Command, args []string) error { tableData = append(tableData, []string{pterm.LightCyan("Email"), c.store.Email}) tableData = append(tableData, []string{ pterm.LightCyan("Role"), - pterm.LightCyan(c.store.Role), + pterm.LightCyan(c.store.PolicyID), }) return pterm.DefaultTable. diff --git a/cmd/cloud/organizations/users/unlink.go b/cmd/cloud/organizations/users/unlink.go index 2b8d81af..cc0cde6d 100644 --- a/cmd/cloud/organizations/users/unlink.go +++ b/cmd/cloud/organizations/users/unlink.go @@ -4,6 +4,7 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -43,13 +44,22 @@ func (c *DeleteController) GetStore() *UnlinkStore { func (c *DeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) if err != nil { return nil, err } - _, err = store.Client().DeleteUserFromOrganization(cmd.Context(), organizationID, args[0]).Execute() + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + request := operations.DeleteUserFromOrganizationRequest{ + OrganizationID: organizationID, + UserID: args[0], + } + + _, err = apiClient.DeleteUserFromOrganization(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/cloud/regions/create.go b/cmd/cloud/regions/create.go index e114993c..b7d8a58e 100644 --- a/cmd/cloud/regions/create.go +++ b/cmd/cloud/regions/create.go @@ -1,10 +1,13 @@ package regions import ( + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -43,9 +46,12 @@ func (c *CreateController) GetStore() *CreateStore { func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return nil, err } @@ -60,17 +66,31 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab } } - regionResponse, _, err := store.Client().CreatePrivateRegion(cmd.Context(), organizationID). - CreatePrivateRegionRequest(membershipclient.CreatePrivateRegionRequest{ - Name: name, - }). - Execute() + reqBody := components.CreatePrivateRegionRequest{ + Name: name, + } + + request := operations.CreatePrivateRegionRequest{ + OrganizationID: organizationID, + Body: &reqBody, + } + + response, err := apiClient.CreatePrivateRegion(cmd.Context(), request) if err != nil { return nil, err } - c.store.RegionId = regionResponse.Data.Id - c.store.Secret = *regionResponse.Data.Secret.Clear + if response.CreatedPrivateRegionResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + region := response.CreatedPrivateRegionResponse.GetData() + c.store.RegionId = region.GetID() + + secret := region.GetSecret() + if secret != nil && secret.GetClear() != nil { + c.store.Secret = *secret.GetClear() + } return c, nil } diff --git a/cmd/cloud/regions/delete.go b/cmd/cloud/regions/delete.go index b3d1e918..12b187ab 100644 --- a/cmd/cloud/regions/delete.go +++ b/cmd/cloud/regions/delete.go @@ -4,6 +4,7 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -41,14 +42,22 @@ func (c *DeleteController) GetStore() *DeleteStore { func (c *DeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return nil, err } - _, err = store.Client().DeleteRegion(cmd.Context(), organizationID, args[0]).Execute() + request := operations.DeleteRegionRequest{ + OrganizationID: organizationID, + RegionID: args[0], + } + + _, err = apiClient.DeleteRegion(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/cloud/regions/list.go b/cmd/cloud/regions/list.go index 7f31087d..adcb0ecb 100644 --- a/cmd/cloud/regions/list.go +++ b/cmd/cloud/regions/list.go @@ -1,17 +1,19 @@ package regions import ( + "fmt" "time" "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) type ListStore struct { - Regions []membershipclient.AnyRegion `json:"regions"` + Regions []components.AnyRegion `json:"regions"` } type ListController struct { store *ListStore @@ -44,48 +46,59 @@ func (c *ListController) GetStore() *ListStore { func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return nil, err } - regionsResponse, _, err := store.Client().ListRegions(cmd.Context(), organizationID).Execute() + request := operations.ListRegionsRequest{ + OrganizationID: organizationID, + } + + response, err := apiClient.ListRegions(cmd.Context(), request) if err != nil { return nil, err } - c.store.Regions = regionsResponse.Data + if response.ListRegionsResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.Regions = response.ListRegionsResponse.GetData() return c, nil } func (c *ListController) Render(cmd *cobra.Command, args []string) error { - tableData := fctl.Map(c.store.Regions, func(i membershipclient.AnyRegion) []string { + tableData := fctl.Map(c.store.Regions, func(i components.AnyRegion) []string { return []string{ - i.Id, - i.Name, - i.BaseUrl, - fctl.BoolToString(i.Public), - fctl.BoolToString(i.Active), + i.GetID(), + i.GetName(), + i.GetBaseURL(), + fctl.BoolToString(i.GetPublic()), + fctl.BoolToString(i.GetActive()), func() string { - if i.LastPing != nil { - return i.LastPing.Format(time.RFC3339) + if ping := i.GetLastPing(); ping != nil { + return ping.Format(time.RFC3339) } return "" }(), func() string { - if i.Creator != nil { - return i.Creator.Email + if creator := i.GetCreator(); creator != nil { + return creator.GetEmail() } return "Formance Cloud" }(), func() string { - if i.Version == nil { - return "" + if version := i.GetVersion(); version != nil { + return *version } - return *i.Version + return "" }(), } }) diff --git a/cmd/cloud/regions/show.go b/cmd/cloud/regions/show.go index 3e69419d..4c6a89a9 100644 --- a/cmd/cloud/regions/show.go +++ b/cmd/cloud/regions/show.go @@ -8,12 +8,13 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) type ShowStore struct { - Region membershipclient.AnyRegion `json:"region"` + Region components.AnyRegion `json:"region"` } type ShowController struct { store *ShowStore @@ -45,19 +46,32 @@ func (c *ShowController) GetStore() *ShowStore { } func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) if err != nil { return nil, err } - response, _, err := store.Client().GetRegion(cmd.Context(), organizationID, args[0]).Execute() + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return nil, err } - c.store.Region = response.Data + request := operations.GetRegionRequest{ + OrganizationID: organizationID, + RegionID: args[0], + } + + response, err := apiClient.GetRegion(cmd.Context(), request) + if err != nil { + return nil, err + } + + if response.GetRegionResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.Region = response.GetRegionResponse.GetData() return c, nil } @@ -65,21 +79,21 @@ func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable func (c *ShowController) Render(cmd *cobra.Command, args []string) (err error) { fctl.Section.WithWriter(cmd.OutOrStdout()).Println("Information") tableData := pterm.TableData{} - tableData = append(tableData, []string{pterm.LightCyan("ID"), c.store.Region.Id}) - tableData = append(tableData, []string{pterm.LightCyan("Name"), c.store.Region.Name}) - tableData = append(tableData, []string{pterm.LightCyan("Base URL"), c.store.Region.BaseUrl}) - tableData = append(tableData, []string{pterm.LightCyan("Active"), fctl.BoolToString(c.store.Region.Active)}) - tableData = append(tableData, []string{pterm.LightCyan("Public"), fctl.BoolToString(c.store.Region.Public)}) - - if c.store.Region.Version != nil { - tableData = append(tableData, []string{pterm.LightCyan("Version"), *c.store.Region.Version}) + tableData = append(tableData, []string{pterm.LightCyan("ID"), c.store.Region.GetID()}) + tableData = append(tableData, []string{pterm.LightCyan("Name"), c.store.Region.GetName()}) + tableData = append(tableData, []string{pterm.LightCyan("Base URL"), c.store.Region.GetBaseURL()}) + tableData = append(tableData, []string{pterm.LightCyan("Active"), fctl.BoolToString(c.store.Region.GetActive())}) + tableData = append(tableData, []string{pterm.LightCyan("Public"), fctl.BoolToString(c.store.Region.GetPublic())}) + + if version := c.store.Region.GetVersion(); version != nil { + tableData = append(tableData, []string{pterm.LightCyan("Version"), *version}) } - if c.store.Region.Creator != nil { - tableData = append(tableData, []string{pterm.LightCyan("Creator"), c.store.Region.Creator.Email}) + if creator := c.store.Region.GetCreator(); creator != nil { + tableData = append(tableData, []string{pterm.LightCyan("Creator"), creator.GetEmail()}) } - if c.store.Region.LastPing != nil { - tableData = append(tableData, []string{pterm.LightCyan("Last ping"), c.store.Region.LastPing.Format(time.RFC3339)}) + if lastPing := c.store.Region.GetLastPing(); lastPing != nil { + tableData = append(tableData, []string{pterm.LightCyan("Last ping"), lastPing.Format(time.RFC3339)}) } err = pterm.DefaultTable. @@ -91,7 +105,7 @@ func (c *ShowController) Render(cmd *cobra.Command, args []string) (err error) { } tableData = pterm.TableData{} - capabilities, err := fctl.StructToMap(c.store.Region.Capabilities) + capabilities, err := fctl.StructToMap(c.store.Region.GetCapabilities()) if err != nil { return } diff --git a/cmd/cloud/root.go b/cmd/cloud/root.go index bc7f1692..87229980 100644 --- a/cmd/cloud/root.go +++ b/cmd/cloud/root.go @@ -21,8 +21,5 @@ func NewCommand() *cobra.Command { NewGeneratePersonalTokenCommand(), apps.NewCommand(), ), - fctl.WithPersistentPreRunE(func(cmd *cobra.Command, args []string) error { - return fctl.NewMembershipStore(cmd) - }), ) } diff --git a/cmd/ledger/accounts/delete_metadata.go b/cmd/ledger/accounts/delete_metadata.go index 4159404d..b06c35af 100644 --- a/cmd/ledger/accounts/delete_metadata.go +++ b/cmd/ledger/accounts/delete_metadata.go @@ -45,13 +45,21 @@ func (c *DeleteMetadataController) GetStore() *DeleteMetadataStore { func (c *DeleteMetadataController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to set a metadata on account %s", args[0]) { + if !fctl.CheckStackApprobation(cmd, "You are about to delete a metadata on account %s", args[0]) { return nil, fctl.ErrMissingApproval } - response, err := store.Client().Ledger.V2.DeleteAccountMetadata(cmd.Context(), operations.V2DeleteAccountMetadataRequest{ + response, err := stackClient.Ledger.V2.DeleteAccountMetadata(cmd.Context(), operations.V2DeleteAccountMetadataRequest{ Address: args[0], Key: args[1], Ledger: fctl.GetString(cmd, internal.LedgerFlag), diff --git a/cmd/ledger/accounts/list.go b/cmd/ledger/accounts/list.go index dfa844ec..ec0f116a 100644 --- a/cmd/ledger/accounts/list.go +++ b/cmd/ledger/accounts/list.go @@ -49,7 +49,15 @@ func (c *ListController) GetStore() *ListStore { func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } metadata, err := fctl.ParseMetadata(fctl.GetStringSlice(cmd, c.metadataFlag)) if err != nil { @@ -71,7 +79,7 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable "$and": body, }, } - rsp, err := store.Client().Ledger.V2.ListAccounts(cmd.Context(), request) + rsp, err := stackClient.Ledger.V2.ListAccounts(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/ledger/accounts/set_metadata.go b/cmd/ledger/accounts/set_metadata.go index 67281cde..aff114f3 100644 --- a/cmd/ledger/accounts/set_metadata.go +++ b/cmd/ledger/accounts/set_metadata.go @@ -48,7 +48,15 @@ func (c *SetMetadataController) GetStore() *SetMetadataStore { func (c *SetMetadataController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } metadata, err := fctl.ParseMetadata(args[1:]) if err != nil { @@ -57,7 +65,7 @@ func (c *SetMetadataController) Run(cmd *cobra.Command, args []string) (fctl.Ren address := args[0] - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to set a metadata on address '%s'", address) { + if !fctl.CheckStackApprobation(cmd, "You are about to set a metadata on address '%s'", address) { return nil, fctl.ErrMissingApproval } @@ -66,7 +74,7 @@ func (c *SetMetadataController) Run(cmd *cobra.Command, args []string) (fctl.Ren Address: address, RequestBody: collectionutils.ConvertMap(metadata, collectionutils.ToAny[string]), } - response, err := store.Client().Ledger.V1.AddMetadataToAccount(cmd.Context(), request) + response, err := stackClient.Ledger.V1.AddMetadataToAccount(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/ledger/accounts/show.go b/cmd/ledger/accounts/show.go index 84fc5161..ce9002ce 100644 --- a/cmd/ledger/accounts/show.go +++ b/cmd/ledger/accounts/show.go @@ -48,10 +48,18 @@ func (c *ShowController) GetStore() *ShowStore { func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } ledger := fctl.GetString(cmd, internal.LedgerFlag) - response, err := store.Client().Ledger.V1.GetAccount(cmd.Context(), operations.GetAccountRequest{ + response, err := stackClient.Ledger.V1.GetAccount(cmd.Context(), operations.GetAccountRequest{ Address: args[0], Ledger: ledger, }) diff --git a/cmd/ledger/create.go b/cmd/ledger/create.go index 6cc53ce5..8f86c163 100644 --- a/cmd/ledger/create.go +++ b/cmd/ledger/create.go @@ -9,7 +9,7 @@ import ( "github.com/formancehq/formance-sdk-go/v3/pkg/models/operations" "github.com/formancehq/formance-sdk-go/v3/pkg/models/shared" - "github.com/formancehq/go-libs/pointer" + "github.com/formancehq/go-libs/v3/pointer" fctl "github.com/formancehq/fctl/pkg" ) @@ -62,8 +62,18 @@ func (c *CreateController) GetStore() *CreateStore { } func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to create a new ledger") { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + if !fctl.CheckStackApprobation(cmd, "You are about to create a new ledger") { return nil, fctl.ErrMissingApproval } @@ -81,7 +91,7 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab features[parts[0]] = parts[1] } - _, err = store.Client().Ledger.V2.CreateLedger(cmd.Context(), operations.V2CreateLedgerRequest{ + _, err = stackClient.Ledger.V2.CreateLedger(cmd.Context(), operations.V2CreateLedgerRequest{ V2CreateLedgerRequest: shared.V2CreateLedgerRequest{ Bucket: pointer.For(fctl.GetString(cmd, bucketNameFlag)), Metadata: metadata, diff --git a/cmd/ledger/delete_metadata.go b/cmd/ledger/delete_metadata.go index de9e324b..826894aa 100644 --- a/cmd/ledger/delete_metadata.go +++ b/cmd/ledger/delete_metadata.go @@ -45,13 +45,21 @@ func (c *DeleteMetadataController) GetStore() *DeleteMetadataStore { func (c *DeleteMetadataController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to set a metadata on ledger %s", args[0]) { + if !fctl.CheckStackApprobation(cmd, "You are about to delete a metadata on ledger %s", args[0]) { return nil, fctl.ErrMissingApproval } - response, err := store.Client().Ledger.V2.DeleteLedgerMetadata(cmd.Context(), operations.V2DeleteLedgerMetadataRequest{ + response, err := stackClient.Ledger.V2.DeleteLedgerMetadata(cmd.Context(), operations.V2DeleteLedgerMetadataRequest{ Key: args[1], Ledger: args[0], }) diff --git a/cmd/ledger/export.go b/cmd/ledger/export.go index 5948ac69..6bdea1c8 100644 --- a/cmd/ledger/export.go +++ b/cmd/ledger/export.go @@ -49,7 +49,16 @@ func (c *ExportController) GetStore() *ExportStore { } func (c *ExportController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } ctx := cmd.Context() out := fctl.GetString(cmd, "file") @@ -57,7 +66,7 @@ func (c *ExportController) Run(cmd *cobra.Command, args []string) (fctl.Renderab ctx = context.WithValue(ctx, "path", out) } - ret, err := store.Client().Ledger.V2.ExportLogs(ctx, operations.V2ExportLogsRequest{ + ret, err := stackClient.Ledger.V2.ExportLogs(ctx, operations.V2ExportLogsRequest{ Ledger: fctl.GetString(cmd, internal.LedgerFlag), }) if err != nil { diff --git a/cmd/ledger/import.go b/cmd/ledger/import.go index 3e27b25d..7cea0ccb 100644 --- a/cmd/ledger/import.go +++ b/cmd/ledger/import.go @@ -4,18 +4,18 @@ import ( "bufio" "bytes" "encoding/json" + "errors" "fmt" "io" "math/big" "os" "path/filepath" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" "github.com/formancehq/formance-sdk-go/v3/pkg/models/operations" - "github.com/formancehq/go-libs/pointer" + "github.com/formancehq/go-libs/v3/pointer" fctl "github.com/formancehq/fctl/pkg" ) @@ -57,7 +57,16 @@ func (c *ImportController) GetStore() *ImportStore { } func (c *ImportController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } lastID := big.NewInt(-1) resumeFromLastLog, err := cmd.Flags().GetBool(c.resumeFromLastLog) @@ -65,7 +74,7 @@ func (c *ImportController) Run(cmd *cobra.Command, args []string) (fctl.Renderab return nil, err } if resumeFromLastLog { - logs, err := store.Client().Ledger.V2.ListLogs(cmd.Context(), operations.V2ListLogsRequest{ + logs, err := stackClient.Ledger.V2.ListLogs(cmd.Context(), operations.V2ListLogsRequest{ Ledger: args[0], PageSize: pointer.For[int64](1), }) @@ -132,7 +141,7 @@ func (c *ImportController) Run(cmd *cobra.Command, args []string) (fctl.Renderab progressBar.Add(len(bytes) + 1) // +1 for the end of line if count == blockSize { - _, err = store.Client().Ledger.V2.ImportLogs(cmd.Context(), operations.V2ImportLogsRequest{ + _, err = stackClient.Ledger.V2.ImportLogs(cmd.Context(), operations.V2ImportLogsRequest{ Ledger: args[0], V2ImportLogsRequest: buffer, }) @@ -148,7 +157,7 @@ func (c *ImportController) Run(cmd *cobra.Command, args []string) (fctl.Renderab } if buffer.Len() > 0 { - _, err = store.Client().Ledger.V2.ImportLogs(cmd.Context(), operations.V2ImportLogsRequest{ + _, err = stackClient.Ledger.V2.ImportLogs(cmd.Context(), operations.V2ImportLogsRequest{ Ledger: args[0], V2ImportLogsRequest: buffer, }) diff --git a/cmd/ledger/list.go b/cmd/ledger/list.go index b2b2ccb3..98481a25 100644 --- a/cmd/ledger/list.go +++ b/cmd/ledger/list.go @@ -47,10 +47,19 @@ func (c *ListController) GetStore() *ListStore { return c.store } -func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) +func (c *ListController) Run(cmd *cobra.Command, _ []string) (fctl.Renderable, error) { - response, err := store.Client().Ledger.V2.ListLedgers(cmd.Context(), operations.V2ListLedgersRequest{}) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + response, err := stackClient.Ledger.V2.ListLedgers(cmd.Context(), operations.V2ListLedgersRequest{}) if err != nil { return nil, err } @@ -60,7 +69,7 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable return c, nil } -func (c *ListController) Render(cmd *cobra.Command, args []string) error { +func (c *ListController) Render(cmd *cobra.Command, _ []string) error { tableData := fctl.Map(c.store.Ledgers, func(ledger shared.V2Ledger) []string { return []string{ ledger.Name, ledger.AddedAt.Format(time.RFC3339Nano), fctl.MetadataAsShortString(ledger.Metadata), diff --git a/cmd/ledger/root.go b/cmd/ledger/root.go index f2ff2fd3..2dc2af76 100644 --- a/cmd/ledger/root.go +++ b/cmd/ledger/root.go @@ -29,8 +29,5 @@ func NewCommand() *cobra.Command { accounts.NewLedgerAccountsCommand(), volumes.NewLedgerVolumesCommand(), ), - fctl.WithPersistentPreRunE(func(cmd *cobra.Command, args []string) error { - return fctl.NewStackStore(cmd) - }), ) } diff --git a/cmd/ledger/send.go b/cmd/ledger/send.go index 5603bbb7..98b43dd2 100644 --- a/cmd/ledger/send.go +++ b/cmd/ledger/send.go @@ -55,9 +55,18 @@ func (c *SendController) GetStore() *SendStore { } func (c *SendController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to create a new transaction") { + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + if !fctl.CheckStackApprobation(cmd, "You are about to create a new transaction") { return nil, fctl.ErrMissingApproval } @@ -86,7 +95,7 @@ func (c *SendController) Run(cmd *cobra.Command, args []string) (fctl.Renderable reference := fctl.GetString(cmd, c.referenceFlag) - response, err := store.Client().Ledger.V1.CreateTransaction(cmd.Context(), operations.CreateTransactionRequest{ + response, err := stackClient.Ledger.V1.CreateTransaction(cmd.Context(), operations.CreateTransactionRequest{ PostTransaction: shared.PostTransaction{ Metadata: collectionutils.ConvertMap(metadata, collectionutils.ToAny[string]), Postings: []shared.Posting{ diff --git a/cmd/ledger/serverinfo.go b/cmd/ledger/serverinfo.go index 4969be2f..0db9a0bf 100644 --- a/cmd/ledger/serverinfo.go +++ b/cmd/ledger/serverinfo.go @@ -47,9 +47,18 @@ func (c *ServerInfoController) GetStore() *ServerInfoStore { } func (c *ServerInfoController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - response, err := store.Client().Ledger.V1.GetInfo(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + response, err := stackClient.Ledger.V1.GetInfo(cmd.Context()) if err != nil { return nil, err } diff --git a/cmd/ledger/set_metadata.go b/cmd/ledger/set_metadata.go index 2a9c967b..79fb5d1e 100644 --- a/cmd/ledger/set_metadata.go +++ b/cmd/ledger/set_metadata.go @@ -45,14 +45,22 @@ func (c *SetMetadataController) GetStore() *SetMetadataStore { func (c *SetMetadataController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } metadata, err := fctl.ParseMetadata(args[1:]) if err != nil { return nil, err } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to set a metadata on ledger %s", args[0]) { + if !fctl.CheckStackApprobation(cmd, "You are about to set a metadata on ledger %s", args[0]) { return nil, fctl.ErrMissingApproval } @@ -60,7 +68,7 @@ func (c *SetMetadataController) Run(cmd *cobra.Command, args []string) (fctl.Ren Ledger: args[0], RequestBody: metadata, } - response, err := store.Client().Ledger.V2.UpdateLedgerMetadata(cmd.Context(), request) + response, err := stackClient.Ledger.V2.UpdateLedgerMetadata(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/ledger/stats.go b/cmd/ledger/stats.go index 30ca1b2f..8d3d7ccd 100644 --- a/cmd/ledger/stats.go +++ b/cmd/ledger/stats.go @@ -47,12 +47,21 @@ func (c *StatsController) GetStore() *StatsStore { } func (c *StatsController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } request := operations.ReadStatsRequest{ Ledger: fctl.GetString(cmd, internal.LedgerFlag), } - response, err := store.Client().Ledger.V1.ReadStats(cmd.Context(), request) + response, err := stackClient.Ledger.V1.ReadStats(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/ledger/transactions/delete_metadata.go b/cmd/ledger/transactions/delete_metadata.go index 2b7f74ef..7e2341f3 100644 --- a/cmd/ledger/transactions/delete_metadata.go +++ b/cmd/ledger/transactions/delete_metadata.go @@ -46,19 +46,27 @@ func (c *DeleteMetadataController) GetStore() *DeleteMetadataStore { func (c *DeleteMetadataController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } - transactionID, err := internal.TransactionIDOrLastN(cmd.Context(), store.Client(), + transactionID, err := internal.TransactionIDOrLastN(cmd.Context(), stackClient, fctl.GetString(cmd, internal.LedgerFlag), args[0]) if err != nil { return nil, err } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to set a metadata on transaction %d", transactionID) { + if !fctl.CheckStackApprobation(cmd, "You are about to delete a metadata on transaction %d", transactionID) { return nil, fctl.ErrMissingApproval } - response, err := store.Client().Ledger.V2.DeleteTransactionMetadata(cmd.Context(), operations.V2DeleteTransactionMetadataRequest{ + response, err := stackClient.Ledger.V2.DeleteTransactionMetadata(cmd.Context(), operations.V2DeleteTransactionMetadataRequest{ ID: transactionID, Key: args[1], Ledger: fctl.GetString(cmd, internal.LedgerFlag), diff --git a/cmd/ledger/transactions/list.go b/cmd/ledger/transactions/list.go index 0677f5e4..279d6498 100644 --- a/cmd/ledger/transactions/list.go +++ b/cmd/ledger/transactions/list.go @@ -4,14 +4,13 @@ import ( "fmt" "time" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" "github.com/formancehq/formance-sdk-go/v3/pkg/models/operations" "github.com/formancehq/formance-sdk-go/v3/pkg/models/shared" "github.com/formancehq/go-libs/collectionutils" - "github.com/formancehq/go-libs/pointer" + "github.com/formancehq/go-libs/v3/pointer" internal "github.com/formancehq/fctl/cmd/ledger/internal" fctl "github.com/formancehq/fctl/pkg" @@ -75,8 +74,17 @@ func (c *ListController) GetStore() *ListStore { return c.store } -func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) +func (c *ListController) Run(cmd *cobra.Command, _ []string) (fctl.Renderable, error) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } metadata, err := fctl.ParseMetadata(fctl.GetStringSlice(cmd, c.metadataFlag)) if err != nil { @@ -104,20 +112,20 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable if startTime := fctl.GetString(cmd, c.startTimeFlag); startTime != "" { t, err := time.Parse(time.RFC3339Nano, startTime) if err != nil { - return nil, errors.Wrap(err, "parsing start time") + return nil, fmt.Errorf("parsing start time: %w", err) } req.StartTime = pointer.For(t) } if endTime := fctl.GetString(cmd, c.endTimeFlag); endTime != "" { t, err := time.Parse(time.RFC3339Nano, endTime) if err != nil { - return nil, errors.Wrap(err, "parsing end time") + return nil, fmt.Errorf("parsing end time: %w", err) } req.EndTime = pointer.For(t) } req.Metadata = collectionutils.ConvertMap(metadata, collectionutils.ToAny[string]) - response, err := store.Client().Ledger.V1.ListTransactions(cmd.Context(), req) + response, err := stackClient.Ledger.V1.ListTransactions(cmd.Context(), req) if err != nil { return nil, err } diff --git a/cmd/ledger/transactions/num.go b/cmd/ledger/transactions/num.go index dac82ef0..a41239ec 100644 --- a/cmd/ledger/transactions/num.go +++ b/cmd/ledger/transactions/num.go @@ -71,14 +71,22 @@ func (c *NumController) GetStore() *NumStore { func (c *NumController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to apply a numscript") { + if !fctl.CheckStackApprobation(cmd, "You are about to apply a numscript") { return nil, fctl.ErrMissingApproval } @@ -139,7 +147,7 @@ func (c *NumController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, ledger := fctl.GetString(cmd, internal.LedgerFlag) - response, err := store.Client().Ledger.V1.CreateTransaction(cmd.Context(), operations.CreateTransactionRequest{ + response, err := stackClient.Ledger.V1.CreateTransaction(cmd.Context(), operations.CreateTransactionRequest{ PostTransaction: shared.PostTransaction{ Metadata: collectionutils.ConvertMap(metadata, collectionutils.ToAny[string]), Reference: &reference, diff --git a/cmd/ledger/transactions/revert.go b/cmd/ledger/transactions/revert.go index d9af4943..a421604d 100644 --- a/cmd/ledger/transactions/revert.go +++ b/cmd/ledger/transactions/revert.go @@ -4,7 +4,7 @@ import ( "github.com/spf13/cobra" "github.com/formancehq/formance-sdk-go/v3/pkg/models/operations" - "github.com/formancehq/go-libs/pointer" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/fctl/cmd/ledger/internal" fctl "github.com/formancehq/fctl/pkg" @@ -46,14 +46,23 @@ func (c *RevertController) GetStore() *RevertStore { } func (c *RevertController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to revert transaction %s", args[0]) { + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + if !fctl.CheckStackApprobation(cmd, "You are about to revert transaction %s", args[0]) { return nil, fctl.ErrMissingApproval } ledger := fctl.GetString(cmd, internal.LedgerFlag) - txId, err := internal.TransactionIDOrLastN(cmd.Context(), store.Client(), ledger, args[0]) + txId, err := internal.TransactionIDOrLastN(cmd.Context(), stackClient, ledger, args[0]) if err != nil { return nil, err } @@ -68,7 +77,7 @@ func (c *RevertController) Run(cmd *cobra.Command, args []string) (fctl.Renderab Force: &force, } - response, err := store.Client().Ledger.V2.RevertTransaction(cmd.Context(), request) + response, err := stackClient.Ledger.V2.RevertTransaction(cmd.Context(), request) if err != nil { return nil, err } @@ -81,7 +90,7 @@ func (c *RevertController) Run(cmd *cobra.Command, args []string) (fctl.Renderab DisableChecks: &force, } - response, err := store.Client().Ledger.V1.RevertTransaction(cmd.Context(), request) + response, err := stackClient.Ledger.V1.RevertTransaction(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/ledger/transactions/set_metadata.go b/cmd/ledger/transactions/set_metadata.go index 4402dd09..db884e0a 100644 --- a/cmd/ledger/transactions/set_metadata.go +++ b/cmd/ledger/transactions/set_metadata.go @@ -47,20 +47,28 @@ func (c *SetMetadataController) GetStore() *SetMetadataStore { func (c *SetMetadataController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } metadata, err := fctl.ParseMetadata(args[1:]) if err != nil { return nil, err } - transactionID, err := internal.TransactionIDOrLastN(cmd.Context(), store.Client(), + transactionID, err := internal.TransactionIDOrLastN(cmd.Context(), stackClient, fctl.GetString(cmd, internal.LedgerFlag), args[0]) if err != nil { return nil, err } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to set a metadata on transaction %d", transactionID) { + if !fctl.CheckStackApprobation(cmd, "You are about to set a metadata on transaction %d", transactionID) { return nil, fctl.ErrMissingApproval } @@ -69,7 +77,7 @@ func (c *SetMetadataController) Run(cmd *cobra.Command, args []string) (fctl.Ren Txid: transactionID, RequestBody: collectionutils.ConvertMap(metadata, collectionutils.ToAny[string]), } - response, err := store.Client().Ledger.V1.AddMetadataOnTransaction(cmd.Context(), request) + response, err := stackClient.Ledger.V1.AddMetadataOnTransaction(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/ledger/transactions/show.go b/cmd/ledger/transactions/show.go index 37a5fa17..6b20c88a 100644 --- a/cmd/ledger/transactions/show.go +++ b/cmd/ledger/transactions/show.go @@ -44,15 +44,24 @@ func (c *ShowController) GetStore() *ShowStore { } func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } ledger := fctl.GetString(cmd, internal.LedgerFlag) - txId, err := internal.TransactionIDOrLastN(cmd.Context(), store.Client(), ledger, args[0]) + txId, err := internal.TransactionIDOrLastN(cmd.Context(), stackClient, ledger, args[0]) if err != nil { return nil, err } - response, err := store.Client().Ledger.V1.GetTransaction(cmd.Context(), operations.GetTransactionRequest{ + response, err := stackClient.Ledger.V1.GetTransaction(cmd.Context(), operations.GetTransactionRequest{ Ledger: ledger, Txid: txId, }) diff --git a/cmd/ledger/volumes/list.go b/cmd/ledger/volumes/list.go index 2d32e769..8e1639e4 100644 --- a/cmd/ledger/volumes/list.go +++ b/cmd/ledger/volumes/list.go @@ -4,7 +4,6 @@ import ( "fmt" "time" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -40,7 +39,15 @@ func (c *ListController) GetStore() *ListStore { func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } metadata, err := fctl.ParseMetadata(fctl.GetStringSlice(cmd, c.metadataFlag)) if err != nil { @@ -104,10 +111,10 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable GroupBy: &groupBy, } - response, err := store.Client().Ledger.V2.GetVolumesWithBalances(cmd.Context(), request) + response, err := stackClient.Ledger.V2.GetVolumesWithBalances(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "Get Volumes With Balances") + return nil, fmt.Errorf("Get Volumes With Balances: %w", err) } c.store.Cursor = response.V2VolumesWithBalanceCursorResponse.Cursor diff --git a/cmd/login/controller.go b/cmd/login/controller.go deleted file mode 100644 index 8f5e5b7e..00000000 --- a/cmd/login/controller.go +++ /dev/null @@ -1,40 +0,0 @@ -package login - -import ( - "context" - "errors" - "fmt" - "net/url" - "time" - - "github.com/zitadel/oidc/v2/pkg/client/rp" - "github.com/zitadel/oidc/v2/pkg/oidc" - - fctl "github.com/formancehq/fctl/pkg" -) - -func LogIn(ctx context.Context, dialog Dialog, relyingParty rp.RelyingParty) (*oidc.AccessTokenResponse, error) { - deviceCode, err := rp.DeviceAuthorization(relyingParty.OAuthConfig().Scopes, relyingParty) - if err != nil { - return nil, err - } - - uri, err := url.Parse(deviceCode.VerificationURI) - if err != nil { - panic(err) - } - query := uri.Query() - query.Set("user_code", deviceCode.UserCode) - uri.RawQuery = query.Encode() - - if err := fctl.Open(uri.String()); err != nil { - if !errors.Is(err, fctl.ErrOpenningBrowser) { - return nil, err - } - fmt.Println("No browser detected") - } - - dialog.DisplayURIAndCode(deviceCode.VerificationURI, deviceCode.UserCode) - - return rp.DeviceAccessToken(ctx, deviceCode.DeviceCode, time.Duration(deviceCode.Interval)*time.Second, relyingParty) -} diff --git a/cmd/login/login.go b/cmd/login/login.go index 1d182cde..7f1f3581 100644 --- a/cmd/login/login.go +++ b/cmd/login/login.go @@ -1,101 +1,99 @@ package login import ( - "fmt" - "github.com/pterm/pterm" "github.com/spf13/cobra" + "github.com/zitadel/oidc/v2/pkg/oidc" fctl "github.com/formancehq/fctl/pkg" ) -type Dialog interface { - DisplayURIAndCode(uri, code string) -} -type DialogFn func(uri, code string) - -func (fn DialogFn) DisplayURIAndCode(uri, code string) { - fn(uri, code) -} - -type LoginStore struct { - profile *fctl.Profile `json:"-"` - DeviceCode string `json:"deviceCode"` - LoginURI string `json:"loginUri"` - BrowserURL string `json:"browserUrl"` - Success bool `json:"success"` +type Store struct { + profile *fctl.Profile } -type LoginController struct { - store *LoginStore +type Controller struct { + store *Store } -func NewDefaultLoginStore() *LoginStore { - return &LoginStore{ - profile: nil, - DeviceCode: "", - LoginURI: "", - BrowserURL: "", - Success: false, +func NewDefaultStore() *Store { + return &Store{ + profile: nil, } } -func (c *LoginController) GetStore() *LoginStore { +func (c *Controller) GetStore() *Store { return c.store } -func NewLoginController() *LoginController { - return &LoginController{ - store: NewDefaultLoginStore(), + +func NewLoginController() *Controller { + return &Controller{ + store: NewDefaultStore(), } } -func (c *LoginController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - cfg, err := fctl.GetConfig(cmd) +func (c *Controller) Run(cmd *cobra.Command, _ []string) (fctl.Renderable, error) { + + cfg, err := fctl.LoadConfig(cmd) + if err != nil { + return nil, err + } + + profile, profileName, err := fctl.LoadCurrentProfile(cmd, *cfg) if err != nil { return nil, err } - profile := fctl.GetCurrentProfile(cmd, cfg) membershipUri, err := cmd.Flags().GetString(fctl.MembershipURIFlag) if err != nil { return nil, err } if membershipUri == "" { membershipUri = profile.GetMembershipURI() + } else { + profile.MembershipURI = membershipUri } - relyingParty, err := fctl.GetAuthRelyingParty(fctl.GetHttpClient(cmd, map[string][]string{}), membershipUri) + relyingParty, err := fctl.GetAuthRelyingParty(cmd.Context(), fctl.GetHttpClient(cmd), membershipUri) if err != nil { return nil, err } c.store.profile = profile - ret, err := LogIn(cmd.Context(), DialogFn(func(uri, code string) { - c.store.DeviceCode = code - c.store.LoginURI = uri - fmt.Println("Link :", fmt.Sprintf("%s?user_code=%s", c.store.LoginURI, c.store.DeviceCode)) - }), relyingParty) - - // Other relying error not related to browser + ret, err := fctl.Authenticate( + cmd.Context(), + relyingParty, + fctl.NewPTermDialog(), + []fctl.AuthenticationOption{ + fctl.AuthenticateWithScopes( + oidc.ScopeOpenID, + oidc.ScopeOfflineAccess, + "accesses", + "on_behalf", + ), + fctl.AuthenticateWithPrompt("no-org"), + }, + []fctl.TokenOption{}, + ) if err != nil { return nil, err } + profile.UpdateRootToken(ret) - // Browser not found - if ret != nil { - c.store.Success = true - profile.UpdateToken(ret) - } - - profile.SetMembershipURI(membershipUri) + currentProfileName := profileName - currentProfileName := fctl.GetCurrentProfileName(cmd, cfg) + cfg.CurrentProfile = currentProfileName + if err := fctl.WriteConfig(cmd, *cfg); err != nil { + return nil, err + } - cfg.SetCurrentProfile(currentProfileName, profile) + if err := fctl.WriteProfile(cmd, currentProfileName, *profile); err != nil { + return nil, err + } - return c, cfg.Persist() + return c, nil } -func (c *LoginController) Render(cmd *cobra.Command, args []string) error { +func (c *Controller) Render(cmd *cobra.Command, args []string) error { pterm.Success.WithWriter(cmd.OutOrStdout()).Printfln("Logged!") return nil } @@ -106,6 +104,6 @@ func NewCommand() *cobra.Command { fctl.WithShortDescription("Login"), fctl.WithArgs(cobra.ExactArgs(0)), fctl.WithValidArgsFunction(cobra.NoFileCompletions), - fctl.WithController[*LoginStore](NewLoginController()), + fctl.WithController[*Store](NewLoginController()), ) } diff --git a/cmd/orchestration/instances/describe.go b/cmd/orchestration/instances/describe.go index f6343683..7d451abf 100644 --- a/cmd/orchestration/instances/describe.go +++ b/cmd/orchestration/instances/describe.go @@ -49,9 +49,18 @@ func (c *InstancesDescribeController) GetStore() *InstancesDescribeStore { } func (c *InstancesDescribeController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - response, err := store.Client().Orchestration.V1.GetInstanceHistory(cmd.Context(), operations.GetInstanceHistoryRequest{ + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + response, err := stackClient.Orchestration.V1.GetInstanceHistory(cmd.Context(), operations.GetInstanceHistoryRequest{ InstanceID: args[0], }) if err != nil { @@ -64,9 +73,19 @@ func (c *InstancesDescribeController) Run(cmd *cobra.Command, args []string) (fc } func (c *InstancesDescribeController) Render(cmd *cobra.Command, args []string) error { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return err + } + for i, history := range c.store.WorkflowInstancesHistory { - if err := printStage(cmd, i, store.Client(), args[0], history); err != nil { + if err := printStage(cmd, i, stackClient, args[0], history); err != nil { return err } } @@ -232,14 +251,14 @@ func printStage(cmd *cobra.Command, i int, client *formance.Formance, id string, listItems = append(listItems, historyItemTitle("List wallets")) } if historyStage.LastFailure != nil { - listItems = append(listItems, historyItemError(*historyStage.LastFailure)) + listItems = append(listItems, historyItemError("%s", *historyStage.LastFailure)) if historyStage.NextExecution != nil { listItems = append(listItems, historyItemError("Next try: %s", historyStage.NextExecution.Format(time.RFC3339))) listItems = append(listItems, historyItemError("Attempt: %d", historyStage.Attempt)) } } if historyStage.Error != nil { - listItems = append(listItems, historyItemError(*historyStage.Error)) + listItems = append(listItems, historyItemError("%s", *historyStage.Error)) } } case shared.StageTypeStageDelay: diff --git a/cmd/orchestration/instances/list.go b/cmd/orchestration/instances/list.go index 221d84f3..13e86b13 100644 --- a/cmd/orchestration/instances/list.go +++ b/cmd/orchestration/instances/list.go @@ -1,9 +1,9 @@ package instances import ( + "fmt" "time" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -62,9 +62,18 @@ func (c *InstancesListController) GetStore() *InstancesListStore { } func (c *InstancesListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - response, err := store.Client().Orchestration.V1.ListInstances(cmd.Context(), operations.ListInstancesRequest{ + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + response, err := stackClient.Orchestration.V1.ListInstances(cmd.Context(), operations.ListInstancesRequest{ Running: fctl.Ptr(fctl.GetBool(cmd, c.runningFlag)), WorkflowID: fctl.Ptr(fctl.GetString(cmd, c.workflowFlag)), }) @@ -114,7 +123,7 @@ func (c *InstancesListController) Render(cmd *cobra.Command, args []string) erro []string{"ID", "Workflow ID", "Created at", "Updated at", "Terminated at"}, ), ).Render(); err != nil { - return errors.Wrap(err, "rendering table") + return fmt.Errorf("rendering table: %w", err) } return nil diff --git a/cmd/orchestration/instances/send_event.go b/cmd/orchestration/instances/send_event.go index fc2f6d1f..bc060ce1 100644 --- a/cmd/orchestration/instances/send_event.go +++ b/cmd/orchestration/instances/send_event.go @@ -48,8 +48,17 @@ func (c *InstancesSendEventController) GetStore() *InstancesSendEventStore { } func (c *InstancesSendEventController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - _, err := store.Client().Orchestration.V1.SendEvent(cmd.Context(), operations.SendEventRequest{ + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + _, err = stackClient.Orchestration.V1.SendEvent(cmd.Context(), operations.SendEventRequest{ RequestBody: &operations.SendEventRequestBody{ Name: args[1], }, diff --git a/cmd/orchestration/instances/show.go b/cmd/orchestration/instances/show.go index e46da074..6f822b13 100644 --- a/cmd/orchestration/instances/show.go +++ b/cmd/orchestration/instances/show.go @@ -1,9 +1,9 @@ package instances import ( + "fmt" "time" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -48,17 +48,26 @@ func (c *InstancesShowController) GetStore() *InstancesShowStore { } func (c *InstancesShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - res, err := store.Client().Orchestration.V1.GetInstance(cmd.Context(), operations.GetInstanceRequest{ + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + res, err := stackClient.Orchestration.V1.GetInstance(cmd.Context(), operations.GetInstanceRequest{ InstanceID: args[0], }) if err != nil { - return nil, errors.Wrap(err, "reading instance") + return nil, fmt.Errorf("reading instance: %w", err) } c.store.WorkflowInstance = res.GetWorkflowInstanceResponse.Data - response, err := store.Client().Orchestration.V1.GetWorkflow(cmd.Context(), operations.GetWorkflowRequest{ + response, err := stackClient.Orchestration.V1.GetWorkflow(cmd.Context(), operations.GetWorkflowRequest{ FlowID: res.GetWorkflowInstanceResponse.Data.WorkflowID, }) if err != nil { diff --git a/cmd/orchestration/instances/stop.go b/cmd/orchestration/instances/stop.go index b27cacc0..49eaa89b 100644 --- a/cmd/orchestration/instances/stop.go +++ b/cmd/orchestration/instances/stop.go @@ -43,9 +43,18 @@ func (c *InstancesStopController) GetStore() *InstancesStopStore { } func (c *InstancesStopController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - _, err := store.Client().Orchestration.V1.CancelEvent(cmd.Context(), operations.CancelEventRequest{ + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + _, err = stackClient.Orchestration.V1.CancelEvent(cmd.Context(), operations.CancelEventRequest{ InstanceID: args[0], }) if err != nil { diff --git a/cmd/orchestration/internal/print.go b/cmd/orchestration/internal/print.go index 457f537a..4b38219d 100644 --- a/cmd/orchestration/internal/print.go +++ b/cmd/orchestration/internal/print.go @@ -1,10 +1,10 @@ package internal import ( + "fmt" "io" "time" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/formancehq/formance-sdk-go/v3/pkg/models/shared" @@ -48,7 +48,7 @@ func PrintWorkflowInstance(out io.Writer, w shared.Workflow, instance shared.Wor []string{"Name", "Started at", "Terminated at", "Error"}, ), ).Render(); err != nil { - return errors.Wrap(err, "rendering table") + return fmt.Errorf("rendering table: %w", err) } return nil } diff --git a/cmd/orchestration/root.go b/cmd/orchestration/root.go index 0bd30077..bb5384ed 100644 --- a/cmd/orchestration/root.go +++ b/cmd/orchestration/root.go @@ -19,8 +19,5 @@ func NewCommand() *cobra.Command { workflows.NewCommand(), triggers.NewCommand(), ), - fctl.WithPersistentPreRunE(func(cmd *cobra.Command, args []string) error { - return fctl.NewStackStore(cmd) - }), ) } diff --git a/cmd/orchestration/triggers/create.go b/cmd/orchestration/triggers/create.go index 78d1ac9c..a3fe7915 100644 --- a/cmd/orchestration/triggers/create.go +++ b/cmd/orchestration/triggers/create.go @@ -1,14 +1,15 @@ package triggers import ( + "errors" + "fmt" "strings" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" "github.com/formancehq/formance-sdk-go/v3/pkg/models/shared" - "github.com/formancehq/go-libs/pointer" + "github.com/formancehq/go-libs/v3/pointer" fctl "github.com/formancehq/fctl/pkg" ) @@ -56,7 +57,16 @@ func (c *TriggersCreateController) GetStore() *TriggersCreateStore { } func (c *TriggersCreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } var ( event = args[0] @@ -85,9 +95,9 @@ func (c *TriggersCreateController) Run(cmd *cobra.Command, args []string) (fctl. } } - res, err := store.Client().Orchestration.V1.CreateTrigger(cmd.Context(), data) + res, err := stackClient.Orchestration.V1.CreateTrigger(cmd.Context(), data) if err != nil { - return nil, errors.Wrap(err, "reading trigger") + return nil, fmt.Errorf("reading trigger: %w", err) } c.store.Trigger = res.CreateTriggerResponse.Data diff --git a/cmd/orchestration/triggers/delete.go b/cmd/orchestration/triggers/delete.go index a880f605..8bea3b61 100644 --- a/cmd/orchestration/triggers/delete.go +++ b/cmd/orchestration/triggers/delete.go @@ -1,7 +1,8 @@ package triggers import ( - "github.com/pkg/errors" + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -44,12 +45,21 @@ func (c *TriggersDeleteController) GetStore() *TriggersDeleteStore { } func (c *TriggersDeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - _, err := store.Client().Orchestration.V1.DeleteTrigger(cmd.Context(), operations.DeleteTriggerRequest{ + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + _, err = stackClient.Orchestration.V1.DeleteTrigger(cmd.Context(), operations.DeleteTriggerRequest{ TriggerID: args[0], }) if err != nil { - return nil, errors.Wrap(err, "deleting trigger") + return nil, fmt.Errorf("deleting trigger: %w", err) } c.store.Success = true diff --git a/cmd/orchestration/triggers/list.go b/cmd/orchestration/triggers/list.go index 85d9eacf..fdfcf5e7 100644 --- a/cmd/orchestration/triggers/list.go +++ b/cmd/orchestration/triggers/list.go @@ -1,9 +1,9 @@ package triggers import ( + "fmt" "time" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -50,9 +50,18 @@ func (c *TriggersListController) GetStore() *TriggersListStore { } func (c *TriggersListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } var name = fctl.GetString(cmd, c.nameFlag) - response, err := store.Client().Orchestration.V1.ListTriggers(cmd.Context(), operations.ListTriggersRequest{ + response, err := stackClient.Orchestration.V1.ListTriggers(cmd.Context(), operations.ListTriggersRequest{ Name: &name, }) @@ -95,7 +104,7 @@ func (c *TriggersListController) Render(cmd *cobra.Command, args []string) error []string{"ID", "Name", "Workflow ID", "Created at", "Event", "Filter"}, ), ).Render(); err != nil { - return errors.Wrap(err, "rendering table") + return fmt.Errorf("rendering table: %w", err) } return nil diff --git a/cmd/orchestration/triggers/occurrences/list.go b/cmd/orchestration/triggers/occurrences/list.go index 4fdb03e5..0307c83e 100644 --- a/cmd/orchestration/triggers/occurrences/list.go +++ b/cmd/orchestration/triggers/occurrences/list.go @@ -1,9 +1,9 @@ package occurrences import ( + "fmt" "time" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -47,9 +47,18 @@ func (c *OccurrencesListController) GetStore() *OccurrencesListStore { } func (c *OccurrencesListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - response, err := store.Client().Orchestration.V1.ListTriggersOccurrences(cmd.Context(), operations.ListTriggersOccurrencesRequest{ + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + response, err := stackClient.Orchestration.V1.ListTriggersOccurrences(cmd.Context(), operations.ListTriggersOccurrencesRequest{ TriggerID: args[0], }) if err != nil { @@ -98,7 +107,7 @@ func (c *OccurrencesListController) Render(cmd *cobra.Command, args []string) er []string{"Workflow instance ID", "Date", "Terminated", "Terminated at", "Error"}, ), ).Render(); err != nil { - return errors.Wrap(err, "rendering table") + return fmt.Errorf("rendering table: %w", err) } return nil diff --git a/cmd/orchestration/triggers/show.go b/cmd/orchestration/triggers/show.go index 75a67993..b238f33d 100644 --- a/cmd/orchestration/triggers/show.go +++ b/cmd/orchestration/triggers/show.go @@ -1,9 +1,9 @@ package triggers import ( + "fmt" "time" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -46,13 +46,22 @@ func (c *TriggersShowController) GetStore() *TriggersShowStore { } func (c *TriggersShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - res, err := store.Client().Orchestration.V1.ReadTrigger(cmd.Context(), operations.ReadTriggerRequest{ + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + res, err := stackClient.Orchestration.V1.ReadTrigger(cmd.Context(), operations.ReadTriggerRequest{ TriggerID: args[0], }) if err != nil { - return nil, errors.Wrap(err, "reading trigger") + return nil, fmt.Errorf("reading trigger: %w", err) } c.store.Trigger = res.ReadTriggerResponse.Data diff --git a/cmd/orchestration/triggers/test.go b/cmd/orchestration/triggers/test.go index 4b60e2b5..f31979f0 100644 --- a/cmd/orchestration/triggers/test.go +++ b/cmd/orchestration/triggers/test.go @@ -2,8 +2,8 @@ package triggers import ( "encoding/json" + "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -46,19 +46,28 @@ func (c *TriggersTestController) GetStore() *TriggersTestStore { } func (c *TriggersTestController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } data := make(map[string]any) if err := json.Unmarshal([]byte(args[1]), &data); err != nil { return nil, err } - res, err := store.Client().Orchestration.V2.TestTrigger(cmd.Context(), operations.TestTriggerRequest{ + res, err := stackClient.Orchestration.V2.TestTrigger(cmd.Context(), operations.TestTriggerRequest{ TriggerID: args[0], RequestBody: data, }) if err != nil { - return nil, errors.Wrap(err, "testing trigger") + return nil, fmt.Errorf("testing trigger: %w", err) } c.store.Trigger = res.V2TestTriggerResponse.Data diff --git a/cmd/orchestration/workflows/create.go b/cmd/orchestration/workflows/create.go index f54b7cbe..e28e34ed 100644 --- a/cmd/orchestration/workflows/create.go +++ b/cmd/orchestration/workflows/create.go @@ -44,9 +44,17 @@ func (c *WorkflowsCreateController) GetStore() *WorkflowsCreateStore { func (c *WorkflowsCreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -57,7 +65,7 @@ func (c *WorkflowsCreateController) Run(cmd *cobra.Command, args []string) (fctl } //nolint:gosimple - response, err := store.Client().Orchestration.V1. + response, err := stackClient.Orchestration.V1. CreateWorkflow(cmd.Context(), &shared.WorkflowConfig{ Name: config.Name, Stages: config.Stages, diff --git a/cmd/orchestration/workflows/delete.go b/cmd/orchestration/workflows/delete.go index 599b4c42..3d6b6030 100644 --- a/cmd/orchestration/workflows/delete.go +++ b/cmd/orchestration/workflows/delete.go @@ -42,9 +42,18 @@ func (c *WorkflowsDeleteController) GetStore() *WorkflowsDeleteStore { } func (c *WorkflowsDeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - _, err := store.Client().Orchestration.V1.DeleteWorkflow( + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + _, err = stackClient.Orchestration.V1.DeleteWorkflow( cmd.Context(), operations.DeleteWorkflowRequest{ FlowID: args[0], diff --git a/cmd/orchestration/workflows/list.go b/cmd/orchestration/workflows/list.go index f0cb53ef..27d01e76 100644 --- a/cmd/orchestration/workflows/list.go +++ b/cmd/orchestration/workflows/list.go @@ -1,9 +1,9 @@ package workflows import ( + "fmt" "time" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -53,9 +53,17 @@ func (c *WorkflowsListController) GetStore() *WorkflowsListStore { func (c *WorkflowsListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } - response, err := store.Client().Orchestration.V1.ListWorkflows(cmd.Context()) + response, err := stackClient.Orchestration.V1.ListWorkflows(cmd.Context()) if err != nil { return nil, err } @@ -100,7 +108,7 @@ func (c *WorkflowsListController) Render(cmd *cobra.Command, args []string) erro []string{"ID", "Name", "Created at", "Updated at"}, ), ).Render(); err != nil { - return errors.Wrap(err, "rendering table") + return fmt.Errorf("rendering table: %w", err) } return nil diff --git a/cmd/orchestration/workflows/run.go b/cmd/orchestration/workflows/run.go index 0fe86097..5cfeafba 100644 --- a/cmd/orchestration/workflows/run.go +++ b/cmd/orchestration/workflows/run.go @@ -1,9 +1,9 @@ package workflows import ( + "errors" "strings" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -57,7 +57,15 @@ func (c *WorkflowsRunController) GetStore() *WorkflowsRunStore { func (c *WorkflowsRunController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } wait := fctl.GetBool(cmd, c.waitFlag) variables := make(map[string]string) @@ -69,7 +77,7 @@ func (c *WorkflowsRunController) Run(cmd *cobra.Command, args []string) (fctl.Re variables[parts[0]] = parts[1] } - response, err := store.Client().Orchestration.V1. + response, err := stackClient.Orchestration.V1. RunWorkflow(cmd.Context(), operations.RunWorkflowRequest{ RequestBody: variables, Wait: &wait, @@ -85,10 +93,19 @@ func (c *WorkflowsRunController) Run(cmd *cobra.Command, args []string) (fctl.Re } func (c *WorkflowsRunController) Render(cmd *cobra.Command, args []string) error { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return err + } pterm.Success.WithWriter(cmd.OutOrStdout()).Printfln("Workflow instance created with ID: %s", c.store.WorkflowInstance.ID) if c.wait { - w, err := store.Client().Orchestration.V1.GetWorkflow(cmd.Context(), operations.GetWorkflowRequest{ + w, err := stackClient.Orchestration.V1.GetWorkflow(cmd.Context(), operations.GetWorkflowRequest{ FlowID: args[0], }) if err != nil { diff --git a/cmd/orchestration/workflows/show.go b/cmd/orchestration/workflows/show.go index 707f3b0d..ebeffef5 100644 --- a/cmd/orchestration/workflows/show.go +++ b/cmd/orchestration/workflows/show.go @@ -48,9 +48,17 @@ func (c *WorkflowsShowController) GetStore() *WorkflowsShowStore { func (c *WorkflowsShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } - response, err := store.Client().Orchestration.V1. + response, err := stackClient.Orchestration.V1. GetWorkflow(cmd.Context(), operations.GetWorkflowRequest{ FlowID: args[0], }) diff --git a/cmd/payments/accounts/balances.go b/cmd/payments/accounts/balances.go index c43720e4..11acb042 100644 --- a/cmd/payments/accounts/balances.go +++ b/cmd/payments/accounts/balances.go @@ -46,7 +46,16 @@ func (c *ListBalancesController) GetStore() *ListBalancesStore { } func (c *ListBalancesController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } var cursor *string if c := fctl.GetString(cmd, c.cursorFlag); c != "" { @@ -58,7 +67,7 @@ func (c *ListBalancesController) Run(cmd *cobra.Command, args []string) (fctl.Re pageSize = fctl.Ptr(int64(ps)) } - response, err := store.Client().Payments.V1.GetAccountBalances( + response, err := stackClient.Payments.V1.GetAccountBalances( cmd.Context(), operations.GetAccountBalancesRequest{ Cursor: cursor, diff --git a/cmd/payments/accounts/create.go b/cmd/payments/accounts/create.go index 5de90213..fcda8b8e 100644 --- a/cmd/payments/accounts/create.go +++ b/cmd/payments/accounts/create.go @@ -54,7 +54,16 @@ func (c *CreateController) GetStore() *CreateStore { } func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err } @@ -63,11 +72,11 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab return nil, fmt.Errorf("accounts creation are only supported in >= v1.0.0") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to create an account") { + if !fctl.CheckStackApprobation(cmd, "You are about to create an account") { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -78,7 +87,7 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab } //nolint:gosimple - response, err := store.Client().Payments.V1.CreateAccount(cmd.Context(), request) + response, err := stackClient.Payments.V1.CreateAccount(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/payments/accounts/list.go b/cmd/payments/accounts/list.go index 311314a9..63ace3fe 100644 --- a/cmd/payments/accounts/list.go +++ b/cmd/payments/accounts/list.go @@ -46,7 +46,16 @@ func (c *ListController) GetStore() *ListStore { } func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } var cursor *string if c := fctl.GetString(cmd, c.cursorFlag); c != "" { cursor = &c @@ -57,7 +66,7 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable pageSize = fctl.Ptr(int64(ps)) } - response, err := store.Client().Payments.V1.PaymentslistAccounts( + response, err := stackClient.Payments.V1.PaymentslistAccounts( cmd.Context(), operations.PaymentslistAccountsRequest{ Cursor: cursor, diff --git a/cmd/payments/accounts/show.go b/cmd/payments/accounts/show.go index 9600111c..646f08a1 100644 --- a/cmd/payments/accounts/show.go +++ b/cmd/payments/accounts/show.go @@ -47,9 +47,18 @@ func (c *ShowController) GetStore() *ShowStore { } func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - response, err := store.Client().Payments.V1.PaymentsgetAccount(cmd.Context(), operations.PaymentsgetAccountRequest{ + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + response, err := stackClient.Payments.V1.PaymentsgetAccount(cmd.Context(), operations.PaymentsgetAccountRequest{ AccountID: args[0], }) if err != nil { diff --git a/cmd/payments/bankaccounts/create.go b/cmd/payments/bankaccounts/create.go index 05d1a6cc..c3fea242 100644 --- a/cmd/payments/bankaccounts/create.go +++ b/cmd/payments/bankaccounts/create.go @@ -54,7 +54,16 @@ func (c *CreateController) GetStore() *CreateStore { } func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -64,11 +73,11 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab return nil, fmt.Errorf("bank accounts are only supported in >= v1.0.0") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to create a bank account") { + if !fctl.CheckStackApprobation(cmd, "You are about to create a bank account") { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -79,7 +88,7 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab return nil, err } - response, err := store.Client().Payments.V3.CreateBankAccount(cmd.Context(), &request) + response, err := stackClient.Payments.V3.CreateBankAccount(cmd.Context(), &request) if err != nil { return nil, err } @@ -97,7 +106,7 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab } //nolint:gosimple - response, err := store.Client().Payments.V1.CreateBankAccount(cmd.Context(), request) + response, err := stackClient.Payments.V1.CreateBankAccount(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/payments/bankaccounts/forward.go b/cmd/payments/bankaccounts/forward.go index 12d2fa83..d05408d4 100644 --- a/cmd/payments/bankaccounts/forward.go +++ b/cmd/payments/bankaccounts/forward.go @@ -1,9 +1,9 @@ package bankaccounts import ( + "errors" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -59,7 +59,16 @@ func (c *ForwardController) GetStore() *ForwardStore { } func (c *ForwardController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -69,7 +78,7 @@ func (c *ForwardController) Run(cmd *cobra.Command, args []string) (fctl.Rendera return nil, fmt.Errorf("bank accounts are only supported in >= v1.0.0") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to forward a bank account to a connector") { + if !fctl.CheckStackApprobation(cmd, "You are about to forward a bank account to a connector") { return nil, fctl.ErrMissingApproval } @@ -85,7 +94,7 @@ func (c *ForwardController) Run(cmd *cobra.Command, args []string) (fctl.Rendera if c.PaymentsVersion < versions.V3 { //nolint:gosimple - response, err := store.Client().Payments.V1.ForwardBankAccount(cmd.Context(), operations.ForwardBankAccountRequest{ + response, err := stackClient.Payments.V1.ForwardBankAccount(cmd.Context(), operations.ForwardBankAccountRequest{ ForwardBankAccountRequest: shared.ForwardBankAccountRequest{ ConnectorID: connectorID, }, @@ -105,7 +114,7 @@ func (c *ForwardController) Run(cmd *cobra.Command, args []string) (fctl.Rendera return c, nil } - response, err := store.Client().Payments.V3.ForwardBankAccount(cmd.Context(), operations.V3ForwardBankAccountRequest{ + response, err := stackClient.Payments.V3.ForwardBankAccount(cmd.Context(), operations.V3ForwardBankAccountRequest{ V3ForwardBankAccountRequest: &shared.V3ForwardBankAccountRequest{ ConnectorID: connectorID, }, diff --git a/cmd/payments/bankaccounts/list.go b/cmd/payments/bankaccounts/list.go index 3a74005a..01a343c5 100644 --- a/cmd/payments/bankaccounts/list.go +++ b/cmd/payments/bankaccounts/list.go @@ -7,6 +7,7 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" + formance "github.com/formancehq/formance-sdk-go/v3" "github.com/formancehq/formance-sdk-go/v3/pkg/models/operations" "github.com/formancehq/formance-sdk-go/v3/pkg/models/shared" @@ -53,7 +54,16 @@ func (c *ListController) GetStore() *ListStore { } func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -74,10 +84,10 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable } if c.PaymentsVersion >= versions.V3 { - return c.v3list(cmd, store, cursor, pageSize) + return c.v3list(cmd, stackClient, cursor, pageSize) } - response, err := store.Client().Payments.V1.ListBankAccounts( + response, err := stackClient.Payments.V1.ListBankAccounts( cmd.Context(), operations.ListBankAccountsRequest{ Cursor: cursor, @@ -97,8 +107,8 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable return c, nil } -func (c *ListController) v3list(cmd *cobra.Command, store *fctl.StackStore, cursor *string, pageSize *int64) (fctl.Renderable, error) { - response, err := store.Client().Payments.V3.ListBankAccounts( +func (c *ListController) v3list(cmd *cobra.Command, stackClient *formance.Formance, cursor *string, pageSize *int64) (fctl.Renderable, error) { + response, err := stackClient.Payments.V3.ListBankAccounts( cmd.Context(), operations.V3ListBankAccountsRequest{ Cursor: cursor, diff --git a/cmd/payments/bankaccounts/show.go b/cmd/payments/bankaccounts/show.go index 2e9437f0..027ed9a4 100644 --- a/cmd/payments/bankaccounts/show.go +++ b/cmd/payments/bankaccounts/show.go @@ -54,7 +54,16 @@ func (c *ShowController) GetStore() *ShowStore { } func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -65,7 +74,7 @@ func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable } if c.PaymentsVersion >= versions.V3 { - response, err := store.Client().Payments.V3.GetBankAccount(cmd.Context(), operations.V3GetBankAccountRequest{ + response, err := stackClient.Payments.V3.GetBankAccount(cmd.Context(), operations.V3GetBankAccountRequest{ BankAccountID: args[0], }) if err != nil { @@ -80,7 +89,7 @@ func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable return c, nil } - response, err := store.Client().Payments.V1.GetBankAccount(cmd.Context(), operations.GetBankAccountRequest{ + response, err := stackClient.Payments.V1.GetBankAccount(cmd.Context(), operations.GetBankAccountRequest{ BankAccountID: args[0], }) if err != nil { diff --git a/cmd/payments/bankaccounts/update_metadata.go b/cmd/payments/bankaccounts/update_metadata.go index 540aaa22..09342b46 100644 --- a/cmd/payments/bankaccounts/update_metadata.go +++ b/cmd/payments/bankaccounts/update_metadata.go @@ -54,7 +54,16 @@ func (c *UpdateMetadataController) GetStore() *UpdateMetadataStore { } func (c *UpdateMetadataController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -71,7 +80,7 @@ func (c *UpdateMetadataController) Run(cmd *cobra.Command, args []string) (fctl. bankAccountID := args[0] - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to set a metadata on bank account '%s'", bankAccountID) { + if !fctl.CheckStackApprobation(cmd, "You are about to set a metadata on bank account '%s'", bankAccountID) { return nil, fctl.ErrMissingApproval } if c.PaymentsVersion >= versions.V3 { @@ -82,7 +91,7 @@ func (c *UpdateMetadataController) Run(cmd *cobra.Command, args []string) (fctl. BankAccountID: bankAccountID, } - response, err := store.Client().Payments.V3.UpdateBankAccountMetadata(cmd.Context(), request) + response, err := stackClient.Payments.V3.UpdateBankAccountMetadata(cmd.Context(), request) if err != nil { return nil, err } @@ -102,7 +111,7 @@ func (c *UpdateMetadataController) Run(cmd *cobra.Command, args []string) (fctl. BankAccountID: bankAccountID, } - response, err := store.Client().Payments.V1.UpdateBankAccountMetadata(cmd.Context(), request) + response, err := stackClient.Payments.V1.UpdateBankAccountMetadata(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/payments/connectors/configs/adyen.go b/cmd/payments/connectors/configs/adyen.go index 75917eda..7c985d17 100644 --- a/cmd/payments/connectors/configs/adyen.go +++ b/cmd/payments/connectors/configs/adyen.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -64,7 +63,16 @@ func (c *UpdateAdyenConnectorConfigController) GetStore() *UpdateAdyenConnectorC } func (c *UpdateAdyenConnectorConfigController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -78,11 +86,11 @@ func (c *UpdateAdyenConnectorConfigController) Run(cmd *cobra.Command, args []st if connectorID == "" { return nil, fmt.Errorf("missing connector ID") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to update the config of connector '%s'", connectorID) { + if !fctl.CheckStackApprobation(cmd, "You are about to update the config of connector '%s'", connectorID) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -92,7 +100,7 @@ func (c *UpdateAdyenConnectorConfigController) Run(cmd *cobra.Command, args []st return nil, err } - response, err := store.Client().Payments.V1.UpdateConnectorConfigV1(cmd.Context(), operations.UpdateConnectorConfigV1Request{ + response, err := stackClient.Payments.V1.UpdateConnectorConfigV1(cmd.Context(), operations.UpdateConnectorConfigV1Request{ ConnectorConfig: shared.ConnectorConfig{ AdyenConfig: config, }, @@ -100,7 +108,7 @@ func (c *UpdateAdyenConnectorConfigController) Run(cmd *cobra.Command, args []st ConnectorID: connectorID, }) if err != nil { - return nil, errors.Wrap(err, "updating config of connector") + return nil, fmt.Errorf("updating config of connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/configs/atlar.go b/cmd/payments/connectors/configs/atlar.go index a880bf6a..7933e543 100644 --- a/cmd/payments/connectors/configs/atlar.go +++ b/cmd/payments/connectors/configs/atlar.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -64,7 +63,16 @@ func (c *UpdateAtlarConnectorConfigController) GetStore() *UpdateAtlarConnectorC } func (c *UpdateAtlarConnectorConfigController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -79,11 +87,11 @@ func (c *UpdateAtlarConnectorConfigController) Run(cmd *cobra.Command, args []st return nil, fmt.Errorf("missing connector ID") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to update the config of connector '%s'", connectorID) { + if !fctl.CheckStackApprobation(cmd, "You are about to update the config of connector '%s'", connectorID) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -93,7 +101,7 @@ func (c *UpdateAtlarConnectorConfigController) Run(cmd *cobra.Command, args []st return nil, err } - response, err := store.Client().Payments.V1.UpdateConnectorConfigV1(cmd.Context(), operations.UpdateConnectorConfigV1Request{ + response, err := stackClient.Payments.V1.UpdateConnectorConfigV1(cmd.Context(), operations.UpdateConnectorConfigV1Request{ ConnectorConfig: shared.ConnectorConfig{ AtlarConfig: config, }, @@ -101,7 +109,7 @@ func (c *UpdateAtlarConnectorConfigController) Run(cmd *cobra.Command, args []st ConnectorID: connectorID, }) if err != nil { - return nil, errors.Wrap(err, "updating config of connector") + return nil, fmt.Errorf("updating config of connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/configs/bankingcircle.go b/cmd/payments/connectors/configs/bankingcircle.go index 95f57276..5799831d 100644 --- a/cmd/payments/connectors/configs/bankingcircle.go +++ b/cmd/payments/connectors/configs/bankingcircle.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -64,7 +63,16 @@ func (c *UpdateBankingCircleConnectorConfigController) GetStore() *UpdateBanking } func (c *UpdateBankingCircleConnectorConfigController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -79,11 +87,11 @@ func (c *UpdateBankingCircleConnectorConfigController) Run(cmd *cobra.Command, a return nil, fmt.Errorf("missing connector ID") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to update the config of connector '%s'", connectorID) { + if !fctl.CheckStackApprobation(cmd, "You are about to update the config of connector '%s'", connectorID) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -93,7 +101,7 @@ func (c *UpdateBankingCircleConnectorConfigController) Run(cmd *cobra.Command, a return nil, err } - response, err := store.Client().Payments.V1.UpdateConnectorConfigV1(cmd.Context(), operations.UpdateConnectorConfigV1Request{ + response, err := stackClient.Payments.V1.UpdateConnectorConfigV1(cmd.Context(), operations.UpdateConnectorConfigV1Request{ ConnectorConfig: shared.ConnectorConfig{ BankingCircleConfig: config, }, @@ -101,7 +109,7 @@ func (c *UpdateBankingCircleConnectorConfigController) Run(cmd *cobra.Command, a ConnectorID: connectorID, }) if err != nil { - return nil, errors.Wrap(err, "updating config of connector") + return nil, fmt.Errorf("updating config of connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/configs/column.go b/cmd/payments/connectors/configs/column.go index 965f2fc1..7aa9b9f9 100644 --- a/cmd/payments/connectors/configs/column.go +++ b/cmd/payments/connectors/configs/column.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -64,18 +63,27 @@ func (c *UpdateColumnConnectorConfigController) GetStore() *UpdateColumnConnecto } func (c *UpdateColumnConnectorConfigController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } connectorID := fctl.GetString(cmd, c.connectorIDFlag) if connectorID == "" { return nil, fmt.Errorf("missing connector ID") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to update the config of connector '%s'", connectorID) { + if !fctl.CheckStackApprobation(cmd, "You are about to update the config of connector '%s'", connectorID) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -85,14 +93,14 @@ func (c *UpdateColumnConnectorConfigController) Run(cmd *cobra.Command, args []s return nil, err } - response, err := store.Client().Payments.V3.V3UpdateConnectorConfig(cmd.Context(), operations.V3UpdateConnectorConfigRequest{ + response, err := stackClient.Payments.V3.V3UpdateConnectorConfig(cmd.Context(), operations.V3UpdateConnectorConfigRequest{ V3InstallConnectorRequest: &shared.V3InstallConnectorRequest{ V3ColumnConfig: config, }, ConnectorID: connectorID, }) if err != nil { - return nil, errors.Wrap(err, "updating config of connector") + return nil, fmt.Errorf("updating config of connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/configs/currencycloud.go b/cmd/payments/connectors/configs/currencycloud.go index f0dd26cb..0d386fcf 100644 --- a/cmd/payments/connectors/configs/currencycloud.go +++ b/cmd/payments/connectors/configs/currencycloud.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -64,7 +63,16 @@ func (c *UpdateCurrencyCloudConnectorConfigController) GetStore() *UpdateCurrenc } func (c *UpdateCurrencyCloudConnectorConfigController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -79,11 +87,11 @@ func (c *UpdateCurrencyCloudConnectorConfigController) Run(cmd *cobra.Command, a return nil, fmt.Errorf("missing connector ID") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to update the config of connector '%s'", connectorID) { + if !fctl.CheckStackApprobation(cmd, "You are about to update the config of connector '%s'", connectorID) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -93,7 +101,7 @@ func (c *UpdateCurrencyCloudConnectorConfigController) Run(cmd *cobra.Command, a return nil, err } - response, err := store.Client().Payments.V1.UpdateConnectorConfigV1(cmd.Context(), operations.UpdateConnectorConfigV1Request{ + response, err := stackClient.Payments.V1.UpdateConnectorConfigV1(cmd.Context(), operations.UpdateConnectorConfigV1Request{ ConnectorConfig: shared.ConnectorConfig{ CurrencyCloudConfig: config, }, @@ -101,7 +109,7 @@ func (c *UpdateCurrencyCloudConnectorConfigController) Run(cmd *cobra.Command, a ConnectorID: connectorID, }) if err != nil { - return nil, errors.Wrap(err, "updating config of connector") + return nil, fmt.Errorf("updating config of connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/configs/getconfig.go b/cmd/payments/connectors/configs/getconfig.go index cf8e3400..0909b7da 100644 --- a/cmd/payments/connectors/configs/getconfig.go +++ b/cmd/payments/connectors/configs/getconfig.go @@ -17,58 +17,67 @@ import ( fctl "github.com/formancehq/fctl/pkg" ) -type PaymentsGetConfigStore struct { +type PaymentsLoadConfigStore struct { ConnectorConfig *shared.ConnectorConfigResponse `json:"connectorConfig"` Provider string `json:"provider"` ConnectorID string `json:"connectorId"` } -type PaymentsGetConfigController struct { +type PaymentsLoadConfigController struct { PaymentsVersion versions.Version - store *PaymentsGetConfigStore + store *PaymentsLoadConfigStore providerNameFlag string connectorIDFlag string } -func (c *PaymentsGetConfigController) SetVersion(version versions.Version) { +func (c *PaymentsLoadConfigController) SetVersion(version versions.Version) { c.PaymentsVersion = version } -var _ fctl.Controller[*PaymentsGetConfigStore] = (*PaymentsGetConfigController)(nil) +var _ fctl.Controller[*PaymentsLoadConfigStore] = (*PaymentsLoadConfigController)(nil) -func NewDefaultPaymentsGetConfigStore() *PaymentsGetConfigStore { - return &PaymentsGetConfigStore{} +func NewDefaultPaymentsLoadConfigStore() *PaymentsLoadConfigStore { + return &PaymentsLoadConfigStore{} } -func NewPaymentsGetConfigController() *PaymentsGetConfigController { - return &PaymentsGetConfigController{ - store: NewDefaultPaymentsGetConfigStore(), +func NewPaymentsLoadConfigController() *PaymentsLoadConfigController { + return &PaymentsLoadConfigController{ + store: NewDefaultPaymentsLoadConfigStore(), providerNameFlag: "provider", connectorIDFlag: "connector-id", } } -func NewGetConfigCommand() *cobra.Command { - c := NewPaymentsGetConfigController() +func NewLoadConfigCommand() *cobra.Command { + c := NewPaymentsLoadConfigController() return fctl.NewCommand("get-config", - fctl.WithAliases("getconfig", "getconf", "gc", "get", "g"), + fctl.WithAliases("LoadConfig", "getconf", "gc", "get", "g"), fctl.WithArgs(cobra.ExactArgs(0)), fctl.WithValidArgsFunction(cobra.NoFileCompletions), fctl.WithStringFlag("provider", "", "Provider name"), fctl.WithStringFlag("connector-id", "", "Connector ID"), fctl.WithShortDescription(fmt.Sprintf("Read a connector config (Connectors available: %v)", internal.AllConnectors)), - fctl.WithController[*PaymentsGetConfigStore](c), + fctl.WithController[*PaymentsLoadConfigStore](c), ) } -func (c *PaymentsGetConfigController) GetStore() *PaymentsGetConfigStore { +func (c *PaymentsLoadConfigController) GetStore() *PaymentsLoadConfigStore { return c.store } -func (c *PaymentsGetConfigController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) +func (c *PaymentsLoadConfigController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -83,7 +92,7 @@ func (c *PaymentsGetConfigController) Run(cmd *cobra.Command, args []string) (fc return nil, fmt.Errorf("provider is required") } - response, err := store.Client().Payments.V1.ReadConnectorConfig(cmd.Context(), operations.ReadConnectorConfigRequest{ + response, err := stackClient.Payments.V1.ReadConnectorConfig(cmd.Context(), operations.ReadConnectorConfigRequest{ Connector: shared.Connector(provider), }) if err != nil { @@ -98,7 +107,7 @@ func (c *PaymentsGetConfigController) Run(cmd *cobra.Command, args []string) (fc c.store.ConnectorConfig = response.ConnectorConfigResponse default: - connectorList, err := store.Client().Payments.V1.ListAllConnectors(cmd.Context()) + connectorList, err := stackClient.Payments.V1.ListAllConnectors(cmd.Context()) if err != nil { return nil, err } @@ -138,7 +147,7 @@ func (c *PaymentsGetConfigController) Run(cmd *cobra.Command, args []string) (fc provider = strings.Split(strings.Split(selectedOption, " ")[1], ":")[1] } - response, err := store.Client().Payments.V1.ReadConnectorConfigV1(cmd.Context(), operations.ReadConnectorConfigV1Request{ + response, err := stackClient.Payments.V1.ReadConnectorConfigV1(cmd.Context(), operations.ReadConnectorConfigV1Request{ Connector: shared.Connector(provider), ConnectorID: connectorID, }) @@ -160,7 +169,7 @@ func (c *PaymentsGetConfigController) Run(cmd *cobra.Command, args []string) (fc } // TODO: This need to use the ui.NewListModel -func (c *PaymentsGetConfigController) Render(cmd *cobra.Command, args []string) error { +func (c *PaymentsLoadConfigController) Render(cmd *cobra.Command, args []string) error { var err error switch c.store.Provider { case internal.StripeConnector: diff --git a/cmd/payments/connectors/configs/mangopay.go b/cmd/payments/connectors/configs/mangopay.go index 867a1591..10dda20e 100644 --- a/cmd/payments/connectors/configs/mangopay.go +++ b/cmd/payments/connectors/configs/mangopay.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -64,7 +63,16 @@ func (c *UpdateMangopayConnectorConfigController) GetStore() *UpdateMangopayConn } func (c *UpdateMangopayConnectorConfigController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -79,11 +87,11 @@ func (c *UpdateMangopayConnectorConfigController) Run(cmd *cobra.Command, args [ return nil, fmt.Errorf("connector ID is required") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to update the config of connector '%s'", connectorID) { + if !fctl.CheckStackApprobation(cmd, "You are about to update the config of connector '%s'", connectorID) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -93,7 +101,7 @@ func (c *UpdateMangopayConnectorConfigController) Run(cmd *cobra.Command, args [ return nil, err } - response, err := store.Client().Payments.V1.UpdateConnectorConfigV1(cmd.Context(), operations.UpdateConnectorConfigV1Request{ + response, err := stackClient.Payments.V1.UpdateConnectorConfigV1(cmd.Context(), operations.UpdateConnectorConfigV1Request{ ConnectorConfig: shared.ConnectorConfig{ MangoPayConfig: config, }, @@ -101,7 +109,7 @@ func (c *UpdateMangopayConnectorConfigController) Run(cmd *cobra.Command, args [ ConnectorID: connectorID, }) if err != nil { - return nil, errors.Wrap(err, "updating config of connector") + return nil, fmt.Errorf("updating config of connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/configs/modulr.go b/cmd/payments/connectors/configs/modulr.go index f85b5a5d..7bd7ade9 100644 --- a/cmd/payments/connectors/configs/modulr.go +++ b/cmd/payments/connectors/configs/modulr.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -64,7 +63,16 @@ func (c *UpdateModulrConnectorConfigController) GetStore() *UpdateModulrConnecto } func (c *UpdateModulrConnectorConfigController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -79,11 +87,11 @@ func (c *UpdateModulrConnectorConfigController) Run(cmd *cobra.Command, args []s return nil, fmt.Errorf("missing connector ID") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to update the config of connector '%s'", connectorID) { + if !fctl.CheckStackApprobation(cmd, "You are about to update the config of connector '%s'", connectorID) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -93,7 +101,7 @@ func (c *UpdateModulrConnectorConfigController) Run(cmd *cobra.Command, args []s return nil, err } - response, err := store.Client().Payments.V1.UpdateConnectorConfigV1(cmd.Context(), operations.UpdateConnectorConfigV1Request{ + response, err := stackClient.Payments.V1.UpdateConnectorConfigV1(cmd.Context(), operations.UpdateConnectorConfigV1Request{ ConnectorConfig: shared.ConnectorConfig{ ModulrConfig: config, }, @@ -101,7 +109,7 @@ func (c *UpdateModulrConnectorConfigController) Run(cmd *cobra.Command, args []s ConnectorID: connectorID, }) if err != nil { - return nil, errors.Wrap(err, "updating config of connector") + return nil, fmt.Errorf("updating config of connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/configs/moneycorp.go b/cmd/payments/connectors/configs/moneycorp.go index 947b2ec7..bc135dbe 100644 --- a/cmd/payments/connectors/configs/moneycorp.go +++ b/cmd/payments/connectors/configs/moneycorp.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -64,7 +63,16 @@ func (c *UpdateMoneycorpConnectorConfigController) GetStore() *UpdateMoneycorpCo } func (c *UpdateMoneycorpConnectorConfigController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -79,11 +87,11 @@ func (c *UpdateMoneycorpConnectorConfigController) Run(cmd *cobra.Command, args return nil, fmt.Errorf("missing connector ID") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to update the config of connector '%s'", connectorID) { + if !fctl.CheckStackApprobation(cmd, "You are about to update the config of connector '%s'", connectorID) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -93,7 +101,7 @@ func (c *UpdateMoneycorpConnectorConfigController) Run(cmd *cobra.Command, args return nil, err } - response, err := store.Client().Payments.V1.UpdateConnectorConfigV1(cmd.Context(), operations.UpdateConnectorConfigV1Request{ + response, err := stackClient.Payments.V1.UpdateConnectorConfigV1(cmd.Context(), operations.UpdateConnectorConfigV1Request{ ConnectorConfig: shared.ConnectorConfig{ MoneycorpConfig: config, }, @@ -101,7 +109,7 @@ func (c *UpdateMoneycorpConnectorConfigController) Run(cmd *cobra.Command, args ConnectorID: connectorID, }) if err != nil { - return nil, errors.Wrap(err, "updating config of connector") + return nil, fmt.Errorf("updating config of connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/configs/qonto.go b/cmd/payments/connectors/configs/qonto.go index cae358c9..767820e6 100644 --- a/cmd/payments/connectors/configs/qonto.go +++ b/cmd/payments/connectors/configs/qonto.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -64,18 +63,27 @@ func (c *UpdateQontoConnectorConfigController) GetStore() *UpdateQontoConnectorC } func (c *UpdateQontoConnectorConfigController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } connectorID := fctl.GetString(cmd, c.connectorIDFlag) if connectorID == "" { return nil, fmt.Errorf("missing connector ID") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to update the config of connector '%s'", connectorID) { + if !fctl.CheckStackApprobation(cmd, "You are about to update the config of connector '%s'", connectorID) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -85,14 +93,14 @@ func (c *UpdateQontoConnectorConfigController) Run(cmd *cobra.Command, args []st return nil, err } - response, err := store.Client().Payments.V3.V3UpdateConnectorConfig(cmd.Context(), operations.V3UpdateConnectorConfigRequest{ + response, err := stackClient.Payments.V3.V3UpdateConnectorConfig(cmd.Context(), operations.V3UpdateConnectorConfigRequest{ V3InstallConnectorRequest: &shared.V3InstallConnectorRequest{ V3QontoConfig: config, }, ConnectorID: connectorID, }) if err != nil { - return nil, errors.Wrap(err, "updating config of connector") + return nil, fmt.Errorf("updating config of connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/configs/stripe.go b/cmd/payments/connectors/configs/stripe.go index dbc9c7bc..df1a5e5e 100644 --- a/cmd/payments/connectors/configs/stripe.go +++ b/cmd/payments/connectors/configs/stripe.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -65,7 +64,15 @@ func (c *UpdateStripeConnectorConfigController) GetStore() *UpdateStripeConnecto func (c *UpdateStripeConnectorConfigController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -80,11 +87,11 @@ func (c *UpdateStripeConnectorConfigController) Run(cmd *cobra.Command, args []s return nil, fmt.Errorf("missing connector ID") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to update the config of connector '%s'", connectorID) { + if !fctl.CheckStackApprobation(cmd, "You are about to update the config of connector '%s'", connectorID) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -94,7 +101,7 @@ func (c *UpdateStripeConnectorConfigController) Run(cmd *cobra.Command, args []s return nil, err } - response, err := store.Client().Payments.V1.UpdateConnectorConfigV1(cmd.Context(), operations.UpdateConnectorConfigV1Request{ + response, err := stackClient.Payments.V1.UpdateConnectorConfigV1(cmd.Context(), operations.UpdateConnectorConfigV1Request{ ConnectorConfig: shared.ConnectorConfig{ StripeConfig: config, }, @@ -102,7 +109,7 @@ func (c *UpdateStripeConnectorConfigController) Run(cmd *cobra.Command, args []s ConnectorID: connectorID, }) if err != nil { - return nil, errors.Wrap(err, "updating config of connector") + return nil, fmt.Errorf("updating config of connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/configs/wise.go b/cmd/payments/connectors/configs/wise.go index 425548c1..45a9adfa 100644 --- a/cmd/payments/connectors/configs/wise.go +++ b/cmd/payments/connectors/configs/wise.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -64,7 +63,16 @@ func (c *UpdateWiseConnectorConfigController) GetStore() *UpdateWiseConnectorCon } func (c *UpdateWiseConnectorConfigController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -78,11 +86,11 @@ func (c *UpdateWiseConnectorConfigController) Run(cmd *cobra.Command, args []str if connectorID == "" { return nil, fmt.Errorf("missing connector ID") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to update the config of connector '%s'", connectorID) { + if !fctl.CheckStackApprobation(cmd, "You are about to update the config of connector '%s'", connectorID) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -92,7 +100,7 @@ func (c *UpdateWiseConnectorConfigController) Run(cmd *cobra.Command, args []str return nil, err } - response, err := store.Client().Payments.V1.UpdateConnectorConfigV1(cmd.Context(), operations.UpdateConnectorConfigV1Request{ + response, err := stackClient.Payments.V1.UpdateConnectorConfigV1(cmd.Context(), operations.UpdateConnectorConfigV1Request{ ConnectorConfig: shared.ConnectorConfig{ WiseConfig: config, }, @@ -100,7 +108,7 @@ func (c *UpdateWiseConnectorConfigController) Run(cmd *cobra.Command, args []str ConnectorID: connectorID, }) if err != nil { - return nil, errors.Wrap(err, "updating config of connector") + return nil, fmt.Errorf("updating config of connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/install/adyen.go b/cmd/payments/connectors/install/adyen.go index 25f24ef8..50f7c165 100644 --- a/cmd/payments/connectors/install/adyen.go +++ b/cmd/payments/connectors/install/adyen.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -54,11 +53,20 @@ func (c *PaymentsConnectorsAdyenController) GetStore() *PaymentsConnectorsAdyenS } func (c *PaymentsConnectorsAdyenController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to install connector '%s'", internal.AdyenConnector) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + if !fctl.CheckStackApprobation(cmd, "You are about to install connector '%s'", internal.AdyenConnector) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -68,14 +76,14 @@ func (c *PaymentsConnectorsAdyenController) Run(cmd *cobra.Command, args []strin return nil, err } - response, err := store.Client().Payments.V1.InstallConnector(cmd.Context(), operations.InstallConnectorRequest{ + response, err := stackClient.Payments.V1.InstallConnector(cmd.Context(), operations.InstallConnectorRequest{ ConnectorConfig: shared.ConnectorConfig{ AdyenConfig: &config, }, Connector: shared.ConnectorAdyen, }) if err != nil { - return nil, errors.Wrap(err, "installing connector") + return nil, fmt.Errorf("installing connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/install/atlar.go b/cmd/payments/connectors/install/atlar.go index ed8db684..c74e0dd7 100644 --- a/cmd/payments/connectors/install/atlar.go +++ b/cmd/payments/connectors/install/atlar.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -54,11 +53,20 @@ func (c *PaymentsConnectorsAtlarController) GetStore() *PaymentsConnectorsAtlarS } func (c *PaymentsConnectorsAtlarController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to install connector '%s'", internal.AtlarConnector) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + if !fctl.CheckStackApprobation(cmd, "You are about to install connector '%s'", internal.AtlarConnector) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -68,14 +76,14 @@ func (c *PaymentsConnectorsAtlarController) Run(cmd *cobra.Command, args []strin return nil, err } - response, err := store.Client().Payments.V1.InstallConnector(cmd.Context(), operations.InstallConnectorRequest{ + response, err := stackClient.Payments.V1.InstallConnector(cmd.Context(), operations.InstallConnectorRequest{ ConnectorConfig: shared.ConnectorConfig{ AtlarConfig: &config, }, Connector: shared.ConnectorAtlar, }) if err != nil { - return nil, errors.Wrap(err, "installing connector") + return nil, fmt.Errorf("installing connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/install/bankingcircle.go b/cmd/payments/connectors/install/bankingcircle.go index 01457ff7..bcea1a34 100644 --- a/cmd/payments/connectors/install/bankingcircle.go +++ b/cmd/payments/connectors/install/bankingcircle.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -53,11 +52,20 @@ func (c *PaymentsConnectorsBankingCircleController) GetStore() *PaymentsConnecto } func (c *PaymentsConnectorsBankingCircleController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to install connector '%s'", internal.BankingCircleConnector) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + if !fctl.CheckStackApprobation(cmd, "You are about to install connector '%s'", internal.BankingCircleConnector) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -73,9 +81,9 @@ func (c *PaymentsConnectorsBankingCircleController) Run(cmd *cobra.Command, args BankingCircleConfig: &config, }, } - response, err := store.Client().Payments.V1.InstallConnector(cmd.Context(), request) + response, err := stackClient.Payments.V1.InstallConnector(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "installing connector") + return nil, fmt.Errorf("installing connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/install/column.go b/cmd/payments/connectors/install/column.go index aa73e1fa..8943b8e6 100644 --- a/cmd/payments/connectors/install/column.go +++ b/cmd/payments/connectors/install/column.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -59,7 +58,16 @@ func (c *PaymentsConnectorsColumnController) GetStore() *PaymentsConnectorsColum } func (c *PaymentsConnectorsColumnController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -68,7 +76,7 @@ func (c *PaymentsConnectorsColumnController) Run(cmd *cobra.Command, args []stri return nil, fmt.Errorf("column connector is only supported in version >= v3.0.0") } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -77,10 +85,10 @@ func (c *PaymentsConnectorsColumnController) Run(cmd *cobra.Command, args []stri if err := json.Unmarshal([]byte(script), &config); err != nil { return nil, err } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to install connector '%s'", internal.ColumnConnector) { + if !fctl.CheckStackApprobation(cmd, "You are about to install connector '%s'", internal.ColumnConnector) { return nil, fctl.ErrMissingApproval } - response, err := store.Client().Payments.V3.InstallConnector(cmd.Context(), operations.V3InstallConnectorRequest{ + response, err := stackClient.Payments.V3.InstallConnector(cmd.Context(), operations.V3InstallConnectorRequest{ V3InstallConnectorRequest: &shared.V3InstallConnectorRequest{ V3ColumnConfig: &config, Type: internal.ColumnConnector, @@ -88,7 +96,7 @@ func (c *PaymentsConnectorsColumnController) Run(cmd *cobra.Command, args []stri Connector: internal.ColumnConnector, }) if err != nil { - return nil, errors.Wrap(err, "unexpected error during installation") + return nil, fmt.Errorf("unexpected error during installation: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/install/currencycloud.go b/cmd/payments/connectors/install/currencycloud.go index 88f5f452..fe6256b2 100644 --- a/cmd/payments/connectors/install/currencycloud.go +++ b/cmd/payments/connectors/install/currencycloud.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -53,11 +52,20 @@ func (c *PaymentsConnectorsCurrencyCloudController) GetStore() *PaymentsConnecto } func (c *PaymentsConnectorsCurrencyCloudController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to install connector '%s'", internal.CurrencyCloudConnector) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + if !fctl.CheckStackApprobation(cmd, "You are about to install connector '%s'", internal.CurrencyCloudConnector) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -67,14 +75,14 @@ func (c *PaymentsConnectorsCurrencyCloudController) Run(cmd *cobra.Command, args return nil, err } - response, err := store.Client().Payments.V1.InstallConnector(cmd.Context(), operations.InstallConnectorRequest{ + response, err := stackClient.Payments.V1.InstallConnector(cmd.Context(), operations.InstallConnectorRequest{ ConnectorConfig: shared.ConnectorConfig{ CurrencyCloudConfig: &config, }, Connector: shared.ConnectorCurrencyCloud, }) if err != nil { - return nil, errors.Wrap(err, "installing connector") + return nil, fmt.Errorf("installing connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/install/generic.go b/cmd/payments/connectors/install/generic.go index 94df912d..511d2125 100644 --- a/cmd/payments/connectors/install/generic.go +++ b/cmd/payments/connectors/install/generic.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -51,13 +50,22 @@ func (c *PaymentsConnectorsGenericController) GetStore() *PaymentsConnectorsGene } func (c *PaymentsConnectorsGenericController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to install connector '%s'", internal.GenericConnector) { + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + if !fctl.CheckStackApprobation(cmd, "You are about to install connector '%s'", internal.GenericConnector) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -73,9 +81,9 @@ func (c *PaymentsConnectorsGenericController) Run(cmd *cobra.Command, args []str GenericConfig: &config, }, } - response, err := store.Client().Payments.V1.InstallConnector(cmd.Context(), request) + response, err := stackClient.Payments.V1.InstallConnector(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "installing connector") + return nil, fmt.Errorf("installing connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/install/mangopay.go b/cmd/payments/connectors/install/mangopay.go index f0353768..a4318026 100644 --- a/cmd/payments/connectors/install/mangopay.go +++ b/cmd/payments/connectors/install/mangopay.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -51,13 +50,22 @@ func (c *PaymentsConnectorsMangoPayController) GetStore() *PaymentsConnectorsMan } func (c *PaymentsConnectorsMangoPayController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to install connector '%s'", internal.MangoPayConnector) { + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + if !fctl.CheckStackApprobation(cmd, "You are about to install connector '%s'", internal.MangoPayConnector) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -73,9 +81,9 @@ func (c *PaymentsConnectorsMangoPayController) Run(cmd *cobra.Command, args []st MangoPayConfig: &config, }, } - response, err := store.Client().Payments.V1.InstallConnector(cmd.Context(), request) + response, err := stackClient.Payments.V1.InstallConnector(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "installing connector") + return nil, fmt.Errorf("installing connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/install/modulr.go b/cmd/payments/connectors/install/modulr.go index d812f21e..64f910c9 100644 --- a/cmd/payments/connectors/install/modulr.go +++ b/cmd/payments/connectors/install/modulr.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -54,11 +53,20 @@ func (c *PaymentsConnectorsModulrController) GetStore() *PaymentsConnectorsModul } func (c *PaymentsConnectorsModulrController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to install connector '%s'", internal.ModulrConnector) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + if !fctl.CheckStackApprobation(cmd, "You are about to install connector '%s'", internal.ModulrConnector) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -68,14 +76,14 @@ func (c *PaymentsConnectorsModulrController) Run(cmd *cobra.Command, args []stri return nil, err } - response, err := store.Client().Payments.V1.InstallConnector(cmd.Context(), operations.InstallConnectorRequest{ + response, err := stackClient.Payments.V1.InstallConnector(cmd.Context(), operations.InstallConnectorRequest{ ConnectorConfig: shared.ConnectorConfig{ ModulrConfig: &config, }, Connector: shared.ConnectorModulr, }) if err != nil { - return nil, errors.Wrap(err, "installing connector") + return nil, fmt.Errorf("installing connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/install/moneycorp.go b/cmd/payments/connectors/install/moneycorp.go index 19ad910f..9be16b7d 100644 --- a/cmd/payments/connectors/install/moneycorp.go +++ b/cmd/payments/connectors/install/moneycorp.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -51,13 +50,22 @@ func (c *PaymentsConnectorsMoneycorpController) GetStore() *PaymentsConnectorsMo } func (c *PaymentsConnectorsMoneycorpController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to install connector '%s'", internal.MoneycorpConnector) { + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + if !fctl.CheckStackApprobation(cmd, "You are about to install connector '%s'", internal.MoneycorpConnector) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -73,9 +81,9 @@ func (c *PaymentsConnectorsMoneycorpController) Run(cmd *cobra.Command, args []s MoneycorpConfig: &config, }, } - response, err := store.Client().Payments.V1.InstallConnector(cmd.Context(), request) + response, err := stackClient.Payments.V1.InstallConnector(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "installing connector") + return nil, fmt.Errorf("installing connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/install/qonto.go b/cmd/payments/connectors/install/qonto.go index a44660d9..4d5aedd0 100644 --- a/cmd/payments/connectors/install/qonto.go +++ b/cmd/payments/connectors/install/qonto.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -57,7 +56,16 @@ func NewQontoCommand() *cobra.Command { func (c *PaymentsConnectorsQontoController) GetStore() *PaymentsConnectorsQontoStore { return c.store } func (c *PaymentsConnectorsQontoController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -66,7 +74,7 @@ func (c *PaymentsConnectorsQontoController) Run(cmd *cobra.Command, args []strin return nil, fmt.Errorf("qonto connector is only supported in version >= v3.0.0") } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -75,10 +83,10 @@ func (c *PaymentsConnectorsQontoController) Run(cmd *cobra.Command, args []strin if err := json.Unmarshal([]byte(script), &config); err != nil { return nil, err } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to install connector '%s'", internal.QontoConnector) { + if !fctl.CheckStackApprobation(cmd, "You are about to install connector '%s'", internal.QontoConnector) { return nil, fctl.ErrMissingApproval } - response, err := store.Client().Payments.V3.InstallConnector(cmd.Context(), operations.V3InstallConnectorRequest{ + response, err := stackClient.Payments.V3.InstallConnector(cmd.Context(), operations.V3InstallConnectorRequest{ V3InstallConnectorRequest: &shared.V3InstallConnectorRequest{ V3QontoConfig: &config, Type: internal.QontoConnector, @@ -86,7 +94,7 @@ func (c *PaymentsConnectorsQontoController) Run(cmd *cobra.Command, args []strin Connector: internal.QontoConnector, }) if err != nil { - return nil, errors.Wrap(err, "unexpected error during installation") + return nil, fmt.Errorf("unexpected error during installation: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/install/stripe.go b/cmd/payments/connectors/install/stripe.go index 1bd98dc3..d0a34cfb 100644 --- a/cmd/payments/connectors/install/stripe.go +++ b/cmd/payments/connectors/install/stripe.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -53,9 +52,18 @@ func (c *PaymentsConnectorsStripeController) GetStore() *PaymentsConnectorsStrip } func (c *PaymentsConnectorsStripeController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -64,17 +72,17 @@ func (c *PaymentsConnectorsStripeController) Run(cmd *cobra.Command, args []stri if err := json.Unmarshal([]byte(script), &config); err != nil { return nil, err } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to install connector '%s'", internal.StripeConnector) { + if !fctl.CheckStackApprobation(cmd, "You are about to install connector '%s'", internal.StripeConnector) { return nil, fctl.ErrMissingApproval } - response, err := store.Client().Payments.V1.InstallConnector(cmd.Context(), operations.InstallConnectorRequest{ + response, err := stackClient.Payments.V1.InstallConnector(cmd.Context(), operations.InstallConnectorRequest{ ConnectorConfig: shared.ConnectorConfig{ StripeConfig: &config, }, Connector: shared.ConnectorStripe, }) if err != nil { - return nil, errors.Wrap(err, "installing connector") + return nil, fmt.Errorf("installing connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/install/wise.go b/cmd/payments/connectors/install/wise.go index 1f84b195..63524567 100644 --- a/cmd/payments/connectors/install/wise.go +++ b/cmd/payments/connectors/install/wise.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -53,11 +52,20 @@ func (c *PaymentsConnectorsWiseController) GetStore() *PaymentsConnectorsWiseSto } func (c *PaymentsConnectorsWiseController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to install connector '%s'", internal.WiseConnector) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + if !fctl.CheckStackApprobation(cmd, "You are about to install connector '%s'", internal.WiseConnector) { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -67,14 +75,14 @@ func (c *PaymentsConnectorsWiseController) Run(cmd *cobra.Command, args []string return nil, err } - response, err := store.Client().Payments.V1.InstallConnector(cmd.Context(), operations.InstallConnectorRequest{ + response, err := stackClient.Payments.V1.InstallConnector(cmd.Context(), operations.InstallConnectorRequest{ ConnectorConfig: shared.ConnectorConfig{ WiseConfig: &config, }, Connector: shared.ConnectorWise, }) if err != nil { - return nil, errors.Wrap(err, "installing connector") + return nil, fmt.Errorf("installing connector: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/payments/connectors/list.go b/cmd/payments/connectors/list.go index a628c1d8..6657a9de 100644 --- a/cmd/payments/connectors/list.go +++ b/cmd/payments/connectors/list.go @@ -64,7 +64,16 @@ func (c *PaymentsConnectorsListController) GetStore() *PaymentsConnectorsListSto } func (c *PaymentsConnectorsListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -74,7 +83,7 @@ func (c *PaymentsConnectorsListController) Run(cmd *cobra.Command, args []string switch c.PaymentsVersion { case versions.V3: - response, err := store.Client().Payments.V3.ListConnectors(cmd.Context(), operations.V3ListConnectorsRequest{ + response, err := stackClient.Payments.V3.ListConnectors(cmd.Context(), operations.V3ListConnectorsRequest{ PageSize: &pageSizeAsInt, }) if err != nil { @@ -91,7 +100,7 @@ func (c *PaymentsConnectorsListController) Run(cmd *cobra.Command, args []string c.store.Connectors = fctl.Map(response.V3ConnectorsCursorResponse.Cursor.Data, V3toConnectorData) case versions.V0, versions.V1, versions.V2: - response, err := store.Client().Payments.V1.ListAllConnectors(cmd.Context()) + response, err := stackClient.Payments.V1.ListAllConnectors(cmd.Context()) if err != nil { return nil, err } diff --git a/cmd/payments/connectors/root.go b/cmd/payments/connectors/root.go index 63c1428c..5d3d1895 100644 --- a/cmd/payments/connectors/root.go +++ b/cmd/payments/connectors/root.go @@ -17,7 +17,7 @@ func NewConnectorsCommand() *cobra.Command { NewListCommand(), install.NewInstallCommand(), configs.NewUpdateConfigCommands(), - configs.NewGetConfigCommand(), + configs.NewLoadConfigCommand(), ), ) } diff --git a/cmd/payments/connectors/uninstall.go b/cmd/payments/connectors/uninstall.go index ad807de0..7c689495 100644 --- a/cmd/payments/connectors/uninstall.go +++ b/cmd/payments/connectors/uninstall.go @@ -75,7 +75,16 @@ func (c *PaymentsConnectorsUninstallController) GetStore() *PaymentsConnectorsUn } func (c *PaymentsConnectorsUninstallController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -89,11 +98,11 @@ func (c *PaymentsConnectorsUninstallController) Run(cmd *cobra.Command, args []s return nil, fmt.Errorf("missing connector ID") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to uninstall connector '%s'", connectorID) { + if !fctl.CheckStackApprobation(cmd, "You are about to uninstall connector '%s'", connectorID) { return nil, fctl.ErrMissingApproval } - response, err := store.Client().Payments.V3.UninstallConnector(cmd.Context(), operations.V3UninstallConnectorRequest{ + response, err := stackClient.Payments.V3.UninstallConnector(cmd.Context(), operations.V3UninstallConnectorRequest{ ConnectorID: connectorID, }) if err != nil { @@ -115,11 +124,11 @@ func (c *PaymentsConnectorsUninstallController) Run(cmd *cobra.Command, args []s return nil, fmt.Errorf("missing connector ID") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to uninstall connector '%s' from provider '%s'", connectorID, provider) { + if !fctl.CheckStackApprobation(cmd, "You are about to uninstall connector '%s' from provider '%s'", connectorID, provider) { return nil, fctl.ErrMissingApproval } - response, err := store.Client().Payments.V1.UninstallConnectorV1(cmd.Context(), operations.UninstallConnectorV1Request{ + response, err := stackClient.Payments.V1.UninstallConnectorV1(cmd.Context(), operations.UninstallConnectorV1Request{ ConnectorID: connectorID, Connector: shared.Connector(provider), }) @@ -137,11 +146,11 @@ func (c *PaymentsConnectorsUninstallController) Run(cmd *cobra.Command, args []s return nil, fmt.Errorf("missing provider") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to uninstall connector '%s'", provider) { + if !fctl.CheckStackApprobation(cmd, "You are about to uninstall connector '%s'", provider) { return nil, fctl.ErrMissingApproval } - response, err := store.Client().Payments.V1.UninstallConnector(cmd.Context(), operations.UninstallConnectorRequest{ + response, err := stackClient.Payments.V1.UninstallConnector(cmd.Context(), operations.UninstallConnectorRequest{ Connector: shared.Connector(provider), }) if err != nil { diff --git a/cmd/payments/payments/create.go b/cmd/payments/payments/create.go index 8373bead..9c5286a2 100644 --- a/cmd/payments/payments/create.go +++ b/cmd/payments/payments/create.go @@ -54,7 +54,16 @@ func (c *CreateController) GetStore() *CreateStore { } func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err } @@ -63,11 +72,11 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab return nil, fmt.Errorf("payment creation are only supported in >= v1.0.0") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to create a payment") { + if !fctl.CheckStackApprobation(cmd, "You are about to create a payment") { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -78,7 +87,7 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab } //nolint:gosimple - response, err := store.Client().Payments.V1.CreatePayment(cmd.Context(), request) + response, err := stackClient.Payments.V1.CreatePayment(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/payments/payments/list.go b/cmd/payments/payments/list.go index aa905d66..487bcbb3 100644 --- a/cmd/payments/payments/list.go +++ b/cmd/payments/payments/list.go @@ -46,7 +46,15 @@ func (c *ListController) GetStore() *ListStore { func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } var cursor *string if c := fctl.GetString(cmd, c.cursorFlag); c != "" { @@ -58,7 +66,7 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable pageSize = fctl.Ptr(int64(ps)) } - response, err := store.Client().Payments.V1.ListPayments( + response, err := stackClient.Payments.V1.ListPayments( cmd.Context(), operations.ListPaymentsRequest{ Cursor: cursor, diff --git a/cmd/payments/payments/set_metadata.go b/cmd/payments/payments/set_metadata.go index 34b39d42..41cbfd34 100644 --- a/cmd/payments/payments/set_metadata.go +++ b/cmd/payments/payments/set_metadata.go @@ -47,7 +47,16 @@ func (c *SetMetadataController) GetStore() *SetMetadataStore { } func (c *SetMetadataController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } metadata, err := fctl.ParseMetadata(args[1:]) if err != nil { @@ -56,7 +65,7 @@ func (c *SetMetadataController) Run(cmd *cobra.Command, args []string) (fctl.Ren paymentID := args[0] - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to set a metadata on paymentID '%s'", paymentID) { + if !fctl.CheckStackApprobation(cmd, "You are about to set metadata on paymentID '%s'", paymentID) { return nil, fctl.ErrMissingApproval } @@ -65,7 +74,7 @@ func (c *SetMetadataController) Run(cmd *cobra.Command, args []string) (fctl.Ren PaymentID: paymentID, } - response, err := store.Client().Payments.V1.UpdateMetadata(cmd.Context(), request) + response, err := stackClient.Payments.V1.UpdateMetadata(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/payments/payments/show.go b/cmd/payments/payments/show.go index 8d873c39..e7e3ac17 100644 --- a/cmd/payments/payments/show.go +++ b/cmd/payments/payments/show.go @@ -48,8 +48,17 @@ func (c *ShowController) GetStore() *ShowStore { } func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - response, err := store.Client().Payments.V1.GetPayment(cmd.Context(), operations.GetPaymentRequest{ + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + response, err := stackClient.Payments.V1.GetPayment(cmd.Context(), operations.GetPaymentRequest{ PaymentID: args[0], }) if err != nil { diff --git a/cmd/payments/pools/add_accounts.go b/cmd/payments/pools/add_accounts.go index 4ae3b8d6..324a99bd 100644 --- a/cmd/payments/pools/add_accounts.go +++ b/cmd/payments/pools/add_accounts.go @@ -56,7 +56,16 @@ func (c *AddAccountController) GetStore() *AddAccountStore { } func (c *AddAccountController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -66,7 +75,7 @@ func (c *AddAccountController) Run(cmd *cobra.Command, args []string) (fctl.Rend return nil, fmt.Errorf("pools are only supported in >= v1.0.0") } - response, err := store.Client().Payments.V1.AddAccountToPool(cmd.Context(), operations.AddAccountToPoolRequest{ + response, err := stackClient.Payments.V1.AddAccountToPool(cmd.Context(), operations.AddAccountToPoolRequest{ PoolID: args[0], AddAccountToPoolRequest: shared.AddAccountToPoolRequest{ AccountID: args[1], diff --git a/cmd/payments/pools/balances.go b/cmd/payments/pools/balances.go index 54e80a3c..4e616a6a 100644 --- a/cmd/payments/pools/balances.go +++ b/cmd/payments/pools/balances.go @@ -40,14 +40,23 @@ func (c *BalancesController) GetStore() *BalancesStore { } func (c *BalancesController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } at, err := time.Parse(time.RFC3339, args[1]) if err != nil { return nil, err } - response, err := store.Client().Payments.V1.GetPoolBalances( + response, err := stackClient.Payments.V1.GetPoolBalances( cmd.Context(), operations.GetPoolBalancesRequest{ At: at, diff --git a/cmd/payments/pools/create.go b/cmd/payments/pools/create.go index 9c306844..7072571b 100644 --- a/cmd/payments/pools/create.go +++ b/cmd/payments/pools/create.go @@ -54,7 +54,16 @@ func (c *CreateController) GetStore() *CreateStore { } func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err } @@ -63,11 +72,11 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab return nil, fmt.Errorf("pools are only supported in >= v1.0.0") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to create a new pool") { + if !fctl.CheckStackApprobation(cmd, "You are about to create a new pool") { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -78,7 +87,7 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab } //nolint:gosimple - response, err := store.Client().Payments.V1.CreatePool(cmd.Context(), request) + response, err := stackClient.Payments.V1.CreatePool(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/payments/pools/delete.go b/cmd/payments/pools/delete.go index 80618672..9cdb4e50 100644 --- a/cmd/payments/pools/delete.go +++ b/cmd/payments/pools/delete.go @@ -55,7 +55,16 @@ func (c *DeleteController) GetStore() *DeleteStore { } func (c *DeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -65,11 +74,11 @@ func (c *DeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderab return nil, fmt.Errorf("pools are only supported in >= v1.0.0") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to delete '%s'", args[0]) { + if !fctl.CheckStackApprobation(cmd, "You are about to delete '%s'", args[0]) { return nil, fctl.ErrMissingApproval } - response, err := store.Client().Payments.V1.DeletePool( + response, err := stackClient.Payments.V1.DeletePool( cmd.Context(), operations.DeletePoolRequest{ PoolID: args[0], diff --git a/cmd/payments/pools/list.go b/cmd/payments/pools/list.go index 6d7ca11e..5ff12f66 100644 --- a/cmd/payments/pools/list.go +++ b/cmd/payments/pools/list.go @@ -53,7 +53,16 @@ func (c *ListController) GetStore() *ListStore { } func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -73,7 +82,7 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable pageSize = fctl.Ptr(int64(ps)) } - response, err := store.Client().Payments.V1.ListPools( + response, err := stackClient.Payments.V1.ListPools( cmd.Context(), operations.ListPoolsRequest{ Cursor: cursor, diff --git a/cmd/payments/pools/remove_account.go b/cmd/payments/pools/remove_account.go index 475a2836..b2c015ee 100644 --- a/cmd/payments/pools/remove_account.go +++ b/cmd/payments/pools/remove_account.go @@ -55,7 +55,16 @@ func (c *RemoveAccountController) GetStore() *RemoveAccountStore { } func (c *RemoveAccountController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -65,7 +74,7 @@ func (c *RemoveAccountController) Run(cmd *cobra.Command, args []string) (fctl.R return nil, fmt.Errorf("pools are only supported in >= v1.0.0") } - response, err := store.Client().Payments.V1.RemoveAccountFromPool(cmd.Context(), operations.RemoveAccountFromPoolRequest{ + response, err := stackClient.Payments.V1.RemoveAccountFromPool(cmd.Context(), operations.RemoveAccountFromPoolRequest{ PoolID: args[0], AccountID: args[1], }) diff --git a/cmd/payments/pools/show.go b/cmd/payments/pools/show.go index fe00f6cd..73e7e8a2 100644 --- a/cmd/payments/pools/show.go +++ b/cmd/payments/pools/show.go @@ -55,7 +55,16 @@ func (c *ShowController) GetStore() *ShowStore { } func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -65,7 +74,7 @@ func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable return nil, fmt.Errorf("pools are only supported in >= v1.0.0") } - response, err := store.Client().Payments.V1.GetPool(cmd.Context(), operations.GetPoolRequest{ + response, err := stackClient.Payments.V1.GetPool(cmd.Context(), operations.GetPoolRequest{ PoolID: args[0], }) if err != nil { diff --git a/cmd/payments/root.go b/cmd/payments/root.go index d6bc0cd3..fff17c40 100644 --- a/cmd/payments/root.go +++ b/cmd/payments/root.go @@ -25,8 +25,5 @@ func NewCommand() *cobra.Command { pools.NewPoolsCommand(), tasks.NewTasksCommand(), ), - fctl.WithPersistentPreRunE(func(cmd *cobra.Command, args []string) error { - return fctl.NewStackStore(cmd) - }), ) } diff --git a/cmd/payments/tasks/show.go b/cmd/payments/tasks/show.go index f99d5843..23afcd7b 100644 --- a/cmd/payments/tasks/show.go +++ b/cmd/payments/tasks/show.go @@ -54,7 +54,16 @@ func (c *ShowController) GetStore() *ShowStore { } func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -64,7 +73,7 @@ func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable return nil, fmt.Errorf("tasks are only supported in >= v3.0.0") } - response, err := store.Client().Payments.V3.GetTask(cmd.Context(), operations.V3GetTaskRequest{ + response, err := stackClient.Payments.V3.GetTask(cmd.Context(), operations.V3GetTaskRequest{ TaskID: args[0], }) if err != nil { diff --git a/cmd/payments/transferinitiation/approve.go b/cmd/payments/transferinitiation/approve.go index 6e09455a..c7d5fb6c 100644 --- a/cmd/payments/transferinitiation/approve.go +++ b/cmd/payments/transferinitiation/approve.go @@ -55,7 +55,16 @@ func (c *ApproveController) GetStore() *ApproveStore { } func (c *ApproveController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -65,11 +74,11 @@ func (c *ApproveController) Run(cmd *cobra.Command, args []string) (fctl.Rendera return nil, fmt.Errorf("transfer initiation approval is only supported in >= v3.0.0") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to approve the transfer initiation %q", args[0]) { + if !fctl.CheckStackApprobation(cmd, "You are about to approve the transfer initiation %q", args[0]) { return nil, fctl.ErrMissingApproval } - response, err := store.Client().Payments.V3.ApprovePaymentInitiation(cmd.Context(), operations.V3ApprovePaymentInitiationRequest{ + response, err := stackClient.Payments.V3.ApprovePaymentInitiation(cmd.Context(), operations.V3ApprovePaymentInitiationRequest{ PaymentInitiationID: args[0], }) if err != nil { diff --git a/cmd/payments/transferinitiation/create.go b/cmd/payments/transferinitiation/create.go index e7f64fc7..330413d0 100644 --- a/cmd/payments/transferinitiation/create.go +++ b/cmd/payments/transferinitiation/create.go @@ -54,7 +54,16 @@ func (c *CreateController) GetStore() *CreateStore { } func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err } @@ -63,11 +72,11 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab return nil, fmt.Errorf("transfer initiation are only supported in >= v1.0.0") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to create a transfer initation") { + if !fctl.CheckStackApprobation(cmd, "You are about to create a transfer initiation") { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -78,7 +87,7 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab } //nolint:gosimple - response, err := store.Client().Payments.V1.CreateTransferInitiation(cmd.Context(), request) + response, err := stackClient.Payments.V1.CreateTransferInitiation(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/payments/transferinitiation/delete.go b/cmd/payments/transferinitiation/delete.go index 759d2f3a..8be190bd 100644 --- a/cmd/payments/transferinitiation/delete.go +++ b/cmd/payments/transferinitiation/delete.go @@ -54,7 +54,16 @@ func (c *DeleteController) GetStore() *DeleteStore { } func (c *DeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -64,11 +73,11 @@ func (c *DeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderab return nil, fmt.Errorf("transfer initiation are only supported in >= v1.0.0") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to delete '%s'", args[0]) { + if !fctl.CheckStackApprobation(cmd, "You are about to delete '%s'", args[0]) { return nil, fctl.ErrMissingApproval } - response, err := store.Client().Payments.V1.DeleteTransferInitiation( + response, err := stackClient.Payments.V1.DeleteTransferInitiation( cmd.Context(), operations.DeleteTransferInitiationRequest{ TransferID: args[0], diff --git a/cmd/payments/transferinitiation/list.go b/cmd/payments/transferinitiation/list.go index 6c56a966..6c5de978 100644 --- a/cmd/payments/transferinitiation/list.go +++ b/cmd/payments/transferinitiation/list.go @@ -53,7 +53,16 @@ func (c *ListController) GetStore() *ListStore { } func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err } @@ -72,7 +81,7 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable pageSize = fctl.Ptr(int64(ps)) } - response, err := store.Client().Payments.V1.ListTransferInitiations( + response, err := stackClient.Payments.V1.ListTransferInitiations( cmd.Context(), operations.ListTransferInitiationsRequest{ Cursor: cursor, diff --git a/cmd/payments/transferinitiation/reject.go b/cmd/payments/transferinitiation/reject.go index 4854277a..cba5eca2 100644 --- a/cmd/payments/transferinitiation/reject.go +++ b/cmd/payments/transferinitiation/reject.go @@ -55,7 +55,16 @@ func (c *RejectController) GetStore() *RejectStore { } func (c *RejectController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -65,11 +74,11 @@ func (c *RejectController) Run(cmd *cobra.Command, args []string) (fctl.Renderab return nil, fmt.Errorf("transfer initiation rejection is only supported in >= v3.0.0") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to reject the transfer initiation %q", args[0]) { + if !fctl.CheckStackApprobation(cmd, "You are about to reject the transfer initiation %q", args[0]) { return nil, fctl.ErrMissingApproval } - response, err := store.Client().Payments.V3.RejectPaymentInitiation(cmd.Context(), operations.V3RejectPaymentInitiationRequest{ + response, err := stackClient.Payments.V3.RejectPaymentInitiation(cmd.Context(), operations.V3RejectPaymentInitiationRequest{ PaymentInitiationID: args[0], }) if err != nil { diff --git a/cmd/payments/transferinitiation/retry.go b/cmd/payments/transferinitiation/retry.go index 9b40b9fd..ec4648de 100644 --- a/cmd/payments/transferinitiation/retry.go +++ b/cmd/payments/transferinitiation/retry.go @@ -55,7 +55,16 @@ func (c *RetryController) GetStore() *RetryStore { } func (c *RetryController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err } @@ -64,12 +73,12 @@ func (c *RetryController) Run(cmd *cobra.Command, args []string) (fctl.Renderabl return nil, fmt.Errorf("transfer initiation are only supported in >= v1.0.0") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to retry the transfer initiation '%s'", args[0]) { + if !fctl.CheckStackApprobation(cmd, "You are about to retry the transfer initiation '%s'", args[0]) { return nil, fctl.ErrMissingApproval } //nolint:gosimple - response, err := store.Client().Payments.V1.RetryTransferInitiation(cmd.Context(), operations.RetryTransferInitiationRequest{ + response, err := stackClient.Payments.V1.RetryTransferInitiation(cmd.Context(), operations.RetryTransferInitiationRequest{ TransferID: args[0], }) if err != nil { diff --git a/cmd/payments/transferinitiation/reverse.go b/cmd/payments/transferinitiation/reverse.go index 4300026e..88c558d3 100644 --- a/cmd/payments/transferinitiation/reverse.go +++ b/cmd/payments/transferinitiation/reverse.go @@ -56,7 +56,16 @@ func (c *ReverseController) GetStore() *ReverseStore { } func (c *ReverseController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -66,7 +75,7 @@ func (c *ReverseController) Run(cmd *cobra.Command, args []string) (fctl.Rendera return nil, fmt.Errorf("transfer initiation are only supported in >= v1.0.0") } - script, err := fctl.ReadFile(cmd, store.Stack(), args[1]) + script, err := fctl.ReadFile(cmd, args[1]) if err != nil { return nil, err } @@ -76,11 +85,11 @@ func (c *ReverseController) Run(cmd *cobra.Command, args []string) (fctl.Rendera return nil, err } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to delete '%s'", args[0]) { + if !fctl.CheckStackApprobation(cmd, "You are about to reverse '%s'", args[0]) { return nil, fctl.ErrMissingApproval } - response, err := store.Client().Payments.V1.ReverseTransferInitiation( + response, err := stackClient.Payments.V1.ReverseTransferInitiation( cmd.Context(), operations.ReverseTransferInitiationRequest{ TransferID: args[0], diff --git a/cmd/payments/transferinitiation/show.go b/cmd/payments/transferinitiation/show.go index 7e812bf3..5373429b 100644 --- a/cmd/payments/transferinitiation/show.go +++ b/cmd/payments/transferinitiation/show.go @@ -55,7 +55,16 @@ func (c *ShowController) GetStore() *ShowStore { } func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err } @@ -64,7 +73,7 @@ func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable return nil, fmt.Errorf("transfer initiation are only supported in >= v1.0.0") } - response, err := store.Client().Payments.V1.GetTransferInitiation(cmd.Context(), operations.GetTransferInitiationRequest{ + response, err := stackClient.Payments.V1.GetTransferInitiation(cmd.Context(), operations.GetTransferInitiationRequest{ TransferID: args[0], }) if err != nil { diff --git a/cmd/payments/transferinitiation/update_status.go b/cmd/payments/transferinitiation/update_status.go index e06e2189..f7a994b8 100644 --- a/cmd/payments/transferinitiation/update_status.go +++ b/cmd/payments/transferinitiation/update_status.go @@ -57,7 +57,16 @@ func (c *UpdateStatusController) GetStore() *UpdateStatusStore { } func (c *UpdateStatusController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if err := versions.GetPaymentsVersion(cmd, args, c); err != nil { return nil, err @@ -67,12 +76,12 @@ func (c *UpdateStatusController) Run(cmd *cobra.Command, args []string) (fctl.Re return nil, fmt.Errorf("transfer initiation updates are only supported in >= v2.0.0") } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to update the status of the transfer initiation '%s' to '%s'", args[0], args[1]) { + if !fctl.CheckStackApprobation(cmd, "You are about to update the status of the transfer initiation '%s' to '%s'", args[0], args[1]) { return nil, fctl.ErrMissingApproval } //nolint:gosimple - response, err := store.Client().Payments.V1.UpdateTransferInitiationStatus(cmd.Context(), operations.UpdateTransferInitiationStatusRequest{ + response, err := stackClient.Payments.V1.UpdateTransferInitiationStatus(cmd.Context(), operations.UpdateTransferInitiationStatusRequest{ UpdateTransferInitiationStatusRequest: shared.UpdateTransferInitiationStatusRequest{ Status: shared.Status(args[1]), }, diff --git a/cmd/payments/versions/versions.go b/cmd/payments/versions/versions.go index 122cf3ee..61c51a27 100644 --- a/cmd/payments/versions/versions.go +++ b/cmd/payments/versions/versions.go @@ -22,9 +22,18 @@ type VersionController interface { SetVersion(Version) } -func GetPaymentsVersion(cmd *cobra.Command, args []string, controller VersionController) error { - store := fctl.GetStackStore(cmd.Context()) - response, err := store.Client().Payments.V1.PaymentsgetServerInfo(cmd.Context()) +func GetPaymentsVersion(cmd *cobra.Command, _ []string, controller VersionController) error { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return err + } + response, err := stackClient.Payments.V1.PaymentsgetServerInfo(cmd.Context()) if err != nil { return err } diff --git a/cmd/profiles/delete.go b/cmd/profiles/delete.go index 4fde2c50..a5caceb7 100644 --- a/cmd/profiles/delete.go +++ b/cmd/profiles/delete.go @@ -1,7 +1,6 @@ package profiles import ( - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -34,19 +33,10 @@ func (c *ProfileDeleteController) GetStore() *ProfilesDeleteStore { } func (c *ProfileDeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - - config, err := fctl.GetConfig(cmd) - if err != nil { - return nil, err - } - if err := config.DeleteProfile(args[0]); err != nil { + if err := fctl.DeleteProfile(cmd, args[0]); err != nil { return nil, err } - if err := config.Persist(); err != nil { - return nil, errors.Wrap(err, "updating config") - } - c.store.Success = true return c, nil diff --git a/cmd/profiles/list.go b/cmd/profiles/list.go index 406560c4..ad1b7c01 100644 --- a/cmd/profiles/list.go +++ b/cmd/profiles/list.go @@ -37,15 +37,19 @@ func (c *ProfilesListController) GetStore() *ProfilesListStore { } func (c *ProfilesListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - cfg, err := fctl.GetConfig(cmd) + cfg, err := fctl.LoadConfig(cmd) if err != nil { return nil, err } - p := fctl.MapKeys(cfg.GetProfiles()) - currentProfileName := fctl.GetCurrentProfileName(cmd, cfg) + profiles, err := fctl.ListProfiles(cmd) + if err != nil { + return nil, err + } + + currentProfileName := fctl.GetCurrentProfileName(cmd, *cfg) - for _, k := range p { + for _, k := range profiles { c.store.Profiles = append(c.store.Profiles, &Profile{ Name: k, Active: func(k string) string { diff --git a/cmd/profiles/rename.go b/cmd/profiles/rename.go index 5a5f55b5..7caae892 100644 --- a/cmd/profiles/rename.go +++ b/cmd/profiles/rename.go @@ -1,70 +1,62 @@ package profiles import ( - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" fctl "github.com/formancehq/fctl/pkg" ) -type ProfilesRenameStore struct { +type RenameStore struct { Success bool `json:"success"` } -type ProfilesRenameController struct { - store *ProfilesRenameStore +type RenameController struct { + store *RenameStore } -var _ fctl.Controller[*ProfilesRenameStore] = (*ProfilesRenameController)(nil) +var _ fctl.Controller[*RenameStore] = (*RenameController)(nil) -func NewDefaultProfilesRenameStore() *ProfilesRenameStore { - return &ProfilesRenameStore{ +func NewDefaultProfilesRenameStore() *RenameStore { + return &RenameStore{ Success: false, } } -func NewProfilesRenameController() *ProfilesRenameController { - return &ProfilesRenameController{ +func NewProfilesRenameController() *RenameController { + return &RenameController{ store: NewDefaultProfilesRenameStore(), } } -func (c *ProfilesRenameController) GetStore() *ProfilesRenameStore { +func (c *RenameController) GetStore() *RenameStore { return c.store } -func (c *ProfilesRenameController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { +func (c *RenameController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { oldName := args[0] newName := args[1] - config, err := fctl.GetConfig(cmd) + config, err := fctl.LoadConfig(cmd) if err != nil { return nil, err } - p := config.GetProfile(oldName) - if p == nil { - return nil, errors.New("profile not found") - } - - if err := config.DeleteProfile(oldName); err != nil { + if err := fctl.RenameProfile(cmd, oldName, newName); err != nil { return nil, err } - if config.GetCurrentProfileName() == oldName { - config.SetCurrentProfile(newName, p) - } else { - config.SetProfile(newName, p) - } - if err := config.Persist(); err != nil { - return nil, errors.Wrap(config.Persist(), "Updating config") + if config.CurrentProfile == oldName { + config.CurrentProfile = newName + if err := fctl.WriteConfig(cmd, *config); err != nil { + return nil, err + } } c.store.Success = true return c, nil } -func (c *ProfilesRenameController) Render(cmd *cobra.Command, args []string) error { +func (c *RenameController) Render(cmd *cobra.Command, args []string) error { pterm.Success.WithWriter(cmd.OutOrStdout()).Printfln("Profile renamed!") return nil } diff --git a/cmd/profiles/reset.go b/cmd/profiles/reset.go index 2c5ea383..9808cbdb 100644 --- a/cmd/profiles/reset.go +++ b/cmd/profiles/reset.go @@ -1,7 +1,6 @@ package profiles import ( - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -34,17 +33,9 @@ func (c *ResetController) GetStore() *ResetStore { } func (c *ResetController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - config, err := fctl.GetConfig(cmd) - if err != nil { + if err := fctl.ResetProfile(cmd, args[0]); err != nil { return nil, err } - if err := config.ResetProfile(args[0]); err != nil { - return nil, err - } - - if err := config.Persist(); err != nil { - return nil, errors.Wrap(err, "updating config") - } c.store.Success = true diff --git a/cmd/profiles/setdefaultorganization.go b/cmd/profiles/setdefaultorganization.go index c6e8419c..2009220b 100644 --- a/cmd/profiles/setdefaultorganization.go +++ b/cmd/profiles/setdefaultorganization.go @@ -1,60 +1,71 @@ package profiles import ( + "errors" "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/go-libs/collectionutils" - - "github.com/formancehq/fctl/membershipclient" fctl "github.com/formancehq/fctl/pkg" ) -type ProfilesSetDefaultOrganizationStore struct { +type SetDefaultOrganizationStore struct { Success bool `json:"success"` } -type ProfilesSetDefaultOrganizationController struct { - store *ProfilesSetDefaultOrganizationStore +type SetDefaultOrganizationController struct { + store *SetDefaultOrganizationStore } -var _ fctl.Controller[*ProfilesSetDefaultOrganizationStore] = (*ProfilesSetDefaultOrganizationController)(nil) +var _ fctl.Controller[*SetDefaultOrganizationStore] = (*SetDefaultOrganizationController)(nil) -func NewDefaultProfilesSetDefaultOrganizationStore() *ProfilesSetDefaultOrganizationStore { - return &ProfilesSetDefaultOrganizationStore{ +func NewDefaultProfilesSetDefaultOrganizationStore() *SetDefaultOrganizationStore { + return &SetDefaultOrganizationStore{ Success: false, } } -func NewProfilesSetDefaultOrganizationController() *ProfilesSetDefaultOrganizationController { - return &ProfilesSetDefaultOrganizationController{ +func NewProfilesSetDefaultOrganizationController() *SetDefaultOrganizationController { + return &SetDefaultOrganizationController{ store: NewDefaultProfilesSetDefaultOrganizationStore(), } } -func (c *ProfilesSetDefaultOrganizationController) GetStore() *ProfilesSetDefaultOrganizationStore { +func (c *SetDefaultOrganizationController) GetStore() *SetDefaultOrganizationStore { return c.store } -func (c *ProfilesSetDefaultOrganizationController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - cfg, err := fctl.GetConfig(cmd) +func (c *SetDefaultOrganizationController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { + cfg, err := fctl.LoadConfig(cmd) + if err != nil { + return nil, err + } + + currentProfile, profileName, err := fctl.LoadCurrentProfile(cmd, *cfg) if err != nil { return nil, err } - fctl.GetCurrentProfile(cmd, cfg).SetDefaultOrganization(args[0]) - fctl.GetCurrentProfile(cmd, cfg).SetDefaultStack("") - if err := cfg.Persist(); err != nil { - return nil, errors.Wrap(err, "Updating config") + if !currentProfile.IsConnected() { + return nil, errors.New("You are not connected, please run 'fctl login'") + } + + if !currentProfile.RootTokens.ID.Claims.HasOrganizationAccess(args[0]) { + return nil, fmt.Errorf("organization %s not found in your access list", args[0]) + } + + currentProfile.DefaultOrganization = args[0] + currentProfile.DefaultStack = "" + + if err := fctl.WriteProfile(cmd, profileName, *currentProfile); err != nil { + return nil, fmt.Errorf("Updating config: %w", err) } c.store.Success = true return c, nil } -func (c *ProfilesSetDefaultOrganizationController) Render(cmd *cobra.Command, args []string) error { +func (c *SetDefaultOrganizationController) Render(cmd *cobra.Command, args []string) error { pterm.Success.WithWriter(cmd.OutOrStdout()).Printfln("Default organization updated!") return nil } @@ -64,30 +75,7 @@ func NewSetDefaultOrganizationCommand() *cobra.Command { fctl.WithArgs(cobra.ExactArgs(1)), fctl.WithAliases("sdo"), fctl.WithShortDescription("Set default organization"), - fctl.WithValidArgsFunction(organizationCompletion), + fctl.WithValidArgsFunction(fctl.OrganizationCompletion), fctl.WithController(NewProfilesSetDefaultOrganizationController()), ) } - -func organizationCompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if err := fctl.NewMembershipStore(cmd); err != nil { - return []string{}, cobra.ShellCompDirectiveError - } - - mbStore := fctl.GetMembershipStore(cmd.Context()) - - ret, res, err := mbStore.Client().ListOrganizations(cmd.Context()).Execute() - if err != nil { - return []string{}, cobra.ShellCompDirectiveError - } - - if res.StatusCode > 300 { - return []string{}, cobra.ShellCompDirectiveError - } - - opts := collectionutils.Reduce(ret.Data, func(acc []string, o membershipclient.OrganizationExpanded) []string { - return append(acc, fmt.Sprintf("%s\t%s", o.Id, o.Name)) - }, []string{}) - - return opts, cobra.ShellCompDirectiveNoFileComp -} diff --git a/cmd/profiles/setdefaultstack.go b/cmd/profiles/setdefaultstack.go index e635d284..43ec2163 100644 --- a/cmd/profiles/setdefaultstack.go +++ b/cmd/profiles/setdefaultstack.go @@ -3,13 +3,9 @@ package profiles import ( "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/go-libs/collectionutils" - - "github.com/formancehq/fctl/membershipclient" fctl "github.com/formancehq/fctl/pkg" ) @@ -39,32 +35,28 @@ func (c *SetDefaultStackController) GetStore() *SetDefaultStackStore { } func (c *SetDefaultStackController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - cfg, err := fctl.GetConfig(cmd) + cfg, err := fctl.LoadConfig(cmd) if err != nil { return nil, err } - if err := fctl.NewMembershipStore(cmd); err != nil { + currentProfile, profileName, err := fctl.LoadCurrentProfile(cmd, *cfg) + if err != nil { return nil, err } - store := fctl.GetMembershipStore(cmd.Context()) - organizationId, err := fctl.ResolveOrganizationID(cmd, cfg, store.Client()) + organizationID, err := fctl.ResolveOrganizationID(cmd, *currentProfile) if err != nil { return nil, err } - stackRes, res, err := store.Client().GetStack(cmd.Context(), organizationId, args[0]).Execute() - if err != nil { - return nil, fmt.Errorf("failed to get stack: %w", err) - } - if res.StatusCode != 200 { - return nil, errors.Errorf("Failed to get stack: %s", res.Status) + if !currentProfile.RootTokens.ID.Claims.HasStackAccess(organizationID, args[0]) { + return nil, fmt.Errorf("stack %s not found in your access list", args[0]) } - cfg.GetCurrentProfile().SetDefaultStack(stackRes.Data.Id) - if err := cfg.Persist(); err != nil { - return nil, errors.Wrap(err, "Updating config") + currentProfile.DefaultStack = args[0] + if err := fctl.WriteProfile(cmd, profileName, *currentProfile); err != nil { + return nil, fmt.Errorf("Updating config: %w", err) } c.store.Success = true @@ -81,30 +73,7 @@ func NewSetDefaultStackCommand() *cobra.Command { fctl.WithArgs(cobra.ExactArgs(1)), fctl.WithAliases("sds"), fctl.WithShortDescription("Set default stack"), - fctl.WithValidArgsFunction(stackCompletion), + fctl.WithValidArgsFunction(fctl.StackCompletion), fctl.WithController(NewSetDefaultStackController()), ) } - -func stackCompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if err := fctl.NewMembershipOrganizationStore(cmd); err != nil { - return []string{}, cobra.ShellCompDirectiveNoFileComp - } - - orgStore := fctl.GetOrganizationStore(cmd) - - ret, res, err := orgStore.Client().ListStacks(cmd.Context(), orgStore.OrganizationId()).Execute() - if err != nil { - return []string{}, cobra.ShellCompDirectiveError - } - - if res.StatusCode > 300 { - return []string{}, cobra.ShellCompDirectiveError - } - - opts := collectionutils.Reduce(ret.Data, func(acc []string, s membershipclient.Stack) []string { - return append(acc, fmt.Sprintf("%s\t%s", s.Id, s.Name)) - }, []string{}) - - return opts, cobra.ShellCompDirectiveNoFileComp -} diff --git a/cmd/profiles/show.go b/cmd/profiles/show.go index 269a4f7c..49cbc8b6 100644 --- a/cmd/profiles/show.go +++ b/cmd/profiles/show.go @@ -1,7 +1,8 @@ package profiles import ( - "github.com/pkg/errors" + "errors" + "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -39,12 +40,10 @@ func (c *ProfilesShowController) GetStore() *ProfilesShowStore { func (c *ProfilesShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - config, err := fctl.GetConfig(cmd) + p, err := fctl.LoadProfile(cmd, args[0]) if err != nil { return nil, err } - - p := config.GetProfile(args[0]) if p == nil { return nil, errors.New("not found") } diff --git a/cmd/profiles/use.go b/cmd/profiles/use.go index 01937b90..133a8664 100644 --- a/cmd/profiles/use.go +++ b/cmd/profiles/use.go @@ -1,36 +1,38 @@ package profiles import ( - "github.com/pkg/errors" + "fmt" + "os" + "strings" + "github.com/pterm/pterm" "github.com/spf13/cobra" fctl "github.com/formancehq/fctl/pkg" ) -type ProfilesUseStore struct { - Success bool `json:"success"` +type UseStore struct { } -type ProfilesUseController struct { - store *ProfilesUseStore +type UseController struct { + store *UseStore } -var _ fctl.Controller[*ProfilesUseStore] = (*ProfilesUseController)(nil) +var _ fctl.Controller[*UseStore] = (*UseController)(nil) -func NewDefaultProfilesUseStore() *ProfilesUseStore { - return &ProfilesUseStore{ - Success: false, - } +func NewDefaultProfilesUseStore() *UseStore { + return &UseStore{} } -func NewProfilesUseController() *ProfilesUseController { - return &ProfilesUseController{ +func NewProfilesUseController() *UseController { + return &UseController{ store: NewDefaultProfilesUseStore(), } } -func ProfileNamesAutoCompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - ret, err := fctl.ListProfiles(cmd, toComplete) +func ProfileNamesAutoCompletion(cmd *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) { + ret, err := fctl.ListProfiles(cmd, func(s string) bool { + return strings.HasPrefix(s, toComplete) + }) if err != nil { return []string{}, cobra.ShellCompDirectiveError } @@ -38,26 +40,33 @@ func ProfileNamesAutoCompletion(cmd *cobra.Command, args []string, toComplete st return ret, cobra.ShellCompDirectiveNoFileComp } -func (c *ProfilesUseController) GetStore() *ProfilesUseStore { +func (c *UseController) GetStore() *UseStore { return c.store } -func (c *ProfilesUseController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - config, err := fctl.GetConfig(cmd) +func (c *UseController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { + config, err := fctl.LoadConfig(cmd) + if err != nil { + return nil, err + } + + _, err = fctl.LoadProfile(cmd, args[0]) + if os.IsNotExist(err) { + return nil, fmt.Errorf("profile %s not found", args[0]) + } if err != nil { return nil, err } - config.SetCurrentProfileName(args[0]) - if err := config.Persist(); err != nil { - return nil, errors.Wrap(err, "Updating config") + config.CurrentProfile = args[0] + if err := fctl.WriteConfig(cmd, *config); err != nil { + return nil, fmt.Errorf("Updating config: %w", err) } - c.store.Success = true return c, nil } -func (c *ProfilesUseController) Render(cmd *cobra.Command, args []string) error { +func (c *UseController) Render(cmd *cobra.Command, _ []string) error { pterm.Success.WithWriter(cmd.OutOrStdout()).Printfln("Selected profile updated!") return nil } diff --git a/cmd/prompt.go b/cmd/prompt.go index a65c2406..17e50aca 100644 --- a/cmd/prompt.go +++ b/cmd/prompt.go @@ -1,7 +1,6 @@ package cmd import ( - "context" "errors" "fmt" "os" @@ -60,11 +59,15 @@ func (p *prompt) completionsFromCommand(subCommand *cobra.Command, completionsAr }), d.GetWordBeforeCursor(), true) } -func (p *prompt) completions(cfg *fctl.Config, d goprompt.Document) []goprompt.Suggest { +func (p *prompt) completions(cmd *cobra.Command, d goprompt.Document) ([]goprompt.Suggest, error) { suggestions := make([]goprompt.Suggest, 0) switch { case strings.HasPrefix(d.Text, ":set "+fctl.ProfileFlag): - profiles := fctl.MapKeys(cfg.GetProfiles()) + profiles, err := fctl.ListProfiles(cmd) + if err != nil { + return nil, err + } + sort.Strings(profiles) for _, p := range profiles { suggestions = append(suggestions, goprompt.Suggest{ @@ -99,19 +102,24 @@ func (p *prompt) completions(cfg *fctl.Config, d goprompt.Document) []goprompt.S }) } - return goprompt.FilterHasPrefix(suggestions, d.GetWordBeforeCursor(), true) + return goprompt.FilterHasPrefix(suggestions, d.GetWordBeforeCursor(), true), nil } -func (p *prompt) startPrompt(ctx context.Context, prompt string, cfg *fctl.Config, opts ...goprompt.Option) string { +func (p *prompt) startPrompt(cmd *cobra.Command, prompt string, opts ...goprompt.Option) (string, error) { return goprompt.Input(prompt, func(d goprompt.Document) []goprompt.Suggest { subCommand := NewRootCommand() - subCommand.SetContext(ctx) + subCommand.SetContext(cmd.Context()) switch { case d.Text == "": return p.completionsFromCommand(subCommand, []string{""}, d) case strings.HasPrefix(d.Text, ":"): - return p.completions(cfg, d) + completions, err := p.completions(cmd, d) + if err != nil { + return []goprompt.Suggest{} + } + + return completions default: parse, err := shellwords.Parse(d.Text) if err != nil { @@ -123,7 +131,7 @@ func (p *prompt) startPrompt(ctx context.Context, prompt string, cfg *fctl.Confi } return p.completionsFromCommand(subCommand, parse, d) } - }, opts...) + }, opts...), nil } func (p *prompt) executeCommand(cmd *cobra.Command, t string) error { @@ -168,13 +176,17 @@ func (p *prompt) executePromptCommand(cmd *cobra.Command, t string) error { return nil } -func (p *prompt) refreshUserEmail(cmd *cobra.Command, cfg *fctl.Config) error { - profile := fctl.GetCurrentProfile(cmd, cfg) +func (p *prompt) refreshUserEmail(cmd *cobra.Command, cfg fctl.Config) error { + profile, _, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfileWithConfig(cmd, cfg) + if err != nil { + return err + } if !profile.IsConnected() { p.userEmail = "" return nil } - userInfo, err := profile.GetUserInfo(cmd) + + userInfo, err := fctl.UserInfo(cmd, relyingParty, profile.RootTokens.Access) if err != nil { p.userEmail = "" return nil @@ -184,32 +196,36 @@ func (p *prompt) refreshUserEmail(cmd *cobra.Command, cfg *fctl.Config) error { } func (p *prompt) displayHeader(cmd *cobra.Command, cfg *fctl.Config) error { - header := fctl.GetCurrentProfileName(cmd, cfg) + header := "" if p.userEmail != "" { + currentProfile, _, err := fctl.LoadCurrentProfile(cmd, *cfg) + if err != nil { + return err + } header += " / " + p.userEmail - if organizationID := fctl.GetCurrentProfile(cmd, cfg).GetDefaultOrganization(); organizationID != "" { + if organizationID := currentProfile.GetDefaultOrganization(); organizationID != "" { header += " / " + organizationID } - if stackID := fctl.GetCurrentProfile(cmd, cfg).GetDefaultStack(); stackID != "" { + if stackID := currentProfile.GetDefaultStack(); stackID != "" { header += " / " + stackID } } header += " #" - fctl.BasicTextCyan.WithWriter(cmd.OutOrStdout()).Printfln(header) + fctl.BasicTextCyan.WithWriter(cmd.OutOrStdout()).Printfln("%s", header) return nil } func (p *prompt) nextCommand(cmd *cobra.Command) error { - cfg, err := fctl.GetConfig(cmd) + cfg, err := fctl.LoadConfig(cmd) if err != nil { return err } - currentProfileName := fctl.GetCurrentProfileName(cmd, cfg) + currentProfileName := fctl.GetCurrentProfileName(cmd, *cfg) if currentProfileName != p.actualProfile || p.userEmail == "" { - if err := p.refreshUserEmail(cmd, cfg); err != nil { + if err := p.refreshUserEmail(cmd, *cfg); err != nil { return err } p.actualProfile = currentProfileName @@ -219,18 +235,22 @@ func (p *prompt) nextCommand(cmd *cobra.Command) error { return err } - switch t := p.startPrompt(cmd.Context(), " > ", cfg, + prompt, err := p.startPrompt(cmd, " > ", goprompt.OptionPrefixTextColor(p.promptColor), goprompt.OptionHistory(p.history), - goprompt.OptionCompletionOnDown()); t { + goprompt.OptionCompletionOnDown()) + if err != nil { + return err + } + switch prompt { case "": p.promptColor = goprompt.Blue default: var err error - if strings.HasPrefix(t, ":") { - err = p.executePromptCommand(cmd, t) + if strings.HasPrefix(prompt, ":") { + err = p.executePromptCommand(cmd, prompt) } else { - err = p.executeCommand(cmd, t) + err = p.executeCommand(cmd, prompt) } if err != nil { pterm.Error.WithWriter(cmd.OutOrStderr()).Printfln("%s", err) @@ -238,7 +258,7 @@ func (p *prompt) nextCommand(cmd *cobra.Command) error { } else { p.promptColor = goprompt.Blue } - p.history = append(p.history, t) + p.history = append(p.history, prompt) } return nil diff --git a/cmd/reconciliation/list.go b/cmd/reconciliation/list.go index 4d9cad1d..0747d717 100644 --- a/cmd/reconciliation/list.go +++ b/cmd/reconciliation/list.go @@ -46,7 +46,16 @@ func (c *ListController) GetStore() *ListStore { } func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } var cursor *string if c := fctl.GetString(cmd, c.cursorFlag); c != "" { @@ -58,7 +67,7 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable pageSize = fctl.Ptr(int64(ps)) } - response, err := store.Client().Reconciliation.V1.ListReconciliations( + response, err := stackClient.Reconciliation.V1.ListReconciliations( cmd.Context(), operations.ListReconciliationsRequest{ Cursor: cursor, diff --git a/cmd/reconciliation/policies/create.go b/cmd/reconciliation/policies/create.go index 6352990c..296c555f 100644 --- a/cmd/reconciliation/policies/create.go +++ b/cmd/reconciliation/policies/create.go @@ -47,13 +47,22 @@ func (c *CreateController) GetStore() *CreateStore { } func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to create a new policy") { + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + if !fctl.CheckStackApprobation(cmd, "You are about to create a new policy") { return nil, fctl.ErrMissingApproval } - script, err := fctl.ReadFile(cmd, store.Stack(), args[0]) + script, err := fctl.ReadFile(cmd, args[0]) if err != nil { return nil, err } @@ -64,7 +73,7 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab } //nolint:gosimple - response, err := store.Client().Reconciliation.V1.CreatePolicy(cmd.Context(), request) + response, err := stackClient.Reconciliation.V1.CreatePolicy(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/reconciliation/policies/delete.go b/cmd/reconciliation/policies/delete.go index 792b28ad..4ad63ea2 100644 --- a/cmd/reconciliation/policies/delete.go +++ b/cmd/reconciliation/policies/delete.go @@ -49,13 +49,21 @@ func (c *DeleteController) GetStore() *DeleteStore { func (c *DeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to delete '%s'", args[0]) { + if !fctl.CheckStackApprobation(cmd, "You are about to delete '%s'", args[0]) { return nil, fctl.ErrMissingApproval } - response, err := store.Client().Reconciliation.V1.DeletePolicy( + response, err := stackClient.Reconciliation.V1.DeletePolicy( cmd.Context(), operations.DeletePolicyRequest{ PolicyID: args[0], diff --git a/cmd/reconciliation/policies/list.go b/cmd/reconciliation/policies/list.go index 0bba0887..608e9c4d 100644 --- a/cmd/reconciliation/policies/list.go +++ b/cmd/reconciliation/policies/list.go @@ -47,7 +47,16 @@ func (c *ListController) GetStore() *ListStore { } func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } var cursor *string if c := fctl.GetString(cmd, c.cursorFlag); c != "" { @@ -59,7 +68,7 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable pageSize = fctl.Ptr(int64(ps)) } - response, err := store.Client().Reconciliation.V1.ListPolicies( + response, err := stackClient.Reconciliation.V1.ListPolicies( cmd.Context(), operations.ListPoliciesRequest{ Cursor: cursor, diff --git a/cmd/reconciliation/policies/reconciliation.go b/cmd/reconciliation/policies/reconciliation.go index c866e816..be5e7802 100644 --- a/cmd/reconciliation/policies/reconciliation.go +++ b/cmd/reconciliation/policies/reconciliation.go @@ -48,7 +48,16 @@ func (c *ReconciliationController) GetStore() *ReconciliationStore { } func (c *ReconciliationController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } atLedger, err := time.Parse(time.RFC3339, args[1]) if err != nil { @@ -60,7 +69,7 @@ func (c *ReconciliationController) Run(cmd *cobra.Command, args []string) (fctl. return nil, err } - response, err := store.Client().Reconciliation.V1.Reconcile(cmd.Context(), operations.ReconcileRequest{ + response, err := stackClient.Reconciliation.V1.Reconcile(cmd.Context(), operations.ReconcileRequest{ PolicyID: args[0], ReconciliationRequest: shared.ReconciliationRequest{ ReconciledAtLedger: atLedger, diff --git a/cmd/reconciliation/policies/show.go b/cmd/reconciliation/policies/show.go index 7d2269a7..32aebc76 100644 --- a/cmd/reconciliation/policies/show.go +++ b/cmd/reconciliation/policies/show.go @@ -48,9 +48,18 @@ func (c *ShowController) GetStore() *ShowStore { } func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - response, err := store.Client().Reconciliation.V1.GetPolicy(cmd.Context(), operations.GetPolicyRequest{ + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + response, err := stackClient.Reconciliation.V1.GetPolicy(cmd.Context(), operations.GetPolicyRequest{ PolicyID: args[0], }) if err != nil { diff --git a/cmd/reconciliation/root.go b/cmd/reconciliation/root.go index bf5aef6d..a86d12a3 100644 --- a/cmd/reconciliation/root.go +++ b/cmd/reconciliation/root.go @@ -15,8 +15,5 @@ func NewCommand() *cobra.Command { NewListCommand(), NewShowCommand(), ), - fctl.WithPersistentPreRunE(func(cmd *cobra.Command, args []string) error { - return fctl.NewStackStore(cmd) - }), ) } diff --git a/cmd/reconciliation/show.go b/cmd/reconciliation/show.go index 7ce283c3..fe07f8c7 100644 --- a/cmd/reconciliation/show.go +++ b/cmd/reconciliation/show.go @@ -48,9 +48,18 @@ func (c *ShowController) GetStore() *ShowStore { } func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - response, err := store.Client().Reconciliation.V1.GetReconciliation(cmd.Context(), operations.GetReconciliationRequest{ + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + response, err := stackClient.Reconciliation.V1.GetReconciliation(cmd.Context(), operations.GetReconciliationRequest{ ReconciliationID: args[0], }) if err != nil { diff --git a/cmd/root.go b/cmd/root.go index 1618f62c..3683c3e6 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -13,8 +13,8 @@ import ( "github.com/spf13/cobra" "github.com/formancehq/formance-sdk-go/v3/pkg/models/sdkerrors" - "github.com/formancehq/go-libs/api" - "github.com/formancehq/go-libs/logging" + "github.com/formancehq/go-libs/v3/api" + "github.com/formancehq/go-libs/v3/logging" "github.com/formancehq/fctl/cmd/auth" "github.com/formancehq/fctl/cmd/cloud" @@ -30,7 +30,7 @@ import ( "github.com/formancehq/fctl/cmd/version" "github.com/formancehq/fctl/cmd/wallets" "github.com/formancehq/fctl/cmd/webhooks" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/apierrors" fctl "github.com/formancehq/fctl/pkg" ) @@ -65,13 +65,13 @@ func NewRootCommand() *cobra.Command { orchestration.NewCommand(), ), fctl.WithPersistentStringPFlag(fctl.ProfileFlag, "p", "", "Configuration profile to use"), - fctl.WithPersistentStringPFlag(fctl.FileFlag, "c", fmt.Sprintf("%s/.formance/fctl.config", homedir), "Path to configuration file"), + fctl.WithPersistentStringPFlag(fctl.ConfigDir, "c", fmt.Sprintf("%s/.config/formance/fctl", homedir), "Path to configuration dir"), fctl.WithPersistentBoolPFlag(fctl.DebugFlag, "d", false, "Enable debug mode"), fctl.WithPersistentStringPFlag(fctl.OutputFlag, "o", "plain", "Output format (plain, json)"), fctl.WithPersistentBoolFlag(fctl.InsecureTlsFlag, false, "Allow insecure TLS connections"), fctl.WithPersistentBoolFlag(fctl.TelemetryFlag, false, "Enable telemetry"), fctl.WithPersistentPreRunE(func(cmd *cobra.Command, args []string) error { - logger := logging.NewDefaultLogger(cmd.OutOrStdout(), fctl.GetBool(cmd, fctl.DebugFlag), false) + logger := logging.NewDefaultLogger(cmd.OutOrStdout(), fctl.GetBool(cmd, fctl.DebugFlag), false, false) ctx := logging.ContextWithLogger(cmd.Context(), logger) cmd.SetContext(ctx) return nil @@ -80,15 +80,12 @@ func NewRootCommand() *cobra.Command { cmd.Version = version.Version err = cmd.RegisterFlagCompletionFunc(fctl.ProfileFlag, func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - cfg, err := fctl.GetConfig(cmd) + profiles, err := fctl.ListProfiles(cmd) if err != nil { return []string{}, cobra.ShellCompDirectiveError } - ret := make([]string, 0) - for name := range cfg.GetProfiles() { - ret = append(ret, name) - } - return ret, cobra.ShellCompDirectiveNoFileComp + + return profiles, cobra.ShellCompDirectiveNoFileComp }) if err != nil { panic(err) @@ -123,16 +120,23 @@ func Execute() { case *sdkerrors.V2ErrorResponse: printV2ErrorResponse(err) return - case *membershipclient.GenericOpenAPIError: - body := err.Body() + case *apierrors.APIError: + body := err.Body errResponse := api.ErrorResponse{} - if err := json.Unmarshal(body, &errResponse); err != nil { - pterm.Error.WithWriter(os.Stderr).Printfln(string(body)) + if err := json.Unmarshal([]byte(body), &errResponse); err != nil { + pterm.Error.WithWriter(os.Stderr).Printfln("%s", body) return } printError(errResponse.ErrorCode, errResponse.ErrorMessage, &errResponse.Details) return + case *apierrors.Error: + errMsg := "" + if err.ErrorMessage != nil { + errMsg = *err.ErrorMessage + } + printError(err.ErrorCode, errMsg, nil) + return default: pterm.Error.WithWriter(os.Stderr).Println(unwrapped) unwrapped = errors.Unwrap(unwrapped) diff --git a/cmd/search/root.go b/cmd/search/root.go index a7cfd3b0..972ad79d 100644 --- a/cmd/search/root.go +++ b/cmd/search/root.go @@ -55,7 +55,15 @@ func (c *SearchController) GetStore() *SearchStore { func (c *SearchController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } terms := make([]string, 0) if len(args) > 1 { @@ -74,7 +82,7 @@ func (c *SearchController) Run(cmd *cobra.Command, args []string) (fctl.Renderab Terms: terms, Target: &target, } - response, err := store.Client().Search.V1.Search(cmd.Context(), request) + response, err := stackClient.Search.V1.Search(cmd.Context(), request) if err != nil { return nil, err } @@ -173,33 +181,5 @@ func NewCommand() *cobra.Command { // }), fctl.WithShortDescription("Search in all services (Default: ANY), or in a specific service (ACCOUNT, TRANSACTION, ASSET, PAYMENT)"), fctl.WithController(NewSearchController()), - fctl.WithPersistentPreRunE(func(cmd *cobra.Command, args []string) error { - - cfg, err := fctl.GetConfig(cmd) - if err != nil { - return err - } - apiClient, err := fctl.NewMembershipClient(cmd, cfg) - if err != nil { - return err - } - organizationID, err := fctl.ResolveOrganizationID(cmd, cfg, apiClient.DefaultAPI) - if err != nil { - return err - } - - stack, err := fctl.ResolveStack(cmd, cfg, organizationID) - if err != nil { - return err - } - - stackClient, err := fctl.NewStackClient(cmd, cfg, stack) - if err != nil { - return err - } - cmd.SetContext(fctl.ContextWithStackStore(cmd.Context(), fctl.StackNode(cfg, stack, organizationID, stackClient))) - - return nil - }), ) } diff --git a/cmd/stack/controller.go b/cmd/stack/controller.go index 638c1c34..e963d1b9 100644 --- a/cmd/stack/controller.go +++ b/cmd/stack/controller.go @@ -9,15 +9,12 @@ import ( "github.com/spf13/cobra" "github.com/formancehq/fctl/cmd/stack/internal" - "github.com/formancehq/fctl/membershipclient" - fctl "github.com/formancehq/fctl/pkg" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" ) -func waitStackReady(cmd *cobra.Command, client *fctl.MembershipClient, organizationId, stackId string) (*membershipclient.Stack, error) { - var resp *http.Response - var err error - var stackRsp *membershipclient.CreateStackResponse - +func waitStackReady(cmd *cobra.Command, client *membershipclient.SDK, organizationId, stackId string) (*components.Stack, error) { waitTime := 2 * time.Second sum := 2 * time.Second @@ -29,28 +26,39 @@ func waitStackReady(cmd *cobra.Command, client *fctl.MembershipClient, organizat } for { - err = client.RefreshIfNeeded(cmd) - if err != nil { - return nil, err + request := operations.GetStackRequest{ + OrganizationID: organizationId, + StackID: stackId, } - stackRsp, resp, err = client.DefaultAPI.GetStack(cmd.Context(), organizationId, stackId).Execute() + stackRsp, err := client.GetStack(cmd.Context(), request) if err != nil { return nil, err } - if resp.StatusCode == http.StatusNotFound { + + if stackRsp.GetHTTPMeta().Response.StatusCode == http.StatusNotFound { return nil, fmt.Errorf("stack %s not found", stackId) } - if stackRsp.Data.Status == "READY" { - return stackRsp.Data, nil + if stackRsp.CreateStackResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + stackData := stackRsp.CreateStackResponse.GetData() + + if stackData == nil { + return nil, fmt.Errorf("unexpected response: stack data is nil") + } + + if stackData.GetStatus() == "READY" { + return stackData, nil } if sum > 10*time.Minute { pterm.Warning.Printf("You can check fctl stack show %s --organization %s to see the status of the stack", stackId, organizationId) problem := fmt.Errorf("there might a problem with the stack scheduling, if the problem persists, please contact the support") - err = internal.PrintStackInformation(cmd.OutOrStdout(), client.GetProfile(), stackRsp.Data, nil) + err = internal.PrintStackInformation(cmd.OutOrStdout(), stackData, nil) if err != nil { return nil, problem } diff --git a/cmd/stack/create.go b/cmd/stack/create.go index b84e966a..dc288adf 100644 --- a/cmd/stack/create.go +++ b/cmd/stack/create.go @@ -1,48 +1,47 @@ package stack import ( + "errors" "fmt" "net/http" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" "github.com/formancehq/formance-sdk-go/v3/pkg/models/shared" - "github.com/formancehq/go-libs/pointer" + "github.com/formancehq/go-libs/v3/pointer" "github.com/formancehq/fctl/cmd/stack/internal" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) const ( - unprotectFlag = "unprotect" - regionFlag = "region" - nowaitFlag = "no-wait" - versionFlag = "version" + regionFlag = "region" + nowaitFlag = "no-wait" + versionFlag = "version" ) -type StackCreateStore struct { - Stack *membershipclient.Stack +type CreateStore struct { + Stack *components.Stack Versions *shared.GetVersionsResponse } -type StackCreateController struct { - store *StackCreateStore - profile *fctl.Profile +type CreateController struct { + store *CreateStore } -var _ fctl.Controller[*StackCreateStore] = (*StackCreateController)(nil) +var _ fctl.Controller[*CreateStore] = (*CreateController)(nil) -func NewDefaultStackCreateStore() *StackCreateStore { - return &StackCreateStore{ - Stack: &membershipclient.Stack{}, +func NewDefaultStackCreateStore() *CreateStore { + return &CreateStore{ + Stack: &components.Stack{}, Versions: &shared.GetVersionsResponse{}, } } -func NewStackCreateController() *StackCreateController { - return &StackCreateController{ +func NewStackCreateController() *CreateController { + return &CreateController{ store: NewDefaultStackCreateStore(), } } @@ -53,24 +52,27 @@ func NewCreateCommand() *cobra.Command { fctl.WithAliases("c", "cr"), fctl.WithArgs(cobra.RangeArgs(0, 1)), fctl.WithValidArgsFunction(cobra.NoFileCompletions), - fctl.WithBoolFlag(unprotectFlag, false, "Unprotect stacks (no confirmation on write commands)"), fctl.WithStringFlag(regionFlag, "", "Region on which deploy the stack"), fctl.WithStringFlag(versionFlag, "", "Version of the stack"), fctl.WithBoolFlag(nowaitFlag, false, "Not wait stack availability"), fctl.WithController(NewStackCreateController()), ) } -func (c *StackCreateController) GetStore() *StackCreateStore { +func (c *CreateController) GetStore() *CreateStore { return c.store } -func (c *StackCreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { +func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { var err error - store := fctl.GetOrganizationStore(cmd) - protected := !fctl.GetBool(cmd, unprotectFlag) - metadata := map[string]string{ - fctl.ProtectedStackMetadata: fctl.BoolPointerToString(&protected), + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err } name := "" @@ -85,22 +87,30 @@ func (c *StackCreateController) Run(cmd *cobra.Command, args []string) (fctl.Ren region := fctl.GetString(cmd, regionFlag) if region == "" { - regions, _, err := store.Client().ListRegions(cmd.Context(), store.OrganizationId()).Execute() + listRegionsRequest := operations.ListRegionsRequest{ + OrganizationID: organizationID, + } + + regionsResponse, err := apiClient.ListRegions(cmd.Context(), listRegionsRequest) if err != nil { - return nil, errors.Wrap(err, "listing regions") + return nil, fmt.Errorf("listing regions: %w", err) + } + + if regionsResponse.ListRegionsResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") } var options []string - for _, region := range regions.Data { + for _, regionItem := range regionsResponse.ListRegionsResponse.GetData() { privacy := "Private" - if region.Public { + if regionItem.GetPublic() { privacy = "Public " } name := "" - if region.Name != "" { - name = region.Name + if regionName := regionItem.GetName(); regionName != "" { + name = regionName } - options = append(options, fmt.Sprintf("%s | %s | %s", region.Id, privacy, name)) + options = append(options, fmt.Sprintf("%s | %s | %s", regionItem.GetID(), privacy, name)) } if len(options) == 0 { @@ -114,32 +124,36 @@ func (c *StackCreateController) Run(cmd *cobra.Command, args []string) (fctl.Ren } for i := 0; i < len(options); i++ { if selectedOption == options[i] { - region = regions.Data[i].Id + region = regionsResponse.ListRegionsResponse.GetData()[i].GetID() break } } } - req := membershipclient.CreateStackRequest{ + req := components.CreateStackRequest{ Name: name, - Metadata: pointer.For(metadata), RegionID: region, } - availableVersions, httpResponse, err := store.Client().GetRegionVersions(cmd.Context(), store.OrganizationId(), region).Execute() + getVersionsRequest := operations.GetRegionVersionsRequest{ + OrganizationID: organizationID, + RegionID: region, + } + + availableVersionsResponse, err := apiClient.GetRegionVersions(cmd.Context(), getVersionsRequest) if err != nil { - return nil, errors.Wrap(err, "retrieving available versions") + return nil, fmt.Errorf("retrieving available versions: %w", err) } - if httpResponse.StatusCode > 300 { - return nil, err + if availableVersionsResponse.GetRegionVersionsResponse == nil { + return nil, fmt.Errorf("unexpected response: no versions data") } specifiedVersion := fctl.GetString(cmd, versionFlag) if specifiedVersion == "" { var options []string - for _, version := range availableVersions.Data { - options = append(options, version.Name) + for _, version := range availableVersionsResponse.GetRegionVersionsResponse.GetData() { + options = append(options, version.GetName()) } selectedOption := "" @@ -155,12 +169,24 @@ func (c *StackCreateController) Run(cmd *cobra.Command, args []string) (fctl.Ren } req.Version = pointer.For(specifiedVersion) - stackResponse, _, err := store.Client(). - CreateStack(cmd.Context(), store.OrganizationId()). - CreateStackRequest(req). - Execute() + createStackRequest := operations.CreateStackRequest{ + OrganizationID: organizationID, + Body: &req, + } + + stackResponse, err := apiClient.CreateStack(cmd.Context(), createStackRequest) if err != nil { - return nil, errors.Wrap(err, "creating stack") + return nil, fmt.Errorf("creating stack: %w", err) + } + + if stackResponse.CreateStackResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + stackData := stackResponse.CreateStackResponse.GetData() + + if stackData == nil { + return nil, fmt.Errorf("unexpected response: stack data is nil") } if !fctl.GetBool(cmd, nowaitFlag) { @@ -169,7 +195,7 @@ func (c *StackCreateController) Run(cmd *cobra.Command, args []string) (fctl.Ren return nil, err } - stack, err := waitStackReady(cmd, store.MembershipClient, stackResponse.Data.OrganizationId, stackResponse.Data.Id) + stack, err := waitStackReady(cmd, apiClient, stackData.GetOrganizationID(), stackData.GetID()) if err != nil { return nil, err } @@ -179,21 +205,30 @@ func (c *StackCreateController) Run(cmd *cobra.Command, args []string) (fctl.Ren return nil, err } } else { - c.store.Stack = stackResponse.Data + c.store.Stack = stackData } portal := fctl.DefaultConsoleURL - serverInfo, err := fctl.MembershipServerInfo(cmd.Context(), store.Client()) + serverInfo, err := fctl.MembershipServerInfo(cmd.Context(), apiClient) if err != nil { return nil, err } - if v := serverInfo.ConsoleURL; v != nil { + if v := serverInfo.GetConsoleURL(); v != nil { portal = *v } fctl.BasicTextCyan.WithWriter(cmd.OutOrStdout()).Println("Your portal will be reachable on: " + portal) - stackClient, err := fctl.NewStackClient(cmd, store.Config, stackResponse.Data) + // todo: need a long running client with auto refresh + stackClient, err := fctl.NewStackClient( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + organizationID, + stackData.GetID(), + ) if err != nil { return nil, err } @@ -207,11 +242,10 @@ func (c *StackCreateController) Run(cmd *cobra.Command, args []string) (fctl.Ren } c.store.Versions = versions.GetVersionsResponse - c.profile = store.Config.GetProfile(fctl.GetCurrentProfileName(cmd, store.Config)) return c, nil } -func (c *StackCreateController) Render(cmd *cobra.Command, args []string) error { - return internal.PrintStackInformation(cmd.OutOrStdout(), c.profile, c.store.Stack, c.store.Versions) +func (c *CreateController) Render(cmd *cobra.Command, _ []string) error { + return internal.PrintStackInformation(cmd.OutOrStdout(), c.store.Stack, c.store.Versions) } diff --git a/cmd/stack/delete.go b/cmd/stack/delete.go index 18135348..0f8f4264 100644 --- a/cmd/stack/delete.go +++ b/cmd/stack/delete.go @@ -1,11 +1,16 @@ package stack import ( - "github.com/pkg/errors" + "errors" + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/go-libs/v3/pointer" + + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -15,8 +20,8 @@ const ( ) type DeletedStackStore struct { - Stack *membershipclient.Stack `json:"stack"` - Status string `json:"status"` + Stack *components.Stack `json:"stack"` + Status string `json:"status"` } type StackDeleteController struct { store *DeletedStackStore @@ -26,7 +31,7 @@ var _ fctl.Controller[*DeletedStackStore] = (*StackDeleteController)(nil) func NewDefaultDeletedStackStore() *DeletedStackStore { return &DeletedStackStore{ - Stack: &membershipclient.Stack{}, + Stack: &components.Stack{}, Status: "", } } @@ -54,30 +59,53 @@ func (c *StackDeleteController) GetStore() *DeletedStackStore { } func (c *StackDeleteController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetOrganizationStore(cmd) - var stack *membershipclient.Stack + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + var stack *components.Stack if len(args) == 1 { if fctl.GetString(cmd, stackNameFlag) != "" { return nil, errors.New("need either an id of a name specified using --name flag") } - rsp, _, err := store.Client().GetStack(cmd.Context(), store.OrganizationId(), args[0]).Execute() + getRequest := operations.GetStackRequest{ + OrganizationID: organizationID, + StackID: args[0], + } + rsp, err := apiClient.GetStack(cmd.Context(), getRequest) if err != nil { return nil, err } - stack = rsp.Data + if rsp.CreateStackResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + stack = rsp.CreateStackResponse.GetData() } else { if fctl.GetString(cmd, stackNameFlag) == "" { return nil, errors.New("need either an id of a name specified using --name flag") } - stacks, _, err := store.Client().ListStacks(cmd.Context(), store.OrganizationId()).Execute() + listRequest := operations.ListStacksRequest{ + OrganizationID: organizationID, + } + stacksResponse, err := apiClient.ListStacks(cmd.Context(), listRequest) if err != nil { - return nil, errors.Wrap(err, "listing stacks") + return nil, fmt.Errorf("listing stacks: %w", err) } - for _, s := range stacks.Data { - if s.Name == fctl.GetString(cmd, stackNameFlag) { - stack = &s + if stacksResponse.ListStacksResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + for _, s := range stacksResponse.ListStacksResponse.GetData() { + if s.GetName() == fctl.GetString(cmd, stackNameFlag) { + stackData := s + stack = &stackData break } } @@ -86,21 +114,21 @@ func (c *StackDeleteController) Run(cmd *cobra.Command, args []string) (fctl.Ren return nil, errors.New("Stack not found") } - if !fctl.CheckStackApprobation(cmd, stack, "You are about to delete stack '%s'", stack.Name) { + if !fctl.CheckStackApprobation(cmd, "You are about to delete stack '%s'", stack.GetName()) { return nil, fctl.ErrMissingApproval } - query := store.Client().DeleteStack(cmd.Context(), store.OrganizationId(), stack.Id) + deleteRequest := operations.DeleteStackRequest{ + OrganizationID: organizationID, + StackID: stack.GetID(), + } if fctl.GetBool(cmd, forceFlag) { - if isValid := fctl.CheckMembershipVersion("v0.27.1")(cmd, args); isValid != nil { - return nil, isValid - } - query = query.Force(true) + deleteRequest.Force = pointer.For(true) } - _, err := query.Execute() + _, err = apiClient.DeleteStack(cmd.Context(), deleteRequest) if err != nil { - return nil, errors.Wrap(err, "deleting stack") + return nil, fmt.Errorf("deleting stack: %w", err) } c.store.Stack = stack diff --git a/cmd/stack/disable.go b/cmd/stack/disable.go index 4b4f90a4..33a3684a 100644 --- a/cmd/stack/disable.go +++ b/cmd/stack/disable.go @@ -1,17 +1,20 @@ package stack import ( - "github.com/pkg/errors" + "errors" + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) type DisabledStore struct { - Stack *membershipclient.Stack `json:"stack"` - Status string `json:"status"` + Stack *components.Stack `json:"stack"` + Status string `json:"status"` } type DisableController struct { store *DisabledStore @@ -21,7 +24,7 @@ var _ fctl.Controller[*DisabledStore] = (*DisableController)(nil) func NewDisableStore() *DisabledStore { return &DisabledStore{ - Stack: &membershipclient.Stack{}, + Stack: &components.Stack{}, Status: "", } } @@ -54,29 +57,51 @@ func (c *DisableController) Run(cmd *cobra.Command, args []string) (fctl.Rendera stackNameFlag = "name" ) - store := fctl.GetOrganizationStore(cmd) - var stack *membershipclient.Stack + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + var stack *components.Stack if len(args) == 1 { if fctl.GetString(cmd, stackNameFlag) != "" { return nil, errors.New("need either an id of a name specified using --name flag") } - rsp, _, err := store.Client().GetStack(cmd.Context(), store.OrganizationId(), args[0]).Execute() + getRequest := operations.GetStackRequest{ + OrganizationID: organizationID, + StackID: args[0], + } + rsp, err := apiClient.GetStack(cmd.Context(), getRequest) if err != nil { return nil, err } - stack = rsp.Data + if rsp.CreateStackResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + stack = rsp.CreateStackResponse.GetData() } else { if fctl.GetString(cmd, stackNameFlag) == "" { return nil, errors.New("need either an id of a name specified using --name flag") } - stacks, _, err := store.Client().ListStacks(cmd.Context(), store.OrganizationId()).Execute() + listRequest := operations.ListStacksRequest{ + OrganizationID: organizationID, + } + stacksResponse, err := apiClient.ListStacks(cmd.Context(), listRequest) if err != nil { - return nil, errors.Wrap(err, "listing stacks") + return nil, fmt.Errorf("listing stacks: %w", err) } - for _, s := range stacks.Data { - if s.Name == fctl.GetString(cmd, stackNameFlag) { - stack = &s + if stacksResponse.ListStacksResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + for _, s := range stacksResponse.ListStacksResponse.GetData() { + if s.GetName() == fctl.GetString(cmd, stackNameFlag) { + stackData := s + stack = &stackData break } } @@ -85,12 +110,16 @@ func (c *DisableController) Run(cmd *cobra.Command, args []string) (fctl.Rendera return nil, errors.New("Stack not found") } - if !fctl.CheckStackApprobation(cmd, stack, "You are about to disable stack '%s'", stack.Name) { + if !fctl.CheckStackApprobation(cmd, "You are about to disable stack '%s'", stack.GetName()) { return nil, fctl.ErrMissingApproval } - if _, err := store.Client().DisableStack(cmd.Context(), store.OrganizationId(), stack.Id).Execute(); err != nil { - return nil, errors.Wrap(err, "stack disable") + disableRequest := operations.DisableStackRequest{ + OrganizationID: organizationID, + StackID: stack.GetID(), + } + if _, err := apiClient.DisableStack(cmd.Context(), disableRequest); err != nil { + return nil, fmt.Errorf("stack disable: %w", err) } c.store.Stack = stack diff --git a/cmd/stack/enable.go b/cmd/stack/enable.go index 8cfb6f17..6bc441c6 100644 --- a/cmd/stack/enable.go +++ b/cmd/stack/enable.go @@ -1,17 +1,20 @@ package stack import ( - "github.com/pkg/errors" + "errors" + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) type EnableStore struct { - Stack *membershipclient.Stack `json:"stack"` - Status string `json:"status"` + Stack *components.Stack `json:"stack"` + Status string `json:"status"` } type EnableController struct { store *EnableStore @@ -21,7 +24,7 @@ var _ fctl.Controller[*EnableStore] = (*EnableController)(nil) func NewEnableStore() *EnableStore { return &EnableStore{ - Stack: &membershipclient.Stack{}, + Stack: &components.Stack{}, Status: "", } } @@ -54,30 +57,52 @@ func (c *EnableController) Run(cmd *cobra.Command, args []string) (fctl.Renderab stackNameFlag = "name" ) - store := fctl.GetOrganizationStore(cmd) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } - var stack *membershipclient.Stack + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + var stack *components.Stack if len(args) == 1 { if fctl.GetString(cmd, stackNameFlag) != "" { - return nil, errors.New("need either an id of a name specified using --name flag") + return nil, errors.New("need either an id or a name specified using --name flag") } - rsp, _, err := store.Client().GetStack(cmd.Context(), store.OrganizationId(), args[0]).Execute() + getRequest := operations.GetStackRequest{ + OrganizationID: organizationID, + StackID: args[0], + } + rsp, err := apiClient.GetStack(cmd.Context(), getRequest) if err != nil { return nil, err } - stack = rsp.Data + if rsp.CreateStackResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + stack = rsp.CreateStackResponse.GetData() } else { if fctl.GetString(cmd, stackNameFlag) == "" { return nil, errors.New("need either an id of a name specified using --name flag") } - stacks, _, err := store.Client().ListStacks(cmd.Context(), store.OrganizationId()).Execute() + listRequest := operations.ListStacksRequest{ + OrganizationID: organizationID, + } + stacksResponse, err := apiClient.ListStacks(cmd.Context(), listRequest) if err != nil { - return nil, errors.Wrap(err, "listing stacks") + return nil, fmt.Errorf("listing stacks: %w", err) } - for _, s := range stacks.Data { - if s.Name == fctl.GetString(cmd, stackNameFlag) { - stack = &s + if stacksResponse.ListStacksResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + for _, s := range stacksResponse.ListStacksResponse.GetData() { + if s.GetName() == fctl.GetString(cmd, stackNameFlag) { + stackData := s + stack = &stackData break } } @@ -86,12 +111,16 @@ func (c *EnableController) Run(cmd *cobra.Command, args []string) (fctl.Renderab return nil, errors.New("Stack not found") } - if !fctl.CheckStackApprobation(cmd, stack, "You are about to enable stack '%s'", stack.Name) { + if !fctl.CheckStackApprobation(cmd, "You are about to enable stack '%s'", stack.GetName()) { return nil, fctl.ErrMissingApproval } - if _, err := store.Client().EnableStack(cmd.Context(), store.OrganizationId(), stack.Id).Execute(); err != nil { - return nil, errors.Wrap(err, "stack enable") + enableRequest := operations.EnableStackRequest{ + OrganizationID: organizationID, + StackID: stack.GetID(), + } + if _, err := apiClient.EnableStack(cmd.Context(), enableRequest); err != nil { + return nil, fmt.Errorf("stack enable: %w", err) } c.store.Stack = stack diff --git a/cmd/stack/history.go b/cmd/stack/history.go index be92f109..13ed642f 100644 --- a/cmd/stack/history.go +++ b/cmd/stack/history.go @@ -2,11 +2,15 @@ package stack import ( "errors" + "fmt" "strings" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/go-libs/v3/pointer" + + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" "github.com/formancehq/fctl/pkg/printer" ) @@ -22,7 +26,7 @@ const ( ) type HistoryStore struct { - Cursor *membershipclient.LogCursorData `json:"cursor"` + Cursor *components.LogCursorData `json:"cursor"` } type HistoryController struct { @@ -33,7 +37,7 @@ var _ fctl.Controller[*HistoryStore] = (*HistoryController)(nil) func NewDefaultHistoryStore() *HistoryStore { return &HistoryStore{ - Cursor: &membershipclient.LogCursorData{}, + Cursor: &components.LogCursorData{}, } } func NewHistoryController() *HistoryController { @@ -56,9 +60,6 @@ func NewHistoryCommand() *cobra.Command { fctl.WithStringFlag(cursorFlag, "", "Cursor"), fctl.WithIntFlag(pageSizeFlag, 10, "Page size"), - fctl.WithPreRunE(func(cmd *cobra.Command, args []string) error { - return fctl.CheckMembershipVersion("v0.29.0")(cmd, args) - }), fctl.WithController(NewHistoryController()), ) } @@ -67,36 +68,54 @@ func (c *HistoryController) GetStore() *HistoryStore { } func (c *HistoryController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetOrganizationStore(cmd) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } pageSize := fctl.GetInt(cmd, pageSizeFlag) stackID := args[0] - req := store.Client().ListLogs(cmd.Context(), store.OrganizationId()).PageSize(int32(pageSize)).StackId(stackID) cursor := fctl.GetString(cmd, cursorFlag) userID := fctl.GetString(cmd, userIdFlag) action := fctl.GetString(cmd, actionFlag) data := fctl.GetString(cmd, dataFlag) + if cursor != "" { if userID != "" || action != "" || data != "" { return nil, errors.New("cursor can't be used with other flags") } - - req = req.Cursor(cursor) } if stackID == "" && cursor == "" { return nil, errors.New("stack-id or cursor is required") } + request := operations.ListLogsRequest{ + OrganizationID: organizationID, + StackID: &stackID, + PageSize: pointer.For(int64(pageSize)), + } + + if cursor != "" { + request.Cursor = &cursor + } + if userID != "" { - req = req.UserId(userID) + request.UserID = &userID } if action != "" { if !strings.Contains(action, "stacks") { return nil, errors.New("stacks history are scoped to 'stacks.*' actions") } - req = req.Action(membershipclient.Action(action)) + actionEnum := components.Action(action) + request.Action = &actionEnum } if data != "" { @@ -104,20 +123,21 @@ func (c *HistoryController) Run(cmd *cobra.Command, args []string) (fctl.Rendera if len(keyVal) != 2 { return nil, errors.New("data filter must be in the form key=value") } - - req = req.Key(keyVal[0]).Value(keyVal[1]) + request.Key = &keyVal[0] + request.Value = &keyVal[1] } - log, res, err := req.Execute() + response, err := apiClient.ListLogs(cmd.Context(), request) if err != nil { return nil, err } - if res.StatusCode >= 300 { - return nil, errors.New("error listing stack logs") + if response.LogCursor == nil { + return nil, fmt.Errorf("unexpected response: no data") } - c.store.Cursor = &log.Data + cursorData := response.LogCursor.GetData() + c.store.Cursor = &cursorData return c, nil } diff --git a/cmd/stack/internal/print.go b/cmd/stack/internal/print.go index 29f04321..980f30d5 100644 --- a/cmd/stack/internal/print.go +++ b/cmd/stack/internal/print.go @@ -3,20 +3,17 @@ package internal import ( "fmt" "io" - "net/url" "github.com/iancoleman/strcase" "github.com/pterm/pterm" "github.com/formancehq/formance-sdk-go/v3/pkg/models/shared" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" fctl "github.com/formancehq/fctl/pkg" ) -func PrintStackInformation(out io.Writer, profile *fctl.Profile, stack *membershipclient.Stack, versions *shared.GetVersionsResponse) error { - baseUrlStr := profile.ServicesBaseUrl(stack) - +func PrintStackInformation(out io.Writer, stack *components.Stack, versions *shared.GetVersionsResponse) error { err := printInformation(out, stack) if err != nil { @@ -24,7 +21,7 @@ func PrintStackInformation(out io.Writer, profile *fctl.Profile, stack *membersh } if versions != nil { - err = printVersion(out, baseUrlStr, versions, stack) + err = printVersion(out, stack.URI, versions) if err != nil { return err @@ -39,15 +36,15 @@ func PrintStackInformation(out io.Writer, profile *fctl.Profile, stack *membersh return nil } -func printInformation(out io.Writer, stack *membershipclient.Stack) error { +func printInformation(out io.Writer, stack *components.Stack) error { fctl.Section.WithWriter(out).Println("Information") tableData := pterm.TableData{} - tableData = append(tableData, []string{pterm.LightCyan("ID"), stack.Id, ""}) + tableData = append(tableData, []string{pterm.LightCyan("ID"), stack.ID, ""}) tableData = append(tableData, []string{pterm.LightCyan("Name"), stack.Name, ""}) tableData = append(tableData, []string{pterm.LightCyan("Region"), stack.RegionID, ""}) - tableData = append(tableData, []string{pterm.LightCyan("Status"), stack.State, ""}) - tableData = append(tableData, []string{pterm.LightCyan("Effective status"), stack.Status, ""}) + tableData = append(tableData, []string{pterm.LightCyan("Status"), string(stack.State), ""}) + tableData = append(tableData, []string{pterm.LightCyan("Effective status"), string(stack.Status), ""}) if stack.AuditEnabled != nil { tableData = append(tableData, []string{pterm.LightCyan("Audit enabled"), fctl.BoolPointerToString(stack.AuditEnabled), ""}) @@ -59,7 +56,7 @@ func printInformation(out io.Writer, stack *membershipclient.Stack) error { Render() } -func printVersion(out io.Writer, url *url.URL, versions *shared.GetVersionsResponse, stack *membershipclient.Stack) error { +func printVersion(out io.Writer, url string, versions *shared.GetVersionsResponse) error { fctl.Println() fctl.Section.WithWriter(out).Println("Versions") @@ -67,7 +64,7 @@ func printVersion(out io.Writer, url *url.URL, versions *shared.GetVersionsRespo for _, service := range versions.Versions { tableData = append(tableData, []string{pterm.LightCyan(strcase.ToCamel(service.Name)), service.Version, - fmt.Sprintf("%s/api/%s", url.String(), service.Name)}) + fmt.Sprintf("%s/api/%s", url, service.Name)}) } return pterm.DefaultTable. @@ -76,14 +73,14 @@ func printVersion(out io.Writer, url *url.URL, versions *shared.GetVersionsRespo Render() } -func printMetadata(out io.Writer, stack *membershipclient.Stack) error { +func printMetadata(out io.Writer, stack *components.Stack) error { fctl.Println() fctl.Section.WithWriter(out).Println("Metadata") tableData := pterm.TableData{} if stack.Metadata != nil { - for k, v := range *stack.Metadata { + for k, v := range stack.Metadata { tableData = append(tableData, []string{pterm.LightCyan(k), v}) } } diff --git a/cmd/stack/list.go b/cmd/stack/list.go index 283324f8..56fd5d72 100644 --- a/cmd/stack/list.go +++ b/cmd/stack/list.go @@ -4,11 +4,13 @@ import ( "fmt" "time" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/go-libs/v3/pointer" + + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -32,8 +34,7 @@ type StackListStore struct { } type StackListController struct { - store *StackListStore - profile *fctl.Profile + store *StackListStore } var _ fctl.Controller[*StackListStore] = (*StackListController)(nil) @@ -66,50 +67,64 @@ func (c *StackListController) GetStore() *StackListStore { return c.store } -func (c *StackListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { +func (c *StackListController) Run(cmd *cobra.Command, _ []string) (fctl.Renderable, error) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } - store := fctl.GetOrganizationStore(cmd) - c.profile = store.Config.GetProfile(fctl.GetCurrentProfileName(cmd, store.Config)) + request := operations.ListStacksRequest{ + OrganizationID: organizationID, + All: pointer.For(fctl.GetBool(cmd, allFlag)), + Deleted: pointer.For(fctl.GetBool(cmd, deletedFlag)), + } - rsp, _, err := store.Client().ListStacks(cmd.Context(), store.OrganizationId()). - All(fctl.GetBool(cmd, allFlag)). - Deleted(fctl.GetBool(cmd, deletedFlag)). - Execute() + rsp, err := apiClient.ListStacks(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "listing stacks") + return nil, fmt.Errorf("listing stacks: %w", err) + } + + if rsp.ListStacksResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") } - if len(rsp.Data) == 0 { + if len(rsp.ListStacksResponse.GetData()) == 0 { return c, nil } portal := fctl.DefaultConsoleURL - serverInfo, err := fctl.MembershipServerInfo(cmd.Context(), store.Client()) + serverInfo, err := fctl.MembershipServerInfo(cmd.Context(), apiClient) if err != nil { return nil, err } - if v := serverInfo.ConsoleURL; v != nil { + if v := serverInfo.GetConsoleURL(); v != nil { portal = *v } - c.store.Stacks = fctl.Map(rsp.Data, func(stack membershipclient.Stack) Stack { + c.store.Stacks = fctl.Map(rsp.ListStacksResponse.GetData(), func(stack components.Stack) Stack { return Stack{ - Id: stack.Id, - Name: stack.Name, + Id: stack.GetID(), + Name: stack.GetName(), Dashboard: portal, - RegionID: stack.RegionID, - Status: stack.State, - AuditEnabled: fctl.BoolPointerToString(stack.AuditEnabled), + RegionID: stack.GetRegionID(), + Status: string(stack.GetState()), + AuditEnabled: fctl.BoolPointerToString(stack.GetAuditEnabled()), DisabledAt: func() *string { - if stack.DisabledAt != nil { - t := stack.DisabledAt.Format(time.RFC3339) + if disabledAt := stack.GetDisabledAt(); disabledAt != nil { + t := disabledAt.Format(time.RFC3339) return &t } return nil }(), DeletedAt: func() *string { - if stack.DeletedAt != nil { - t := stack.DeletedAt.Format(time.RFC3339) + if deletedAt := stack.GetDeletedAt(); deletedAt != nil { + t := deletedAt.Format(time.RFC3339) return &t } return nil diff --git a/cmd/stack/modules/disable.go b/cmd/stack/modules/disable.go index f649b022..bef14158 100644 --- a/cmd/stack/modules/disable.go +++ b/cmd/stack/modules/disable.go @@ -4,6 +4,7 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -39,9 +40,33 @@ func (c *DisableController) GetStore() *DisableStore { } func (c *DisableController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - mbStackStore := fctl.GetMembershipStackStore(cmd.Context()) - _, err := mbStackStore.Client().DisableModule(cmd.Context(), mbStackStore.OrganizationId(), mbStackStore.StackId()).Name(args[0]).Execute() + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, stackID, err := fctl.ResolveStackID(cmd, *profile) + if err != nil { + return nil, err + } + + apiClient, err := fctl.NewMembershipClientForOrganization(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile, organizationID) + if err != nil { + return nil, err + } + + if !fctl.CheckStackApprobation(cmd, "You are about to disable a module") { + return nil, fctl.ErrMissingApproval + } + + request := operations.DisableModuleRequest{ + OrganizationID: organizationID, + StackID: stackID, + Name: args[0], + } + + _, err = apiClient.DisableModule(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/stack/modules/enable.go b/cmd/stack/modules/enable.go index 6c5ea5fd..96087565 100644 --- a/cmd/stack/modules/enable.go +++ b/cmd/stack/modules/enable.go @@ -4,6 +4,7 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -39,8 +40,33 @@ func (c *EnableController) GetStore() *EnableStore { } func (c *EnableController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - mbStackStore := fctl.GetMembershipStackStore(cmd.Context()) - _, err := mbStackStore.Client().EnableModule(cmd.Context(), mbStackStore.OrganizationId(), mbStackStore.StackId()).Name(args[0]).Execute() + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + _, stackID, err := fctl.ResolveStackID(cmd, *profile) + if err != nil { + return nil, err + } + + if !fctl.CheckStackApprobation(cmd, "You are about to enable a module") { + return nil, fctl.ErrMissingApproval + } + + request := operations.EnableModuleRequest{ + OrganizationID: organizationID, + StackID: stackID, + Name: args[0], + } + + _, err = apiClient.EnableModule(cmd.Context(), request) if err != nil { return nil, err } diff --git a/cmd/stack/modules/list.go b/cmd/stack/modules/list.go index 302a71dc..af260cb1 100644 --- a/cmd/stack/modules/list.go +++ b/cmd/stack/modules/list.go @@ -1,17 +1,20 @@ package modules import ( + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" "github.com/formancehq/go-libs/time" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) type ListStore struct { - *membershipclient.ListModulesResponse + Modules []components.Module `json:"modules"` } type ListController struct { store *ListStore @@ -43,14 +46,37 @@ func (c *ListController) GetStore() *ListStore { } func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - mbStackStore := fctl.GetMembershipStackStore(cmd.Context()) - modules, _, err := mbStackStore.Client().ListModules(cmd.Context(), mbStackStore.OrganizationId(), mbStackStore.StackId()).Execute() + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, stackID, err := fctl.ResolveStackID(cmd, *profile) + if err != nil { + return nil, err + } + + apiClient, err := fctl.NewMembershipClientForOrganization(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile, organizationID) if err != nil { return nil, err } - c.store.ListModulesResponse = modules + request := operations.ListModulesRequest{ + OrganizationID: organizationID, + StackID: stackID, + } + + response, err := apiClient.ListModules(cmd.Context(), request) + if err != nil { + return nil, err + } + + if response.ListModulesResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.Modules = response.ListModulesResponse.GetData() return c, nil } @@ -58,13 +84,13 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable func (c *ListController) Render(cmd *cobra.Command, args []string) error { header := []string{"Name", "State", "Cluster status", "Last state update", "Last cluster state update"} - tableData := fctl.Map(c.store.ListModulesResponse.Data, func(module membershipclient.Module) []string { + tableData := fctl.Map(c.store.Modules, func(module components.Module) []string { return []string{ - module.Name, - module.State, - module.Status, - time.Time{Time: module.LastStateUpdate}.String(), - time.Time{Time: module.LastStatusUpdate}.String(), + module.GetName(), + string(module.GetState()), + string(module.GetStatus()), + time.Time{Time: module.GetLastStateUpdate()}.String(), + time.Time{Time: module.GetLastStatusUpdate()}.String(), } }) diff --git a/cmd/stack/modules/root.go b/cmd/stack/modules/root.go index 07cf3007..bb29044b 100644 --- a/cmd/stack/modules/root.go +++ b/cmd/stack/modules/root.go @@ -3,7 +3,6 @@ package modules import ( "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" fctl "github.com/formancehq/fctl/pkg" ) @@ -11,24 +10,6 @@ func NewCommand() *cobra.Command { return fctl.NewStackCommand("modules", fctl.WithShortDescription("Manage your modules"), fctl.WithAliases("module", "mod"), - fctl.WithPersistentPreRunE(func(cmd *cobra.Command, args []string) error { - orgStore := fctl.GetOrganizationStore(cmd) - if err := orgStore.CheckRegionCapability(string(membershipclient.MODULE_LIST), func(s []any) bool { - return len(s) > 0 - })(cmd, args); err != nil { - return err - } - - if err := fctl.CheckMembershipCapabilities(membershipclient.MODULE_SELECTION)(cmd, args); err != nil { - return err - } - - if err := fctl.NewMembershipStackStore(cmd); err != nil { - return err - } - - return nil - }), fctl.WithChildCommands( NewDisableCommand(), NewEnableCommand(), diff --git a/cmd/stack/proxy.go b/cmd/stack/proxy.go index f27a3c78..5cc6c18e 100644 --- a/cmd/stack/proxy.go +++ b/cmd/stack/proxy.go @@ -11,14 +11,12 @@ import ( "os" "os/signal" "strings" - "sync" "syscall" "time" "github.com/spf13/cobra" "golang.org/x/oauth2" - "github.com/formancehq/fctl/membershipclient" fctl "github.com/formancehq/fctl/pkg" ) @@ -27,26 +25,21 @@ const ( allowedOriginsFlag = "allowed-origins" ) -type StackProxyStore struct { - ProxyUrl string `json:"proxyUrl"` - StackUrl string `json:"stackUrl"` - OrganizationID string `json:"organizationId"` - StackID string `json:"stackId"` +type ProxyStore struct { } -type StackProxyController struct { - store *StackProxyStore - profile *fctl.Profile +type ProxyController struct { + store *ProxyStore } -var _ fctl.Controller[*StackProxyStore] = (*StackProxyController)(nil) +var _ fctl.Controller[*ProxyStore] = (*ProxyController)(nil) -func NewDefaultStackProxyStore() *StackProxyStore { - return &StackProxyStore{} +func NewDefaultStackProxyStore() *ProxyStore { + return &ProxyStore{} } -func NewStackProxyController() *StackProxyController { - return &StackProxyController{ +func NewStackProxyController() *ProxyController { + return &ProxyController{ store: NewDefaultStackProxyStore(), } } @@ -63,7 +56,7 @@ func NewProxyCommand() *cobra.Command { return cmd } -func (c *StackProxyController) GetStore() *StackProxyStore { +func (c *ProxyController) GetStore() *ProxyStore { return c.store } @@ -110,40 +103,38 @@ func corsMiddleware(allowedOrigins []string, next http.Handler) http.Handler { }) } -func (c *StackProxyController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetOrganizationStore(cmd) - c.profile = store.Config.GetProfile(fctl.GetCurrentProfileName(cmd, store.Config)) +func (c *ProxyController) Run(cmd *cobra.Command, _ []string) (fctl.Renderable, error) { - organizationID, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) if err != nil { return nil, err } - stack, err := fctl.ResolveStack(cmd, store.Config, organizationID) + organizationID, stackID, err := fctl.ResolveStackID(cmd, *profile) if err != nil { return nil, err } - c.store.OrganizationID = organizationID - c.store.StackID = stack.Id - c.store.StackUrl = c.profile.ServicesBaseUrl(stack).String() + stackToken, stackAccess, err := fctl.EnsureStackAccess(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile, organizationID, stackID) + if err != nil { + return nil, err + } port := fctl.GetInt(cmd, proxyPortFlag) allowedOrigins := fctl.GetStringSlice(cmd, allowedOriginsFlag) - c.store.ProxyUrl = fmt.Sprintf("http://localhost:%d", port) - stackBaseURL, err := url.Parse(c.store.StackUrl) + stackBaseURL, err := url.Parse(stackAccess.URI) if err != nil { return nil, fmt.Errorf("error parsing stack URL: %v", err) } - fmt.Fprintf(cmd.OutOrStdout(), "Target Stack URL: %s\r\n", stackBaseURL.String()) + _, _ = fmt.Fprintf(cmd.OutOrStdout(), "Target Stack URL: %s\r\n", stackBaseURL.String()) // Only show CORS info if origins are specified if len(allowedOrigins) > 0 { - fmt.Fprintf(cmd.OutOrStdout(), "CORS enabled - Allowed Origins: %s\r\n", strings.Join(allowedOrigins, ", ")) + _, _ = fmt.Fprintf(cmd.OutOrStdout(), "CORS enabled - Allowed Origins: %s\r\n", strings.Join(allowedOrigins, ", ")) } else { - fmt.Fprintf(cmd.OutOrStdout(), "CORS disabled\r\n") + _, _ = fmt.Fprintf(cmd.OutOrStdout(), "CORS disabled\r\n") } proxy := httputil.NewSingleHostReverseProxy(stackBaseURL) @@ -165,7 +156,7 @@ func (c *StackProxyController) Run(cmd *cobra.Command, args []string) (fctl.Rend RawQuery: req.URL.RawQuery, } - fmt.Fprintf(cmd.OutOrStdout(), "[%s] Proxying %s %s to %s\r\n", + _, _ = fmt.Fprintf(cmd.OutOrStdout(), "[%s] Proxying %s %s to %s\r\n", time.Now().Format(time.RFC3339), req.Method, sourceURL.String(), @@ -180,7 +171,7 @@ func (c *StackProxyController) Run(cmd *cobra.Command, args []string) (fctl.Rend RawQuery: r.URL.RawQuery, } - fmt.Fprintf(cmd.ErrOrStderr(), "[%s] ERROR proxying request to %s: %v\r\n", + _, _ = fmt.Fprintf(cmd.ErrOrStderr(), "[%s] ERROR proxying request to %s: %v\r\n", time.Now().Format(time.RFC3339), targetURL.String(), err) @@ -193,16 +184,18 @@ func (c *StackProxyController) Run(cmd *cobra.Command, args []string) (fctl.Rend _, _ = io.WriteString(w, errorMsg) } - transport := &tokenTransport{ - wrapped: fctl.NewHTTPTransport(cmd, map[string][]string{}), - profile: c.profile, - stack: stack, - cmd: cmd, - tokenMux: &sync.RWMutex{}, + proxy.Transport = &oauth2.Transport{ + Base: fctl.GetHttpClient(cmd).Transport, + Source: fctl.NewStackTokenSource( + *stackToken, + stackAccess, + relyingParty, + func(newToken fctl.AccessToken) error { + return fctl.WriteStackToken(cmd, profileName, stackID, newToken) + }, + ), } - proxy.Transport = transport - // Clear any CORS headers from upstream to prevent conflicts with our CORS middleware proxy.ModifyResponse = func(resp *http.Response) error { resp.Header.Del("Access-Control-Allow-Origin") @@ -236,7 +229,7 @@ func (c *StackProxyController) Run(cmd *cobra.Command, args []string) (fctl.Rend serverErrors := make(chan error, 1) go func() { - fmt.Fprintf(cmd.OutOrStdout(), "Starting proxy server at %s -> %s\r\n", c.store.ProxyUrl, c.store.StackUrl) + fmt.Fprintf(cmd.OutOrStdout(), "Starting proxy server at http://localhost:%d -> %s\r\n", port, stackAccess.URI) fmt.Fprintf(cmd.OutOrStdout(), "Press Ctrl+C to stop the server\r\n") // Check if port is available before starting the server @@ -281,94 +274,3 @@ type EmptyRenderable struct{} func (r *EmptyRenderable) Render(cmd *cobra.Command, args []string) error { return nil } - -type tokenTransport struct { - wrapped http.RoundTripper - profile *fctl.Profile - stack *membershipclient.Stack - cmd *cobra.Command - token *oauth2.Token - tokenMux *sync.RWMutex - tokenExpiry time.Time -} - -func (t *tokenTransport) isTokenValid() bool { - // First, grab a read lock to check for nil token and expiry zero-value. - t.tokenMux.RLock() - if t.token == nil { - t.tokenMux.RUnlock() - return false - } - - // Check if token is expired - if !t.tokenExpiry.IsZero() { - valid := time.Until(t.tokenExpiry) > 30*time.Second - t.tokenMux.RUnlock() - return valid - } - - t.tokenMux.RUnlock() - return false -} - -func (t *tokenTransport) refreshToken(ctx context.Context) error { - t.tokenMux.Lock() - defer t.tokenMux.Unlock() - - httpClient := fctl.GetHttpClient(t.cmd, map[string][]string{}) - newToken, err := t.profile.GetStackToken(ctx, httpClient, t.stack) - if err != nil { - return err - } - - t.token = newToken - t.tokenExpiry = newToken.Expiry - - fmt.Fprintf(t.cmd.OutOrStdout(), "[%s] Token refreshed, will expire at %s\r\n", - time.Now().Format(time.RFC3339), - t.tokenExpiry.Format(time.RFC3339)) - - return nil -} - -func (t *tokenTransport) RoundTrip(req *http.Request) (*http.Response, error) { - if !t.isTokenValid() { - if err := t.refreshToken(req.Context()); err != nil { - return nil, fmt.Errorf("failed to refresh token: %w", err) - } - } - - t.tokenMux.RLock() - token := t.token - t.tokenMux.RUnlock() - - reqCopy := req.Clone(req.Context()) - reqCopy.Header.Set("Authorization", fmt.Sprintf("%s %s", token.TokenType, token.AccessToken)) - - resp, err := t.wrapped.RoundTrip(reqCopy) - if err != nil { - return nil, err - } - - if resp.StatusCode == http.StatusUnauthorized { - if err := resp.Body.Close(); err != nil { - fmt.Fprintf(t.cmd.ErrOrStderr(), "[%s] Error closing response body: %v\r\n", - time.Now().Format(time.RFC3339), err) - } - - if err := t.refreshToken(req.Context()); err != nil { - return nil, fmt.Errorf("failed to refresh token after 401: %w", err) - } - - t.tokenMux.RLock() - token = t.token - t.tokenMux.RUnlock() - - newReqCopy := req.Clone(req.Context()) - newReqCopy.Header.Set("Authorization", fmt.Sprintf("%s %s", token.TokenType, token.AccessToken)) - - return t.wrapped.RoundTrip(newReqCopy) - } - - return resp, nil -} diff --git a/cmd/stack/restore.go b/cmd/stack/restore.go index 86657af9..61ce7c70 100644 --- a/cmd/stack/restore.go +++ b/cmd/stack/restore.go @@ -1,34 +1,35 @@ package stack import ( + "errors" "fmt" "net/http" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" "github.com/formancehq/formance-sdk-go/v3/pkg/models/shared" "github.com/formancehq/fctl/cmd/stack/internal" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) type StackRestoreStore struct { - Stack *membershipclient.Stack `json:"stack"` + Stack *components.Stack `json:"stack"` Versions *shared.GetVersionsResponse `json:"versions"` } type StackRestoreController struct { store *StackRestoreStore - config *fctl.Config + config fctl.Config } var _ fctl.Controller[*StackRestoreStore] = (*StackRestoreController)(nil) func NewDefaultVersionStore() *StackRestoreStore { return &StackRestoreStore{ - Stack: &membershipclient.Stack{}, + Stack: &components.Stack{}, Versions: &shared.GetVersionsResponse{}, } } @@ -55,38 +56,63 @@ func (c *StackRestoreController) GetStore() *StackRestoreStore { } func (c *StackRestoreController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetOrganizationStore(cmd) - var stack *membershipclient.Stack + + cfg, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + var stack *components.Stack if len(args) == 1 { - rsp, _, err := store.Client().GetStack(cmd.Context(), store.OrganizationId(), args[0]).Execute() + getRequest := operations.GetStackRequest{ + OrganizationID: organizationID, + StackID: args[0], + } + rsp, err := apiClient.GetStack(cmd.Context(), getRequest) if err != nil { return nil, err } - stack = rsp.Data + if rsp.CreateStackResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + stack = rsp.CreateStackResponse.GetData() } if stack == nil { return nil, errors.New("Stack not found") } - if !fctl.CheckStackApprobation(cmd, stack, "You are about to restore stack '%s'", stack.Name) { + if !fctl.CheckStackApprobation(cmd, "You are about to restore stack '%s'", stack.GetName()) { return nil, fctl.ErrMissingApproval } - response, _, err := store.Client(). - RestoreStack(cmd.Context(), store.OrganizationId(), args[0]). - Execute() + restoreRequest := operations.RestoreStackRequest{ + OrganizationID: organizationID, + StackID: args[0], + } + + response, err := apiClient.RestoreStack(cmd.Context(), restoreRequest) if err != nil { return nil, err } + if response.CreateStackResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + restoredStackData := response.CreateStackResponse.GetData() + if !fctl.GetBool(cmd, nowaitFlag) { spinner, err := pterm.DefaultSpinner.Start("Waiting services availability") if err != nil { return nil, err } - stack, err = waitStackReady(cmd, store.MembershipClient, response.Data.OrganizationId, response.Data.Id) + stack, err = waitStackReady(cmd, apiClient, restoredStackData.GetOrganizationID(), restoredStackData.GetID()) if err != nil { return nil, err } @@ -97,10 +123,18 @@ func (c *StackRestoreController) Run(cmd *cobra.Command, args []string) (fctl.Re c.store.Stack = stack } else { - c.store.Stack = response.Data + c.store.Stack = restoredStackData } - stackClient, err := fctl.NewStackClient(cmd, store.Config, response.Data) + stackClient, err := fctl.NewStackClient( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + restoredStackData.GetOrganizationID(), + restoredStackData.GetID(), + ) if err != nil { return nil, err } @@ -115,11 +149,11 @@ func (c *StackRestoreController) Run(cmd *cobra.Command, args []string) (fctl.Re } c.store.Versions = versions.GetVersionsResponse - c.config = store.Config + c.config = *cfg return c, nil } -func (c *StackRestoreController) Render(cmd *cobra.Command, args []string) error { - return internal.PrintStackInformation(cmd.OutOrStdout(), fctl.GetCurrentProfile(cmd, c.config), c.store.Stack, c.store.Versions) +func (c *StackRestoreController) Render(cmd *cobra.Command, _ []string) error { + return internal.PrintStackInformation(cmd.OutOrStdout(), c.store.Stack, c.store.Versions) } diff --git a/cmd/stack/root.go b/cmd/stack/root.go index 9f7e037f..c87ec2d3 100644 --- a/cmd/stack/root.go +++ b/cmd/stack/root.go @@ -27,8 +27,5 @@ func NewCommand() *cobra.Command { users.NewCommand(), modules.NewCommand(), ), - fctl.WithPersistentPreRunE(func(cmd *cobra.Command, args []string) error { - return fctl.NewMembershipOrganizationStore(cmd) - }), ) } diff --git a/cmd/stack/show.go b/cmd/stack/show.go index 4ae98d62..d8b7257c 100644 --- a/cmd/stack/show.go +++ b/cmd/stack/show.go @@ -1,36 +1,37 @@ package stack import ( + "errors" "fmt" "net/http" - "github.com/pkg/errors" "github.com/spf13/cobra" "github.com/formancehq/formance-sdk-go/v3/pkg/models/shared" "github.com/formancehq/fctl/cmd/stack/internal" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) var errStackNotFound = errors.New("stack not found") type StackShowStore struct { - Stack *membershipclient.Stack `json:"stack"` + Stack *components.Stack `json:"stack"` Versions *shared.GetVersionsResponse `json:"versions"` } type StackShowController struct { store *StackShowStore - config *fctl.Config + config fctl.Config } var _ fctl.Controller[*StackShowStore] = (*StackShowController)(nil) func NewDefaultStackShowStore() *StackShowStore { return &StackShowStore{ - Stack: &membershipclient.Stack{}, + Stack: &components.Stack{}, } } @@ -59,32 +60,54 @@ func (c *StackShowController) GetStore() *StackShowStore { func (c *StackShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { var stackNameFlag = "name" - var stack *membershipclient.Stack + var stack *components.Stack - store := fctl.GetOrganizationStore(cmd) + cfg, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } if len(args) == 1 { if fctl.GetString(cmd, stackNameFlag) != "" { return nil, errors.New("need either an id of a name specified using --name flag") } - stackResponse, httpResponse, err := store.Client().GetStack(cmd.Context(), store.OrganizationId(), args[0]).Execute() + getRequest := operations.GetStackRequest{ + OrganizationID: organizationID, + StackID: args[0], + } + stackResponse, err := apiClient.GetStack(cmd.Context(), getRequest) if err != nil { - if httpResponse.StatusCode == http.StatusNotFound { + if stackResponse.GetHTTPMeta().Response.StatusCode == http.StatusNotFound { return nil, errStackNotFound } - return nil, errors.Wrap(err, "listing stacks") + return nil, fmt.Errorf("listing stacks: %w", err) + } + if stackResponse.CreateStackResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") } - stack = stackResponse.Data + stack = stackResponse.CreateStackResponse.GetData() } else { if fctl.GetString(cmd, stackNameFlag) == "" { return nil, errors.New("need either an id of a name specified using --name flag") } - stacksResponse, _, err := store.Client().ListStacks(cmd.Context(), store.OrganizationId()).Execute() + listRequest := operations.ListStacksRequest{ + OrganizationID: organizationID, + } + stacksResponse, err := apiClient.ListStacks(cmd.Context(), listRequest) if err != nil { - return nil, errors.Wrap(err, "listing stacks") + return nil, fmt.Errorf("listing stacks: %w", err) + } + if stacksResponse.ListStacksResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") } - for _, s := range stacksResponse.Data { - if s.Name == fctl.GetString(cmd, stackNameFlag) { - stack = &s + for _, s := range stacksResponse.ListStacksResponse.GetData() { + if s.GetName() == fctl.GetString(cmd, stackNameFlag) { + stackData := s + stack = &stackData break } } @@ -95,15 +118,23 @@ func (c *StackShowController) Run(cmd *cobra.Command, args []string) (fctl.Rende } c.store.Stack = stack - c.config = store.Config + c.config = *cfg // the stack is not active, we can't get the running versions // Maybe add something in the process with sync status and store it in membership - if stack.State != "ACTIVE" { + if stack.GetStatus() != "ACTIVE" { return c, nil } - stackClient, err := fctl.NewStackClient(cmd, store.Config, stack) + stackClient, err := fctl.NewStackClient( + cmd, + relyingParty, + fctl.NewPTermDialog(), + profileName, + *profile, + stack.GetOrganizationID(), + stack.GetID(), + ) if err != nil { return nil, err } @@ -125,5 +156,5 @@ func (c *StackShowController) Run(cmd *cobra.Command, args []string) (fctl.Rende } func (c *StackShowController) Render(cmd *cobra.Command, args []string) error { - return internal.PrintStackInformation(cmd.OutOrStdout(), fctl.GetCurrentProfile(cmd, c.config), c.store.Stack, c.store.Versions) + return internal.PrintStackInformation(cmd.OutOrStdout(), c.store.Stack, c.store.Versions) } diff --git a/cmd/stack/update.go b/cmd/stack/update.go index 32883e3a..fffccb2f 100644 --- a/cmd/stack/update.go +++ b/cmd/stack/update.go @@ -1,13 +1,14 @@ package stack import ( - "github.com/pkg/errors" - "github.com/spf13/cobra" + "errors" + "fmt" - "github.com/formancehq/go-libs/pointer" + "github.com/spf13/cobra" "github.com/formancehq/fctl/cmd/stack/internal" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -15,24 +16,24 @@ const ( nameFlag = "name" ) -type StackUpdateStore struct { - Stack *membershipclient.Stack +type UpdateStore struct { + Stack *components.Stack } -type StackUpdateController struct { - store *StackUpdateStore - profile *fctl.Profile +type UpdateController struct { + store *UpdateStore + profile fctl.Profile } -var _ fctl.Controller[*StackUpdateStore] = (*StackUpdateController)(nil) +var _ fctl.Controller[*UpdateStore] = (*UpdateController)(nil) -func NewDefaultStackUpdateStore() *StackUpdateStore { - return &StackUpdateStore{ - Stack: &membershipclient.Stack{}, +func NewDefaultStackUpdateStore() *UpdateStore { + return &UpdateStore{ + Stack: &components.Stack{}, } } -func NewStackUpdateController() *StackUpdateController { - return &StackUpdateController{ +func NewStackUpdateController() *UpdateController { + return &UpdateController{ store: NewDefaultStackUpdateStore(), } } @@ -42,59 +43,75 @@ func NewUpdateCommand() *cobra.Command { fctl.WithShortDescription("Update a created stack, name, or metadata"), fctl.WithArgs(cobra.ExactArgs(1)), fctl.WithValidArgsFunction(fctl.StackCompletion), - fctl.WithPreRunE(func(cmd *cobra.Command, args []string) error { - return fctl.CheckMembershipVersion("v0.27.1")(cmd, args) - - }), - fctl.WithBoolFlag(unprotectFlag, false, "Unprotect stacks (no confirmation on write commands)"), fctl.WithStringFlag(nameFlag, "", "Name of the stack"), fctl.WithController(NewStackUpdateController()), ) } -func (c *StackUpdateController) GetStore() *StackUpdateStore { +func (c *UpdateController) GetStore() *UpdateStore { return c.store } -func (c *StackUpdateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetOrganizationStore(cmd) - c.profile = store.Config.GetProfile(fctl.GetCurrentProfileName(cmd, store.Config)) +func (c *UpdateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } - protected := !fctl.GetBool(cmd, unprotectFlag) - metadata := map[string]string{ - fctl.ProtectedStackMetadata: fctl.BoolPointerToString(&protected), + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err } - stack, res, err := store.Client().GetStack(cmd.Context(), store.OrganizationId(), args[0]).Execute() + c.profile = *profile + + getRequest := operations.GetStackRequest{ + OrganizationID: organizationID, + StackID: args[0], + } + stackResponse, err := apiClient.GetStack(cmd.Context(), getRequest) if err != nil { - return nil, errors.Wrap(err, "retrieving stack") + return nil, fmt.Errorf("retrieving stack: %w", err) } - if res.StatusCode > 300 { + if stackResponse.GetHTTPMeta().Response.StatusCode > 300 { return nil, errors.New("stack not found") } + if stackResponse.CreateStackResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + stackData := stackResponse.CreateStackResponse.GetData() + name := fctl.GetString(cmd, nameFlag) if name == "" { - name = stack.Data.Name + name = stackData.GetName() } - req := membershipclient.UpdateStackRequest{ - Name: name, - Metadata: pointer.For(metadata), + updateData := components.StackData{ + Name: name, } - stackResponse, _, err := store.Client(). - UpdateStack(cmd.Context(), store.OrganizationId(), args[0]). - UpdateStackRequest(req). - Execute() + updateRequest := operations.UpdateStackRequest{ + OrganizationID: organizationID, + StackID: args[0], + Body: &updateData, + } + + updatedStackResponse, err := apiClient.UpdateStack(cmd.Context(), updateRequest) if err != nil { - return nil, errors.Wrap(err, "updating stack") + return nil, fmt.Errorf("updating stack: %w", err) + } + + if updatedStackResponse.CreateStackResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") } - c.store.Stack = stackResponse.Data + c.store.Stack = updatedStackResponse.CreateStackResponse.GetData() return c, nil } -func (c *StackUpdateController) Render(cmd *cobra.Command, args []string) error { - return internal.PrintStackInformation(cmd.OutOrStdout(), c.profile, c.store.Stack, nil) +func (c *UpdateController) Render(cmd *cobra.Command, _ []string) error { + return internal.PrintStackInformation(cmd.OutOrStdout(), c.store.Stack, nil) } diff --git a/cmd/stack/upgrade.go b/cmd/stack/upgrade.go index 4e82af90..43bc5a6d 100644 --- a/cmd/stack/upgrade.go +++ b/cmd/stack/upgrade.go @@ -2,32 +2,33 @@ package stack import ( "context" + "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" "golang.org/x/mod/semver" - "github.com/formancehq/go-libs/pointer" + "github.com/formancehq/go-libs/v3/pointer" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) type UpgradeStore struct { - Stack *membershipclient.Stack + Stack *components.Stack } type UpgradeController struct { - store *UpgradeStore - profile *fctl.Profile + store *UpgradeStore } var _ fctl.Controller[*UpgradeStore] = (*UpgradeController)(nil) func NewDefaultUpgradeStore() *UpgradeStore { return &UpgradeStore{ - Stack: &membershipclient.Stack{}, + Stack: &components.Stack{}, } } func NewUpgradeController() *UpgradeController { @@ -42,9 +43,6 @@ func NewUpgradeCommand() *cobra.Command { fctl.WithBoolFlag(nowaitFlag, false, "Wait stack availability"), fctl.WithArgs(cobra.RangeArgs(1, 2)), fctl.WithValidArgsFunction(fctl.StackCompletion), - fctl.WithPreRunE(func(cmd *cobra.Command, args []string) error { - return fctl.CheckMembershipVersion("v0.27.1")(cmd, args) - }), fctl.WithController(NewUpgradeController()), ) } @@ -53,29 +51,43 @@ func (c *UpgradeController) GetStore() *UpgradeStore { } func (c *UpgradeController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetOrganizationStore(cmd) - c.profile = store.Config.GetProfile(fctl.GetCurrentProfileName(cmd, store.Config)) - organization, err := fctl.ResolveOrganizationID(cmd, store.Config, store.Client()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) if err != nil { return nil, err } - stack, res, err := store.Client().GetStack(cmd.Context(), organization, args[0]).Execute() + organizationID, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { - return nil, errors.Wrap(err, "retrieving stack") + return nil, err } - if res.StatusCode > 300 { - return nil, err + getRequest := operations.GetStackRequest{ + OrganizationID: organizationID, + StackID: args[0], + } + + stackResponse, err := apiClient.GetStack(cmd.Context(), getRequest) + if err != nil { + return nil, fmt.Errorf("retrieving stack: %w", err) } - req := membershipclient.StackVersion{ + if stackResponse.GetHTTPMeta().Response.StatusCode > 300 { + return nil, fmt.Errorf("unexpected status code: %d", stackResponse.GetHTTPMeta().Response.StatusCode) + } + + if stackResponse.CreateStackResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + stackData := stackResponse.CreateStackResponse.GetData() + + req := components.StackVersion{ Version: nil, } specifiedVersion := fctl.GetString(cmd, versionFlag) if specifiedVersion == "" { - upgradeOpts, err := retrieveUpgradableVersion(cmd.Context(), organization, *stack.Data, store.Client()) + upgradeOpts, err := retrieveUpgradableVersion(cmd.Context(), organizationID, *stackData, apiClient) if err != nil { return nil, err } @@ -88,8 +100,13 @@ func (c *UpgradeController) Run(cmd *cobra.Command, args []string) (fctl.Rendera specifiedVersion = selectedOption } - if specifiedVersion != *stack.Data.Version { - if !fctl.CheckStackApprobation(cmd, stack.Data, "Disclaimer: You are about to migrate the stack '%s' from '%s' to '%s'. It might take some time to fully migrate", stack.Data.Name, *stack.Data.Version, specifiedVersion) { + currentVersion := stackData.GetVersion() + if currentVersion == nil { + return nil, fmt.Errorf("stack has no version") + } + + if specifiedVersion != *currentVersion { + if !fctl.CheckStackApprobation(cmd, "Disclaimer: You are about to migrate the stack '%s' from '%s' to '%s'. It might take some time to fully migrate", stackData.GetName(), *currentVersion, specifiedVersion) { return nil, fctl.ErrMissingApproval } } else { @@ -98,15 +115,19 @@ func (c *UpgradeController) Run(cmd *cobra.Command, args []string) (fctl.Rendera } req.Version = pointer.For(specifiedVersion) - res, err = store.Client(). - UpgradeStack(cmd.Context(), organization, args[0]).StackVersion(req). - Execute() + upgradeRequest := operations.UpgradeStackRequest{ + OrganizationID: organizationID, + StackID: args[0], + Body: &req, + } + + upgradeResponse, err := apiClient.UpgradeStack(cmd.Context(), upgradeRequest) if err != nil { - return nil, errors.Wrap(err, "upgrading stack") + return nil, fmt.Errorf("upgrading stack: %w", err) } - if res.StatusCode > 300 { - return nil, err + if upgradeResponse.GetHTTPMeta().Response.StatusCode > 300 { + return nil, fmt.Errorf("unexpected status code: %d", upgradeResponse.GetHTTPMeta().Response.StatusCode) } if !fctl.GetBool(cmd, nowaitFlag) { @@ -115,11 +136,11 @@ func (c *UpgradeController) Run(cmd *cobra.Command, args []string) (fctl.Rendera return nil, err } - stack, err := waitStackReady(cmd, store.MembershipClient, stack.Data.OrganizationId, stack.Data.Id) + readyStack, err := waitStackReady(cmd, apiClient, stackData.GetOrganizationID(), stackData.GetID()) if err != nil { return nil, err } - c.store.Stack = stack + c.store.Stack = readyStack if err := spinner.Stop(); err != nil { return nil, err @@ -134,19 +155,34 @@ func (c *UpgradeController) Render(cmd *cobra.Command, args []string) error { return nil } -func retrieveUpgradableVersion(ctx context.Context, organization string, stack membershipclient.Stack, apiClient *membershipclient.DefaultAPIService) ([]string, error) { - availableVersions, httpResponse, err := apiClient.GetRegionVersions(ctx, organization, stack.RegionID).Execute() - if httpResponse == nil { +func retrieveUpgradableVersion(ctx context.Context, organization string, stack components.Stack, apiClient *membershipclient.SDK) ([]string, error) { + getVersionsRequest := operations.GetRegionVersionsRequest{ + OrganizationID: organization, + RegionID: stack.GetRegionID(), + } + + availableVersionsResponse, err := apiClient.GetRegionVersions(ctx, getVersionsRequest) + if err != nil { return nil, err } + if availableVersionsResponse.GetRegionVersionsResponse == nil { + return nil, fmt.Errorf("unexpected response: no versions data") + } + + currentVersion := stack.GetVersion() + if currentVersion == nil { + return nil, fmt.Errorf("stack has no version") + } + var upgradeOptions []string - for _, version := range availableVersions.Data { - if version.Name == *stack.Version { + for _, version := range availableVersionsResponse.GetRegionVersionsResponse.GetData() { + versionName := version.GetName() + if versionName == *currentVersion { continue } - if !semver.IsValid(version.Name) || semver.Compare(version.Name, *stack.Version) >= 1 { - upgradeOptions = append(upgradeOptions, version.Name) + if !semver.IsValid(versionName) || semver.Compare(versionName, *currentVersion) >= 1 { + upgradeOptions = append(upgradeOptions, versionName) } } return upgradeOptions, nil diff --git a/cmd/stack/users/link.go b/cmd/stack/users/link.go index add1169f..9e4851c0 100644 --- a/cmd/stack/users/link.go +++ b/cmd/stack/users/link.go @@ -6,7 +6,8 @@ import ( "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) @@ -33,7 +34,7 @@ func NewLinkController() *LinkController { func NewLinkCommand() *cobra.Command { return fctl.NewCommand("link ", - fctl.WithStringFlag("role", "", "Roles: (ADMIN, GUEST)"), + fctl.WithIntFlag("policy-id", 0, "Policy id"), fctl.WithShortDescription("Link stack user with properties"), fctl.WithArgs(cobra.ExactArgs(1)), fctl.WithValidArgsFunction(cobra.NoFileCompletions), @@ -46,26 +47,43 @@ func (c *LinkController) GetStore() *LinkStore { } func (c *LinkController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStackStore(cmd.Context()) - - role := membershipclient.Role(fctl.GetString(cmd, "role")) - req := membershipclient.UpdateStackUserRequest{} - if role != "" { - req.Role = role - } else { - return nil, fmt.Errorf("role is required") + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, stackID, err := fctl.ResolveStackID(cmd, *profile) + if err != nil { + return nil, err + } + + apiClient, err := fctl.NewMembershipClientForOrganization(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile, organizationID) + if err != nil { + return nil, err + } + + policyID := fctl.GetInt(cmd, "policy-id") + if policyID == 0 { + return nil, fmt.Errorf("policy id is required") } - _, err := store.Client(). - UpsertStackUserAccess(cmd.Context(), store.OrganizationId(), store.StackId(), args[0]). - UpdateStackUserRequest(req).Execute() + _, err = apiClient. + UpsertStackUserAccess(cmd.Context(), operations.UpsertStackUserAccessRequest{ + OrganizationID: organizationID, + StackID: stackID, + UserID: args[0], + Body: &components.UpdateStackUserRequest{ + PolicyID: int64(policyID), + }, + }) if err != nil { return nil, err } - c.store.OrganizationID = store.OrganizationId() - c.store.StackID = args[0] - c.store.UserID = args[1] + c.store.OrganizationID = organizationID + c.store.StackID = stackID + c.store.UserID = args[0] return c, nil } diff --git a/cmd/stack/users/list.go b/cmd/stack/users/list.go index 32d4a9b7..5a13d9a4 100644 --- a/cmd/stack/users/list.go +++ b/cmd/stack/users/list.go @@ -1,15 +1,18 @@ package users import ( + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) type ListStore struct { - list []membershipclient.StackUserAccess + list []components.StackUserAccessResponseData } type ListController struct { store *ListStore @@ -19,7 +22,7 @@ var _ fctl.Controller[*ListStore] = (*ListController)(nil) func NewDefaultListStore() *ListStore { return &ListStore{ - list: []membershipclient.StackUserAccess{}, + list: []components.StackUserAccessResponseData{}, } } @@ -45,29 +48,47 @@ func (c *ListController) GetStore() *ListStore { func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } - listStackUsersAccesses, response, err := store.Client().ListStackUsersAccesses(cmd.Context(), store.OrganizationId(), store.StackId()).Execute() + organizationID, stackID, err := fctl.ResolveStackID(cmd, *profile) if err != nil { return nil, err } - if response.StatusCode > 300 { + apiClient, err := fctl.NewMembershipClientForOrganization(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile, organizationID) + if err != nil { return nil, err } - c.store.list = append(c.store.list, listStackUsersAccesses.Data...) + request := operations.ListStackUsersAccessesRequest{ + OrganizationID: organizationID, + StackID: stackID, + } + + response, err := apiClient.ListStackUsersAccesses(cmd.Context(), request) + if err != nil { + return nil, err + } + + if response.StackUserAccessResponse == nil { + return nil, fmt.Errorf("unexpected response: no data") + } + + c.store.list = response.StackUserAccessResponse.GetData() return c, nil } -func (c *ListController) Render(cmd *cobra.Command, args []string) error { - stackUserAccessMap := fctl.Map(c.store.list, func(o membershipclient.StackUserAccess) []string { +func (c *ListController) Render(cmd *cobra.Command, _ []string) error { + stackUserAccessMap := fctl.Map(c.store.list, func(o components.StackUserAccessResponseData) []string { return []string{ - o.StackId, - o.UserId, - o.Email, - string(o.Role), + o.GetStackID(), + o.GetUserID(), + o.GetEmail(), + fmt.Sprintf("%d", o.GetPolicyID()), } }) diff --git a/cmd/stack/users/root.go b/cmd/stack/users/root.go index 14d06dab..afab9bd1 100644 --- a/cmd/stack/users/root.go +++ b/cmd/stack/users/root.go @@ -10,13 +10,6 @@ func NewCommand() *cobra.Command { return fctl.NewStackCommand("users", fctl.WithAliases("u", "user"), fctl.WithShortDescription("Stack users management within an organization"), - fctl.WithPersistentPreRunE(func(cmd *cobra.Command, args []string) error { - if err := fctl.NewMembershipStackStore(cmd); err != nil { - return err - } - - return nil - }), fctl.WithChildCommands( NewLinkCommand(), NewListCommand(), diff --git a/cmd/stack/users/unlink.go b/cmd/stack/users/unlink.go index 4d469e81..e64241fc 100644 --- a/cmd/stack/users/unlink.go +++ b/cmd/stack/users/unlink.go @@ -1,16 +1,19 @@ package users import ( + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" fctl "github.com/formancehq/fctl/pkg" ) type UnlinkStore struct { - Stack *membershipclient.Stack `json:"stack"` - Status string `json:"status"` + Stack *components.Stack `json:"stack"` + Status string `json:"status"` } type UnlinkController struct { store *UnlinkStore @@ -20,7 +23,7 @@ var _ fctl.Controller[*UnlinkStore] = (*UnlinkController)(nil) func NewDefaultUnlinkStore() *UnlinkStore { return &UnlinkStore{ - Stack: &membershipclient.Stack{}, + Stack: &components.Stack{}, Status: "", } } @@ -44,17 +47,37 @@ func (c *UnlinkController) GetStore() *UnlinkStore { } func (c *UnlinkController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStackStore(cmd.Context()) - res, err := store.Client().DeleteStackUserAccess(cmd.Context(), store.OrganizationId(), store.StackId(), args[0]).Execute() + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + organizationID, stackID, err := fctl.ResolveStackID(cmd, *profile) + if err != nil { + return nil, err + } + + apiClient, err := fctl.NewMembershipClientForOrganization(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile, organizationID) if err != nil { return nil, err } - if res.StatusCode > 300 { + request := operations.DeleteStackUserAccessRequest{ + OrganizationID: organizationID, + StackID: stackID, + UserID: args[0], + } + + response, err := apiClient.DeleteStackUserAccess(cmd.Context(), request) + if err != nil { return nil, err } + if response.Error != nil { + return nil, fmt.Errorf("error deleting stack user access: %s", response.Error.GetErrorCode()) + } + return c, nil } diff --git a/cmd/ui/ui.go b/cmd/ui/ui.go index c55e5727..8e31b48e 100644 --- a/cmd/ui/ui.go +++ b/cmd/ui/ui.go @@ -63,13 +63,23 @@ func (c *UiController) GetStore() *UiStruct { } func (c *UiController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetMembershipStore(cmd.Context()) - serverInfo, err := fctl.MembershipServerInfo(cmd.Context(), store.Client()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + _, apiClient, err := fctl.NewMembershipClientForOrganizationFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) if err != nil { return nil, err } - if v := serverInfo.ConsoleURL; v != nil { + serverInfo, err := fctl.MembershipServerInfo(cmd.Context(), apiClient) + if err != nil { + return nil, err + } + + if v := serverInfo.GetConsoleURL(); v != nil { c.store.UIUrl = *v } @@ -81,7 +91,6 @@ func (c *UiController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, } func (c *UiController) Render(cmd *cobra.Command, args []string) error { - fmt.Println("Opening url: ", c.store.UIUrl) return nil @@ -93,8 +102,5 @@ func NewCommand() *cobra.Command { fctl.WithArgs(cobra.ExactArgs(0)), fctl.WithValidArgsFunction(cobra.NoFileCompletions), fctl.WithController[*UiStruct](NewUiController()), - fctl.WithPersistentPreRunE(func(cmd *cobra.Command, args []string) error { - return fctl.NewMembershipStore(cmd) - }), ) } diff --git a/cmd/version/version.go b/cmd/version/version.go index b57111a4..27927f15 100644 --- a/cmd/version/version.go +++ b/cmd/version/version.go @@ -13,27 +13,27 @@ var ( BuildDate = "-" ) -type VersionStore struct { +type Store struct { Version string `json:"version"` BuildDate string `json:"buildDate"` Commit string `json:"commit"` } -type VersionController struct { - store *VersionStore +type Controller struct { + store *Store } -var _ fctl.Controller[*VersionStore] = (*VersionController)(nil) +var _ fctl.Controller[*Store] = (*Controller)(nil) -func NewDefaultVersionStore() *VersionStore { - return &VersionStore{ +func NewDefaultVersionStore() *Store { + return &Store{ Version: Version, BuildDate: BuildDate, Commit: Commit, } } -func NewVersionController() *VersionController { - return &VersionController{ +func NewVersionController() *Controller { + return &Controller{ store: NewDefaultVersionStore(), } } @@ -43,20 +43,20 @@ func NewCommand() *cobra.Command { fctl.WithShortDescription("Get version"), fctl.WithArgs(cobra.ExactArgs(0)), fctl.WithValidArgsFunction(cobra.NoFileCompletions), - fctl.WithController[*VersionStore](NewVersionController()), + fctl.WithController[*Store](NewVersionController()), ) } -func (c *VersionController) GetStore() *VersionStore { +func (c *Controller) GetStore() *Store { return c.store } -func (c *VersionController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { +func (c *Controller) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { return c, nil } // TODO: This need to use the ui.NewListModel -func (c *VersionController) Render(cmd *cobra.Command, args []string) error { +func (c *Controller) Render(cmd *cobra.Command, args []string) error { tableData := pterm.TableData{} tableData = append(tableData, []string{pterm.LightCyan("Version"), c.store.Version}) tableData = append(tableData, []string{pterm.LightCyan("Date"), c.store.BuildDate}) diff --git a/cmd/wallets/balances/create.go b/cmd/wallets/balances/create.go index df1acdb7..d861d5d0 100644 --- a/cmd/wallets/balances/create.go +++ b/cmd/wallets/balances/create.go @@ -1,9 +1,9 @@ package balances import ( + "fmt" "math/big" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -57,9 +57,18 @@ func (c *CreateController) GetStore() *CreateStore { } func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - walletID, err := internal.RequireWalletID(cmd, store.Client()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + walletID, err := internal.RequireWalletID(cmd, stackClient) if err != nil { return nil, err } @@ -83,9 +92,9 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab Priority: priority, }, } - response, err := store.Client().Wallets.V1.CreateBalance(cmd.Context(), request) + response, err := stackClient.Wallets.V1.CreateBalance(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "creating balance") + return nil, fmt.Errorf("creating balance: %w", err) } c.store.BalanceName = response.CreateBalanceResponse.Data.Name diff --git a/cmd/wallets/balances/list.go b/cmd/wallets/balances/list.go index 1501f820..24f2ae61 100644 --- a/cmd/wallets/balances/list.go +++ b/cmd/wallets/balances/list.go @@ -3,7 +3,6 @@ package balances import ( "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -50,9 +49,18 @@ func (c *ListController) GetStore() *ListStore { } func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - walletID, err := internal.RequireWalletID(cmd, store.Client()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + walletID, err := internal.RequireWalletID(cmd, stackClient) if err != nil { return nil, err } @@ -60,9 +68,9 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable request := operations.ListBalancesRequest{ ID: walletID, } - response, err := store.Client().Wallets.V1.ListBalances(cmd.Context(), request) + response, err := stackClient.Wallets.V1.ListBalances(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "listing balance") + return nil, fmt.Errorf("listing balance: %w", err) } if response.StatusCode >= 300 { diff --git a/cmd/wallets/balances/show.go b/cmd/wallets/balances/show.go index eea9334c..70cd941d 100644 --- a/cmd/wallets/balances/show.go +++ b/cmd/wallets/balances/show.go @@ -1,7 +1,8 @@ package balances import ( - "github.com/pkg/errors" + "fmt" + "github.com/spf13/cobra" "github.com/formancehq/formance-sdk-go/v3/pkg/models/operations" @@ -49,9 +50,17 @@ func (c *ShowController) GetStore() *ShowStore { func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } - walletID, err := internal.RequireWalletID(cmd, store.Client()) + walletID, err := internal.RequireWalletID(cmd, stackClient) if err != nil { return nil, err } @@ -60,9 +69,9 @@ func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable ID: walletID, BalanceName: args[0], } - response, err := store.Client().Wallets.V1.GetBalance(cmd.Context(), request) + response, err := stackClient.Wallets.V1.GetBalance(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "getting balance") + return nil, fmt.Errorf("getting balance: %w", err) } c.store.Balance = response.GetBalanceResponse.Data diff --git a/cmd/wallets/create.go b/cmd/wallets/create.go index 00aa4cd5..40569dd9 100644 --- a/cmd/wallets/create.go +++ b/cmd/wallets/create.go @@ -1,7 +1,8 @@ package wallets import ( - "github.com/pkg/errors" + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -53,9 +54,18 @@ func (c *CreateController) GetStore() *CreateStore { } func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to create a wallet") { + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + if !fctl.CheckStackApprobation(cmd, "You are about to create a wallet") { return nil, fctl.ErrMissingApproval } @@ -71,9 +81,9 @@ func (c *CreateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab }, IdempotencyKey: fctl.Ptr(fctl.GetString(cmd, c.ikFlag)), } - response, err := store.Client().Wallets.V1.CreateWallet(cmd.Context(), request) + response, err := stackClient.Wallets.V1.CreateWallet(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "creating wallet") + return nil, fmt.Errorf("creating wallet: %w", err) } c.store.WalletID = response.CreateWalletResponse.Data.ID diff --git a/cmd/wallets/credit.go b/cmd/wallets/credit.go index 3c722fee..5e9b5b7c 100644 --- a/cmd/wallets/credit.go +++ b/cmd/wallets/credit.go @@ -1,10 +1,10 @@ package wallets import ( + "errors" "fmt" "math/big" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -65,14 +65,23 @@ func (c *CreditWalletController) GetStore() *CreditWalletStore { } func (c *CreditWalletController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to credit a wallets") { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + if !fctl.CheckStackApprobation(cmd, "You are about to credit a wallets") { return nil, fctl.ErrMissingApproval } amountStr := args[0] asset := args[1] - walletID, err := internal.RetrieveWalletID(cmd, store.Client()) + walletID, err := internal.RetrieveWalletID(cmd, stackClient) if err != nil { return nil, err } @@ -93,7 +102,7 @@ func (c *CreditWalletController) Run(cmd *cobra.Command, args []string) (fctl.Re sources := make([]shared.Subject, 0) for _, sourceStr := range fctl.GetStringSlice(cmd, c.sourceFlag) { - source, err := internal.ParseSubject(sourceStr, cmd, store.Client()) + source, err := internal.ParseSubject(sourceStr, cmd, stackClient) if err != nil { return nil, err } @@ -113,9 +122,9 @@ func (c *CreditWalletController) Run(cmd *cobra.Command, args []string) (fctl.Re Balance: formance.String(fctl.GetString(cmd, c.balanceFlag)), }, } - _, err = store.Client().Wallets.V1.CreditWallet(cmd.Context(), request) + _, err = stackClient.Wallets.V1.CreditWallet(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "crediting wallet") + return nil, fmt.Errorf("crediting wallet: %w", err) } c.store.Success = true diff --git a/cmd/wallets/debit.go b/cmd/wallets/debit.go index 78ebc6b9..bf1bb43e 100644 --- a/cmd/wallets/debit.go +++ b/cmd/wallets/debit.go @@ -4,7 +4,6 @@ import ( "fmt" "math/big" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -76,8 +75,18 @@ func (c *DebitWalletController) GetStore() *DebitWalletStore { } func (c *DebitWalletController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to debit a wallets") { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + if !fctl.CheckStackApprobation(cmd, "You are about to debit a wallets") { return nil, fctl.ErrMissingApproval } @@ -90,7 +99,7 @@ func (c *DebitWalletController) Run(cmd *cobra.Command, args []string) (fctl.Ren amountStr := args[0] asset := args[1] - walletID, err := internal.RequireWalletID(cmd, store.Client()) + walletID, err := internal.RequireWalletID(cmd, stackClient) if err != nil { return nil, err } @@ -104,13 +113,13 @@ func (c *DebitWalletController) Run(cmd *cobra.Command, args []string) (fctl.Ren var destination *shared.Subject if destinationStr := fctl.GetString(cmd, c.destinationFlag); destinationStr != "" { - destination, err = internal.ParseSubject(destinationStr, cmd, store.Client()) + destination, err = internal.ParseSubject(destinationStr, cmd, stackClient) if err != nil { return nil, err } } - response, err := store.Client().Wallets.V1.DebitWallet(cmd.Context(), operations.DebitWalletRequest{ + response, err := stackClient.Wallets.V1.DebitWallet(cmd.Context(), operations.DebitWalletRequest{ DebitWalletRequest: &shared.DebitWalletRequest{ Amount: shared.Monetary{ Asset: asset, @@ -125,7 +134,7 @@ func (c *DebitWalletController) Run(cmd *cobra.Command, args []string) (fctl.Ren ID: walletID, }) if err != nil { - return nil, errors.Wrap(err, "debiting wallet") + return nil, fmt.Errorf("debiting wallet: %w", err) } if response.DebitWalletResponse != nil { diff --git a/cmd/wallets/holds/confirm.go b/cmd/wallets/holds/confirm.go index 95c4a6d8..8749bf08 100644 --- a/cmd/wallets/holds/confirm.go +++ b/cmd/wallets/holds/confirm.go @@ -1,9 +1,9 @@ package holds import ( + "fmt" "math/big" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -58,7 +58,16 @@ func (c *ConfirmController) GetStore() *ConfirmStore { } func (c *ConfirmController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } final := fctl.GetBool(cmd, c.finalFlag) amount := int64(fctl.GetInt(cmd, c.amountFlag)) @@ -70,9 +79,9 @@ func (c *ConfirmController) Run(cmd *cobra.Command, args []string) (fctl.Rendera Final: &final, }, } - _, err := store.Client().Wallets.V1.ConfirmHold(cmd.Context(), request) + _, err = stackClient.Wallets.V1.ConfirmHold(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "confirming hold") + return nil, fmt.Errorf("confirming hold: %w", err) } c.store.Success = true //Todo: check status code diff --git a/cmd/wallets/holds/list.go b/cmd/wallets/holds/list.go index 0052e7f6..49e1327e 100644 --- a/cmd/wallets/holds/list.go +++ b/cmd/wallets/holds/list.go @@ -1,7 +1,8 @@ package holds import ( - "github.com/pkg/errors" + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -53,9 +54,17 @@ func (c *ListController) GetStore() *ListStore { func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } - walletID, err := internal.RetrieveWalletID(cmd, store.Client()) + walletID, err := internal.RetrieveWalletID(cmd, stackClient) if err != nil { return nil, err } @@ -69,9 +78,9 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable WalletID: &walletID, Metadata: metadata, } - response, err := store.Client().Wallets.V1.GetHolds(cmd.Context(), request) + response, err := stackClient.Wallets.V1.GetHolds(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "getting holds") + return nil, fmt.Errorf("getting holds: %w", err) } c.store.Holds = response.GetHoldsResponse.Cursor.Data @@ -102,7 +111,7 @@ func (c *ListController) Render(cmd *cobra.Command, args []string) error { []string{"ID", "Wallet ID", "Description", "Metadata"}, ), ).Render(); err != nil { - return errors.Wrap(err, "rendering table") + return fmt.Errorf("rendering table: %w", err) } return nil diff --git a/cmd/wallets/holds/show.go b/cmd/wallets/holds/show.go index a82b5c29..3a8dc145 100644 --- a/cmd/wallets/holds/show.go +++ b/cmd/wallets/holds/show.go @@ -1,7 +1,8 @@ package holds import ( - "github.com/pkg/errors" + "fmt" + "github.com/spf13/cobra" "github.com/formancehq/formance-sdk-go/v3/pkg/models/operations" @@ -45,14 +46,23 @@ func (c *ShowController) GetStore() *ShowStore { } func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } request := operations.GetHoldRequest{ HoldID: args[0], } - response, err := store.Client().Wallets.V1.GetHold(cmd.Context(), request) + response, err := stackClient.Wallets.V1.GetHold(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "getting hold") + return nil, fmt.Errorf("getting hold: %w", err) } c.store.Hold = response.GetHoldResponse.Data diff --git a/cmd/wallets/holds/void.go b/cmd/wallets/holds/void.go index 59320c14..8880ad00 100644 --- a/cmd/wallets/holds/void.go +++ b/cmd/wallets/holds/void.go @@ -1,7 +1,8 @@ package holds import ( - "github.com/pkg/errors" + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -50,14 +51,22 @@ func (c *VoidController) GetStore() *VoidStore { func (c *VoidController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } request := operations.VoidHoldRequest{ IdempotencyKey: fctl.Ptr(fctl.GetString(cmd, c.ikFlag)), HoldID: args[0], } - _, err := store.Client().Wallets.V1.VoidHold(cmd.Context(), request) + _, err = stackClient.Wallets.V1.VoidHold(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "voiding hold") + return nil, fmt.Errorf("voiding hold: %w", err) } c.store.Success = true diff --git a/cmd/wallets/internal/command.go b/cmd/wallets/internal/command.go index 5c67f44f..afd3ac4e 100644 --- a/cmd/wallets/internal/command.go +++ b/cmd/wallets/internal/command.go @@ -1,9 +1,9 @@ package internal import ( + "errors" "fmt" - "github.com/pkg/errors" "github.com/spf13/cobra" formance "github.com/formancehq/formance-sdk-go/v3" @@ -35,7 +35,7 @@ func DiscoverWalletIDFromName(cmd *cobra.Command, client *formance.Formance, wal } wallets, err := client.Wallets.V1.ListWallets(cmd.Context(), request) if err != nil { - return "", errors.Wrap(err, "listing wallets to retrieve wallet by name") + return "", fmt.Errorf("listing wallets to retrieve wallet by name: %w", err) } if wallets.StatusCode >= 300 { diff --git a/cmd/wallets/internal/subject.go b/cmd/wallets/internal/subject.go index 5b2b08bb..4892b6e2 100644 --- a/cmd/wallets/internal/subject.go +++ b/cmd/wallets/internal/subject.go @@ -1,9 +1,9 @@ package internal import ( + "errors" "strings" - "github.com/pkg/errors" "github.com/spf13/cobra" formance "github.com/formancehq/formance-sdk-go/v3" diff --git a/cmd/wallets/list.go b/cmd/wallets/list.go index 1a9b8a24..43740cf4 100644 --- a/cmd/wallets/list.go +++ b/cmd/wallets/list.go @@ -3,7 +3,6 @@ package wallets import ( "fmt" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -52,18 +51,26 @@ func (c *ListController) GetStore() *ListStore { func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } metadata, err := fctl.ParseMetadata(fctl.GetStringSlice(cmd, c.metadataFlag)) if err != nil { return nil, err } - response, err := store.Client().Wallets.V1.ListWallets(cmd.Context(), operations.ListWalletsRequest{ + response, err := stackClient.Wallets.V1.ListWallets(cmd.Context(), operations.ListWalletsRequest{ Metadata: metadata, }) if err != nil { - return nil, errors.Wrap(err, "listing wallet") + return nil, fmt.Errorf("listing wallet: %w", err) } if response.StatusCode >= 300 { @@ -96,7 +103,7 @@ func (c *ListController) Render(cmd *cobra.Command, args []string) error { []string{"ID", "Name"}, ), ).Render(); err != nil { - return errors.Wrap(err, "rendering table") + return fmt.Errorf("rendering table: %w", err) } return nil } diff --git a/cmd/wallets/root.go b/cmd/wallets/root.go index 2d41c3f7..5e33de51 100644 --- a/cmd/wallets/root.go +++ b/cmd/wallets/root.go @@ -24,8 +24,5 @@ func NewCommand() *cobra.Command { holds.NewCommand(), balances.NewCommand(), ), - fctl.WithPersistentPreRunE(func(cmd *cobra.Command, args []string) error { - return fctl.NewStackStore(cmd) - }), ) } diff --git a/cmd/wallets/show.go b/cmd/wallets/show.go index 9bcca34e..3248196a 100644 --- a/cmd/wallets/show.go +++ b/cmd/wallets/show.go @@ -1,7 +1,9 @@ package wallets import ( - "github.com/pkg/errors" + "errors" + "fmt" + "github.com/spf13/cobra" "github.com/formancehq/formance-sdk-go/v3/pkg/models/operations" @@ -51,9 +53,17 @@ func (c *ShowController) GetStore() *ShowStore { func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } - walletID, err := internal.RetrieveWalletID(cmd, store.Client()) + walletID, err := internal.RetrieveWalletID(cmd, stackClient) if err != nil { return nil, err } @@ -61,11 +71,11 @@ func (c *ShowController) Run(cmd *cobra.Command, args []string) (fctl.Renderable return nil, errors.New("You need to specify wallet id using --id or --name flags") } - response, err := store.Client().Wallets.V1.GetWallet(cmd.Context(), operations.GetWalletRequest{ + response, err := stackClient.Wallets.V1.GetWallet(cmd.Context(), operations.GetWalletRequest{ ID: walletID, }) if err != nil { - return nil, errors.Wrap(err, "getting wallet") + return nil, fmt.Errorf("getting wallet: %w", err) } c.store.Wallet = response.ActivityGetWalletOutput.Data diff --git a/cmd/wallets/transactions/list.go b/cmd/wallets/transactions/list.go index fcbbc241..19a0b718 100644 --- a/cmd/wallets/transactions/list.go +++ b/cmd/wallets/transactions/list.go @@ -4,7 +4,6 @@ import ( "fmt" "time" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -52,8 +51,17 @@ func (c *ListController) GetStore() *ListStore { func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - walletID, err := internal.RetrieveWalletID(cmd, store.Client()) + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + walletID, err := internal.RetrieveWalletID(cmd, stackClient) if err != nil { return nil, err } @@ -61,9 +69,9 @@ func (c *ListController) Run(cmd *cobra.Command, args []string) (fctl.Renderable request := operations.GetTransactionsRequest{ WalletID: &walletID, } - response, err := store.Client().Wallets.V1.GetTransactions(cmd.Context(), request) + response, err := stackClient.Wallets.V1.GetTransactions(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "listing transactions") + return nil, fmt.Errorf("listing transactions: %w", err) } c.store.Transactions = response.GetTransactionsResponse.Cursor.Data diff --git a/cmd/wallets/update.go b/cmd/wallets/update.go index d4873b53..b5926584 100644 --- a/cmd/wallets/update.go +++ b/cmd/wallets/update.go @@ -1,7 +1,8 @@ package wallets import ( - "github.com/pkg/errors" + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -52,9 +53,18 @@ func (c *UpdateController) GetStore() *UpdateStore { } func (c *UpdateController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to update a wallets") { + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + if !fctl.CheckStackApprobation(cmd, "You are about to update a wallets") { return nil, fctl.ErrMissingApproval } @@ -63,14 +73,14 @@ func (c *UpdateController) Run(cmd *cobra.Command, args []string) (fctl.Renderab return nil, err } - _, err = store.Client().Wallets.V1.UpdateWallet(cmd.Context(), operations.UpdateWalletRequest{ + _, err = stackClient.Wallets.V1.UpdateWallet(cmd.Context(), operations.UpdateWalletRequest{ RequestBody: &operations.UpdateWalletRequestBody{ Metadata: metadata, }, ID: args[0], }) if err != nil { - return nil, errors.Wrap(err, "updating wallet") + return nil, fmt.Errorf("updating wallet: %w", err) } c.store.Success = true diff --git a/cmd/webhooks/activate.go b/cmd/webhooks/activate.go index 7068572f..ebf0aab7 100644 --- a/cmd/webhooks/activate.go +++ b/cmd/webhooks/activate.go @@ -1,7 +1,8 @@ package webhooks import ( - "github.com/pkg/errors" + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -32,8 +33,17 @@ func (c *ActivateWebhookController) GetStore() *ActivateWebhookStore { } func (c *ActivateWebhookController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are bout to activate a webhook") { + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + if !fctl.CheckStackApprobation(cmd, "You are about to activate a webhook") { return nil, fctl.ErrMissingApproval } @@ -41,9 +51,9 @@ func (c *ActivateWebhookController) Run(cmd *cobra.Command, args []string) (fctl ID: args[0], } - _, err := store.Client().Webhooks.V1.ActivateConfig(cmd.Context(), request) + _, err = stackClient.Webhooks.V1.ActivateConfig(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "activating config") + return nil, fmt.Errorf("activating config: %w", err) } return c, nil diff --git a/cmd/webhooks/create.go b/cmd/webhooks/create.go index 27059af9..51ef6599 100644 --- a/cmd/webhooks/create.go +++ b/cmd/webhooks/create.go @@ -1,9 +1,9 @@ package webhooks import ( + "fmt" "net/url" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -42,26 +42,35 @@ func (c *CreateWebhookController) GetStore() *CreateWebhookStore { } func (c *CreateWebhookController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to create a webhook") { + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + if !fctl.CheckStackApprobation(cmd, "You are about to create a webhook") { return nil, fctl.ErrMissingApproval } if _, err := url.Parse(args[0]); err != nil { - return nil, errors.Wrap(err, "invalid endpoint URL") + return nil, fmt.Errorf("invalid endpoint URL: %w", err) } secret := fctl.GetString(cmd, secretFlag) - response, err := store.Client().Webhooks.V1.InsertConfig(cmd.Context(), shared.ConfigUser{ + response, err := stackClient.Webhooks.V1.InsertConfig(cmd.Context(), shared.ConfigUser{ Endpoint: args[0], EventTypes: args[1:], Secret: &secret, }) if err != nil { - return nil, errors.Wrap(err, "creating config") + return nil, fmt.Errorf("creating config: %w", err) } c.store.Webhook = response.ConfigResponse.Data diff --git a/cmd/webhooks/deactivate.go b/cmd/webhooks/deactivate.go index 139d1194..92ac361d 100644 --- a/cmd/webhooks/deactivate.go +++ b/cmd/webhooks/deactivate.go @@ -1,7 +1,8 @@ package webhooks import ( - "github.com/pkg/errors" + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -36,18 +37,27 @@ func (c *DesactivateWebhookController) GetStore() *DesactivateWebhookStore { } func (c *DesactivateWebhookController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to deactivate a webhook") { + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + if !fctl.CheckStackApprobation(cmd, "You are about to deactivate a webhook") { return nil, fctl.ErrMissingApproval } request := operations.DeactivateConfigRequest{ ID: args[0], } - response, err := store.Client().Webhooks.V1.DeactivateConfig(cmd.Context(), request) + response, err := stackClient.Webhooks.V1.DeactivateConfig(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "deactivating config") + return nil, fmt.Errorf("deactivating config: %w", err) } c.store.Success = !response.ConfigResponse.Data.Active diff --git a/cmd/webhooks/delete.go b/cmd/webhooks/delete.go index 688a9ff3..f61005d1 100644 --- a/cmd/webhooks/delete.go +++ b/cmd/webhooks/delete.go @@ -1,7 +1,8 @@ package webhooks import ( - "github.com/pkg/errors" + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -17,8 +18,7 @@ type DeleteWebhookStore struct { } type DeleteWebhookController struct { - store *DeleteWebhookStore - config *fctl.Config + store *DeleteWebhookStore } var _ fctl.Controller[*DeleteWebhookStore] = (*DeleteWebhookController)(nil) @@ -31,8 +31,7 @@ func NewDefaultDeleteWebhookStore() *DeleteWebhookStore { func NewDeleteWebhookController() *DeleteWebhookController { return &DeleteWebhookController{ - store: NewDefaultDeleteWebhookStore(), - config: nil, + store: NewDefaultDeleteWebhookStore(), } } @@ -41,19 +40,27 @@ func (c *DeleteWebhookController) GetStore() *DeleteWebhookStore { } func (c *DeleteWebhookController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - c.config = store.Config - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to delete a webhook") { + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + if !fctl.CheckStackApprobation(cmd, "You are about to delete a webhook") { return nil, fctl.ErrMissingApproval } request := operations.DeleteConfigRequest{ ID: args[0], } - _, err := store.Client().Webhooks.V1.DeleteConfig(cmd.Context(), request) + _, err = stackClient.Webhooks.V1.DeleteConfig(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "deleting config") + return nil, fmt.Errorf("deleting config: %w", err) } c.store.Success = true @@ -68,7 +75,7 @@ func (c *DeleteWebhookController) Render(cmd *cobra.Command, args []string) erro } if c.store.ErrorResponse != nil { - pterm.Warning.WithShowLineNumber(false).Printfln(c.store.ErrorResponse.ErrorMessage) + pterm.Warning.WithShowLineNumber(false).Printfln("%s", c.store.ErrorResponse.ErrorMessage) return nil } diff --git a/cmd/webhooks/list.go b/cmd/webhooks/list.go index 2507d24a..57b955e3 100644 --- a/cmd/webhooks/list.go +++ b/cmd/webhooks/list.go @@ -1,10 +1,10 @@ package webhooks import ( + "fmt" "strings" "time" - "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -39,11 +39,20 @@ func (c *ListWebhookController) GetStore() *ListWebhookStore { } func (c *ListWebhookController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) + + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } request := operations.GetManyConfigsRequest{} - response, err := store.Client().Webhooks.V1.GetManyConfigs(cmd.Context(), request) + response, err := stackClient.Webhooks.V1.GetManyConfigs(cmd.Context(), request) if err != nil { - return nil, errors.Wrap(err, "listing all config") + return nil, fmt.Errorf("listing all config: %w", err) } c.store.Webhooks = response.ConfigsResponse.Cursor.Data @@ -72,7 +81,7 @@ func (c *ListWebhookController) Render(cmd *cobra.Command, args []string) error []string{"ID", "Created at", "Secret", "Endpoint", "Active", "Event types"}, ), ).Render(); err != nil { - return errors.Wrap(err, "rendering table") + return fmt.Errorf("rendering table: %w", err) } return nil } diff --git a/cmd/webhooks/root.go b/cmd/webhooks/root.go index 2d0202ad..63711510 100644 --- a/cmd/webhooks/root.go +++ b/cmd/webhooks/root.go @@ -18,8 +18,5 @@ func NewCommand() *cobra.Command { NewDeleteCommand(), NewChangeSecretCommand(), ), - fctl.WithPersistentPreRunE(func(cmd *cobra.Command, args []string) error { - return fctl.NewStackStore(cmd) - }), ) } diff --git a/cmd/webhooks/secret.go b/cmd/webhooks/secret.go index b6b9501f..61c76599 100644 --- a/cmd/webhooks/secret.go +++ b/cmd/webhooks/secret.go @@ -1,7 +1,8 @@ package webhooks import ( - "github.com/pkg/errors" + "fmt" + "github.com/pterm/pterm" "github.com/spf13/cobra" @@ -37,9 +38,18 @@ func (c *ChangeSecretWebhookController) GetStore() *ChangeSecretStore { return c.store } func (c *ChangeSecretWebhookController) Run(cmd *cobra.Command, args []string) (fctl.Renderable, error) { - store := fctl.GetStackStore(cmd.Context()) - if !fctl.CheckStackApprobation(cmd, store.Stack(), "You are about to change a webhook secret") { + _, profile, profileName, relyingParty, err := fctl.LoadAndAuthenticateCurrentProfile(cmd) + if err != nil { + return nil, err + } + + stackClient, err := fctl.NewStackClientFromFlags(cmd, relyingParty, fctl.NewPTermDialog(), profileName, *profile) + if err != nil { + return nil, err + } + + if !fctl.CheckStackApprobation(cmd, "You are about to change a webhook secret") { return nil, fctl.ErrMissingApproval } secret := "" @@ -47,7 +57,7 @@ func (c *ChangeSecretWebhookController) Run(cmd *cobra.Command, args []string) ( secret = args[1] } - response, err := store.Client().Webhooks.V1. + response, err := stackClient.Webhooks.V1. ChangeConfigSecret(cmd.Context(), operations.ChangeConfigSecretRequest{ ConfigChangeSecret: &shared.ConfigChangeSecret{ Secret: secret, @@ -55,7 +65,7 @@ func (c *ChangeSecretWebhookController) Run(cmd *cobra.Command, args []string) ( ID: args[0], }) if err != nil { - return nil, errors.Wrap(err, "changing secret") + return nil, fmt.Errorf("changing secret: %w", err) } c.store.ID = response.ConfigResponse.Data.ID diff --git a/flake.nix b/flake.nix index 5ca8ac86..e8b1c66f 100644 --- a/flake.nix +++ b/flake.nix @@ -37,7 +37,7 @@ f { pkgs = pkgs; pkgs-unstable = pkgs-unstable; system = system; } ); - speakeasyVersion = "1.563.0"; + speakeasyVersion = "1.648.0"; speakeasyPlatforms = { "x86_64-linux" = "linux_amd64"; "aarch64-linux" = "linux_arm64"; @@ -45,10 +45,10 @@ "aarch64-darwin" = "darwin_arm64"; }; speakeasyHashes = { - "x86_64-linux" = "632559a6bdc765ef42b81b8404fd0a3e5023919a0bb70ff7e40a8cc259545afd"; - "aarch64-linux" = "c74c502df3a05a2d69e6b282886df23354a319d0510d2c1a21fcc124b7ad00ef"; - "x86_64-darwin" = "8814be1fdd4eaf6dcc7fb251ede5693e1d3d4c8e03986f8d37bfd59e049698b9"; - "aarch64-darwin" = "12c20fa485de4725c9730cb2e8936cab4b0961d0a956e9f4c45534371f2a6148"; + "x86_64-linux" = "feefe6dd4a6b37f546976b8880b3d60d50a3a5587e2d66161edb395a814704a0"; + "aarch64-linux" = "7534abefd77a91643c5fafbc5fb829d8ba4f0adffe68ce6e4a50b362aafe6f68"; + "x86_64-darwin" = "ceac256d2b171ad984ef830c55480a7be76fd69af71e6f016d4c02be55058b33"; + "aarch64-darwin" = "35e143bcaf7e940018fe53a166142efab8ec6d0739059ef01ad5e375936493ce"; }; in diff --git a/go.mod b/go.mod index 2b2bafd3..f284ec09 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,12 @@ module github.com/formancehq/fctl -go 1.24.0 +go 1.24.4 toolchain go1.25.4 replace ( github.com/formancehq/fctl/internal/deployserverclient => ./internal/deployserverclient - github.com/formancehq/fctl/membershipclient => ./membershipclient + github.com/formancehq/fctl/internal/membershipclient => ./internal/membershipclient github.com/spf13/cobra => github.com/formancehq/cobra v0.0.0-20240315111924-ca456bf9cac9 github.com/zitadel/oidc/v2 v2.6.1 => github.com/formancehq/oidc/v2 v2.6.2-0.20230526075055-93dc5ecb0149 ) @@ -15,19 +15,19 @@ require ( github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2 github.com/c-bata/go-prompt v0.2.6 github.com/formancehq/fctl/internal/deployserverclient v0.0.0-00010101000000-000000000000 - github.com/formancehq/fctl/membershipclient v0.0.0-00010101000000-000000000000 + github.com/formancehq/fctl/internal/membershipclient v0.0.0-20251027061333-c274726dd769 github.com/formancehq/formance-sdk-go/v3 v3.5.0 github.com/formancehq/go-libs v1.7.2 - github.com/golang-jwt/jwt v3.2.2+incompatible + github.com/formancehq/go-libs/v3 v3.4.0 github.com/iancoleman/strcase v0.3.0 github.com/mattn/go-shellwords v1.0.12 github.com/pkg/errors v0.9.1 github.com/pterm/pterm v0.12.81 github.com/segmentio/ksuid v1.0.4 - github.com/spf13/cobra v1.8.1 + github.com/spf13/cobra v1.9.1 github.com/zitadel/oidc/v2 v2.12.2 golang.org/x/mod v0.28.0 - golang.org/x/oauth2 v0.30.0 + golang.org/x/oauth2 v0.31.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -35,28 +35,31 @@ require ( atomicgo.dev/cursor v0.2.0 // indirect atomicgo.dev/keyboard v0.2.9 // indirect atomicgo.dev/schedule v0.1.0 // indirect - dario.cat/mergo v1.0.1 // indirect - github.com/ThreeDotsLabs/watermill v1.3.7 // indirect + dario.cat/mergo v1.0.2 // indirect + github.com/ThreeDotsLabs/watermill v1.5.1 // indirect github.com/bahlo/generic-list-go v0.2.0 // indirect github.com/buger/jsonparser v1.1.1 // indirect github.com/containerd/console v1.0.5 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 // indirect - github.com/fatih/color v1.17.0 // indirect - github.com/go-chi/chi/v5 v5.2.2 // indirect - github.com/google/go-cmp v0.6.0 // indirect + github.com/fatih/color v1.18.0 // indirect + github.com/go-chi/chi/v5 v5.2.3 // indirect + github.com/go-jose/go-jose/v4 v4.0.5 // indirect + github.com/go-logr/logr v1.4.3 // indirect + github.com/go-logr/stdr v1.2.2 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gookit/color v1.5.4 // indirect github.com/gorilla/schema v1.4.1 // indirect github.com/gorilla/securecookie v1.1.2 // indirect + github.com/hashicorp/go-hclog v1.6.3 // indirect github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect - github.com/invopop/jsonschema v0.12.0 // indirect + github.com/invopop/jsonschema v0.13.0 // indirect github.com/jinzhu/inflection v1.0.0 // indirect github.com/lithammer/fuzzysearch v1.1.8 // indirect github.com/lithammer/shortuuid/v3 v3.0.7 // indirect github.com/mailru/easyjson v0.7.7 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-colorable v0.1.14 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mattn/go-tty v0.0.5 // indirect @@ -64,18 +67,27 @@ require ( github.com/oklog/ulid v1.3.1 // indirect github.com/pkg/term v1.2.0-beta.2 // indirect github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect - github.com/puzpuzpuz/xsync/v3 v3.4.0 // indirect + github.com/puzpuzpuz/xsync/v3 v3.5.1 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/sergi/go-diff v1.3.1 // indirect github.com/sirupsen/logrus v1.9.3 // indirect - github.com/spf13/pflag v1.0.5 // indirect + github.com/spf13/pflag v1.0.10 // indirect github.com/stretchr/testify v1.11.1 // indirect github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc // indirect - github.com/uptrace/bun v1.2.3 // indirect + github.com/uptrace/bun v1.2.15 // indirect + github.com/uptrace/opentelemetry-go-extra/otellogrus v0.3.2 // indirect + github.com/uptrace/opentelemetry-go-extra/otelutil v0.3.2 // indirect github.com/vmihailenco/msgpack/v5 v5.4.1 // indirect github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/wk8/go-ordered-map/v2 v2.1.8 // indirect github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect + github.com/zitadel/oidc/v3 v3.45.0 // indirect + github.com/zitadel/schema v1.3.1 // indirect + go.opentelemetry.io/auto/sdk v1.1.0 // indirect + go.opentelemetry.io/otel v1.38.0 // indirect + go.opentelemetry.io/otel/log v0.6.0 // indirect + go.opentelemetry.io/otel/metric v1.38.0 // indirect + go.opentelemetry.io/otel/trace v1.38.0 // indirect go.uber.org/multierr v1.11.0 // indirect go.uber.org/zap v1.27.0 // indirect golang.org/x/crypto v0.43.0 // indirect @@ -84,5 +96,4 @@ require ( golang.org/x/term v0.36.0 // indirect golang.org/x/text v0.30.0 // indirect gopkg.in/go-jose/go-jose.v2 v2.6.3 // indirect - gopkg.in/validator.v2 v2.0.1 // indirect ) diff --git a/go.sum b/go.sum index 7a680c6f..9a023aed 100644 --- a/go.sum +++ b/go.sum @@ -6,8 +6,8 @@ atomicgo.dev/keyboard v0.2.9 h1:tOsIid3nlPLZ3lwgG8KZMp/SFmr7P0ssEN5JUsm78K8= atomicgo.dev/keyboard v0.2.9/go.mod h1:BC4w9g00XkxH/f1HXhW2sXmJFOCWbKn9xrOunSFtExQ= atomicgo.dev/schedule v0.1.0 h1:nTthAbhZS5YZmgYbb2+DH8uQIZcTlIrd4eYr3UQxEjs= atomicgo.dev/schedule v0.1.0/go.mod h1:xeUa3oAkiuHYh8bKiQBRojqAMq3PXXbJujjb0hw8pEU= -dario.cat/mergo v1.0.1 h1:Ra4+bf83h2ztPIQYNP99R6m+Y7KfnARDfID+a+vLl4s= -dario.cat/mergo v1.0.1/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= +dario.cat/mergo v1.0.2 h1:85+piFYR1tMbRrLcDwR18y4UKJ3aH1Tbzi24VRW1TK8= +dario.cat/mergo v1.0.2/go.mod h1:E/hbnu0NxMFBjpMIE34DRGLWqDy0g5FuKDhCb31ngxA= filippo.io/edwards25519 v1.1.0 h1:FNf4tywRC1HmFuKW5xopWpigGjJKiJSV0Cqo0cJWDaA= filippo.io/edwards25519 v1.1.0/go.mod h1:BxyFTGdWcka3PhytdK4V28tE5sGfRvvvRV7EaN4VDT4= github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25UVaW/CKtUDjefjrs0SPonmDGUVOYP0= @@ -25,39 +25,39 @@ github.com/Microsoft/go-winio v0.6.2 h1:F2VQgta7ecxGYO8k3ZZz3RS8fVIXVxONVUPlNERo github.com/Microsoft/go-winio v0.6.2/go.mod h1:yd8OoFMLzJbo9gZq8j5qaps8bJ9aShtEA8Ipt1oGCvU= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw= github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk= -github.com/ThreeDotsLabs/watermill v1.3.7 h1:NV0PSTmuACVEOV4dMxRnmGXrmbz8U83LENOvpHekN7o= -github.com/ThreeDotsLabs/watermill v1.3.7/go.mod h1:lBnrLbxOjeMRgcJbv+UiZr8Ylz8RkJ4m6i/VN/Nk+to= +github.com/ThreeDotsLabs/watermill v1.5.1 h1:t5xMivyf9tpmU3iozPqyrCZXHvoV1XQDfihas4sV0fY= +github.com/ThreeDotsLabs/watermill v1.5.1/go.mod h1:Uop10dA3VeJWsSvis9qO3vbVY892LARrKAdki6WtXS4= github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2 h1:ZBbLwSJqkHBuFDA6DUhhse0IGJ7T5bemHyNILUjvOq4= github.com/TylerBrock/colorjson v0.0.0-20200706003622-8a50f05110d2/go.mod h1:VSw57q4QFiWDbRnjdX8Cb3Ow0SFncRw+bA/ofY6Q83w= github.com/atomicgo/cursor v0.0.1/go.mod h1:cBON2QmmrysudxNBFthvMtN32r3jxVRIvzkUiF/RuIk= -github.com/aws/aws-sdk-go-v2 v1.32.2 h1:AkNLZEyYMLnx/Q/mSKkcMqwNFXMAvFto9bNsHqcTduI= -github.com/aws/aws-sdk-go-v2 v1.32.2/go.mod h1:2SK5n0a2karNTv5tbP1SjsX0uhttou00v/HpXKM1ZUo= -github.com/aws/aws-sdk-go-v2/config v1.27.43 h1:p33fDDihFC390dhhuv8nOmX419wjOSDQRb+USt20RrU= -github.com/aws/aws-sdk-go-v2/config v1.27.43/go.mod h1:pYhbtvg1siOOg8h5an77rXle9tVG8T+BWLWAo7cOukc= -github.com/aws/aws-sdk-go-v2/credentials v1.17.41 h1:7gXo+Axmp+R4Z+AK8YFQO0ZV3L0gizGINCOWxSLY9W8= -github.com/aws/aws-sdk-go-v2/credentials v1.17.41/go.mod h1:u4Eb8d3394YLubphT4jLEwN1rLNq2wFOlT6OuxFwPzU= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.17 h1:TMH3f/SCAWdNtXXVPPu5D6wrr4G5hI1rAxbcocKfC7Q= -github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.17/go.mod h1:1ZRXLdTpzdJb9fwTMXiLipENRxkGMTn1sfKexGllQCw= -github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.4.21 h1:wRH9E07mfYqZ1EPphNTUIkrZ/7wcbZAGcjhrBlkWy4c= -github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.4.21/go.mod h1:6m/MDzT+aFxaIo46f2MYV4d+qG9J9keLlHL0qKnQFgA= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.21 h1:UAsR3xA31QGf79WzpG/ixT9FZvQlh5HY1NRqSHBNOCk= -github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.21/go.mod h1:JNr43NFf5L9YaG3eKTm7HQzls9J+A9YYcGI5Quh1r2Y= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.21 h1:6jZVETqmYCadGFvrYEQfC5fAQmlo80CeL5psbno6r0s= -github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.21/go.mod h1:1SR0GbLlnN3QUmYaflZNiH1ql+1qrSiB2vwcJ+4UM60= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 h1:VaRN3TlFdd6KxX1x3ILT5ynH6HvKgqdiXoTxAF4HQcQ= -github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1/go.mod h1:FbtygfRFze9usAadmnGJNc8KsP346kEe+y2/oyhGAGc= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0 h1:TToQNkvGguu209puTojY/ozlqy2d/SFNcoLIqTFi42g= -github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.12.0/go.mod h1:0jp+ltwkf+SwG2fm/PKo8t4y8pJSgOCO4D8Lz3k0aHQ= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.2 h1:s7NA1SOw8q/5c0wr8477yOPp0z+uBaXBnLE0XYb0POA= -github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.12.2/go.mod h1:fnjjWyAW/Pj5HYOxl9LJqWtEwS7W2qgcRLWP+uWbss0= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.2 h1:bSYXVyUzoTHoKalBmwaZxs97HU9DWWI3ehHSAMa7xOk= -github.com/aws/aws-sdk-go-v2/service/sso v1.24.2/go.mod h1:skMqY7JElusiOUjMJMOv1jJsP7YUg7DrhgqZZWuzu1U= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.2 h1:AhmO1fHINP9vFYUE0LHzCWg/LfUWUF+zFPEcY9QXb7o= -github.com/aws/aws-sdk-go-v2/service/ssooidc v1.28.2/go.mod h1:o8aQygT2+MVP0NaV6kbdE1YnnIM8RRVQzoeUH45GOdI= -github.com/aws/aws-sdk-go-v2/service/sts v1.32.2 h1:CiS7i0+FUe+/YY1GvIBLLrR/XNGZ4CtM1Ll0XavNuVo= -github.com/aws/aws-sdk-go-v2/service/sts v1.32.2/go.mod h1:HtaiBI8CjYoNVde8arShXb94UbQQi9L4EMr6D+xGBwo= -github.com/aws/smithy-go v1.22.0 h1:uunKnWlcoL3zO7q+gG2Pk53joueEOsnNB28QdMsmiMM= -github.com/aws/smithy-go v1.22.0/go.mod h1:irrKGvNn1InZwb2d7fkIRNucdfwR8R+Ts3wxYa/cJHg= +github.com/aws/aws-sdk-go-v2 v1.39.0 h1:xm5WV/2L4emMRmMjHFykqiA4M/ra0DJVSWUkDyBjbg4= +github.com/aws/aws-sdk-go-v2 v1.39.0/go.mod h1:sDioUELIUO9Znk23YVmIk86/9DOpkbyyVb1i/gUNFXY= +github.com/aws/aws-sdk-go-v2/config v1.31.7 h1:zS1O6hr6t0nZdBCMFc/c9OyZFyLhXhf/B2IZ9Y0lRQE= +github.com/aws/aws-sdk-go-v2/config v1.31.7/go.mod h1:GpHmi1PQDdL5pP4JaB00pU0ek4EXVcYH7IkjkUadQmM= +github.com/aws/aws-sdk-go-v2/credentials v1.18.11 h1:1Fnb+7Dk96/VYx/uYfzk5sU2V0b0y2RWZROiMZCN/Io= +github.com/aws/aws-sdk-go-v2/credentials v1.18.11/go.mod h1:iuvn9v10dkxU4sDgtTXGWY0MrtkEcmkUmjv4clxhuTc= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.7 h1:Is2tPmieqGS2edBnmOJIbdvOA6Op+rRpaYR60iBAwXM= +github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.18.7/go.mod h1:F1i5V5421EGci570yABvpIXgRIBPb5JM+lSkHF6Dq5w= +github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.5.14 h1:jC4xN9XwabWPEHcUojwxrXUPLKwizRJyzTqcnHd7q+M= +github.com/aws/aws-sdk-go-v2/feature/rds/auth v1.5.14/go.mod h1:Fr7lAii+im8B1NOejSXDG0WXkOH2C0DsnDKCOoxDw8s= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.7 h1:UCxq0X9O3xrlENdKf1r9eRJoKz/b0AfGkpp3a7FPlhg= +github.com/aws/aws-sdk-go-v2/internal/configsources v1.4.7/go.mod h1:rHRoJUNUASj5Z/0eqI4w32vKvC7atoWR0jC+IkmVH8k= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.7 h1:Y6DTZUn7ZUC4th9FMBbo8LVE+1fyq3ofw+tRwkUd3PY= +github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.7.7/go.mod h1:x3XE6vMnU9QvHN/Wrx2s44kwzV2o2g5x/siw4ZUJ9g8= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3 h1:bIqFDwgGXXN1Kpp99pDOdKMTTb5d2KyU5X/BZxjOkRo= +github.com/aws/aws-sdk-go-v2/internal/ini v1.8.3/go.mod h1:H5O/EsxDWyU+LP/V8i5sm8cxoZgc2fdNR9bxlOFrQTo= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.1 h1:oegbebPEMA/1Jny7kvwejowCaHz1FWZAQ94WXFNCyTM= +github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.13.1/go.mod h1:kemo5Myr9ac0U9JfSjMo9yHLtw+pECEHsFtJ9tqCEI8= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.7 h1:mLgc5QIgOy26qyh5bvW+nDoAppxgn3J2WV3m9ewq7+8= +github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.13.7/go.mod h1:wXb/eQnqt8mDQIQTTmcw58B5mYGxzLGZGK8PWNFZ0BA= +github.com/aws/aws-sdk-go-v2/service/sso v1.29.2 h1:rcoTaYOhGE/zfxE1uR6X5fvj+uKkqeCNRE0rBbiQM34= +github.com/aws/aws-sdk-go-v2/service/sso v1.29.2/go.mod h1:Ql6jE9kyyWI5JHn+61UT/Y5Z0oyVJGmgmJbZD5g4unY= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.34.3 h1:BSIfeFtU9tlSt8vEYS7KzurMoAuYzYPWhcZiMtxVf2M= +github.com/aws/aws-sdk-go-v2/service/ssooidc v1.34.3/go.mod h1:XclEty74bsGBCr1s0VSaA11hQ4ZidK4viWK7rRfO88I= +github.com/aws/aws-sdk-go-v2/service/sts v1.38.3 h1:yEiZ0ztgji2GsCb/6uQSITXcGdtmWMfLRys0jJFiUkc= +github.com/aws/aws-sdk-go-v2/service/sts v1.38.3/go.mod h1:Z+Gd23v97pX9zK97+tX4ppAgqCt3Z2dIXB02CtBncK8= +github.com/aws/smithy-go v1.23.0 h1:8n6I3gXzWJB2DxBDnfxgBaSX6oe0d/t10qGz7OKqMCE= +github.com/aws/smithy-go v1.23.0/go.mod h1:t1ufH5HMublsJYulve2RKmHDC15xu1f26kHCp/HgceI= github.com/bahlo/generic-list-go v0.2.0 h1:5sz/EEAK+ls5wF+NeqDpk5+iNdMDXrh3z3nPnH1Wvgk= github.com/bahlo/generic-list-go v0.2.0/go.mod h1:2KvAjgMlE5NNynlg/5iLrrCCZ2+5xWbdbCW3pNTGyYg= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= @@ -78,44 +78,50 @@ github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1 github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/docker/cli v27.3.1+incompatible h1:qEGdFBF3Xu6SCvCYhc7CzaQTlBmqDuzxPDpigSyeKQQ= github.com/docker/cli v27.3.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= -github.com/docker/docker v27.3.1+incompatible h1:KttF0XoteNTicmUtBO0L2tP+J7FGRFTjaEF4k6WdhfI= -github.com/docker/docker v27.3.1+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= -github.com/docker/go-connections v0.5.0 h1:USnMq7hx7gwdVZq1L49hLXaFtUdTADjXGp+uj1Br63c= -github.com/docker/go-connections v0.5.0/go.mod h1:ov60Kzw0kKElRwhNs9UlUHAE/F9Fe6GLaXnqyDdmEXc= +github.com/docker/docker v28.3.3+incompatible h1:Dypm25kh4rmk49v1eiVbsAtpAsYURjYkaKubwuBdxEI= +github.com/docker/docker v28.3.3+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= +github.com/docker/go-connections v0.6.0 h1:LlMG9azAe1TqfR7sO+NJttz1gy6KO7VJBh+pMmjSD94= +github.com/docker/go-connections v0.6.0/go.mod h1:AahvXYshr6JgfUJGdDCs2b5EZG/vmaMAntpSFH5BFKE= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/docker/go-units v0.5.0/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731 h1:R/ZjJpjQKsZ6L/+Gf9WHbt31GG8NMVcpRqUE+1mMIyo= github.com/ericlagergren/decimal v0.0.0-20240411145413-00de7ca16731/go.mod h1:M9R1FoZ3y//hwwnJtO51ypFGwm8ZfpxPT/ZLtO1mcgQ= -github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= -github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= +github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= +github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= +github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= +github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= github.com/formancehq/cobra v0.0.0-20240315111924-ca456bf9cac9 h1:y+q436ECR5jNU+CAqK0pPGGM6pKUtvreQ4m/nfaKGQM= github.com/formancehq/cobra v0.0.0-20240315111924-ca456bf9cac9/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho= github.com/formancehq/formance-sdk-go/v3 v3.5.0 h1:4qUhPOaF0igfH+cR95bnsteNXoidZuSxtq1RZZYpAJg= github.com/formancehq/formance-sdk-go/v3 v3.5.0/go.mod h1:6V6/yj6FZDYS3lA7R8d93y/Z4mQbLdGoNOYEMrUKUWM= github.com/formancehq/go-libs v1.7.2 h1:zPLkMVigMxcdPQiA8Q0HLPgA/al/hKmLxLw9muDPM1U= github.com/formancehq/go-libs v1.7.2/go.mod h1:3+crp7AA/Rllpo9M/ZQslaHkYt9EtXtbE4qYasV201Q= -github.com/go-chi/chi/v5 v5.2.2 h1:CMwsvRVTbXVytCk1Wd72Zy1LAsAh9GxMmSNWLHCG618= -github.com/go-chi/chi/v5 v5.2.2/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/formancehq/go-libs/v3 v3.4.0 h1:/hk51xOL++qRItlrZEhYlPQX+o9ePz/eBc3KiLK03Dc= +github.com/formancehq/go-libs/v3 v3.4.0/go.mod h1:Lr0qE3ioCTFlm+BuXSwB7qpGF12/IfKYOpFvszTFRJk= +github.com/go-chi/chi/v5 v5.2.3 h1:WQIt9uxdsAbgIYgid+BpYc+liqQZGMHRaUwp0JUcvdE= +github.com/go-chi/chi/v5 v5.2.3/go.mod h1:L2yAIGWB3H+phAw1NxKwWM+7eUH/lU8pOMm5hHcoops= +github.com/go-jose/go-jose/v4 v4.0.5 h1:M6T8+mKZl/+fNNuFHvGIzDz7BTLQPIounk/b9dw3AaE= +github.com/go-jose/go-jose/v4 v4.0.5/go.mod h1:s3P1lRrkT8igV8D9OjyL4WRyHvjB6a4JSllnOrmmBOA= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.3 h1:CjnDlHq8ikf6E492q6eKboGOC0T8CDaOvkHCIg8idEI= +github.com/go-logr/logr v1.4.3/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-sql-driver/mysql v1.8.1 h1:LedoTUt/eveggdHS9qUFC1EFSa8bU2+1pZjSRpvNJ1Y= -github.com/go-sql-driver/mysql v1.8.1/go.mod h1:wEBSXgmK//2ZFJyE+qWnIsVGmvmEKlqwuVSjsCm7DZg= +github.com/go-sql-driver/mysql v1.9.3 h1:U/N249h2WzJ3Ukj8SowVFjdtZKfu9vlLZxjPXV1aweo= +github.com/go-sql-driver/mysql v1.9.3/go.mod h1:qn46aNg1333BRMNU69Lq93t8du/dwxI64Gl8i5p1WMU= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= github.com/go-task/slim-sprig/v3 v3.0.0/go.mod h1:W848ghGpv3Qj3dhTPRyJypKRiqCdHZiAzKg9hl15HA8= -github.com/go-viper/mapstructure/v2 v2.2.1 h1:ZAaOCxANMuZx5RCeg0mBdEZk7DZasvvZIxtHqx8aGss= -github.com/go-viper/mapstructure/v2 v2.2.1/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= +github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9LvH92wZUgs= +github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= -github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8= +github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/pprof v0.0.0-20240910150728-a0b0bb1d4134 h1:c5FlPPgxOn7kJz3VoPLkQYQXGBS3EklQ4Zfi57uOuqQ= -github.com/google/pprof v0.0.0-20240910150728-a0b0bb1d4134/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= +github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J0b1vyeLSOYI8bm5wbJM/8yDe8= +github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.2.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -125,22 +131,28 @@ github.com/gookit/color v1.4.2/go.mod h1:fqRyamkC1W8uxl+lxCQxOT09l/vYfZ+QeiX3rKQ github.com/gookit/color v1.5.0/go.mod h1:43aQb+Zerm/BWh2GnrgOQm7ffz7tvQXEKV6BFMl7wAo= github.com/gookit/color v1.5.4 h1:FZmqs7XOyGgCAxmWyPslpiok1k05wmY3SJTytgvYFs0= github.com/gookit/color v1.5.4/go.mod h1:pZJOeOS8DM43rXbp4AZo1n9zCU2qjpcRko0b6/QJi9w= -github.com/gorilla/mux v1.8.1 h1:TuBL49tXwgrFYWhqrNgrUNEY92u81SPhu7sTdzQEiWY= -github.com/gorilla/mux v1.8.1/go.mod h1:AKf9I4AEqPTmMytcMc0KkNouC66V3BtZ4qD5fmWSiMQ= github.com/gorilla/schema v1.4.1 h1:jUg5hUjCSDZpNGLuXQOgIWGdlgrIdYvgQ0wZtdK1M3E= github.com/gorilla/schema v1.4.1/go.mod h1:Dg5SSm5PV60mhF2NFaTV1xuYYj8tV8NOPRo4FggUMnM= github.com/gorilla/securecookie v1.1.2 h1:YCIWL56dvtr73r6715mJs5ZvhtnY73hBvEF8kXD8ePA= github.com/gorilla/securecookie v1.1.2/go.mod h1:NfCASbcHqRSY+3a8tlWJwsQap2VX5pwzwo4h3eOamfo= +github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k= +github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f h1:7LYC+Yfkj3CTRcShK0KOL/w6iTiKyqqBA9a41Wnggw8= github.com/hokaccha/go-prettyjson v0.0.0-20211117102719-0474bc63780f/go.mod h1:pFlLw2CfqZiIBOx6BuCeRLCrfxBJipTY0nIOF/VbGcI= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8= github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= -github.com/invopop/jsonschema v0.12.0 h1:6ovsNSuvn9wEQVOyc72aycBMVQFKz7cPdMJn10CvzRI= -github.com/invopop/jsonschema v0.12.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0= -github.com/jeremija/gosubmit v0.2.7 h1:At0OhGCFGPXyjPYAsCchoBUhE099pcBXmsb4iZqROIc= -github.com/jeremija/gosubmit v0.2.7/go.mod h1:Ui+HS073lCFREXBbdfrJzMB57OI/bdxTiLtrDHHhFPI= +github.com/invopop/jsonschema v0.13.0 h1:KvpoAJWEjR3uD9Kbm2HWJmqsEaHt8lBUpd0qHcIi21E= +github.com/invopop/jsonschema v0.13.0/go.mod h1:ffZ5Km5SWWRAIN6wbDXItl95euhFz2uON45H2qjYt+0= +github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= +github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= +github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761 h1:iCEnooe7UlwOQYpKFhBabPMi4aNAfoODPEFNiAnClxo= +github.com/jackc/pgservicefile v0.0.0-20240606120523-5a60cdf6a761/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM= +github.com/jackc/pgx/v5 v5.7.6 h1:rWQc5FwZSPX58r1OQmkuaNicxdmExaEz5A2DO2hUuTk= +github.com/jackc/pgx/v5 v5.7.6/go.mod h1:aruU7o91Tc2q2cFp5h4uP3f6ztExVpyVv88Xl/8Vl8M= +github.com/jackc/puddle/v2 v2.2.2 h1:PR8nw+E/1w0GLuRFSmiioY6UooMp6KJv0/61nB7icHo= +github.com/jackc/puddle/v2 v2.2.2/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4= github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= @@ -150,14 +162,12 @@ github.com/klauspost/cpuid/v2 v2.0.12/go.mod h1:g2LTdtYhdyuGPqyWyv7qRAmj1WBqxuOb github.com/klauspost/cpuid/v2 v2.2.3 h1:sxCkb+qR91z4vsqw4vGGZlDgPz3G7gjaLyK3V8y70BU= github.com/klauspost/cpuid/v2 v2.2.3/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= -github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lithammer/fuzzysearch v1.1.8 h1:/HIuJnjHuXS8bKaiTMeeDlW2/AyIWk2brx1V8LFgLN4= github.com/lithammer/fuzzysearch v1.1.8/go.mod h1:IdqeyBClc3FFqSzYq/MXESsS4S0FsZ5ajtkr5xPLts4= github.com/lithammer/shortuuid/v3 v3.0.7 h1:trX0KTHy4Pbwo/6ia8fscyHoGA+mf1jWbPJVuvyJQQ8= @@ -166,12 +176,14 @@ github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0 github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.7/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE= +github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8= github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84= github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.6/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= @@ -187,22 +199,22 @@ github.com/mattn/go-tty v0.0.5 h1:s09uXI7yDbXzzTTfw3zonKFzwGkyYlgU3OMjqA0ddz4= github.com/mattn/go-tty v0.0.5/go.mod h1:u5GGXBtZU6RQoKV8gY5W6UhMudbR5vXnUe7j3pxse28= github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0= github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo= +github.com/moby/sys/user v0.4.0 h1:jhcMKit7SA80hivmFJcbB1vqmw//wU61Zdui2eQXuMs= +github.com/moby/sys/user v0.4.0/go.mod h1:bG+tYYYJgaMtRKgEmuueC0hJEAZWwtIbZTB+85uoHjs= github.com/moby/term v0.5.0 h1:xt8Q1nalod/v7BqbG21f8mQPqH+xAaC9C3N3wfWbVP0= github.com/moby/term v0.5.0/go.mod h1:8FzsFHVUBGZdbDsJw/ot+X+d5HLUbvklYLJ9uGfcI3Y= github.com/muhlemmer/gu v0.3.1 h1:7EAqmFrW7n3hETvuAdmFmn4hS8W+z3LgKtrnow+YzNM= github.com/muhlemmer/gu v0.3.1/go.mod h1:YHtHR+gxM+bKEIIs7Hmi9sPT3ZDUvTN/i88wQpZkrdM= -github.com/muhlemmer/httpforwarded v0.1.0 h1:x4DLrzXdliq8mprgUMR0olDvHGkou5BJsK/vWUetyzY= -github.com/muhlemmer/httpforwarded v0.1.0/go.mod h1:yo9czKedo2pdZhoXe+yDkGVbU0TJ0q9oQ90BVoDEtw0= github.com/oklog/ulid v1.3.1 h1:EGfNDEx6MqHz8B3uNV6QAib1UR2Lm97sHi3ocA6ESJ4= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= -github.com/onsi/ginkgo/v2 v2.20.2 h1:7NVCeyIWROIAheY21RLS+3j2bb52W0W82tkberYytp4= -github.com/onsi/ginkgo/v2 v2.20.2/go.mod h1:K9gyxPIlb+aIvnZ8bd9Ak+YP18w3APlR+5coaZoE2ag= +github.com/onsi/ginkgo/v2 v2.23.4 h1:ktYTpKJAVZnDT4VjxSbiBenUjmlL/5QkBEocaWXiQus= +github.com/onsi/ginkgo/v2 v2.23.4/go.mod h1:Bt66ApGPBFzHyR+JO10Zbt0Gsp4uWxu5mIOTusL46e8= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= -github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= -github.com/opencontainers/image-spec v1.1.0/go.mod h1:W4s4sFTMaBeK1BQLXbG4AdM2szdn85PY75RI83NrTrM= -github.com/opencontainers/runc v1.1.14 h1:rgSuzbmgz5DUJjeSnw337TxDbRuqjs6iqQck/2weR6w= -github.com/opencontainers/runc v1.1.14/go.mod h1:E4C2z+7BxR7GHXp0hAY53mek+x49X1LjPNeMTfRGvOA= +github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJwooC2xJA040= +github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M= +github.com/opencontainers/runc v1.2.8 h1:RnEICeDReapbZ5lZEgHvj7E9Q3Eex9toYmaGBsbvU5Q= +github.com/opencontainers/runc v1.2.8/go.mod h1:cC0YkmZcuvr+rtBZ6T7NBoVbMGNAdLa/21vIElJDOzI= github.com/ory/dockertest/v3 v3.11.0 h1:OiHcxKAvSDUwsEVh2BjxQQc/5EHz9n0va9awCtNGuyA= github.com/ory/dockertest/v3 v3.11.0/go.mod h1:VIPxS1gwT9NpPOrfD3rACs8Y9Z7yhzO4SB194iUDnUI= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= @@ -221,13 +233,13 @@ github.com/pterm/pterm v0.12.36/go.mod h1:NjiL09hFhT/vWjQHSj1athJpx6H8cjpHXNAK5b github.com/pterm/pterm v0.12.40/go.mod h1:ffwPLwlbXxP+rxT0GsgDTzS3y3rmpAO1NMjUkGTYf8s= github.com/pterm/pterm v0.12.81 h1:ju+j5I2++FO1jBKMmscgh5h5DPFDFMB7epEjSoKehKA= github.com/pterm/pterm v0.12.81/go.mod h1:TyuyrPjnxfwP+ccJdBTeWHtd/e0ybQHkOS/TakajZCw= -github.com/puzpuzpuz/xsync/v3 v3.4.0 h1:DuVBAdXuGFHv8adVXjWWZ63pJq+NRXOWVXlKDBZ+mJ4= -github.com/puzpuzpuz/xsync/v3 v3.4.0/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA= +github.com/puzpuzpuz/xsync/v3 v3.5.1 h1:GJYJZwO6IdxN/IKbneznS6yPkVC+c3zyY/j19c++5Fg= +github.com/puzpuzpuz/xsync/v3 v3.5.1/go.mod h1:VjzYrABPabuM4KyBh1Ftq6u8nhwY5tBPKP9jpmh0nnA= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/rs/cors v1.11.1 h1:eU3gRzXLRK57F5rKMGMZURNdIG4EoAmX8k94r9wXWHA= -github.com/rs/cors v1.11.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/segmentio/ksuid v1.0.4 h1:sBo2BdShXjmcugAMwjugoGUdUV0pcxY5mW4xKRn3v4c= github.com/segmentio/ksuid v1.0.4/go.mod h1:/XUiZBD3kVx5SmUOl55voK5yeAbBNNIed+2O73XgrPE= @@ -236,24 +248,30 @@ github.com/sergi/go-diff v1.3.1 h1:xkr+Oxo4BOQKmkn/B9eMK0g5Kg/983T9DqqPHwYqD+8= github.com/sergi/go-diff v1.3.1/go.mod h1:aMJSSKb2lpPvRNec0+w3fl7LP9IOFzdc9Pa4NFbPK1I= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/pflag v1.0.10 h1:4EBh2KAYBwaONj6b2Ye1GiHfwjqyROoF4RwYO+vPwFk= +github.com/spf13/pflag v1.0.10/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo= github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs= -github.com/uptrace/bun v1.2.3 h1:6KDc6YiNlXde38j9ATKufb8o7MS8zllhAOeIyELKrk0= -github.com/uptrace/bun v1.2.3/go.mod h1:8frYFHrO/Zol3I4FEjoXam0HoNk+t5k7aJRl3FXp0mk= -github.com/uptrace/bun/dialect/pgdialect v1.2.3 h1:YyCxxqeL0lgFWRZzKCOt6mnxUsjqITcxSo0mLqgwMUA= -github.com/uptrace/bun/dialect/pgdialect v1.2.3/go.mod h1:Vx9TscyEq1iN4tnirn6yYGwEflz0KG3rBZTBCLpKAjc= -github.com/uptrace/bun/extra/bunotel v1.2.3 h1:G19QpDE68TXw97x6NciB6nKVDuK0Wb2KgtyMqNIyqBI= -github.com/uptrace/bun/extra/bunotel v1.2.3/go.mod h1:jHRgTqLlX/Zj1KIDokCMDat6JwZHJyErOx0PQ10UFgQ= +github.com/uptrace/bun v1.2.15 h1:Ut68XRBLDgp9qG9QBMa9ELWaZOmzHNdczHQdrOZbEFE= +github.com/uptrace/bun v1.2.15/go.mod h1:Eghz7NonZMiTX/Z6oKYytJ0oaMEJ/eq3kEV4vSqG038= +github.com/uptrace/bun/dialect/pgdialect v1.2.15 h1:er+/3giAIqpfrXJw+KP9B7ujyQIi5XkPnFmgjAVL6bA= +github.com/uptrace/bun/dialect/pgdialect v1.2.15/go.mod h1:QSiz6Qpy9wlGFsfpf7UMSL6mXAL1jDJhFwuOVacCnOQ= +github.com/uptrace/bun/extra/bunotel v1.2.15 h1:6KAvKRpH9BC/7n3eMXVgDYLqghHf2H3FJOvxs/yjFJM= +github.com/uptrace/bun/extra/bunotel v1.2.15/go.mod h1:qnASdcJVuoEE+13N3Gd8XHi5gwCydt2S1TccJnefH2k= +github.com/uptrace/opentelemetry-go-extra/otellogrus v0.3.2 h1:H8wwQwTe5sL6x30z71lUgNiwBdeCHQjrphCfLwqIHGo= +github.com/uptrace/opentelemetry-go-extra/otellogrus v0.3.2/go.mod h1:/kR4beFhlz2g+V5ik8jW+3PMiMQAPt29y6K64NNY53c= github.com/uptrace/opentelemetry-go-extra/otelsql v0.3.2 h1:ZjUj9BLYf9PEqBn8W/OapxhPjVRdC6CsXTdULHsyk5c= github.com/uptrace/opentelemetry-go-extra/otelsql v0.3.2/go.mod h1:O8bHQfyinKwTXKkiKNGmLQS7vRsqRxIQTFZpYpHK3IQ= +github.com/uptrace/opentelemetry-go-extra/otelutil v0.3.2 h1:3/aHKUq7qaFMWxyQV0W2ryNgg8x8rVeKVA20KJUkfS0= +github.com/uptrace/opentelemetry-go-extra/otelutil v0.3.2/go.mod h1:Zit4b8AQXaXvA68+nzmbyDzqiyFRISyw1JiD5JqUBjw= github.com/vmihailenco/msgpack/v5 v5.4.1 h1:cQriyiUvjTwOHg8QZaPihLWeRAAVoCpE00IUPn0Bjt8= github.com/vmihailenco/msgpack/v5 v5.4.1/go.mod h1:GaZTsDaehaPpQVyxrf5mtQlH+pc21PIudVV/E3rRQok= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= @@ -266,24 +284,38 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= -github.com/xo/dburl v0.23.2 h1:Fl88cvayrgE56JA/sqhNMLljCW/b7RmG1mMkKMZUFgA= -github.com/xo/dburl v0.23.2/go.mod h1:uazlaAQxj4gkshhfuuYyvwCBouOmNnG2aDxTCFZpmL4= +github.com/xo/dburl v0.23.8 h1:NwFghJfjaUW7tp+WE5mTLQQCfgseRsvgXjlSvk7x4t4= +github.com/xo/dburl v0.23.8/go.mod h1:uazlaAQxj4gkshhfuuYyvwCBouOmNnG2aDxTCFZpmL4= github.com/xo/terminfo v0.0.0-20210125001918-ca9a967f8778/go.mod h1:2MuV+tbUrU1zIOPMxZ5EncGwgmMJsa+9ucAQZXxsObs= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e h1:JVG44RsyaB9T2KIHavMF/ppJZNG9ZpyihvCd0w101no= github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e/go.mod h1:RbqR21r5mrJuqunuUZ/Dhy/avygyECGrLceyNeo4LiM= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= github.com/zitadel/oidc/v2 v2.12.2 h1:3kpckg4rurgw7w7aLJrq7yvRxb2pkNOtD08RH42vPEs= github.com/zitadel/oidc/v2 v2.12.2/go.mod h1:vhP26g1g4YVntcTi0amMYW3tJuid70nxqxf+kb6XKgg= -go.opentelemetry.io/otel v1.31.0 h1:NsJcKPIW0D0H3NgzPDHmo0WW6SptzPdqg/L1zsIm2hY= -go.opentelemetry.io/otel v1.31.0/go.mod h1:O0C14Yl9FgkjqcCZAsE053C13OaddMYr/hz6clDkEJE= -go.opentelemetry.io/otel/metric v1.31.0 h1:FSErL0ATQAmYHUIzSezZibnyVlft1ybhy4ozRPcF2fE= -go.opentelemetry.io/otel/metric v1.31.0/go.mod h1:C3dEloVbLuYoX41KpmAhOqNriGbA+qqH6PQ5E5mUfnY= -go.opentelemetry.io/otel/trace v1.31.0 h1:ffjsj1aRouKewfr85U2aGagJ46+MvodynlQ1HYdmJys= -go.opentelemetry.io/otel/trace v1.31.0/go.mod h1:TXZkRk7SM2ZQLtR6eoAWQFIHPvzQ06FJAsO1tJg480A= -go.uber.org/dig v1.18.0 h1:imUL1UiY0Mg4bqbFfsRQO5G4CGRBec/ZujWTvSVp3pw= -go.uber.org/dig v1.18.0/go.mod h1:Us0rSJiThwCv2GteUN0Q7OKvU7n5J4dxZ9JKUXozFdE= -go.uber.org/fx v1.23.0 h1:lIr/gYWQGfTwGcSXWXu4vP5Ws6iqnNEIY+F/aFzCKTg= -go.uber.org/fx v1.23.0/go.mod h1:o/D9n+2mLP6v1EG+qsdT1O8wKopYAsqZasju97SDFCU= +github.com/zitadel/oidc/v3 v3.45.0 h1:SaVJ2kdcJi/zdEWWlAns+81VxmfdYX4E+2mWFVIH7Ec= +github.com/zitadel/oidc/v3 v3.45.0/go.mod h1:UeK0iVOoqfMuDVgSfv56BqTz8YQC2M+tGRIXZ7Ii3VY= +github.com/zitadel/schema v1.3.1 h1:QT3kwiRIRXXLVAs6gCK/u044WmUVh6IlbLXUsn6yRQU= +github.com/zitadel/schema v1.3.1/go.mod h1:071u7D2LQacy1HAN+YnMd/mx1qVE2isb0Mjeqg46xnU= +go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA= +go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0 h1:Hf9xI/XLML9ElpiHVDNwvqI0hIFlzV8dgIr35kV1kRU= +go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.62.0/go.mod h1:NfchwuyNoMcZ5MLHwPrODwUF1HWCXWrL31s8gSAdIKY= +go.opentelemetry.io/otel v1.38.0 h1:RkfdswUDRimDg0m2Az18RKOsnI8UDzppJAtj01/Ymk8= +go.opentelemetry.io/otel v1.38.0/go.mod h1:zcmtmQ1+YmQM9wrNsTGV/q/uyusom3P8RxwExxkZhjM= +go.opentelemetry.io/otel/log v0.6.0 h1:nH66tr+dmEgW5y+F9LanGJUBYPrRgP4g2EkmPE3LeK8= +go.opentelemetry.io/otel/log v0.6.0/go.mod h1:KdySypjQHhP069JX0z/t26VHwa8vSwzgaKmXtIB3fJM= +go.opentelemetry.io/otel/metric v1.38.0 h1:Kl6lzIYGAh5M159u9NgiRkmoMKjvbsKtYRwgfrA6WpA= +go.opentelemetry.io/otel/metric v1.38.0/go.mod h1:kB5n/QoRM8YwmUahxvI3bO34eVtQf2i4utNVLr9gEmI= +go.opentelemetry.io/otel/sdk v1.37.0 h1:ItB0QUqnjesGRvNcmAcU0LyvkVyGJ2xftD29bWdDvKI= +go.opentelemetry.io/otel/sdk v1.37.0/go.mod h1:VredYzxUvuo2q3WRcDnKDjbdvmO0sCzOvVAiY+yUkAg= +go.opentelemetry.io/otel/trace v1.38.0 h1:Fxk5bKrDZJUH+AMyyIXGcFAPah0oRcT+LuNtJrmcNLE= +go.opentelemetry.io/otel/trace v1.38.0/go.mod h1:j1P9ivuFsTceSWe1oY+EeW3sc+Pp42sO++GHkg4wwhs= +go.uber.org/automaxprocs v1.6.0 h1:O3y2/QNTOdbF+e/dpXNNW7Rx2hZ4sTIPyybbxyNqTUs= +go.uber.org/automaxprocs v1.6.0/go.mod h1:ifeIMSnPZuznNm6jmdzmU3/bfk01Fe2fotchwEFJ8r8= +go.uber.org/dig v1.19.0 h1:BACLhebsYdpQ7IROQ1AGPjrXcP5dF80U3gKoFzbaq/4= +go.uber.org/dig v1.19.0/go.mod h1:Us0rSJiThwCv2GteUN0Q7OKvU7n5J4dxZ9JKUXozFdE= +go.uber.org/fx v1.24.0 h1:wE8mruvpg2kiiL1Vqd0CC+tr0/24XIB10Iwp2lLWzkg= +go.uber.org/fx v1.24.0/go.mod h1:AmDeGyS+ZARGKM4tlH4FY2Jr63VjbEDJHtqXTGP5hbo= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= @@ -304,10 +336,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.45.0 h1:RLBg5JKixCy82FtLJpeNlVM0nrSqpCRYzVU1n8kj0tM= -golang.org/x/net v0.45.0/go.mod h1:ECOoLqd5U3Lhyeyo/QDCEVQ4sNgYsqvCZ722XogGieY= -golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI= -golang.org/x/oauth2 v0.30.0/go.mod h1:B++QgG3ZKulg6sRPGD/mqlHQs5rB3Ml9erfeDY7xKlU= +golang.org/x/oauth2 v0.31.0 h1:8Fq0yVZLh4j4YA47vHKFTa9Ew5XIrCP8LC6UeNZnLxo= +golang.org/x/oauth2 v0.31.0/go.mod h1:lzm5WQJQwKZ3nwavOZ3IS5Aulzxi68dUSgRHujetwEA= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -326,12 +356,14 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211013075003-97ac67df715c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -364,8 +396,6 @@ gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntN gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/go-jose/go-jose.v2 v2.6.3 h1:nt80fvSDlhKWQgSWyHyy5CfmlQr+asih51R8PTWNKKs= gopkg.in/go-jose/go-jose.v2 v2.6.3/go.mod h1:zzZDPkNNw/c9IE7Z9jr11mBZQhKQTMzoEEIoEdZlFBI= -gopkg.in/validator.v2 v2.0.1 h1:xF0KWyGWXm/LM2G1TrEjqOu4pa6coO9AlWSf3msVfDY= -gopkg.in/validator.v2 v2.0.1/go.mod h1:lIUZBlB3Im4s/eYp39Ry/wkR02yOPhZ9IwIRBjuPuG8= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= diff --git a/internal/deployserverclient/.speakeasy/gen.lock b/internal/deployserverclient/.speakeasy/gen.lock index 473593e1..ce37e337 100644 --- a/internal/deployserverclient/.speakeasy/gen.lock +++ b/internal/deployserverclient/.speakeasy/gen.lock @@ -3,15 +3,15 @@ id: 8068b42d-3ccb-4bcf-87ba-eaf586d7782d management: docChecksum: 59577c447ac91b447ca6bed84676d04d docVersion: 0.1.0 - speakeasyVersion: 1.658.1 - generationVersion: 2.755.6 + speakeasyVersion: 1.661.3 + generationVersion: 2.763.3 releaseVersion: 0.0.1 - configChecksum: 245d28481398341ceab8d0112f197b44 + configChecksum: c2caea4a8732e9fd7b89ede000a98e38 features: go: acceptHeaders: 2.81.2 additionalDependencies: 0.1.0 - core: 3.13.2 + core: 3.13.3 defaultEnabledRetries: 0.2.0 devContainers: 2.90.0 downloadStreams: 0.1.2 diff --git a/internal/deployserverclient/.speakeasy/gen.yaml b/internal/deployserverclient/.speakeasy/gen.yaml index 4fd31f91..65bca9ce 100644 --- a/internal/deployserverclient/.speakeasy/gen.yaml +++ b/internal/deployserverclient/.speakeasy/gen.yaml @@ -45,6 +45,7 @@ go: shared: models/components webhooks: models/webhooks includeEmptyObjects: false + inferUnionDiscriminators: false inputModelSuffix: input maxMethodParams: 4 methodArguments: require-security-and-request @@ -55,4 +56,4 @@ go: respectRequiredFields: false responseFormat: envelope-http sdkPackageName: "" - unionDeserializationStrategy: left-to-right + unionStrategy: left-to-right diff --git a/internal/deployserverclient/.speakeasy/workflow.lock b/internal/deployserverclient/.speakeasy/workflow.lock index 9f9c6701..09e84e87 100644 --- a/internal/deployserverclient/.speakeasy/workflow.lock +++ b/internal/deployserverclient/.speakeasy/workflow.lock @@ -1,4 +1,4 @@ -speakeasyVersion: 1.658.1 +speakeasyVersion: 1.661.3 sources: Terraform HCP Proxy API: sourceNamespace: terraform-hcp-proxy-api @@ -14,7 +14,7 @@ targets: sourceRevisionDigest: sha256:f1310732b16a83ea2f109d4f78830715d57879609c64cb722782adccfe9fc973 sourceBlobDigest: sha256:a9f26be0b3f3ff302cde5d9e04d9b78d5d06d1971e2848ad8257d99519805095 codeSamplesNamespace: terraform-hcp-proxy-api-go-code-samples - codeSamplesRevisionDigest: sha256:69490bd38fedac0128b4e128460f37a8aa96a16ee8afe2c271637692d4072c99 + codeSamplesRevisionDigest: sha256:5b2c663d0f9c0e686d67f3d231057173135ec77c887be5edb0abb6cadaa5a910 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/internal/deployserverclient/deployserver.go b/internal/deployserverclient/deployserver.go index a5c93608..56f0753a 100644 --- a/internal/deployserverclient/deployserver.go +++ b/internal/deployserverclient/deployserver.go @@ -2,7 +2,7 @@ package deployserverclient -// Generated from OpenAPI doc version 0.1.0 and generator version 2.755.6 +// Generated from OpenAPI doc version 0.1.0 and generator version 2.763.3 import ( "bytes" @@ -119,7 +119,7 @@ func New(opts ...SDKOption) *DeployServer { sdk := &DeployServer{ SDKVersion: "0.0.1", sdkConfiguration: config.SDKConfiguration{ - UserAgent: "speakeasy-sdk/go 0.0.1 2.755.6 0.1.0 github.com/formancehq/fctl/internal/deployserverclient", + UserAgent: "speakeasy-sdk/go 0.0.1 2.763.3 0.1.0 github.com/formancehq/fctl/internal/deployserverclient", ServerList: ServerList, }, hooks: hooks.New(), diff --git a/internal/deployserverclient/internal/utils/json.go b/internal/deployserverclient/internal/utils/json.go index 37fb2d5e..2de6c8e6 100644 --- a/internal/deployserverclient/internal/utils/json.go +++ b/internal/deployserverclient/internal/utils/json.go @@ -658,17 +658,23 @@ func CalculateJSONSize(v interface{}) int { // UnionCandidate represents a candidate type during union deserialization type UnionCandidate struct { - FieldCount int - Size int - Type any // The union type enum value - Value any // The unmarshaled value + FieldCount int + InexactCount int // Count of fields with unknown/unrecognized enum values + Size int + Type any // The union type enum value + Value any // The unmarshaled value } -// CountFields recursively counts the number of valid (non-nil, non-zero) fields set in a value. -// This is used as the primary discriminator for union types, with JSON size as a tiebreaker. -func CountFields(v interface{}) int { +// FieldCounts holds the result of counting fields in a value +type FieldCounts struct { + Total int // Total number of populated fields + Inexact int // Number of fields with unknown/unrecognized open enum values +} + +// CountFieldsWithInexact recursively counts fields and tracks inexact matches (unknown open enum values). +func CountFieldsWithInexact(v interface{}) FieldCounts { if v == nil { - return 0 + return FieldCounts{} } typ := reflect.TypeOf(v) @@ -677,7 +683,7 @@ func CountFields(v interface{}) int { // Dereference pointers for typ.Kind() == reflect.Ptr { if val.IsNil() { - return 0 + return FieldCounts{} } typ = typ.Elem() val = val.Elem() @@ -688,8 +694,9 @@ func CountFields(v interface{}) int { // PickBestCandidate selects the best union type candidate using a multi-stage filtering approach: // 1. If multiple candidates, filter by field count (keep only those with max field count) -// 2. If still multiple, filter by JSON size (keep only those with max size) -// 3. Return the first remaining candidate +// 2. If still multiple, filter by inexact count (keep only those with min inexact count) +// 3. If still multiple, filter by JSON size (keep only those with max size) +// 4. Return the first remaining candidate func PickBestCandidate(candidates []UnionCandidate) *UnionCandidate { if len(candidates) == 0 { return nil @@ -703,7 +710,9 @@ func PickBestCandidate(candidates []UnionCandidate) *UnionCandidate { if len(candidates) > 1 { maxFieldCount := -1 for i := range candidates { - candidates[i].FieldCount = CountFields(candidates[i].Value) + fieldCounts := CountFieldsWithInexact(candidates[i].Value) + candidates[i].FieldCount = fieldCounts.Total + candidates[i].InexactCount = fieldCounts.Inexact if candidates[i].FieldCount > maxFieldCount { maxFieldCount = candidates[i].FieldCount } @@ -723,6 +732,30 @@ func PickBestCandidate(candidates []UnionCandidate) *UnionCandidate { return &candidates[0] } + // Filter by inexact count if we still have multiple candidates + // Prefer candidates with fewer unknown/unrecognized enum values + if len(candidates) > 1 { + minInexactCount := int(^uint(0) >> 1) // max int + for _, c := range candidates { + if c.InexactCount < minInexactCount { + minInexactCount = c.InexactCount + } + } + + // Keep only candidates with minimum inexact count + filtered := make([]UnionCandidate, 0, len(candidates)) + for _, c := range candidates { + if c.InexactCount == minInexactCount { + filtered = append(filtered, c) + } + } + candidates = filtered + } + + if len(candidates) == 1 { + return &candidates[0] + } + // Filter by JSON size if we still have multiple candidates if len(candidates) > 1 { maxSize := -1 @@ -747,8 +780,25 @@ func PickBestCandidate(candidates []UnionCandidate) *UnionCandidate { return &candidates[0] } -func countFieldsRecursive(typ reflect.Type, val reflect.Value) int { - count := 0 +func countFieldsRecursive(typ reflect.Type, val reflect.Value) FieldCounts { + counts := FieldCounts{} + + // Check if the value has an IsExact() method (for open enums) + // Try both the value and its pointer + if val.CanInterface() && val.CanAddr() { + ptrVal := val.Addr() + if method := ptrVal.MethodByName("IsExact"); method.IsValid() { + results := method.Call(nil) + if len(results) == 1 && results[0].Kind() == reflect.Bool { + isExact := results[0].Bool() + counts.Total = 1 + if !isExact { + counts.Inexact = 1 // Unknown enum value + } + return counts + } + } + } switch typ.Kind() { case reflect.Struct: @@ -756,18 +806,18 @@ func countFieldsRecursive(typ reflect.Type, val reflect.Value) int { switch typ { case reflect.TypeOf(time.Time{}): if !val.Interface().(time.Time).IsZero() { - return 1 + return FieldCounts{Total: 1} } - return 0 + return FieldCounts{} case reflect.TypeOf(big.Int{}): b := val.Interface().(big.Int) if b.Sign() != 0 { - return 1 + return FieldCounts{Total: 1} } - return 0 + return FieldCounts{} case reflect.TypeOf(types.Date{}): // Date is always counted if it exists - return 1 + return FieldCounts{Total: 1} } // For regular structs, count non-zero fields @@ -797,13 +847,15 @@ func countFieldsRecursive(typ reflect.Type, val reflect.Value) int { } if !isNil(field.Type, val.Field(i)) { - count += countFieldsRecursive(fieldTyp, fieldVal) + fieldCounts := countFieldsRecursive(fieldTyp, fieldVal) + counts.Total += fieldCounts.Total + counts.Inexact += fieldCounts.Inexact } } case reflect.Slice, reflect.Array: if val.IsNil() || val.Len() == 0 { - return 0 + return FieldCounts{} } // Count each array/slice element for i := 0; i < val.Len(); i++ { @@ -820,40 +872,42 @@ func countFieldsRecursive(typ reflect.Type, val reflect.Value) int { } if !isNil(itemTyp, itemVal) { - count += countFieldsRecursive(itemTyp, itemVal) + itemCounts := countFieldsRecursive(itemTyp, itemVal) + counts.Total += itemCounts.Total + counts.Inexact += itemCounts.Inexact } } case reflect.String: if val.String() != "" { - count = 1 + counts.Total = 1 } case reflect.Bool: // Bools always count as a field (even if false) - count = 1 + counts.Total = 1 case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: if val.Int() != 0 { - count = 1 + counts.Total = 1 } case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: if val.Uint() != 0 { - count = 1 + counts.Total = 1 } case reflect.Float32, reflect.Float64: if val.Float() != 0 { - count = 1 + counts.Total = 1 } default: // For any other type, if it's not zero, count it as 1 if !val.IsZero() { - count = 1 + counts.Total = 1 } } - return count + return counts } diff --git a/internal/membershipclient/.gitattributes b/internal/membershipclient/.gitattributes new file mode 100644 index 00000000..e6a99441 --- /dev/null +++ b/internal/membershipclient/.gitattributes @@ -0,0 +1,2 @@ +# This allows generated code to be indexed correctly +*.go linguist-generated=false \ No newline at end of file diff --git a/internal/membershipclient/.gitignore b/internal/membershipclient/.gitignore new file mode 100644 index 00000000..3bbfa14c --- /dev/null +++ b/internal/membershipclient/.gitignore @@ -0,0 +1,7 @@ +# .gitignore +.DS_Store +**/.speakeasy/temp/ +**/.speakeasy/logs/ +.speakeasy/reports +.env +.env.local diff --git a/internal/membershipclient/.speakeasy/gen.lock b/internal/membershipclient/.speakeasy/gen.lock new file mode 100644 index 00000000..3a245fb4 --- /dev/null +++ b/internal/membershipclient/.speakeasy/gen.lock @@ -0,0 +1,1197 @@ +lockVersion: 2.0.0 +id: 61dd85f3-592f-465f-a3c4-a3f10e3e6f10 +management: + docChecksum: 2261488416352a021f4f1e4aee627d0a + docVersion: 0.1.0 + speakeasyVersion: 1.661.3 + generationVersion: 2.763.3 + releaseVersion: 0.1.0 + configChecksum: 76c0e45e65b5c931b8995565a01160b1 +features: + go: + additionalDependencies: 0.1.0 + constsAndDefaults: 0.1.12 + core: 3.13.3 + defaultEnabledRetries: 0.2.0 + deprecations: 2.81.3 + envVarSecurityUsage: 0.3.2 + globalSecurity: 2.82.12 + globalSecurityCallbacks: 0.1.0 + globalSecurityFlattening: 0.1.0 + globalServerURLs: 2.83.0 + intellisenseMarkdownSupport: 0.1.0 + nullables: 0.2.1 + responseFormat: 0.1.2 + retries: 2.84.2 + sdkHooks: 0.2.0 + unions: 2.87.2 +generatedFiles: + - .gitattributes + - /models/apierrors/error.go + - /models/components/action.go + - /models/components/anyregion.go + - /models/components/application.go + - /models/components/applicationdata.go + - /models/components/applicationwithscope.go + - /models/components/authenticationproviderdata.go + - /models/components/authenticationproviderresponse.go + - /models/components/capability.go + - /models/components/createapplicationresponse.go + - /models/components/createapplicationscoperequest.go + - /models/components/createapplicationscoperesponse.go + - /models/components/createclientresponseresponse.go + - /models/components/createdprivateregionresponse.go + - /models/components/createinvitationresponse.go + - /models/components/createorganizationclientrequest.go + - /models/components/createorganizationclientresponse.go + - /models/components/createorganizationrequest.go + - /models/components/createorganizationresponse.go + - /models/components/createpolicyresponse.go + - /models/components/createprivateregionrequest.go + - /models/components/createstackrequest.go + - /models/components/createstackresponse.go + - /models/components/createuserrequest.go + - /models/components/createuserresponse.go + - /models/components/enableapplicationfororganizationresponse.go + - /models/components/error.go + - /models/components/getapplicationresponse.go + - /models/components/getregionresponse.go + - /models/components/getregionversionsresponse.go + - /models/components/httpmetadata.go + - /models/components/invitation.go + - /models/components/listapplicationsresponse.go + - /models/components/listinvitationsresponse.go + - /models/components/listmodulesresponse.go + - /models/components/listorganizationexpandedresponse.go + - /models/components/listpoliciesresponse.go + - /models/components/listregionsresponse.go + - /models/components/liststacksresponse.go + - /models/components/listusersresponse.go + - /models/components/log.go + - /models/components/logcursor.go + - /models/components/module.go + - /models/components/organizationapplication.go + - /models/components/organizationclient.go + - /models/components/organizationdata.go + - /models/components/organizationexpanded.go + - /models/components/organizationfeature.go + - /models/components/policy.go + - /models/components/policydata.go + - /models/components/privateregion.go + - /models/components/privateregionsecret.go + - /models/components/readorganizationclientresponse.go + - /models/components/readorganizationclientsresponse.go + - /models/components/readorganizationresponse.go + - /models/components/readorganizationuserresponse.go + - /models/components/readpolicyresponse.go + - /models/components/readstackuseraccess.go + - /models/components/readuserresponse.go + - /models/components/region.go + - /models/components/regioncapability.go + - /models/components/scope.go + - /models/components/security.go + - /models/components/serverinfo.go + - /models/components/stack.go + - /models/components/stackdata.go + - /models/components/stackuseraccessresponse.go + - /models/components/stackversion.go + - /models/components/systemrole.go + - /models/components/updateapplicationresponse.go + - /models/components/updateorganizationclientrequest.go + - /models/components/updateorganizationuserrequest.go + - /models/components/updatepolicyresponse.go + - /models/components/updatestackuserrequest.go + - /models/components/user.go + - /models/components/version.go + - /models/operations/acceptinvitation.go + - /models/operations/addfeatures.go + - /models/operations/addscopetopolicy.go + - /models/operations/createapplication.go + - /models/operations/createapplicationscope.go + - /models/operations/createinvitation.go + - /models/operations/createorganization.go + - /models/operations/createorganizationclient.go + - /models/operations/createpolicy.go + - /models/operations/createprivateregion.go + - /models/operations/createstack.go + - /models/operations/createuser.go + - /models/operations/declineinvitation.go + - /models/operations/deleteapplication.go + - /models/operations/deleteapplicationscope.go + - /models/operations/deleteauthenticationprovider.go + - /models/operations/deletefeature.go + - /models/operations/deleteinvitation.go + - /models/operations/deleteorganization.go + - /models/operations/deleteorganizationclient.go + - /models/operations/deletepolicy.go + - /models/operations/deleteregion.go + - /models/operations/deletestack.go + - /models/operations/deletestackuseraccess.go + - /models/operations/deleteuserfromorganization.go + - /models/operations/disableapplicationfororganization.go + - /models/operations/disablemodule.go + - /models/operations/disablestack.go + - /models/operations/disablestargate.go + - /models/operations/enableapplicationfororganization.go + - /models/operations/enablemodule.go + - /models/operations/enablestack.go + - /models/operations/enablestargate.go + - /models/operations/getapplication.go + - /models/operations/getorganizationapplication.go + - /models/operations/getregion.go + - /models/operations/getregionversions.go + - /models/operations/getserverinfo.go + - /models/operations/getstack.go + - /models/operations/listapplications.go + - /models/operations/listfeatures.go + - /models/operations/listinvitations.go + - /models/operations/listlogs.go + - /models/operations/listmodules.go + - /models/operations/listorganizationapplications.go + - /models/operations/listorganizationinvitations.go + - /models/operations/listorganizations.go + - /models/operations/listorganizationsexpanded.go + - /models/operations/listpolicies.go + - /models/operations/listregions.go + - /models/operations/liststacks.go + - /models/operations/liststackusersaccesses.go + - /models/operations/listusersoforganization.go + - /models/operations/organizationclientcreate.go + - /models/operations/organizationclientdelete.go + - /models/operations/organizationclientread.go + - /models/operations/organizationclientsread.go + - /models/operations/organizationclientupdate.go + - /models/operations/readauthenticationprovider.go + - /models/operations/readconnecteduser.go + - /models/operations/readorganization.go + - /models/operations/readorganizationclient.go + - /models/operations/readpolicy.go + - /models/operations/readstackuseraccess.go + - /models/operations/readuseroforganization.go + - /models/operations/removescopefrompolicy.go + - /models/operations/restorestack.go + - /models/operations/updateapplication.go + - /models/operations/updateorganization.go + - /models/operations/updatepolicy.go + - /models/operations/updatestack.go + - /models/operations/upgradestack.go + - /models/operations/upsertauthenticationprovider.go + - /models/operations/upsertorganizationuser.go + - /models/operations/upsertstackuseraccess.go + - USAGE.md + - docs/models/apierrors/error.md + - docs/models/components/action.md + - docs/models/components/anyregion.md + - docs/models/components/application.md + - docs/models/components/applicationdata.md + - docs/models/components/applicationwithscope.md + - docs/models/components/authenticationproviderdata.md + - docs/models/components/authenticationproviderdatagithubidpconfig.md + - docs/models/components/authenticationproviderdatagithubidpconfigconfig.md + - docs/models/components/authenticationproviderdatagithubidpconfigtype.md + - docs/models/components/authenticationproviderdatagoogleidpconfig.md + - docs/models/components/authenticationproviderdatagoogleidpconfigconfig.md + - docs/models/components/authenticationproviderdatagoogleidpconfigtype.md + - docs/models/components/authenticationproviderdatamicrosoftidpconfig.md + - docs/models/components/authenticationproviderdatamicrosoftidpconfigconfig.md + - docs/models/components/authenticationproviderdatamicrosoftidpconfigtype.md + - docs/models/components/authenticationproviderdataoidcconfig.md + - docs/models/components/authenticationproviderdataoidcconfigconfig.md + - docs/models/components/authenticationproviderdataoidcconfigtype.md + - docs/models/components/authenticationproviderresponse.md + - docs/models/components/authenticationproviderresponsegithubidpconfig.md + - docs/models/components/authenticationproviderresponsegithubidpconfigconfig.md + - docs/models/components/authenticationproviderresponsegithubidpconfigtype.md + - docs/models/components/authenticationproviderresponsegoogleidpconfig.md + - docs/models/components/authenticationproviderresponsegoogleidpconfigconfig.md + - docs/models/components/authenticationproviderresponsegoogleidpconfigtype.md + - docs/models/components/authenticationproviderresponsemicrosoftidpconfig.md + - docs/models/components/authenticationproviderresponsemicrosoftidpconfigconfig.md + - docs/models/components/authenticationproviderresponsemicrosoftidpconfigtype.md + - docs/models/components/authenticationproviderresponseoidcconfig.md + - docs/models/components/authenticationproviderresponseoidcconfigconfig.md + - docs/models/components/authenticationproviderresponseoidcconfigtype.md + - docs/models/components/capability.md + - docs/models/components/clusterstatus.md + - docs/models/components/createapplicationresponse.md + - docs/models/components/createapplicationscoperequest.md + - docs/models/components/createapplicationscoperesponse.md + - docs/models/components/createclientresponseresponse.md + - docs/models/components/createclientresponseresponsedata.md + - docs/models/components/createclientresponseresponsesecret.md + - docs/models/components/createdprivateregionresponse.md + - docs/models/components/createinvitationresponse.md + - docs/models/components/createorganizationclientrequest.md + - docs/models/components/createorganizationclientresponse.md + - docs/models/components/createorganizationrequest.md + - docs/models/components/createorganizationresponse.md + - docs/models/components/createpolicyresponse.md + - docs/models/components/createprivateregionrequest.md + - docs/models/components/createstackrequest.md + - docs/models/components/createstackresponse.md + - docs/models/components/createuserrequest.md + - docs/models/components/createuserresponse.md + - docs/models/components/cursor.md + - docs/models/components/data.md + - docs/models/components/enableapplicationfororganizationresponse.md + - docs/models/components/error.md + - docs/models/components/expectedstatus.md + - docs/models/components/getapplicationresponse.md + - docs/models/components/getregionresponse.md + - docs/models/components/getregionversionsresponse.md + - docs/models/components/httpmetadata.md + - docs/models/components/invitation.md + - docs/models/components/invitationstatus.md + - docs/models/components/listapplicationsresponse.md + - docs/models/components/listinvitationsresponse.md + - docs/models/components/listmodulesresponse.md + - docs/models/components/listorganizationexpandedresponse.md + - docs/models/components/listpoliciesresponse.md + - docs/models/components/listregionsresponse.md + - docs/models/components/liststacksresponse.md + - docs/models/components/listusersresponse.md + - docs/models/components/log.md + - docs/models/components/logcursor.md + - docs/models/components/logcursordata.md + - docs/models/components/logdata.md + - docs/models/components/module.md + - docs/models/components/modulestate.md + - docs/models/components/modulestatus.md + - docs/models/components/organizationaccess.md + - docs/models/components/organizationapplication.md + - docs/models/components/organizationclient.md + - docs/models/components/organizationclientsecret.md + - docs/models/components/organizationdata.md + - docs/models/components/organizationexpanded.md + - docs/models/components/organizationfeature.md + - docs/models/components/organizationuser.md + - docs/models/components/policy.md + - docs/models/components/policydata.md + - docs/models/components/privateregion.md + - docs/models/components/privateregionsecret.md + - docs/models/components/readorganizationclientresponse.md + - docs/models/components/readorganizationclientsresponse.md + - docs/models/components/readorganizationclientsresponsedata.md + - docs/models/components/readorganizationresponse.md + - docs/models/components/readorganizationuserresponse.md + - docs/models/components/readorganizationuserresponsedata.md + - docs/models/components/readpolicyresponse.md + - docs/models/components/readstackuseraccess.md + - docs/models/components/readstackuseraccessdata.md + - docs/models/components/readuserresponse.md + - docs/models/components/region.md + - docs/models/components/regioncapability.md + - docs/models/components/scope.md + - docs/models/components/security.md + - docs/models/components/serverinfo.md + - docs/models/components/stack.md + - docs/models/components/stackdata.md + - docs/models/components/stackstate.md + - docs/models/components/stackstatus.md + - docs/models/components/stackuseraccessresponse.md + - docs/models/components/stackuseraccessresponsedata.md + - docs/models/components/stackversion.md + - docs/models/components/systemrole.md + - docs/models/components/updateapplicationresponse.md + - docs/models/components/updateorganizationclientrequest.md + - docs/models/components/updateorganizationuserrequest.md + - docs/models/components/updatepolicyresponse.md + - docs/models/components/updatestackuserrequest.md + - docs/models/components/user.md + - docs/models/components/version.md + - docs/models/operations/acceptinvitationrequest.md + - docs/models/operations/acceptinvitationresponse.md + - docs/models/operations/addfeaturesrequest.md + - docs/models/operations/addfeaturesrequestbody.md + - docs/models/operations/addfeaturesresponse.md + - docs/models/operations/addscopetopolicyrequest.md + - docs/models/operations/addscopetopolicyresponse.md + - docs/models/operations/createapplicationresponse.md + - docs/models/operations/createapplicationscoperequest.md + - docs/models/operations/createapplicationscoperesponse.md + - docs/models/operations/createinvitationrequest.md + - docs/models/operations/createinvitationresponse.md + - docs/models/operations/createorganizationclientrequest.md + - docs/models/operations/createorganizationclientresponse.md + - docs/models/operations/createorganizationresponse.md + - docs/models/operations/createpolicyrequest.md + - docs/models/operations/createpolicyresponse.md + - docs/models/operations/createprivateregionrequest.md + - docs/models/operations/createprivateregionresponse.md + - docs/models/operations/createstackrequest.md + - docs/models/operations/createstackresponse.md + - docs/models/operations/createuserresponse.md + - docs/models/operations/declineinvitationrequest.md + - docs/models/operations/declineinvitationresponse.md + - docs/models/operations/deleteapplicationrequest.md + - docs/models/operations/deleteapplicationresponse.md + - docs/models/operations/deleteapplicationscoperequest.md + - docs/models/operations/deleteapplicationscoperesponse.md + - docs/models/operations/deleteauthenticationproviderrequest.md + - docs/models/operations/deleteauthenticationproviderresponse.md + - docs/models/operations/deletefeaturerequest.md + - docs/models/operations/deletefeatureresponse.md + - docs/models/operations/deleteinvitationrequest.md + - docs/models/operations/deleteinvitationresponse.md + - docs/models/operations/deleteorganizationclientrequest.md + - docs/models/operations/deleteorganizationclientresponse.md + - docs/models/operations/deleteorganizationrequest.md + - docs/models/operations/deleteorganizationresponse.md + - docs/models/operations/deletepolicyrequest.md + - docs/models/operations/deletepolicyresponse.md + - docs/models/operations/deleteregionrequest.md + - docs/models/operations/deleteregionresponse.md + - docs/models/operations/deletestackrequest.md + - docs/models/operations/deletestackresponse.md + - docs/models/operations/deletestackuseraccessrequest.md + - docs/models/operations/deletestackuseraccessresponse.md + - docs/models/operations/deleteuserfromorganizationrequest.md + - docs/models/operations/deleteuserfromorganizationresponse.md + - docs/models/operations/disableapplicationfororganizationrequest.md + - docs/models/operations/disableapplicationfororganizationresponse.md + - docs/models/operations/disablemodulerequest.md + - docs/models/operations/disablemoduleresponse.md + - docs/models/operations/disablestackrequest.md + - docs/models/operations/disablestackresponse.md + - docs/models/operations/disablestargaterequest.md + - docs/models/operations/disablestargateresponse.md + - docs/models/operations/enableapplicationfororganizationrequest.md + - docs/models/operations/enableapplicationfororganizationresponse.md + - docs/models/operations/enablemodulerequest.md + - docs/models/operations/enablemoduleresponse.md + - docs/models/operations/enablestackrequest.md + - docs/models/operations/enablestackresponse.md + - docs/models/operations/enablestargaterequest.md + - docs/models/operations/enablestargateresponse.md + - docs/models/operations/getapplicationrequest.md + - docs/models/operations/getapplicationresponse.md + - docs/models/operations/getorganizationapplicationrequest.md + - docs/models/operations/getorganizationapplicationresponse.md + - docs/models/operations/getregionrequest.md + - docs/models/operations/getregionresponse.md + - docs/models/operations/getregionversionsrequest.md + - docs/models/operations/getregionversionsresponse.md + - docs/models/operations/getserverinforesponse.md + - docs/models/operations/getstackrequest.md + - docs/models/operations/getstackresponse.md + - docs/models/operations/listapplicationsresponse.md + - docs/models/operations/listfeaturesrequest.md + - docs/models/operations/listfeaturesresponse.md + - docs/models/operations/listfeaturesresponsebody.md + - docs/models/operations/listinvitationsrequest.md + - docs/models/operations/listinvitationsresponse.md + - docs/models/operations/listlogsrequest.md + - docs/models/operations/listlogsresponse.md + - docs/models/operations/listmodulesrequest.md + - docs/models/operations/listmodulesresponse.md + - docs/models/operations/listorganizationapplicationsrequest.md + - docs/models/operations/listorganizationapplicationsresponse.md + - docs/models/operations/listorganizationinvitationsrequest.md + - docs/models/operations/listorganizationinvitationsresponse.md + - docs/models/operations/listorganizationsexpandedresponse.md + - docs/models/operations/listorganizationsrequest.md + - docs/models/operations/listorganizationsresponse.md + - docs/models/operations/listpoliciesrequest.md + - docs/models/operations/listpoliciesresponse.md + - docs/models/operations/listregionsrequest.md + - docs/models/operations/listregionsresponse.md + - docs/models/operations/liststacksrequest.md + - docs/models/operations/liststacksresponse.md + - docs/models/operations/liststackusersaccessesrequest.md + - docs/models/operations/liststackusersaccessesresponse.md + - docs/models/operations/listusersoforganizationrequest.md + - docs/models/operations/listusersoforganizationresponse.md + - docs/models/operations/option.md + - docs/models/operations/organizationclientcreaterequest.md + - docs/models/operations/organizationclientcreateresponse.md + - docs/models/operations/organizationclientdeleterequest.md + - docs/models/operations/organizationclientdeleteresponse.md + - docs/models/operations/organizationclientreadrequest.md + - docs/models/operations/organizationclientreadresponse.md + - docs/models/operations/organizationclientsreadrequest.md + - docs/models/operations/organizationclientsreadresponse.md + - docs/models/operations/organizationclientupdaterequest.md + - docs/models/operations/organizationclientupdateresponse.md + - docs/models/operations/readauthenticationproviderrequest.md + - docs/models/operations/readauthenticationproviderresponse.md + - docs/models/operations/readconnecteduserresponse.md + - docs/models/operations/readorganizationclientrequest.md + - docs/models/operations/readorganizationclientresponse.md + - docs/models/operations/readorganizationrequest.md + - docs/models/operations/readorganizationresponse.md + - docs/models/operations/readpolicyrequest.md + - docs/models/operations/readpolicyresponse.md + - docs/models/operations/readstackuseraccessrequest.md + - docs/models/operations/readstackuseraccessresponse.md + - docs/models/operations/readuseroforganizationrequest.md + - docs/models/operations/readuseroforganizationresponse.md + - docs/models/operations/removescopefrompolicyrequest.md + - docs/models/operations/removescopefrompolicyresponse.md + - docs/models/operations/restorestackrequest.md + - docs/models/operations/restorestackresponse.md + - docs/models/operations/updateapplicationrequest.md + - docs/models/operations/updateapplicationresponse.md + - docs/models/operations/updateorganizationrequest.md + - docs/models/operations/updateorganizationresponse.md + - docs/models/operations/updatepolicyrequest.md + - docs/models/operations/updatepolicyresponse.md + - docs/models/operations/updatestackrequest.md + - docs/models/operations/updatestackresponse.md + - docs/models/operations/upgradestackrequest.md + - docs/models/operations/upgradestackresponse.md + - docs/models/operations/upsertauthenticationproviderrequest.md + - docs/models/operations/upsertauthenticationproviderresponse.md + - docs/models/operations/upsertorganizationuserrequest.md + - docs/models/operations/upsertorganizationuserresponse.md + - docs/models/operations/upsertstackuseraccessrequest.md + - docs/models/operations/upsertstackuseraccessresponse.md + - docs/sdks/sdk/README.md + - go.mod + - internal/config/sdkconfiguration.go + - internal/hooks/hooks.go + - internal/utils/contenttype.go + - internal/utils/env.go + - internal/utils/form.go + - internal/utils/headers.go + - internal/utils/json.go + - internal/utils/pathparams.go + - internal/utils/queryparams.go + - internal/utils/requestbody.go + - internal/utils/retries.go + - internal/utils/security.go + - internal/utils/utils.go + - models/apierrors/apierror.go + - models/operations/options.go + - optionalnullable/optionalnullable.go + - optionalnullable/optionalnullable_test.go + - retry/config.go + - sdk.go + - types/bigint.go + - types/date.go + - types/datetime.go + - types/pointers.go +examples: + getServerInfo: + speakeasy-default-get-server-info: + responses: + "200": + application/json: {"version": ""} + default: + application/json: {"errorCode": ""} + listOrganizations: + speakeasy-default-list-organizations: + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + createOrganization: + speakeasy-default-create-organization: + responses: + "201": + application/json: {} + default: + application/json: {"errorCode": ""} + listOrganizationsExpanded: + speakeasy-default-list-organizations-expanded: + responses: + "200": + application/json: {} + readOrganization: + speakeasy-default-read-organization: + parameters: + path: + organizationId: "" + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + updateOrganization: + speakeasy-default-update-organization: + parameters: + path: + organizationId: "" + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + deleteOrganization: + speakeasy-default-delete-organization: + parameters: + path: + organizationId: "" + responses: + default: + application/json: {"errorCode": ""} + readAuthenticationProvider: + speakeasy-default-read-authentication-provider: + parameters: + path: + organizationId: "" + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + upsertAuthenticationProvider: + speakeasy-default-upsert-authentication-provider: + parameters: + path: + organizationId: "" + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + deleteAuthenticationProvider: + speakeasy-default-delete-authentication-provider: + parameters: + path: + organizationId: "" + responses: + default: + application/json: {"errorCode": ""} + listFeatures: + speakeasy-default-list-features: + parameters: + path: + organizationId: "" + responses: + "200": + application/json: {"data": [{"organizationID": "", "name": "", "createdAt": "2025-11-09T12:05:56.871Z"}]} + default: + application/json: {"errorCode": ""} + addFeatures: + speakeasy-default-add-features: + parameters: + path: + organizationId: "" + responses: + default: + application/json: {"errorCode": ""} + deleteFeature: + speakeasy-default-delete-feature: + parameters: + path: + organizationId: "" + name: "" + responses: + default: + application/json: {"errorCode": ""} + readOrganizationClient: + speakeasy-default-read-organization-client: + parameters: + path: + organizationId: "" + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + createOrganizationClient: + speakeasy-default-create-organization-client: + parameters: + path: + organizationId: "" + responses: + "201": + application/json: {} + default: + application/json: {"errorCode": ""} + deleteOrganizationClient: + speakeasy-default-delete-organization-client: + parameters: + path: + organizationId: "" + responses: + default: + application/json: {"errorCode": ""} + organizationClientsRead: + speakeasy-default-organization-clients-read: + parameters: + path: + organizationId: "" + responses: + "200": + application/json: {"data": {"pageSize": 15, "hasMore": false, "previous": "YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol=", "next": "", "data": [{"id": "", "secret": {"lastDigits": ""}, "name": "", "description": "even furthermore sarcastic at tinderbox resort guacamole incandescence redound than", "createdAt": "2024-10-01T11:29:19.916Z", "updatedAt": "2024-12-23T20:03:23.769Z"}]}} + default: + application/json: {"errorCode": ""} + organizationClientCreate: + speakeasy-default-organization-client-create: + parameters: + path: + organizationId: "" + responses: + "201": + application/json: {"data": {"id": "", "secret": {"lastDigits": ""}, "name": "", "description": "reclassify rapid likewise separate carp pish upsell quintuple", "createdAt": "2024-01-13T09:33:21.504Z", "updatedAt": "2023-08-27T21:07:22.984Z"}} + default: + application/json: {"errorCode": ""} + organizationClientRead: + speakeasy-default-organization-client-read: + parameters: + path: + organizationId: "" + clientId: "" + responses: + "200": + application/json: {"data": {"id": "", "secret": {"lastDigits": ""}, "name": "", "description": "oh solution gosh amid nor orient narrate within gah fooey", "createdAt": "2025-05-24T11:12:14.293Z", "updatedAt": "2024-11-19T21:20:10.690Z"}} + default: + application/json: {"errorCode": ""} + organizationClientDelete: + speakeasy-default-organization-client-delete: + parameters: + path: + organizationId: "" + clientId: "" + responses: + default: + application/json: {"errorCode": ""} + organizationClientUpdate: + speakeasy-default-organization-client-update: + parameters: + path: + organizationId: "" + clientId: "" + responses: + default: + application/json: {"errorCode": ""} + listLogs: + speakeasy-default-list-logs: + parameters: + path: + organizationId: "" + responses: + "200": + application/json: {"data": {"pageSize": 15, "hasMore": false, "previous": "YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol=", "next": "", "data": [{"seq": "1e6f8b6e-1b6b-4b3b-8b3b-1b6b4b3b8b3b", "organizationId": "", "userId": "", "action": "", "date": "2024-08-30T19:05:54.946Z", "data": {}}]}} + default: + application/json: {"errorCode": ""} + listUsersOfOrganization: + speakeasy-default-list-users-of-organization: + parameters: + path: + organizationId: "" + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + readUserOfOrganization: + speakeasy-default-read-user-of-organization: + parameters: + path: + organizationId: "" + userId: "" + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + upsertOrganizationUser: + speakeasy-default-upsert-organization-user: + parameters: + path: + organizationId: "" + userId: "" + responses: + default: + application/json: {"errorCode": ""} + deleteUserFromOrganization: + speakeasy-default-delete-user-from-organization: + parameters: + path: + organizationId: "" + userId: "" + responses: + default: + application/json: {"errorCode": ""} + listPolicies: + speakeasy-default-list-policies: + parameters: + path: + organizationId: "" + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + createPolicy: + speakeasy-default-create-policy: + parameters: + path: + organizationId: "" + responses: + "201": + application/json: {} + default: + application/json: {"errorCode": ""} + readPolicy: + speakeasy-default-read-policy: + parameters: + path: + organizationId: "" + policyId: 831591 + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + updatePolicy: + speakeasy-default-update-policy: + parameters: + path: + organizationId: "" + policyId: 127460 + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + deletePolicy: + speakeasy-default-delete-policy: + parameters: + path: + organizationId: "" + policyId: 114294 + responses: + default: + application/json: {"errorCode": ""} + addScopeToPolicy: + speakeasy-default-add-scope-to-policy: + parameters: + path: + organizationId: "" + policyId: 328027 + scopeId: 675877 + responses: + default: + application/json: {"errorCode": ""} + removeScopeFromPolicy: + speakeasy-default-remove-scope-from-policy: + parameters: + path: + organizationId: "" + policyId: 995736 + scopeId: 485996 + responses: + default: + application/json: {"errorCode": ""} + listStacks: + speakeasy-default-list-stacks: + parameters: + path: + organizationId: "" + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + createStack: + speakeasy-default-create-stack: + parameters: + path: + organizationId: "" + responses: + "202": + application/json: {} + default: + application/json: {"errorCode": ""} + listModules: + speakeasy-default-list-modules: + parameters: + path: + organizationId: "" + stackId: "" + responses: + "200": + application/json: {"data": []} + default: + application/json: {"errorCode": ""} + enableModule: + speakeasy-default-enable-module: + parameters: + path: + organizationId: "" + stackId: "" + query: + name: "" + responses: + default: + application/json: {"errorCode": ""} + disableModule: + speakeasy-default-disable-module: + parameters: + path: + organizationId: "" + stackId: "" + query: + name: "" + responses: + default: + application/json: {"errorCode": ""} + upgradeStack: + speakeasy-default-upgrade-stack: + parameters: + path: + organizationId: "" + stackId: "" + responses: + default: + application/json: {"errorCode": ""} + getStack: + speakeasy-default-get-stack: + parameters: + path: + organizationId: "" + stackId: "" + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + updateStack: + speakeasy-default-update-stack: + parameters: + path: + organizationId: "" + stackId: "" + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + deleteStack: + speakeasy-default-delete-stack: + parameters: + path: + organizationId: "" + stackId: "" + responses: + default: + application/json: {"errorCode": ""} + listStackUsersAccesses: + speakeasy-default-list-stack-users-accesses: + parameters: + path: + organizationId: "" + stackId: "" + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + readStackUserAccess: + speakeasy-default-read-stack-user-access: + parameters: + path: + organizationId: "" + stackId: "" + userId: "" + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + deleteStackUserAccess: + speakeasy-default-delete-stack-user-access: + parameters: + path: + organizationId: "" + stackId: "" + userId: "" + responses: + default: + application/json: {"errorCode": ""} + upsertStackUserAccess: + speakeasy-default-upsert-stack-user-access: + parameters: + path: + organizationId: "" + stackId: "" + userId: "" + responses: + default: + application/json: {"errorCode": ""} + disableStack: + speakeasy-default-disable-stack: + parameters: + path: + organizationId: "" + stackId: "" + responses: + default: + application/json: {"errorCode": ""} + enableStack: + speakeasy-default-enable-stack: + parameters: + path: + organizationId: "" + stackId: "" + responses: + default: + application/json: {"errorCode": ""} + restoreStack: + speakeasy-default-restore-stack: + parameters: + path: + organizationId: "" + stackId: "" + responses: + "202": + application/json: {} + default: + application/json: {"errorCode": ""} + enableStargate: + speakeasy-default-enable-stargate: + parameters: + path: + organizationId: "" + stackId: "" + responses: + default: + application/json: {"errorCode": ""} + disableStargate: + speakeasy-default-disable-stargate: + parameters: + path: + organizationId: "" + stackId: "" + responses: + default: + application/json: {"errorCode": ""} + listInvitations: + speakeasy-default-list-invitations: + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + acceptInvitation: + speakeasy-default-accept-invitation: + parameters: + path: + invitationId: "" + responses: + default: + application/json: {"errorCode": ""} + declineInvitation: + speakeasy-default-decline-invitation: + parameters: + path: + invitationId: "" + responses: + default: + application/json: {"errorCode": ""} + listOrganizationInvitations: + speakeasy-default-list-organization-invitations: + parameters: + path: + organizationId: "" + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + createInvitation: + speakeasy-default-create-invitation: + parameters: + path: + organizationId: "" + query: + email: "Manley_Hoeger@hotmail.com" + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + deleteInvitation: + speakeasy-default-delete-invitation: + parameters: + path: + organizationId: "" + invitationId: "" + responses: + default: + application/json: {"errorCode": ""} + listRegions: + speakeasy-default-list-regions: + parameters: + path: + organizationId: "" + responses: + "200": + application/json: {"data": []} + default: + application/json: {"errorCode": ""} + createPrivateRegion: + speakeasy-default-create-private-region: + parameters: + path: + organizationId: "" + responses: + "200": + application/json: {"data": {"id": "", "baseUrl": "https://wide-eyed-kinase.org", "createdAt": "2024-12-31T09:20:38.935Z", "active": true, "name": "", "capabilities": {}, "agentID": "", "outdated": true, "organizationID": "", "creatorID": ""}} + default: + application/json: {"errorCode": ""} + getRegion: + speakeasy-default-get-region: + parameters: + path: + organizationId: "" + regionID: "" + responses: + "200": + application/json: {"data": {"id": "", "baseUrl": "https://critical-pine.info/", "createdAt": "2024-12-31T04:45:57.185Z", "active": false, "name": "", "capabilities": {}, "agentID": "", "outdated": false, "public": true}} + default: + application/json: {"errorCode": ""} + deleteRegion: + speakeasy-default-delete-region: + parameters: + path: + organizationId: "" + regionID: "" + responses: + default: + application/json: {"errorCode": ""} + getRegionVersions: + speakeasy-default-get-region-versions: + parameters: + path: + organizationId: "" + regionID: "" + responses: + "200": + application/json: {"data": []} + default: + application/json: {"errorCode": ""} + enableApplicationForOrganization: + speakeasy-default-enable-application-for-organization: + parameters: + path: + organizationId: "" + applicationId: "" + responses: + "201": + application/json: {} + default: + application/json: {"errorCode": ""} + disableApplicationForOrganization: + speakeasy-default-disable-application-for-organization: + parameters: + path: + organizationId: "" + applicationId: "" + responses: + default: + application/json: {"errorCode": ""} + listApplications: + speakeasy-default-list-applications: + responses: + "200": + application/json: {"cursor": {"pageSize": 15, "hasMore": false, "previous": "YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol=", "next": "", "data": []}} + default: + application/json: {"errorCode": ""} + createApplication: + speakeasy-default-create-application: + responses: + "201": + application/json: {} + default: + application/json: {"errorCode": ""} + getApplication: + speakeasy-default-get-application: + parameters: + path: + applicationId: "" + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + updateApplication: + speakeasy-default-update-application: + parameters: + path: + applicationId: "" + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + deleteApplication: + speakeasy-default-delete-application: + parameters: + path: + applicationId: "" + responses: + default: + application/json: {"errorCode": ""} + createApplicationScope: + speakeasy-default-create-application-scope: + parameters: + path: + applicationId: "550e8400-e29b-41d4-a716-446655440000" + responses: + "201": + application/json: {} + default: + application/json: {"errorCode": ""} + deleteApplicationScope: + speakeasy-default-delete-application-scope: + parameters: + path: + applicationId: "550e8400-e29b-41d4-a716-446655440000" + scopeID: 115177 + responses: + "400": + application/json: {"errorCode": ""} + "500": + application/json: {"errorCode": ""} + default: + application/json: {"errorCode": ""} + createUser: + speakeasy-default-create-user: + requestBody: + application/json: {"email": "user@example.com"} + responses: + "201": + application/json: {} + "400": + application/json: {"errorCode": ""} + "500": + application/json: {"errorCode": ""} + default: + application/json: {"errorCode": ""} + readConnectedUser: + speakeasy-default-read-connected-user: + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} + listOrganizationApplications: + speakeasy-default-list-organization-applications: + parameters: + path: + organizationId: "" + query: + pageSize: 15 + page: 0 + responses: + "200": + application/json: {"cursor": {"pageSize": 15, "hasMore": false, "previous": "YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol=", "next": "", "data": []}} + default: + application/json: {"errorCode": ""} + getOrganizationApplication: + speakeasy-default-get-organization-application: + parameters: + path: + organizationId: "" + applicationId: "" + responses: + "200": + application/json: {} + default: + application/json: {"errorCode": ""} +examplesVersion: 1.0.2 diff --git a/internal/membershipclient/.speakeasy/gen.yaml b/internal/membershipclient/.speakeasy/gen.yaml new file mode 100644 index 00000000..6a19dc02 --- /dev/null +++ b/internal/membershipclient/.speakeasy/gen.yaml @@ -0,0 +1,56 @@ +configVersion: 2.0.0 +generation: + sdkClassName: SDK + maintainOpenAPIOrder: true + usageSnippets: + optionalPropertyRendering: withExample + sdkInitStyle: constructor + useClassNamesForArrayFields: true + fixes: + nameResolutionDec2023: true + nameResolutionFeb2025: true + parameterOrderingFeb2024: true + requestResponseComponentNamesFeb2024: true + securityFeb2025: true + sharedErrorComponentsApr2025: true + auth: + oAuth2ClientCredentialsEnabled: true + oAuth2PasswordEnabled: true + hoistGlobalSecurity: true + inferSSEOverload: true + sdkHooksConfigAccess: true + schemas: + allOfMergeStrategy: shallowMerge + requestBodyFieldName: body + tests: + generateTests: false + generateNewTests: true + skipResponseBodyAssertions: false +go: + version: 0.1.0 + additionalDependencies: {} + baseErrorName: SDKError + clientServerStatusCodesAsErrors: true + defaultErrorName: APIError + flattenGlobalSecurity: true + imports: + option: openapi + paths: + callbacks: models/callbacks + errors: models/apierrors + operations: models/operations + shared: models/components + webhooks: models/webhooks + includeEmptyObjects: true + inferUnionDiscriminators: false + inputModelSuffix: input + maxMethodParams: 0 + methodArguments: require-security-and-request + modulePath: "" + nullableOptionalWrapper: true + outputModelSuffix: output + packageName: github.com/formancehq/fctl/internal/membershipclient + respectRequiredFields: false + responseFormat: envelope-http + sdkPackageName: "" + unionStrategy: left-to-right diff --git a/internal/membershipclient/.speakeasy/workflow.lock b/internal/membershipclient/.speakeasy/workflow.lock new file mode 100644 index 00000000..10202a58 --- /dev/null +++ b/internal/membershipclient/.speakeasy/workflow.lock @@ -0,0 +1,36 @@ +speakeasyVersion: 1.661.3 +sources: + membership: + sourceNamespace: membership + sourceRevisionDigest: sha256:43d2b208ac1a3492602f5ebe5ee335548bc06ecf07f8e8047c86ae807b1b1354 + sourceBlobDigest: sha256:cc9d8d2f899357b7a2062c6d771067ca22ce09546f07087e255c7096e2830e48 + tags: + - latest + - 0.1.0 +targets: + membership: + source: membership + sourceNamespace: membership + sourceRevisionDigest: sha256:43d2b208ac1a3492602f5ebe5ee335548bc06ecf07f8e8047c86ae807b1b1354 + sourceBlobDigest: sha256:cc9d8d2f899357b7a2062c6d771067ca22ce09546f07087e255c7096e2830e48 + codeSamplesNamespace: membership-go-code-samples + codeSamplesRevisionDigest: sha256:d40bd50c75e705bd2d6a46f7805a2b365894b52c8a091a03ee01ba5600ec11a5 +workflow: + workflowVersion: 1.0.0 + speakeasyVersion: latest + sources: + membership: + inputs: + - location: ../../openapi/membership.yaml + registry: + location: registry.speakeasyapi.dev/formance/formance/membership + targets: + membership: + target: go + source: membership + codeSamples: + registry: + location: registry.speakeasyapi.dev/formance/formance/membership-go-code-samples + labelOverride: + fixedValue: Go (SDK) + blocking: false diff --git a/internal/membershipclient/.speakeasy/workflow.yaml b/internal/membershipclient/.speakeasy/workflow.yaml new file mode 100644 index 00000000..9bc8a593 --- /dev/null +++ b/internal/membershipclient/.speakeasy/workflow.yaml @@ -0,0 +1,18 @@ +workflowVersion: 1.0.0 +speakeasyVersion: latest +sources: + membership: + inputs: + - location: ../../openapi/membership.yaml + registry: + location: registry.speakeasyapi.dev/formance/formance/membership +targets: + membership: + target: go + source: membership + codeSamples: + registry: + location: registry.speakeasyapi.dev/formance/formance/membership-go-code-samples + labelOverride: + fixedValue: Go (SDK) + blocking: false diff --git a/internal/membershipclient/CONTRIBUTING.md b/internal/membershipclient/CONTRIBUTING.md new file mode 100644 index 00000000..d585717f --- /dev/null +++ b/internal/membershipclient/CONTRIBUTING.md @@ -0,0 +1,26 @@ +# Contributing to This Repository + +Thank you for your interest in contributing to this repository. Please note that this repository contains generated code. As such, we do not accept direct changes or pull requests. Instead, we encourage you to follow the guidelines below to report issues and suggest improvements. + +## How to Report Issues + +If you encounter any bugs or have suggestions for improvements, please open an issue on GitHub. When reporting an issue, please provide as much detail as possible to help us reproduce the problem. This includes: + +- A clear and descriptive title +- Steps to reproduce the issue +- Expected and actual behavior +- Any relevant logs, screenshots, or error messages +- Information about your environment (e.g., operating system, software versions) + - For example can be collected using the `npx envinfo` command from your terminal if you have Node.js installed + +## Issue Triage and Upstream Fixes + +We will review and triage issues as quickly as possible. Our goal is to address bugs and incorporate improvements in the upstream source code. Fixes will be included in the next generation of the generated code. + +## Contact + +If you have any questions or need further assistance, please feel free to reach out by opening an issue. + +Thank you for your understanding and cooperation! + +The Maintainers diff --git a/internal/membershipclient/README.md b/internal/membershipclient/README.md new file mode 100644 index 00000000..19a38e08 --- /dev/null +++ b/internal/membershipclient/README.md @@ -0,0 +1,543 @@ +# undefined + +Developer-friendly & type-safe Go SDK specifically catered to leverage *undefined* API. + + + + +

+> [!IMPORTANT] +> This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your [workspace](https://app.speakeasy.com/org/formance/formance). Delete this section before > publishing to a package manager. + + +## Summary + + + + + +## Table of Contents + +* [undefined](#undefined) + * [SDK Installation](#sdk-installation) + * [SDK Example Usage](#sdk-example-usage) + * [Authentication](#authentication) + * [Available Resources and Operations](#available-resources-and-operations) + * [Retries](#retries) + * [Error Handling](#error-handling) + * [Server Selection](#server-selection) + * [Custom HTTP Client](#custom-http-client) +* [Development](#development) + * [Maturity](#maturity) + * [Contributions](#contributions) + + + + +## SDK Installation + +To add the SDK as a dependency to your project: +```bash +go get github.com/formancehq/fctl/internal/membershipclient +``` + + + +## SDK Example Usage + +### Example + +```go +package main + +import ( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.GetServerInfo(ctx) + if err != nil { + log.Fatal(err) + } + if res.ServerInfo != nil { + // handle response + } +} + +``` + + + +## Authentication + +### Per-Client Security Schemes + +This SDK supports the following security scheme globally: + +| Name | Type | Scheme | +| -------- | ------ | ------------ | +| `Oauth2` | oauth2 | OAuth2 token | + +You can configure it using the `WithSecurity` option when initializing the SDK client instance. For example: +```go +package main + +import ( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.GetServerInfo(ctx) + if err != nil { + log.Fatal(err) + } + if res.ServerInfo != nil { + // handle response + } +} + +``` + + + +## Available Resources and Operations + +
+Available methods + +### [SDK](docs/sdks/sdk/README.md) + +* [GetServerInfo](docs/sdks/sdk/README.md#getserverinfo) - Get server info +* [ListOrganizations](docs/sdks/sdk/README.md#listorganizations) - List organizations of the connected user +* [CreateOrganization](docs/sdks/sdk/README.md#createorganization) - Create organization +* [~~ListOrganizationsExpanded~~](docs/sdks/sdk/README.md#listorganizationsexpanded) - List organizations of the connected user with expanded data :warning: **Deprecated** +* [ReadOrganization](docs/sdks/sdk/README.md#readorganization) - Read organization +* [UpdateOrganization](docs/sdks/sdk/README.md#updateorganization) - Update organization +* [DeleteOrganization](docs/sdks/sdk/README.md#deleteorganization) - Delete organization +* [ReadAuthenticationProvider](docs/sdks/sdk/README.md#readauthenticationprovider) - Read authentication provider +* [UpsertAuthenticationProvider](docs/sdks/sdk/README.md#upsertauthenticationprovider) - Upsert an authentication provider +* [DeleteAuthenticationProvider](docs/sdks/sdk/README.md#deleteauthenticationprovider) - Delete authentication provider +* [ListFeatures](docs/sdks/sdk/README.md#listfeatures) - List features +* [AddFeatures](docs/sdks/sdk/README.md#addfeatures) - Add Features +* [DeleteFeature](docs/sdks/sdk/README.md#deletefeature) - Delete feature +* [~~ReadOrganizationClient~~](docs/sdks/sdk/README.md#readorganizationclient) - Read organization client (DEPRECATED) (until 12/31/2025) :warning: **Deprecated** +* [~~CreateOrganizationClient~~](docs/sdks/sdk/README.md#createorganizationclient) - Create organization client (DEPRECATED) (until 12/31/2025) :warning: **Deprecated** +* [~~DeleteOrganizationClient~~](docs/sdks/sdk/README.md#deleteorganizationclient) - Delete organization client (DEPRECATED) (until 12/31/2025) :warning: **Deprecated** +* [OrganizationClientsRead](docs/sdks/sdk/README.md#organizationclientsread) - Read organization clients +* [OrganizationClientCreate](docs/sdks/sdk/README.md#organizationclientcreate) - Create organization client +* [OrganizationClientRead](docs/sdks/sdk/README.md#organizationclientread) - Read organization client +* [OrganizationClientDelete](docs/sdks/sdk/README.md#organizationclientdelete) - Delete organization client +* [OrganizationClientUpdate](docs/sdks/sdk/README.md#organizationclientupdate) - Update organization client +* [ListLogs](docs/sdks/sdk/README.md#listlogs) - List logs +* [ListUsersOfOrganization](docs/sdks/sdk/README.md#listusersoforganization) - List users of organization +* [ReadUserOfOrganization](docs/sdks/sdk/README.md#readuseroforganization) - Read user of organization +* [UpsertOrganizationUser](docs/sdks/sdk/README.md#upsertorganizationuser) - Update user within an organization +* [DeleteUserFromOrganization](docs/sdks/sdk/README.md#deleteuserfromorganization) - delete user from organization +* [ListPolicies](docs/sdks/sdk/README.md#listpolicies) - List policies of organization +* [CreatePolicy](docs/sdks/sdk/README.md#createpolicy) - Create policy +* [ReadPolicy](docs/sdks/sdk/README.md#readpolicy) - Read policy with scopes +* [UpdatePolicy](docs/sdks/sdk/README.md#updatepolicy) - Update policy +* [DeletePolicy](docs/sdks/sdk/README.md#deletepolicy) - Delete policy +* [AddScopeToPolicy](docs/sdks/sdk/README.md#addscopetopolicy) - Add scope to policy +* [RemoveScopeFromPolicy](docs/sdks/sdk/README.md#removescopefrompolicy) - Remove scope from policy +* [ListStacks](docs/sdks/sdk/README.md#liststacks) - List stacks +* [CreateStack](docs/sdks/sdk/README.md#createstack) - Create stack +* [ListModules](docs/sdks/sdk/README.md#listmodules) - List modules of a stack +* [EnableModule](docs/sdks/sdk/README.md#enablemodule) - enable module +* [DisableModule](docs/sdks/sdk/README.md#disablemodule) - disable module +* [UpgradeStack](docs/sdks/sdk/README.md#upgradestack) - Upgrade stack +* [GetStack](docs/sdks/sdk/README.md#getstack) - Find stack +* [UpdateStack](docs/sdks/sdk/README.md#updatestack) - Update stack +* [DeleteStack](docs/sdks/sdk/README.md#deletestack) - Delete stack +* [ListStackUsersAccesses](docs/sdks/sdk/README.md#liststackusersaccesses) - List stack users accesses within an organization +* [ReadStackUserAccess](docs/sdks/sdk/README.md#readstackuseraccess) - Read stack user access within an organization +* [DeleteStackUserAccess](docs/sdks/sdk/README.md#deletestackuseraccess) - Delete stack user access within an organization +* [UpsertStackUserAccess](docs/sdks/sdk/README.md#upsertstackuseraccess) - Update stack user access within an organization +* [DisableStack](docs/sdks/sdk/README.md#disablestack) - Disable stack +* [EnableStack](docs/sdks/sdk/README.md#enablestack) - Enable stack +* [RestoreStack](docs/sdks/sdk/README.md#restorestack) - Restore stack +* [EnableStargate](docs/sdks/sdk/README.md#enablestargate) - Enable stargate on a stack +* [DisableStargate](docs/sdks/sdk/README.md#disablestargate) - Disable stargate on a stack +* [ListInvitations](docs/sdks/sdk/README.md#listinvitations) - List invitations of the user +* [AcceptInvitation](docs/sdks/sdk/README.md#acceptinvitation) - Accept invitation +* [DeclineInvitation](docs/sdks/sdk/README.md#declineinvitation) - Decline invitation +* [ListOrganizationInvitations](docs/sdks/sdk/README.md#listorganizationinvitations) - List invitations of the organization +* [CreateInvitation](docs/sdks/sdk/README.md#createinvitation) - Create invitation +* [DeleteInvitation](docs/sdks/sdk/README.md#deleteinvitation) - Delete invitation +* [ListRegions](docs/sdks/sdk/README.md#listregions) - List regions +* [CreatePrivateRegion](docs/sdks/sdk/README.md#createprivateregion) - Create a private region +* [GetRegion](docs/sdks/sdk/README.md#getregion) - Get region +* [DeleteRegion](docs/sdks/sdk/README.md#deleteregion) - Delete region +* [GetRegionVersions](docs/sdks/sdk/README.md#getregionversions) - Get region versions +* [ListOrganizationApplications](docs/sdks/sdk/README.md#listorganizationapplications) - List applications enabled for organization +* [GetOrganizationApplication](docs/sdks/sdk/README.md#getorganizationapplication) - Get application for organization +* [EnableApplicationForOrganization](docs/sdks/sdk/README.md#enableapplicationfororganization) - Enable application for organization +* [DisableApplicationForOrganization](docs/sdks/sdk/README.md#disableapplicationfororganization) - Disable application for organization +* [ListApplications](docs/sdks/sdk/README.md#listapplications) - List applications +* [CreateApplication](docs/sdks/sdk/README.md#createapplication) - Create application +* [GetApplication](docs/sdks/sdk/README.md#getapplication) - Get application +* [UpdateApplication](docs/sdks/sdk/README.md#updateapplication) - Update application +* [DeleteApplication](docs/sdks/sdk/README.md#deleteapplication) - Delete application +* [CreateApplicationScope](docs/sdks/sdk/README.md#createapplicationscope) - Create application scope +* [DeleteApplicationScope](docs/sdks/sdk/README.md#deleteapplicationscope) - Delete application scope +* [CreateUser](docs/sdks/sdk/README.md#createuser) - Create user +* [ReadConnectedUser](docs/sdks/sdk/README.md#readconnecteduser) - Read user + +
+ + + +## Retries + +Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK. + +To change the default retry strategy for a single API call, simply provide a `retry.Config` object to the call by using the `WithRetries` option: +```go +package main + +import ( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/retry" + "log" + "models/operations" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.GetServerInfo(ctx, operations.WithRetries( + retry.Config{ + Strategy: "backoff", + Backoff: &retry.BackoffStrategy{ + InitialInterval: 1, + MaxInterval: 50, + Exponent: 1.1, + MaxElapsedTime: 100, + }, + RetryConnectionErrors: false, + })) + if err != nil { + log.Fatal(err) + } + if res.ServerInfo != nil { + // handle response + } +} + +``` + +If you'd like to override the default retry strategy for all operations that support retries, you can use the `WithRetryConfig` option at SDK initialization: +```go +package main + +import ( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/retry" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithRetryConfig( + retry.Config{ + Strategy: "backoff", + Backoff: &retry.BackoffStrategy{ + InitialInterval: 1, + MaxInterval: 50, + Exponent: 1.1, + MaxElapsedTime: 100, + }, + RetryConnectionErrors: false, + }), + membershipclient.WithSecurity(""), + ) + + res, err := s.GetServerInfo(ctx) + if err != nil { + log.Fatal(err) + } + if res.ServerInfo != nil { + // handle response + } +} + +``` + + + +## Error Handling + +Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both. + +By Default, an API error will return `apierrors.APIError`. When custom error responses are specified for an operation, the SDK may also return their associated error. You can refer to respective *Errors* tables in SDK docs for more details on possible error types for each operation. + +For example, the `DeleteApplicationScope` function may return the following errors: + +| Error Type | Status Code | Content Type | +| ------------------ | ----------- | ---------------- | +| apierrors.Error | 400, 404 | application/json | +| apierrors.Error | 500 | application/json | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +### Example + +```go +package main + +import ( + "context" + "errors" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/apierrors" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.DeleteApplicationScope(ctx, operations.DeleteApplicationScopeRequest{ + ApplicationID: "550e8400-e29b-41d4-a716-446655440000", + ScopeID: 115177, + }) + if err != nil { + + var e *apierrors.Error + if errors.As(err, &e) { + // handle error + log.Fatal(e.Error()) + } + + var e *apierrors.Error + if errors.As(err, &e) { + // handle error + log.Fatal(e.Error()) + } + + var e *apierrors.APIError + if errors.As(err, &e) { + // handle error + log.Fatal(e.Error()) + } + } +} + +``` + + + +## Server Selection + +### Override Server URL Per-Client + +The default server can be overridden globally using the `WithServerURL(serverURL string)` option when initializing the SDK client instance. For example: +```go +package main + +import ( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithServerURL("http://localhost:8080"), + membershipclient.WithSecurity(""), + ) + + res, err := s.GetServerInfo(ctx) + if err != nil { + log.Fatal(err) + } + if res.ServerInfo != nil { + // handle response + } +} + +``` + + + +## Custom HTTP Client + +The Go SDK makes API calls that wrap an internal HTTP client. The requirements for the HTTP client are very simple. It must match this interface: + +```go +type HTTPClient interface { + Do(req *http.Request) (*http.Response, error) +} +``` + +The built-in `net/http` client satisfies this interface and a default client based on the built-in is provided by default. To replace this default with a client of your own, you can implement this interface yourself or provide your own client configured as desired. Here's a simple example, which adds a client with a 30 second timeout. + +```go +import ( + "net/http" + "time" + + "github.com/formancehq/fctl/internal/membershipclient" +) + +var ( + httpClient = &http.Client{Timeout: 30 * time.Second} + sdkClient = membershipclient.New(membershipclient.WithClient(httpClient)) +) +``` + +This can be a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration. + + + + +# Development + +## Maturity + +This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage +to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally +looking for the latest version. + +## Contributions + +While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation. +We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release. + +### SDK Created by [Speakeasy](https://www.speakeasy.com/?utm_source=undefined&utm_campaign=go) + + \ No newline at end of file diff --git a/internal/membershipclient/USAGE.md b/internal/membershipclient/USAGE.md new file mode 100644 index 00000000..27764be0 --- /dev/null +++ b/internal/membershipclient/USAGE.md @@ -0,0 +1,28 @@ + +```go +package main + +import ( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.GetServerInfo(ctx) + if err != nil { + log.Fatal(err) + } + if res.ServerInfo != nil { + // handle response + } +} + +``` + \ No newline at end of file diff --git a/internal/membershipclient/docs/models/apierrors/error.md b/internal/membershipclient/docs/models/apierrors/error.md new file mode 100644 index 00000000..3379412b --- /dev/null +++ b/internal/membershipclient/docs/models/apierrors/error.md @@ -0,0 +1,10 @@ +# Error + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `ErrorCode` | *string* | :heavy_check_mark: | N/A | +| `ErrorMessage` | **string* | :heavy_minus_sign: | N/A | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/action.md b/internal/membershipclient/docs/models/components/action.md new file mode 100644 index 00000000..81a0f84d --- /dev/null +++ b/internal/membershipclient/docs/models/components/action.md @@ -0,0 +1,47 @@ +# Action + + +## Values + +| Name | Value | +| --------------------------------- | --------------------------------- | +| `ActionAgentsConnected` | agents.connected | +| `ActionAgentsDisconnected` | agents.disconnected | +| `ActionInvitationsCreated` | invitations.created | +| `ActionInvitationsAccepted` | invitations.accepted | +| `ActionInvitationsRejected` | invitations.rejected | +| `ActionInvitationsCancelled` | invitations.cancelled | +| `ActionOrganizationsCreated` | organizations.created | +| `ActionOrganizationsUpdated` | organizations.updated | +| `ActionOrganizationsDeleted` | organizations.deleted | +| `ActionOrganizationsUserDeleted` | organizations.user.deleted | +| `ActionOrganizationsUserUpdated` | organizations.user.updated | +| `ActionRegionsCreated` | regions.created | +| `ActionRegionsDeleted` | regions.deleted | +| `ActionUsersCreated` | users.created | +| `ActionUsersDeleted` | users.deleted | +| `ActionStacksDisposal` | stacks.disposal | +| `ActionStacksDisposalReset` | stacks.disposal-reset | +| `ActionStacksWarned` | stacks.warned | +| `ActionStacksPruned` | stacks.pruned | +| `ActionStacksStatusUpdated` | stacks.status.updated | +| `ActionStacksCreated` | stacks.created | +| `ActionStacksUpdated` | stacks.updated | +| `ActionStacksDeleted` | stacks.deleted | +| `ActionStacksRestored` | stacks.restored | +| `ActionStacksDisabled` | stacks.disabled | +| `ActionStacksEnabled` | stacks.enabled | +| `ActionStacksUpgraded` | stacks.upgraded | +| `ActionStacksStargateEnabled` | stacks.stargate.enabled | +| `ActionStacksStargateDisabled` | stacks.stargate.disabled | +| `ActionStacksUserUpdated` | stacks.user.updated | +| `ActionStacksUserDeleted` | stacks.user.deleted | +| `ActionStacksReachnessUpdated` | stacks.reachness.updated | +| `ActionStacksModuleEnabled` | stacks.module.enabled | +| `ActionStacksModuleDisabled` | stacks.module.disabled | +| `ActionStacksModuleStatusUpdated` | stacks.module.status.updated | +| `ActionPoliciesCreated` | policies.created | +| `ActionPoliciesUpdated` | policies.updated | +| `ActionPoliciesDeleted` | policies.deleted | +| `ActionPoliciesScopeAdded` | policies.scope.added | +| `ActionPoliciesScopeRemoved` | policies.scope.removed | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/anyregion.md b/internal/membershipclient/docs/models/components/anyregion.md new file mode 100644 index 00000000..e5016eae --- /dev/null +++ b/internal/membershipclient/docs/models/components/anyregion.md @@ -0,0 +1,24 @@ +# AnyRegion + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| `ID` | *string* | :heavy_check_mark: | N/A | +| `BaseURL` | *string* | :heavy_check_mark: | N/A | +| `CreatedAt` | *string* | :heavy_check_mark: | N/A | +| `Active` | *bool* | :heavy_check_mark: | N/A | +| `LastPing` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | +| `Name` | *string* | :heavy_check_mark: | N/A | +| `Capabilities` | [components.RegionCapability](../../models/components/regioncapability.md) | :heavy_check_mark: | N/A | +| `AgentID` | *string* | :heavy_check_mark: | N/A | +| `Outdated` | *bool* | :heavy_check_mark: | N/A | +| `CreatorID` | **string* | :heavy_minus_sign: | N/A | +| `Version` | **string* | :heavy_minus_sign: | N/A | +| `ClientID` | **string* | :heavy_minus_sign: | N/A | +| `OrganizationID` | **string* | :heavy_minus_sign: | N/A | +| `Creator` | [*components.User](../../models/components/user.md) | :heavy_minus_sign: | N/A | +| `Production` | **bool* | :heavy_minus_sign: | N/A | +| `Public` | *bool* | :heavy_check_mark: | N/A | +| `Secret` | [*components.PrivateRegionSecret](../../models/components/privateregionsecret.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/application.md b/internal/membershipclient/docs/models/components/application.md new file mode 100644 index 00000000..f29a4ea9 --- /dev/null +++ b/internal/membershipclient/docs/models/components/application.md @@ -0,0 +1,14 @@ +# Application + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | +| `Name` | *string* | :heavy_check_mark: | Application name | +| `Description` | **string* | :heavy_minus_sign: | Application description | +| `URL` | *string* | :heavy_check_mark: | Application URL (must be unique) | +| `Alias` | *string* | :heavy_check_mark: | Application alias | +| `ID` | *string* | :heavy_check_mark: | Application ID | +| `CreatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | Creation date | +| `UpdatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | Last update date | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/applicationdata.md b/internal/membershipclient/docs/models/components/applicationdata.md new file mode 100644 index 00000000..10a5ad4d --- /dev/null +++ b/internal/membershipclient/docs/models/components/applicationdata.md @@ -0,0 +1,11 @@ +# ApplicationData + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------- | -------------------------------- | -------------------------------- | -------------------------------- | +| `Name` | *string* | :heavy_check_mark: | Application name | +| `Description` | **string* | :heavy_minus_sign: | Application description | +| `URL` | *string* | :heavy_check_mark: | Application URL (must be unique) | +| `Alias` | *string* | :heavy_check_mark: | Application alias | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/applicationwithscope.md b/internal/membershipclient/docs/models/components/applicationwithscope.md new file mode 100644 index 00000000..95c092c9 --- /dev/null +++ b/internal/membershipclient/docs/models/components/applicationwithscope.md @@ -0,0 +1,15 @@ +# ApplicationWithScope + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | +| `Name` | *string* | :heavy_check_mark: | Application name | +| `Description` | **string* | :heavy_minus_sign: | Application description | +| `URL` | *string* | :heavy_check_mark: | Application URL (must be unique) | +| `Alias` | *string* | :heavy_check_mark: | Application alias | +| `ID` | *string* | :heavy_check_mark: | Application ID | +| `CreatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | Creation date | +| `UpdatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | Last update date | +| `Scopes` | [][components.Scope](../../models/components/scope.md) | :heavy_check_mark: | List of scopes associated with this application | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderdata.md b/internal/membershipclient/docs/models/components/authenticationproviderdata.md new file mode 100644 index 00000000..fb80aa12 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderdata.md @@ -0,0 +1,29 @@ +# AuthenticationProviderData + + +## Supported Types + +### AuthenticationProviderDataGoogleIDPConfig + +```go +authenticationProviderData := components.CreateAuthenticationProviderDataAuthenticationProviderDataGoogleIDPConfig(components.AuthenticationProviderDataGoogleIDPConfig{/* values here */}) +``` + +### AuthenticationProviderDataMicrosoftIDPConfig + +```go +authenticationProviderData := components.CreateAuthenticationProviderDataAuthenticationProviderDataMicrosoftIDPConfig(components.AuthenticationProviderDataMicrosoftIDPConfig{/* values here */}) +``` + +### AuthenticationProviderDataGithubIDPConfig + +```go +authenticationProviderData := components.CreateAuthenticationProviderDataAuthenticationProviderDataGithubIDPConfig(components.AuthenticationProviderDataGithubIDPConfig{/* values here */}) +``` + +### AuthenticationProviderDataOIDCConfig + +```go +authenticationProviderData := components.CreateAuthenticationProviderDataAuthenticationProviderDataOIDCConfig(components.AuthenticationProviderDataOIDCConfig{/* values here */}) +``` + diff --git a/internal/membershipclient/docs/models/components/authenticationproviderdatagithubidpconfig.md b/internal/membershipclient/docs/models/components/authenticationproviderdatagithubidpconfig.md new file mode 100644 index 00000000..5e16c190 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderdatagithubidpconfig.md @@ -0,0 +1,12 @@ +# AuthenticationProviderDataGithubIDPConfig + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | +| `Type` | [components.AuthenticationProviderDataGithubIDPConfigType](../../models/components/authenticationproviderdatagithubidpconfigtype.md) | :heavy_check_mark: | Type of the authentication provider | +| `Name` | *string* | :heavy_check_mark: | Name of the authentication provider | +| `ClientID` | *string* | :heavy_check_mark: | Client ID for the authentication provider | +| `ClientSecret` | *string* | :heavy_check_mark: | Client secret for the authentication provider | +| `Config` | [components.AuthenticationProviderDataGithubIDPConfigConfig](../../models/components/authenticationproviderdatagithubidpconfigconfig.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderdatagithubidpconfigconfig.md b/internal/membershipclient/docs/models/components/authenticationproviderdatagithubidpconfigconfig.md new file mode 100644 index 00000000..e7dfa013 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderdatagithubidpconfigconfig.md @@ -0,0 +1,7 @@ +# AuthenticationProviderDataGithubIDPConfigConfig + + +## Fields + +| Field | Type | Required | Description | +| ----------- | ----------- | ----------- | ----------- | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderdatagithubidpconfigtype.md b/internal/membershipclient/docs/models/components/authenticationproviderdatagithubidpconfigtype.md new file mode 100644 index 00000000..24024361 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderdatagithubidpconfigtype.md @@ -0,0 +1,13 @@ +# AuthenticationProviderDataGithubIDPConfigType + +Type of the authentication provider + + +## Values + +| Name | Value | +| -------------------------------------------------------- | -------------------------------------------------------- | +| `AuthenticationProviderDataGithubIDPConfigTypeOidc` | oidc | +| `AuthenticationProviderDataGithubIDPConfigTypeGoogle` | google | +| `AuthenticationProviderDataGithubIDPConfigTypeGithub` | github | +| `AuthenticationProviderDataGithubIDPConfigTypeMicrosoft` | microsoft | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderdatagoogleidpconfig.md b/internal/membershipclient/docs/models/components/authenticationproviderdatagoogleidpconfig.md new file mode 100644 index 00000000..9f54a6a4 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderdatagoogleidpconfig.md @@ -0,0 +1,12 @@ +# AuthenticationProviderDataGoogleIDPConfig + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | +| `Type` | [components.AuthenticationProviderDataGoogleIDPConfigType](../../models/components/authenticationproviderdatagoogleidpconfigtype.md) | :heavy_check_mark: | Type of the authentication provider | +| `Name` | *string* | :heavy_check_mark: | Name of the authentication provider | +| `ClientID` | *string* | :heavy_check_mark: | Client ID for the authentication provider | +| `ClientSecret` | *string* | :heavy_check_mark: | Client secret for the authentication provider | +| `Config` | [components.AuthenticationProviderDataGoogleIDPConfigConfig](../../models/components/authenticationproviderdatagoogleidpconfigconfig.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderdatagoogleidpconfigconfig.md b/internal/membershipclient/docs/models/components/authenticationproviderdatagoogleidpconfigconfig.md new file mode 100644 index 00000000..ef67f685 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderdatagoogleidpconfigconfig.md @@ -0,0 +1,7 @@ +# AuthenticationProviderDataGoogleIDPConfigConfig + + +## Fields + +| Field | Type | Required | Description | +| ----------- | ----------- | ----------- | ----------- | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderdatagoogleidpconfigtype.md b/internal/membershipclient/docs/models/components/authenticationproviderdatagoogleidpconfigtype.md new file mode 100644 index 00000000..82e6e636 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderdatagoogleidpconfigtype.md @@ -0,0 +1,13 @@ +# AuthenticationProviderDataGoogleIDPConfigType + +Type of the authentication provider + + +## Values + +| Name | Value | +| -------------------------------------------------------- | -------------------------------------------------------- | +| `AuthenticationProviderDataGoogleIDPConfigTypeOidc` | oidc | +| `AuthenticationProviderDataGoogleIDPConfigTypeGoogle` | google | +| `AuthenticationProviderDataGoogleIDPConfigTypeGithub` | github | +| `AuthenticationProviderDataGoogleIDPConfigTypeMicrosoft` | microsoft | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderdatamicrosoftidpconfig.md b/internal/membershipclient/docs/models/components/authenticationproviderdatamicrosoftidpconfig.md new file mode 100644 index 00000000..bfc22793 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderdatamicrosoftidpconfig.md @@ -0,0 +1,12 @@ +# AuthenticationProviderDataMicrosoftIDPConfig + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | +| `Type` | [components.AuthenticationProviderDataMicrosoftIDPConfigType](../../models/components/authenticationproviderdatamicrosoftidpconfigtype.md) | :heavy_check_mark: | Type of the authentication provider | +| `Name` | *string* | :heavy_check_mark: | Name of the authentication provider | +| `ClientID` | *string* | :heavy_check_mark: | Client ID for the authentication provider | +| `ClientSecret` | *string* | :heavy_check_mark: | Client secret for the authentication provider | +| `Config` | [components.AuthenticationProviderDataMicrosoftIDPConfigConfig](../../models/components/authenticationproviderdatamicrosoftidpconfigconfig.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderdatamicrosoftidpconfigconfig.md b/internal/membershipclient/docs/models/components/authenticationproviderdatamicrosoftidpconfigconfig.md new file mode 100644 index 00000000..3c2a6c88 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderdatamicrosoftidpconfigconfig.md @@ -0,0 +1,8 @@ +# AuthenticationProviderDataMicrosoftIDPConfigConfig + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------- | -------------------------------------- | -------------------------------------- | -------------------------------------- | +| `Tenant` | **string* | :heavy_minus_sign: | Tenant ID for Microsoft authentication | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderdatamicrosoftidpconfigtype.md b/internal/membershipclient/docs/models/components/authenticationproviderdatamicrosoftidpconfigtype.md new file mode 100644 index 00000000..c813a9c6 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderdatamicrosoftidpconfigtype.md @@ -0,0 +1,13 @@ +# AuthenticationProviderDataMicrosoftIDPConfigType + +Type of the authentication provider + + +## Values + +| Name | Value | +| ----------------------------------------------------------- | ----------------------------------------------------------- | +| `AuthenticationProviderDataMicrosoftIDPConfigTypeOidc` | oidc | +| `AuthenticationProviderDataMicrosoftIDPConfigTypeGoogle` | google | +| `AuthenticationProviderDataMicrosoftIDPConfigTypeGithub` | github | +| `AuthenticationProviderDataMicrosoftIDPConfigTypeMicrosoft` | microsoft | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderdataoidcconfig.md b/internal/membershipclient/docs/models/components/authenticationproviderdataoidcconfig.md new file mode 100644 index 00000000..70bd3472 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderdataoidcconfig.md @@ -0,0 +1,12 @@ +# AuthenticationProviderDataOIDCConfig + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ | +| `Type` | [components.AuthenticationProviderDataOIDCConfigType](../../models/components/authenticationproviderdataoidcconfigtype.md) | :heavy_check_mark: | Type of the authentication provider | +| `Name` | *string* | :heavy_check_mark: | Name of the authentication provider | +| `ClientID` | *string* | :heavy_check_mark: | Client ID for the authentication provider | +| `ClientSecret` | *string* | :heavy_check_mark: | Client secret for the authentication provider | +| `Config` | [components.AuthenticationProviderDataOIDCConfigConfig](../../models/components/authenticationproviderdataoidcconfigconfig.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderdataoidcconfigconfig.md b/internal/membershipclient/docs/models/components/authenticationproviderdataoidcconfigconfig.md new file mode 100644 index 00000000..c8e9f513 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderdataoidcconfigconfig.md @@ -0,0 +1,9 @@ +# AuthenticationProviderDataOIDCConfigConfig + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `Issuer` | *string* | :heavy_check_mark: | OIDC issuer URL | +| `DiscoveryPath` | **string* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderdataoidcconfigtype.md b/internal/membershipclient/docs/models/components/authenticationproviderdataoidcconfigtype.md new file mode 100644 index 00000000..27f6acc6 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderdataoidcconfigtype.md @@ -0,0 +1,13 @@ +# AuthenticationProviderDataOIDCConfigType + +Type of the authentication provider + + +## Values + +| Name | Value | +| --------------------------------------------------- | --------------------------------------------------- | +| `AuthenticationProviderDataOIDCConfigTypeOidc` | oidc | +| `AuthenticationProviderDataOIDCConfigTypeGoogle` | google | +| `AuthenticationProviderDataOIDCConfigTypeGithub` | github | +| `AuthenticationProviderDataOIDCConfigTypeMicrosoft` | microsoft | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderresponse.md b/internal/membershipclient/docs/models/components/authenticationproviderresponse.md new file mode 100644 index 00000000..f4056631 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderresponse.md @@ -0,0 +1,8 @@ +# AuthenticationProviderResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | +| `Data` | [*components.Data](../../models/components/data.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderresponsegithubidpconfig.md b/internal/membershipclient/docs/models/components/authenticationproviderresponsegithubidpconfig.md new file mode 100644 index 00000000..c5a34efa --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderresponsegithubidpconfig.md @@ -0,0 +1,16 @@ +# AuthenticationProviderResponseGithubIDPConfig + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ | +| `Type` | [components.AuthenticationProviderResponseGithubIDPConfigType](../../models/components/authenticationproviderresponsegithubidpconfigtype.md) | :heavy_check_mark: | Type of the authentication provider | +| `Name` | *string* | :heavy_check_mark: | Name of the authentication provider | +| `ClientID` | *string* | :heavy_check_mark: | Client ID for the authentication provider | +| `ClientSecret` | *string* | :heavy_check_mark: | Client secret for the authentication provider | +| `Config` | [components.AuthenticationProviderResponseGithubIDPConfigConfig](../../models/components/authenticationproviderresponsegithubidpconfigconfig.md) | :heavy_check_mark: | N/A | +| `OrganizationID` | *string* | :heavy_check_mark: | Unique identifier for the authentication provider | +| `CreatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | Creation date of the authentication provider | +| `UpdatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | Last update date of the authentication provider | +| `RedirectURI` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderresponsegithubidpconfigconfig.md b/internal/membershipclient/docs/models/components/authenticationproviderresponsegithubidpconfigconfig.md new file mode 100644 index 00000000..0301600d --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderresponsegithubidpconfigconfig.md @@ -0,0 +1,7 @@ +# AuthenticationProviderResponseGithubIDPConfigConfig + + +## Fields + +| Field | Type | Required | Description | +| ----------- | ----------- | ----------- | ----------- | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderresponsegithubidpconfigtype.md b/internal/membershipclient/docs/models/components/authenticationproviderresponsegithubidpconfigtype.md new file mode 100644 index 00000000..2b4ddd68 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderresponsegithubidpconfigtype.md @@ -0,0 +1,13 @@ +# AuthenticationProviderResponseGithubIDPConfigType + +Type of the authentication provider + + +## Values + +| Name | Value | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| `AuthenticationProviderResponseGithubIDPConfigTypeOidc` | oidc | +| `AuthenticationProviderResponseGithubIDPConfigTypeGoogle` | google | +| `AuthenticationProviderResponseGithubIDPConfigTypeGithub` | github | +| `AuthenticationProviderResponseGithubIDPConfigTypeMicrosoft` | microsoft | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderresponsegoogleidpconfig.md b/internal/membershipclient/docs/models/components/authenticationproviderresponsegoogleidpconfig.md new file mode 100644 index 00000000..a88b24cf --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderresponsegoogleidpconfig.md @@ -0,0 +1,16 @@ +# AuthenticationProviderResponseGoogleIDPConfig + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------ | +| `Type` | [components.AuthenticationProviderResponseGoogleIDPConfigType](../../models/components/authenticationproviderresponsegoogleidpconfigtype.md) | :heavy_check_mark: | Type of the authentication provider | +| `Name` | *string* | :heavy_check_mark: | Name of the authentication provider | +| `ClientID` | *string* | :heavy_check_mark: | Client ID for the authentication provider | +| `ClientSecret` | *string* | :heavy_check_mark: | Client secret for the authentication provider | +| `Config` | [components.AuthenticationProviderResponseGoogleIDPConfigConfig](../../models/components/authenticationproviderresponsegoogleidpconfigconfig.md) | :heavy_check_mark: | N/A | +| `OrganizationID` | *string* | :heavy_check_mark: | Unique identifier for the authentication provider | +| `CreatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | Creation date of the authentication provider | +| `UpdatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | Last update date of the authentication provider | +| `RedirectURI` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderresponsegoogleidpconfigconfig.md b/internal/membershipclient/docs/models/components/authenticationproviderresponsegoogleidpconfigconfig.md new file mode 100644 index 00000000..b777b938 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderresponsegoogleidpconfigconfig.md @@ -0,0 +1,7 @@ +# AuthenticationProviderResponseGoogleIDPConfigConfig + + +## Fields + +| Field | Type | Required | Description | +| ----------- | ----------- | ----------- | ----------- | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderresponsegoogleidpconfigtype.md b/internal/membershipclient/docs/models/components/authenticationproviderresponsegoogleidpconfigtype.md new file mode 100644 index 00000000..92b3f27a --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderresponsegoogleidpconfigtype.md @@ -0,0 +1,13 @@ +# AuthenticationProviderResponseGoogleIDPConfigType + +Type of the authentication provider + + +## Values + +| Name | Value | +| ------------------------------------------------------------ | ------------------------------------------------------------ | +| `AuthenticationProviderResponseGoogleIDPConfigTypeOidc` | oidc | +| `AuthenticationProviderResponseGoogleIDPConfigTypeGoogle` | google | +| `AuthenticationProviderResponseGoogleIDPConfigTypeGithub` | github | +| `AuthenticationProviderResponseGoogleIDPConfigTypeMicrosoft` | microsoft | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderresponsemicrosoftidpconfig.md b/internal/membershipclient/docs/models/components/authenticationproviderresponsemicrosoftidpconfig.md new file mode 100644 index 00000000..cc1072f5 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderresponsemicrosoftidpconfig.md @@ -0,0 +1,16 @@ +# AuthenticationProviderResponseMicrosoftIDPConfig + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | +| `Type` | [components.AuthenticationProviderResponseMicrosoftIDPConfigType](../../models/components/authenticationproviderresponsemicrosoftidpconfigtype.md) | :heavy_check_mark: | Type of the authentication provider | +| `Name` | *string* | :heavy_check_mark: | Name of the authentication provider | +| `ClientID` | *string* | :heavy_check_mark: | Client ID for the authentication provider | +| `ClientSecret` | *string* | :heavy_check_mark: | Client secret for the authentication provider | +| `Config` | [components.AuthenticationProviderResponseMicrosoftIDPConfigConfig](../../models/components/authenticationproviderresponsemicrosoftidpconfigconfig.md) | :heavy_check_mark: | N/A | +| `OrganizationID` | *string* | :heavy_check_mark: | Unique identifier for the authentication provider | +| `CreatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | Creation date of the authentication provider | +| `UpdatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | Last update date of the authentication provider | +| `RedirectURI` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderresponsemicrosoftidpconfigconfig.md b/internal/membershipclient/docs/models/components/authenticationproviderresponsemicrosoftidpconfigconfig.md new file mode 100644 index 00000000..df8760ab --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderresponsemicrosoftidpconfigconfig.md @@ -0,0 +1,8 @@ +# AuthenticationProviderResponseMicrosoftIDPConfigConfig + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------- | -------------------------------------- | -------------------------------------- | -------------------------------------- | +| `Tenant` | **string* | :heavy_minus_sign: | Tenant ID for Microsoft authentication | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderresponsemicrosoftidpconfigtype.md b/internal/membershipclient/docs/models/components/authenticationproviderresponsemicrosoftidpconfigtype.md new file mode 100644 index 00000000..415eca25 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderresponsemicrosoftidpconfigtype.md @@ -0,0 +1,13 @@ +# AuthenticationProviderResponseMicrosoftIDPConfigType + +Type of the authentication provider + + +## Values + +| Name | Value | +| --------------------------------------------------------------- | --------------------------------------------------------------- | +| `AuthenticationProviderResponseMicrosoftIDPConfigTypeOidc` | oidc | +| `AuthenticationProviderResponseMicrosoftIDPConfigTypeGoogle` | google | +| `AuthenticationProviderResponseMicrosoftIDPConfigTypeGithub` | github | +| `AuthenticationProviderResponseMicrosoftIDPConfigTypeMicrosoft` | microsoft | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderresponseoidcconfig.md b/internal/membershipclient/docs/models/components/authenticationproviderresponseoidcconfig.md new file mode 100644 index 00000000..903c6169 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderresponseoidcconfig.md @@ -0,0 +1,16 @@ +# AuthenticationProviderResponseOIDCConfig + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | +| `Type` | [components.AuthenticationProviderResponseOIDCConfigType](../../models/components/authenticationproviderresponseoidcconfigtype.md) | :heavy_check_mark: | Type of the authentication provider | +| `Name` | *string* | :heavy_check_mark: | Name of the authentication provider | +| `ClientID` | *string* | :heavy_check_mark: | Client ID for the authentication provider | +| `ClientSecret` | *string* | :heavy_check_mark: | Client secret for the authentication provider | +| `Config` | [components.AuthenticationProviderResponseOIDCConfigConfig](../../models/components/authenticationproviderresponseoidcconfigconfig.md) | :heavy_check_mark: | N/A | +| `OrganizationID` | *string* | :heavy_check_mark: | Unique identifier for the authentication provider | +| `CreatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | Creation date of the authentication provider | +| `UpdatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | Last update date of the authentication provider | +| `RedirectURI` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderresponseoidcconfigconfig.md b/internal/membershipclient/docs/models/components/authenticationproviderresponseoidcconfigconfig.md new file mode 100644 index 00000000..e88a2822 --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderresponseoidcconfigconfig.md @@ -0,0 +1,9 @@ +# AuthenticationProviderResponseOIDCConfigConfig + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `Issuer` | *string* | :heavy_check_mark: | OIDC issuer URL | +| `DiscoveryPath` | **string* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/authenticationproviderresponseoidcconfigtype.md b/internal/membershipclient/docs/models/components/authenticationproviderresponseoidcconfigtype.md new file mode 100644 index 00000000..1f3f356b --- /dev/null +++ b/internal/membershipclient/docs/models/components/authenticationproviderresponseoidcconfigtype.md @@ -0,0 +1,13 @@ +# AuthenticationProviderResponseOIDCConfigType + +Type of the authentication provider + + +## Values + +| Name | Value | +| ------------------------------------------------------- | ------------------------------------------------------- | +| `AuthenticationProviderResponseOIDCConfigTypeOidc` | oidc | +| `AuthenticationProviderResponseOIDCConfigTypeGoogle` | google | +| `AuthenticationProviderResponseOIDCConfigTypeGithub` | github | +| `AuthenticationProviderResponseOIDCConfigTypeMicrosoft` | microsoft | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/capability.md b/internal/membershipclient/docs/models/components/capability.md new file mode 100644 index 00000000..a089cd19 --- /dev/null +++ b/internal/membershipclient/docs/models/components/capability.md @@ -0,0 +1,8 @@ +# Capability + + +## Values + +| Name | Value | +| --------------------------- | --------------------------- | +| `CapabilityModuleSelection` | MODULE_SELECTION | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/clusterstatus.md b/internal/membershipclient/docs/models/components/clusterstatus.md new file mode 100644 index 00000000..0b60308e --- /dev/null +++ b/internal/membershipclient/docs/models/components/clusterstatus.md @@ -0,0 +1,7 @@ +# ClusterStatus + + +## Fields + +| Field | Type | Required | Description | +| ----------- | ----------- | ----------- | ----------- | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/createapplicationresponse.md b/internal/membershipclient/docs/models/components/createapplicationresponse.md new file mode 100644 index 00000000..37f02682 --- /dev/null +++ b/internal/membershipclient/docs/models/components/createapplicationresponse.md @@ -0,0 +1,8 @@ +# CreateApplicationResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `Data` | [*components.Application](../../models/components/application.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/createapplicationscoperequest.md b/internal/membershipclient/docs/models/components/createapplicationscoperequest.md new file mode 100644 index 00000000..6a0d0e09 --- /dev/null +++ b/internal/membershipclient/docs/models/components/createapplicationscoperequest.md @@ -0,0 +1,9 @@ +# CreateApplicationScopeRequest + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | +| `Description` | **string* | :heavy_minus_sign: | Scope description | +| `Label` | *string* | :heavy_check_mark: | The OAuth2 scope label (e.g., "custom:read") | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/createapplicationscoperesponse.md b/internal/membershipclient/docs/models/components/createapplicationscoperesponse.md new file mode 100644 index 00000000..d8bb7463 --- /dev/null +++ b/internal/membershipclient/docs/models/components/createapplicationscoperesponse.md @@ -0,0 +1,8 @@ +# CreateApplicationScopeResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | +| `Data` | [*components.Scope](../../models/components/scope.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/createclientresponseresponse.md b/internal/membershipclient/docs/models/components/createclientresponseresponse.md new file mode 100644 index 00000000..7082e1ff --- /dev/null +++ b/internal/membershipclient/docs/models/components/createclientresponseresponse.md @@ -0,0 +1,8 @@ +# CreateClientResponseResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | +| `Data` | [*components.CreateClientResponseResponseData](../../models/components/createclientresponseresponsedata.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/createclientresponseresponsedata.md b/internal/membershipclient/docs/models/components/createclientresponseresponsedata.md new file mode 100644 index 00000000..545fa47b --- /dev/null +++ b/internal/membershipclient/docs/models/components/createclientresponseresponsedata.md @@ -0,0 +1,14 @@ +# CreateClientResponseResponseData + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | +| `ID` | *string* | :heavy_check_mark: | Organization ID | +| `Secret` | [components.CreateClientResponseResponseSecret](../../models/components/createclientresponseresponsesecret.md) | :heavy_check_mark: | N/A | +| `Name` | *string* | :heavy_check_mark: | Name of the client | +| `Description` | *string* | :heavy_check_mark: | Description of the client | +| `CreatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | +| `UpdatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | +| `OwnerID` | *string* | :heavy_check_mark: | The ID of the owner of the client (DEPRECATED will be empty) | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/createclientresponseresponsesecret.md b/internal/membershipclient/docs/models/components/createclientresponseresponsesecret.md new file mode 100644 index 00000000..faa9f43f --- /dev/null +++ b/internal/membershipclient/docs/models/components/createclientresponseresponsesecret.md @@ -0,0 +1,9 @@ +# CreateClientResponseResponseSecret + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `LastDigits` | *string* | :heavy_check_mark: | N/A | +| `Clear` | **string* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/createdprivateregionresponse.md b/internal/membershipclient/docs/models/components/createdprivateregionresponse.md new file mode 100644 index 00000000..c434fcf6 --- /dev/null +++ b/internal/membershipclient/docs/models/components/createdprivateregionresponse.md @@ -0,0 +1,8 @@ +# CreatedPrivateRegionResponse + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | +| `Data` | [components.PrivateRegion](../../models/components/privateregion.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/createinvitationresponse.md b/internal/membershipclient/docs/models/components/createinvitationresponse.md new file mode 100644 index 00000000..57404aae --- /dev/null +++ b/internal/membershipclient/docs/models/components/createinvitationresponse.md @@ -0,0 +1,8 @@ +# CreateInvitationResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------- | +| `Data` | [*components.Invitation](../../models/components/invitation.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/createorganizationclientrequest.md b/internal/membershipclient/docs/models/components/createorganizationclientrequest.md new file mode 100644 index 00000000..d7190e0b --- /dev/null +++ b/internal/membershipclient/docs/models/components/createorganizationclientrequest.md @@ -0,0 +1,9 @@ +# CreateOrganizationClientRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------------- | ------------------------- | ------------------------- | ------------------------- | +| `Name` | **string* | :heavy_minus_sign: | Name of the client | +| `Description` | **string* | :heavy_minus_sign: | Description of the client | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/createorganizationclientresponse.md b/internal/membershipclient/docs/models/components/createorganizationclientresponse.md new file mode 100644 index 00000000..07163fca --- /dev/null +++ b/internal/membershipclient/docs/models/components/createorganizationclientresponse.md @@ -0,0 +1,8 @@ +# CreateOrganizationClientResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `Data` | [components.OrganizationClient](../../models/components/organizationclient.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/createorganizationrequest.md b/internal/membershipclient/docs/models/components/createorganizationrequest.md new file mode 100644 index 00000000..00878af0 --- /dev/null +++ b/internal/membershipclient/docs/models/components/createorganizationrequest.md @@ -0,0 +1,11 @@ +# CreateOrganizationRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | +| `Name` | *string* | :heavy_check_mark: | Organization name | +| `Domain` | **string* | :heavy_minus_sign: | Organization domain | +| `DefaultPolicyID` | **int64* | :heavy_minus_sign: | Default policy ID applied to new users | +| `OwnerID` | **string* | :heavy_minus_sign: | User ID of the owner of the organization (only when used with a non user agent) | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/createorganizationresponse.md b/internal/membershipclient/docs/models/components/createorganizationresponse.md new file mode 100644 index 00000000..5ab64439 --- /dev/null +++ b/internal/membershipclient/docs/models/components/createorganizationresponse.md @@ -0,0 +1,8 @@ +# CreateOrganizationResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| `Data` | [*components.OrganizationExpanded](../../models/components/organizationexpanded.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/createpolicyresponse.md b/internal/membershipclient/docs/models/components/createpolicyresponse.md new file mode 100644 index 00000000..202a71ef --- /dev/null +++ b/internal/membershipclient/docs/models/components/createpolicyresponse.md @@ -0,0 +1,8 @@ +# CreatePolicyResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | +| `Data` | [*components.Policy](../../models/components/policy.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/createprivateregionrequest.md b/internal/membershipclient/docs/models/components/createprivateregionrequest.md new file mode 100644 index 00000000..33f220e5 --- /dev/null +++ b/internal/membershipclient/docs/models/components/createprivateregionrequest.md @@ -0,0 +1,8 @@ +# CreatePrivateRegionRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `Name` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/createstackrequest.md b/internal/membershipclient/docs/models/components/createstackrequest.md new file mode 100644 index 00000000..d69c1aa1 --- /dev/null +++ b/internal/membershipclient/docs/models/components/createstackrequest.md @@ -0,0 +1,11 @@ +# CreateStackRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| `Name` | *string* | :heavy_check_mark: | Stack name | +| `Metadata` | map[string]*string* | :heavy_minus_sign: | N/A | +| `Version` | **string* | :heavy_minus_sign: | Supported only with agent version >= v0.7.0 | +| `RegionID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/createstackresponse.md b/internal/membershipclient/docs/models/components/createstackresponse.md new file mode 100644 index 00000000..f19f79f8 --- /dev/null +++ b/internal/membershipclient/docs/models/components/createstackresponse.md @@ -0,0 +1,8 @@ +# CreateStackResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------- | +| `Data` | [*components.Stack](../../models/components/stack.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/createuserrequest.md b/internal/membershipclient/docs/models/components/createuserrequest.md new file mode 100644 index 00000000..9056605e --- /dev/null +++ b/internal/membershipclient/docs/models/components/createuserrequest.md @@ -0,0 +1,8 @@ +# CreateUserRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------- | ----------------------------------- | ----------------------------------- | ----------------------------------- | ----------------------------------- | +| `Email` | *string* | :heavy_check_mark: | Email address of the user to create | user@example.com | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/createuserresponse.md b/internal/membershipclient/docs/models/components/createuserresponse.md new file mode 100644 index 00000000..63bd364b --- /dev/null +++ b/internal/membershipclient/docs/models/components/createuserresponse.md @@ -0,0 +1,8 @@ +# CreateUserResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | +| `Data` | [*components.User](../../models/components/user.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/cursor.md b/internal/membershipclient/docs/models/components/cursor.md new file mode 100644 index 00000000..949bbb5d --- /dev/null +++ b/internal/membershipclient/docs/models/components/cursor.md @@ -0,0 +1,12 @@ +# Cursor + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `PageSize` | *int64* | :heavy_check_mark: | N/A | 15 | +| `HasMore` | *bool* | :heavy_check_mark: | N/A | false | +| `Previous` | **string* | :heavy_minus_sign: | N/A | YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= | +| `Next` | **string* | :heavy_minus_sign: | N/A | | +| `Data` | [][components.Application](../../models/components/application.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/data.md b/internal/membershipclient/docs/models/components/data.md new file mode 100644 index 00000000..7c33fb2f --- /dev/null +++ b/internal/membershipclient/docs/models/components/data.md @@ -0,0 +1,29 @@ +# Data + + +## Supported Types + +### AuthenticationProviderResponseGoogleIDPConfig + +```go +data := components.CreateDataAuthenticationProviderResponseGoogleIDPConfig(components.AuthenticationProviderResponseGoogleIDPConfig{/* values here */}) +``` + +### AuthenticationProviderResponseMicrosoftIDPConfig + +```go +data := components.CreateDataAuthenticationProviderResponseMicrosoftIDPConfig(components.AuthenticationProviderResponseMicrosoftIDPConfig{/* values here */}) +``` + +### AuthenticationProviderResponseGithubIDPConfig + +```go +data := components.CreateDataAuthenticationProviderResponseGithubIDPConfig(components.AuthenticationProviderResponseGithubIDPConfig{/* values here */}) +``` + +### AuthenticationProviderResponseOIDCConfig + +```go +data := components.CreateDataAuthenticationProviderResponseOIDCConfig(components.AuthenticationProviderResponseOIDCConfig{/* values here */}) +``` + diff --git a/internal/membershipclient/docs/models/components/enableapplicationfororganizationresponse.md b/internal/membershipclient/docs/models/components/enableapplicationfororganizationresponse.md new file mode 100644 index 00000000..67141a7e --- /dev/null +++ b/internal/membershipclient/docs/models/components/enableapplicationfororganizationresponse.md @@ -0,0 +1,8 @@ +# EnableApplicationForOrganizationResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | +| `Data` | [*components.OrganizationApplication](../../models/components/organizationapplication.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/error.md b/internal/membershipclient/docs/models/components/error.md new file mode 100644 index 00000000..69299f27 --- /dev/null +++ b/internal/membershipclient/docs/models/components/error.md @@ -0,0 +1,9 @@ +# Error + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `ErrorCode` | *string* | :heavy_check_mark: | N/A | +| `ErrorMessage` | **string* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/expectedstatus.md b/internal/membershipclient/docs/models/components/expectedstatus.md new file mode 100644 index 00000000..889e38d0 --- /dev/null +++ b/internal/membershipclient/docs/models/components/expectedstatus.md @@ -0,0 +1,10 @@ +# ExpectedStatus + + +## Values + +| Name | Value | +| ------------------------ | ------------------------ | +| `ExpectedStatusReady` | READY | +| `ExpectedStatusDisabled` | DISABLED | +| `ExpectedStatusDeleted` | DELETED | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/getapplicationresponse.md b/internal/membershipclient/docs/models/components/getapplicationresponse.md new file mode 100644 index 00000000..6f59f1e2 --- /dev/null +++ b/internal/membershipclient/docs/models/components/getapplicationresponse.md @@ -0,0 +1,8 @@ +# GetApplicationResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| `Data` | [*components.ApplicationWithScope](../../models/components/applicationwithscope.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/getregionresponse.md b/internal/membershipclient/docs/models/components/getregionresponse.md new file mode 100644 index 00000000..1d2d2886 --- /dev/null +++ b/internal/membershipclient/docs/models/components/getregionresponse.md @@ -0,0 +1,8 @@ +# GetRegionResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | +| `Data` | [components.AnyRegion](../../models/components/anyregion.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/getregionversionsresponse.md b/internal/membershipclient/docs/models/components/getregionversionsresponse.md new file mode 100644 index 00000000..7dc88160 --- /dev/null +++ b/internal/membershipclient/docs/models/components/getregionversionsresponse.md @@ -0,0 +1,8 @@ +# GetRegionVersionsResponse + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | ---------------------------------------------------------- | +| `Data` | [][components.Version](../../models/components/version.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/httpmetadata.md b/internal/membershipclient/docs/models/components/httpmetadata.md new file mode 100644 index 00000000..df1fdd59 --- /dev/null +++ b/internal/membershipclient/docs/models/components/httpmetadata.md @@ -0,0 +1,9 @@ +# HTTPMetadata + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | +| `Response` | [*http.Response](https://pkg.go.dev/net/http#Response) | :heavy_check_mark: | Raw HTTP response; suitable for custom response parsing | +| `Request` | [*http.Request](https://pkg.go.dev/net/http#Request) | :heavy_check_mark: | Raw HTTP request; suitable for debugging | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/invitation.md b/internal/membershipclient/docs/models/components/invitation.md new file mode 100644 index 00000000..5f1f8f17 --- /dev/null +++ b/internal/membershipclient/docs/models/components/invitation.md @@ -0,0 +1,18 @@ +# Invitation + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | +| `ID` | *string* | :heavy_check_mark: | N/A | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `UserEmail` | *string* | :heavy_check_mark: | N/A | +| `Status` | [components.InvitationStatus](../../models/components/invitationstatus.md) | :heavy_check_mark: | N/A | +| `CreationDate` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | +| `UpdatedAt` | **string* | :heavy_minus_sign: | N/A | +| `UserID` | **string* | :heavy_minus_sign: | N/A | +| `OrganizationAccess` | [*components.OrganizationAccess](../../models/components/organizationaccess.md) | :heavy_minus_sign: | N/A | +| `ExpiresAt` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | +| `CreatorID` | **string* | :heavy_minus_sign: | N/A | +| `LastUpdate` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/invitationstatus.md b/internal/membershipclient/docs/models/components/invitationstatus.md new file mode 100644 index 00000000..b0193609 --- /dev/null +++ b/internal/membershipclient/docs/models/components/invitationstatus.md @@ -0,0 +1,11 @@ +# InvitationStatus + + +## Values + +| Name | Value | +| --------------------------- | --------------------------- | +| `InvitationStatusPending` | PENDING | +| `InvitationStatusAccepted` | ACCEPTED | +| `InvitationStatusRejected` | REJECTED | +| `InvitationStatusCancelled` | CANCELLED | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/listapplicationsresponse.md b/internal/membershipclient/docs/models/components/listapplicationsresponse.md new file mode 100644 index 00000000..da707f35 --- /dev/null +++ b/internal/membershipclient/docs/models/components/listapplicationsresponse.md @@ -0,0 +1,8 @@ +# ListApplicationsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | +| `Cursor` | [*components.Cursor](../../models/components/cursor.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/listinvitationsresponse.md b/internal/membershipclient/docs/models/components/listinvitationsresponse.md new file mode 100644 index 00000000..45456e50 --- /dev/null +++ b/internal/membershipclient/docs/models/components/listinvitationsresponse.md @@ -0,0 +1,8 @@ +# ListInvitationsResponse + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | +| `Data` | [][components.Invitation](../../models/components/invitation.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/listmodulesresponse.md b/internal/membershipclient/docs/models/components/listmodulesresponse.md new file mode 100644 index 00000000..d1de1c15 --- /dev/null +++ b/internal/membershipclient/docs/models/components/listmodulesresponse.md @@ -0,0 +1,8 @@ +# ListModulesResponse + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `Data` | [][components.Module](../../models/components/module.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/listorganizationexpandedresponse.md b/internal/membershipclient/docs/models/components/listorganizationexpandedresponse.md new file mode 100644 index 00000000..326db67f --- /dev/null +++ b/internal/membershipclient/docs/models/components/listorganizationexpandedresponse.md @@ -0,0 +1,8 @@ +# ListOrganizationExpandedResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | +| `Data` | [][components.OrganizationExpanded](../../models/components/organizationexpanded.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/listpoliciesresponse.md b/internal/membershipclient/docs/models/components/listpoliciesresponse.md new file mode 100644 index 00000000..8a483704 --- /dev/null +++ b/internal/membershipclient/docs/models/components/listpoliciesresponse.md @@ -0,0 +1,8 @@ +# ListPoliciesResponse + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `Data` | [][components.Policy](../../models/components/policy.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/listregionsresponse.md b/internal/membershipclient/docs/models/components/listregionsresponse.md new file mode 100644 index 00000000..bd98c631 --- /dev/null +++ b/internal/membershipclient/docs/models/components/listregionsresponse.md @@ -0,0 +1,8 @@ +# ListRegionsResponse + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | +| `Data` | [][components.AnyRegion](../../models/components/anyregion.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/liststacksresponse.md b/internal/membershipclient/docs/models/components/liststacksresponse.md new file mode 100644 index 00000000..c7bb25e1 --- /dev/null +++ b/internal/membershipclient/docs/models/components/liststacksresponse.md @@ -0,0 +1,8 @@ +# ListStacksResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | +| `Data` | [][components.Stack](../../models/components/stack.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/listusersresponse.md b/internal/membershipclient/docs/models/components/listusersresponse.md new file mode 100644 index 00000000..28623a62 --- /dev/null +++ b/internal/membershipclient/docs/models/components/listusersresponse.md @@ -0,0 +1,8 @@ +# ListUsersResponse + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | +| `Data` | [][components.OrganizationUser](../../models/components/organizationuser.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/log.md b/internal/membershipclient/docs/models/components/log.md new file mode 100644 index 00000000..ff8ef138 --- /dev/null +++ b/internal/membershipclient/docs/models/components/log.md @@ -0,0 +1,13 @@ +# Log + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `Seq` | *string* | :heavy_check_mark: | N/A | 1e6f8b6e-1b6b-4b3b-8b3b-1b6b4b3b8b3b | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | | +| `UserID` | *string* | :heavy_check_mark: | N/A | | +| `Action` | *string* | :heavy_check_mark: | N/A | | +| `Date` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | | +| `Data` | [components.LogData](../../models/components/logdata.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/logcursor.md b/internal/membershipclient/docs/models/components/logcursor.md new file mode 100644 index 00000000..ef3f2af7 --- /dev/null +++ b/internal/membershipclient/docs/models/components/logcursor.md @@ -0,0 +1,8 @@ +# LogCursor + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | -------------------------------------------------------------------- | +| `Data` | [components.LogCursorData](../../models/components/logcursordata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/logcursordata.md b/internal/membershipclient/docs/models/components/logcursordata.md new file mode 100644 index 00000000..b96d5072 --- /dev/null +++ b/internal/membershipclient/docs/models/components/logcursordata.md @@ -0,0 +1,12 @@ +# LogCursorData + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | -------------------------------------------------- | +| `PageSize` | *int64* | :heavy_check_mark: | N/A | 15 | +| `HasMore` | *bool* | :heavy_check_mark: | N/A | false | +| `Previous` | **string* | :heavy_minus_sign: | N/A | YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= | +| `Next` | **string* | :heavy_minus_sign: | N/A | | +| `Data` | [][components.Log](../../models/components/log.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/logdata.md b/internal/membershipclient/docs/models/components/logdata.md new file mode 100644 index 00000000..54cd59d9 --- /dev/null +++ b/internal/membershipclient/docs/models/components/logdata.md @@ -0,0 +1,7 @@ +# LogData + + +## Fields + +| Field | Type | Required | Description | +| ----------- | ----------- | ----------- | ----------- | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/module.md b/internal/membershipclient/docs/models/components/module.md new file mode 100644 index 00000000..5f8115cc --- /dev/null +++ b/internal/membershipclient/docs/models/components/module.md @@ -0,0 +1,13 @@ +# Module + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------- | --------------------------------------------------------------------- | +| `Name` | *string* | :heavy_check_mark: | N/A | +| `State` | [components.ModuleState](../../models/components/modulestate.md) | :heavy_check_mark: | N/A | +| `Status` | [components.ModuleStatus](../../models/components/modulestatus.md) | :heavy_check_mark: | N/A | +| `LastStatusUpdate` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | +| `LastStateUpdate` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | +| `ClusterStatus` | [*components.ClusterStatus](../../models/components/clusterstatus.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/modulestate.md b/internal/membershipclient/docs/models/components/modulestate.md new file mode 100644 index 00000000..2fa9789a --- /dev/null +++ b/internal/membershipclient/docs/models/components/modulestate.md @@ -0,0 +1,9 @@ +# ModuleState + + +## Values + +| Name | Value | +| --------------------- | --------------------- | +| `ModuleStateEnabled` | ENABLED | +| `ModuleStateDisabled` | DISABLED | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/modulestatus.md b/internal/membershipclient/docs/models/components/modulestatus.md new file mode 100644 index 00000000..de076362 --- /dev/null +++ b/internal/membershipclient/docs/models/components/modulestatus.md @@ -0,0 +1,11 @@ +# ModuleStatus + + +## Values + +| Name | Value | +| ------------------------- | ------------------------- | +| `ModuleStatusUnknown` | UNKNOWN | +| `ModuleStatusProgressing` | PROGRESSING | +| `ModuleStatusReady` | READY | +| `ModuleStatusDeleted` | DELETED | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/organizationaccess.md b/internal/membershipclient/docs/models/components/organizationaccess.md new file mode 100644 index 00000000..657ed81c --- /dev/null +++ b/internal/membershipclient/docs/models/components/organizationaccess.md @@ -0,0 +1,10 @@ +# OrganizationAccess + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------- | ----------------------------- | ----------------------------- | ----------------------------- | +| `Email` | *string* | :heavy_check_mark: | N/A | +| `ID` | *string* | :heavy_check_mark: | N/A | +| `PolicyID` | *int64* | :heavy_check_mark: | Policy ID applied to the user | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/organizationapplication.md b/internal/membershipclient/docs/models/components/organizationapplication.md new file mode 100644 index 00000000..f1628e12 --- /dev/null +++ b/internal/membershipclient/docs/models/components/organizationapplication.md @@ -0,0 +1,10 @@ +# OrganizationApplication + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | +| `OrganizationID` | *string* | :heavy_check_mark: | Organization ID | +| `ApplicationID` | *string* | :heavy_check_mark: | Application ID | +| `CreatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | Creation date | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/organizationclient.md b/internal/membershipclient/docs/models/components/organizationclient.md new file mode 100644 index 00000000..1a3d184f --- /dev/null +++ b/internal/membershipclient/docs/models/components/organizationclient.md @@ -0,0 +1,13 @@ +# OrganizationClient + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | +| `ID` | *string* | :heavy_check_mark: | Organization ID | +| `Secret` | [components.OrganizationClientSecret](../../models/components/organizationclientsecret.md) | :heavy_check_mark: | N/A | +| `Name` | *string* | :heavy_check_mark: | Name of the client | +| `Description` | *string* | :heavy_check_mark: | Description of the client | +| `CreatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | +| `UpdatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/organizationclientsecret.md b/internal/membershipclient/docs/models/components/organizationclientsecret.md new file mode 100644 index 00000000..aaa408e5 --- /dev/null +++ b/internal/membershipclient/docs/models/components/organizationclientsecret.md @@ -0,0 +1,9 @@ +# OrganizationClientSecret + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `LastDigits` | *string* | :heavy_check_mark: | N/A | +| `Clear` | **string* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/organizationdata.md b/internal/membershipclient/docs/models/components/organizationdata.md new file mode 100644 index 00000000..6651e0dd --- /dev/null +++ b/internal/membershipclient/docs/models/components/organizationdata.md @@ -0,0 +1,10 @@ +# OrganizationData + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------- | -------------------------------------- | -------------------------------------- | -------------------------------------- | +| `Name` | *string* | :heavy_check_mark: | Organization name | +| `Domain` | **string* | :heavy_minus_sign: | Organization domain | +| `DefaultPolicyID` | *int64* | :heavy_check_mark: | Default policy ID applied to new users | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/organizationexpanded.md b/internal/membershipclient/docs/models/components/organizationexpanded.md new file mode 100644 index 00000000..0702bacc --- /dev/null +++ b/internal/membershipclient/docs/models/components/organizationexpanded.md @@ -0,0 +1,19 @@ +# OrganizationExpanded + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | +| `Name` | *string* | :heavy_check_mark: | Organization name | +| `Domain` | **string* | :heavy_minus_sign: | Organization domain | +| `DefaultPolicyID` | *int64* | :heavy_check_mark: | Default policy ID applied to new users | +| `ID` | *string* | :heavy_check_mark: | Organization ID | +| `OwnerID` | *string* | :heavy_check_mark: | Owner ID | +| `AvailableStacks` | **int64* | :heavy_minus_sign: | Number of available stacks | +| `AvailableSandboxes` | **int64* | :heavy_minus_sign: | Number of available sandboxes | +| `CreatedAt` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | +| `UpdatedAt` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | +| `TotalStacks` | **int64* | :heavy_minus_sign: | N/A | +| `TotalUsers` | **int64* | :heavy_minus_sign: | N/A | +| `Owner` | [*components.User](../../models/components/user.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/organizationfeature.md b/internal/membershipclient/docs/models/components/organizationfeature.md new file mode 100644 index 00000000..4493e9fe --- /dev/null +++ b/internal/membershipclient/docs/models/components/organizationfeature.md @@ -0,0 +1,10 @@ +# OrganizationFeature + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `Name` | *string* | :heavy_check_mark: | N/A | +| `CreatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/organizationuser.md b/internal/membershipclient/docs/models/components/organizationuser.md new file mode 100644 index 00000000..36cd0cec --- /dev/null +++ b/internal/membershipclient/docs/models/components/organizationuser.md @@ -0,0 +1,10 @@ +# OrganizationUser + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------- | ----------------------------- | ----------------------------- | ----------------------------- | +| `Email` | *string* | :heavy_check_mark: | N/A | +| `ID` | *string* | :heavy_check_mark: | N/A | +| `PolicyID` | *int64* | :heavy_check_mark: | Policy ID applied to the user | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/policy.md b/internal/membershipclient/docs/models/components/policy.md new file mode 100644 index 00000000..487b3dad --- /dev/null +++ b/internal/membershipclient/docs/models/components/policy.md @@ -0,0 +1,15 @@ +# Policy + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | +| `Name` | *string* | :heavy_check_mark: | Policy name | +| `Description` | **string* | :heavy_minus_sign: | Policy description | +| `ID` | *int64* | :heavy_check_mark: | Policy ID | +| `OrganizationID` | **string* | :heavy_minus_sign: | Organization ID | +| `Protected` | *bool* | :heavy_check_mark: | Whether the policy is protected from modification | +| `Scopes` | [][components.Scope](../../models/components/scope.md) | :heavy_minus_sign: | List of scopes assigned to the policy (only present when fetched via GET endpoint) | +| `CreatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | Creation date | +| `UpdatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | Last update date | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/policydata.md b/internal/membershipclient/docs/models/components/policydata.md new file mode 100644 index 00000000..89d3e596 --- /dev/null +++ b/internal/membershipclient/docs/models/components/policydata.md @@ -0,0 +1,9 @@ +# PolicyData + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `Name` | *string* | :heavy_check_mark: | Policy name | +| `Description` | **string* | :heavy_minus_sign: | Policy description | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/privateregion.md b/internal/membershipclient/docs/models/components/privateregion.md new file mode 100644 index 00000000..0214f6e4 --- /dev/null +++ b/internal/membershipclient/docs/models/components/privateregion.md @@ -0,0 +1,21 @@ +# PrivateRegion + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| `ID` | *string* | :heavy_check_mark: | N/A | +| `BaseURL` | *string* | :heavy_check_mark: | N/A | +| `CreatedAt` | *string* | :heavy_check_mark: | N/A | +| `Active` | *bool* | :heavy_check_mark: | N/A | +| `LastPing` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | +| `Name` | *string* | :heavy_check_mark: | N/A | +| `Capabilities` | [components.RegionCapability](../../models/components/regioncapability.md) | :heavy_check_mark: | N/A | +| `AgentID` | *string* | :heavy_check_mark: | N/A | +| `Outdated` | *bool* | :heavy_check_mark: | N/A | +| `CreatorID` | **string* | :heavy_minus_sign: | N/A | +| `Version` | **string* | :heavy_minus_sign: | N/A | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `CreatorId1` | *string* | :heavy_check_mark: | N/A | +| `Secret` | [*components.PrivateRegionSecret](../../models/components/privateregionsecret.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/privateregionsecret.md b/internal/membershipclient/docs/models/components/privateregionsecret.md new file mode 100644 index 00000000..82adf5f8 --- /dev/null +++ b/internal/membershipclient/docs/models/components/privateregionsecret.md @@ -0,0 +1,9 @@ +# PrivateRegionSecret + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `LastDigits` | *string* | :heavy_check_mark: | N/A | +| `Clear` | **string* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/readorganizationclientresponse.md b/internal/membershipclient/docs/models/components/readorganizationclientresponse.md new file mode 100644 index 00000000..f408fef9 --- /dev/null +++ b/internal/membershipclient/docs/models/components/readorganizationclientresponse.md @@ -0,0 +1,8 @@ +# ReadOrganizationClientResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `Data` | [components.OrganizationClient](../../models/components/organizationclient.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/readorganizationclientsresponse.md b/internal/membershipclient/docs/models/components/readorganizationclientsresponse.md new file mode 100644 index 00000000..7380695d --- /dev/null +++ b/internal/membershipclient/docs/models/components/readorganizationclientsresponse.md @@ -0,0 +1,8 @@ +# ReadOrganizationClientsResponse + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | +| `Data` | [components.ReadOrganizationClientsResponseData](../../models/components/readorganizationclientsresponsedata.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/readorganizationclientsresponsedata.md b/internal/membershipclient/docs/models/components/readorganizationclientsresponsedata.md new file mode 100644 index 00000000..abcac9b1 --- /dev/null +++ b/internal/membershipclient/docs/models/components/readorganizationclientsresponsedata.md @@ -0,0 +1,12 @@ +# ReadOrganizationClientsResponseData + + +## Fields + +| Field | Type | Required | Description | Example | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `PageSize` | *int64* | :heavy_check_mark: | N/A | 15 | +| `HasMore` | *bool* | :heavy_check_mark: | N/A | false | +| `Previous` | **string* | :heavy_minus_sign: | N/A | YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= | +| `Next` | **string* | :heavy_minus_sign: | N/A | | +| `Data` | [][components.OrganizationClient](../../models/components/organizationclient.md) | :heavy_check_mark: | N/A | | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/readorganizationresponse.md b/internal/membershipclient/docs/models/components/readorganizationresponse.md new file mode 100644 index 00000000..b1f615e8 --- /dev/null +++ b/internal/membershipclient/docs/models/components/readorganizationresponse.md @@ -0,0 +1,8 @@ +# ReadOrganizationResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| `Data` | [*components.OrganizationExpanded](../../models/components/organizationexpanded.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/readorganizationuserresponse.md b/internal/membershipclient/docs/models/components/readorganizationuserresponse.md new file mode 100644 index 00000000..145a39ae --- /dev/null +++ b/internal/membershipclient/docs/models/components/readorganizationuserresponse.md @@ -0,0 +1,8 @@ +# ReadOrganizationUserResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | +| `Data` | [*components.ReadOrganizationUserResponseData](../../models/components/readorganizationuserresponsedata.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/readorganizationuserresponsedata.md b/internal/membershipclient/docs/models/components/readorganizationuserresponsedata.md new file mode 100644 index 00000000..e36f5440 --- /dev/null +++ b/internal/membershipclient/docs/models/components/readorganizationuserresponsedata.md @@ -0,0 +1,10 @@ +# ReadOrganizationUserResponseData + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------- | ----------------------------- | ----------------------------- | ----------------------------- | +| `Email` | *string* | :heavy_check_mark: | N/A | +| `ID` | *string* | :heavy_check_mark: | N/A | +| `PolicyID` | *int64* | :heavy_check_mark: | Policy ID applied to the user | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/readpolicyresponse.md b/internal/membershipclient/docs/models/components/readpolicyresponse.md new file mode 100644 index 00000000..ab514ada --- /dev/null +++ b/internal/membershipclient/docs/models/components/readpolicyresponse.md @@ -0,0 +1,8 @@ +# ReadPolicyResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | +| `Data` | [*components.Policy](../../models/components/policy.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/readstackuseraccess.md b/internal/membershipclient/docs/models/components/readstackuseraccess.md new file mode 100644 index 00000000..6a222a55 --- /dev/null +++ b/internal/membershipclient/docs/models/components/readstackuseraccess.md @@ -0,0 +1,8 @@ +# ReadStackUserAccess + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | +| `Data` | [*components.ReadStackUserAccessData](../../models/components/readstackuseraccessdata.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/readstackuseraccessdata.md b/internal/membershipclient/docs/models/components/readstackuseraccessdata.md new file mode 100644 index 00000000..c73d2bcb --- /dev/null +++ b/internal/membershipclient/docs/models/components/readstackuseraccessdata.md @@ -0,0 +1,11 @@ +# ReadStackUserAccessData + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| `StackID` | *string* | :heavy_check_mark: | Stack ID | +| `UserID` | *string* | :heavy_check_mark: | User ID | +| `Email` | *string* | :heavy_check_mark: | User email | +| `PolicyID` | *int64* | :heavy_check_mark: | Policy ID applied to the user for the stack | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/readuserresponse.md b/internal/membershipclient/docs/models/components/readuserresponse.md new file mode 100644 index 00000000..dfe6eddb --- /dev/null +++ b/internal/membershipclient/docs/models/components/readuserresponse.md @@ -0,0 +1,8 @@ +# ReadUserResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | --------------------------------------------------- | +| `Data` | [*components.User](../../models/components/user.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/region.md b/internal/membershipclient/docs/models/components/region.md new file mode 100644 index 00000000..45b1fc5d --- /dev/null +++ b/internal/membershipclient/docs/models/components/region.md @@ -0,0 +1,18 @@ +# Region + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | +| `ID` | *string* | :heavy_check_mark: | N/A | +| `BaseURL` | *string* | :heavy_check_mark: | N/A | +| `CreatedAt` | *string* | :heavy_check_mark: | N/A | +| `Active` | *bool* | :heavy_check_mark: | N/A | +| `LastPing` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | +| `Name` | *string* | :heavy_check_mark: | N/A | +| `Capabilities` | [components.RegionCapability](../../models/components/regioncapability.md) | :heavy_check_mark: | N/A | +| `AgentID` | *string* | :heavy_check_mark: | N/A | +| `Outdated` | *bool* | :heavy_check_mark: | N/A | +| `CreatorID` | **string* | :heavy_minus_sign: | N/A | +| `Version` | **string* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/regioncapability.md b/internal/membershipclient/docs/models/components/regioncapability.md new file mode 100644 index 00000000..8c24a99e --- /dev/null +++ b/internal/membershipclient/docs/models/components/regioncapability.md @@ -0,0 +1,9 @@ +# RegionCapability + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `ModuleList` | []*string* | :heavy_minus_sign: | N/A | +| `Ee` | []*string* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/scope.md b/internal/membershipclient/docs/models/components/scope.md new file mode 100644 index 00000000..f6b4984e --- /dev/null +++ b/internal/membershipclient/docs/models/components/scope.md @@ -0,0 +1,14 @@ +# Scope + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | -------------------------------------------- | +| `ID` | *int64* | :heavy_check_mark: | Scope ID | +| `Label` | *string* | :heavy_check_mark: | The OAuth2 scope label (e.g., "custom:read") | +| `Description` | **string* | :heavy_minus_sign: | Scope description | +| `ApplicationID` | **string* | :heavy_minus_sign: | Application ID (null for global scopes) | +| `Protected` | **bool* | :heavy_minus_sign: | Whether the scope is protected | +| `CreatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | Creation timestamp | +| `UpdatedAt` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | Last update timestamp | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/security.md b/internal/membershipclient/docs/models/components/security.md new file mode 100644 index 00000000..5fba54a2 --- /dev/null +++ b/internal/membershipclient/docs/models/components/security.md @@ -0,0 +1,8 @@ +# Security + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `Oauth2` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/serverinfo.md b/internal/membershipclient/docs/models/components/serverinfo.md new file mode 100644 index 00000000..e6f9756f --- /dev/null +++ b/internal/membershipclient/docs/models/components/serverinfo.md @@ -0,0 +1,10 @@ +# ServerInfo + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- | +| `Version` | *string* | :heavy_check_mark: | N/A | +| `Capabilities` | [][components.Capability](../../models/components/capability.md) | :heavy_minus_sign: | N/A | +| `ConsoleURL` | **string* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/stack.md b/internal/membershipclient/docs/models/components/stack.md new file mode 100644 index 00000000..8ae37965 --- /dev/null +++ b/internal/membershipclient/docs/models/components/stack.md @@ -0,0 +1,33 @@ +# Stack + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | +| `Name` | *string* | :heavy_check_mark: | Stack name | +| `Metadata` | map[string]*string* | :heavy_minus_sign: | N/A | +| `Version` | **string* | :heavy_minus_sign: | Supported only with agent version >= v0.7.0 | +| `Status` | [components.StackStatus](../../models/components/stackstatus.md) | :heavy_check_mark: | N/A | +| `State` | [components.StackState](../../models/components/stackstate.md) | :heavy_check_mark: | N/A | +| `ExpectedStatus` | [components.ExpectedStatus](../../models/components/expectedstatus.md) | :heavy_check_mark: | N/A | +| `LastStateUpdate` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | +| `LastExpectedStatusUpdate` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | +| `LastStatusUpdate` | [time.Time](https://pkg.go.dev/time#Time) | :heavy_check_mark: | N/A | +| `WarnedAt` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | +| `DisposableSince` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | +| `Reachable` | *bool* | :heavy_check_mark: | Stack is reachable through Stargate | +| `LastReachableUpdate` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | Last time the stack was reachable | +| `ID` | *string* | :heavy_check_mark: | Stack ID | +| `OrganizationID` | *string* | :heavy_check_mark: | Organization ID | +| `URI` | *string* | :heavy_check_mark: | Base stack uri | +| `RegionID` | *string* | :heavy_check_mark: | The region where the stack is installed | +| `Region` | [*components.Region](../../models/components/region.md) | :heavy_minus_sign: | N/A | +| `StargateEnabled` | *bool* | :heavy_check_mark: | N/A | +| `CreatedAt` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | +| `DeletedAt` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | +| `DisabledAt` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | +| `AuditEnabled` | **bool* | :heavy_minus_sign: | N/A | +| `Synchronised` | *bool* | :heavy_check_mark: | N/A | +| `UpdatedAt` | [*time.Time](https://pkg.go.dev/time#Time) | :heavy_minus_sign: | N/A | +| `Modules` | [][components.Module](../../models/components/module.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/stackdata.md b/internal/membershipclient/docs/models/components/stackdata.md new file mode 100644 index 00000000..686ab05a --- /dev/null +++ b/internal/membershipclient/docs/models/components/stackdata.md @@ -0,0 +1,9 @@ +# StackData + + +## Fields + +| Field | Type | Required | Description | +| ------------------- | ------------------- | ------------------- | ------------------- | +| `Name` | *string* | :heavy_check_mark: | Stack name | +| `Metadata` | map[string]*string* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/stackstate.md b/internal/membershipclient/docs/models/components/stackstate.md new file mode 100644 index 00000000..238576c2 --- /dev/null +++ b/internal/membershipclient/docs/models/components/stackstate.md @@ -0,0 +1,10 @@ +# StackState + + +## Values + +| Name | Value | +| -------------------- | -------------------- | +| `StackStateActive` | ACTIVE | +| `StackStateDisabled` | DISABLED | +| `StackStateDeleted` | DELETED | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/stackstatus.md b/internal/membershipclient/docs/models/components/stackstatus.md new file mode 100644 index 00000000..7c1085a7 --- /dev/null +++ b/internal/membershipclient/docs/models/components/stackstatus.md @@ -0,0 +1,12 @@ +# StackStatus + + +## Values + +| Name | Value | +| ------------------------ | ------------------------ | +| `StackStatusUnknown` | UNKNOWN | +| `StackStatusProgressing` | PROGRESSING | +| `StackStatusReady` | READY | +| `StackStatusDisabled` | DISABLED | +| `StackStatusDeleted` | DELETED | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/stackuseraccessresponse.md b/internal/membershipclient/docs/models/components/stackuseraccessresponse.md new file mode 100644 index 00000000..e7a4eda1 --- /dev/null +++ b/internal/membershipclient/docs/models/components/stackuseraccessresponse.md @@ -0,0 +1,8 @@ +# StackUserAccessResponse + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | +| `Data` | [][components.StackUserAccessResponseData](../../models/components/stackuseraccessresponsedata.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/stackuseraccessresponsedata.md b/internal/membershipclient/docs/models/components/stackuseraccessresponsedata.md new file mode 100644 index 00000000..934ce7f7 --- /dev/null +++ b/internal/membershipclient/docs/models/components/stackuseraccessresponsedata.md @@ -0,0 +1,11 @@ +# StackUserAccessResponseData + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| `StackID` | *string* | :heavy_check_mark: | Stack ID | +| `UserID` | *string* | :heavy_check_mark: | User ID | +| `Email` | *string* | :heavy_check_mark: | User email | +| `PolicyID` | *int64* | :heavy_check_mark: | Policy ID applied to the user for the stack | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/stackversion.md b/internal/membershipclient/docs/models/components/stackversion.md new file mode 100644 index 00000000..c6450f0d --- /dev/null +++ b/internal/membershipclient/docs/models/components/stackversion.md @@ -0,0 +1,8 @@ +# StackVersion + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | ------------------------------------------- | +| `Version` | **string* | :heavy_minus_sign: | Supported only with agent version >= v0.7.0 | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/systemrole.md b/internal/membershipclient/docs/models/components/systemrole.md new file mode 100644 index 00000000..ab8b19e9 --- /dev/null +++ b/internal/membershipclient/docs/models/components/systemrole.md @@ -0,0 +1,9 @@ +# SystemRole + + +## Values + +| Name | Value | +| ------------------ | ------------------ | +| `SystemRoleUser` | USER | +| `SystemRoleSystem` | SYSTEM | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/updateapplicationresponse.md b/internal/membershipclient/docs/models/components/updateapplicationresponse.md new file mode 100644 index 00000000..38df4edd --- /dev/null +++ b/internal/membershipclient/docs/models/components/updateapplicationresponse.md @@ -0,0 +1,8 @@ +# UpdateApplicationResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | ----------------------------------------------------------------- | +| `Data` | [*components.Application](../../models/components/application.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/updateorganizationclientrequest.md b/internal/membershipclient/docs/models/components/updateorganizationclientrequest.md new file mode 100644 index 00000000..2e15158e --- /dev/null +++ b/internal/membershipclient/docs/models/components/updateorganizationclientrequest.md @@ -0,0 +1,9 @@ +# UpdateOrganizationClientRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------------- | ------------------------- | ------------------------- | ------------------------- | +| `Name` | *string* | :heavy_check_mark: | Name of the client | +| `Description` | **string* | :heavy_minus_sign: | Description of the client | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/updateorganizationuserrequest.md b/internal/membershipclient/docs/models/components/updateorganizationuserrequest.md new file mode 100644 index 00000000..0aaf5f50 --- /dev/null +++ b/internal/membershipclient/docs/models/components/updateorganizationuserrequest.md @@ -0,0 +1,8 @@ +# UpdateOrganizationUserRequest + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------- | ----------------------------- | ----------------------------- | ----------------------------- | +| `PolicyID` | **int64* | :heavy_minus_sign: | Policy ID applied to the user | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/updatepolicyresponse.md b/internal/membershipclient/docs/models/components/updatepolicyresponse.md new file mode 100644 index 00000000..ee775c25 --- /dev/null +++ b/internal/membershipclient/docs/models/components/updatepolicyresponse.md @@ -0,0 +1,8 @@ +# UpdatePolicyResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | +| `Data` | [*components.Policy](../../models/components/policy.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/updatestackuserrequest.md b/internal/membershipclient/docs/models/components/updatestackuserrequest.md new file mode 100644 index 00000000..5407f47a --- /dev/null +++ b/internal/membershipclient/docs/models/components/updatestackuserrequest.md @@ -0,0 +1,8 @@ +# UpdateStackUserRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `PolicyID` | *int64* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/user.md b/internal/membershipclient/docs/models/components/user.md new file mode 100644 index 00000000..7d017874 --- /dev/null +++ b/internal/membershipclient/docs/models/components/user.md @@ -0,0 +1,10 @@ +# User + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------- | +| `Email` | *string* | :heavy_check_mark: | N/A | +| `ID` | *string* | :heavy_check_mark: | User ID | +| `Role` | [*components.SystemRole](../../models/components/systemrole.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/components/version.md b/internal/membershipclient/docs/models/components/version.md new file mode 100644 index 00000000..e4c4ddb1 --- /dev/null +++ b/internal/membershipclient/docs/models/components/version.md @@ -0,0 +1,11 @@ +# Version + + +## Fields + +| Field | Type | Required | Description | +| -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | -------------------------------------------------------------- | +| `Name` | *string* | :heavy_check_mark: | N/A | +| `Versions` | map[string]*string* | :heavy_check_mark: | N/A | +| `RegionID` | *string* | :heavy_check_mark: | N/A | +| `Deprecated` | **bool* | :heavy_minus_sign: | Indicates if this version is deprecated and should not be used | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/acceptinvitationrequest.md b/internal/membershipclient/docs/models/operations/acceptinvitationrequest.md new file mode 100644 index 00000000..165b2de6 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/acceptinvitationrequest.md @@ -0,0 +1,8 @@ +# AcceptInvitationRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `InvitationID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/acceptinvitationresponse.md b/internal/membershipclient/docs/models/operations/acceptinvitationresponse.md new file mode 100644 index 00000000..4e347ce2 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/acceptinvitationresponse.md @@ -0,0 +1,9 @@ +# AcceptInvitationResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/addfeaturesrequest.md b/internal/membershipclient/docs/models/operations/addfeaturesrequest.md new file mode 100644 index 00000000..6e613e27 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/addfeaturesrequest.md @@ -0,0 +1,9 @@ +# AddFeaturesRequest + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `Body` | [*operations.AddFeaturesRequestBody](../../models/operations/addfeaturesrequestbody.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/addfeaturesrequestbody.md b/internal/membershipclient/docs/models/operations/addfeaturesrequestbody.md new file mode 100644 index 00000000..5b615feb --- /dev/null +++ b/internal/membershipclient/docs/models/operations/addfeaturesrequestbody.md @@ -0,0 +1,8 @@ +# AddFeaturesRequestBody + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `Features` | []*string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/addfeaturesresponse.md b/internal/membershipclient/docs/models/operations/addfeaturesresponse.md new file mode 100644 index 00000000..546d90dc --- /dev/null +++ b/internal/membershipclient/docs/models/operations/addfeaturesresponse.md @@ -0,0 +1,9 @@ +# AddFeaturesResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/addscopetopolicyrequest.md b/internal/membershipclient/docs/models/operations/addscopetopolicyrequest.md new file mode 100644 index 00000000..fd975bd2 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/addscopetopolicyrequest.md @@ -0,0 +1,10 @@ +# AddScopeToPolicyRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `PolicyID` | *int64* | :heavy_check_mark: | N/A | +| `ScopeID` | *int64* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/addscopetopolicyresponse.md b/internal/membershipclient/docs/models/operations/addscopetopolicyresponse.md new file mode 100644 index 00000000..eb800412 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/addscopetopolicyresponse.md @@ -0,0 +1,9 @@ +# AddScopeToPolicyResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/createapplicationresponse.md b/internal/membershipclient/docs/models/operations/createapplicationresponse.md new file mode 100644 index 00000000..3eda4783 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/createapplicationresponse.md @@ -0,0 +1,10 @@ +# CreateApplicationResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `CreateApplicationResponse` | [*components.CreateApplicationResponse](../../models/components/createapplicationresponse.md) | :heavy_minus_sign: | Application created | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/createapplicationscoperequest.md b/internal/membershipclient/docs/models/operations/createapplicationscoperequest.md new file mode 100644 index 00000000..ceea66cd --- /dev/null +++ b/internal/membershipclient/docs/models/operations/createapplicationscoperequest.md @@ -0,0 +1,9 @@ +# CreateApplicationScopeRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | +| `ApplicationID` | *string* | :heavy_check_mark: | The unique identifier of the application (UUID format) | 550e8400-e29b-41d4-a716-446655440000 | +| `Body` | [*components.CreateApplicationScopeRequest](../../models/components/createapplicationscoperequest.md) | :heavy_minus_sign: | N/A | | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/createapplicationscoperesponse.md b/internal/membershipclient/docs/models/operations/createapplicationscoperesponse.md new file mode 100644 index 00000000..5a4657fe --- /dev/null +++ b/internal/membershipclient/docs/models/operations/createapplicationscoperesponse.md @@ -0,0 +1,10 @@ +# CreateApplicationScopeResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `CreateApplicationScopeResponse` | [*components.CreateApplicationScopeResponse](../../models/components/createapplicationscoperesponse.md) | :heavy_minus_sign: | Application scope created | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/createinvitationrequest.md b/internal/membershipclient/docs/models/operations/createinvitationrequest.md new file mode 100644 index 00000000..02254bb9 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/createinvitationrequest.md @@ -0,0 +1,9 @@ +# CreateInvitationRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `Email` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/createinvitationresponse.md b/internal/membershipclient/docs/models/operations/createinvitationresponse.md new file mode 100644 index 00000000..689f5932 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/createinvitationresponse.md @@ -0,0 +1,10 @@ +# CreateInvitationResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `CreateInvitationResponse` | [*components.CreateInvitationResponse](../../models/components/createinvitationresponse.md) | :heavy_minus_sign: | Invitation already sent | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/createorganizationclientrequest.md b/internal/membershipclient/docs/models/operations/createorganizationclientrequest.md new file mode 100644 index 00000000..1413cfef --- /dev/null +++ b/internal/membershipclient/docs/models/operations/createorganizationclientrequest.md @@ -0,0 +1,8 @@ +# CreateOrganizationClientRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/createorganizationclientresponse.md b/internal/membershipclient/docs/models/operations/createorganizationclientresponse.md new file mode 100644 index 00000000..9bedc434 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/createorganizationclientresponse.md @@ -0,0 +1,10 @@ +# CreateOrganizationClientResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `CreateClientResponseResponse` | [*components.CreateClientResponseResponse](../../models/components/createclientresponseresponse.md) | :heavy_minus_sign: | Client organization created | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/createorganizationresponse.md b/internal/membershipclient/docs/models/operations/createorganizationresponse.md new file mode 100644 index 00000000..4ee49302 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/createorganizationresponse.md @@ -0,0 +1,10 @@ +# CreateOrganizationResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `CreateOrganizationResponse` | [*components.CreateOrganizationResponse](../../models/components/createorganizationresponse.md) | :heavy_minus_sign: | Organization created | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/createpolicyrequest.md b/internal/membershipclient/docs/models/operations/createpolicyrequest.md new file mode 100644 index 00000000..66d8b567 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/createpolicyrequest.md @@ -0,0 +1,9 @@ +# CreatePolicyRequest + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------- | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `Body` | [*components.PolicyData](../../models/components/policydata.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/createpolicyresponse.md b/internal/membershipclient/docs/models/operations/createpolicyresponse.md new file mode 100644 index 00000000..453d2a9e --- /dev/null +++ b/internal/membershipclient/docs/models/operations/createpolicyresponse.md @@ -0,0 +1,10 @@ +# CreatePolicyResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `CreatePolicyResponse` | [*components.CreatePolicyResponse](../../models/components/createpolicyresponse.md) | :heavy_minus_sign: | Policy created | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/createprivateregionrequest.md b/internal/membershipclient/docs/models/operations/createprivateregionrequest.md new file mode 100644 index 00000000..60611fe1 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/createprivateregionrequest.md @@ -0,0 +1,9 @@ +# CreatePrivateRegionRequest + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `Body` | [*components.CreatePrivateRegionRequest](../../models/components/createprivateregionrequest.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/createprivateregionresponse.md b/internal/membershipclient/docs/models/operations/createprivateregionresponse.md new file mode 100644 index 00000000..b4f9b0cf --- /dev/null +++ b/internal/membershipclient/docs/models/operations/createprivateregionresponse.md @@ -0,0 +1,10 @@ +# CreatePrivateRegionResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `CreatedPrivateRegionResponse` | [*components.CreatedPrivateRegionResponse](../../models/components/createdprivateregionresponse.md) | :heavy_minus_sign: | Created region | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/createstackrequest.md b/internal/membershipclient/docs/models/operations/createstackrequest.md new file mode 100644 index 00000000..39af0af7 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/createstackrequest.md @@ -0,0 +1,9 @@ +# CreateStackRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `Body` | [*components.CreateStackRequest](../../models/components/createstackrequest.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/createstackresponse.md b/internal/membershipclient/docs/models/operations/createstackresponse.md new file mode 100644 index 00000000..548a8a72 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/createstackresponse.md @@ -0,0 +1,10 @@ +# CreateStackResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `CreateStackResponse` | [*components.CreateStackResponse](../../models/components/createstackresponse.md) | :heavy_minus_sign: | Stack created | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/createuserresponse.md b/internal/membershipclient/docs/models/operations/createuserresponse.md new file mode 100644 index 00000000..d7c29815 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/createuserresponse.md @@ -0,0 +1,10 @@ +# CreateUserResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `CreateUserResponse` | [*components.CreateUserResponse](../../models/components/createuserresponse.md) | :heavy_minus_sign: | User created successfully | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Invalid request (missing or invalid email) | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/declineinvitationrequest.md b/internal/membershipclient/docs/models/operations/declineinvitationrequest.md new file mode 100644 index 00000000..05d3e561 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/declineinvitationrequest.md @@ -0,0 +1,8 @@ +# DeclineInvitationRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `InvitationID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/declineinvitationresponse.md b/internal/membershipclient/docs/models/operations/declineinvitationresponse.md new file mode 100644 index 00000000..27aaf247 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/declineinvitationresponse.md @@ -0,0 +1,9 @@ +# DeclineInvitationResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deleteapplicationrequest.md b/internal/membershipclient/docs/models/operations/deleteapplicationrequest.md new file mode 100644 index 00000000..7812d84f --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deleteapplicationrequest.md @@ -0,0 +1,8 @@ +# DeleteApplicationRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `ApplicationID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deleteapplicationresponse.md b/internal/membershipclient/docs/models/operations/deleteapplicationresponse.md new file mode 100644 index 00000000..b971f275 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deleteapplicationresponse.md @@ -0,0 +1,9 @@ +# DeleteApplicationResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deleteapplicationscoperequest.md b/internal/membershipclient/docs/models/operations/deleteapplicationscoperequest.md new file mode 100644 index 00000000..cede4e62 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deleteapplicationscoperequest.md @@ -0,0 +1,9 @@ +# DeleteApplicationScopeRequest + + +## Fields + +| Field | Type | Required | Description | Example | +| ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | ------------------------------------------------------ | +| `ApplicationID` | *string* | :heavy_check_mark: | The unique identifier of the application (UUID format) | 550e8400-e29b-41d4-a716-446655440000 | +| `ScopeID` | *int64* | :heavy_check_mark: | The unique identifier of the scope to operate on | | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deleteapplicationscoperesponse.md b/internal/membershipclient/docs/models/operations/deleteapplicationscoperesponse.md new file mode 100644 index 00000000..79dd9bc8 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deleteapplicationscoperesponse.md @@ -0,0 +1,9 @@ +# DeleteApplicationScopeResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Invalid request (invalid UUID or empty scope ID) | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deleteauthenticationproviderrequest.md b/internal/membershipclient/docs/models/operations/deleteauthenticationproviderrequest.md new file mode 100644 index 00000000..ccb3c67e --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deleteauthenticationproviderrequest.md @@ -0,0 +1,8 @@ +# DeleteAuthenticationProviderRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deleteauthenticationproviderresponse.md b/internal/membershipclient/docs/models/operations/deleteauthenticationproviderresponse.md new file mode 100644 index 00000000..bc65ba5c --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deleteauthenticationproviderresponse.md @@ -0,0 +1,9 @@ +# DeleteAuthenticationProviderResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deletefeaturerequest.md b/internal/membershipclient/docs/models/operations/deletefeaturerequest.md new file mode 100644 index 00000000..37533c25 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deletefeaturerequest.md @@ -0,0 +1,9 @@ +# DeleteFeatureRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `Name` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deletefeatureresponse.md b/internal/membershipclient/docs/models/operations/deletefeatureresponse.md new file mode 100644 index 00000000..a14743c5 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deletefeatureresponse.md @@ -0,0 +1,9 @@ +# DeleteFeatureResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deleteinvitationrequest.md b/internal/membershipclient/docs/models/operations/deleteinvitationrequest.md new file mode 100644 index 00000000..dc185b1b --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deleteinvitationrequest.md @@ -0,0 +1,9 @@ +# DeleteInvitationRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `InvitationID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deleteinvitationresponse.md b/internal/membershipclient/docs/models/operations/deleteinvitationresponse.md new file mode 100644 index 00000000..85fc3a0d --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deleteinvitationresponse.md @@ -0,0 +1,9 @@ +# DeleteInvitationResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deleteorganizationclientrequest.md b/internal/membershipclient/docs/models/operations/deleteorganizationclientrequest.md new file mode 100644 index 00000000..d22f8bb6 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deleteorganizationclientrequest.md @@ -0,0 +1,8 @@ +# DeleteOrganizationClientRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deleteorganizationclientresponse.md b/internal/membershipclient/docs/models/operations/deleteorganizationclientresponse.md new file mode 100644 index 00000000..605b5ae7 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deleteorganizationclientresponse.md @@ -0,0 +1,9 @@ +# DeleteOrganizationClientResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deleteorganizationrequest.md b/internal/membershipclient/docs/models/operations/deleteorganizationrequest.md new file mode 100644 index 00000000..3e603427 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deleteorganizationrequest.md @@ -0,0 +1,8 @@ +# DeleteOrganizationRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deleteorganizationresponse.md b/internal/membershipclient/docs/models/operations/deleteorganizationresponse.md new file mode 100644 index 00000000..a4bc77bd --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deleteorganizationresponse.md @@ -0,0 +1,9 @@ +# DeleteOrganizationResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deletepolicyrequest.md b/internal/membershipclient/docs/models/operations/deletepolicyrequest.md new file mode 100644 index 00000000..3ad40efc --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deletepolicyrequest.md @@ -0,0 +1,9 @@ +# DeletePolicyRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `PolicyID` | *int64* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deletepolicyresponse.md b/internal/membershipclient/docs/models/operations/deletepolicyresponse.md new file mode 100644 index 00000000..ea21efd5 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deletepolicyresponse.md @@ -0,0 +1,9 @@ +# DeletePolicyResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deleteregionrequest.md b/internal/membershipclient/docs/models/operations/deleteregionrequest.md new file mode 100644 index 00000000..ee69ad5d --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deleteregionrequest.md @@ -0,0 +1,9 @@ +# DeleteRegionRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `RegionID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deleteregionresponse.md b/internal/membershipclient/docs/models/operations/deleteregionresponse.md new file mode 100644 index 00000000..4e9e874b --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deleteregionresponse.md @@ -0,0 +1,9 @@ +# DeleteRegionResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deletestackrequest.md b/internal/membershipclient/docs/models/operations/deletestackrequest.md new file mode 100644 index 00000000..4e18dd46 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deletestackrequest.md @@ -0,0 +1,10 @@ +# DeleteStackRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `StackID` | *string* | :heavy_check_mark: | N/A | +| `Force` | **bool* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deletestackresponse.md b/internal/membershipclient/docs/models/operations/deletestackresponse.md new file mode 100644 index 00000000..9c5d9afa --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deletestackresponse.md @@ -0,0 +1,9 @@ +# DeleteStackResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deletestackuseraccessrequest.md b/internal/membershipclient/docs/models/operations/deletestackuseraccessrequest.md new file mode 100644 index 00000000..c2a4c41f --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deletestackuseraccessrequest.md @@ -0,0 +1,10 @@ +# DeleteStackUserAccessRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `StackID` | *string* | :heavy_check_mark: | N/A | +| `UserID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deletestackuseraccessresponse.md b/internal/membershipclient/docs/models/operations/deletestackuseraccessresponse.md new file mode 100644 index 00000000..9c85b70d --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deletestackuseraccessresponse.md @@ -0,0 +1,9 @@ +# DeleteStackUserAccessResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deleteuserfromorganizationrequest.md b/internal/membershipclient/docs/models/operations/deleteuserfromorganizationrequest.md new file mode 100644 index 00000000..c9163f64 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deleteuserfromorganizationrequest.md @@ -0,0 +1,9 @@ +# DeleteUserFromOrganizationRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `UserID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/deleteuserfromorganizationresponse.md b/internal/membershipclient/docs/models/operations/deleteuserfromorganizationresponse.md new file mode 100644 index 00000000..4f0b4966 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/deleteuserfromorganizationresponse.md @@ -0,0 +1,9 @@ +# DeleteUserFromOrganizationResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/disableapplicationfororganizationrequest.md b/internal/membershipclient/docs/models/operations/disableapplicationfororganizationrequest.md new file mode 100644 index 00000000..3c5852a0 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/disableapplicationfororganizationrequest.md @@ -0,0 +1,9 @@ +# DisableApplicationForOrganizationRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `ApplicationID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/disableapplicationfororganizationresponse.md b/internal/membershipclient/docs/models/operations/disableapplicationfororganizationresponse.md new file mode 100644 index 00000000..2866f843 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/disableapplicationfororganizationresponse.md @@ -0,0 +1,9 @@ +# DisableApplicationForOrganizationResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/disablemodulerequest.md b/internal/membershipclient/docs/models/operations/disablemodulerequest.md new file mode 100644 index 00000000..da8bf14e --- /dev/null +++ b/internal/membershipclient/docs/models/operations/disablemodulerequest.md @@ -0,0 +1,10 @@ +# DisableModuleRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `StackID` | *string* | :heavy_check_mark: | N/A | +| `Name` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/disablemoduleresponse.md b/internal/membershipclient/docs/models/operations/disablemoduleresponse.md new file mode 100644 index 00000000..69e6624d --- /dev/null +++ b/internal/membershipclient/docs/models/operations/disablemoduleresponse.md @@ -0,0 +1,9 @@ +# DisableModuleResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/disablestackrequest.md b/internal/membershipclient/docs/models/operations/disablestackrequest.md new file mode 100644 index 00000000..b6348f68 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/disablestackrequest.md @@ -0,0 +1,9 @@ +# DisableStackRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `StackID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/disablestackresponse.md b/internal/membershipclient/docs/models/operations/disablestackresponse.md new file mode 100644 index 00000000..efb01b56 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/disablestackresponse.md @@ -0,0 +1,9 @@ +# DisableStackResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/disablestargaterequest.md b/internal/membershipclient/docs/models/operations/disablestargaterequest.md new file mode 100644 index 00000000..afad7bd6 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/disablestargaterequest.md @@ -0,0 +1,9 @@ +# DisableStargateRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `StackID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/disablestargateresponse.md b/internal/membershipclient/docs/models/operations/disablestargateresponse.md new file mode 100644 index 00000000..e8309b3a --- /dev/null +++ b/internal/membershipclient/docs/models/operations/disablestargateresponse.md @@ -0,0 +1,9 @@ +# DisableStargateResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/enableapplicationfororganizationrequest.md b/internal/membershipclient/docs/models/operations/enableapplicationfororganizationrequest.md new file mode 100644 index 00000000..22967535 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/enableapplicationfororganizationrequest.md @@ -0,0 +1,9 @@ +# EnableApplicationForOrganizationRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `ApplicationID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/enableapplicationfororganizationresponse.md b/internal/membershipclient/docs/models/operations/enableapplicationfororganizationresponse.md new file mode 100644 index 00000000..397d75dd --- /dev/null +++ b/internal/membershipclient/docs/models/operations/enableapplicationfororganizationresponse.md @@ -0,0 +1,10 @@ +# EnableApplicationForOrganizationResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `EnableApplicationForOrganizationResponse` | [*components.EnableApplicationForOrganizationResponse](../../models/components/enableapplicationfororganizationresponse.md) | :heavy_minus_sign: | Application enabled for organization | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/enablemodulerequest.md b/internal/membershipclient/docs/models/operations/enablemodulerequest.md new file mode 100644 index 00000000..dfc1b90b --- /dev/null +++ b/internal/membershipclient/docs/models/operations/enablemodulerequest.md @@ -0,0 +1,10 @@ +# EnableModuleRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `StackID` | *string* | :heavy_check_mark: | N/A | +| `Name` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/enablemoduleresponse.md b/internal/membershipclient/docs/models/operations/enablemoduleresponse.md new file mode 100644 index 00000000..a8c8a9ec --- /dev/null +++ b/internal/membershipclient/docs/models/operations/enablemoduleresponse.md @@ -0,0 +1,9 @@ +# EnableModuleResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/enablestackrequest.md b/internal/membershipclient/docs/models/operations/enablestackrequest.md new file mode 100644 index 00000000..10364ace --- /dev/null +++ b/internal/membershipclient/docs/models/operations/enablestackrequest.md @@ -0,0 +1,9 @@ +# EnableStackRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `StackID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/enablestackresponse.md b/internal/membershipclient/docs/models/operations/enablestackresponse.md new file mode 100644 index 00000000..4be2a9c5 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/enablestackresponse.md @@ -0,0 +1,9 @@ +# EnableStackResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/enablestargaterequest.md b/internal/membershipclient/docs/models/operations/enablestargaterequest.md new file mode 100644 index 00000000..5d3256b2 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/enablestargaterequest.md @@ -0,0 +1,9 @@ +# EnableStargateRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `StackID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/enablestargateresponse.md b/internal/membershipclient/docs/models/operations/enablestargateresponse.md new file mode 100644 index 00000000..93c97291 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/enablestargateresponse.md @@ -0,0 +1,9 @@ +# EnableStargateResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/getapplicationrequest.md b/internal/membershipclient/docs/models/operations/getapplicationrequest.md new file mode 100644 index 00000000..4a654c6f --- /dev/null +++ b/internal/membershipclient/docs/models/operations/getapplicationrequest.md @@ -0,0 +1,8 @@ +# GetApplicationRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `ApplicationID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/getapplicationresponse.md b/internal/membershipclient/docs/models/operations/getapplicationresponse.md new file mode 100644 index 00000000..82b78c86 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/getapplicationresponse.md @@ -0,0 +1,10 @@ +# GetApplicationResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `GetApplicationResponse` | [*components.GetApplicationResponse](../../models/components/getapplicationresponse.md) | :heavy_minus_sign: | Application details | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/getorganizationapplicationrequest.md b/internal/membershipclient/docs/models/operations/getorganizationapplicationrequest.md new file mode 100644 index 00000000..6fd88849 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/getorganizationapplicationrequest.md @@ -0,0 +1,9 @@ +# GetOrganizationApplicationRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `ApplicationID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/getorganizationapplicationresponse.md b/internal/membershipclient/docs/models/operations/getorganizationapplicationresponse.md new file mode 100644 index 00000000..4f0ac1b3 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/getorganizationapplicationresponse.md @@ -0,0 +1,10 @@ +# GetOrganizationApplicationResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `GetApplicationResponse` | [*components.GetApplicationResponse](../../models/components/getapplicationresponse.md) | :heavy_minus_sign: | Application details | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/getregionrequest.md b/internal/membershipclient/docs/models/operations/getregionrequest.md new file mode 100644 index 00000000..adbd58c1 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/getregionrequest.md @@ -0,0 +1,9 @@ +# GetRegionRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `RegionID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/getregionresponse.md b/internal/membershipclient/docs/models/operations/getregionresponse.md new file mode 100644 index 00000000..c037d812 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/getregionresponse.md @@ -0,0 +1,10 @@ +# GetRegionResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `GetRegionResponse` | [*components.GetRegionResponse](../../models/components/getregionresponse.md) | :heavy_minus_sign: | Get a specific region | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/getregionversionsrequest.md b/internal/membershipclient/docs/models/operations/getregionversionsrequest.md new file mode 100644 index 00000000..c8351ccd --- /dev/null +++ b/internal/membershipclient/docs/models/operations/getregionversionsrequest.md @@ -0,0 +1,9 @@ +# GetRegionVersionsRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `RegionID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/getregionversionsresponse.md b/internal/membershipclient/docs/models/operations/getregionversionsresponse.md new file mode 100644 index 00000000..ebcbaccc --- /dev/null +++ b/internal/membershipclient/docs/models/operations/getregionversionsresponse.md @@ -0,0 +1,10 @@ +# GetRegionVersionsResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `GetRegionVersionsResponse` | [*components.GetRegionVersionsResponse](../../models/components/getregionversionsresponse.md) | :heavy_minus_sign: | Get a specific region | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/getserverinforesponse.md b/internal/membershipclient/docs/models/operations/getserverinforesponse.md new file mode 100644 index 00000000..18ed5ab9 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/getserverinforesponse.md @@ -0,0 +1,10 @@ +# GetServerInfoResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ServerInfo` | [*components.ServerInfo](../../models/components/serverinfo.md) | :heavy_minus_sign: | Server information | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/getstackrequest.md b/internal/membershipclient/docs/models/operations/getstackrequest.md new file mode 100644 index 00000000..58524d49 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/getstackrequest.md @@ -0,0 +1,9 @@ +# GetStackRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `StackID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/getstackresponse.md b/internal/membershipclient/docs/models/operations/getstackresponse.md new file mode 100644 index 00000000..9e60a753 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/getstackresponse.md @@ -0,0 +1,10 @@ +# GetStackResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `CreateStackResponse` | [*components.CreateStackResponse](../../models/components/createstackresponse.md) | :heavy_minus_sign: | OK | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listapplicationsresponse.md b/internal/membershipclient/docs/models/operations/listapplicationsresponse.md new file mode 100644 index 00000000..17a69ea0 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listapplicationsresponse.md @@ -0,0 +1,10 @@ +# ListApplicationsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ListApplicationsResponse` | [*components.ListApplicationsResponse](../../models/components/listapplicationsresponse.md) | :heavy_minus_sign: | List of applications | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listfeaturesrequest.md b/internal/membershipclient/docs/models/operations/listfeaturesrequest.md new file mode 100644 index 00000000..4e7eed3c --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listfeaturesrequest.md @@ -0,0 +1,8 @@ +# ListFeaturesRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listfeaturesresponse.md b/internal/membershipclient/docs/models/operations/listfeaturesresponse.md new file mode 100644 index 00000000..c90b0e07 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listfeaturesresponse.md @@ -0,0 +1,10 @@ +# ListFeaturesResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Object` | [*operations.ListFeaturesResponseBody](../../models/operations/listfeaturesresponsebody.md) | :heavy_minus_sign: | List of features | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listfeaturesresponsebody.md b/internal/membershipclient/docs/models/operations/listfeaturesresponsebody.md new file mode 100644 index 00000000..7e779c70 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listfeaturesresponsebody.md @@ -0,0 +1,10 @@ +# ListFeaturesResponseBody + +List of features + + +## Fields + +| Field | Type | Required | Description | +| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | +| `Data` | [][components.OrganizationFeature](../../models/components/organizationfeature.md) | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listinvitationsrequest.md b/internal/membershipclient/docs/models/operations/listinvitationsrequest.md new file mode 100644 index 00000000..473b5664 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listinvitationsrequest.md @@ -0,0 +1,9 @@ +# ListInvitationsRequest + + +## Fields + +| Field | Type | Required | Description | +| ----------------------- | ----------------------- | ----------------------- | ----------------------- | +| `Status` | **string* | :heavy_minus_sign: | Status of organizations | +| `Organization` | **string* | :heavy_minus_sign: | Status of organizations | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listinvitationsresponse.md b/internal/membershipclient/docs/models/operations/listinvitationsresponse.md new file mode 100644 index 00000000..ce6f2ec1 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listinvitationsresponse.md @@ -0,0 +1,10 @@ +# ListInvitationsResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ListInvitationsResponse` | [*components.ListInvitationsResponse](../../models/components/listinvitationsresponse.md) | :heavy_minus_sign: | List of the invitations for the connected user | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listlogsrequest.md b/internal/membershipclient/docs/models/operations/listlogsrequest.md new file mode 100644 index 00000000..8b42b288 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listlogsrequest.md @@ -0,0 +1,15 @@ +# ListLogsRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | ------------------------------------------------------- | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `StackID` | **string* | :heavy_minus_sign: | N/A | +| `Cursor` | **string* | :heavy_minus_sign: | N/A | +| `PageSize` | **int64* | :heavy_minus_sign: | N/A | +| `Action` | [*components.Action](../../models/components/action.md) | :heavy_minus_sign: | N/A | +| `UserID` | **string* | :heavy_minus_sign: | N/A | +| `Key` | **string* | :heavy_minus_sign: | N/A | +| `Value` | **string* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listlogsresponse.md b/internal/membershipclient/docs/models/operations/listlogsresponse.md new file mode 100644 index 00000000..868f447e --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listlogsresponse.md @@ -0,0 +1,10 @@ +# ListLogsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `LogCursor` | [*components.LogCursor](../../models/components/logcursor.md) | :heavy_minus_sign: | Cursor of logs | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listmodulesrequest.md b/internal/membershipclient/docs/models/operations/listmodulesrequest.md new file mode 100644 index 00000000..ec0ed937 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listmodulesrequest.md @@ -0,0 +1,9 @@ +# ListModulesRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `StackID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listmodulesresponse.md b/internal/membershipclient/docs/models/operations/listmodulesresponse.md new file mode 100644 index 00000000..33ea1354 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listmodulesresponse.md @@ -0,0 +1,10 @@ +# ListModulesResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ListModulesResponse` | [*components.ListModulesResponse](../../models/components/listmodulesresponse.md) | :heavy_minus_sign: | List of modules | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listorganizationapplicationsrequest.md b/internal/membershipclient/docs/models/operations/listorganizationapplicationsrequest.md new file mode 100644 index 00000000..d06262c7 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listorganizationapplicationsrequest.md @@ -0,0 +1,10 @@ +# ListOrganizationApplicationsRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `PageSize` | **int64* | :heavy_minus_sign: | N/A | +| `Page` | **int64* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listorganizationapplicationsresponse.md b/internal/membershipclient/docs/models/operations/listorganizationapplicationsresponse.md new file mode 100644 index 00000000..f2124c61 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listorganizationapplicationsresponse.md @@ -0,0 +1,10 @@ +# ListOrganizationApplicationsResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ListApplicationsResponse` | [*components.ListApplicationsResponse](../../models/components/listapplicationsresponse.md) | :heavy_minus_sign: | List of applications enabled for organization | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listorganizationinvitationsrequest.md b/internal/membershipclient/docs/models/operations/listorganizationinvitationsrequest.md new file mode 100644 index 00000000..c2146526 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listorganizationinvitationsrequest.md @@ -0,0 +1,9 @@ +# ListOrganizationInvitationsRequest + + +## Fields + +| Field | Type | Required | Description | +| ----------------------- | ----------------------- | ----------------------- | ----------------------- | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `Status` | **string* | :heavy_minus_sign: | Status of organizations | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listorganizationinvitationsresponse.md b/internal/membershipclient/docs/models/operations/listorganizationinvitationsresponse.md new file mode 100644 index 00000000..226c656e --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listorganizationinvitationsresponse.md @@ -0,0 +1,10 @@ +# ListOrganizationInvitationsResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ListInvitationsResponse` | [*components.ListInvitationsResponse](../../models/components/listinvitationsresponse.md) | :heavy_minus_sign: | List of the invitations for the organization | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listorganizationsexpandedresponse.md b/internal/membershipclient/docs/models/operations/listorganizationsexpandedresponse.md new file mode 100644 index 00000000..3c9d88e0 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listorganizationsexpandedresponse.md @@ -0,0 +1,9 @@ +# ListOrganizationsExpandedResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ListOrganizationExpandedResponse` | [*components.ListOrganizationExpandedResponse](../../models/components/listorganizationexpandedresponse.md) | :heavy_minus_sign: | List of organizations with expanded data | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listorganizationsrequest.md b/internal/membershipclient/docs/models/operations/listorganizationsrequest.md new file mode 100644 index 00000000..c36f979c --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listorganizationsrequest.md @@ -0,0 +1,8 @@ +# ListOrganizationsRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `Expand` | **bool* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listorganizationsresponse.md b/internal/membershipclient/docs/models/operations/listorganizationsresponse.md new file mode 100644 index 00000000..1241dd49 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listorganizationsresponse.md @@ -0,0 +1,10 @@ +# ListOrganizationsResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ListOrganizationExpandedResponse` | [*components.ListOrganizationExpandedResponse](../../models/components/listorganizationexpandedresponse.md) | :heavy_minus_sign: | List of organizations | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listpoliciesrequest.md b/internal/membershipclient/docs/models/operations/listpoliciesrequest.md new file mode 100644 index 00000000..2156063a --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listpoliciesrequest.md @@ -0,0 +1,8 @@ +# ListPoliciesRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listpoliciesresponse.md b/internal/membershipclient/docs/models/operations/listpoliciesresponse.md new file mode 100644 index 00000000..c1ed2ff1 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listpoliciesresponse.md @@ -0,0 +1,10 @@ +# ListPoliciesResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ListPoliciesResponse` | [*components.ListPoliciesResponse](../../models/components/listpoliciesresponse.md) | :heavy_minus_sign: | List of policies | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listregionsrequest.md b/internal/membershipclient/docs/models/operations/listregionsrequest.md new file mode 100644 index 00000000..8f1b8d91 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listregionsrequest.md @@ -0,0 +1,8 @@ +# ListRegionsRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listregionsresponse.md b/internal/membershipclient/docs/models/operations/listregionsresponse.md new file mode 100644 index 00000000..ad308a3c --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listregionsresponse.md @@ -0,0 +1,10 @@ +# ListRegionsResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ListRegionsResponse` | [*components.ListRegionsResponse](../../models/components/listregionsresponse.md) | :heavy_minus_sign: | List of the regions | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/liststacksrequest.md b/internal/membershipclient/docs/models/operations/liststacksrequest.md new file mode 100644 index 00000000..4d974d22 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/liststacksrequest.md @@ -0,0 +1,10 @@ +# ListStacksRequest + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `All` | **bool* | :heavy_minus_sign: | Include deleted and disabled stacks | +| ~~`Deleted`~~ | **bool* | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

Include deleted stacks | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/liststacksresponse.md b/internal/membershipclient/docs/models/operations/liststacksresponse.md new file mode 100644 index 00000000..86c4e710 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/liststacksresponse.md @@ -0,0 +1,10 @@ +# ListStacksResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ListStacksResponse` | [*components.ListStacksResponse](../../models/components/liststacksresponse.md) | :heavy_minus_sign: | List of stacks | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/liststackusersaccessesrequest.md b/internal/membershipclient/docs/models/operations/liststackusersaccessesrequest.md new file mode 100644 index 00000000..d7945f2a --- /dev/null +++ b/internal/membershipclient/docs/models/operations/liststackusersaccessesrequest.md @@ -0,0 +1,9 @@ +# ListStackUsersAccessesRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `StackID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/liststackusersaccessesresponse.md b/internal/membershipclient/docs/models/operations/liststackusersaccessesresponse.md new file mode 100644 index 00000000..edad0b69 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/liststackusersaccessesresponse.md @@ -0,0 +1,10 @@ +# ListStackUsersAccessesResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `StackUserAccessResponse` | [*components.StackUserAccessResponse](../../models/components/stackuseraccessresponse.md) | :heavy_minus_sign: | Stack users access | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listusersoforganizationrequest.md b/internal/membershipclient/docs/models/operations/listusersoforganizationrequest.md new file mode 100644 index 00000000..1d307af4 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listusersoforganizationrequest.md @@ -0,0 +1,8 @@ +# ListUsersOfOrganizationRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/listusersoforganizationresponse.md b/internal/membershipclient/docs/models/operations/listusersoforganizationresponse.md new file mode 100644 index 00000000..499a7b18 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/listusersoforganizationresponse.md @@ -0,0 +1,10 @@ +# ListUsersOfOrganizationResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ----------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ListUsersResponse` | [*components.ListUsersResponse](../../models/components/listusersresponse.md) | :heavy_minus_sign: | List of users | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/option.md b/internal/membershipclient/docs/models/operations/option.md new file mode 100644 index 00000000..35d8a1e2 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/option.md @@ -0,0 +1,37 @@ +## Options + +### WithServerURL + +WithServerURL allows providing an alternative server URL. + +```go +operations.WithServerURL("http://api.example.com") +``` + +## WithTemplatedServerURL + +WithTemplatedServerURL allows providing an alternative server URL with templated parameters. + +```go +operations.WithTemplatedServerURL("http://{host}:{port}", map[string]string{ + "host": "api.example.com", + "port": "8080", +}) +``` + +### WithRetries + +WithRetries allows customizing the default retry configuration. Only usable with methods that mention they support retries. + +```go +operations.WithRetries(retry.Config{ + Strategy: "backoff", + Backoff: retry.BackoffStrategy{ + InitialInterval: 500 * time.Millisecond, + MaxInterval: 60 * time.Second, + Exponent: 1.5, + MaxElapsedTime: 5 * time.Minute, + }, + RetryConnectionErrors: true, +}) +``` \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/organizationclientcreaterequest.md b/internal/membershipclient/docs/models/operations/organizationclientcreaterequest.md new file mode 100644 index 00000000..68c45195 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/organizationclientcreaterequest.md @@ -0,0 +1,9 @@ +# OrganizationClientCreateRequest + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `Body` | [*components.CreateOrganizationClientRequest](../../models/components/createorganizationclientrequest.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/organizationclientcreateresponse.md b/internal/membershipclient/docs/models/operations/organizationclientcreateresponse.md new file mode 100644 index 00000000..c1491d81 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/organizationclientcreateresponse.md @@ -0,0 +1,10 @@ +# OrganizationClientCreateResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `CreateOrganizationClientResponse` | [*components.CreateOrganizationClientResponse](../../models/components/createorganizationclientresponse.md) | :heavy_minus_sign: | Organization client created | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/organizationclientdeleterequest.md b/internal/membershipclient/docs/models/operations/organizationclientdeleterequest.md new file mode 100644 index 00000000..b54faf24 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/organizationclientdeleterequest.md @@ -0,0 +1,9 @@ +# OrganizationClientDeleteRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `ClientID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/organizationclientdeleteresponse.md b/internal/membershipclient/docs/models/operations/organizationclientdeleteresponse.md new file mode 100644 index 00000000..f82700c0 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/organizationclientdeleteresponse.md @@ -0,0 +1,9 @@ +# OrganizationClientDeleteResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/organizationclientreadrequest.md b/internal/membershipclient/docs/models/operations/organizationclientreadrequest.md new file mode 100644 index 00000000..65b8163d --- /dev/null +++ b/internal/membershipclient/docs/models/operations/organizationclientreadrequest.md @@ -0,0 +1,9 @@ +# OrganizationClientReadRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `ClientID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/organizationclientreadresponse.md b/internal/membershipclient/docs/models/operations/organizationclientreadresponse.md new file mode 100644 index 00000000..4eb9b823 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/organizationclientreadresponse.md @@ -0,0 +1,10 @@ +# OrganizationClientReadResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ReadOrganizationClientResponse` | [*components.ReadOrganizationClientResponse](../../models/components/readorganizationclientresponse.md) | :heavy_minus_sign: | Organization client details | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/organizationclientsreadrequest.md b/internal/membershipclient/docs/models/operations/organizationclientsreadrequest.md new file mode 100644 index 00000000..33b127ac --- /dev/null +++ b/internal/membershipclient/docs/models/operations/organizationclientsreadrequest.md @@ -0,0 +1,10 @@ +# OrganizationClientsReadRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `Cursor` | **string* | :heavy_minus_sign: | N/A | +| `PageSize` | **int64* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/organizationclientsreadresponse.md b/internal/membershipclient/docs/models/operations/organizationclientsreadresponse.md new file mode 100644 index 00000000..4b3c5a04 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/organizationclientsreadresponse.md @@ -0,0 +1,10 @@ +# OrganizationClientsReadResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ReadOrganizationClientsResponse` | [*components.ReadOrganizationClientsResponse](../../models/components/readorganizationclientsresponse.md) | :heavy_minus_sign: | Organization client | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/organizationclientupdaterequest.md b/internal/membershipclient/docs/models/operations/organizationclientupdaterequest.md new file mode 100644 index 00000000..53751494 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/organizationclientupdaterequest.md @@ -0,0 +1,10 @@ +# OrganizationClientUpdateRequest + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `ClientID` | *string* | :heavy_check_mark: | N/A | +| `Body` | [*components.UpdateOrganizationClientRequest](../../models/components/updateorganizationclientrequest.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/organizationclientupdateresponse.md b/internal/membershipclient/docs/models/operations/organizationclientupdateresponse.md new file mode 100644 index 00000000..ee493197 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/organizationclientupdateresponse.md @@ -0,0 +1,9 @@ +# OrganizationClientUpdateResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/readauthenticationproviderrequest.md b/internal/membershipclient/docs/models/operations/readauthenticationproviderrequest.md new file mode 100644 index 00000000..8179d622 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/readauthenticationproviderrequest.md @@ -0,0 +1,8 @@ +# ReadAuthenticationProviderRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/readauthenticationproviderresponse.md b/internal/membershipclient/docs/models/operations/readauthenticationproviderresponse.md new file mode 100644 index 00000000..221b6c7a --- /dev/null +++ b/internal/membershipclient/docs/models/operations/readauthenticationproviderresponse.md @@ -0,0 +1,10 @@ +# ReadAuthenticationProviderResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `AuthenticationProviderResponse` | [*components.AuthenticationProviderResponse](../../models/components/authenticationproviderresponse.md) | :heavy_minus_sign: | Authentication provider details | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/readconnecteduserresponse.md b/internal/membershipclient/docs/models/operations/readconnecteduserresponse.md new file mode 100644 index 00000000..b8f57de8 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/readconnecteduserresponse.md @@ -0,0 +1,10 @@ +# ReadConnectedUserResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ReadUserResponse` | [*components.ReadUserResponse](../../models/components/readuserresponse.md) | :heavy_minus_sign: | Read a user | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/readorganizationclientrequest.md b/internal/membershipclient/docs/models/operations/readorganizationclientrequest.md new file mode 100644 index 00000000..c163ae7c --- /dev/null +++ b/internal/membershipclient/docs/models/operations/readorganizationclientrequest.md @@ -0,0 +1,8 @@ +# ReadOrganizationClientRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/readorganizationclientresponse.md b/internal/membershipclient/docs/models/operations/readorganizationclientresponse.md new file mode 100644 index 00000000..802a5f1a --- /dev/null +++ b/internal/membershipclient/docs/models/operations/readorganizationclientresponse.md @@ -0,0 +1,10 @@ +# ReadOrganizationClientResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `CreateClientResponseResponse` | [*components.CreateClientResponseResponse](../../models/components/createclientresponseresponse.md) | :heavy_minus_sign: | Organization client | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/readorganizationrequest.md b/internal/membershipclient/docs/models/operations/readorganizationrequest.md new file mode 100644 index 00000000..1a958fcb --- /dev/null +++ b/internal/membershipclient/docs/models/operations/readorganizationrequest.md @@ -0,0 +1,9 @@ +# ReadOrganizationRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `Expand` | **bool* | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/readorganizationresponse.md b/internal/membershipclient/docs/models/operations/readorganizationresponse.md new file mode 100644 index 00000000..826d5758 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/readorganizationresponse.md @@ -0,0 +1,10 @@ +# ReadOrganizationResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ReadOrganizationResponse` | [*components.ReadOrganizationResponse](../../models/components/readorganizationresponse.md) | :heavy_minus_sign: | OK | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/readpolicyrequest.md b/internal/membershipclient/docs/models/operations/readpolicyrequest.md new file mode 100644 index 00000000..a5d091f0 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/readpolicyrequest.md @@ -0,0 +1,9 @@ +# ReadPolicyRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `PolicyID` | *int64* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/readpolicyresponse.md b/internal/membershipclient/docs/models/operations/readpolicyresponse.md new file mode 100644 index 00000000..d202ab5e --- /dev/null +++ b/internal/membershipclient/docs/models/operations/readpolicyresponse.md @@ -0,0 +1,10 @@ +# ReadPolicyResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ReadPolicyResponse` | [*components.ReadPolicyResponse](../../models/components/readpolicyresponse.md) | :heavy_minus_sign: | Policy with scopes | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/readstackuseraccessrequest.md b/internal/membershipclient/docs/models/operations/readstackuseraccessrequest.md new file mode 100644 index 00000000..43937ff1 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/readstackuseraccessrequest.md @@ -0,0 +1,10 @@ +# ReadStackUserAccessRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `StackID` | *string* | :heavy_check_mark: | N/A | +| `UserID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/readstackuseraccessresponse.md b/internal/membershipclient/docs/models/operations/readstackuseraccessresponse.md new file mode 100644 index 00000000..1c50f09c --- /dev/null +++ b/internal/membershipclient/docs/models/operations/readstackuseraccessresponse.md @@ -0,0 +1,10 @@ +# ReadStackUserAccessResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ReadStackUserAccess` | [*components.ReadStackUserAccess](../../models/components/readstackuseraccess.md) | :heavy_minus_sign: | Stack user access | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/readuseroforganizationrequest.md b/internal/membershipclient/docs/models/operations/readuseroforganizationrequest.md new file mode 100644 index 00000000..4182a599 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/readuseroforganizationrequest.md @@ -0,0 +1,9 @@ +# ReadUserOfOrganizationRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `UserID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/readuseroforganizationresponse.md b/internal/membershipclient/docs/models/operations/readuseroforganizationresponse.md new file mode 100644 index 00000000..b2daf9d2 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/readuseroforganizationresponse.md @@ -0,0 +1,10 @@ +# ReadUserOfOrganizationResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ReadOrganizationUserResponse` | [*components.ReadOrganizationUserResponse](../../models/components/readorganizationuserresponse.md) | :heavy_minus_sign: | Read a user | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/removescopefrompolicyrequest.md b/internal/membershipclient/docs/models/operations/removescopefrompolicyrequest.md new file mode 100644 index 00000000..fed72cbc --- /dev/null +++ b/internal/membershipclient/docs/models/operations/removescopefrompolicyrequest.md @@ -0,0 +1,10 @@ +# RemoveScopeFromPolicyRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `PolicyID` | *int64* | :heavy_check_mark: | N/A | +| `ScopeID` | *int64* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/removescopefrompolicyresponse.md b/internal/membershipclient/docs/models/operations/removescopefrompolicyresponse.md new file mode 100644 index 00000000..3f9ac299 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/removescopefrompolicyresponse.md @@ -0,0 +1,9 @@ +# RemoveScopeFromPolicyResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/restorestackrequest.md b/internal/membershipclient/docs/models/operations/restorestackrequest.md new file mode 100644 index 00000000..7eec7a44 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/restorestackrequest.md @@ -0,0 +1,9 @@ +# RestoreStackRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------ | ------------------ | ------------------ | ------------------ | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `StackID` | *string* | :heavy_check_mark: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/restorestackresponse.md b/internal/membershipclient/docs/models/operations/restorestackresponse.md new file mode 100644 index 00000000..6be11c71 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/restorestackresponse.md @@ -0,0 +1,10 @@ +# RestoreStackResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `CreateStackResponse` | [*components.CreateStackResponse](../../models/components/createstackresponse.md) | :heavy_minus_sign: | OK | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/updateapplicationrequest.md b/internal/membershipclient/docs/models/operations/updateapplicationrequest.md new file mode 100644 index 00000000..e8948da5 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/updateapplicationrequest.md @@ -0,0 +1,9 @@ +# UpdateApplicationRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | ------------------------------------------------------------------------- | +| `ApplicationID` | *string* | :heavy_check_mark: | N/A | +| `Body` | [*components.ApplicationData](../../models/components/applicationdata.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/updateapplicationresponse.md b/internal/membershipclient/docs/models/operations/updateapplicationresponse.md new file mode 100644 index 00000000..a762a046 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/updateapplicationresponse.md @@ -0,0 +1,10 @@ +# UpdateApplicationResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `UpdateApplicationResponse` | [*components.UpdateApplicationResponse](../../models/components/updateapplicationresponse.md) | :heavy_minus_sign: | Application updated | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/updateorganizationrequest.md b/internal/membershipclient/docs/models/operations/updateorganizationrequest.md new file mode 100644 index 00000000..4184d396 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/updateorganizationrequest.md @@ -0,0 +1,9 @@ +# UpdateOrganizationRequest + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | --------------------------------------------------------------------------- | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `Body` | [*components.OrganizationData](../../models/components/organizationdata.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/updateorganizationresponse.md b/internal/membershipclient/docs/models/operations/updateorganizationresponse.md new file mode 100644 index 00000000..7a89e4f8 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/updateorganizationresponse.md @@ -0,0 +1,10 @@ +# UpdateOrganizationResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `ReadOrganizationResponse` | [*components.ReadOrganizationResponse](../../models/components/readorganizationresponse.md) | :heavy_minus_sign: | Organization updated | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/updatepolicyrequest.md b/internal/membershipclient/docs/models/operations/updatepolicyrequest.md new file mode 100644 index 00000000..e04dd429 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/updatepolicyrequest.md @@ -0,0 +1,10 @@ +# UpdatePolicyRequest + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------- | --------------------------------------------------------------- | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `PolicyID` | *int64* | :heavy_check_mark: | N/A | +| `Body` | [*components.PolicyData](../../models/components/policydata.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/updatepolicyresponse.md b/internal/membershipclient/docs/models/operations/updatepolicyresponse.md new file mode 100644 index 00000000..dc0a8e95 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/updatepolicyresponse.md @@ -0,0 +1,10 @@ +# UpdatePolicyResponse + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `UpdatePolicyResponse` | [*components.UpdatePolicyResponse](../../models/components/updatepolicyresponse.md) | :heavy_minus_sign: | Policy updated | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/updatestackrequest.md b/internal/membershipclient/docs/models/operations/updatestackrequest.md new file mode 100644 index 00000000..228797e5 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/updatestackrequest.md @@ -0,0 +1,10 @@ +# UpdateStackRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------- | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `StackID` | *string* | :heavy_check_mark: | N/A | +| `Body` | [*components.StackData](../../models/components/stackdata.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/updatestackresponse.md b/internal/membershipclient/docs/models/operations/updatestackresponse.md new file mode 100644 index 00000000..bf90338a --- /dev/null +++ b/internal/membershipclient/docs/models/operations/updatestackresponse.md @@ -0,0 +1,10 @@ +# UpdateStackResponse + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `CreateStackResponse` | [*components.CreateStackResponse](../../models/components/createstackresponse.md) | :heavy_minus_sign: | Updated stack | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/upgradestackrequest.md b/internal/membershipclient/docs/models/operations/upgradestackrequest.md new file mode 100644 index 00000000..39b2bf86 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/upgradestackrequest.md @@ -0,0 +1,10 @@ +# UpgradeStackRequest + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | ------------------------------------------------------------------- | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `StackID` | *string* | :heavy_check_mark: | N/A | +| `Body` | [*components.StackVersion](../../models/components/stackversion.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/upgradestackresponse.md b/internal/membershipclient/docs/models/operations/upgradestackresponse.md new file mode 100644 index 00000000..5c5455f0 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/upgradestackresponse.md @@ -0,0 +1,9 @@ +# UpgradeStackResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/upsertauthenticationproviderrequest.md b/internal/membershipclient/docs/models/operations/upsertauthenticationproviderrequest.md new file mode 100644 index 00000000..25954d7b --- /dev/null +++ b/internal/membershipclient/docs/models/operations/upsertauthenticationproviderrequest.md @@ -0,0 +1,9 @@ +# UpsertAuthenticationProviderRequest + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `Body` | [*components.AuthenticationProviderData](../../models/components/authenticationproviderdata.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/upsertauthenticationproviderresponse.md b/internal/membershipclient/docs/models/operations/upsertauthenticationproviderresponse.md new file mode 100644 index 00000000..c4b912d3 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/upsertauthenticationproviderresponse.md @@ -0,0 +1,10 @@ +# UpsertAuthenticationProviderResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `AuthenticationProviderResponse` | [*components.AuthenticationProviderResponse](../../models/components/authenticationproviderresponse.md) | :heavy_minus_sign: | Authentication provider created or updated | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/upsertorganizationuserrequest.md b/internal/membershipclient/docs/models/operations/upsertorganizationuserrequest.md new file mode 100644 index 00000000..f1ad6aa5 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/upsertorganizationuserrequest.md @@ -0,0 +1,10 @@ +# UpsertOrganizationUserRequest + + +## Fields + +| Field | Type | Required | Description | +| ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `UserID` | *string* | :heavy_check_mark: | N/A | +| `Body` | [*components.UpdateOrganizationUserRequest](../../models/components/updateorganizationuserrequest.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/upsertorganizationuserresponse.md b/internal/membershipclient/docs/models/operations/upsertorganizationuserresponse.md new file mode 100644 index 00000000..70438f1f --- /dev/null +++ b/internal/membershipclient/docs/models/operations/upsertorganizationuserresponse.md @@ -0,0 +1,9 @@ +# UpsertOrganizationUserResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/upsertstackuseraccessrequest.md b/internal/membershipclient/docs/models/operations/upsertstackuseraccessrequest.md new file mode 100644 index 00000000..135103fc --- /dev/null +++ b/internal/membershipclient/docs/models/operations/upsertstackuseraccessrequest.md @@ -0,0 +1,11 @@ +# UpsertStackUserAccessRequest + + +## Fields + +| Field | Type | Required | Description | +| --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------- | +| `OrganizationID` | *string* | :heavy_check_mark: | N/A | +| `StackID` | *string* | :heavy_check_mark: | N/A | +| `UserID` | *string* | :heavy_check_mark: | N/A | +| `Body` | [*components.UpdateStackUserRequest](../../models/components/updatestackuserrequest.md) | :heavy_minus_sign: | N/A | \ No newline at end of file diff --git a/internal/membershipclient/docs/models/operations/upsertstackuseraccessresponse.md b/internal/membershipclient/docs/models/operations/upsertstackuseraccessresponse.md new file mode 100644 index 00000000..6cc606a7 --- /dev/null +++ b/internal/membershipclient/docs/models/operations/upsertstackuseraccessresponse.md @@ -0,0 +1,9 @@ +# UpsertStackUserAccessResponse + + +## Fields + +| Field | Type | Required | Description | +| ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ------------------------------------------------------------------ | +| `HTTPMeta` | [components.HTTPMetadata](../../models/components/httpmetadata.md) | :heavy_check_mark: | N/A | +| `Error` | [*components.Error](../../models/components/error.md) | :heavy_minus_sign: | Error | \ No newline at end of file diff --git a/internal/membershipclient/docs/sdks/sdk/README.md b/internal/membershipclient/docs/sdks/sdk/README.md new file mode 100644 index 00000000..34b3daef --- /dev/null +++ b/internal/membershipclient/docs/sdks/sdk/README.md @@ -0,0 +1,4162 @@ +# SDK + +## Overview + +### Available Operations + +* [GetServerInfo](#getserverinfo) - Get server info +* [ListOrganizations](#listorganizations) - List organizations of the connected user +* [CreateOrganization](#createorganization) - Create organization +* [~~ListOrganizationsExpanded~~](#listorganizationsexpanded) - List organizations of the connected user with expanded data :warning: **Deprecated** +* [ReadOrganization](#readorganization) - Read organization +* [UpdateOrganization](#updateorganization) - Update organization +* [DeleteOrganization](#deleteorganization) - Delete organization +* [ReadAuthenticationProvider](#readauthenticationprovider) - Read authentication provider +* [UpsertAuthenticationProvider](#upsertauthenticationprovider) - Upsert an authentication provider +* [DeleteAuthenticationProvider](#deleteauthenticationprovider) - Delete authentication provider +* [ListFeatures](#listfeatures) - List features +* [AddFeatures](#addfeatures) - Add Features +* [DeleteFeature](#deletefeature) - Delete feature +* [~~ReadOrganizationClient~~](#readorganizationclient) - Read organization client (DEPRECATED) (until 12/31/2025) :warning: **Deprecated** +* [~~CreateOrganizationClient~~](#createorganizationclient) - Create organization client (DEPRECATED) (until 12/31/2025) :warning: **Deprecated** +* [~~DeleteOrganizationClient~~](#deleteorganizationclient) - Delete organization client (DEPRECATED) (until 12/31/2025) :warning: **Deprecated** +* [OrganizationClientsRead](#organizationclientsread) - Read organization clients +* [OrganizationClientCreate](#organizationclientcreate) - Create organization client +* [OrganizationClientRead](#organizationclientread) - Read organization client +* [OrganizationClientDelete](#organizationclientdelete) - Delete organization client +* [OrganizationClientUpdate](#organizationclientupdate) - Update organization client +* [ListLogs](#listlogs) - List logs +* [ListUsersOfOrganization](#listusersoforganization) - List users of organization +* [ReadUserOfOrganization](#readuseroforganization) - Read user of organization +* [UpsertOrganizationUser](#upsertorganizationuser) - Update user within an organization +* [DeleteUserFromOrganization](#deleteuserfromorganization) - delete user from organization +* [ListPolicies](#listpolicies) - List policies of organization +* [CreatePolicy](#createpolicy) - Create policy +* [ReadPolicy](#readpolicy) - Read policy with scopes +* [UpdatePolicy](#updatepolicy) - Update policy +* [DeletePolicy](#deletepolicy) - Delete policy +* [AddScopeToPolicy](#addscopetopolicy) - Add scope to policy +* [RemoveScopeFromPolicy](#removescopefrompolicy) - Remove scope from policy +* [ListStacks](#liststacks) - List stacks +* [CreateStack](#createstack) - Create stack +* [ListModules](#listmodules) - List modules of a stack +* [EnableModule](#enablemodule) - enable module +* [DisableModule](#disablemodule) - disable module +* [UpgradeStack](#upgradestack) - Upgrade stack +* [GetStack](#getstack) - Find stack +* [UpdateStack](#updatestack) - Update stack +* [DeleteStack](#deletestack) - Delete stack +* [ListStackUsersAccesses](#liststackusersaccesses) - List stack users accesses within an organization +* [ReadStackUserAccess](#readstackuseraccess) - Read stack user access within an organization +* [DeleteStackUserAccess](#deletestackuseraccess) - Delete stack user access within an organization +* [UpsertStackUserAccess](#upsertstackuseraccess) - Update stack user access within an organization +* [DisableStack](#disablestack) - Disable stack +* [EnableStack](#enablestack) - Enable stack +* [RestoreStack](#restorestack) - Restore stack +* [EnableStargate](#enablestargate) - Enable stargate on a stack +* [DisableStargate](#disablestargate) - Disable stargate on a stack +* [ListInvitations](#listinvitations) - List invitations of the user +* [AcceptInvitation](#acceptinvitation) - Accept invitation +* [DeclineInvitation](#declineinvitation) - Decline invitation +* [ListOrganizationInvitations](#listorganizationinvitations) - List invitations of the organization +* [CreateInvitation](#createinvitation) - Create invitation +* [DeleteInvitation](#deleteinvitation) - Delete invitation +* [ListRegions](#listregions) - List regions +* [CreatePrivateRegion](#createprivateregion) - Create a private region +* [GetRegion](#getregion) - Get region +* [DeleteRegion](#deleteregion) - Delete region +* [GetRegionVersions](#getregionversions) - Get region versions +* [ListOrganizationApplications](#listorganizationapplications) - List applications enabled for organization +* [GetOrganizationApplication](#getorganizationapplication) - Get application for organization +* [EnableApplicationForOrganization](#enableapplicationfororganization) - Enable application for organization +* [DisableApplicationForOrganization](#disableapplicationfororganization) - Disable application for organization +* [ListApplications](#listapplications) - List applications +* [CreateApplication](#createapplication) - Create application +* [GetApplication](#getapplication) - Get application +* [UpdateApplication](#updateapplication) - Update application +* [DeleteApplication](#deleteapplication) - Delete application +* [CreateApplicationScope](#createapplicationscope) - Create application scope +* [DeleteApplicationScope](#deleteapplicationscope) - Delete application scope +* [CreateUser](#createuser) - Create user +* [ReadConnectedUser](#readconnecteduser) - Read user + +## GetServerInfo + +Get server info + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.GetServerInfo(ctx) + if err != nil { + log.Fatal(err) + } + if res.ServerInfo != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.GetServerInfoResponse](../../models/operations/getserverinforesponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ListOrganizations + +List organizations of the connected user + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ListOrganizations(ctx, operations.ListOrganizationsRequest{}) + if err != nil { + log.Fatal(err) + } + if res.ListOrganizationExpandedResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListOrganizationsRequest](../../models/operations/listorganizationsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListOrganizationsResponse](../../models/operations/listorganizationsresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## CreateOrganization + +Create organization + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.CreateOrganization(ctx, nil) + if err != nil { + log.Fatal(err) + } + if res.CreateOrganizationResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [components.CreateOrganizationRequest](../../models/components/createorganizationrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.CreateOrganizationResponse](../../models/operations/createorganizationresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ~~ListOrganizationsExpanded~~ + +List organizations of the connected user with expanded data + +> :warning: **DEPRECATED**: This will be removed in a future release, please migrate away from it as soon as possible. + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ListOrganizationsExpanded(ctx) + if err != nil { + log.Fatal(err) + } + if res.ListOrganizationExpandedResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListOrganizationsExpandedResponse](../../models/operations/listorganizationsexpandedresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ReadOrganization + +Read organization + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ReadOrganization(ctx, operations.ReadOrganizationRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.ReadOrganizationResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ReadOrganizationRequest](../../models/operations/readorganizationrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ReadOrganizationResponse](../../models/operations/readorganizationresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## UpdateOrganization + +Update organization + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.UpdateOrganization(ctx, operations.UpdateOrganizationRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.ReadOrganizationResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.UpdateOrganizationRequest](../../models/operations/updateorganizationrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.UpdateOrganizationResponse](../../models/operations/updateorganizationresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## DeleteOrganization + +Delete organization + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.DeleteOrganization(ctx, operations.DeleteOrganizationRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DeleteOrganizationRequest](../../models/operations/deleteorganizationrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DeleteOrganizationResponse](../../models/operations/deleteorganizationresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ReadAuthenticationProvider + +Read authentication provider + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ReadAuthenticationProvider(ctx, operations.ReadAuthenticationProviderRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.AuthenticationProviderResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ReadAuthenticationProviderRequest](../../models/operations/readauthenticationproviderrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ReadAuthenticationProviderResponse](../../models/operations/readauthenticationproviderresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## UpsertAuthenticationProvider + +Upsert an authentication provider + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.UpsertAuthenticationProvider(ctx, operations.UpsertAuthenticationProviderRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.AuthenticationProviderResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.UpsertAuthenticationProviderRequest](../../models/operations/upsertauthenticationproviderrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.UpsertAuthenticationProviderResponse](../../models/operations/upsertauthenticationproviderresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## DeleteAuthenticationProvider + +Delete authentication provider + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.DeleteAuthenticationProvider(ctx, operations.DeleteAuthenticationProviderRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DeleteAuthenticationProviderRequest](../../models/operations/deleteauthenticationproviderrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DeleteAuthenticationProviderResponse](../../models/operations/deleteauthenticationproviderresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ListFeatures + +List features + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ListFeatures(ctx, operations.ListFeaturesRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Object != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListFeaturesRequest](../../models/operations/listfeaturesrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListFeaturesResponse](../../models/operations/listfeaturesresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## AddFeatures + +Add Features + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.AddFeatures(ctx, operations.AddFeaturesRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.AddFeaturesRequest](../../models/operations/addfeaturesrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.AddFeaturesResponse](../../models/operations/addfeaturesresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## DeleteFeature + +Delete feature + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.DeleteFeature(ctx, operations.DeleteFeatureRequest{ + OrganizationID: "", + Name: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DeleteFeatureRequest](../../models/operations/deletefeaturerequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DeleteFeatureResponse](../../models/operations/deletefeatureresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ~~ReadOrganizationClient~~ + +Read organization client (DEPRECATED) (until 12/31/2025) + +> :warning: **DEPRECATED**: This will be removed in a future release, please migrate away from it as soon as possible. + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ReadOrganizationClient(ctx, operations.ReadOrganizationClientRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.CreateClientResponseResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ReadOrganizationClientRequest](../../models/operations/readorganizationclientrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ReadOrganizationClientResponse](../../models/operations/readorganizationclientresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ~~CreateOrganizationClient~~ + +Create organization client (DEPRECATED) (until 12/31/2025) + +> :warning: **DEPRECATED**: This will be removed in a future release, please migrate away from it as soon as possible. + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.CreateOrganizationClient(ctx, operations.CreateOrganizationClientRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.CreateClientResponseResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.CreateOrganizationClientRequest](../../models/operations/createorganizationclientrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.CreateOrganizationClientResponse](../../models/operations/createorganizationclientresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ~~DeleteOrganizationClient~~ + +Delete organization client (DEPRECATED) (until 12/31/2025) + +> :warning: **DEPRECATED**: This will be removed in a future release, please migrate away from it as soon as possible. + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.DeleteOrganizationClient(ctx, operations.DeleteOrganizationClientRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DeleteOrganizationClientRequest](../../models/operations/deleteorganizationclientrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DeleteOrganizationClientResponse](../../models/operations/deleteorganizationclientresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## OrganizationClientsRead + +Read organization clients + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.OrganizationClientsRead(ctx, operations.OrganizationClientsReadRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.ReadOrganizationClientsResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.OrganizationClientsReadRequest](../../models/operations/organizationclientsreadrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.OrganizationClientsReadResponse](../../models/operations/organizationclientsreadresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## OrganizationClientCreate + +Create organization client + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.OrganizationClientCreate(ctx, operations.OrganizationClientCreateRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.CreateOrganizationClientResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.OrganizationClientCreateRequest](../../models/operations/organizationclientcreaterequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.OrganizationClientCreateResponse](../../models/operations/organizationclientcreateresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## OrganizationClientRead + +Read organization client + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.OrganizationClientRead(ctx, operations.OrganizationClientReadRequest{ + OrganizationID: "", + ClientID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.ReadOrganizationClientResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.OrganizationClientReadRequest](../../models/operations/organizationclientreadrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.OrganizationClientReadResponse](../../models/operations/organizationclientreadresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## OrganizationClientDelete + +Delete organization client + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.OrganizationClientDelete(ctx, operations.OrganizationClientDeleteRequest{ + OrganizationID: "", + ClientID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.OrganizationClientDeleteRequest](../../models/operations/organizationclientdeleterequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.OrganizationClientDeleteResponse](../../models/operations/organizationclientdeleteresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## OrganizationClientUpdate + +Update organization client + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.OrganizationClientUpdate(ctx, operations.OrganizationClientUpdateRequest{ + OrganizationID: "", + ClientID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.OrganizationClientUpdateRequest](../../models/operations/organizationclientupdaterequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.OrganizationClientUpdateResponse](../../models/operations/organizationclientupdateresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ListLogs + +List logs + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ListLogs(ctx, operations.ListLogsRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.LogCursor != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListLogsRequest](../../models/operations/listlogsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListLogsResponse](../../models/operations/listlogsresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ListUsersOfOrganization + +List users of organization + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ListUsersOfOrganization(ctx, operations.ListUsersOfOrganizationRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.ListUsersResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListUsersOfOrganizationRequest](../../models/operations/listusersoforganizationrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListUsersOfOrganizationResponse](../../models/operations/listusersoforganizationresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ReadUserOfOrganization + +Read user of organization + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ReadUserOfOrganization(ctx, operations.ReadUserOfOrganizationRequest{ + OrganizationID: "", + UserID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.ReadOrganizationUserResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ReadUserOfOrganizationRequest](../../models/operations/readuseroforganizationrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ReadUserOfOrganizationResponse](../../models/operations/readuseroforganizationresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## UpsertOrganizationUser + +Update user within an organization + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.UpsertOrganizationUser(ctx, operations.UpsertOrganizationUserRequest{ + OrganizationID: "", + UserID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.UpsertOrganizationUserRequest](../../models/operations/upsertorganizationuserrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.UpsertOrganizationUserResponse](../../models/operations/upsertorganizationuserresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## DeleteUserFromOrganization + +The owner of the organization can remove anyone while each user can leave any organization where it is not owner. + + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.DeleteUserFromOrganization(ctx, operations.DeleteUserFromOrganizationRequest{ + OrganizationID: "", + UserID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DeleteUserFromOrganizationRequest](../../models/operations/deleteuserfromorganizationrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DeleteUserFromOrganizationResponse](../../models/operations/deleteuserfromorganizationresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ListPolicies + +List policies of organization + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ListPolicies(ctx, operations.ListPoliciesRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.ListPoliciesResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListPoliciesRequest](../../models/operations/listpoliciesrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListPoliciesResponse](../../models/operations/listpoliciesresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## CreatePolicy + +Create policy + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.CreatePolicy(ctx, operations.CreatePolicyRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.CreatePolicyResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.CreatePolicyRequest](../../models/operations/createpolicyrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.CreatePolicyResponse](../../models/operations/createpolicyresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ReadPolicy + +Read policy with scopes + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ReadPolicy(ctx, operations.ReadPolicyRequest{ + OrganizationID: "", + PolicyID: 831591, + }) + if err != nil { + log.Fatal(err) + } + if res.ReadPolicyResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ReadPolicyRequest](../../models/operations/readpolicyrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ReadPolicyResponse](../../models/operations/readpolicyresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## UpdatePolicy + +Update policy + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.UpdatePolicy(ctx, operations.UpdatePolicyRequest{ + OrganizationID: "", + PolicyID: 127460, + }) + if err != nil { + log.Fatal(err) + } + if res.UpdatePolicyResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.UpdatePolicyRequest](../../models/operations/updatepolicyrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.UpdatePolicyResponse](../../models/operations/updatepolicyresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## DeletePolicy + +Delete policy + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.DeletePolicy(ctx, operations.DeletePolicyRequest{ + OrganizationID: "", + PolicyID: 114294, + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DeletePolicyRequest](../../models/operations/deletepolicyrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DeletePolicyResponse](../../models/operations/deletepolicyresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## AddScopeToPolicy + +Add scope to policy + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.AddScopeToPolicy(ctx, operations.AddScopeToPolicyRequest{ + OrganizationID: "", + PolicyID: 328027, + ScopeID: 675877, + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.AddScopeToPolicyRequest](../../models/operations/addscopetopolicyrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.AddScopeToPolicyResponse](../../models/operations/addscopetopolicyresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## RemoveScopeFromPolicy + +Remove scope from policy + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.RemoveScopeFromPolicy(ctx, operations.RemoveScopeFromPolicyRequest{ + OrganizationID: "", + PolicyID: 995736, + ScopeID: 485996, + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.RemoveScopeFromPolicyRequest](../../models/operations/removescopefrompolicyrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.RemoveScopeFromPolicyResponse](../../models/operations/removescopefrompolicyresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ListStacks + +List stacks + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ListStacks(ctx, operations.ListStacksRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.ListStacksResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListStacksRequest](../../models/operations/liststacksrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListStacksResponse](../../models/operations/liststacksresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## CreateStack + +Create stack + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.CreateStack(ctx, operations.CreateStackRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.CreateStackResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.CreateStackRequest](../../models/operations/createstackrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.CreateStackResponse](../../models/operations/createstackresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ListModules + +List modules of a stack + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ListModules(ctx, operations.ListModulesRequest{ + OrganizationID: "", + StackID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.ListModulesResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListModulesRequest](../../models/operations/listmodulesrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListModulesResponse](../../models/operations/listmodulesresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## EnableModule + +enable module + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.EnableModule(ctx, operations.EnableModuleRequest{ + OrganizationID: "", + StackID: "", + Name: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.EnableModuleRequest](../../models/operations/enablemodulerequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.EnableModuleResponse](../../models/operations/enablemoduleresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## DisableModule + +disable module + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.DisableModule(ctx, operations.DisableModuleRequest{ + OrganizationID: "", + StackID: "", + Name: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DisableModuleRequest](../../models/operations/disablemodulerequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DisableModuleResponse](../../models/operations/disablemoduleresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## UpgradeStack + +Upgrade stack + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.UpgradeStack(ctx, operations.UpgradeStackRequest{ + OrganizationID: "", + StackID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.UpgradeStackRequest](../../models/operations/upgradestackrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.UpgradeStackResponse](../../models/operations/upgradestackresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## GetStack + +Find stack + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.GetStack(ctx, operations.GetStackRequest{ + OrganizationID: "", + StackID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.CreateStackResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.GetStackRequest](../../models/operations/getstackrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.GetStackResponse](../../models/operations/getstackresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## UpdateStack + +Update stack + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.UpdateStack(ctx, operations.UpdateStackRequest{ + OrganizationID: "", + StackID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.CreateStackResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.UpdateStackRequest](../../models/operations/updatestackrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.UpdateStackResponse](../../models/operations/updatestackresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## DeleteStack + +Delete stack + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.DeleteStack(ctx, operations.DeleteStackRequest{ + OrganizationID: "", + StackID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DeleteStackRequest](../../models/operations/deletestackrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DeleteStackResponse](../../models/operations/deletestackresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ListStackUsersAccesses + +List stack users accesses within an organization + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ListStackUsersAccesses(ctx, operations.ListStackUsersAccessesRequest{ + OrganizationID: "", + StackID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.StackUserAccessResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListStackUsersAccessesRequest](../../models/operations/liststackusersaccessesrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListStackUsersAccessesResponse](../../models/operations/liststackusersaccessesresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ReadStackUserAccess + +Read stack user access within an organization + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ReadStackUserAccess(ctx, operations.ReadStackUserAccessRequest{ + OrganizationID: "", + StackID: "", + UserID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.ReadStackUserAccess != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ReadStackUserAccessRequest](../../models/operations/readstackuseraccessrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ReadStackUserAccessResponse](../../models/operations/readstackuseraccessresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## DeleteStackUserAccess + +Delete stack user access within an organization + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.DeleteStackUserAccess(ctx, operations.DeleteStackUserAccessRequest{ + OrganizationID: "", + StackID: "", + UserID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DeleteStackUserAccessRequest](../../models/operations/deletestackuseraccessrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DeleteStackUserAccessResponse](../../models/operations/deletestackuseraccessresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## UpsertStackUserAccess + +Update stack user access within an organization + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.UpsertStackUserAccess(ctx, operations.UpsertStackUserAccessRequest{ + OrganizationID: "", + StackID: "", + UserID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.UpsertStackUserAccessRequest](../../models/operations/upsertstackuseraccessrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.UpsertStackUserAccessResponse](../../models/operations/upsertstackuseraccessresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## DisableStack + +Disable stack + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.DisableStack(ctx, operations.DisableStackRequest{ + OrganizationID: "", + StackID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DisableStackRequest](../../models/operations/disablestackrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DisableStackResponse](../../models/operations/disablestackresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## EnableStack + +Enable stack + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.EnableStack(ctx, operations.EnableStackRequest{ + OrganizationID: "", + StackID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.EnableStackRequest](../../models/operations/enablestackrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.EnableStackResponse](../../models/operations/enablestackresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## RestoreStack + +Restore stack + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.RestoreStack(ctx, operations.RestoreStackRequest{ + OrganizationID: "", + StackID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.CreateStackResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.RestoreStackRequest](../../models/operations/restorestackrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.RestoreStackResponse](../../models/operations/restorestackresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## EnableStargate + +Enable stargate on a stack + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.EnableStargate(ctx, operations.EnableStargateRequest{ + OrganizationID: "", + StackID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.EnableStargateRequest](../../models/operations/enablestargaterequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.EnableStargateResponse](../../models/operations/enablestargateresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## DisableStargate + +Disable stargate on a stack + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.DisableStargate(ctx, operations.DisableStargateRequest{ + OrganizationID: "", + StackID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DisableStargateRequest](../../models/operations/disablestargaterequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DisableStargateResponse](../../models/operations/disablestargateresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ListInvitations + +List invitations of the user + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ListInvitations(ctx, operations.ListInvitationsRequest{}) + if err != nil { + log.Fatal(err) + } + if res.ListInvitationsResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListInvitationsRequest](../../models/operations/listinvitationsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListInvitationsResponse](../../models/operations/listinvitationsresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## AcceptInvitation + +Accept invitation + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.AcceptInvitation(ctx, operations.AcceptInvitationRequest{ + InvitationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.AcceptInvitationRequest](../../models/operations/acceptinvitationrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.AcceptInvitationResponse](../../models/operations/acceptinvitationresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## DeclineInvitation + +Decline invitation + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.DeclineInvitation(ctx, operations.DeclineInvitationRequest{ + InvitationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DeclineInvitationRequest](../../models/operations/declineinvitationrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DeclineInvitationResponse](../../models/operations/declineinvitationresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ListOrganizationInvitations + +List invitations of the organization + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ListOrganizationInvitations(ctx, operations.ListOrganizationInvitationsRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.ListInvitationsResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListOrganizationInvitationsRequest](../../models/operations/listorganizationinvitationsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListOrganizationInvitationsResponse](../../models/operations/listorganizationinvitationsresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## CreateInvitation + +Create invitation + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.CreateInvitation(ctx, operations.CreateInvitationRequest{ + OrganizationID: "", + Email: "Manley_Hoeger@hotmail.com", + }) + if err != nil { + log.Fatal(err) + } + if res.CreateInvitationResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.CreateInvitationRequest](../../models/operations/createinvitationrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.CreateInvitationResponse](../../models/operations/createinvitationresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## DeleteInvitation + +Delete invitation + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.DeleteInvitation(ctx, operations.DeleteInvitationRequest{ + OrganizationID: "", + InvitationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DeleteInvitationRequest](../../models/operations/deleteinvitationrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DeleteInvitationResponse](../../models/operations/deleteinvitationresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ListRegions + +List regions + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ListRegions(ctx, operations.ListRegionsRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.ListRegionsResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListRegionsRequest](../../models/operations/listregionsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListRegionsResponse](../../models/operations/listregionsresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## CreatePrivateRegion + +Create a private region + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.CreatePrivateRegion(ctx, operations.CreatePrivateRegionRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.CreatedPrivateRegionResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.CreatePrivateRegionRequest](../../models/operations/createprivateregionrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.CreatePrivateRegionResponse](../../models/operations/createprivateregionresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## GetRegion + +Get region + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.GetRegion(ctx, operations.GetRegionRequest{ + OrganizationID: "", + RegionID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.GetRegionResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | -------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.GetRegionRequest](../../models/operations/getregionrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.GetRegionResponse](../../models/operations/getregionresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## DeleteRegion + +Delete region + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.DeleteRegion(ctx, operations.DeleteRegionRequest{ + OrganizationID: "", + RegionID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DeleteRegionRequest](../../models/operations/deleteregionrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DeleteRegionResponse](../../models/operations/deleteregionresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## GetRegionVersions + +Get region versions + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.GetRegionVersions(ctx, operations.GetRegionVersionsRequest{ + OrganizationID: "", + RegionID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.GetRegionVersionsResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.GetRegionVersionsRequest](../../models/operations/getregionversionsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.GetRegionVersionsResponse](../../models/operations/getregionversionsresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ListOrganizationApplications + +List applications enabled for organization + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ListOrganizationApplications(ctx, operations.ListOrganizationApplicationsRequest{ + OrganizationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.ListApplicationsResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.ListOrganizationApplicationsRequest](../../models/operations/listorganizationapplicationsrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListOrganizationApplicationsResponse](../../models/operations/listorganizationapplicationsresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## GetOrganizationApplication + +Get application for organization + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.GetOrganizationApplication(ctx, operations.GetOrganizationApplicationRequest{ + OrganizationID: "", + ApplicationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.GetApplicationResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.GetOrganizationApplicationRequest](../../models/operations/getorganizationapplicationrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.GetOrganizationApplicationResponse](../../models/operations/getorganizationapplicationresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## EnableApplicationForOrganization + +Enable application for organization + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.EnableApplicationForOrganization(ctx, operations.EnableApplicationForOrganizationRequest{ + OrganizationID: "", + ApplicationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.EnableApplicationForOrganizationResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.EnableApplicationForOrganizationRequest](../../models/operations/enableapplicationfororganizationrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.EnableApplicationForOrganizationResponse](../../models/operations/enableapplicationfororganizationresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## DisableApplicationForOrganization + +Disable application for organization + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.DisableApplicationForOrganization(ctx, operations.DisableApplicationForOrganizationRequest{ + OrganizationID: "", + ApplicationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DisableApplicationForOrganizationRequest](../../models/operations/disableapplicationfororganizationrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DisableApplicationForOrganizationResponse](../../models/operations/disableapplicationfororganizationresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ListApplications + +List applications + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ListApplications(ctx) + if err != nil { + log.Fatal(err) + } + if res.ListApplicationsResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ListApplicationsResponse](../../models/operations/listapplicationsresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## CreateApplication + +Create application + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.CreateApplication(ctx, nil) + if err != nil { + log.Fatal(err) + } + if res.CreateApplicationResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [components.ApplicationData](../../models/components/applicationdata.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.CreateApplicationResponse](../../models/operations/createapplicationresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## GetApplication + +Get application + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.GetApplication(ctx, operations.GetApplicationRequest{ + ApplicationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.GetApplicationResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.GetApplicationRequest](../../models/operations/getapplicationrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.GetApplicationResponse](../../models/operations/getapplicationresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## UpdateApplication + +Update application + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.UpdateApplication(ctx, operations.UpdateApplicationRequest{ + ApplicationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.UpdateApplicationResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.UpdateApplicationRequest](../../models/operations/updateapplicationrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.UpdateApplicationResponse](../../models/operations/updateapplicationresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## DeleteApplication + +Delete application + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.DeleteApplication(ctx, operations.DeleteApplicationRequest{ + ApplicationID: "", + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------ | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DeleteApplicationRequest](../../models/operations/deleteapplicationrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DeleteApplicationResponse](../../models/operations/deleteapplicationresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## CreateApplicationScope + +Create application scope + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.CreateApplicationScope(ctx, operations.CreateApplicationScopeRequest{ + ApplicationID: "550e8400-e29b-41d4-a716-446655440000", + }) + if err != nil { + log.Fatal(err) + } + if res.CreateApplicationScopeResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.CreateApplicationScopeRequest](../../models/operations/createapplicationscoperequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.CreateApplicationScopeResponse](../../models/operations/createapplicationscoperesponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## DeleteApplicationScope + +Delete a specific scope from an application. This operation requires system administrator privileges. + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.DeleteApplicationScope(ctx, operations.DeleteApplicationScopeRequest{ + ApplicationID: "550e8400-e29b-41d4-a716-446655440000", + ScopeID: 115177, + }) + if err != nil { + log.Fatal(err) + } + if res.Error != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [operations.DeleteApplicationScopeRequest](../../models/operations/deleteapplicationscoperequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.DeleteApplicationScopeResponse](../../models/operations/deleteapplicationscoperesponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.Error | 400, 404 | application/json | +| apierrors.Error | 500 | application/json | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## CreateUser + +Create a new user in the system. This operation requires system administrator privileges. + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.CreateUser(ctx, components.CreateUserRequest{ + Email: "user@example.com", + }) + if err != nil { + log.Fatal(err) + } + if res.CreateUserResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `request` | [components.CreateUserRequest](../../models/components/createuserrequest.md) | :heavy_check_mark: | The request object to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.CreateUserResponse](../../models/operations/createuserresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.Error | 400 | application/json | +| apierrors.Error | 500 | application/json | +| apierrors.APIError | 4XX, 5XX | \*/\* | + +## ReadConnectedUser + +Read user + +### Example Usage + + +```go +package main + +import( + "context" + "github.com/formancehq/fctl/internal/membershipclient" + "log" +) + +func main() { + ctx := context.Background() + + s := membershipclient.New( + membershipclient.WithSecurity(""), + ) + + res, err := s.ReadConnectedUser(ctx) + if err != nil { + log.Fatal(err) + } + if res.ReadUserResponse != nil { + // handle response + } +} +``` + +### Parameters + +| Parameter | Type | Required | Description | +| -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | -------------------------------------------------------- | +| `ctx` | [context.Context](https://pkg.go.dev/context#Context) | :heavy_check_mark: | The context to use for the request. | +| `opts` | [][operations.Option](../../models/operations/option.md) | :heavy_minus_sign: | The options for this request. | + +### Response + +**[*operations.ReadConnectedUserResponse](../../models/operations/readconnecteduserresponse.md), error** + +### Errors + +| Error Type | Status Code | Content Type | +| ------------------ | ------------------ | ------------------ | +| apierrors.APIError | 4XX, 5XX | \*/\* | \ No newline at end of file diff --git a/internal/membershipclient/go.mod b/internal/membershipclient/go.mod new file mode 100644 index 00000000..dfe1b531 --- /dev/null +++ b/internal/membershipclient/go.mod @@ -0,0 +1,11 @@ +module github.com/formancehq/fctl/internal/membershipclient + +go 1.22 + +require github.com/stretchr/testify v1.11.1 + +require ( + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/internal/membershipclient/go.sum b/internal/membershipclient/go.sum new file mode 100644 index 00000000..c4c1710c --- /dev/null +++ b/internal/membershipclient/go.sum @@ -0,0 +1,10 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U= +github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/membershipclient/internal/config/sdkconfiguration.go b/internal/membershipclient/internal/config/sdkconfiguration.go new file mode 100644 index 00000000..60ed069d --- /dev/null +++ b/internal/membershipclient/internal/config/sdkconfiguration.go @@ -0,0 +1,33 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package config + +import ( + "context" + "github.com/formancehq/fctl/internal/membershipclient/retry" + "net/http" + "time" +) + +type HTTPClient interface { + Do(req *http.Request) (*http.Response, error) +} + +type SDKConfiguration struct { + Client HTTPClient + Security func(context.Context) (interface{}, error) + ServerURL string + ServerIndex int + ServerList []string + UserAgent string + RetryConfig *retry.Config + Timeout *time.Duration +} + +func (c *SDKConfiguration) GetServerDetails() (string, map[string]string) { + if c.ServerURL != "" { + return c.ServerURL, nil + } + + return c.ServerList[c.ServerIndex], nil +} diff --git a/internal/membershipclient/internal/hooks/hooks.go b/internal/membershipclient/internal/hooks/hooks.go new file mode 100644 index 00000000..a849b1c6 --- /dev/null +++ b/internal/membershipclient/internal/hooks/hooks.go @@ -0,0 +1,153 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package hooks + +import ( + "context" + "errors" + "github.com/formancehq/fctl/internal/membershipclient/internal/config" + "net/http" +) + +type FailEarly struct { + Cause error +} + +var _ error = (*FailEarly)(nil) + +func (f *FailEarly) Error() string { + return f.Cause.Error() +} + +// HTTPClient provides an interface for supplying the SDK with a custom HTTP client +type HTTPClient interface { + Do(req *http.Request) (*http.Response, error) +} + +type HookContext struct { + SDK any + SDKConfiguration config.SDKConfiguration + BaseURL string + Context context.Context + OperationID string + OAuth2Scopes []string + SecuritySource func(context.Context) (interface{}, error) +} + +type BeforeRequestContext struct { + HookContext +} + +type AfterSuccessContext struct { + HookContext +} + +type AfterErrorContext struct { + HookContext +} + +// sdkInitHook is called when the SDK is initializing. The hook can modify and return a new baseURL and HTTP client to be used by the SDK. +type sdkInitHook interface { + SDKInit(config config.SDKConfiguration) config.SDKConfiguration +} + +// beforeRequestHook is called before the SDK sends a request. The hook can modify the request before it is sent or return an error to stop the request from being sent. +type beforeRequestHook interface { + BeforeRequest(hookCtx BeforeRequestContext, req *http.Request) (*http.Request, error) +} + +// afterSuccessHook is called after the SDK receives a response. The hook can modify the response before it is handled or return an error to stop the response from being handled. +type afterSuccessHook interface { + AfterSuccess(hookCtx AfterSuccessContext, res *http.Response) (*http.Response, error) +} + +// afterErrorHook is called after the SDK encounters an error, or a non-successful response. The hook can modify the response if available otherwise modify the error. +// All afterErrorHook hooks are called and returning an error won't stop the other hooks from being called. But if you want to stop the other hooks from being called, you can return a FailEarly error wrapping your error. +type afterErrorHook interface { + AfterError(hookCtx AfterErrorContext, res *http.Response, err error) (*http.Response, error) +} + +type Hooks struct { + sdkInitHooks []sdkInitHook + beforeRequestHook []beforeRequestHook + afterSuccessHook []afterSuccessHook + afterErrorHook []afterErrorHook +} + +var _ sdkInitHook = (*Hooks)(nil) +var _ beforeRequestHook = (*Hooks)(nil) +var _ afterSuccessHook = (*Hooks)(nil) +var _ afterErrorHook = (*Hooks)(nil) + +func New() *Hooks { + h := &Hooks{ + sdkInitHooks: []sdkInitHook{}, + beforeRequestHook: []beforeRequestHook{}, + afterSuccessHook: []afterSuccessHook{}, + afterErrorHook: []afterErrorHook{}, + } + + initHooks(h) + + return h +} + +// registerSDKInitHook registers a hook to be used by the SDK for the initialization event. +func (h *Hooks) registerSDKInitHook(hook sdkInitHook) { + h.sdkInitHooks = append(h.sdkInitHooks, hook) +} + +// registerBeforeRequestHook registers a hook to be used by the SDK for the before request event. +func (h *Hooks) registerBeforeRequestHook(hook beforeRequestHook) { + h.beforeRequestHook = append(h.beforeRequestHook, hook) +} + +// registerAfterSuccessHook registers a hook to be used by the SDK for the after success event. +func (h *Hooks) registerAfterSuccessHook(hook afterSuccessHook) { + h.afterSuccessHook = append(h.afterSuccessHook, hook) +} + +// registerAfterErrorHook registers a hook to be used by the SDK for the after error event. +func (h *Hooks) registerAfterErrorHook(hook afterErrorHook) { + h.afterErrorHook = append(h.afterErrorHook, hook) +} + +func (h *Hooks) SDKInit(config config.SDKConfiguration) config.SDKConfiguration { + for _, hook := range h.sdkInitHooks { + config = hook.SDKInit(config) + } + return config +} + +func (h *Hooks) BeforeRequest(hookCtx BeforeRequestContext, req *http.Request) (*http.Request, error) { + for _, hook := range h.beforeRequestHook { + var err error + req, err = hook.BeforeRequest(hookCtx, req) + if err != nil { + return req, err + } + } + return req, nil +} + +func (h *Hooks) AfterSuccess(hookCtx AfterSuccessContext, res *http.Response) (*http.Response, error) { + for _, hook := range h.afterSuccessHook { + var err error + res, err = hook.AfterSuccess(hookCtx, res) + if err != nil { + return res, err + } + } + return res, nil +} + +func (h *Hooks) AfterError(hookCtx AfterErrorContext, res *http.Response, err error) (*http.Response, error) { + for _, hook := range h.afterErrorHook { + res, err = hook.AfterError(hookCtx, res, err) + var fe *FailEarly + if errors.As(err, &fe) { + return nil, fe.Cause + } + } + return res, err +} diff --git a/internal/membershipclient/internal/hooks/registration.go b/internal/membershipclient/internal/hooks/registration.go new file mode 100644 index 00000000..fa131be8 --- /dev/null +++ b/internal/membershipclient/internal/hooks/registration.go @@ -0,0 +1,18 @@ +package hooks + +/* + * This file is only ever generated once on the first generation and then is free to be modified. + * Any hooks you wish to add should be registered in the initHooks function. Feel free to define + * your hooks in this file or in separate files in the hooks package. + * + * Hooks are registered per SDK instance, and are valid for the lifetime of the SDK instance. + */ + +func initHooks(h *Hooks) { + // exampleHook := &ExampleHook{} + + // h.registerSDKInitHook(exampleHook) + // h.registerBeforeRequestHook(exampleHook) + // h.registerAfterErrorHook(exampleHook) + // h.registerAfterSuccessHook(exampleHook) +} diff --git a/internal/membershipclient/internal/utils/contenttype.go b/internal/membershipclient/internal/utils/contenttype.go new file mode 100644 index 00000000..f6487e01 --- /dev/null +++ b/internal/membershipclient/internal/utils/contenttype.go @@ -0,0 +1,37 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "fmt" + "mime" + "strings" +) + +func MatchContentType(contentType string, pattern string) bool { + if contentType == "" { + contentType = "application/octet-stream" + } + + if contentType == pattern || pattern == "*" || pattern == "*/*" { + return true + } + + mediaType, _, err := mime.ParseMediaType(contentType) + if err != nil { + return false + } + + if mediaType == pattern { + return true + } + + parts := strings.Split(mediaType, "/") + if len(parts) == 2 { + if fmt.Sprintf("%s/*", parts[0]) == pattern || fmt.Sprintf("*/%s", parts[1]) == pattern { + return true + } + } + + return false +} diff --git a/internal/membershipclient/internal/utils/env.go b/internal/membershipclient/internal/utils/env.go new file mode 100644 index 00000000..110d464e --- /dev/null +++ b/internal/membershipclient/internal/utils/env.go @@ -0,0 +1,16 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "os" +) + +// GetEnv returns the value of the environment variable named by the key or the defaultValue if the environment variable is not set. +func GetEnv(name, defaultValue string) string { + value := os.Getenv(name) + if value == "" { + return defaultValue + } + return value +} diff --git a/internal/membershipclient/internal/utils/form.go b/internal/membershipclient/internal/utils/form.go new file mode 100644 index 00000000..a2c1b148 --- /dev/null +++ b/internal/membershipclient/internal/utils/form.go @@ -0,0 +1,134 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "fmt" + "math/big" + "net/url" + "reflect" + "strings" + "time" + + "github.com/formancehq/fctl/internal/membershipclient/optionalnullable" + "github.com/formancehq/fctl/internal/membershipclient/types" +) + +func populateForm(paramName string, explode bool, objType reflect.Type, objValue reflect.Value, delimiter string, defaultValue *string, getFieldName func(reflect.StructField) string) url.Values { + + formValues := url.Values{} + + if isNil(objType, objValue) { + if defaultValue != nil { + formValues.Add(paramName, *defaultValue) + } + + return formValues + } + + if objType.Kind() == reflect.Pointer { + objType = objType.Elem() + objValue = objValue.Elem() + } + + switch objType.Kind() { + case reflect.Struct: + switch objValue.Interface().(type) { + case time.Time: + formValues.Add(paramName, valToString(objValue.Interface())) + case types.Date: + formValues.Add(paramName, valToString(objValue.Interface())) + case big.Int: + formValues.Add(paramName, valToString(objValue.Interface())) + default: + var items []string + + for i := 0; i < objType.NumField(); i++ { + fieldType := objType.Field(i) + valType := objValue.Field(i) + + if isNil(fieldType.Type, valType) { + continue + } + + if valType.Kind() == reflect.Pointer { + valType = valType.Elem() + } + + fieldName := getFieldName(fieldType) + if fieldName == "" { + continue + } + + if explode { + if valType.Kind() == reflect.Slice || valType.Kind() == reflect.Array { + for i := 0; i < valType.Len(); i++ { + formValues.Add(fieldName, valToString(valType.Index(i).Interface())) + } + } else { + formValues.Add(fieldName, valToString(valType.Interface())) + } + } else { + items = append(items, fmt.Sprintf("%s%s%s", fieldName, delimiter, valToString(valType.Interface()))) + } + } + + if len(items) > 0 { + formValues.Add(paramName, strings.Join(items, delimiter)) + } + } + case reflect.Map: + // check if optionalnullable.OptionalNullable[T] + if nullableValue, ok := optionalnullable.AsOptionalNullable(objValue); ok { + // Handle optionalnullable.OptionalNullable[T] using GetUntyped method + if value, isSet := nullableValue.GetUntyped(); isSet && value != nil { + formValues.Add(paramName, valToString(value)) + } + // If not set or explicitly null, skip adding to form + return formValues + } + + items := []string{} + + iter := objValue.MapRange() + for iter.Next() { + if explode { + formValues.Add(iter.Key().String(), valToString(iter.Value().Interface())) + } else { + items = append(items, fmt.Sprintf("%s%s%s", iter.Key().String(), delimiter, valToString(iter.Value().Interface()))) + } + } + + if len(items) > 0 { + formValues.Add(paramName, strings.Join(items, delimiter)) + } + case reflect.Slice, reflect.Array: + values := parseDelimitedArray(explode, objValue, delimiter) + for _, v := range values { + formValues.Add(paramName, v) + } + default: + formValues.Add(paramName, valToString(objValue.Interface())) + } + + return formValues +} + +func parseDelimitedArray(explode bool, objValue reflect.Value, delimiter string) []string { + values := []string{} + items := []string{} + + for i := 0; i < objValue.Len(); i++ { + if explode { + values = append(values, valToString(objValue.Index(i).Interface())) + } else { + items = append(items, valToString(objValue.Index(i).Interface())) + } + } + + if len(items) > 0 { + values = append(values, strings.Join(items, delimiter)) + } + + return values +} diff --git a/internal/membershipclient/internal/utils/headers.go b/internal/membershipclient/internal/utils/headers.go new file mode 100644 index 00000000..7556070d --- /dev/null +++ b/internal/membershipclient/internal/utils/headers.go @@ -0,0 +1,136 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "context" + "fmt" + "net/http" + "reflect" + "strings" + + "github.com/formancehq/fctl/internal/membershipclient/optionalnullable" +) + +func PopulateHeaders(_ context.Context, req *http.Request, headers interface{}, globals interface{}) { + globalsAlreadyPopulated := populateHeaders(headers, globals, req.Header, []string{}) + if globals != nil { + _ = populateHeaders(globals, nil, req.Header, globalsAlreadyPopulated) + } +} + +func populateHeaders(headers interface{}, globals interface{}, reqHeaders http.Header, skipFields []string) []string { + headerParamsStructType, headerParamsValType := dereferencePointers(reflect.TypeOf(headers), reflect.ValueOf(headers)) + + globalsAlreadyPopulated := []string{} + + for i := 0; i < headerParamsStructType.NumField(); i++ { + fieldType := headerParamsStructType.Field(i) + valType := headerParamsValType.Field(i) + + if contains(skipFields, fieldType.Name) { + continue + } + + if globals != nil { + var globalFound bool + fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, headerParamTagKey, globals) + if globalFound { + globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name) + } + } + + tag := parseParamTag(headerParamTagKey, fieldType, "simple", false) + if tag == nil { + continue + } + + value := serializeHeader(fieldType.Type, valType, tag.Explode) + if value != "" { + reqHeaders.Add(tag.ParamName, value) + } + } + + return globalsAlreadyPopulated +} + +func serializeHeader(objType reflect.Type, objValue reflect.Value, explode bool) string { + if isNil(objType, objValue) { + return "" + } + + if objType.Kind() == reflect.Pointer { + objType = objType.Elem() + objValue = objValue.Elem() + } + + switch objType.Kind() { + case reflect.Struct: + items := []string{} + + for i := 0; i < objType.NumField(); i++ { + fieldType := objType.Field(i) + valType := objValue.Field(i) + + if isNil(fieldType.Type, valType) { + continue + } + + if fieldType.Type.Kind() == reflect.Pointer { + valType = valType.Elem() + } + + tag := parseParamTag(headerParamTagKey, fieldType, "simple", false) + if tag == nil { + continue + } + + fieldName := tag.ParamName + + if fieldName == "" { + continue + } + + if explode { + items = append(items, fmt.Sprintf("%s=%s", fieldName, valToString(valType.Interface()))) + } else { + items = append(items, fieldName, valToString(valType.Interface())) + } + } + + return strings.Join(items, ",") + case reflect.Map: + // check if optionalnullable.OptionalNullable[T] + if nullableValue, ok := optionalnullable.AsOptionalNullable(objValue); ok { + // Handle optionalnullable.OptionalNullable[T] using GetUntyped method + if value, isSet := nullableValue.GetUntyped(); isSet && value != nil { + return valToString(value) + } + // If not set or explicitly null, return empty string + return "" + } + + items := []string{} + + iter := objValue.MapRange() + for iter.Next() { + if explode { + items = append(items, fmt.Sprintf("%s=%s", iter.Key().String(), valToString(iter.Value().Interface()))) + } else { + items = append(items, iter.Key().String(), valToString(iter.Value().Interface())) + } + } + + return strings.Join(items, ",") + case reflect.Slice, reflect.Array: + items := []string{} + + for i := 0; i < objValue.Len(); i++ { + items = append(items, valToString(objValue.Index(i).Interface())) + } + + return strings.Join(items, ",") + default: + return valToString(objValue.Interface()) + } +} diff --git a/internal/membershipclient/internal/utils/json.go b/internal/membershipclient/internal/utils/json.go new file mode 100644 index 00000000..98c4241b --- /dev/null +++ b/internal/membershipclient/internal/utils/json.go @@ -0,0 +1,920 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "math/big" + "reflect" + "strconv" + "strings" + "time" + "unsafe" + + "github.com/formancehq/fctl/internal/membershipclient/types" +) + +func MarshalJSON(v interface{}, tag reflect.StructTag, topLevel bool) ([]byte, error) { + typ, val := dereferencePointers(reflect.TypeOf(v), reflect.ValueOf(v)) + + switch { + case isModelType(typ): + if topLevel { + return json.Marshal(v) + } + + if isNil(typ, val) { + return []byte("null"), nil + } + + out := map[string]json.RawMessage{} + + for i := 0; i < typ.NumField(); i++ { + field := typ.Field(i) + fieldVal := val.Field(i) + + fieldName := field.Name + + omitEmpty := false + omitZero := false + jsonTag := field.Tag.Get("json") + if jsonTag != "" { + for _, tag := range strings.Split(jsonTag, ",") { + if tag == "omitempty" { + omitEmpty = true + } else if tag == "omitzero" { + omitZero = true + } else { + fieldName = tag + } + } + } + + if (omitEmpty || omitZero) && field.Tag.Get("const") == "" { + // Both omitempty and omitzero skip zero values (including nil) + if isNil(field.Type, fieldVal) { + continue + } + + if omitZero && fieldVal.IsZero() { + continue + } + + if omitEmpty && fieldVal.Kind() != reflect.Struct && fieldVal.IsZero() { + continue + } + + if omitEmpty && isEmptyContainer(field.Type, fieldVal) { + continue + } + } + + if !field.IsExported() && field.Tag.Get("const") == "" { + continue + } + + additionalProperties := field.Tag.Get("additionalProperties") + if fieldName == "-" && additionalProperties == "" { + continue + } + + if additionalProperties == "true" { + if isNil(field.Type, fieldVal) { + continue + } + fieldVal := trueReflectValue(fieldVal) + if fieldVal.Type().Kind() != reflect.Map { + return nil, fmt.Errorf("additionalProperties must be a map") + } + + for _, key := range fieldVal.MapKeys() { + r, err := marshalValue(fieldVal.MapIndex(key).Interface(), field.Tag) + if err != nil { + return nil, err + } + + out[key.String()] = r + } + + continue + } + + var fv interface{} + + if field.IsExported() { + fv = fieldVal.Interface() + } else { + pt := reflect.New(typ).Elem() + pt.Set(val) + + pf := pt.Field(i) + + fv = reflect.NewAt(pf.Type(), unsafe.Pointer(pf.UnsafeAddr())).Elem().Interface() + } + + r, err := marshalValue(fv, field.Tag) + if err != nil { + return nil, err + } + + out[fieldName] = r + } + + return json.Marshal(out) + default: + return marshalValue(v, tag) + } +} + +func UnmarshalJSON(b []byte, v interface{}, tag reflect.StructTag, topLevel bool, requiredFields []string) error { + if reflect.TypeOf(v).Kind() != reflect.Ptr { + return errors.New("v must be a pointer") + } + + typ, val := dereferencePointers(reflect.TypeOf(v), reflect.ValueOf(v)) + + switch { + case isModelType(typ): + if topLevel || bytes.Equal(b, []byte("null")) { + return json.Unmarshal(b, v) + } + + var unmarshaled map[string]json.RawMessage + + if err := json.Unmarshal(b, &unmarshaled); err != nil { + return err + } + + missingFields := []string{} + for _, requiredField := range requiredFields { + if _, ok := unmarshaled[requiredField]; !ok { + missingFields = append(missingFields, requiredField) + } + } + if len(missingFields) > 0 { + return fmt.Errorf("missing required fields: %s", strings.Join(missingFields, ", ")) + } + + var additionalPropertiesField *reflect.StructField + var additionalPropertiesValue *reflect.Value + + for i := 0; i < typ.NumField(); i++ { + field := typ.Field(i) + fieldVal := val.Field(i) + + fieldName := field.Name + + jsonTag := field.Tag.Get("json") + if jsonTag != "" { + for _, tag := range strings.Split(jsonTag, ",") { + if tag != "omitempty" && tag != "omitzero" { + fieldName = tag + } + } + } + + if field.Tag.Get("additionalProperties") == "true" { + additionalPropertiesField = &field + additionalPropertiesValue = &fieldVal + continue + } + + // If we receive a value for a const field ignore it but mark it as unmarshaled + if field.Tag.Get("const") != "" { + if r, ok := unmarshaled[fieldName]; ok { + val := string(r) + + if strings.HasPrefix(val, `"`) && strings.HasSuffix(val, `"`) { + var err error + val, err = strconv.Unquote(val) + if err != nil { + return fmt.Errorf("failed to unquote const field `%s` value `%s`: %w", fieldName, val, err) + } + } + constValue := field.Tag.Get("const") + if val != constValue { + return fmt.Errorf("const field `%s` does not match expected value `%s` got `%s`", fieldName, constValue, val) + } + + delete(unmarshaled, fieldName) + } + } else if !field.IsExported() { + continue + } + + value, ok := unmarshaled[fieldName] + if !ok { + defaultTag, defaultOk := field.Tag.Lookup("default") + if defaultOk { + value = handleDefaultConstValue(defaultTag, fieldVal.Interface(), field.Tag) + ok = true + } + } else { + delete(unmarshaled, fieldName) + } + + if ok { + if err := unmarshalValue(value, fieldVal, field.Tag); err != nil { + return err + } + } + } + + keys := make([]string, 0, len(unmarshaled)) + for k := range unmarshaled { + keys = append(keys, k) + } + + if len(keys) > 0 { + if additionalPropertiesField != nil && additionalPropertiesValue != nil { + typeOfMap := additionalPropertiesField.Type + if additionalPropertiesValue.Type().Kind() == reflect.Interface { + typeOfMap = reflect.TypeOf(map[string]interface{}{}) + } else if additionalPropertiesValue.Type().Kind() != reflect.Map { + return fmt.Errorf("additionalProperties must be a map") + } + + mapValue := reflect.MakeMap(typeOfMap) + + for key, value := range unmarshaled { + val := reflect.New(typeOfMap.Elem()) + + if err := unmarshalValue(value, val, additionalPropertiesField.Tag); err != nil { + return err + } + + if val.Elem().Type().String() == typeOfMap.Elem().String() { + mapValue.SetMapIndex(reflect.ValueOf(key), val.Elem()) + } else { + mapValue.SetMapIndex(reflect.ValueOf(key), trueReflectValue(val)) + } + + } + if additionalPropertiesValue.Type().Kind() == reflect.Interface { + additionalPropertiesValue.Set(mapValue) + } else { + additionalPropertiesValue.Set(mapValue) + } + } + } + default: + return unmarshalValue(b, reflect.ValueOf(v), tag) + } + + return nil +} + +func marshalValue(v interface{}, tag reflect.StructTag) (json.RawMessage, error) { + constTag := tag.Get("const") + if constTag != "" { + return handleDefaultConstValue(constTag, v, tag), nil + } + + if isNil(reflect.TypeOf(v), reflect.ValueOf(v)) { + defaultTag, ok := tag.Lookup("default") + if ok { + return handleDefaultConstValue(defaultTag, v, tag), nil + } + + return []byte("null"), nil + } + + typ, val := dereferencePointers(reflect.TypeOf(v), reflect.ValueOf(v)) + switch typ.Kind() { + case reflect.Int64: + format := tag.Get("integer") + if format == "string" { + b := val.Interface().(int64) + return []byte(fmt.Sprintf(`"%d"`, b)), nil + } + case reflect.Float64: + format := tag.Get("number") + if format == "string" { + b := val.Interface().(float64) + return []byte(fmt.Sprintf(`"%g"`, b)), nil + } + case reflect.Map: + if isNil(typ, val) { + return []byte("null"), nil + } + + // Check if the map implements json.Marshaler (like optionalnullable.OptionalNullable[T]) + if marshaler, ok := val.Interface().(json.Marshaler); ok { + return marshaler.MarshalJSON() + } + + out := map[string]json.RawMessage{} + + for _, key := range val.MapKeys() { + itemVal := val.MapIndex(key) + + if isNil(itemVal.Type(), itemVal) { + out[key.String()] = []byte("null") + continue + } + + r, err := marshalValue(itemVal.Interface(), tag) + if err != nil { + return nil, err + } + + out[key.String()] = r + } + + return json.Marshal(out) + case reflect.Slice, reflect.Array: + if isNil(typ, val) { + return []byte("null"), nil + } + + out := []json.RawMessage{} + + for i := 0; i < val.Len(); i++ { + itemVal := val.Index(i) + + if isNil(itemVal.Type(), itemVal) { + out = append(out, []byte("null")) + continue + } + + r, err := marshalValue(itemVal.Interface(), tag) + if err != nil { + return nil, err + } + + out = append(out, r) + } + + return json.Marshal(out) + case reflect.Struct: + switch typ { + case reflect.TypeOf(time.Time{}): + return []byte(fmt.Sprintf(`"%s"`, val.Interface().(time.Time).Format(time.RFC3339Nano))), nil + case reflect.TypeOf(big.Int{}): + format := tag.Get("bigint") + if format == "string" { + b := val.Interface().(big.Int) + return []byte(fmt.Sprintf(`"%s"`, (&b).String())), nil + } + } + } + + return json.Marshal(v) +} + +func handleDefaultConstValue(tagValue string, val interface{}, tag reflect.StructTag) json.RawMessage { + if tagValue == "null" { + return []byte("null") + } + + typ := dereferenceTypePointer(reflect.TypeOf(val)) + switch typ { + case reflect.TypeOf(time.Time{}): + return []byte(fmt.Sprintf(`"%s"`, tagValue)) + case reflect.TypeOf(big.Int{}): + bigIntTag := tag.Get("bigint") + if bigIntTag == "string" { + return []byte(fmt.Sprintf(`"%s"`, tagValue)) + } + case reflect.TypeOf(int64(0)): + format := tag.Get("integer") + if format == "string" { + return []byte(fmt.Sprintf(`"%s"`, tagValue)) + } + case reflect.TypeOf(float64(0)): + format := tag.Get("number") + if format == "string" { + return []byte(fmt.Sprintf(`"%s"`, tagValue)) + } + case reflect.TypeOf(types.Date{}): + return []byte(fmt.Sprintf(`"%s"`, tagValue)) + default: + if typ.Kind() == reflect.String { + return []byte(fmt.Sprintf("%q", tagValue)) + } + } + + return []byte(tagValue) +} + +func unmarshalValue(value json.RawMessage, v reflect.Value, tag reflect.StructTag) error { + if bytes.Equal(value, []byte("null")) { + if v.CanAddr() { + return json.Unmarshal(value, v.Addr().Interface()) + } else { + return json.Unmarshal(value, v.Interface()) + } + } + + typ := dereferenceTypePointer(v.Type()) + + switch typ.Kind() { + case reflect.Int64: + var b int64 + + format := tag.Get("integer") + if format == "string" { + var s string + if err := json.Unmarshal(value, &s); err != nil { + return err + } + + var err error + b, err = strconv.ParseInt(s, 10, 64) + if err != nil { + return fmt.Errorf("failed to parse string as int64: %w", err) + } + if v.Kind() == reflect.Ptr { + if v.IsNil() { + v.Set(reflect.New(typ)) + } + v = v.Elem() + } + + v.Set(reflect.ValueOf(b)) + return nil + } + case reflect.Float64: + var b float64 + + format := tag.Get("number") + if format == "string" { + var s string + if err := json.Unmarshal(value, &s); err != nil { + return err + } + + var err error + b, err = strconv.ParseFloat(s, 64) + if err != nil { + return fmt.Errorf("failed to parse string as float64: %w", err) + } + + if v.Kind() == reflect.Ptr { + if v.IsNil() { + v.Set(reflect.New(typ)) + } + v = v.Elem() + } + + v.Set(reflect.ValueOf(b)) + return nil + } + case reflect.Map: + if bytes.Equal(value, []byte("null")) || !isComplexValueType(dereferenceTypePointer(typ.Elem())) { + if v.CanAddr() { + return json.Unmarshal(value, v.Addr().Interface()) + } else { + return json.Unmarshal(value, v.Interface()) + } + } + + var unmarshaled map[string]json.RawMessage + + if err := json.Unmarshal(value, &unmarshaled); err != nil { + return err + } + + m := reflect.MakeMap(typ) + + for k, value := range unmarshaled { + itemVal := reflect.New(typ.Elem()) + + if err := unmarshalValue(value, itemVal, tag); err != nil { + return err + } + + m.SetMapIndex(reflect.ValueOf(k), itemVal.Elem()) + } + + v.Set(m) + return nil + case reflect.Slice, reflect.Array: + var unmarshaled []json.RawMessage + + if err := json.Unmarshal(value, &unmarshaled); err != nil { + return err + } + + arrVal := reflect.MakeSlice(typ, len(unmarshaled), len(unmarshaled)) + + for index, value := range unmarshaled { + itemVal := reflect.New(typ.Elem()) + + if err := unmarshalValue(value, itemVal, tag); err != nil { + return err + } + + arrVal.Index(index).Set(itemVal.Elem()) + } + + if v.Kind() == reflect.Pointer { + if v.IsNil() { + v.Set(reflect.New(typ)) + } + v = v.Elem() + } + + v.Set(arrVal) + return nil + case reflect.Struct: + switch typ { + case reflect.TypeOf(time.Time{}): + var s string + if err := json.Unmarshal(value, &s); err != nil { + return err + } + + t, err := time.Parse(time.RFC3339Nano, s) + if err != nil { + return fmt.Errorf("failed to parse string as time.Time: %w", err) + } + + if v.Kind() == reflect.Ptr { + if v.IsNil() { + v.Set(reflect.New(typ)) + } + v = v.Elem() + } + + v.Set(reflect.ValueOf(t)) + return nil + case reflect.TypeOf(big.Int{}): + var b *big.Int + + format := tag.Get("bigint") + if format == "string" { + var s string + if err := json.Unmarshal(value, &s); err != nil { + return err + } + + var ok bool + b, ok = new(big.Int).SetString(s, 10) + if !ok { + return fmt.Errorf("failed to parse string as big.Int") + } + } else { + if err := json.Unmarshal(value, &b); err != nil { + return err + } + } + + if v.Kind() == reflect.Ptr && v.Elem().Kind() == reflect.Ptr { + v = v.Elem() + } + + v.Set(reflect.ValueOf(b)) + return nil + case reflect.TypeOf(types.Date{}): + var s string + + if err := json.Unmarshal(value, &s); err != nil { + return err + } + + d, err := types.DateFromString(s) + if err != nil { + return fmt.Errorf("failed to parse string as types.Date: %w", err) + } + + if v.Kind() == reflect.Ptr { + if v.IsNil() { + v.Set(reflect.New(typ)) + } + v = v.Elem() + } + + v.Set(reflect.ValueOf(d)) + return nil + } + } + + var val interface{} + + if v.CanAddr() { + val = v.Addr().Interface() + } else { + val = v.Interface() + } + + return json.Unmarshal(value, val) +} + +func dereferencePointers(typ reflect.Type, val reflect.Value) (reflect.Type, reflect.Value) { + if typ.Kind() == reflect.Ptr { + typ = typ.Elem() + val = val.Elem() + } else { + return typ, val + } + + return dereferencePointers(typ, val) +} + +func dereferenceTypePointer(typ reflect.Type) reflect.Type { + if typ.Kind() == reflect.Ptr { + typ = typ.Elem() + } else { + return typ + } + + return dereferenceTypePointer(typ) +} + +func isComplexValueType(typ reflect.Type) bool { + switch typ.Kind() { + case reflect.Struct: + switch typ { + case reflect.TypeOf(time.Time{}): + fallthrough + case reflect.TypeOf(big.Int{}): + fallthrough + case reflect.TypeOf(types.Date{}): + return true + } + } + + return false +} + +func isModelType(typ reflect.Type) bool { + if isComplexValueType(typ) { + return false + } + + if typ.Kind() == reflect.Struct { + return true + } + + return false +} + +// CalculateJSONSize returns the byte size of the JSON representation of a value. +// This is used to determine which union type variant has the most data. +func CalculateJSONSize(v interface{}) int { + data, err := json.Marshal(v) + if err != nil { + return 0 + } + return len(data) +} + +// UnionCandidate represents a candidate type during union deserialization +type UnionCandidate struct { + FieldCount int + InexactCount int // Count of fields with unknown/unrecognized enum values + Size int + Type any // The union type enum value + Value any // The unmarshaled value +} + +// FieldCounts holds the result of counting fields in a value +type FieldCounts struct { + Total int // Total number of populated fields + Inexact int // Number of fields with unknown/unrecognized open enum values +} + +// CountFieldsWithInexact recursively counts fields and tracks inexact matches (unknown open enum values). +func CountFieldsWithInexact(v interface{}) FieldCounts { + if v == nil { + return FieldCounts{} + } + + typ := reflect.TypeOf(v) + val := reflect.ValueOf(v) + + // Dereference pointers + for typ.Kind() == reflect.Ptr { + if val.IsNil() { + return FieldCounts{} + } + typ = typ.Elem() + val = val.Elem() + } + + return countFieldsRecursive(typ, val) +} + +// PickBestCandidate selects the best union type candidate using a multi-stage filtering approach: +// 1. If multiple candidates, filter by field count (keep only those with max field count) +// 2. If still multiple, filter by inexact count (keep only those with min inexact count) +// 3. If still multiple, filter by JSON size (keep only those with max size) +// 4. Return the first remaining candidate +func PickBestCandidate(candidates []UnionCandidate) *UnionCandidate { + if len(candidates) == 0 { + return nil + } + + if len(candidates) == 1 { + return &candidates[0] + } + + // Filter by field count if we have multiple candidates + if len(candidates) > 1 { + maxFieldCount := -1 + for i := range candidates { + fieldCounts := CountFieldsWithInexact(candidates[i].Value) + candidates[i].FieldCount = fieldCounts.Total + candidates[i].InexactCount = fieldCounts.Inexact + if candidates[i].FieldCount > maxFieldCount { + maxFieldCount = candidates[i].FieldCount + } + } + + // Keep only candidates with maximum field count + filtered := make([]UnionCandidate, 0, len(candidates)) + for _, c := range candidates { + if c.FieldCount == maxFieldCount { + filtered = append(filtered, c) + } + } + candidates = filtered + } + + if len(candidates) == 1 { + return &candidates[0] + } + + // Filter by inexact count if we still have multiple candidates + // Prefer candidates with fewer unknown/unrecognized enum values + if len(candidates) > 1 { + minInexactCount := int(^uint(0) >> 1) // max int + for _, c := range candidates { + if c.InexactCount < minInexactCount { + minInexactCount = c.InexactCount + } + } + + // Keep only candidates with minimum inexact count + filtered := make([]UnionCandidate, 0, len(candidates)) + for _, c := range candidates { + if c.InexactCount == minInexactCount { + filtered = append(filtered, c) + } + } + candidates = filtered + } + + if len(candidates) == 1 { + return &candidates[0] + } + + // Filter by JSON size if we still have multiple candidates + if len(candidates) > 1 { + maxSize := -1 + for i := range candidates { + candidates[i].Size = CalculateJSONSize(candidates[i].Value) + if candidates[i].Size > maxSize { + maxSize = candidates[i].Size + } + } + + // Keep only candidates with maximum size + filtered := make([]UnionCandidate, 0, len(candidates)) + for _, c := range candidates { + if c.Size == maxSize { + filtered = append(filtered, c) + } + } + candidates = filtered + } + + // Pick the first remaining candidate + return &candidates[0] +} + +func countFieldsRecursive(typ reflect.Type, val reflect.Value) FieldCounts { + counts := FieldCounts{} + + // Check if the value has an IsExact() method (for open enums) + // Try both the value and its pointer + if val.CanInterface() && val.CanAddr() { + ptrVal := val.Addr() + if method := ptrVal.MethodByName("IsExact"); method.IsValid() { + results := method.Call(nil) + if len(results) == 1 && results[0].Kind() == reflect.Bool { + isExact := results[0].Bool() + counts.Total = 1 + if !isExact { + counts.Inexact = 1 // Unknown enum value + } + return counts + } + } + } + + switch typ.Kind() { + case reflect.Struct: + // Handle special types + switch typ { + case reflect.TypeOf(time.Time{}): + if !val.Interface().(time.Time).IsZero() { + return FieldCounts{Total: 1} + } + return FieldCounts{} + case reflect.TypeOf(big.Int{}): + b := val.Interface().(big.Int) + if b.Sign() != 0 { + return FieldCounts{Total: 1} + } + return FieldCounts{} + case reflect.TypeOf(types.Date{}): + // Date is always counted if it exists + return FieldCounts{Total: 1} + } + + // For regular structs, count non-zero fields + for i := 0; i < typ.NumField(); i++ { + field := typ.Field(i) + fieldVal := val.Field(i) + + // Skip unexported fields and const fields + if !field.IsExported() || field.Tag.Get("const") != "" { + continue + } + + // Skip fields tagged with json:"-" + jsonTag := field.Tag.Get("json") + if jsonTag == "-" { + continue + } + + fieldTyp := field.Type + // Dereference pointer types for the field + for fieldTyp.Kind() == reflect.Ptr { + if fieldVal.IsNil() { + break + } + fieldTyp = fieldTyp.Elem() + fieldVal = fieldVal.Elem() + } + + if !isNil(field.Type, val.Field(i)) { + fieldCounts := countFieldsRecursive(fieldTyp, fieldVal) + counts.Total += fieldCounts.Total + counts.Inexact += fieldCounts.Inexact + } + } + + case reflect.Slice, reflect.Array: + if val.IsNil() || val.Len() == 0 { + return FieldCounts{} + } + // Count each array/slice element + for i := 0; i < val.Len(); i++ { + itemVal := val.Index(i) + itemTyp := itemVal.Type() + + // Dereference pointer types + for itemTyp.Kind() == reflect.Ptr { + if itemVal.IsNil() { + break + } + itemTyp = itemTyp.Elem() + itemVal = itemVal.Elem() + } + + if !isNil(itemTyp, itemVal) { + itemCounts := countFieldsRecursive(itemTyp, itemVal) + counts.Total += itemCounts.Total + counts.Inexact += itemCounts.Inexact + } + } + + case reflect.String: + if val.String() != "" { + counts.Total = 1 + } + + case reflect.Bool: + // Bools always count as a field (even if false) + counts.Total = 1 + + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + if val.Int() != 0 { + counts.Total = 1 + } + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + if val.Uint() != 0 { + counts.Total = 1 + } + + case reflect.Float32, reflect.Float64: + if val.Float() != 0 { + counts.Total = 1 + } + + default: + // For any other type, if it's not zero, count it as 1 + if !val.IsZero() { + counts.Total = 1 + } + } + + return counts +} diff --git a/internal/membershipclient/internal/utils/pathparams.go b/internal/membershipclient/internal/utils/pathparams.go new file mode 100644 index 00000000..501556ff --- /dev/null +++ b/internal/membershipclient/internal/utils/pathparams.go @@ -0,0 +1,179 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "context" + "fmt" + "math/big" + "net/url" + "reflect" + "strings" + "time" + + "github.com/formancehq/fctl/internal/membershipclient/optionalnullable" + "github.com/formancehq/fctl/internal/membershipclient/types" +) + +func GenerateURL(_ context.Context, serverURL, path string, pathParams interface{}, globals interface{}) (string, error) { + uri := strings.TrimSuffix(serverURL, "/") + path + + parsedParameters := map[string]string{} + + globalsAlreadyPopulated, err := populateParsedParameters(pathParams, globals, parsedParameters, []string{}) + if err != nil { + return "", err + } + + if globals != nil { + _, err = populateParsedParameters(globals, nil, parsedParameters, globalsAlreadyPopulated) + if err != nil { + return "", err + } + } + + // TODO should we handle the case where there are no matching path params? + return ReplaceParameters(uri, parsedParameters), nil +} + +func populateParsedParameters(pathParams interface{}, globals interface{}, parsedParameters map[string]string, skipFields []string) ([]string, error) { + pathParamsStructType, pathParamsValType := dereferencePointers(reflect.TypeOf(pathParams), reflect.ValueOf(pathParams)) + + globalsAlreadyPopulated := []string{} + + for i := 0; i < pathParamsStructType.NumField(); i++ { + fieldType := pathParamsStructType.Field(i) + valType := pathParamsValType.Field(i) + + if contains(skipFields, fieldType.Name) { + continue + } + + requestTag := getRequestTag(fieldType) + if requestTag != nil { + continue + } + + ppTag := parseParamTag(pathParamTagKey, fieldType, "simple", false) + if ppTag == nil { + continue + } + + if globals != nil { + var globalFound bool + fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, pathParamTagKey, globals) + if globalFound { + globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name) + } + } + + if ppTag.Serialization != "" { + vals, err := populateSerializedParams(ppTag, fieldType.Type, valType) + if err != nil { + return nil, err + } + for k, v := range vals { + parsedParameters[k] = url.PathEscape(v) + } + } else { + // TODO: support other styles + switch ppTag.Style { + case "simple": + simpleParams := getSimplePathParams(ppTag.ParamName, fieldType.Type, valType, ppTag.Explode) + for k, v := range simpleParams { + parsedParameters[k] = v + } + } + } + } + + return globalsAlreadyPopulated, nil +} + +func getSimplePathParams(parentName string, objType reflect.Type, objValue reflect.Value, explode bool) map[string]string { + pathParams := make(map[string]string) + + if isNil(objType, objValue) { + return nil + } + + if objType.Kind() == reflect.Ptr { + objType = objType.Elem() + objValue = objValue.Elem() + } + + switch objType.Kind() { + case reflect.Array, reflect.Slice: + if objValue.Len() == 0 { + return nil + } + var ppVals []string + for i := 0; i < objValue.Len(); i++ { + ppVals = append(ppVals, valToString(objValue.Index(i).Interface())) + } + pathParams[parentName] = strings.Join(ppVals, ",") + case reflect.Map: + // check if optionalnullable.OptionalNullable[T] + if nullableValue, ok := optionalnullable.AsOptionalNullable(objValue); ok { + // Handle optionalnullable.OptionalNullable[T] using GetUntyped method + if value, isSet := nullableValue.GetUntyped(); isSet && value != nil { + pathParams[parentName] = valToString(value) + } + // If not set or explicitly null, return nil (skip parameter) + return pathParams + } + + if objValue.Len() == 0 { + return nil + } + var ppVals []string + objMap := objValue.MapRange() + for objMap.Next() { + if explode { + ppVals = append(ppVals, fmt.Sprintf("%s=%s", objMap.Key().String(), valToString(objMap.Value().Interface()))) + } else { + ppVals = append(ppVals, fmt.Sprintf("%s,%s", objMap.Key().String(), valToString(objMap.Value().Interface()))) + } + } + pathParams[parentName] = strings.Join(ppVals, ",") + case reflect.Struct: + switch objValue.Interface().(type) { + case time.Time: + pathParams[parentName] = valToString(objValue.Interface()) + case types.Date: + pathParams[parentName] = valToString(objValue.Interface()) + case big.Int: + pathParams[parentName] = valToString(objValue.Interface()) + default: + var ppVals []string + for i := 0; i < objType.NumField(); i++ { + fieldType := objType.Field(i) + valType := objValue.Field(i) + + ppTag := parseParamTag(pathParamTagKey, fieldType, "simple", explode) + if ppTag == nil { + continue + } + + if isNil(fieldType.Type, valType) { + continue + } + + if fieldType.Type.Kind() == reflect.Pointer { + valType = valType.Elem() + } + + if explode { + ppVals = append(ppVals, fmt.Sprintf("%s=%s", ppTag.ParamName, valToString(valType.Interface()))) + } else { + ppVals = append(ppVals, fmt.Sprintf("%s,%s", ppTag.ParamName, valToString(valType.Interface()))) + } + } + pathParams[parentName] = strings.Join(ppVals, ",") + } + default: + pathParams[parentName] = valToString(objValue.Interface()) + } + + return pathParams +} diff --git a/internal/membershipclient/internal/utils/queryparams.go b/internal/membershipclient/internal/utils/queryparams.go new file mode 100644 index 00000000..40a0ddf5 --- /dev/null +++ b/internal/membershipclient/internal/utils/queryparams.go @@ -0,0 +1,290 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "context" + "encoding/json" + "fmt" + "math/big" + "net/http" + "net/url" + "reflect" + "time" + + "github.com/formancehq/fctl/internal/membershipclient/optionalnullable" + "github.com/formancehq/fctl/internal/membershipclient/types" +) + +func PopulateQueryParams(_ context.Context, req *http.Request, queryParams interface{}, globals interface{}) error { + // Query parameters may already be present from overriding URL + if req.URL.RawQuery != "" { + return nil + } + + values := url.Values{} + + globalsAlreadyPopulated, err := populateQueryParams(queryParams, globals, values, []string{}) + if err != nil { + return err + } + + if globals != nil { + _, err = populateQueryParams(globals, nil, values, globalsAlreadyPopulated) + if err != nil { + return err + } + } + + req.URL.RawQuery = values.Encode() + + return nil +} + +func populateQueryParams(queryParams interface{}, globals interface{}, values url.Values, skipFields []string) ([]string, error) { + queryParamsVal := reflect.ValueOf(queryParams) + if queryParamsVal.Kind() == reflect.Pointer && queryParamsVal.IsNil() { + return nil, nil + } + queryParamsStructType, queryParamsValType := dereferencePointers(reflect.TypeOf(queryParams), queryParamsVal) + + globalsAlreadyPopulated := []string{} + for i := 0; i < queryParamsStructType.NumField(); i++ { + fieldType := queryParamsStructType.Field(i) + valType := queryParamsValType.Field(i) + + if contains(skipFields, fieldType.Name) { + continue + } + + requestTag := getRequestTag(fieldType) + if requestTag != nil { + continue + } + + qpTag := parseQueryParamTag(fieldType) + if qpTag == nil { + continue + } + + constValue := parseConstTag(fieldType) + if constValue != nil { + values.Add(qpTag.ParamName, *constValue) + continue + } + + defaultValue := parseDefaultTag(fieldType) + + if globals != nil { + var globalFound bool + fieldType, valType, globalFound = populateFromGlobals(fieldType, valType, queryParamTagKey, globals) + if globalFound { + globalsAlreadyPopulated = append(globalsAlreadyPopulated, fieldType.Name) + } + } + + if qpTag.Serialization != "" { + vals, err := populateSerializedParams(qpTag, fieldType.Type, valType) + if err != nil { + return nil, err + } + for k, v := range vals { + values.Add(k, v) + } + } else { + switch qpTag.Style { + case "deepObject": + vals := populateDeepObjectParams(qpTag, fieldType.Type, valType) + for k, v := range vals { + for _, vv := range v { + values.Add(k, vv) + } + } + case "form": + vals := populateFormParams(qpTag, fieldType.Type, valType, ",", defaultValue) + for k, v := range vals { + for _, vv := range v { + values.Add(k, vv) + } + } + case "pipeDelimited": + vals := populateFormParams(qpTag, fieldType.Type, valType, "|", defaultValue) + for k, v := range vals { + for _, vv := range v { + values.Add(k, vv) + } + } + default: + return nil, fmt.Errorf("unsupported style: %s", qpTag.Style) + } + } + } + + return globalsAlreadyPopulated, nil +} + +func populateSerializedParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) (map[string]string, error) { + if isNil(objType, objValue) { + return nil, nil + } + + if objType.Kind() == reflect.Pointer { + objValue = objValue.Elem() + } + + values := map[string]string{} + + switch tag.Serialization { + case "json": + data, err := json.Marshal(objValue.Interface()) + if err != nil { + return nil, fmt.Errorf("error marshaling json: %v", err) + } + values[tag.ParamName] = string(data) + } + + return values, nil +} + +func populateDeepObjectParams(tag *paramTag, objType reflect.Type, objValue reflect.Value) url.Values { + values := url.Values{} + + if isNil(objType, objValue) { + return values + } + + if objValue.Kind() == reflect.Pointer { + objValue = objValue.Elem() + } + + switch objValue.Kind() { + case reflect.Map: + // check if optionalnullable.OptionalNullable[T] + if nullableValue, ok := optionalnullable.AsOptionalNullable(objValue); ok { + // Handle optionalnullable.OptionalNullable[T] using GetUntyped method + if value, isSet := nullableValue.GetUntyped(); isSet && value != nil { + values.Add(tag.ParamName, valToString(value)) + } + // If not set or explicitly null, skip adding to values + return values + } + + populateDeepObjectParamsMap(values, tag.ParamName, objValue) + case reflect.Struct: + populateDeepObjectParamsStruct(values, tag.ParamName, objValue) + } + + return values +} + +func populateDeepObjectParamsArray(qsValues url.Values, priorScope string, value reflect.Value) { + if value.Kind() != reflect.Array && value.Kind() != reflect.Slice { + return + } + + for i := 0; i < value.Len(); i++ { + qsValues.Add(priorScope, valToString(value.Index(i).Interface())) + } +} + +func populateDeepObjectParamsMap(qsValues url.Values, priorScope string, mapValue reflect.Value) { + if mapValue.Kind() != reflect.Map { + return + } + + iter := mapValue.MapRange() + + for iter.Next() { + scope := priorScope + "[" + iter.Key().String() + "]" + iterValue := iter.Value() + + switch iterValue.Kind() { + case reflect.Array, reflect.Slice: + populateDeepObjectParamsArray(qsValues, scope, iterValue) + case reflect.Map: + populateDeepObjectParamsMap(qsValues, scope, iterValue) + default: + qsValues.Add(scope, valToString(iterValue.Interface())) + } + } +} + +func populateDeepObjectParamsStruct(qsValues url.Values, priorScope string, structValue reflect.Value) { + if structValue.Kind() != reflect.Struct { + return + } + + structType := structValue.Type() + + for i := 0; i < structType.NumField(); i++ { + field := structType.Field(i) + fieldValue := structValue.Field(i) + + if isNil(field.Type, fieldValue) { + continue + } + + if fieldValue.Kind() == reflect.Pointer { + fieldValue = fieldValue.Elem() + } + + qpTag := parseQueryParamTag(field) + + if qpTag == nil { + continue + } + + scope := priorScope + + if !qpTag.Inline { + scope = priorScope + "[" + qpTag.ParamName + "]" + } + + switch fieldValue.Kind() { + case reflect.Array, reflect.Slice: + populateDeepObjectParamsArray(qsValues, scope, fieldValue) + case reflect.Map: + populateDeepObjectParamsMap(qsValues, scope, fieldValue) + case reflect.Struct: + switch fieldValue.Type() { + case reflect.TypeOf(big.Int{}), reflect.TypeOf(time.Time{}), reflect.TypeOf(types.Date{}): + qsValues.Add(scope, valToString(fieldValue.Interface())) + + continue + } + + populateDeepObjectParamsStruct(qsValues, scope, fieldValue) + default: + qsValues.Add(scope, valToString(fieldValue.Interface())) + } + } +} + +func populateFormParams(tag *paramTag, objType reflect.Type, objValue reflect.Value, delimiter string, defaultValue *string) url.Values { + return populateForm(tag.ParamName, tag.Explode, objType, objValue, delimiter, defaultValue, func(fieldType reflect.StructField) string { + qpTag := parseQueryParamTag(fieldType) + if qpTag == nil { + return "" + } + + return qpTag.ParamName + }) +} + +type paramTag struct { + Style string + Explode bool + ParamName string + Serialization string + + // Inline is a special case for union/oneOf. When a wrapper struct type is + // used, each union/oneOf value field should be inlined (e.g. not appended + // in deepObject style with the name) as if the value was directly on the + // parent struct field. Without this annotation, the value would not be + // encoded by downstream logic that requires the struct field tag. + Inline bool +} + +func parseQueryParamTag(field reflect.StructField) *paramTag { + return parseParamTag(queryParamTagKey, field, "form", true) +} diff --git a/internal/membershipclient/internal/utils/requestbody.go b/internal/membershipclient/internal/utils/requestbody.go new file mode 100644 index 00000000..60e32600 --- /dev/null +++ b/internal/membershipclient/internal/utils/requestbody.go @@ -0,0 +1,458 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "bytes" + "context" + "fmt" + "io" + "mime" + "mime/multipart" + "net/textproto" + "net/url" + "path/filepath" + "reflect" + "regexp" + + "github.com/formancehq/fctl/internal/membershipclient/optionalnullable" +) + +const ( + requestTagKey = "request" + multipartFormTagKey = "multipartForm" + formTagKey = "form" +) + +var ( + jsonEncodingRegex = regexp.MustCompile(`(application|text)\/.*?\+*json.*`) + multipartEncodingRegex = regexp.MustCompile(`multipart\/.*`) + urlEncodedEncodingRegex = regexp.MustCompile(`application\/x-www-form-urlencoded.*`) +) + +func SerializeRequestBody(_ context.Context, request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) { + bodyReader, contentType, err := serializeRequestBody(request, nullable, optional, requestFieldName, serializationMethod, tag) + if err != nil { + return nil, "", fmt.Errorf("error serializing request body: %w", err) + } + + if bodyReader == nil && !optional { + return nil, "", fmt.Errorf("request body is required") + } + + return bodyReader, contentType, nil +} + +func serializeRequestBody(request interface{}, nullable, optional bool, requestFieldName, serializationMethod, tag string) (io.Reader, string, error) { + requestStructType := reflect.TypeOf(request) + requestValType := reflect.ValueOf(request) + + if isNil(requestStructType, requestValType) { + if !nullable && optional { + return nil, "", nil + } + + return serializeContentType(requestFieldName, SerializationMethodToContentType[serializationMethod], requestValType, tag) + } + + if requestStructType.Kind() == reflect.Pointer { + requestStructType = requestStructType.Elem() + requestValType = requestValType.Elem() + } + + if requestStructType.Kind() != reflect.Struct { + return serializeContentType(requestFieldName, SerializationMethodToContentType[serializationMethod], requestValType, tag) + } + + requestField, ok := requestStructType.FieldByName(requestFieldName) + + if ok { + tag := getRequestTag(requestField) + if tag != nil { + // request object (non-flattened) + requestVal := requestValType.FieldByName(requestFieldName) + val := reflect.ValueOf(requestVal.Interface()) + if isNil(requestField.Type, requestVal) { + if !nullable && optional { + return nil, "", nil + } + + return serializeContentType(requestFieldName, tag.MediaType, val, string(requestField.Tag)) + } + + return serializeContentType(requestFieldName, tag.MediaType, val, string(requestField.Tag)) + } + } + + // flattened request object + return serializeContentType(requestFieldName, SerializationMethodToContentType[serializationMethod], reflect.ValueOf(request), tag) +} + +func serializeContentType(fieldName string, mediaType string, val reflect.Value, tag string) (io.Reader, string, error) { + buf := &bytes.Buffer{} + + if isNil(val.Type(), val) { + // TODO: what does a null mean for other content types? Just returning an empty buffer for now + if jsonEncodingRegex.MatchString(mediaType) { + if _, err := buf.Write([]byte("null")); err != nil { + return nil, "", err + } + } + + return buf, mediaType, nil + } + + switch { + case jsonEncodingRegex.MatchString(mediaType): + data, err := MarshalJSON(val.Interface(), reflect.StructTag(tag), true) + if err != nil { + return nil, "", err + } + + if _, err := buf.Write(data); err != nil { + return nil, "", err + } + case multipartEncodingRegex.MatchString(mediaType): + var err error + mediaType, err = encodeMultipartFormData(buf, val.Interface()) + if err != nil { + return nil, "", err + } + case urlEncodedEncodingRegex.MatchString(mediaType): + if err := encodeFormData(fieldName, buf, val.Interface()); err != nil { + return nil, "", err + } + case val.Type().Implements(reflect.TypeOf((*io.Reader)(nil)).Elem()): + return val.Interface().(io.Reader), mediaType, nil + default: + val = reflect.Indirect(val) + + switch { + case val.Type().Kind() == reflect.String: + if _, err := buf.WriteString(valToString(val.Interface())); err != nil { + return nil, "", err + } + case reflect.TypeOf(val.Interface()) == reflect.TypeOf([]byte(nil)): + if _, err := buf.Write(val.Interface().([]byte)); err != nil { + return nil, "", err + } + default: + return nil, "", fmt.Errorf("invalid request body type %s for mediaType %s", val.Type(), mediaType) + } + } + + return buf, mediaType, nil +} + +func encodeMultipartFormData(w io.Writer, data interface{}) (string, error) { + requestStructType := reflect.TypeOf(data) + requestValType := reflect.ValueOf(data) + + if requestStructType.Kind() == reflect.Pointer { + requestStructType = requestStructType.Elem() + requestValType = requestValType.Elem() + } + + writer := multipart.NewWriter(w) + + for i := 0; i < requestStructType.NumField(); i++ { + field := requestStructType.Field(i) + fieldType := field.Type + valType := requestValType.Field(i) + + if isNil(fieldType, valType) { + continue + } + + if fieldType.Kind() == reflect.Pointer { + fieldType = fieldType.Elem() + valType = valType.Elem() + } + + tag := parseMultipartFormTag(field) + if tag.File { + switch fieldType.Kind() { + case reflect.Slice, reflect.Array: + for i := 0; i < valType.Len(); i++ { + arrayVal := valType.Index(i) + + if err := encodeMultipartFormDataFile(writer, tag.Name+"[]", arrayVal.Type(), arrayVal); err != nil { + writer.Close() + return "", err + } + } + default: + if err := encodeMultipartFormDataFile(writer, tag.Name, fieldType, valType); err != nil { + writer.Close() + return "", err + } + } + } else if tag.JSON { + jw, err := writer.CreateFormField(tag.Name) + if err != nil { + writer.Close() + return "", err + } + d, err := MarshalJSON(valType.Interface(), field.Tag, true) + if err != nil { + writer.Close() + return "", err + } + if _, err := jw.Write(d); err != nil { + writer.Close() + return "", err + } + } else { + switch fieldType.Kind() { + case reflect.Slice, reflect.Array: + values := parseDelimitedArray(true, valType, ",") + for _, v := range values { + if err := writer.WriteField(tag.Name+"[]", v); err != nil { + writer.Close() + return "", err + } + } + default: + if err := writer.WriteField(tag.Name, valToString(valType.Interface())); err != nil { + writer.Close() + return "", err + } + } + } + } + + if err := writer.Close(); err != nil { + return "", err + } + + return writer.FormDataContentType(), nil +} + +func encodeMultipartFormDataFile(w *multipart.Writer, fieldName string, fieldType reflect.Type, valType reflect.Value) error { + if fieldType.Kind() != reflect.Struct { + return fmt.Errorf("invalid type %s for multipart/form-data file", valType.Type()) + } + + var fileName string + var reader io.Reader + + for i := 0; i < fieldType.NumField(); i++ { + field := fieldType.Field(i) + val := valType.Field(i) + + tag := parseMultipartFormTag(field) + if !tag.Content && tag.Name == "" { + continue + } + + if tag.Content && val.CanInterface() { + if reflect.TypeOf(val.Interface()) == reflect.TypeOf([]byte(nil)) { + reader = bytes.NewReader(val.Interface().([]byte)) + } else if reflect.TypeOf(val.Interface()).Implements(reflect.TypeOf((*io.Reader)(nil)).Elem()) { + reader = val.Interface().(io.Reader) + } + } else { + fileName = val.String() + } + } + + if fileName == "" || reader == nil { + return fmt.Errorf("invalid multipart/form-data file") + } + + // Detect content type based on file extension + contentType := mime.TypeByExtension(filepath.Ext(fileName)) + if contentType == "" { + contentType = "application/octet-stream" + } + + // Create multipart header with proper content type + h := make(textproto.MIMEHeader) + h.Set("Content-Disposition", fmt.Sprintf(`form-data; name="%s"; filename="%s"`, fieldName, fileName)) + h.Set("Content-Type", contentType) + + fw, err := w.CreatePart(h) + if err != nil { + return err + } + if _, err := io.Copy(fw, reader); err != nil { + return err + } + + // Reset seek position to 0 if the reader supports seeking + if seeker, ok := reader.(io.Seeker); ok { + _, _ = seeker.Seek(0, io.SeekStart) + } + + return nil +} + +func encodeFormData(fieldName string, w io.Writer, data interface{}) error { + requestType := reflect.TypeOf(data) + requestValType := reflect.ValueOf(data) + + if requestType.Kind() == reflect.Pointer { + requestType = requestType.Elem() + requestValType = requestValType.Elem() + } + + dataValues := url.Values{} + + switch requestType.Kind() { + case reflect.Struct: + for i := 0; i < requestType.NumField(); i++ { + field := requestType.Field(i) + fieldType := field.Type + valType := requestValType.Field(i) + + if isNil(fieldType, valType) { + continue + } + + if fieldType.Kind() == reflect.Pointer { + fieldType = fieldType.Elem() + valType = valType.Elem() + } + + tag := parseFormTag(field) + if tag.JSON { + data, err := MarshalJSON(valType.Interface(), field.Tag, true) + if err != nil { + return err + } + dataValues.Set(tag.Name, string(data)) + } else { + switch tag.Style { + // TODO: support other styles + case "form": + values := populateForm(tag.Name, tag.Explode, fieldType, valType, ",", nil, func(sf reflect.StructField) string { + tag := parseFormTag(field) + if tag == nil { + return "" + } + + return tag.Name + }) + for k, v := range values { + for _, vv := range v { + dataValues.Add(k, vv) + } + } + } + } + } + case reflect.Map: + // check if optionalnullable.OptionalNullable[T] + if nullableValue, ok := optionalnullable.AsOptionalNullable(requestValType); ok { + // Handle optionalnullable.OptionalNullable[T] using GetUntyped method + if value, isSet := nullableValue.GetUntyped(); isSet && value != nil { + dataValues.Set(fieldName, valToString(value)) + } + // If not set or explicitly null, skip adding to form + break + } + + // Handle regular map + for _, k := range requestValType.MapKeys() { + v := requestValType.MapIndex(k) + dataValues.Set(fmt.Sprintf("%v", k.Interface()), valToString(v.Interface())) + } + case reflect.Slice, reflect.Array: + for i := 0; i < requestValType.Len(); i++ { + v := requestValType.Index(i) + dataValues.Set(fieldName, valToString(v.Interface())) + } + } + + if _, err := w.Write([]byte(dataValues.Encode())); err != nil { + return err + } + + return nil +} + +type requestTag struct { + MediaType string +} + +func getRequestTag(field reflect.StructField) *requestTag { + // example `request:"mediaType=multipart/form-data"` + values := parseStructTag(requestTagKey, field) + if values == nil { + return nil + } + + tag := &requestTag{ + MediaType: "application/octet-stream", + } + + for k, v := range values { + switch k { + case "mediaType": + tag.MediaType = v + } + } + + return tag +} + +type multipartFormTag struct { + File bool + Content bool + JSON bool + Name string +} + +func parseMultipartFormTag(field reflect.StructField) *multipartFormTag { + // example `multipartForm:"name=file"` + values := parseStructTag(multipartFormTagKey, field) + + tag := &multipartFormTag{} + + for k, v := range values { + switch k { + case "file": + tag.File = v == "true" + case "content": + tag.Content = v == "true" + case "name": + tag.Name = v + case "json": + tag.JSON = v == "true" + } + } + + return tag +} + +type formTag struct { + Name string + JSON bool + Style string + Explode bool +} + +func parseFormTag(field reflect.StructField) *formTag { + // example `form:"name=propName,style=spaceDelimited,explode"` + values := parseStructTag(formTagKey, field) + + tag := &formTag{ + Style: "form", + Explode: true, + } + + for k, v := range values { + switch k { + case "name": + tag.Name = v + case "json": + tag.JSON = v == "true" + case "style": + tag.Style = v + case "explode": + tag.Explode = v == "true" + } + } + + return tag +} diff --git a/internal/membershipclient/internal/utils/retries.go b/internal/membershipclient/internal/utils/retries.go new file mode 100644 index 00000000..89f9f88d --- /dev/null +++ b/internal/membershipclient/internal/utils/retries.go @@ -0,0 +1,270 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "context" + "errors" + "fmt" + "github.com/formancehq/fctl/internal/membershipclient/retry" + "io" + "math" + "math/rand" + "net/http" + "net/url" + "slices" + "strconv" + "strings" + "time" +) + +// Deprecated: Use retry.BackoffStrategy instead. +type BackoffStrategy = retry.BackoffStrategy + +// Deprecated: Use retry.Config instead. +type RetryConfig = retry.Config + +type Retries struct { + Config *retry.Config + StatusCodes []string +} + +var ( + // IETF RFC 7231 4.2 safe and idempotent HTTP methods for connection retries + idempotentHTTPMethods = []string{ + http.MethodDelete, + http.MethodGet, + http.MethodHead, + http.MethodOptions, + http.MethodPut, + } +) + +func Retry(ctx context.Context, r Retries, operation func() (*http.Response, error)) (*http.Response, error) { + switch r.Config.Strategy { + case "backoff": + if r.Config.Backoff == nil { + return operation() + } + + var resp *http.Response + + err := retryWithBackoff(ctx, r.Config.Backoff, func() error { + if resp != nil { + resp.Body.Close() + } + + select { + case <-ctx.Done(): + return retry.Permanent(ctx.Err()) + default: + } + + res, err := operation() + if err != nil { + if !r.Config.RetryConnectionErrors { + return retry.Permanent(err) + } + + var httpMethod string + + // Use http.Request method if available + if res != nil && res.Request != nil { + httpMethod = res.Request.Method + } + + isIdempotentHTTPMethod := slices.Contains(idempotentHTTPMethods, httpMethod) + urlError := new(url.Error) + + if errors.As(err, &urlError) { + if urlError.Temporary() || urlError.Timeout() { + return err + } + + // In certain error cases, the http.Request may not have + // been populated, so use url.Error.Op which only has its + // first character capitalized from the original request + // HTTP method. + if httpMethod == "" { + httpMethod = strings.ToUpper(urlError.Op) + } + + isIdempotentHTTPMethod = slices.Contains(idempotentHTTPMethods, httpMethod) + + // Connection closed + if errors.Is(urlError.Err, io.EOF) && isIdempotentHTTPMethod { + return err + } + } + + // syscall detection is not available on every platform, so + // fallback to best effort string detection. + isBrokenPipeError := strings.Contains(err.Error(), "broken pipe") + isConnectionResetError := strings.Contains(err.Error(), "connection reset") + + if (isBrokenPipeError || isConnectionResetError) && isIdempotentHTTPMethod { + return err + } + + return retry.Permanent(err) + } + resp = res + if res == nil { + return fmt.Errorf("no response") + } + + for _, code := range r.StatusCodes { + if strings.Contains(strings.ToUpper(code), "X") { + codeRange, err := strconv.Atoi(code[:1]) + if err != nil { + continue + } + + s := res.StatusCode / 100 + + if s >= codeRange && s < codeRange+1 { + return retry.TemporaryFromResponse("request failed", res) + } + } else { + parsedCode, err := strconv.Atoi(code) + if err != nil { + continue + } + + if res.StatusCode == parsedCode { + return retry.TemporaryFromResponse("request failed", res) + } + } + } + + resp = res + + return nil + }) + + var tempErr *retry.TemporaryError + if err != nil && !errors.As(err, &tempErr) { + return nil, err + } + + return resp, nil + default: + return operation() + } +} + +func retryWithBackoff(ctx context.Context, s *retry.BackoffStrategy, operation func() error) error { + var ( + err error + next time.Duration + attempt int + start = time.Now() + maxElapsedTime = time.Duration(s.MaxElapsedTime) * time.Millisecond + ) + + timer := &defaultTimer{} + defer func() { + timer.Stop() + }() + + for { + err = operation() + if err == nil { + return nil + } + + var permanent *retry.PermanentError + if errors.As(err, &permanent) { + return permanent.Unwrap() + } + + if time.Since(start) >= maxElapsedTime { + return err + } + + var temporary *retry.TemporaryError + if errors.As(err, &temporary) { + next = temporary.RetryAfter() + } + + if next <= 0 { + next = nextInterval(s, attempt) + } + + timer.Start(next) + + select { + case <-ctx.Done(): + return ctx.Err() + case <-timer.C(): + } + + attempt += 1 + } +} + +type Timer interface { + Start(duration time.Duration) + Stop() + C() <-chan time.Time +} + +// defaultTimer implements Timer interface using time.Timer +type defaultTimer struct { + timer *time.Timer +} + +// C returns the timers channel which receives the current time when the timer fires. +func (t *defaultTimer) C() <-chan time.Time { + return t.timer.C +} + +// Start starts the timer to fire after the given duration +func (t *defaultTimer) Start(duration time.Duration) { + if t.timer == nil { + t.timer = time.NewTimer(duration) + return + } + + if !t.timer.Stop() { + select { + case <-t.timer.C: + default: + } + } + + t.timer.Reset(duration) +} + +// Stop is called when the timer is not used anymore and resources may be freed. +func (t *defaultTimer) Stop() { + if t.timer != nil { + t.timer.Stop() + } +} + +func nextInterval(s *retry.BackoffStrategy, attempt int) time.Duration { + initialInterval := float64(time.Duration(s.InitialInterval) * time.Millisecond) + maxInterval := float64(time.Duration(s.MaxInterval) * time.Millisecond) + exponent := s.Exponent + jitterFactor := float64(0.25) + + interval := initialInterval * math.Pow(float64(attempt+1), exponent) + + jitter := rand.Float64() * jitterFactor * interval + if rand.Float64() < 0.5 { + jitter = -1 * jitter + } + + interval = interval + jitter + + if interval <= 0 { + interval = initialInterval + } + + if interval > maxInterval { + interval = maxInterval + } + + return time.Duration(interval) +} diff --git a/internal/membershipclient/internal/utils/security.go b/internal/membershipclient/internal/utils/security.go new file mode 100644 index 00000000..19dfa6f4 --- /dev/null +++ b/internal/membershipclient/internal/utils/security.go @@ -0,0 +1,285 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "context" + "encoding/base64" + "fmt" + "net/http" + "reflect" + "strings" +) + +const ( + securityTagKey = "security" +) + +type securityTag struct { + Option bool + Scheme bool + Name string + Type string + SubType string + Env string +} + +func PopulateSecurity(ctx context.Context, req *http.Request, securitySource func(context.Context) (interface{}, error)) error { + if securitySource == nil { + return nil + } + + security, err := securitySource(ctx) + if err != nil { + return err + } + + headers := make(map[string]string) + queryParams := make(map[string]string) + + securityValType := trueReflectValue(reflect.ValueOf(security)) + securityStructType := securityValType.Type() + + if isNil(securityStructType, securityValType) { + return nil + } + + if securityStructType.Kind() == reflect.Ptr { + securityStructType = securityStructType.Elem() + securityValType = securityValType.Elem() + } + + for i := 0; i < securityStructType.NumField(); i++ { + fieldType := securityStructType.Field(i) + valType := securityValType.Field(i) + + kind := valType.Kind() + + if isNil(fieldType.Type, valType) { + continue + } + + if fieldType.Type.Kind() == reflect.Pointer { + kind = valType.Elem().Kind() + } + + secTag := parseSecurityTag(fieldType) + if secTag != nil { + if secTag.Option { + handleSecurityOption(headers, queryParams, valType.Interface()) + } else if secTag.Scheme { + // Special case for basic auth which could be a flattened struct + if secTag.SubType == "basic" && kind != reflect.Struct { + parseSecurityScheme(headers, queryParams, secTag, security) + } else { + parseSecurityScheme(headers, queryParams, secTag, valType.Interface()) + } + } + } + } + + for key, value := range headers { + req.Header.Add(key, value) + } + + query := req.URL.Query() + for key, value := range queryParams { + query.Add(key, value) + } + req.URL.RawQuery = query.Encode() + + return nil +} + +func handleSecurityOption(headers, queryParams map[string]string, option interface{}) { + optionValType := trueReflectValue(reflect.ValueOf(option)) + optionStructType := optionValType.Type() + + if isNil(optionStructType, optionValType) { + return + } + + for i := 0; i < optionStructType.NumField(); i++ { + fieldType := optionStructType.Field(i) + valType := optionValType.Field(i) + + secTag := parseSecurityTag(fieldType) + if secTag != nil && secTag.Scheme { + parseSecurityScheme(headers, queryParams, secTag, valType.Interface()) + } + } +} + +func parseSecurityScheme(headers, queryParams map[string]string, schemeTag *securityTag, scheme interface{}) { + schemeVal := trueReflectValue(reflect.ValueOf(scheme)) + schemeType := schemeVal.Type() + + if isNil(schemeType, schemeVal) { + return + } + + if schemeType.Kind() == reflect.Struct { + if schemeTag.Type == "http" { + switch schemeTag.SubType { + case "basic": + handleBasicAuthScheme(headers, schemeVal.Interface()) + return + case "custom": + return + } + } + + for i := 0; i < schemeType.NumField(); i++ { + fieldType := schemeType.Field(i) + valType := schemeVal.Field(i) + + if isNil(fieldType.Type, valType) { + continue + } + + if fieldType.Type.Kind() == reflect.Ptr { + valType = valType.Elem() + } + + secTag := parseSecurityTag(fieldType) + if secTag == nil || secTag.Name == "" { + return + } + + parseSecuritySchemeValue(headers, queryParams, schemeTag, secTag, valType.Interface()) + } + } else { + parseSecuritySchemeValue(headers, queryParams, schemeTag, schemeTag, schemeVal.Interface()) + } +} + +func parseSecuritySchemeValue(headers, queryParams map[string]string, schemeTag *securityTag, secTag *securityTag, val interface{}) { + switch schemeTag.Type { + case "apiKey": + switch schemeTag.SubType { + case "header": + headers[secTag.Name] = valToString(val) + case "query": + queryParams[secTag.Name] = valToString(val) + case "cookie": + headers["Cookie"] = fmt.Sprintf("%s=%s", secTag.Name, valToString(val)) + default: + panic("not supported") + } + case "openIdConnect": + headers[secTag.Name] = prefixBearer(valToString(val)) + case "oauth2": + if schemeTag.SubType != "client_credentials" { + headers[secTag.Name] = prefixBearer(valToString(val)) + } + case "http": + switch schemeTag.SubType { + case "bearer": + headers[secTag.Name] = prefixBearer(valToString(val)) + case "custom": + default: + panic("not supported") + } + default: + panic("not supported") + } +} + +func prefixBearer(authHeaderValue string) string { + if strings.HasPrefix(strings.ToLower(authHeaderValue), "bearer ") { + return authHeaderValue + } + + return fmt.Sprintf("Bearer %s", authHeaderValue) +} + +func handleBasicAuthScheme(headers map[string]string, scheme interface{}) { + schemeStructType := reflect.TypeOf(scheme) + schemeValType := reflect.ValueOf(scheme) + + var username, password string + + for i := 0; i < schemeStructType.NumField(); i++ { + fieldType := schemeStructType.Field(i) + valType := schemeValType.Field(i) + + if fieldType.Type.Kind() == reflect.Ptr { + valType = valType.Elem() + } + + secTag := parseSecurityTag(fieldType) + if secTag == nil || secTag.Name == "" { + continue + } + + switch secTag.Name { + case "username": + username = valType.String() + case "password": + password = valType.String() + } + } + + headers["Authorization"] = fmt.Sprintf("Basic %s", base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s:%s", username, password)))) +} + +func parseSecurityTag(field reflect.StructField) *securityTag { + tag := field.Tag.Get(securityTagKey) + if tag == "" { + return nil + } + + option := false + scheme := false + name := "" + securityType := "" + securitySubType := "" + env := "" + + options := strings.Split(tag, ",") + for _, optionConf := range options { + parts := strings.Split(optionConf, "=") + if len(parts) < 1 || len(parts) > 2 { + continue + } + + switch parts[0] { + case "name": + name = parts[1] + case "type": + securityType = parts[1] + case "subtype": + securitySubType = parts[1] + case "option": + option = true + case "scheme": + scheme = true + case "env": + env = parts[1] + } + } + + // TODO: validate tag? + + return &securityTag{ + Option: option, + Scheme: scheme, + Name: name, + Type: securityType, + SubType: securitySubType, + Env: env, + } +} + +func trueReflectValue(val reflect.Value) reflect.Value { + kind := val.Type().Kind() + for kind == reflect.Interface || kind == reflect.Ptr { + innerVal := val.Elem() + if !innerVal.IsValid() { + break + } + val = innerVal + kind = val.Type().Kind() + } + return val +} diff --git a/internal/membershipclient/internal/utils/utils.go b/internal/membershipclient/internal/utils/utils.go new file mode 100644 index 00000000..0415b536 --- /dev/null +++ b/internal/membershipclient/internal/utils/utils.go @@ -0,0 +1,278 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package utils + +import ( + "bytes" + "context" + "fmt" + "io" + "math/big" + "net/http" + "reflect" + "regexp" + "strconv" + "strings" + "time" +) + +const ( + queryParamTagKey = "queryParam" + headerParamTagKey = "header" + pathParamTagKey = "pathParam" +) + +var ( + paramRegex = regexp.MustCompile(`({.*?})`) + SerializationMethodToContentType = map[string]string{ + "json": "application/json", + "form": "application/x-www-form-urlencoded", + "multipart": "multipart/form-data", + "raw": "application/octet-stream", + "string": "text/plain", + } +) + +func UnmarshalJsonFromResponseBody(body io.Reader, out interface{}, tag string) error { + data, err := io.ReadAll(body) + if err != nil { + return fmt.Errorf("error reading response body: %w", err) + } + if err := UnmarshalJSON(data, out, reflect.StructTag(tag), true, nil); err != nil { + return fmt.Errorf("error unmarshaling json response body: %w", err) + } + + return nil +} + +func ReplaceParameters(stringWithParams string, params map[string]string) string { + if len(params) == 0 { + return stringWithParams + } + + return paramRegex.ReplaceAllStringFunc(stringWithParams, func(match string) string { + match = match[1 : len(match)-1] + return params[match] + }) +} + +func Contains(slice []string, item string) bool { + for _, s := range slice { + if s == item { + return true + } + } + return false +} + +func MatchStatusCodes(expectedCodes []string, statusCode int) bool { + for _, codeStr := range expectedCodes { + code, err := strconv.Atoi(codeStr) + if err == nil { + if code == statusCode { + return true + } + continue + } + + codeRange, err := strconv.Atoi(string(codeStr[0])) + if err != nil { + continue + } + + if statusCode >= (codeRange*100) && statusCode < ((codeRange+1)*100) { + return true + } + } + + return false +} + +func AsSecuritySource(security interface{}) func(context.Context) (interface{}, error) { + return func(context.Context) (interface{}, error) { + return security, nil + } +} + +func parseConstTag(field reflect.StructField) *string { + value := field.Tag.Get("const") + + if value == "" { + return nil + } + + return &value +} + +func parseDefaultTag(field reflect.StructField) *string { + value := field.Tag.Get("default") + + if value == "" { + return nil + } + + return &value +} + +func parseStructTag(tagKey string, field reflect.StructField) map[string]string { + tag := field.Tag.Get(tagKey) + if tag == "" { + return nil + } + + values := map[string]string{} + + options := strings.Split(tag, ",") + for _, optionConf := range options { + parts := strings.Split(optionConf, "=") + + switch len(parts) { + case 1: + // flag option + parts = append(parts, "true") + case 2: + // key=value option + default: + // invalid option + continue + } + + values[parts[0]] = parts[1] + } + + return values +} + +func parseParamTag(tagKey string, field reflect.StructField, defaultStyle string, defaultExplode bool) *paramTag { + // example `{tagKey}:"style=simple,explode=false,name=apiID"` + // example `{tagKey}:"inline"` + values := parseStructTag(tagKey, field) + if values == nil { + return nil + } + + tag := ¶mTag{ + Style: defaultStyle, + Explode: defaultExplode, + ParamName: strings.ToLower(field.Name), + } + + for k, v := range values { + switch k { + case "inline": + tag.Inline = v == "true" + case "style": + tag.Style = v + case "explode": + tag.Explode = v == "true" + case "name": + tag.ParamName = v + case "serialization": + tag.Serialization = v + } + } + + return tag +} + +func valToString(val interface{}) string { + switch v := val.(type) { + case time.Time: + return v.Format(time.RFC3339Nano) + case big.Int: + return v.String() + default: + return fmt.Sprintf("%v", v) + } +} + +func populateFromGlobals(fieldType reflect.StructField, valType reflect.Value, paramType string, globals interface{}) (reflect.StructField, reflect.Value, bool) { + if globals == nil { + return fieldType, valType, false + } + + globalsStruct := reflect.TypeOf(globals) + globalsStructVal := reflect.ValueOf(globals) + + globalsField, found := globalsStruct.FieldByName(fieldType.Name) + if !found { + return fieldType, valType, false + } + + if fieldType.Type.Kind() != reflect.Ptr || !valType.IsNil() { + return fieldType, valType, true + } + + globalsVal := globalsStructVal.FieldByName(fieldType.Name) + + if !globalsVal.IsValid() { + return fieldType, valType, false + } + + switch paramType { + case queryParamTagKey: + qpTag := parseQueryParamTag(globalsField) + if qpTag == nil { + return fieldType, valType, false + } + default: + tag := parseParamTag(paramType, fieldType, "simple", false) + if tag == nil { + return fieldType, valType, false + } + } + + return globalsField, globalsVal, true +} + +func isNil(typ reflect.Type, val reflect.Value) bool { + // `reflect.TypeOf(nil) == nil` so calling typ.Kind() will cause a nil pointer + // dereference panic. Catch it and return early. + // https://github.com/golang/go/issues/51649 + // https://github.com/golang/go/issues/54208 + if typ == nil { + return true + } + + if typ.Kind() == reflect.Ptr || typ.Kind() == reflect.Map || typ.Kind() == reflect.Slice || typ.Kind() == reflect.Interface { + return val.IsNil() + } + + return false +} + +func isEmptyContainer(typ reflect.Type, val reflect.Value) bool { + if isNil(typ, val) { + return true + } + + switch typ.Kind() { + case reflect.Slice, reflect.Array: + return val.Len() == 0 + case reflect.Map: + return val.Len() == 0 + default: + return false + } +} + +func contains(arr []string, str string) bool { + for _, a := range arr { + if a == str { + return true + } + } + return false +} + +func ConsumeRawBody(res *http.Response) ([]byte, error) { + rawBody, err := io.ReadAll(res.Body) + if err != nil { + return nil, fmt.Errorf("error reading response body: %w", err) + } + + res.Body.Close() + res.Body = io.NopCloser(bytes.NewBuffer(rawBody)) + + return rawBody, nil +} diff --git a/internal/membershipclient/models/apierrors/apierror.go b/internal/membershipclient/models/apierrors/apierror.go new file mode 100644 index 00000000..61a9628a --- /dev/null +++ b/internal/membershipclient/models/apierrors/apierror.go @@ -0,0 +1,35 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package apierrors + +import ( + "fmt" + "net/http" +) + +type APIError struct { + Message string + StatusCode int + Body string + RawResponse *http.Response +} + +var _ error = &APIError{} + +func NewAPIError(message string, statusCode int, body string, httpRes *http.Response) *APIError { + return &APIError{ + Message: message, + StatusCode: statusCode, + Body: body, + RawResponse: httpRes, + } +} + +func (e *APIError) Error() string { + body := "" + if len(e.Body) > 0 { + body = fmt.Sprintf("\n%s", e.Body) + } + + return fmt.Sprintf("%s: Status %d%s", e.Message, e.StatusCode, body) +} diff --git a/internal/membershipclient/models/apierrors/error.go b/internal/membershipclient/models/apierrors/error.go new file mode 100644 index 00000000..4d0f5420 --- /dev/null +++ b/internal/membershipclient/models/apierrors/error.go @@ -0,0 +1,21 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package apierrors + +import ( + "encoding/json" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type Error struct { + ErrorCode string `json:"errorCode"` + ErrorMessage *string `json:"errorMessage,omitzero"` + HTTPMeta components.HTTPMetadata `json:"-"` +} + +var _ error = &Error{} + +func (e *Error) Error() string { + data, _ := json.Marshal(e) + return string(data) +} diff --git a/internal/membershipclient/models/components/action.go b/internal/membershipclient/models/components/action.go new file mode 100644 index 00000000..87658859 --- /dev/null +++ b/internal/membershipclient/models/components/action.go @@ -0,0 +1,148 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "encoding/json" + "fmt" +) + +type Action string + +const ( + ActionAgentsConnected Action = "agents.connected" + ActionAgentsDisconnected Action = "agents.disconnected" + ActionInvitationsCreated Action = "invitations.created" + ActionInvitationsAccepted Action = "invitations.accepted" + ActionInvitationsRejected Action = "invitations.rejected" + ActionInvitationsCancelled Action = "invitations.cancelled" + ActionOrganizationsCreated Action = "organizations.created" + ActionOrganizationsUpdated Action = "organizations.updated" + ActionOrganizationsDeleted Action = "organizations.deleted" + ActionOrganizationsUserDeleted Action = "organizations.user.deleted" + ActionOrganizationsUserUpdated Action = "organizations.user.updated" + ActionRegionsCreated Action = "regions.created" + ActionRegionsDeleted Action = "regions.deleted" + ActionUsersCreated Action = "users.created" + ActionUsersDeleted Action = "users.deleted" + ActionStacksDisposal Action = "stacks.disposal" + ActionStacksDisposalReset Action = "stacks.disposal-reset" + ActionStacksWarned Action = "stacks.warned" + ActionStacksPruned Action = "stacks.pruned" + ActionStacksStatusUpdated Action = "stacks.status.updated" + ActionStacksCreated Action = "stacks.created" + ActionStacksUpdated Action = "stacks.updated" + ActionStacksDeleted Action = "stacks.deleted" + ActionStacksRestored Action = "stacks.restored" + ActionStacksDisabled Action = "stacks.disabled" + ActionStacksEnabled Action = "stacks.enabled" + ActionStacksUpgraded Action = "stacks.upgraded" + ActionStacksStargateEnabled Action = "stacks.stargate.enabled" + ActionStacksStargateDisabled Action = "stacks.stargate.disabled" + ActionStacksUserUpdated Action = "stacks.user.updated" + ActionStacksUserDeleted Action = "stacks.user.deleted" + ActionStacksReachnessUpdated Action = "stacks.reachness.updated" + ActionStacksModuleEnabled Action = "stacks.module.enabled" + ActionStacksModuleDisabled Action = "stacks.module.disabled" + ActionStacksModuleStatusUpdated Action = "stacks.module.status.updated" + ActionPoliciesCreated Action = "policies.created" + ActionPoliciesUpdated Action = "policies.updated" + ActionPoliciesDeleted Action = "policies.deleted" + ActionPoliciesScopeAdded Action = "policies.scope.added" + ActionPoliciesScopeRemoved Action = "policies.scope.removed" +) + +func (e Action) ToPointer() *Action { + return &e +} +func (e *Action) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "agents.connected": + fallthrough + case "agents.disconnected": + fallthrough + case "invitations.created": + fallthrough + case "invitations.accepted": + fallthrough + case "invitations.rejected": + fallthrough + case "invitations.cancelled": + fallthrough + case "organizations.created": + fallthrough + case "organizations.updated": + fallthrough + case "organizations.deleted": + fallthrough + case "organizations.user.deleted": + fallthrough + case "organizations.user.updated": + fallthrough + case "regions.created": + fallthrough + case "regions.deleted": + fallthrough + case "users.created": + fallthrough + case "users.deleted": + fallthrough + case "stacks.disposal": + fallthrough + case "stacks.disposal-reset": + fallthrough + case "stacks.warned": + fallthrough + case "stacks.pruned": + fallthrough + case "stacks.status.updated": + fallthrough + case "stacks.created": + fallthrough + case "stacks.updated": + fallthrough + case "stacks.deleted": + fallthrough + case "stacks.restored": + fallthrough + case "stacks.disabled": + fallthrough + case "stacks.enabled": + fallthrough + case "stacks.upgraded": + fallthrough + case "stacks.stargate.enabled": + fallthrough + case "stacks.stargate.disabled": + fallthrough + case "stacks.user.updated": + fallthrough + case "stacks.user.deleted": + fallthrough + case "stacks.reachness.updated": + fallthrough + case "stacks.module.enabled": + fallthrough + case "stacks.module.disabled": + fallthrough + case "stacks.module.status.updated": + fallthrough + case "policies.created": + fallthrough + case "policies.updated": + fallthrough + case "policies.deleted": + fallthrough + case "policies.scope.added": + fallthrough + case "policies.scope.removed": + *e = Action(v) + return nil + default: + return fmt.Errorf("invalid value for Action: %v", v) + } +} diff --git a/internal/membershipclient/models/components/anyregion.go b/internal/membershipclient/models/components/anyregion.go new file mode 100644 index 00000000..a7890c9c --- /dev/null +++ b/internal/membershipclient/models/components/anyregion.go @@ -0,0 +1,158 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "time" +) + +type AnyRegion struct { + ID string `json:"id"` + BaseURL string `json:"baseUrl"` + CreatedAt string `json:"createdAt"` + Active bool `json:"active"` + LastPing *time.Time `json:"lastPing,omitzero"` + Name string `json:"name"` + Capabilities RegionCapability `json:"capabilities"` + AgentID string `json:"agentID"` + Outdated bool `json:"outdated"` + CreatorID *string `json:"creatorId,omitzero"` + Version *string `json:"version,omitzero"` + ClientID *string `json:"clientID,omitzero"` + OrganizationID *string `json:"organizationID,omitzero"` + Creator *User `json:"creator,omitzero"` + Production *bool `json:"production,omitzero"` + Public bool `json:"public"` + Secret *PrivateRegionSecret `json:"secret,omitzero"` +} + +func (a AnyRegion) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AnyRegion) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, []string{"id", "baseUrl", "createdAt", "active", "name", "capabilities", "agentID", "outdated", "public"}); err != nil { + return err + } + return nil +} + +func (a *AnyRegion) GetID() string { + if a == nil { + return "" + } + return a.ID +} + +func (a *AnyRegion) GetBaseURL() string { + if a == nil { + return "" + } + return a.BaseURL +} + +func (a *AnyRegion) GetCreatedAt() string { + if a == nil { + return "" + } + return a.CreatedAt +} + +func (a *AnyRegion) GetActive() bool { + if a == nil { + return false + } + return a.Active +} + +func (a *AnyRegion) GetLastPing() *time.Time { + if a == nil { + return nil + } + return a.LastPing +} + +func (a *AnyRegion) GetName() string { + if a == nil { + return "" + } + return a.Name +} + +func (a *AnyRegion) GetCapabilities() RegionCapability { + if a == nil { + return RegionCapability{} + } + return a.Capabilities +} + +func (a *AnyRegion) GetAgentID() string { + if a == nil { + return "" + } + return a.AgentID +} + +func (a *AnyRegion) GetOutdated() bool { + if a == nil { + return false + } + return a.Outdated +} + +func (a *AnyRegion) GetCreatorID() *string { + if a == nil { + return nil + } + return a.CreatorID +} + +func (a *AnyRegion) GetVersion() *string { + if a == nil { + return nil + } + return a.Version +} + +func (a *AnyRegion) GetClientID() *string { + if a == nil { + return nil + } + return a.ClientID +} + +func (a *AnyRegion) GetOrganizationID() *string { + if a == nil { + return nil + } + return a.OrganizationID +} + +func (a *AnyRegion) GetCreator() *User { + if a == nil { + return nil + } + return a.Creator +} + +func (a *AnyRegion) GetProduction() *bool { + if a == nil { + return nil + } + return a.Production +} + +func (a *AnyRegion) GetPublic() bool { + if a == nil { + return false + } + return a.Public +} + +func (a *AnyRegion) GetSecret() *PrivateRegionSecret { + if a == nil { + return nil + } + return a.Secret +} diff --git a/internal/membershipclient/models/components/application.go b/internal/membershipclient/models/components/application.go new file mode 100644 index 00000000..6c4d116e --- /dev/null +++ b/internal/membershipclient/models/components/application.go @@ -0,0 +1,85 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "time" +) + +type Application struct { + // Application name + Name string `json:"name"` + // Application description + Description *string `json:"description,omitzero"` + // Application URL (must be unique) + URL string `json:"url"` + // Application alias + Alias string `json:"alias"` + // Application ID + ID string `json:"id"` + // Creation date + CreatedAt time.Time `json:"createdAt"` + // Last update date + UpdatedAt time.Time `json:"updatedAt"` +} + +func (a Application) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *Application) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, []string{"name", "url", "alias", "id", "createdAt", "updatedAt"}); err != nil { + return err + } + return nil +} + +func (a *Application) GetName() string { + if a == nil { + return "" + } + return a.Name +} + +func (a *Application) GetDescription() *string { + if a == nil { + return nil + } + return a.Description +} + +func (a *Application) GetURL() string { + if a == nil { + return "" + } + return a.URL +} + +func (a *Application) GetAlias() string { + if a == nil { + return "" + } + return a.Alias +} + +func (a *Application) GetID() string { + if a == nil { + return "" + } + return a.ID +} + +func (a *Application) GetCreatedAt() time.Time { + if a == nil { + return time.Time{} + } + return a.CreatedAt +} + +func (a *Application) GetUpdatedAt() time.Time { + if a == nil { + return time.Time{} + } + return a.UpdatedAt +} diff --git a/internal/membershipclient/models/components/applicationdata.go b/internal/membershipclient/models/components/applicationdata.go new file mode 100644 index 00000000..6e054254 --- /dev/null +++ b/internal/membershipclient/models/components/applicationdata.go @@ -0,0 +1,42 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type ApplicationData struct { + // Application name + Name string `json:"name"` + // Application description + Description *string `json:"description,omitzero"` + // Application URL (must be unique) + URL string `json:"url"` + // Application alias + Alias string `json:"alias"` +} + +func (a *ApplicationData) GetName() string { + if a == nil { + return "" + } + return a.Name +} + +func (a *ApplicationData) GetDescription() *string { + if a == nil { + return nil + } + return a.Description +} + +func (a *ApplicationData) GetURL() string { + if a == nil { + return "" + } + return a.URL +} + +func (a *ApplicationData) GetAlias() string { + if a == nil { + return "" + } + return a.Alias +} diff --git a/internal/membershipclient/models/components/applicationwithscope.go b/internal/membershipclient/models/components/applicationwithscope.go new file mode 100644 index 00000000..c207c72e --- /dev/null +++ b/internal/membershipclient/models/components/applicationwithscope.go @@ -0,0 +1,94 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "time" +) + +type ApplicationWithScope struct { + // Application name + Name string `json:"name"` + // Application description + Description *string `json:"description,omitzero"` + // Application URL (must be unique) + URL string `json:"url"` + // Application alias + Alias string `json:"alias"` + // Application ID + ID string `json:"id"` + // Creation date + CreatedAt time.Time `json:"createdAt"` + // Last update date + UpdatedAt time.Time `json:"updatedAt"` + // List of scopes associated with this application + Scopes []Scope `json:"scopes"` +} + +func (a ApplicationWithScope) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *ApplicationWithScope) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, []string{"name", "url", "alias", "id", "createdAt", "updatedAt", "scopes"}); err != nil { + return err + } + return nil +} + +func (a *ApplicationWithScope) GetName() string { + if a == nil { + return "" + } + return a.Name +} + +func (a *ApplicationWithScope) GetDescription() *string { + if a == nil { + return nil + } + return a.Description +} + +func (a *ApplicationWithScope) GetURL() string { + if a == nil { + return "" + } + return a.URL +} + +func (a *ApplicationWithScope) GetAlias() string { + if a == nil { + return "" + } + return a.Alias +} + +func (a *ApplicationWithScope) GetID() string { + if a == nil { + return "" + } + return a.ID +} + +func (a *ApplicationWithScope) GetCreatedAt() time.Time { + if a == nil { + return time.Time{} + } + return a.CreatedAt +} + +func (a *ApplicationWithScope) GetUpdatedAt() time.Time { + if a == nil { + return time.Time{} + } + return a.UpdatedAt +} + +func (a *ApplicationWithScope) GetScopes() []Scope { + if a == nil { + return []Scope{} + } + return a.Scopes +} diff --git a/internal/membershipclient/models/components/authenticationproviderdata.go b/internal/membershipclient/models/components/authenticationproviderdata.go new file mode 100644 index 00000000..3ee26cd5 --- /dev/null +++ b/internal/membershipclient/models/components/authenticationproviderdata.go @@ -0,0 +1,563 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "encoding/json" + "errors" + "fmt" + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +// AuthenticationProviderDataOIDCConfigType - Type of the authentication provider +type AuthenticationProviderDataOIDCConfigType string + +const ( + AuthenticationProviderDataOIDCConfigTypeOidc AuthenticationProviderDataOIDCConfigType = "oidc" + AuthenticationProviderDataOIDCConfigTypeGoogle AuthenticationProviderDataOIDCConfigType = "google" + AuthenticationProviderDataOIDCConfigTypeGithub AuthenticationProviderDataOIDCConfigType = "github" + AuthenticationProviderDataOIDCConfigTypeMicrosoft AuthenticationProviderDataOIDCConfigType = "microsoft" +) + +func (e AuthenticationProviderDataOIDCConfigType) ToPointer() *AuthenticationProviderDataOIDCConfigType { + return &e +} +func (e *AuthenticationProviderDataOIDCConfigType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "oidc": + fallthrough + case "google": + fallthrough + case "github": + fallthrough + case "microsoft": + *e = AuthenticationProviderDataOIDCConfigType(v) + return nil + default: + return fmt.Errorf("invalid value for AuthenticationProviderDataOIDCConfigType: %v", v) + } +} + +type AuthenticationProviderDataOIDCConfigConfig struct { + // OIDC issuer URL + Issuer string `json:"issuer"` + DiscoveryPath *string `default:"/.well-known/openid-configuration" json:"discoveryPath"` +} + +func (a AuthenticationProviderDataOIDCConfigConfig) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AuthenticationProviderDataOIDCConfigConfig) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, []string{"issuer"}); err != nil { + return err + } + return nil +} + +func (a *AuthenticationProviderDataOIDCConfigConfig) GetIssuer() string { + if a == nil { + return "" + } + return a.Issuer +} + +func (a *AuthenticationProviderDataOIDCConfigConfig) GetDiscoveryPath() *string { + if a == nil { + return nil + } + return a.DiscoveryPath +} + +type AuthenticationProviderDataOIDCConfig struct { + // Type of the authentication provider + Type AuthenticationProviderDataOIDCConfigType `json:"type"` + // Name of the authentication provider + Name string `json:"name"` + // Client ID for the authentication provider + ClientID string `json:"clientID"` + // Client secret for the authentication provider + ClientSecret string `json:"clientSecret"` + Config AuthenticationProviderDataOIDCConfigConfig `json:"config"` +} + +func (a AuthenticationProviderDataOIDCConfig) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AuthenticationProviderDataOIDCConfig) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, []string{"type", "name", "clientID", "clientSecret", "config"}); err != nil { + return err + } + return nil +} + +func (a *AuthenticationProviderDataOIDCConfig) GetType() AuthenticationProviderDataOIDCConfigType { + if a == nil { + return AuthenticationProviderDataOIDCConfigType("") + } + return a.Type +} + +func (a *AuthenticationProviderDataOIDCConfig) GetName() string { + if a == nil { + return "" + } + return a.Name +} + +func (a *AuthenticationProviderDataOIDCConfig) GetClientID() string { + if a == nil { + return "" + } + return a.ClientID +} + +func (a *AuthenticationProviderDataOIDCConfig) GetClientSecret() string { + if a == nil { + return "" + } + return a.ClientSecret +} + +func (a *AuthenticationProviderDataOIDCConfig) GetConfig() AuthenticationProviderDataOIDCConfigConfig { + if a == nil { + return AuthenticationProviderDataOIDCConfigConfig{} + } + return a.Config +} + +// AuthenticationProviderDataGithubIDPConfigType - Type of the authentication provider +type AuthenticationProviderDataGithubIDPConfigType string + +const ( + AuthenticationProviderDataGithubIDPConfigTypeOidc AuthenticationProviderDataGithubIDPConfigType = "oidc" + AuthenticationProviderDataGithubIDPConfigTypeGoogle AuthenticationProviderDataGithubIDPConfigType = "google" + AuthenticationProviderDataGithubIDPConfigTypeGithub AuthenticationProviderDataGithubIDPConfigType = "github" + AuthenticationProviderDataGithubIDPConfigTypeMicrosoft AuthenticationProviderDataGithubIDPConfigType = "microsoft" +) + +func (e AuthenticationProviderDataGithubIDPConfigType) ToPointer() *AuthenticationProviderDataGithubIDPConfigType { + return &e +} +func (e *AuthenticationProviderDataGithubIDPConfigType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "oidc": + fallthrough + case "google": + fallthrough + case "github": + fallthrough + case "microsoft": + *e = AuthenticationProviderDataGithubIDPConfigType(v) + return nil + default: + return fmt.Errorf("invalid value for AuthenticationProviderDataGithubIDPConfigType: %v", v) + } +} + +type AuthenticationProviderDataGithubIDPConfigConfig struct { +} + +func (a AuthenticationProviderDataGithubIDPConfigConfig) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AuthenticationProviderDataGithubIDPConfigConfig) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, nil); err != nil { + return err + } + return nil +} + +type AuthenticationProviderDataGithubIDPConfig struct { + // Type of the authentication provider + Type AuthenticationProviderDataGithubIDPConfigType `json:"type"` + // Name of the authentication provider + Name string `json:"name"` + // Client ID for the authentication provider + ClientID string `json:"clientID"` + // Client secret for the authentication provider + ClientSecret string `json:"clientSecret"` + Config AuthenticationProviderDataGithubIDPConfigConfig `json:"config"` +} + +func (a AuthenticationProviderDataGithubIDPConfig) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AuthenticationProviderDataGithubIDPConfig) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, []string{"type", "name", "clientID", "clientSecret", "config"}); err != nil { + return err + } + return nil +} + +func (a *AuthenticationProviderDataGithubIDPConfig) GetType() AuthenticationProviderDataGithubIDPConfigType { + if a == nil { + return AuthenticationProviderDataGithubIDPConfigType("") + } + return a.Type +} + +func (a *AuthenticationProviderDataGithubIDPConfig) GetName() string { + if a == nil { + return "" + } + return a.Name +} + +func (a *AuthenticationProviderDataGithubIDPConfig) GetClientID() string { + if a == nil { + return "" + } + return a.ClientID +} + +func (a *AuthenticationProviderDataGithubIDPConfig) GetClientSecret() string { + if a == nil { + return "" + } + return a.ClientSecret +} + +func (a *AuthenticationProviderDataGithubIDPConfig) GetConfig() AuthenticationProviderDataGithubIDPConfigConfig { + if a == nil { + return AuthenticationProviderDataGithubIDPConfigConfig{} + } + return a.Config +} + +// AuthenticationProviderDataMicrosoftIDPConfigType - Type of the authentication provider +type AuthenticationProviderDataMicrosoftIDPConfigType string + +const ( + AuthenticationProviderDataMicrosoftIDPConfigTypeOidc AuthenticationProviderDataMicrosoftIDPConfigType = "oidc" + AuthenticationProviderDataMicrosoftIDPConfigTypeGoogle AuthenticationProviderDataMicrosoftIDPConfigType = "google" + AuthenticationProviderDataMicrosoftIDPConfigTypeGithub AuthenticationProviderDataMicrosoftIDPConfigType = "github" + AuthenticationProviderDataMicrosoftIDPConfigTypeMicrosoft AuthenticationProviderDataMicrosoftIDPConfigType = "microsoft" +) + +func (e AuthenticationProviderDataMicrosoftIDPConfigType) ToPointer() *AuthenticationProviderDataMicrosoftIDPConfigType { + return &e +} +func (e *AuthenticationProviderDataMicrosoftIDPConfigType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "oidc": + fallthrough + case "google": + fallthrough + case "github": + fallthrough + case "microsoft": + *e = AuthenticationProviderDataMicrosoftIDPConfigType(v) + return nil + default: + return fmt.Errorf("invalid value for AuthenticationProviderDataMicrosoftIDPConfigType: %v", v) + } +} + +type AuthenticationProviderDataMicrosoftIDPConfigConfig struct { + // Tenant ID for Microsoft authentication + Tenant *string `default:"common" json:"tenant"` +} + +func (a AuthenticationProviderDataMicrosoftIDPConfigConfig) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AuthenticationProviderDataMicrosoftIDPConfigConfig) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, nil); err != nil { + return err + } + return nil +} + +func (a *AuthenticationProviderDataMicrosoftIDPConfigConfig) GetTenant() *string { + if a == nil { + return nil + } + return a.Tenant +} + +type AuthenticationProviderDataMicrosoftIDPConfig struct { + // Type of the authentication provider + Type AuthenticationProviderDataMicrosoftIDPConfigType `json:"type"` + // Name of the authentication provider + Name string `json:"name"` + // Client ID for the authentication provider + ClientID string `json:"clientID"` + // Client secret for the authentication provider + ClientSecret string `json:"clientSecret"` + Config AuthenticationProviderDataMicrosoftIDPConfigConfig `json:"config"` +} + +func (a AuthenticationProviderDataMicrosoftIDPConfig) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AuthenticationProviderDataMicrosoftIDPConfig) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, []string{"type", "name", "clientID", "clientSecret", "config"}); err != nil { + return err + } + return nil +} + +func (a *AuthenticationProviderDataMicrosoftIDPConfig) GetType() AuthenticationProviderDataMicrosoftIDPConfigType { + if a == nil { + return AuthenticationProviderDataMicrosoftIDPConfigType("") + } + return a.Type +} + +func (a *AuthenticationProviderDataMicrosoftIDPConfig) GetName() string { + if a == nil { + return "" + } + return a.Name +} + +func (a *AuthenticationProviderDataMicrosoftIDPConfig) GetClientID() string { + if a == nil { + return "" + } + return a.ClientID +} + +func (a *AuthenticationProviderDataMicrosoftIDPConfig) GetClientSecret() string { + if a == nil { + return "" + } + return a.ClientSecret +} + +func (a *AuthenticationProviderDataMicrosoftIDPConfig) GetConfig() AuthenticationProviderDataMicrosoftIDPConfigConfig { + if a == nil { + return AuthenticationProviderDataMicrosoftIDPConfigConfig{} + } + return a.Config +} + +// AuthenticationProviderDataGoogleIDPConfigType - Type of the authentication provider +type AuthenticationProviderDataGoogleIDPConfigType string + +const ( + AuthenticationProviderDataGoogleIDPConfigTypeOidc AuthenticationProviderDataGoogleIDPConfigType = "oidc" + AuthenticationProviderDataGoogleIDPConfigTypeGoogle AuthenticationProviderDataGoogleIDPConfigType = "google" + AuthenticationProviderDataGoogleIDPConfigTypeGithub AuthenticationProviderDataGoogleIDPConfigType = "github" + AuthenticationProviderDataGoogleIDPConfigTypeMicrosoft AuthenticationProviderDataGoogleIDPConfigType = "microsoft" +) + +func (e AuthenticationProviderDataGoogleIDPConfigType) ToPointer() *AuthenticationProviderDataGoogleIDPConfigType { + return &e +} +func (e *AuthenticationProviderDataGoogleIDPConfigType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "oidc": + fallthrough + case "google": + fallthrough + case "github": + fallthrough + case "microsoft": + *e = AuthenticationProviderDataGoogleIDPConfigType(v) + return nil + default: + return fmt.Errorf("invalid value for AuthenticationProviderDataGoogleIDPConfigType: %v", v) + } +} + +type AuthenticationProviderDataGoogleIDPConfigConfig struct { +} + +func (a AuthenticationProviderDataGoogleIDPConfigConfig) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AuthenticationProviderDataGoogleIDPConfigConfig) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, nil); err != nil { + return err + } + return nil +} + +type AuthenticationProviderDataGoogleIDPConfig struct { + // Type of the authentication provider + Type AuthenticationProviderDataGoogleIDPConfigType `json:"type"` + // Name of the authentication provider + Name string `json:"name"` + // Client ID for the authentication provider + ClientID string `json:"clientID"` + // Client secret for the authentication provider + ClientSecret string `json:"clientSecret"` + Config AuthenticationProviderDataGoogleIDPConfigConfig `json:"config"` +} + +func (a AuthenticationProviderDataGoogleIDPConfig) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AuthenticationProviderDataGoogleIDPConfig) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, []string{"type", "name", "clientID", "clientSecret", "config"}); err != nil { + return err + } + return nil +} + +func (a *AuthenticationProviderDataGoogleIDPConfig) GetType() AuthenticationProviderDataGoogleIDPConfigType { + if a == nil { + return AuthenticationProviderDataGoogleIDPConfigType("") + } + return a.Type +} + +func (a *AuthenticationProviderDataGoogleIDPConfig) GetName() string { + if a == nil { + return "" + } + return a.Name +} + +func (a *AuthenticationProviderDataGoogleIDPConfig) GetClientID() string { + if a == nil { + return "" + } + return a.ClientID +} + +func (a *AuthenticationProviderDataGoogleIDPConfig) GetClientSecret() string { + if a == nil { + return "" + } + return a.ClientSecret +} + +func (a *AuthenticationProviderDataGoogleIDPConfig) GetConfig() AuthenticationProviderDataGoogleIDPConfigConfig { + if a == nil { + return AuthenticationProviderDataGoogleIDPConfigConfig{} + } + return a.Config +} + +type AuthenticationProviderDataType string + +const ( + AuthenticationProviderDataTypeAuthenticationProviderDataGoogleIDPConfig AuthenticationProviderDataType = "AuthenticationProviderData_GoogleIDPConfig" + AuthenticationProviderDataTypeAuthenticationProviderDataMicrosoftIDPConfig AuthenticationProviderDataType = "AuthenticationProviderData_MicrosoftIDPConfig" + AuthenticationProviderDataTypeAuthenticationProviderDataGithubIDPConfig AuthenticationProviderDataType = "AuthenticationProviderData_GithubIDPConfig" + AuthenticationProviderDataTypeAuthenticationProviderDataOIDCConfig AuthenticationProviderDataType = "AuthenticationProviderData_OIDCConfig" +) + +type AuthenticationProviderData struct { + AuthenticationProviderDataGoogleIDPConfig *AuthenticationProviderDataGoogleIDPConfig `queryParam:"inline,name=AuthenticationProviderData"` + AuthenticationProviderDataMicrosoftIDPConfig *AuthenticationProviderDataMicrosoftIDPConfig `queryParam:"inline,name=AuthenticationProviderData"` + AuthenticationProviderDataGithubIDPConfig *AuthenticationProviderDataGithubIDPConfig `queryParam:"inline,name=AuthenticationProviderData"` + AuthenticationProviderDataOIDCConfig *AuthenticationProviderDataOIDCConfig `queryParam:"inline,name=AuthenticationProviderData"` + + Type AuthenticationProviderDataType +} + +func CreateAuthenticationProviderDataAuthenticationProviderDataGoogleIDPConfig(authenticationProviderDataGoogleIDPConfig AuthenticationProviderDataGoogleIDPConfig) AuthenticationProviderData { + typ := AuthenticationProviderDataTypeAuthenticationProviderDataGoogleIDPConfig + + return AuthenticationProviderData{ + AuthenticationProviderDataGoogleIDPConfig: &authenticationProviderDataGoogleIDPConfig, + Type: typ, + } +} + +func CreateAuthenticationProviderDataAuthenticationProviderDataMicrosoftIDPConfig(authenticationProviderDataMicrosoftIDPConfig AuthenticationProviderDataMicrosoftIDPConfig) AuthenticationProviderData { + typ := AuthenticationProviderDataTypeAuthenticationProviderDataMicrosoftIDPConfig + + return AuthenticationProviderData{ + AuthenticationProviderDataMicrosoftIDPConfig: &authenticationProviderDataMicrosoftIDPConfig, + Type: typ, + } +} + +func CreateAuthenticationProviderDataAuthenticationProviderDataGithubIDPConfig(authenticationProviderDataGithubIDPConfig AuthenticationProviderDataGithubIDPConfig) AuthenticationProviderData { + typ := AuthenticationProviderDataTypeAuthenticationProviderDataGithubIDPConfig + + return AuthenticationProviderData{ + AuthenticationProviderDataGithubIDPConfig: &authenticationProviderDataGithubIDPConfig, + Type: typ, + } +} + +func CreateAuthenticationProviderDataAuthenticationProviderDataOIDCConfig(authenticationProviderDataOIDCConfig AuthenticationProviderDataOIDCConfig) AuthenticationProviderData { + typ := AuthenticationProviderDataTypeAuthenticationProviderDataOIDCConfig + + return AuthenticationProviderData{ + AuthenticationProviderDataOIDCConfig: &authenticationProviderDataOIDCConfig, + Type: typ, + } +} + +func (u *AuthenticationProviderData) UnmarshalJSON(data []byte) error { + + var authenticationProviderDataGoogleIDPConfig AuthenticationProviderDataGoogleIDPConfig = AuthenticationProviderDataGoogleIDPConfig{} + if err := utils.UnmarshalJSON(data, &authenticationProviderDataGoogleIDPConfig, "", true, nil); err == nil { + u.AuthenticationProviderDataGoogleIDPConfig = &authenticationProviderDataGoogleIDPConfig + u.Type = AuthenticationProviderDataTypeAuthenticationProviderDataGoogleIDPConfig + return nil + } + + var authenticationProviderDataMicrosoftIDPConfig AuthenticationProviderDataMicrosoftIDPConfig = AuthenticationProviderDataMicrosoftIDPConfig{} + if err := utils.UnmarshalJSON(data, &authenticationProviderDataMicrosoftIDPConfig, "", true, nil); err == nil { + u.AuthenticationProviderDataMicrosoftIDPConfig = &authenticationProviderDataMicrosoftIDPConfig + u.Type = AuthenticationProviderDataTypeAuthenticationProviderDataMicrosoftIDPConfig + return nil + } + + var authenticationProviderDataGithubIDPConfig AuthenticationProviderDataGithubIDPConfig = AuthenticationProviderDataGithubIDPConfig{} + if err := utils.UnmarshalJSON(data, &authenticationProviderDataGithubIDPConfig, "", true, nil); err == nil { + u.AuthenticationProviderDataGithubIDPConfig = &authenticationProviderDataGithubIDPConfig + u.Type = AuthenticationProviderDataTypeAuthenticationProviderDataGithubIDPConfig + return nil + } + + var authenticationProviderDataOIDCConfig AuthenticationProviderDataOIDCConfig = AuthenticationProviderDataOIDCConfig{} + if err := utils.UnmarshalJSON(data, &authenticationProviderDataOIDCConfig, "", true, nil); err == nil { + u.AuthenticationProviderDataOIDCConfig = &authenticationProviderDataOIDCConfig + u.Type = AuthenticationProviderDataTypeAuthenticationProviderDataOIDCConfig + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for AuthenticationProviderData", string(data)) +} + +func (u AuthenticationProviderData) MarshalJSON() ([]byte, error) { + if u.AuthenticationProviderDataGoogleIDPConfig != nil { + return utils.MarshalJSON(u.AuthenticationProviderDataGoogleIDPConfig, "", true) + } + + if u.AuthenticationProviderDataMicrosoftIDPConfig != nil { + return utils.MarshalJSON(u.AuthenticationProviderDataMicrosoftIDPConfig, "", true) + } + + if u.AuthenticationProviderDataGithubIDPConfig != nil { + return utils.MarshalJSON(u.AuthenticationProviderDataGithubIDPConfig, "", true) + } + + if u.AuthenticationProviderDataOIDCConfig != nil { + return utils.MarshalJSON(u.AuthenticationProviderDataOIDCConfig, "", true) + } + + return nil, errors.New("could not marshal union type AuthenticationProviderData: all fields are null") +} diff --git a/internal/membershipclient/models/components/authenticationproviderresponse.go b/internal/membershipclient/models/components/authenticationproviderresponse.go new file mode 100644 index 00000000..374598ef --- /dev/null +++ b/internal/membershipclient/models/components/authenticationproviderresponse.go @@ -0,0 +1,715 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "encoding/json" + "errors" + "fmt" + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "time" +) + +// AuthenticationProviderResponseOIDCConfigType - Type of the authentication provider +type AuthenticationProviderResponseOIDCConfigType string + +const ( + AuthenticationProviderResponseOIDCConfigTypeOidc AuthenticationProviderResponseOIDCConfigType = "oidc" + AuthenticationProviderResponseOIDCConfigTypeGoogle AuthenticationProviderResponseOIDCConfigType = "google" + AuthenticationProviderResponseOIDCConfigTypeGithub AuthenticationProviderResponseOIDCConfigType = "github" + AuthenticationProviderResponseOIDCConfigTypeMicrosoft AuthenticationProviderResponseOIDCConfigType = "microsoft" +) + +func (e AuthenticationProviderResponseOIDCConfigType) ToPointer() *AuthenticationProviderResponseOIDCConfigType { + return &e +} +func (e *AuthenticationProviderResponseOIDCConfigType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "oidc": + fallthrough + case "google": + fallthrough + case "github": + fallthrough + case "microsoft": + *e = AuthenticationProviderResponseOIDCConfigType(v) + return nil + default: + return fmt.Errorf("invalid value for AuthenticationProviderResponseOIDCConfigType: %v", v) + } +} + +type AuthenticationProviderResponseOIDCConfigConfig struct { + // OIDC issuer URL + Issuer string `json:"issuer"` + DiscoveryPath *string `default:"/.well-known/openid-configuration" json:"discoveryPath"` +} + +func (a AuthenticationProviderResponseOIDCConfigConfig) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AuthenticationProviderResponseOIDCConfigConfig) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, []string{"issuer"}); err != nil { + return err + } + return nil +} + +func (a *AuthenticationProviderResponseOIDCConfigConfig) GetIssuer() string { + if a == nil { + return "" + } + return a.Issuer +} + +func (a *AuthenticationProviderResponseOIDCConfigConfig) GetDiscoveryPath() *string { + if a == nil { + return nil + } + return a.DiscoveryPath +} + +type AuthenticationProviderResponseOIDCConfig struct { + // Type of the authentication provider + Type AuthenticationProviderResponseOIDCConfigType `json:"type"` + // Name of the authentication provider + Name string `json:"name"` + // Client ID for the authentication provider + ClientID string `json:"clientID"` + // Client secret for the authentication provider + ClientSecret string `json:"clientSecret"` + Config AuthenticationProviderResponseOIDCConfigConfig `json:"config"` + // Unique identifier for the authentication provider + OrganizationID string `json:"organizationId"` + // Creation date of the authentication provider + CreatedAt time.Time `json:"createdAt"` + // Last update date of the authentication provider + UpdatedAt time.Time `json:"updatedAt"` + RedirectURI string `json:"redirectURI"` +} + +func (a AuthenticationProviderResponseOIDCConfig) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AuthenticationProviderResponseOIDCConfig) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, []string{"type", "name", "clientID", "clientSecret", "config", "organizationId", "createdAt", "updatedAt", "redirectURI"}); err != nil { + return err + } + return nil +} + +func (a *AuthenticationProviderResponseOIDCConfig) GetType() AuthenticationProviderResponseOIDCConfigType { + if a == nil { + return AuthenticationProviderResponseOIDCConfigType("") + } + return a.Type +} + +func (a *AuthenticationProviderResponseOIDCConfig) GetName() string { + if a == nil { + return "" + } + return a.Name +} + +func (a *AuthenticationProviderResponseOIDCConfig) GetClientID() string { + if a == nil { + return "" + } + return a.ClientID +} + +func (a *AuthenticationProviderResponseOIDCConfig) GetClientSecret() string { + if a == nil { + return "" + } + return a.ClientSecret +} + +func (a *AuthenticationProviderResponseOIDCConfig) GetConfig() AuthenticationProviderResponseOIDCConfigConfig { + if a == nil { + return AuthenticationProviderResponseOIDCConfigConfig{} + } + return a.Config +} + +func (a *AuthenticationProviderResponseOIDCConfig) GetOrganizationID() string { + if a == nil { + return "" + } + return a.OrganizationID +} + +func (a *AuthenticationProviderResponseOIDCConfig) GetCreatedAt() time.Time { + if a == nil { + return time.Time{} + } + return a.CreatedAt +} + +func (a *AuthenticationProviderResponseOIDCConfig) GetUpdatedAt() time.Time { + if a == nil { + return time.Time{} + } + return a.UpdatedAt +} + +func (a *AuthenticationProviderResponseOIDCConfig) GetRedirectURI() string { + if a == nil { + return "" + } + return a.RedirectURI +} + +// AuthenticationProviderResponseGithubIDPConfigType - Type of the authentication provider +type AuthenticationProviderResponseGithubIDPConfigType string + +const ( + AuthenticationProviderResponseGithubIDPConfigTypeOidc AuthenticationProviderResponseGithubIDPConfigType = "oidc" + AuthenticationProviderResponseGithubIDPConfigTypeGoogle AuthenticationProviderResponseGithubIDPConfigType = "google" + AuthenticationProviderResponseGithubIDPConfigTypeGithub AuthenticationProviderResponseGithubIDPConfigType = "github" + AuthenticationProviderResponseGithubIDPConfigTypeMicrosoft AuthenticationProviderResponseGithubIDPConfigType = "microsoft" +) + +func (e AuthenticationProviderResponseGithubIDPConfigType) ToPointer() *AuthenticationProviderResponseGithubIDPConfigType { + return &e +} +func (e *AuthenticationProviderResponseGithubIDPConfigType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "oidc": + fallthrough + case "google": + fallthrough + case "github": + fallthrough + case "microsoft": + *e = AuthenticationProviderResponseGithubIDPConfigType(v) + return nil + default: + return fmt.Errorf("invalid value for AuthenticationProviderResponseGithubIDPConfigType: %v", v) + } +} + +type AuthenticationProviderResponseGithubIDPConfigConfig struct { +} + +func (a AuthenticationProviderResponseGithubIDPConfigConfig) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AuthenticationProviderResponseGithubIDPConfigConfig) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, nil); err != nil { + return err + } + return nil +} + +type AuthenticationProviderResponseGithubIDPConfig struct { + // Type of the authentication provider + Type AuthenticationProviderResponseGithubIDPConfigType `json:"type"` + // Name of the authentication provider + Name string `json:"name"` + // Client ID for the authentication provider + ClientID string `json:"clientID"` + // Client secret for the authentication provider + ClientSecret string `json:"clientSecret"` + Config AuthenticationProviderResponseGithubIDPConfigConfig `json:"config"` + // Unique identifier for the authentication provider + OrganizationID string `json:"organizationId"` + // Creation date of the authentication provider + CreatedAt time.Time `json:"createdAt"` + // Last update date of the authentication provider + UpdatedAt time.Time `json:"updatedAt"` + RedirectURI string `json:"redirectURI"` +} + +func (a AuthenticationProviderResponseGithubIDPConfig) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AuthenticationProviderResponseGithubIDPConfig) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, []string{"type", "name", "clientID", "clientSecret", "config", "organizationId", "createdAt", "updatedAt", "redirectURI"}); err != nil { + return err + } + return nil +} + +func (a *AuthenticationProviderResponseGithubIDPConfig) GetType() AuthenticationProviderResponseGithubIDPConfigType { + if a == nil { + return AuthenticationProviderResponseGithubIDPConfigType("") + } + return a.Type +} + +func (a *AuthenticationProviderResponseGithubIDPConfig) GetName() string { + if a == nil { + return "" + } + return a.Name +} + +func (a *AuthenticationProviderResponseGithubIDPConfig) GetClientID() string { + if a == nil { + return "" + } + return a.ClientID +} + +func (a *AuthenticationProviderResponseGithubIDPConfig) GetClientSecret() string { + if a == nil { + return "" + } + return a.ClientSecret +} + +func (a *AuthenticationProviderResponseGithubIDPConfig) GetConfig() AuthenticationProviderResponseGithubIDPConfigConfig { + if a == nil { + return AuthenticationProviderResponseGithubIDPConfigConfig{} + } + return a.Config +} + +func (a *AuthenticationProviderResponseGithubIDPConfig) GetOrganizationID() string { + if a == nil { + return "" + } + return a.OrganizationID +} + +func (a *AuthenticationProviderResponseGithubIDPConfig) GetCreatedAt() time.Time { + if a == nil { + return time.Time{} + } + return a.CreatedAt +} + +func (a *AuthenticationProviderResponseGithubIDPConfig) GetUpdatedAt() time.Time { + if a == nil { + return time.Time{} + } + return a.UpdatedAt +} + +func (a *AuthenticationProviderResponseGithubIDPConfig) GetRedirectURI() string { + if a == nil { + return "" + } + return a.RedirectURI +} + +// AuthenticationProviderResponseMicrosoftIDPConfigType - Type of the authentication provider +type AuthenticationProviderResponseMicrosoftIDPConfigType string + +const ( + AuthenticationProviderResponseMicrosoftIDPConfigTypeOidc AuthenticationProviderResponseMicrosoftIDPConfigType = "oidc" + AuthenticationProviderResponseMicrosoftIDPConfigTypeGoogle AuthenticationProviderResponseMicrosoftIDPConfigType = "google" + AuthenticationProviderResponseMicrosoftIDPConfigTypeGithub AuthenticationProviderResponseMicrosoftIDPConfigType = "github" + AuthenticationProviderResponseMicrosoftIDPConfigTypeMicrosoft AuthenticationProviderResponseMicrosoftIDPConfigType = "microsoft" +) + +func (e AuthenticationProviderResponseMicrosoftIDPConfigType) ToPointer() *AuthenticationProviderResponseMicrosoftIDPConfigType { + return &e +} +func (e *AuthenticationProviderResponseMicrosoftIDPConfigType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "oidc": + fallthrough + case "google": + fallthrough + case "github": + fallthrough + case "microsoft": + *e = AuthenticationProviderResponseMicrosoftIDPConfigType(v) + return nil + default: + return fmt.Errorf("invalid value for AuthenticationProviderResponseMicrosoftIDPConfigType: %v", v) + } +} + +type AuthenticationProviderResponseMicrosoftIDPConfigConfig struct { + // Tenant ID for Microsoft authentication + Tenant *string `default:"common" json:"tenant"` +} + +func (a AuthenticationProviderResponseMicrosoftIDPConfigConfig) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AuthenticationProviderResponseMicrosoftIDPConfigConfig) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, nil); err != nil { + return err + } + return nil +} + +func (a *AuthenticationProviderResponseMicrosoftIDPConfigConfig) GetTenant() *string { + if a == nil { + return nil + } + return a.Tenant +} + +type AuthenticationProviderResponseMicrosoftIDPConfig struct { + // Type of the authentication provider + Type AuthenticationProviderResponseMicrosoftIDPConfigType `json:"type"` + // Name of the authentication provider + Name string `json:"name"` + // Client ID for the authentication provider + ClientID string `json:"clientID"` + // Client secret for the authentication provider + ClientSecret string `json:"clientSecret"` + Config AuthenticationProviderResponseMicrosoftIDPConfigConfig `json:"config"` + // Unique identifier for the authentication provider + OrganizationID string `json:"organizationId"` + // Creation date of the authentication provider + CreatedAt time.Time `json:"createdAt"` + // Last update date of the authentication provider + UpdatedAt time.Time `json:"updatedAt"` + RedirectURI string `json:"redirectURI"` +} + +func (a AuthenticationProviderResponseMicrosoftIDPConfig) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AuthenticationProviderResponseMicrosoftIDPConfig) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, []string{"type", "name", "clientID", "clientSecret", "config", "organizationId", "createdAt", "updatedAt", "redirectURI"}); err != nil { + return err + } + return nil +} + +func (a *AuthenticationProviderResponseMicrosoftIDPConfig) GetType() AuthenticationProviderResponseMicrosoftIDPConfigType { + if a == nil { + return AuthenticationProviderResponseMicrosoftIDPConfigType("") + } + return a.Type +} + +func (a *AuthenticationProviderResponseMicrosoftIDPConfig) GetName() string { + if a == nil { + return "" + } + return a.Name +} + +func (a *AuthenticationProviderResponseMicrosoftIDPConfig) GetClientID() string { + if a == nil { + return "" + } + return a.ClientID +} + +func (a *AuthenticationProviderResponseMicrosoftIDPConfig) GetClientSecret() string { + if a == nil { + return "" + } + return a.ClientSecret +} + +func (a *AuthenticationProviderResponseMicrosoftIDPConfig) GetConfig() AuthenticationProviderResponseMicrosoftIDPConfigConfig { + if a == nil { + return AuthenticationProviderResponseMicrosoftIDPConfigConfig{} + } + return a.Config +} + +func (a *AuthenticationProviderResponseMicrosoftIDPConfig) GetOrganizationID() string { + if a == nil { + return "" + } + return a.OrganizationID +} + +func (a *AuthenticationProviderResponseMicrosoftIDPConfig) GetCreatedAt() time.Time { + if a == nil { + return time.Time{} + } + return a.CreatedAt +} + +func (a *AuthenticationProviderResponseMicrosoftIDPConfig) GetUpdatedAt() time.Time { + if a == nil { + return time.Time{} + } + return a.UpdatedAt +} + +func (a *AuthenticationProviderResponseMicrosoftIDPConfig) GetRedirectURI() string { + if a == nil { + return "" + } + return a.RedirectURI +} + +// AuthenticationProviderResponseGoogleIDPConfigType - Type of the authentication provider +type AuthenticationProviderResponseGoogleIDPConfigType string + +const ( + AuthenticationProviderResponseGoogleIDPConfigTypeOidc AuthenticationProviderResponseGoogleIDPConfigType = "oidc" + AuthenticationProviderResponseGoogleIDPConfigTypeGoogle AuthenticationProviderResponseGoogleIDPConfigType = "google" + AuthenticationProviderResponseGoogleIDPConfigTypeGithub AuthenticationProviderResponseGoogleIDPConfigType = "github" + AuthenticationProviderResponseGoogleIDPConfigTypeMicrosoft AuthenticationProviderResponseGoogleIDPConfigType = "microsoft" +) + +func (e AuthenticationProviderResponseGoogleIDPConfigType) ToPointer() *AuthenticationProviderResponseGoogleIDPConfigType { + return &e +} +func (e *AuthenticationProviderResponseGoogleIDPConfigType) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "oidc": + fallthrough + case "google": + fallthrough + case "github": + fallthrough + case "microsoft": + *e = AuthenticationProviderResponseGoogleIDPConfigType(v) + return nil + default: + return fmt.Errorf("invalid value for AuthenticationProviderResponseGoogleIDPConfigType: %v", v) + } +} + +type AuthenticationProviderResponseGoogleIDPConfigConfig struct { +} + +func (a AuthenticationProviderResponseGoogleIDPConfigConfig) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AuthenticationProviderResponseGoogleIDPConfigConfig) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, nil); err != nil { + return err + } + return nil +} + +type AuthenticationProviderResponseGoogleIDPConfig struct { + // Type of the authentication provider + Type AuthenticationProviderResponseGoogleIDPConfigType `json:"type"` + // Name of the authentication provider + Name string `json:"name"` + // Client ID for the authentication provider + ClientID string `json:"clientID"` + // Client secret for the authentication provider + ClientSecret string `json:"clientSecret"` + Config AuthenticationProviderResponseGoogleIDPConfigConfig `json:"config"` + // Unique identifier for the authentication provider + OrganizationID string `json:"organizationId"` + // Creation date of the authentication provider + CreatedAt time.Time `json:"createdAt"` + // Last update date of the authentication provider + UpdatedAt time.Time `json:"updatedAt"` + RedirectURI string `json:"redirectURI"` +} + +func (a AuthenticationProviderResponseGoogleIDPConfig) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AuthenticationProviderResponseGoogleIDPConfig) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, []string{"type", "name", "clientID", "clientSecret", "config", "organizationId", "createdAt", "updatedAt", "redirectURI"}); err != nil { + return err + } + return nil +} + +func (a *AuthenticationProviderResponseGoogleIDPConfig) GetType() AuthenticationProviderResponseGoogleIDPConfigType { + if a == nil { + return AuthenticationProviderResponseGoogleIDPConfigType("") + } + return a.Type +} + +func (a *AuthenticationProviderResponseGoogleIDPConfig) GetName() string { + if a == nil { + return "" + } + return a.Name +} + +func (a *AuthenticationProviderResponseGoogleIDPConfig) GetClientID() string { + if a == nil { + return "" + } + return a.ClientID +} + +func (a *AuthenticationProviderResponseGoogleIDPConfig) GetClientSecret() string { + if a == nil { + return "" + } + return a.ClientSecret +} + +func (a *AuthenticationProviderResponseGoogleIDPConfig) GetConfig() AuthenticationProviderResponseGoogleIDPConfigConfig { + if a == nil { + return AuthenticationProviderResponseGoogleIDPConfigConfig{} + } + return a.Config +} + +func (a *AuthenticationProviderResponseGoogleIDPConfig) GetOrganizationID() string { + if a == nil { + return "" + } + return a.OrganizationID +} + +func (a *AuthenticationProviderResponseGoogleIDPConfig) GetCreatedAt() time.Time { + if a == nil { + return time.Time{} + } + return a.CreatedAt +} + +func (a *AuthenticationProviderResponseGoogleIDPConfig) GetUpdatedAt() time.Time { + if a == nil { + return time.Time{} + } + return a.UpdatedAt +} + +func (a *AuthenticationProviderResponseGoogleIDPConfig) GetRedirectURI() string { + if a == nil { + return "" + } + return a.RedirectURI +} + +type DataType string + +const ( + DataTypeAuthenticationProviderResponseGoogleIDPConfig DataType = "AuthenticationProviderResponse_GoogleIDPConfig" + DataTypeAuthenticationProviderResponseMicrosoftIDPConfig DataType = "AuthenticationProviderResponse_MicrosoftIDPConfig" + DataTypeAuthenticationProviderResponseGithubIDPConfig DataType = "AuthenticationProviderResponse_GithubIDPConfig" + DataTypeAuthenticationProviderResponseOIDCConfig DataType = "AuthenticationProviderResponse_OIDCConfig" +) + +type Data struct { + AuthenticationProviderResponseGoogleIDPConfig *AuthenticationProviderResponseGoogleIDPConfig `queryParam:"inline,name=data"` + AuthenticationProviderResponseMicrosoftIDPConfig *AuthenticationProviderResponseMicrosoftIDPConfig `queryParam:"inline,name=data"` + AuthenticationProviderResponseGithubIDPConfig *AuthenticationProviderResponseGithubIDPConfig `queryParam:"inline,name=data"` + AuthenticationProviderResponseOIDCConfig *AuthenticationProviderResponseOIDCConfig `queryParam:"inline,name=data"` + + Type DataType +} + +func CreateDataAuthenticationProviderResponseGoogleIDPConfig(authenticationProviderResponseGoogleIDPConfig AuthenticationProviderResponseGoogleIDPConfig) Data { + typ := DataTypeAuthenticationProviderResponseGoogleIDPConfig + + return Data{ + AuthenticationProviderResponseGoogleIDPConfig: &authenticationProviderResponseGoogleIDPConfig, + Type: typ, + } +} + +func CreateDataAuthenticationProviderResponseMicrosoftIDPConfig(authenticationProviderResponseMicrosoftIDPConfig AuthenticationProviderResponseMicrosoftIDPConfig) Data { + typ := DataTypeAuthenticationProviderResponseMicrosoftIDPConfig + + return Data{ + AuthenticationProviderResponseMicrosoftIDPConfig: &authenticationProviderResponseMicrosoftIDPConfig, + Type: typ, + } +} + +func CreateDataAuthenticationProviderResponseGithubIDPConfig(authenticationProviderResponseGithubIDPConfig AuthenticationProviderResponseGithubIDPConfig) Data { + typ := DataTypeAuthenticationProviderResponseGithubIDPConfig + + return Data{ + AuthenticationProviderResponseGithubIDPConfig: &authenticationProviderResponseGithubIDPConfig, + Type: typ, + } +} + +func CreateDataAuthenticationProviderResponseOIDCConfig(authenticationProviderResponseOIDCConfig AuthenticationProviderResponseOIDCConfig) Data { + typ := DataTypeAuthenticationProviderResponseOIDCConfig + + return Data{ + AuthenticationProviderResponseOIDCConfig: &authenticationProviderResponseOIDCConfig, + Type: typ, + } +} + +func (u *Data) UnmarshalJSON(data []byte) error { + + var authenticationProviderResponseGoogleIDPConfig AuthenticationProviderResponseGoogleIDPConfig = AuthenticationProviderResponseGoogleIDPConfig{} + if err := utils.UnmarshalJSON(data, &authenticationProviderResponseGoogleIDPConfig, "", true, nil); err == nil { + u.AuthenticationProviderResponseGoogleIDPConfig = &authenticationProviderResponseGoogleIDPConfig + u.Type = DataTypeAuthenticationProviderResponseGoogleIDPConfig + return nil + } + + var authenticationProviderResponseMicrosoftIDPConfig AuthenticationProviderResponseMicrosoftIDPConfig = AuthenticationProviderResponseMicrosoftIDPConfig{} + if err := utils.UnmarshalJSON(data, &authenticationProviderResponseMicrosoftIDPConfig, "", true, nil); err == nil { + u.AuthenticationProviderResponseMicrosoftIDPConfig = &authenticationProviderResponseMicrosoftIDPConfig + u.Type = DataTypeAuthenticationProviderResponseMicrosoftIDPConfig + return nil + } + + var authenticationProviderResponseGithubIDPConfig AuthenticationProviderResponseGithubIDPConfig = AuthenticationProviderResponseGithubIDPConfig{} + if err := utils.UnmarshalJSON(data, &authenticationProviderResponseGithubIDPConfig, "", true, nil); err == nil { + u.AuthenticationProviderResponseGithubIDPConfig = &authenticationProviderResponseGithubIDPConfig + u.Type = DataTypeAuthenticationProviderResponseGithubIDPConfig + return nil + } + + var authenticationProviderResponseOIDCConfig AuthenticationProviderResponseOIDCConfig = AuthenticationProviderResponseOIDCConfig{} + if err := utils.UnmarshalJSON(data, &authenticationProviderResponseOIDCConfig, "", true, nil); err == nil { + u.AuthenticationProviderResponseOIDCConfig = &authenticationProviderResponseOIDCConfig + u.Type = DataTypeAuthenticationProviderResponseOIDCConfig + return nil + } + + return fmt.Errorf("could not unmarshal `%s` into any supported union types for Data", string(data)) +} + +func (u Data) MarshalJSON() ([]byte, error) { + if u.AuthenticationProviderResponseGoogleIDPConfig != nil { + return utils.MarshalJSON(u.AuthenticationProviderResponseGoogleIDPConfig, "", true) + } + + if u.AuthenticationProviderResponseMicrosoftIDPConfig != nil { + return utils.MarshalJSON(u.AuthenticationProviderResponseMicrosoftIDPConfig, "", true) + } + + if u.AuthenticationProviderResponseGithubIDPConfig != nil { + return utils.MarshalJSON(u.AuthenticationProviderResponseGithubIDPConfig, "", true) + } + + if u.AuthenticationProviderResponseOIDCConfig != nil { + return utils.MarshalJSON(u.AuthenticationProviderResponseOIDCConfig, "", true) + } + + return nil, errors.New("could not marshal union type Data: all fields are null") +} + +type AuthenticationProviderResponse struct { + Data *Data `json:"data,omitzero"` +} + +func (a *AuthenticationProviderResponse) GetData() *Data { + if a == nil { + return nil + } + return a.Data +} diff --git a/internal/membershipclient/models/components/capability.go b/internal/membershipclient/models/components/capability.go new file mode 100644 index 00000000..3ebfc59f --- /dev/null +++ b/internal/membershipclient/models/components/capability.go @@ -0,0 +1,31 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "encoding/json" + "fmt" +) + +type Capability string + +const ( + CapabilityModuleSelection Capability = "MODULE_SELECTION" +) + +func (e Capability) ToPointer() *Capability { + return &e +} +func (e *Capability) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "MODULE_SELECTION": + *e = Capability(v) + return nil + default: + return fmt.Errorf("invalid value for Capability: %v", v) + } +} diff --git a/internal/membershipclient/models/components/createapplicationresponse.go b/internal/membershipclient/models/components/createapplicationresponse.go new file mode 100644 index 00000000..b930e047 --- /dev/null +++ b/internal/membershipclient/models/components/createapplicationresponse.go @@ -0,0 +1,29 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type CreateApplicationResponse struct { + Data *Application `json:"data,omitzero"` +} + +func (c CreateApplicationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreateApplicationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, nil); err != nil { + return err + } + return nil +} + +func (c *CreateApplicationResponse) GetData() *Application { + if c == nil { + return nil + } + return c.Data +} diff --git a/internal/membershipclient/models/components/createapplicationscoperequest.go b/internal/membershipclient/models/components/createapplicationscoperequest.go new file mode 100644 index 00000000..e2917d61 --- /dev/null +++ b/internal/membershipclient/models/components/createapplicationscoperequest.go @@ -0,0 +1,24 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type CreateApplicationScopeRequest struct { + // Scope description + Description *string `json:"description,omitzero"` + // The OAuth2 scope label (e.g., "custom:read") + Label string `json:"label"` +} + +func (c *CreateApplicationScopeRequest) GetDescription() *string { + if c == nil { + return nil + } + return c.Description +} + +func (c *CreateApplicationScopeRequest) GetLabel() string { + if c == nil { + return "" + } + return c.Label +} diff --git a/internal/membershipclient/models/components/createapplicationscoperesponse.go b/internal/membershipclient/models/components/createapplicationscoperesponse.go new file mode 100644 index 00000000..4c3912de --- /dev/null +++ b/internal/membershipclient/models/components/createapplicationscoperesponse.go @@ -0,0 +1,29 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type CreateApplicationScopeResponse struct { + Data *Scope `json:"data,omitzero"` +} + +func (c CreateApplicationScopeResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreateApplicationScopeResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, nil); err != nil { + return err + } + return nil +} + +func (c *CreateApplicationScopeResponse) GetData() *Scope { + if c == nil { + return nil + } + return c.Data +} diff --git a/internal/membershipclient/models/components/createclientresponseresponse.go b/internal/membershipclient/models/components/createclientresponseresponse.go new file mode 100644 index 00000000..99cff175 --- /dev/null +++ b/internal/membershipclient/models/components/createclientresponseresponse.go @@ -0,0 +1,123 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "time" +) + +type CreateClientResponseResponseSecret struct { + LastDigits string `json:"lastDigits"` + Clear *string `json:"clear,omitzero"` +} + +func (c *CreateClientResponseResponseSecret) GetLastDigits() string { + if c == nil { + return "" + } + return c.LastDigits +} + +func (c *CreateClientResponseResponseSecret) GetClear() *string { + if c == nil { + return nil + } + return c.Clear +} + +type CreateClientResponseResponseData struct { + // Organization ID + ID string `json:"id"` + Secret CreateClientResponseResponseSecret `json:"secret"` + // Name of the client + Name string `json:"name"` + // Description of the client + Description string `json:"description"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` + // The ID of the owner of the client (DEPRECATED will be empty) + OwnerID string `json:"ownerId"` +} + +func (c CreateClientResponseResponseData) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreateClientResponseResponseData) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, []string{"id", "secret", "name", "description", "createdAt", "updatedAt", "ownerId"}); err != nil { + return err + } + return nil +} + +func (c *CreateClientResponseResponseData) GetID() string { + if c == nil { + return "" + } + return c.ID +} + +func (c *CreateClientResponseResponseData) GetSecret() CreateClientResponseResponseSecret { + if c == nil { + return CreateClientResponseResponseSecret{} + } + return c.Secret +} + +func (c *CreateClientResponseResponseData) GetName() string { + if c == nil { + return "" + } + return c.Name +} + +func (c *CreateClientResponseResponseData) GetDescription() string { + if c == nil { + return "" + } + return c.Description +} + +func (c *CreateClientResponseResponseData) GetCreatedAt() time.Time { + if c == nil { + return time.Time{} + } + return c.CreatedAt +} + +func (c *CreateClientResponseResponseData) GetUpdatedAt() time.Time { + if c == nil { + return time.Time{} + } + return c.UpdatedAt +} + +func (c *CreateClientResponseResponseData) GetOwnerID() string { + if c == nil { + return "" + } + return c.OwnerID +} + +type CreateClientResponseResponse struct { + Data *CreateClientResponseResponseData `json:"data,omitzero"` +} + +func (c CreateClientResponseResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreateClientResponseResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, nil); err != nil { + return err + } + return nil +} + +func (c *CreateClientResponseResponse) GetData() *CreateClientResponseResponseData { + if c == nil { + return nil + } + return c.Data +} diff --git a/internal/membershipclient/models/components/createdprivateregionresponse.go b/internal/membershipclient/models/components/createdprivateregionresponse.go new file mode 100644 index 00000000..c678f954 --- /dev/null +++ b/internal/membershipclient/models/components/createdprivateregionresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type CreatedPrivateRegionResponse struct { + Data PrivateRegion `json:"data"` +} + +func (c *CreatedPrivateRegionResponse) GetData() PrivateRegion { + if c == nil { + return PrivateRegion{} + } + return c.Data +} diff --git a/internal/membershipclient/models/components/createinvitationresponse.go b/internal/membershipclient/models/components/createinvitationresponse.go new file mode 100644 index 00000000..15d3c2f4 --- /dev/null +++ b/internal/membershipclient/models/components/createinvitationresponse.go @@ -0,0 +1,29 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type CreateInvitationResponse struct { + Data *Invitation `json:"data,omitzero"` +} + +func (c CreateInvitationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreateInvitationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, nil); err != nil { + return err + } + return nil +} + +func (c *CreateInvitationResponse) GetData() *Invitation { + if c == nil { + return nil + } + return c.Data +} diff --git a/internal/membershipclient/models/components/createorganizationclientrequest.go b/internal/membershipclient/models/components/createorganizationclientrequest.go new file mode 100644 index 00000000..d301132c --- /dev/null +++ b/internal/membershipclient/models/components/createorganizationclientrequest.go @@ -0,0 +1,24 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type CreateOrganizationClientRequest struct { + // Name of the client + Name *string `json:"name,omitzero"` + // Description of the client + Description *string `json:"description,omitzero"` +} + +func (c *CreateOrganizationClientRequest) GetName() *string { + if c == nil { + return nil + } + return c.Name +} + +func (c *CreateOrganizationClientRequest) GetDescription() *string { + if c == nil { + return nil + } + return c.Description +} diff --git a/internal/membershipclient/models/components/createorganizationclientresponse.go b/internal/membershipclient/models/components/createorganizationclientresponse.go new file mode 100644 index 00000000..0d82449f --- /dev/null +++ b/internal/membershipclient/models/components/createorganizationclientresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type CreateOrganizationClientResponse struct { + Data OrganizationClient `json:"data"` +} + +func (c *CreateOrganizationClientResponse) GetData() OrganizationClient { + if c == nil { + return OrganizationClient{} + } + return c.Data +} diff --git a/internal/membershipclient/models/components/createorganizationrequest.go b/internal/membershipclient/models/components/createorganizationrequest.go new file mode 100644 index 00000000..71acd60d --- /dev/null +++ b/internal/membershipclient/models/components/createorganizationrequest.go @@ -0,0 +1,42 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type CreateOrganizationRequest struct { + // Organization name + Name string `json:"name"` + // Organization domain + Domain *string `json:"domain,omitzero"` + // Default policy ID applied to new users + DefaultPolicyID *int64 `json:"defaultPolicyID,omitzero"` + // User ID of the owner of the organization (only when used with a non user agent) + OwnerID *string `json:"ownerID,omitzero"` +} + +func (c *CreateOrganizationRequest) GetName() string { + if c == nil { + return "" + } + return c.Name +} + +func (c *CreateOrganizationRequest) GetDomain() *string { + if c == nil { + return nil + } + return c.Domain +} + +func (c *CreateOrganizationRequest) GetDefaultPolicyID() *int64 { + if c == nil { + return nil + } + return c.DefaultPolicyID +} + +func (c *CreateOrganizationRequest) GetOwnerID() *string { + if c == nil { + return nil + } + return c.OwnerID +} diff --git a/internal/membershipclient/models/components/createorganizationresponse.go b/internal/membershipclient/models/components/createorganizationresponse.go new file mode 100644 index 00000000..f2767355 --- /dev/null +++ b/internal/membershipclient/models/components/createorganizationresponse.go @@ -0,0 +1,29 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type CreateOrganizationResponse struct { + Data *OrganizationExpanded `json:"data,omitzero"` +} + +func (c CreateOrganizationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreateOrganizationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, nil); err != nil { + return err + } + return nil +} + +func (c *CreateOrganizationResponse) GetData() *OrganizationExpanded { + if c == nil { + return nil + } + return c.Data +} diff --git a/internal/membershipclient/models/components/createpolicyresponse.go b/internal/membershipclient/models/components/createpolicyresponse.go new file mode 100644 index 00000000..f4ef7198 --- /dev/null +++ b/internal/membershipclient/models/components/createpolicyresponse.go @@ -0,0 +1,29 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type CreatePolicyResponse struct { + Data *Policy `json:"data,omitzero"` +} + +func (c CreatePolicyResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreatePolicyResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, nil); err != nil { + return err + } + return nil +} + +func (c *CreatePolicyResponse) GetData() *Policy { + if c == nil { + return nil + } + return c.Data +} diff --git a/internal/membershipclient/models/components/createprivateregionrequest.go b/internal/membershipclient/models/components/createprivateregionrequest.go new file mode 100644 index 00000000..3d3ab8b9 --- /dev/null +++ b/internal/membershipclient/models/components/createprivateregionrequest.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type CreatePrivateRegionRequest struct { + Name string `json:"name"` +} + +func (c *CreatePrivateRegionRequest) GetName() string { + if c == nil { + return "" + } + return c.Name +} diff --git a/internal/membershipclient/models/components/createstackrequest.go b/internal/membershipclient/models/components/createstackrequest.go new file mode 100644 index 00000000..ca8aa48c --- /dev/null +++ b/internal/membershipclient/models/components/createstackrequest.go @@ -0,0 +1,55 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type CreateStackRequest struct { + // Stack name + Name string `json:"name"` + Metadata map[string]string `json:"metadata,omitzero"` + // Supported only with agent version >= v0.7.0 + Version *string `json:"version,omitzero"` + RegionID string `json:"regionID"` +} + +func (c CreateStackRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreateStackRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, []string{"name", "regionID"}); err != nil { + return err + } + return nil +} + +func (c *CreateStackRequest) GetName() string { + if c == nil { + return "" + } + return c.Name +} + +func (c *CreateStackRequest) GetMetadata() map[string]string { + if c == nil { + return nil + } + return c.Metadata +} + +func (c *CreateStackRequest) GetVersion() *string { + if c == nil { + return nil + } + return c.Version +} + +func (c *CreateStackRequest) GetRegionID() string { + if c == nil { + return "" + } + return c.RegionID +} diff --git a/internal/membershipclient/models/components/createstackresponse.go b/internal/membershipclient/models/components/createstackresponse.go new file mode 100644 index 00000000..946ecd77 --- /dev/null +++ b/internal/membershipclient/models/components/createstackresponse.go @@ -0,0 +1,29 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type CreateStackResponse struct { + Data *Stack `json:"data,omitzero"` +} + +func (c CreateStackResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreateStackResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, nil); err != nil { + return err + } + return nil +} + +func (c *CreateStackResponse) GetData() *Stack { + if c == nil { + return nil + } + return c.Data +} diff --git a/internal/membershipclient/models/components/createuserrequest.go b/internal/membershipclient/models/components/createuserrequest.go new file mode 100644 index 00000000..82ad0b40 --- /dev/null +++ b/internal/membershipclient/models/components/createuserrequest.go @@ -0,0 +1,15 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type CreateUserRequest struct { + // Email address of the user to create + Email string `json:"email"` +} + +func (c *CreateUserRequest) GetEmail() string { + if c == nil { + return "" + } + return c.Email +} diff --git a/internal/membershipclient/models/components/createuserresponse.go b/internal/membershipclient/models/components/createuserresponse.go new file mode 100644 index 00000000..808210df --- /dev/null +++ b/internal/membershipclient/models/components/createuserresponse.go @@ -0,0 +1,29 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type CreateUserResponse struct { + Data *User `json:"data,omitzero"` +} + +func (c CreateUserResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreateUserResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, nil); err != nil { + return err + } + return nil +} + +func (c *CreateUserResponse) GetData() *User { + if c == nil { + return nil + } + return c.Data +} diff --git a/internal/membershipclient/models/components/enableapplicationfororganizationresponse.go b/internal/membershipclient/models/components/enableapplicationfororganizationresponse.go new file mode 100644 index 00000000..310e178d --- /dev/null +++ b/internal/membershipclient/models/components/enableapplicationfororganizationresponse.go @@ -0,0 +1,29 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type EnableApplicationForOrganizationResponse struct { + Data *OrganizationApplication `json:"data,omitzero"` +} + +func (e EnableApplicationForOrganizationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(e, "", false) +} + +func (e *EnableApplicationForOrganizationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &e, "", false, nil); err != nil { + return err + } + return nil +} + +func (e *EnableApplicationForOrganizationResponse) GetData() *OrganizationApplication { + if e == nil { + return nil + } + return e.Data +} diff --git a/internal/membershipclient/models/components/error.go b/internal/membershipclient/models/components/error.go new file mode 100644 index 00000000..12883beb --- /dev/null +++ b/internal/membershipclient/models/components/error.go @@ -0,0 +1,22 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type Error struct { + ErrorCode string `json:"errorCode"` + ErrorMessage *string `json:"errorMessage,omitzero"` +} + +func (e *Error) GetErrorCode() string { + if e == nil { + return "" + } + return e.ErrorCode +} + +func (e *Error) GetErrorMessage() *string { + if e == nil { + return nil + } + return e.ErrorMessage +} diff --git a/internal/membershipclient/models/components/getapplicationresponse.go b/internal/membershipclient/models/components/getapplicationresponse.go new file mode 100644 index 00000000..9bbfe1c5 --- /dev/null +++ b/internal/membershipclient/models/components/getapplicationresponse.go @@ -0,0 +1,29 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type GetApplicationResponse struct { + Data *ApplicationWithScope `json:"data,omitzero"` +} + +func (g GetApplicationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(g, "", false) +} + +func (g *GetApplicationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &g, "", false, nil); err != nil { + return err + } + return nil +} + +func (g *GetApplicationResponse) GetData() *ApplicationWithScope { + if g == nil { + return nil + } + return g.Data +} diff --git a/internal/membershipclient/models/components/getregionresponse.go b/internal/membershipclient/models/components/getregionresponse.go new file mode 100644 index 00000000..357ae586 --- /dev/null +++ b/internal/membershipclient/models/components/getregionresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type GetRegionResponse struct { + Data AnyRegion `json:"data"` +} + +func (g *GetRegionResponse) GetData() AnyRegion { + if g == nil { + return AnyRegion{} + } + return g.Data +} diff --git a/internal/membershipclient/models/components/getregionversionsresponse.go b/internal/membershipclient/models/components/getregionversionsresponse.go new file mode 100644 index 00000000..ec7e1e9b --- /dev/null +++ b/internal/membershipclient/models/components/getregionversionsresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type GetRegionVersionsResponse struct { + Data []Version `json:"data"` +} + +func (g *GetRegionVersionsResponse) GetData() []Version { + if g == nil { + return []Version{} + } + return g.Data +} diff --git a/internal/membershipclient/models/components/httpmetadata.go b/internal/membershipclient/models/components/httpmetadata.go new file mode 100644 index 00000000..148ec47f --- /dev/null +++ b/internal/membershipclient/models/components/httpmetadata.go @@ -0,0 +1,28 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "net/http" +) + +type HTTPMetadata struct { + // Raw HTTP response; suitable for custom response parsing + Response *http.Response `json:"-"` + // Raw HTTP request; suitable for debugging + Request *http.Request `json:"-"` +} + +func (h *HTTPMetadata) GetResponse() *http.Response { + if h == nil { + return nil + } + return h.Response +} + +func (h *HTTPMetadata) GetRequest() *http.Request { + if h == nil { + return nil + } + return h.Request +} diff --git a/internal/membershipclient/models/components/invitation.go b/internal/membershipclient/models/components/invitation.go new file mode 100644 index 00000000..0038d9c7 --- /dev/null +++ b/internal/membershipclient/models/components/invitation.go @@ -0,0 +1,172 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "encoding/json" + "fmt" + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "time" +) + +type InvitationStatus string + +const ( + InvitationStatusPending InvitationStatus = "PENDING" + InvitationStatusAccepted InvitationStatus = "ACCEPTED" + InvitationStatusRejected InvitationStatus = "REJECTED" + InvitationStatusCancelled InvitationStatus = "CANCELLED" +) + +func (e InvitationStatus) ToPointer() *InvitationStatus { + return &e +} +func (e *InvitationStatus) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "PENDING": + fallthrough + case "ACCEPTED": + fallthrough + case "REJECTED": + fallthrough + case "CANCELLED": + *e = InvitationStatus(v) + return nil + default: + return fmt.Errorf("invalid value for InvitationStatus: %v", v) + } +} + +type OrganizationAccess struct { + Email string `json:"email"` + ID string `json:"id"` + // Policy ID applied to the user + PolicyID int64 `json:"policyId"` +} + +func (o *OrganizationAccess) GetEmail() string { + if o == nil { + return "" + } + return o.Email +} + +func (o *OrganizationAccess) GetID() string { + if o == nil { + return "" + } + return o.ID +} + +func (o *OrganizationAccess) GetPolicyID() int64 { + if o == nil { + return 0 + } + return o.PolicyID +} + +type Invitation struct { + ID string `json:"id"` + OrganizationID string `json:"organizationId"` + UserEmail string `json:"userEmail"` + Status InvitationStatus `json:"status"` + CreationDate time.Time `json:"creationDate"` + UpdatedAt *string `json:"updatedAt,omitzero"` + UserID *string `json:"userId,omitzero"` + OrganizationAccess *OrganizationAccess `json:"organizationAccess,omitzero"` + ExpiresAt *time.Time `json:"expiresAt,omitzero"` + CreatorID *string `json:"creatorId,omitzero"` + LastUpdate *time.Time `json:"lastUpdate,omitzero"` +} + +func (i Invitation) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(i, "", false) +} + +func (i *Invitation) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &i, "", false, []string{"id", "organizationId", "userEmail", "status", "creationDate"}); err != nil { + return err + } + return nil +} + +func (i *Invitation) GetID() string { + if i == nil { + return "" + } + return i.ID +} + +func (i *Invitation) GetOrganizationID() string { + if i == nil { + return "" + } + return i.OrganizationID +} + +func (i *Invitation) GetUserEmail() string { + if i == nil { + return "" + } + return i.UserEmail +} + +func (i *Invitation) GetStatus() InvitationStatus { + if i == nil { + return InvitationStatus("") + } + return i.Status +} + +func (i *Invitation) GetCreationDate() time.Time { + if i == nil { + return time.Time{} + } + return i.CreationDate +} + +func (i *Invitation) GetUpdatedAt() *string { + if i == nil { + return nil + } + return i.UpdatedAt +} + +func (i *Invitation) GetUserID() *string { + if i == nil { + return nil + } + return i.UserID +} + +func (i *Invitation) GetOrganizationAccess() *OrganizationAccess { + if i == nil { + return nil + } + return i.OrganizationAccess +} + +func (i *Invitation) GetExpiresAt() *time.Time { + if i == nil { + return nil + } + return i.ExpiresAt +} + +func (i *Invitation) GetCreatorID() *string { + if i == nil { + return nil + } + return i.CreatorID +} + +func (i *Invitation) GetLastUpdate() *time.Time { + if i == nil { + return nil + } + return i.LastUpdate +} diff --git a/internal/membershipclient/models/components/listapplicationsresponse.go b/internal/membershipclient/models/components/listapplicationsresponse.go new file mode 100644 index 00000000..986065d8 --- /dev/null +++ b/internal/membershipclient/models/components/listapplicationsresponse.go @@ -0,0 +1,72 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type Cursor struct { + PageSize int64 `json:"pageSize"` + HasMore bool `json:"hasMore"` + Previous *string `json:"previous,omitzero"` + Next *string `json:"next,omitzero"` + Data []Application `json:"data"` +} + +func (c *Cursor) GetPageSize() int64 { + if c == nil { + return 0 + } + return c.PageSize +} + +func (c *Cursor) GetHasMore() bool { + if c == nil { + return false + } + return c.HasMore +} + +func (c *Cursor) GetPrevious() *string { + if c == nil { + return nil + } + return c.Previous +} + +func (c *Cursor) GetNext() *string { + if c == nil { + return nil + } + return c.Next +} + +func (c *Cursor) GetData() []Application { + if c == nil { + return []Application{} + } + return c.Data +} + +type ListApplicationsResponse struct { + Cursor *Cursor `json:"cursor,omitzero"` +} + +func (l ListApplicationsResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListApplicationsResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, nil); err != nil { + return err + } + return nil +} + +func (l *ListApplicationsResponse) GetCursor() *Cursor { + if l == nil { + return nil + } + return l.Cursor +} diff --git a/internal/membershipclient/models/components/listinvitationsresponse.go b/internal/membershipclient/models/components/listinvitationsresponse.go new file mode 100644 index 00000000..86987aa9 --- /dev/null +++ b/internal/membershipclient/models/components/listinvitationsresponse.go @@ -0,0 +1,29 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type ListInvitationsResponse struct { + Data []Invitation `json:"data,omitzero"` +} + +func (l ListInvitationsResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListInvitationsResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, nil); err != nil { + return err + } + return nil +} + +func (l *ListInvitationsResponse) GetData() []Invitation { + if l == nil { + return nil + } + return l.Data +} diff --git a/internal/membershipclient/models/components/listmodulesresponse.go b/internal/membershipclient/models/components/listmodulesresponse.go new file mode 100644 index 00000000..abea7bed --- /dev/null +++ b/internal/membershipclient/models/components/listmodulesresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type ListModulesResponse struct { + Data []Module `json:"data"` +} + +func (l *ListModulesResponse) GetData() []Module { + if l == nil { + return []Module{} + } + return l.Data +} diff --git a/internal/membershipclient/models/components/listorganizationexpandedresponse.go b/internal/membershipclient/models/components/listorganizationexpandedresponse.go new file mode 100644 index 00000000..4d133127 --- /dev/null +++ b/internal/membershipclient/models/components/listorganizationexpandedresponse.go @@ -0,0 +1,29 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type ListOrganizationExpandedResponse struct { + Data []OrganizationExpanded `json:"data,omitzero"` +} + +func (l ListOrganizationExpandedResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListOrganizationExpandedResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, nil); err != nil { + return err + } + return nil +} + +func (l *ListOrganizationExpandedResponse) GetData() []OrganizationExpanded { + if l == nil { + return nil + } + return l.Data +} diff --git a/internal/membershipclient/models/components/listpoliciesresponse.go b/internal/membershipclient/models/components/listpoliciesresponse.go new file mode 100644 index 00000000..ad5df247 --- /dev/null +++ b/internal/membershipclient/models/components/listpoliciesresponse.go @@ -0,0 +1,29 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type ListPoliciesResponse struct { + Data []Policy `json:"data,omitzero"` +} + +func (l ListPoliciesResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListPoliciesResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, nil); err != nil { + return err + } + return nil +} + +func (l *ListPoliciesResponse) GetData() []Policy { + if l == nil { + return nil + } + return l.Data +} diff --git a/internal/membershipclient/models/components/listregionsresponse.go b/internal/membershipclient/models/components/listregionsresponse.go new file mode 100644 index 00000000..fd19e9a5 --- /dev/null +++ b/internal/membershipclient/models/components/listregionsresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type ListRegionsResponse struct { + Data []AnyRegion `json:"data"` +} + +func (l *ListRegionsResponse) GetData() []AnyRegion { + if l == nil { + return []AnyRegion{} + } + return l.Data +} diff --git a/internal/membershipclient/models/components/liststacksresponse.go b/internal/membershipclient/models/components/liststacksresponse.go new file mode 100644 index 00000000..c9e6f47f --- /dev/null +++ b/internal/membershipclient/models/components/liststacksresponse.go @@ -0,0 +1,29 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type ListStacksResponse struct { + Data []Stack `json:"data,omitzero"` +} + +func (l ListStacksResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListStacksResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, nil); err != nil { + return err + } + return nil +} + +func (l *ListStacksResponse) GetData() []Stack { + if l == nil { + return nil + } + return l.Data +} diff --git a/internal/membershipclient/models/components/listusersresponse.go b/internal/membershipclient/models/components/listusersresponse.go new file mode 100644 index 00000000..3abf1fd5 --- /dev/null +++ b/internal/membershipclient/models/components/listusersresponse.go @@ -0,0 +1,57 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type OrganizationUser struct { + Email string `json:"email"` + ID string `json:"id"` + // Policy ID applied to the user + PolicyID int64 `json:"policyId"` +} + +func (o *OrganizationUser) GetEmail() string { + if o == nil { + return "" + } + return o.Email +} + +func (o *OrganizationUser) GetID() string { + if o == nil { + return "" + } + return o.ID +} + +func (o *OrganizationUser) GetPolicyID() int64 { + if o == nil { + return 0 + } + return o.PolicyID +} + +type ListUsersResponse struct { + Data []OrganizationUser `json:"data,omitzero"` +} + +func (l ListUsersResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListUsersResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, nil); err != nil { + return err + } + return nil +} + +func (l *ListUsersResponse) GetData() []OrganizationUser { + if l == nil { + return nil + } + return l.Data +} diff --git a/internal/membershipclient/models/components/log.go b/internal/membershipclient/models/components/log.go new file mode 100644 index 00000000..0bb68438 --- /dev/null +++ b/internal/membershipclient/models/components/log.go @@ -0,0 +1,73 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "time" +) + +type LogData struct { +} + +type Log struct { + Seq string `json:"seq"` + OrganizationID string `json:"organizationId"` + UserID string `json:"userId"` + Action string `json:"action"` + Date time.Time `json:"date"` + Data LogData `json:"data"` +} + +func (l Log) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *Log) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, []string{"seq", "organizationId", "userId", "action", "date", "data"}); err != nil { + return err + } + return nil +} + +func (l *Log) GetSeq() string { + if l == nil { + return "" + } + return l.Seq +} + +func (l *Log) GetOrganizationID() string { + if l == nil { + return "" + } + return l.OrganizationID +} + +func (l *Log) GetUserID() string { + if l == nil { + return "" + } + return l.UserID +} + +func (l *Log) GetAction() string { + if l == nil { + return "" + } + return l.Action +} + +func (l *Log) GetDate() time.Time { + if l == nil { + return time.Time{} + } + return l.Date +} + +func (l *Log) GetData() LogData { + if l == nil { + return LogData{} + } + return l.Data +} diff --git a/internal/membershipclient/models/components/logcursor.go b/internal/membershipclient/models/components/logcursor.go new file mode 100644 index 00000000..1394bcd0 --- /dev/null +++ b/internal/membershipclient/models/components/logcursor.go @@ -0,0 +1,57 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type LogCursorData struct { + PageSize int64 `json:"pageSize"` + HasMore bool `json:"hasMore"` + Previous *string `json:"previous,omitzero"` + Next *string `json:"next,omitzero"` + Data []Log `json:"data"` +} + +func (l *LogCursorData) GetPageSize() int64 { + if l == nil { + return 0 + } + return l.PageSize +} + +func (l *LogCursorData) GetHasMore() bool { + if l == nil { + return false + } + return l.HasMore +} + +func (l *LogCursorData) GetPrevious() *string { + if l == nil { + return nil + } + return l.Previous +} + +func (l *LogCursorData) GetNext() *string { + if l == nil { + return nil + } + return l.Next +} + +func (l *LogCursorData) GetData() []Log { + if l == nil { + return []Log{} + } + return l.Data +} + +type LogCursor struct { + Data LogCursorData `json:"data"` +} + +func (l *LogCursor) GetData() LogCursorData { + if l == nil { + return LogCursorData{} + } + return l.Data +} diff --git a/internal/membershipclient/models/components/module.go b/internal/membershipclient/models/components/module.go new file mode 100644 index 00000000..6f4c803e --- /dev/null +++ b/internal/membershipclient/models/components/module.go @@ -0,0 +1,133 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "encoding/json" + "fmt" + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "time" +) + +type ModuleState string + +const ( + ModuleStateEnabled ModuleState = "ENABLED" + ModuleStateDisabled ModuleState = "DISABLED" +) + +func (e ModuleState) ToPointer() *ModuleState { + return &e +} +func (e *ModuleState) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "ENABLED": + fallthrough + case "DISABLED": + *e = ModuleState(v) + return nil + default: + return fmt.Errorf("invalid value for ModuleState: %v", v) + } +} + +type ModuleStatus string + +const ( + ModuleStatusUnknown ModuleStatus = "UNKNOWN" + ModuleStatusProgressing ModuleStatus = "PROGRESSING" + ModuleStatusReady ModuleStatus = "READY" + ModuleStatusDeleted ModuleStatus = "DELETED" +) + +func (e ModuleStatus) ToPointer() *ModuleStatus { + return &e +} +func (e *ModuleStatus) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "UNKNOWN": + fallthrough + case "PROGRESSING": + fallthrough + case "READY": + fallthrough + case "DELETED": + *e = ModuleStatus(v) + return nil + default: + return fmt.Errorf("invalid value for ModuleStatus: %v", v) + } +} + +type ClusterStatus struct { +} + +type Module struct { + Name string `json:"name"` + State ModuleState `json:"state"` + Status ModuleStatus `json:"status"` + LastStatusUpdate time.Time `json:"lastStatusUpdate"` + LastStateUpdate time.Time `json:"lastStateUpdate"` + ClusterStatus *ClusterStatus `json:"clusterStatus,omitzero"` +} + +func (m Module) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(m, "", false) +} + +func (m *Module) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &m, "", false, []string{"name", "state", "status", "lastStatusUpdate", "lastStateUpdate"}); err != nil { + return err + } + return nil +} + +func (m *Module) GetName() string { + if m == nil { + return "" + } + return m.Name +} + +func (m *Module) GetState() ModuleState { + if m == nil { + return ModuleState("") + } + return m.State +} + +func (m *Module) GetStatus() ModuleStatus { + if m == nil { + return ModuleStatus("") + } + return m.Status +} + +func (m *Module) GetLastStatusUpdate() time.Time { + if m == nil { + return time.Time{} + } + return m.LastStatusUpdate +} + +func (m *Module) GetLastStateUpdate() time.Time { + if m == nil { + return time.Time{} + } + return m.LastStateUpdate +} + +func (m *Module) GetClusterStatus() *ClusterStatus { + if m == nil { + return nil + } + return m.ClusterStatus +} diff --git a/internal/membershipclient/models/components/organizationapplication.go b/internal/membershipclient/models/components/organizationapplication.go new file mode 100644 index 00000000..be9fb9a6 --- /dev/null +++ b/internal/membershipclient/models/components/organizationapplication.go @@ -0,0 +1,49 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "time" +) + +type OrganizationApplication struct { + // Organization ID + OrganizationID string `json:"organizationId"` + // Application ID + ApplicationID string `json:"applicationId"` + // Creation date + CreatedAt time.Time `json:"createdAt"` +} + +func (o OrganizationApplication) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(o, "", false) +} + +func (o *OrganizationApplication) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &o, "", false, []string{"organizationId", "applicationId", "createdAt"}); err != nil { + return err + } + return nil +} + +func (o *OrganizationApplication) GetOrganizationID() string { + if o == nil { + return "" + } + return o.OrganizationID +} + +func (o *OrganizationApplication) GetApplicationID() string { + if o == nil { + return "" + } + return o.ApplicationID +} + +func (o *OrganizationApplication) GetCreatedAt() time.Time { + if o == nil { + return time.Time{} + } + return o.CreatedAt +} diff --git a/internal/membershipclient/models/components/organizationclient.go b/internal/membershipclient/models/components/organizationclient.go new file mode 100644 index 00000000..4880e68e --- /dev/null +++ b/internal/membershipclient/models/components/organizationclient.go @@ -0,0 +1,92 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "time" +) + +type OrganizationClientSecret struct { + LastDigits string `json:"lastDigits"` + Clear *string `json:"clear,omitzero"` +} + +func (o *OrganizationClientSecret) GetLastDigits() string { + if o == nil { + return "" + } + return o.LastDigits +} + +func (o *OrganizationClientSecret) GetClear() *string { + if o == nil { + return nil + } + return o.Clear +} + +type OrganizationClient struct { + // Organization ID + ID string `json:"id"` + Secret OrganizationClientSecret `json:"secret"` + // Name of the client + Name string `json:"name"` + // Description of the client + Description string `json:"description"` + CreatedAt time.Time `json:"createdAt"` + UpdatedAt time.Time `json:"updatedAt"` +} + +func (o OrganizationClient) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(o, "", false) +} + +func (o *OrganizationClient) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &o, "", false, []string{"id", "secret", "name", "description", "createdAt", "updatedAt"}); err != nil { + return err + } + return nil +} + +func (o *OrganizationClient) GetID() string { + if o == nil { + return "" + } + return o.ID +} + +func (o *OrganizationClient) GetSecret() OrganizationClientSecret { + if o == nil { + return OrganizationClientSecret{} + } + return o.Secret +} + +func (o *OrganizationClient) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *OrganizationClient) GetDescription() string { + if o == nil { + return "" + } + return o.Description +} + +func (o *OrganizationClient) GetCreatedAt() time.Time { + if o == nil { + return time.Time{} + } + return o.CreatedAt +} + +func (o *OrganizationClient) GetUpdatedAt() time.Time { + if o == nil { + return time.Time{} + } + return o.UpdatedAt +} diff --git a/internal/membershipclient/models/components/organizationdata.go b/internal/membershipclient/models/components/organizationdata.go new file mode 100644 index 00000000..f0b6b4bb --- /dev/null +++ b/internal/membershipclient/models/components/organizationdata.go @@ -0,0 +1,33 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type OrganizationData struct { + // Organization name + Name string `json:"name"` + // Organization domain + Domain *string `json:"domain,omitzero"` + // Default policy ID applied to new users + DefaultPolicyID *int64 `json:"defaultPolicyID"` +} + +func (o *OrganizationData) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *OrganizationData) GetDomain() *string { + if o == nil { + return nil + } + return o.Domain +} + +func (o *OrganizationData) GetDefaultPolicyID() *int64 { + if o == nil { + return nil + } + return o.DefaultPolicyID +} diff --git a/internal/membershipclient/models/components/organizationexpanded.go b/internal/membershipclient/models/components/organizationexpanded.go new file mode 100644 index 00000000..193da10f --- /dev/null +++ b/internal/membershipclient/models/components/organizationexpanded.go @@ -0,0 +1,125 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "time" +) + +type OrganizationExpanded struct { + // Organization name + Name string `json:"name"` + // Organization domain + Domain *string `json:"domain,omitzero"` + // Default policy ID applied to new users + DefaultPolicyID *int64 `json:"defaultPolicyID"` + // Organization ID + ID string `json:"id"` + // Owner ID + OwnerID string `json:"ownerId"` + // Number of available stacks + AvailableStacks *int64 `json:"availableStacks,omitzero"` + // Number of available sandboxes + AvailableSandboxes *int64 `json:"availableSandboxes,omitzero"` + CreatedAt *time.Time `json:"createdAt,omitzero"` + UpdatedAt *time.Time `json:"updatedAt,omitzero"` + TotalStacks *int64 `json:"totalStacks,omitzero"` + TotalUsers *int64 `json:"totalUsers,omitzero"` + Owner *User `json:"owner,omitzero"` +} + +func (o OrganizationExpanded) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(o, "", false) +} + +func (o *OrganizationExpanded) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &o, "", false, []string{"name", "id", "ownerId"}); err != nil { + return err + } + return nil +} + +func (o *OrganizationExpanded) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *OrganizationExpanded) GetDomain() *string { + if o == nil { + return nil + } + return o.Domain +} + +func (o *OrganizationExpanded) GetDefaultPolicyID() *int64 { + if o == nil { + return nil + } + return o.DefaultPolicyID +} + +func (o *OrganizationExpanded) GetID() string { + if o == nil { + return "" + } + return o.ID +} + +func (o *OrganizationExpanded) GetOwnerID() string { + if o == nil { + return "" + } + return o.OwnerID +} + +func (o *OrganizationExpanded) GetAvailableStacks() *int64 { + if o == nil { + return nil + } + return o.AvailableStacks +} + +func (o *OrganizationExpanded) GetAvailableSandboxes() *int64 { + if o == nil { + return nil + } + return o.AvailableSandboxes +} + +func (o *OrganizationExpanded) GetCreatedAt() *time.Time { + if o == nil { + return nil + } + return o.CreatedAt +} + +func (o *OrganizationExpanded) GetUpdatedAt() *time.Time { + if o == nil { + return nil + } + return o.UpdatedAt +} + +func (o *OrganizationExpanded) GetTotalStacks() *int64 { + if o == nil { + return nil + } + return o.TotalStacks +} + +func (o *OrganizationExpanded) GetTotalUsers() *int64 { + if o == nil { + return nil + } + return o.TotalUsers +} + +func (o *OrganizationExpanded) GetOwner() *User { + if o == nil { + return nil + } + return o.Owner +} diff --git a/internal/membershipclient/models/components/organizationfeature.go b/internal/membershipclient/models/components/organizationfeature.go new file mode 100644 index 00000000..3b2539ce --- /dev/null +++ b/internal/membershipclient/models/components/organizationfeature.go @@ -0,0 +1,46 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "time" +) + +type OrganizationFeature struct { + OrganizationID string `json:"organizationID"` + Name string `json:"name"` + CreatedAt time.Time `json:"createdAt"` +} + +func (o OrganizationFeature) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(o, "", false) +} + +func (o *OrganizationFeature) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &o, "", false, []string{"organizationID", "name", "createdAt"}); err != nil { + return err + } + return nil +} + +func (o *OrganizationFeature) GetOrganizationID() string { + if o == nil { + return "" + } + return o.OrganizationID +} + +func (o *OrganizationFeature) GetName() string { + if o == nil { + return "" + } + return o.Name +} + +func (o *OrganizationFeature) GetCreatedAt() time.Time { + if o == nil { + return time.Time{} + } + return o.CreatedAt +} diff --git a/internal/membershipclient/models/components/policy.go b/internal/membershipclient/models/components/policy.go new file mode 100644 index 00000000..36be6014 --- /dev/null +++ b/internal/membershipclient/models/components/policy.go @@ -0,0 +1,94 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "time" +) + +type Policy struct { + // Policy name + Name string `json:"name"` + // Policy description + Description *string `json:"description,omitzero"` + // Policy ID + ID int64 `json:"id"` + // Organization ID + OrganizationID *string `json:"organizationId,omitzero"` + // Whether the policy is protected from modification + Protected bool `json:"protected"` + // List of scopes assigned to the policy (only present when fetched via GET endpoint) + Scopes []Scope `json:"scopes,omitzero"` + // Creation date + CreatedAt time.Time `json:"createdAt"` + // Last update date + UpdatedAt time.Time `json:"updatedAt"` +} + +func (p Policy) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(p, "", false) +} + +func (p *Policy) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &p, "", false, []string{"name", "id", "protected", "createdAt", "updatedAt"}); err != nil { + return err + } + return nil +} + +func (p *Policy) GetName() string { + if p == nil { + return "" + } + return p.Name +} + +func (p *Policy) GetDescription() *string { + if p == nil { + return nil + } + return p.Description +} + +func (p *Policy) GetID() int64 { + if p == nil { + return 0 + } + return p.ID +} + +func (p *Policy) GetOrganizationID() *string { + if p == nil { + return nil + } + return p.OrganizationID +} + +func (p *Policy) GetProtected() bool { + if p == nil { + return false + } + return p.Protected +} + +func (p *Policy) GetScopes() []Scope { + if p == nil { + return nil + } + return p.Scopes +} + +func (p *Policy) GetCreatedAt() time.Time { + if p == nil { + return time.Time{} + } + return p.CreatedAt +} + +func (p *Policy) GetUpdatedAt() time.Time { + if p == nil { + return time.Time{} + } + return p.UpdatedAt +} diff --git a/internal/membershipclient/models/components/policydata.go b/internal/membershipclient/models/components/policydata.go new file mode 100644 index 00000000..322e924c --- /dev/null +++ b/internal/membershipclient/models/components/policydata.go @@ -0,0 +1,24 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type PolicyData struct { + // Policy name + Name string `json:"name"` + // Policy description + Description *string `json:"description,omitzero"` +} + +func (p *PolicyData) GetName() string { + if p == nil { + return "" + } + return p.Name +} + +func (p *PolicyData) GetDescription() *string { + if p == nil { + return nil + } + return p.Description +} diff --git a/internal/membershipclient/models/components/privateregion.go b/internal/membershipclient/models/components/privateregion.go new file mode 100644 index 00000000..dd41dcff --- /dev/null +++ b/internal/membershipclient/models/components/privateregion.go @@ -0,0 +1,134 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "time" +) + +type PrivateRegion struct { + ID string `json:"id"` + BaseURL string `json:"baseUrl"` + CreatedAt string `json:"createdAt"` + Active bool `json:"active"` + LastPing *time.Time `json:"lastPing,omitzero"` + Name string `json:"name"` + Capabilities RegionCapability `json:"capabilities"` + AgentID string `json:"agentID"` + Outdated bool `json:"outdated"` + CreatorID *string `json:"creatorId,omitzero"` + Version *string `json:"version,omitzero"` + OrganizationID string `json:"organizationID"` + CreatorId1 string `json:"creatorID"` + Secret *PrivateRegionSecret `json:"secret,omitzero"` +} + +func (p PrivateRegion) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(p, "", false) +} + +func (p *PrivateRegion) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &p, "", false, []string{"id", "baseUrl", "createdAt", "active", "name", "capabilities", "agentID", "outdated", "organizationID", "creatorID"}); err != nil { + return err + } + return nil +} + +func (p *PrivateRegion) GetID() string { + if p == nil { + return "" + } + return p.ID +} + +func (p *PrivateRegion) GetBaseURL() string { + if p == nil { + return "" + } + return p.BaseURL +} + +func (p *PrivateRegion) GetCreatedAt() string { + if p == nil { + return "" + } + return p.CreatedAt +} + +func (p *PrivateRegion) GetActive() bool { + if p == nil { + return false + } + return p.Active +} + +func (p *PrivateRegion) GetLastPing() *time.Time { + if p == nil { + return nil + } + return p.LastPing +} + +func (p *PrivateRegion) GetName() string { + if p == nil { + return "" + } + return p.Name +} + +func (p *PrivateRegion) GetCapabilities() RegionCapability { + if p == nil { + return RegionCapability{} + } + return p.Capabilities +} + +func (p *PrivateRegion) GetAgentID() string { + if p == nil { + return "" + } + return p.AgentID +} + +func (p *PrivateRegion) GetOutdated() bool { + if p == nil { + return false + } + return p.Outdated +} + +func (p *PrivateRegion) GetCreatorID() *string { + if p == nil { + return nil + } + return p.CreatorID +} + +func (p *PrivateRegion) GetVersion() *string { + if p == nil { + return nil + } + return p.Version +} + +func (p *PrivateRegion) GetOrganizationID() string { + if p == nil { + return "" + } + return p.OrganizationID +} + +func (p *PrivateRegion) GetCreatorId1() string { + if p == nil { + return "" + } + return p.CreatorId1 +} + +func (p *PrivateRegion) GetSecret() *PrivateRegionSecret { + if p == nil { + return nil + } + return p.Secret +} diff --git a/internal/membershipclient/models/components/privateregionsecret.go b/internal/membershipclient/models/components/privateregionsecret.go new file mode 100644 index 00000000..bde1ff35 --- /dev/null +++ b/internal/membershipclient/models/components/privateregionsecret.go @@ -0,0 +1,22 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type PrivateRegionSecret struct { + LastDigits string `json:"lastDigits"` + Clear *string `json:"clear,omitzero"` +} + +func (p *PrivateRegionSecret) GetLastDigits() string { + if p == nil { + return "" + } + return p.LastDigits +} + +func (p *PrivateRegionSecret) GetClear() *string { + if p == nil { + return nil + } + return p.Clear +} diff --git a/internal/membershipclient/models/components/readorganizationclientresponse.go b/internal/membershipclient/models/components/readorganizationclientresponse.go new file mode 100644 index 00000000..34042097 --- /dev/null +++ b/internal/membershipclient/models/components/readorganizationclientresponse.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type ReadOrganizationClientResponse struct { + Data OrganizationClient `json:"data"` +} + +func (r *ReadOrganizationClientResponse) GetData() OrganizationClient { + if r == nil { + return OrganizationClient{} + } + return r.Data +} diff --git a/internal/membershipclient/models/components/readorganizationclientsresponse.go b/internal/membershipclient/models/components/readorganizationclientsresponse.go new file mode 100644 index 00000000..5a451ddc --- /dev/null +++ b/internal/membershipclient/models/components/readorganizationclientsresponse.go @@ -0,0 +1,57 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type ReadOrganizationClientsResponseData struct { + PageSize int64 `json:"pageSize"` + HasMore bool `json:"hasMore"` + Previous *string `json:"previous,omitzero"` + Next *string `json:"next,omitzero"` + Data []OrganizationClient `json:"data"` +} + +func (r *ReadOrganizationClientsResponseData) GetPageSize() int64 { + if r == nil { + return 0 + } + return r.PageSize +} + +func (r *ReadOrganizationClientsResponseData) GetHasMore() bool { + if r == nil { + return false + } + return r.HasMore +} + +func (r *ReadOrganizationClientsResponseData) GetPrevious() *string { + if r == nil { + return nil + } + return r.Previous +} + +func (r *ReadOrganizationClientsResponseData) GetNext() *string { + if r == nil { + return nil + } + return r.Next +} + +func (r *ReadOrganizationClientsResponseData) GetData() []OrganizationClient { + if r == nil { + return []OrganizationClient{} + } + return r.Data +} + +type ReadOrganizationClientsResponse struct { + Data ReadOrganizationClientsResponseData `json:"data"` +} + +func (r *ReadOrganizationClientsResponse) GetData() ReadOrganizationClientsResponseData { + if r == nil { + return ReadOrganizationClientsResponseData{} + } + return r.Data +} diff --git a/internal/membershipclient/models/components/readorganizationresponse.go b/internal/membershipclient/models/components/readorganizationresponse.go new file mode 100644 index 00000000..44f747b9 --- /dev/null +++ b/internal/membershipclient/models/components/readorganizationresponse.go @@ -0,0 +1,29 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type ReadOrganizationResponse struct { + Data *OrganizationExpanded `json:"data,omitzero"` +} + +func (r ReadOrganizationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(r, "", false) +} + +func (r *ReadOrganizationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &r, "", false, nil); err != nil { + return err + } + return nil +} + +func (r *ReadOrganizationResponse) GetData() *OrganizationExpanded { + if r == nil { + return nil + } + return r.Data +} diff --git a/internal/membershipclient/models/components/readorganizationuserresponse.go b/internal/membershipclient/models/components/readorganizationuserresponse.go new file mode 100644 index 00000000..c27561c2 --- /dev/null +++ b/internal/membershipclient/models/components/readorganizationuserresponse.go @@ -0,0 +1,57 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type ReadOrganizationUserResponseData struct { + Email string `json:"email"` + ID string `json:"id"` + // Policy ID applied to the user + PolicyID int64 `json:"policyId"` +} + +func (r *ReadOrganizationUserResponseData) GetEmail() string { + if r == nil { + return "" + } + return r.Email +} + +func (r *ReadOrganizationUserResponseData) GetID() string { + if r == nil { + return "" + } + return r.ID +} + +func (r *ReadOrganizationUserResponseData) GetPolicyID() int64 { + if r == nil { + return 0 + } + return r.PolicyID +} + +type ReadOrganizationUserResponse struct { + Data *ReadOrganizationUserResponseData `json:"data,omitzero"` +} + +func (r ReadOrganizationUserResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(r, "", false) +} + +func (r *ReadOrganizationUserResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &r, "", false, nil); err != nil { + return err + } + return nil +} + +func (r *ReadOrganizationUserResponse) GetData() *ReadOrganizationUserResponseData { + if r == nil { + return nil + } + return r.Data +} diff --git a/internal/membershipclient/models/components/readpolicyresponse.go b/internal/membershipclient/models/components/readpolicyresponse.go new file mode 100644 index 00000000..afec6262 --- /dev/null +++ b/internal/membershipclient/models/components/readpolicyresponse.go @@ -0,0 +1,29 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type ReadPolicyResponse struct { + Data *Policy `json:"data,omitzero"` +} + +func (r ReadPolicyResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(r, "", false) +} + +func (r *ReadPolicyResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &r, "", false, nil); err != nil { + return err + } + return nil +} + +func (r *ReadPolicyResponse) GetData() *Policy { + if r == nil { + return nil + } + return r.Data +} diff --git a/internal/membershipclient/models/components/readstackuseraccess.go b/internal/membershipclient/models/components/readstackuseraccess.go new file mode 100644 index 00000000..9fcc81a5 --- /dev/null +++ b/internal/membershipclient/models/components/readstackuseraccess.go @@ -0,0 +1,68 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type ReadStackUserAccessData struct { + // Stack ID + StackID string `json:"stackId"` + // User ID + UserID string `json:"userId"` + // User email + Email string `json:"email"` + // Policy ID applied to the user for the stack + PolicyID int64 `json:"policyId"` +} + +func (r *ReadStackUserAccessData) GetStackID() string { + if r == nil { + return "" + } + return r.StackID +} + +func (r *ReadStackUserAccessData) GetUserID() string { + if r == nil { + return "" + } + return r.UserID +} + +func (r *ReadStackUserAccessData) GetEmail() string { + if r == nil { + return "" + } + return r.Email +} + +func (r *ReadStackUserAccessData) GetPolicyID() int64 { + if r == nil { + return 0 + } + return r.PolicyID +} + +type ReadStackUserAccess struct { + Data *ReadStackUserAccessData `json:"data,omitzero"` +} + +func (r ReadStackUserAccess) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(r, "", false) +} + +func (r *ReadStackUserAccess) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &r, "", false, nil); err != nil { + return err + } + return nil +} + +func (r *ReadStackUserAccess) GetData() *ReadStackUserAccessData { + if r == nil { + return nil + } + return r.Data +} diff --git a/internal/membershipclient/models/components/readuserresponse.go b/internal/membershipclient/models/components/readuserresponse.go new file mode 100644 index 00000000..df8b3968 --- /dev/null +++ b/internal/membershipclient/models/components/readuserresponse.go @@ -0,0 +1,29 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type ReadUserResponse struct { + Data *User `json:"data,omitzero"` +} + +func (r ReadUserResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(r, "", false) +} + +func (r *ReadUserResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &r, "", false, nil); err != nil { + return err + } + return nil +} + +func (r *ReadUserResponse) GetData() *User { + if r == nil { + return nil + } + return r.Data +} diff --git a/internal/membershipclient/models/components/region.go b/internal/membershipclient/models/components/region.go new file mode 100644 index 00000000..8a3eb445 --- /dev/null +++ b/internal/membershipclient/models/components/region.go @@ -0,0 +1,110 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "time" +) + +type Region struct { + ID string `json:"id"` + BaseURL string `json:"baseUrl"` + CreatedAt string `json:"createdAt"` + Active bool `json:"active"` + LastPing *time.Time `json:"lastPing,omitzero"` + Name string `json:"name"` + Capabilities RegionCapability `json:"capabilities"` + AgentID string `json:"agentID"` + Outdated bool `json:"outdated"` + CreatorID *string `json:"creatorId,omitzero"` + Version *string `json:"version,omitzero"` +} + +func (r Region) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(r, "", false) +} + +func (r *Region) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &r, "", false, []string{"id", "baseUrl", "createdAt", "active", "name", "capabilities", "agentID", "outdated"}); err != nil { + return err + } + return nil +} + +func (r *Region) GetID() string { + if r == nil { + return "" + } + return r.ID +} + +func (r *Region) GetBaseURL() string { + if r == nil { + return "" + } + return r.BaseURL +} + +func (r *Region) GetCreatedAt() string { + if r == nil { + return "" + } + return r.CreatedAt +} + +func (r *Region) GetActive() bool { + if r == nil { + return false + } + return r.Active +} + +func (r *Region) GetLastPing() *time.Time { + if r == nil { + return nil + } + return r.LastPing +} + +func (r *Region) GetName() string { + if r == nil { + return "" + } + return r.Name +} + +func (r *Region) GetCapabilities() RegionCapability { + if r == nil { + return RegionCapability{} + } + return r.Capabilities +} + +func (r *Region) GetAgentID() string { + if r == nil { + return "" + } + return r.AgentID +} + +func (r *Region) GetOutdated() bool { + if r == nil { + return false + } + return r.Outdated +} + +func (r *Region) GetCreatorID() *string { + if r == nil { + return nil + } + return r.CreatorID +} + +func (r *Region) GetVersion() *string { + if r == nil { + return nil + } + return r.Version +} diff --git a/internal/membershipclient/models/components/regioncapability.go b/internal/membershipclient/models/components/regioncapability.go new file mode 100644 index 00000000..f7528cb0 --- /dev/null +++ b/internal/membershipclient/models/components/regioncapability.go @@ -0,0 +1,37 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type RegionCapability struct { + ModuleList []string `json:"MODULE_LIST,omitzero"` + Ee []string `json:"EE,omitzero"` +} + +func (r RegionCapability) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(r, "", false) +} + +func (r *RegionCapability) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &r, "", false, nil); err != nil { + return err + } + return nil +} + +func (r *RegionCapability) GetModuleList() []string { + if r == nil { + return nil + } + return r.ModuleList +} + +func (r *RegionCapability) GetEe() []string { + if r == nil { + return nil + } + return r.Ee +} diff --git a/internal/membershipclient/models/components/scope.go b/internal/membershipclient/models/components/scope.go new file mode 100644 index 00000000..cb86af8a --- /dev/null +++ b/internal/membershipclient/models/components/scope.go @@ -0,0 +1,85 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "time" +) + +type Scope struct { + // Scope ID + ID int64 `json:"id"` + // The OAuth2 scope label (e.g., "custom:read") + Label string `json:"label"` + // Scope description + Description *string `json:"description,omitzero"` + // Application ID (null for global scopes) + ApplicationID *string `json:"applicationId,omitzero"` + // Whether the scope is protected + Protected *bool `default:"false" json:"protected"` + // Creation timestamp + CreatedAt time.Time `json:"createdAt"` + // Last update timestamp + UpdatedAt time.Time `json:"updatedAt"` +} + +func (s Scope) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(s, "", false) +} + +func (s *Scope) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &s, "", false, []string{"id", "label", "createdAt", "updatedAt"}); err != nil { + return err + } + return nil +} + +func (s *Scope) GetID() int64 { + if s == nil { + return 0 + } + return s.ID +} + +func (s *Scope) GetLabel() string { + if s == nil { + return "" + } + return s.Label +} + +func (s *Scope) GetDescription() *string { + if s == nil { + return nil + } + return s.Description +} + +func (s *Scope) GetApplicationID() *string { + if s == nil { + return nil + } + return s.ApplicationID +} + +func (s *Scope) GetProtected() *bool { + if s == nil { + return nil + } + return s.Protected +} + +func (s *Scope) GetCreatedAt() time.Time { + if s == nil { + return time.Time{} + } + return s.CreatedAt +} + +func (s *Scope) GetUpdatedAt() time.Time { + if s == nil { + return time.Time{} + } + return s.UpdatedAt +} diff --git a/internal/membershipclient/models/components/security.go b/internal/membershipclient/models/components/security.go new file mode 100644 index 00000000..86ed7557 --- /dev/null +++ b/internal/membershipclient/models/components/security.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type Security struct { + Oauth2 string `security:"scheme,type=oauth2,name=Authorization"` +} + +func (s *Security) GetOauth2() string { + if s == nil { + return "" + } + return s.Oauth2 +} diff --git a/internal/membershipclient/models/components/serverinfo.go b/internal/membershipclient/models/components/serverinfo.go new file mode 100644 index 00000000..67ecdaa4 --- /dev/null +++ b/internal/membershipclient/models/components/serverinfo.go @@ -0,0 +1,45 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type ServerInfo struct { + Version string `json:"version"` + Capabilities []Capability `json:"capabilities,omitzero"` + ConsoleURL *string `json:"consoleURL,omitzero"` +} + +func (s ServerInfo) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(s, "", false) +} + +func (s *ServerInfo) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &s, "", false, []string{"version"}); err != nil { + return err + } + return nil +} + +func (s *ServerInfo) GetVersion() string { + if s == nil { + return "" + } + return s.Version +} + +func (s *ServerInfo) GetCapabilities() []Capability { + if s == nil { + return nil + } + return s.Capabilities +} + +func (s *ServerInfo) GetConsoleURL() *string { + if s == nil { + return nil + } + return s.ConsoleURL +} diff --git a/internal/membershipclient/models/components/stack.go b/internal/membershipclient/models/components/stack.go new file mode 100644 index 00000000..31f66071 --- /dev/null +++ b/internal/membershipclient/models/components/stack.go @@ -0,0 +1,333 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "encoding/json" + "fmt" + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "time" +) + +type StackStatus string + +const ( + StackStatusUnknown StackStatus = "UNKNOWN" + StackStatusProgressing StackStatus = "PROGRESSING" + StackStatusReady StackStatus = "READY" + StackStatusDisabled StackStatus = "DISABLED" + StackStatusDeleted StackStatus = "DELETED" +) + +func (e StackStatus) ToPointer() *StackStatus { + return &e +} +func (e *StackStatus) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "UNKNOWN": + fallthrough + case "PROGRESSING": + fallthrough + case "READY": + fallthrough + case "DISABLED": + fallthrough + case "DELETED": + *e = StackStatus(v) + return nil + default: + return fmt.Errorf("invalid value for StackStatus: %v", v) + } +} + +type StackState string + +const ( + StackStateActive StackState = "ACTIVE" + StackStateDisabled StackState = "DISABLED" + StackStateDeleted StackState = "DELETED" +) + +func (e StackState) ToPointer() *StackState { + return &e +} +func (e *StackState) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "ACTIVE": + fallthrough + case "DISABLED": + fallthrough + case "DELETED": + *e = StackState(v) + return nil + default: + return fmt.Errorf("invalid value for StackState: %v", v) + } +} + +type ExpectedStatus string + +const ( + ExpectedStatusReady ExpectedStatus = "READY" + ExpectedStatusDisabled ExpectedStatus = "DISABLED" + ExpectedStatusDeleted ExpectedStatus = "DELETED" +) + +func (e ExpectedStatus) ToPointer() *ExpectedStatus { + return &e +} +func (e *ExpectedStatus) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "READY": + fallthrough + case "DISABLED": + fallthrough + case "DELETED": + *e = ExpectedStatus(v) + return nil + default: + return fmt.Errorf("invalid value for ExpectedStatus: %v", v) + } +} + +type Stack struct { + // Stack name + Name string `json:"name"` + Metadata map[string]string `json:"metadata,omitzero"` + // Supported only with agent version >= v0.7.0 + Version *string `json:"version,omitzero"` + Status StackStatus `json:"status"` + State StackState `json:"state"` + ExpectedStatus ExpectedStatus `json:"expectedStatus"` + LastStateUpdate time.Time `json:"lastStateUpdate"` + LastExpectedStatusUpdate time.Time `json:"lastExpectedStatusUpdate"` + LastStatusUpdate time.Time `json:"lastStatusUpdate"` + WarnedAt *time.Time `json:"warnedAt,omitzero"` + DisposableSince *time.Time `json:"disposableSince,omitzero"` + // Stack is reachable through Stargate + Reachable bool `json:"reachable"` + // Last time the stack was reachable + LastReachableUpdate *time.Time `json:"lastReachableUpdate,omitzero"` + // Stack ID + ID string `json:"id"` + // Organization ID + OrganizationID string `json:"organizationId"` + // Base stack uri + URI string `json:"uri"` + // The region where the stack is installed + RegionID string `json:"regionID"` + Region *Region `json:"region,omitzero"` + StargateEnabled bool `json:"stargateEnabled"` + CreatedAt *time.Time `json:"createdAt,omitzero"` + DeletedAt *time.Time `json:"deletedAt,omitzero"` + DisabledAt *time.Time `json:"disabledAt,omitzero"` + AuditEnabled *bool `json:"auditEnabled,omitzero"` + Synchronised bool `json:"synchronised"` + UpdatedAt *time.Time `json:"updatedAt,omitzero"` + Modules []Module `json:"modules"` +} + +func (s Stack) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(s, "", false) +} + +func (s *Stack) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &s, "", false, []string{"name", "status", "state", "expectedStatus", "lastStateUpdate", "lastExpectedStatusUpdate", "lastStatusUpdate", "reachable", "id", "organizationId", "uri", "regionID", "stargateEnabled", "synchronised", "modules"}); err != nil { + return err + } + return nil +} + +func (s *Stack) GetName() string { + if s == nil { + return "" + } + return s.Name +} + +func (s *Stack) GetMetadata() map[string]string { + if s == nil { + return nil + } + return s.Metadata +} + +func (s *Stack) GetVersion() *string { + if s == nil { + return nil + } + return s.Version +} + +func (s *Stack) GetStatus() StackStatus { + if s == nil { + return StackStatus("") + } + return s.Status +} + +func (s *Stack) GetState() StackState { + if s == nil { + return StackState("") + } + return s.State +} + +func (s *Stack) GetExpectedStatus() ExpectedStatus { + if s == nil { + return ExpectedStatus("") + } + return s.ExpectedStatus +} + +func (s *Stack) GetLastStateUpdate() time.Time { + if s == nil { + return time.Time{} + } + return s.LastStateUpdate +} + +func (s *Stack) GetLastExpectedStatusUpdate() time.Time { + if s == nil { + return time.Time{} + } + return s.LastExpectedStatusUpdate +} + +func (s *Stack) GetLastStatusUpdate() time.Time { + if s == nil { + return time.Time{} + } + return s.LastStatusUpdate +} + +func (s *Stack) GetWarnedAt() *time.Time { + if s == nil { + return nil + } + return s.WarnedAt +} + +func (s *Stack) GetDisposableSince() *time.Time { + if s == nil { + return nil + } + return s.DisposableSince +} + +func (s *Stack) GetReachable() bool { + if s == nil { + return false + } + return s.Reachable +} + +func (s *Stack) GetLastReachableUpdate() *time.Time { + if s == nil { + return nil + } + return s.LastReachableUpdate +} + +func (s *Stack) GetID() string { + if s == nil { + return "" + } + return s.ID +} + +func (s *Stack) GetOrganizationID() string { + if s == nil { + return "" + } + return s.OrganizationID +} + +func (s *Stack) GetURI() string { + if s == nil { + return "" + } + return s.URI +} + +func (s *Stack) GetRegionID() string { + if s == nil { + return "" + } + return s.RegionID +} + +func (s *Stack) GetRegion() *Region { + if s == nil { + return nil + } + return s.Region +} + +func (s *Stack) GetStargateEnabled() bool { + if s == nil { + return false + } + return s.StargateEnabled +} + +func (s *Stack) GetCreatedAt() *time.Time { + if s == nil { + return nil + } + return s.CreatedAt +} + +func (s *Stack) GetDeletedAt() *time.Time { + if s == nil { + return nil + } + return s.DeletedAt +} + +func (s *Stack) GetDisabledAt() *time.Time { + if s == nil { + return nil + } + return s.DisabledAt +} + +func (s *Stack) GetAuditEnabled() *bool { + if s == nil { + return nil + } + return s.AuditEnabled +} + +func (s *Stack) GetSynchronised() bool { + if s == nil { + return false + } + return s.Synchronised +} + +func (s *Stack) GetUpdatedAt() *time.Time { + if s == nil { + return nil + } + return s.UpdatedAt +} + +func (s *Stack) GetModules() []Module { + if s == nil { + return []Module{} + } + return s.Modules +} diff --git a/internal/membershipclient/models/components/stackdata.go b/internal/membershipclient/models/components/stackdata.go new file mode 100644 index 00000000..5162a930 --- /dev/null +++ b/internal/membershipclient/models/components/stackdata.go @@ -0,0 +1,38 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type StackData struct { + // Stack name + Name string `json:"name"` + Metadata map[string]string `json:"metadata,omitzero"` +} + +func (s StackData) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(s, "", false) +} + +func (s *StackData) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &s, "", false, []string{"name"}); err != nil { + return err + } + return nil +} + +func (s *StackData) GetName() string { + if s == nil { + return "" + } + return s.Name +} + +func (s *StackData) GetMetadata() map[string]string { + if s == nil { + return nil + } + return s.Metadata +} diff --git a/internal/membershipclient/models/components/stackuseraccessresponse.go b/internal/membershipclient/models/components/stackuseraccessresponse.go new file mode 100644 index 00000000..784e0e1b --- /dev/null +++ b/internal/membershipclient/models/components/stackuseraccessresponse.go @@ -0,0 +1,68 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type StackUserAccessResponseData struct { + // Stack ID + StackID string `json:"stackId"` + // User ID + UserID string `json:"userId"` + // User email + Email string `json:"email"` + // Policy ID applied to the user for the stack + PolicyID int64 `json:"policyId"` +} + +func (s *StackUserAccessResponseData) GetStackID() string { + if s == nil { + return "" + } + return s.StackID +} + +func (s *StackUserAccessResponseData) GetUserID() string { + if s == nil { + return "" + } + return s.UserID +} + +func (s *StackUserAccessResponseData) GetEmail() string { + if s == nil { + return "" + } + return s.Email +} + +func (s *StackUserAccessResponseData) GetPolicyID() int64 { + if s == nil { + return 0 + } + return s.PolicyID +} + +type StackUserAccessResponse struct { + Data []StackUserAccessResponseData `json:"data,omitzero"` +} + +func (s StackUserAccessResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(s, "", false) +} + +func (s *StackUserAccessResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &s, "", false, nil); err != nil { + return err + } + return nil +} + +func (s *StackUserAccessResponse) GetData() []StackUserAccessResponseData { + if s == nil { + return nil + } + return s.Data +} diff --git a/internal/membershipclient/models/components/stackversion.go b/internal/membershipclient/models/components/stackversion.go new file mode 100644 index 00000000..2d9440df --- /dev/null +++ b/internal/membershipclient/models/components/stackversion.go @@ -0,0 +1,15 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type StackVersion struct { + // Supported only with agent version >= v0.7.0 + Version *string `json:"version,omitzero"` +} + +func (s *StackVersion) GetVersion() *string { + if s == nil { + return nil + } + return s.Version +} diff --git a/internal/membershipclient/models/components/systemrole.go b/internal/membershipclient/models/components/systemrole.go new file mode 100644 index 00000000..d7e071d9 --- /dev/null +++ b/internal/membershipclient/models/components/systemrole.go @@ -0,0 +1,34 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "encoding/json" + "fmt" +) + +type SystemRole string + +const ( + SystemRoleUser SystemRole = "USER" + SystemRoleSystem SystemRole = "SYSTEM" +) + +func (e SystemRole) ToPointer() *SystemRole { + return &e +} +func (e *SystemRole) UnmarshalJSON(data []byte) error { + var v string + if err := json.Unmarshal(data, &v); err != nil { + return err + } + switch v { + case "USER": + fallthrough + case "SYSTEM": + *e = SystemRole(v) + return nil + default: + return fmt.Errorf("invalid value for SystemRole: %v", v) + } +} diff --git a/internal/membershipclient/models/components/updateapplicationresponse.go b/internal/membershipclient/models/components/updateapplicationresponse.go new file mode 100644 index 00000000..e8d865b3 --- /dev/null +++ b/internal/membershipclient/models/components/updateapplicationresponse.go @@ -0,0 +1,29 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type UpdateApplicationResponse struct { + Data *Application `json:"data,omitzero"` +} + +func (u UpdateApplicationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UpdateApplicationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, nil); err != nil { + return err + } + return nil +} + +func (u *UpdateApplicationResponse) GetData() *Application { + if u == nil { + return nil + } + return u.Data +} diff --git a/internal/membershipclient/models/components/updateorganizationclientrequest.go b/internal/membershipclient/models/components/updateorganizationclientrequest.go new file mode 100644 index 00000000..ab8aca55 --- /dev/null +++ b/internal/membershipclient/models/components/updateorganizationclientrequest.go @@ -0,0 +1,24 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type UpdateOrganizationClientRequest struct { + // Name of the client + Name string `json:"name"` + // Description of the client + Description *string `json:"description,omitzero"` +} + +func (u *UpdateOrganizationClientRequest) GetName() string { + if u == nil { + return "" + } + return u.Name +} + +func (u *UpdateOrganizationClientRequest) GetDescription() *string { + if u == nil { + return nil + } + return u.Description +} diff --git a/internal/membershipclient/models/components/updateorganizationuserrequest.go b/internal/membershipclient/models/components/updateorganizationuserrequest.go new file mode 100644 index 00000000..caa167b9 --- /dev/null +++ b/internal/membershipclient/models/components/updateorganizationuserrequest.go @@ -0,0 +1,15 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type UpdateOrganizationUserRequest struct { + // Policy ID applied to the user + PolicyID *int64 `json:"policyId,omitzero"` +} + +func (u *UpdateOrganizationUserRequest) GetPolicyID() *int64 { + if u == nil { + return nil + } + return u.PolicyID +} diff --git a/internal/membershipclient/models/components/updatepolicyresponse.go b/internal/membershipclient/models/components/updatepolicyresponse.go new file mode 100644 index 00000000..9612fe83 --- /dev/null +++ b/internal/membershipclient/models/components/updatepolicyresponse.go @@ -0,0 +1,29 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" +) + +type UpdatePolicyResponse struct { + Data *Policy `json:"data,omitzero"` +} + +func (u UpdatePolicyResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UpdatePolicyResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, nil); err != nil { + return err + } + return nil +} + +func (u *UpdatePolicyResponse) GetData() *Policy { + if u == nil { + return nil + } + return u.Data +} diff --git a/internal/membershipclient/models/components/updatestackuserrequest.go b/internal/membershipclient/models/components/updatestackuserrequest.go new file mode 100644 index 00000000..8bf7a622 --- /dev/null +++ b/internal/membershipclient/models/components/updatestackuserrequest.go @@ -0,0 +1,14 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type UpdateStackUserRequest struct { + PolicyID int64 `json:"policyId"` +} + +func (u *UpdateStackUserRequest) GetPolicyID() int64 { + if u == nil { + return 0 + } + return u.PolicyID +} diff --git a/internal/membershipclient/models/components/user.go b/internal/membershipclient/models/components/user.go new file mode 100644 index 00000000..44b07086 --- /dev/null +++ b/internal/membershipclient/models/components/user.go @@ -0,0 +1,31 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type User struct { + Email string `json:"email"` + // User ID + ID string `json:"id"` + Role *SystemRole `json:"role,omitzero"` +} + +func (u *User) GetEmail() string { + if u == nil { + return "" + } + return u.Email +} + +func (u *User) GetID() string { + if u == nil { + return "" + } + return u.ID +} + +func (u *User) GetRole() *SystemRole { + if u == nil { + return nil + } + return u.Role +} diff --git a/internal/membershipclient/models/components/version.go b/internal/membershipclient/models/components/version.go new file mode 100644 index 00000000..5fde6f1b --- /dev/null +++ b/internal/membershipclient/models/components/version.go @@ -0,0 +1,39 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package components + +type Version struct { + Name string `json:"name"` + Versions map[string]string `json:"versions"` + RegionID string `json:"regionID"` + // Indicates if this version is deprecated and should not be used + Deprecated *bool `json:"deprecated,omitzero"` +} + +func (v *Version) GetName() string { + if v == nil { + return "" + } + return v.Name +} + +func (v *Version) GetVersions() map[string]string { + if v == nil { + return map[string]string{} + } + return v.Versions +} + +func (v *Version) GetRegionID() string { + if v == nil { + return "" + } + return v.RegionID +} + +func (v *Version) GetDeprecated() *bool { + if v == nil { + return nil + } + return v.Deprecated +} diff --git a/internal/membershipclient/models/operations/acceptinvitation.go b/internal/membershipclient/models/operations/acceptinvitation.go new file mode 100644 index 00000000..4c834dab --- /dev/null +++ b/internal/membershipclient/models/operations/acceptinvitation.go @@ -0,0 +1,50 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type AcceptInvitationRequest struct { + InvitationID string `pathParam:"style=simple,explode=false,name=invitationId"` +} + +func (a *AcceptInvitationRequest) GetInvitationID() string { + if a == nil { + return "" + } + return a.InvitationID +} + +type AcceptInvitationResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (a AcceptInvitationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AcceptInvitationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (a *AcceptInvitationResponse) GetHTTPMeta() components.HTTPMetadata { + if a == nil { + return components.HTTPMetadata{} + } + return a.HTTPMeta +} + +func (a *AcceptInvitationResponse) GetError() *components.Error { + if a == nil { + return nil + } + return a.Error +} diff --git a/internal/membershipclient/models/operations/addfeatures.go b/internal/membershipclient/models/operations/addfeatures.go new file mode 100644 index 00000000..9194e875 --- /dev/null +++ b/internal/membershipclient/models/operations/addfeatures.go @@ -0,0 +1,80 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type AddFeaturesRequestBody struct { + Features []string `json:"features"` +} + +func (a *AddFeaturesRequestBody) GetFeatures() []string { + if a == nil { + return []string{} + } + return a.Features +} + +type AddFeaturesRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + Body *AddFeaturesRequestBody `request:"mediaType=application/json"` +} + +func (a AddFeaturesRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AddFeaturesRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, []string{"organizationId"}); err != nil { + return err + } + return nil +} + +func (a *AddFeaturesRequest) GetOrganizationID() string { + if a == nil { + return "" + } + return a.OrganizationID +} + +func (a *AddFeaturesRequest) GetBody() *AddFeaturesRequestBody { + if a == nil { + return nil + } + return a.Body +} + +type AddFeaturesResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (a AddFeaturesResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AddFeaturesResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (a *AddFeaturesResponse) GetHTTPMeta() components.HTTPMetadata { + if a == nil { + return components.HTTPMetadata{} + } + return a.HTTPMeta +} + +func (a *AddFeaturesResponse) GetError() *components.Error { + if a == nil { + return nil + } + return a.Error +} diff --git a/internal/membershipclient/models/operations/addscopetopolicy.go b/internal/membershipclient/models/operations/addscopetopolicy.go new file mode 100644 index 00000000..3f777d27 --- /dev/null +++ b/internal/membershipclient/models/operations/addscopetopolicy.go @@ -0,0 +1,66 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type AddScopeToPolicyRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + PolicyID int64 `pathParam:"style=simple,explode=false,name=policyId"` + ScopeID int64 `pathParam:"style=simple,explode=false,name=scopeId"` +} + +func (a *AddScopeToPolicyRequest) GetOrganizationID() string { + if a == nil { + return "" + } + return a.OrganizationID +} + +func (a *AddScopeToPolicyRequest) GetPolicyID() int64 { + if a == nil { + return 0 + } + return a.PolicyID +} + +func (a *AddScopeToPolicyRequest) GetScopeID() int64 { + if a == nil { + return 0 + } + return a.ScopeID +} + +type AddScopeToPolicyResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (a AddScopeToPolicyResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(a, "", false) +} + +func (a *AddScopeToPolicyResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &a, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (a *AddScopeToPolicyResponse) GetHTTPMeta() components.HTTPMetadata { + if a == nil { + return components.HTTPMetadata{} + } + return a.HTTPMeta +} + +func (a *AddScopeToPolicyResponse) GetError() *components.Error { + if a == nil { + return nil + } + return a.Error +} diff --git a/internal/membershipclient/models/operations/createapplication.go b/internal/membershipclient/models/operations/createapplication.go new file mode 100644 index 00000000..012dcfef --- /dev/null +++ b/internal/membershipclient/models/operations/createapplication.go @@ -0,0 +1,48 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type CreateApplicationResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Application created + CreateApplicationResponse *components.CreateApplicationResponse + // Error + Error *components.Error +} + +func (c CreateApplicationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreateApplicationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (c *CreateApplicationResponse) GetHTTPMeta() components.HTTPMetadata { + if c == nil { + return components.HTTPMetadata{} + } + return c.HTTPMeta +} + +func (c *CreateApplicationResponse) GetCreateApplicationResponse() *components.CreateApplicationResponse { + if c == nil { + return nil + } + return c.CreateApplicationResponse +} + +func (c *CreateApplicationResponse) GetError() *components.Error { + if c == nil { + return nil + } + return c.Error +} diff --git a/internal/membershipclient/models/operations/createapplicationscope.go b/internal/membershipclient/models/operations/createapplicationscope.go new file mode 100644 index 00000000..62b2ae95 --- /dev/null +++ b/internal/membershipclient/models/operations/createapplicationscope.go @@ -0,0 +1,79 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type CreateApplicationScopeRequest struct { + // The unique identifier of the application (UUID format) + ApplicationID string `pathParam:"style=simple,explode=false,name=applicationId"` + Body *components.CreateApplicationScopeRequest `request:"mediaType=application/json"` +} + +func (c CreateApplicationScopeRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreateApplicationScopeRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, []string{"applicationId"}); err != nil { + return err + } + return nil +} + +func (c *CreateApplicationScopeRequest) GetApplicationID() string { + if c == nil { + return "" + } + return c.ApplicationID +} + +func (c *CreateApplicationScopeRequest) GetBody() *components.CreateApplicationScopeRequest { + if c == nil { + return nil + } + return c.Body +} + +type CreateApplicationScopeResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Application scope created + CreateApplicationScopeResponse *components.CreateApplicationScopeResponse + // Error + Error *components.Error +} + +func (c CreateApplicationScopeResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreateApplicationScopeResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (c *CreateApplicationScopeResponse) GetHTTPMeta() components.HTTPMetadata { + if c == nil { + return components.HTTPMetadata{} + } + return c.HTTPMeta +} + +func (c *CreateApplicationScopeResponse) GetCreateApplicationScopeResponse() *components.CreateApplicationScopeResponse { + if c == nil { + return nil + } + return c.CreateApplicationScopeResponse +} + +func (c *CreateApplicationScopeResponse) GetError() *components.Error { + if c == nil { + return nil + } + return c.Error +} diff --git a/internal/membershipclient/models/operations/createinvitation.go b/internal/membershipclient/models/operations/createinvitation.go new file mode 100644 index 00000000..312c273a --- /dev/null +++ b/internal/membershipclient/models/operations/createinvitation.go @@ -0,0 +1,67 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type CreateInvitationRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + Email string `queryParam:"style=form,explode=true,name=email"` +} + +func (c *CreateInvitationRequest) GetOrganizationID() string { + if c == nil { + return "" + } + return c.OrganizationID +} + +func (c *CreateInvitationRequest) GetEmail() string { + if c == nil { + return "" + } + return c.Email +} + +type CreateInvitationResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Invitation already sent + CreateInvitationResponse *components.CreateInvitationResponse + // Error + Error *components.Error +} + +func (c CreateInvitationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreateInvitationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (c *CreateInvitationResponse) GetHTTPMeta() components.HTTPMetadata { + if c == nil { + return components.HTTPMetadata{} + } + return c.HTTPMeta +} + +func (c *CreateInvitationResponse) GetCreateInvitationResponse() *components.CreateInvitationResponse { + if c == nil { + return nil + } + return c.CreateInvitationResponse +} + +func (c *CreateInvitationResponse) GetError() *components.Error { + if c == nil { + return nil + } + return c.Error +} diff --git a/internal/membershipclient/models/operations/createorganization.go b/internal/membershipclient/models/operations/createorganization.go new file mode 100644 index 00000000..c7c2e5fd --- /dev/null +++ b/internal/membershipclient/models/operations/createorganization.go @@ -0,0 +1,48 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type CreateOrganizationResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Organization created + CreateOrganizationResponse *components.CreateOrganizationResponse + // Error + Error *components.Error +} + +func (c CreateOrganizationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreateOrganizationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (c *CreateOrganizationResponse) GetHTTPMeta() components.HTTPMetadata { + if c == nil { + return components.HTTPMetadata{} + } + return c.HTTPMeta +} + +func (c *CreateOrganizationResponse) GetCreateOrganizationResponse() *components.CreateOrganizationResponse { + if c == nil { + return nil + } + return c.CreateOrganizationResponse +} + +func (c *CreateOrganizationResponse) GetError() *components.Error { + if c == nil { + return nil + } + return c.Error +} diff --git a/internal/membershipclient/models/operations/createorganizationclient.go b/internal/membershipclient/models/operations/createorganizationclient.go new file mode 100644 index 00000000..7aa3a0a0 --- /dev/null +++ b/internal/membershipclient/models/operations/createorganizationclient.go @@ -0,0 +1,59 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type CreateOrganizationClientRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` +} + +func (c *CreateOrganizationClientRequest) GetOrganizationID() string { + if c == nil { + return "" + } + return c.OrganizationID +} + +type CreateOrganizationClientResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Client organization created + CreateClientResponseResponse *components.CreateClientResponseResponse + // Error + Error *components.Error +} + +func (c CreateOrganizationClientResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreateOrganizationClientResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (c *CreateOrganizationClientResponse) GetHTTPMeta() components.HTTPMetadata { + if c == nil { + return components.HTTPMetadata{} + } + return c.HTTPMeta +} + +func (c *CreateOrganizationClientResponse) GetCreateClientResponseResponse() *components.CreateClientResponseResponse { + if c == nil { + return nil + } + return c.CreateClientResponseResponse +} + +func (c *CreateOrganizationClientResponse) GetError() *components.Error { + if c == nil { + return nil + } + return c.Error +} diff --git a/internal/membershipclient/models/operations/createpolicy.go b/internal/membershipclient/models/operations/createpolicy.go new file mode 100644 index 00000000..0a22b6da --- /dev/null +++ b/internal/membershipclient/models/operations/createpolicy.go @@ -0,0 +1,78 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type CreatePolicyRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + Body *components.PolicyData `request:"mediaType=application/json"` +} + +func (c CreatePolicyRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreatePolicyRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, []string{"organizationId"}); err != nil { + return err + } + return nil +} + +func (c *CreatePolicyRequest) GetOrganizationID() string { + if c == nil { + return "" + } + return c.OrganizationID +} + +func (c *CreatePolicyRequest) GetBody() *components.PolicyData { + if c == nil { + return nil + } + return c.Body +} + +type CreatePolicyResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Policy created + CreatePolicyResponse *components.CreatePolicyResponse + // Error + Error *components.Error +} + +func (c CreatePolicyResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreatePolicyResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (c *CreatePolicyResponse) GetHTTPMeta() components.HTTPMetadata { + if c == nil { + return components.HTTPMetadata{} + } + return c.HTTPMeta +} + +func (c *CreatePolicyResponse) GetCreatePolicyResponse() *components.CreatePolicyResponse { + if c == nil { + return nil + } + return c.CreatePolicyResponse +} + +func (c *CreatePolicyResponse) GetError() *components.Error { + if c == nil { + return nil + } + return c.Error +} diff --git a/internal/membershipclient/models/operations/createprivateregion.go b/internal/membershipclient/models/operations/createprivateregion.go new file mode 100644 index 00000000..9c1a1025 --- /dev/null +++ b/internal/membershipclient/models/operations/createprivateregion.go @@ -0,0 +1,78 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type CreatePrivateRegionRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + Body *components.CreatePrivateRegionRequest `request:"mediaType=application/json"` +} + +func (c CreatePrivateRegionRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreatePrivateRegionRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, []string{"organizationId"}); err != nil { + return err + } + return nil +} + +func (c *CreatePrivateRegionRequest) GetOrganizationID() string { + if c == nil { + return "" + } + return c.OrganizationID +} + +func (c *CreatePrivateRegionRequest) GetBody() *components.CreatePrivateRegionRequest { + if c == nil { + return nil + } + return c.Body +} + +type CreatePrivateRegionResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Created region + CreatedPrivateRegionResponse *components.CreatedPrivateRegionResponse + // Error + Error *components.Error +} + +func (c CreatePrivateRegionResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreatePrivateRegionResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (c *CreatePrivateRegionResponse) GetHTTPMeta() components.HTTPMetadata { + if c == nil { + return components.HTTPMetadata{} + } + return c.HTTPMeta +} + +func (c *CreatePrivateRegionResponse) GetCreatedPrivateRegionResponse() *components.CreatedPrivateRegionResponse { + if c == nil { + return nil + } + return c.CreatedPrivateRegionResponse +} + +func (c *CreatePrivateRegionResponse) GetError() *components.Error { + if c == nil { + return nil + } + return c.Error +} diff --git a/internal/membershipclient/models/operations/createstack.go b/internal/membershipclient/models/operations/createstack.go new file mode 100644 index 00000000..4d37a7ab --- /dev/null +++ b/internal/membershipclient/models/operations/createstack.go @@ -0,0 +1,78 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type CreateStackRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + Body *components.CreateStackRequest `request:"mediaType=application/json"` +} + +func (c CreateStackRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreateStackRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, []string{"organizationId"}); err != nil { + return err + } + return nil +} + +func (c *CreateStackRequest) GetOrganizationID() string { + if c == nil { + return "" + } + return c.OrganizationID +} + +func (c *CreateStackRequest) GetBody() *components.CreateStackRequest { + if c == nil { + return nil + } + return c.Body +} + +type CreateStackResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Stack created + CreateStackResponse *components.CreateStackResponse + // Error + Error *components.Error +} + +func (c CreateStackResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreateStackResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (c *CreateStackResponse) GetHTTPMeta() components.HTTPMetadata { + if c == nil { + return components.HTTPMetadata{} + } + return c.HTTPMeta +} + +func (c *CreateStackResponse) GetCreateStackResponse() *components.CreateStackResponse { + if c == nil { + return nil + } + return c.CreateStackResponse +} + +func (c *CreateStackResponse) GetError() *components.Error { + if c == nil { + return nil + } + return c.Error +} diff --git a/internal/membershipclient/models/operations/createuser.go b/internal/membershipclient/models/operations/createuser.go new file mode 100644 index 00000000..4d70697b --- /dev/null +++ b/internal/membershipclient/models/operations/createuser.go @@ -0,0 +1,48 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type CreateUserResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // User created successfully + CreateUserResponse *components.CreateUserResponse + // Invalid request (missing or invalid email) + Error *components.Error +} + +func (c CreateUserResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(c, "", false) +} + +func (c *CreateUserResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &c, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (c *CreateUserResponse) GetHTTPMeta() components.HTTPMetadata { + if c == nil { + return components.HTTPMetadata{} + } + return c.HTTPMeta +} + +func (c *CreateUserResponse) GetCreateUserResponse() *components.CreateUserResponse { + if c == nil { + return nil + } + return c.CreateUserResponse +} + +func (c *CreateUserResponse) GetError() *components.Error { + if c == nil { + return nil + } + return c.Error +} diff --git a/internal/membershipclient/models/operations/declineinvitation.go b/internal/membershipclient/models/operations/declineinvitation.go new file mode 100644 index 00000000..6ff05244 --- /dev/null +++ b/internal/membershipclient/models/operations/declineinvitation.go @@ -0,0 +1,50 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type DeclineInvitationRequest struct { + InvitationID string `pathParam:"style=simple,explode=false,name=invitationId"` +} + +func (d *DeclineInvitationRequest) GetInvitationID() string { + if d == nil { + return "" + } + return d.InvitationID +} + +type DeclineInvitationResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (d DeclineInvitationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(d, "", false) +} + +func (d *DeclineInvitationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &d, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (d *DeclineInvitationResponse) GetHTTPMeta() components.HTTPMetadata { + if d == nil { + return components.HTTPMetadata{} + } + return d.HTTPMeta +} + +func (d *DeclineInvitationResponse) GetError() *components.Error { + if d == nil { + return nil + } + return d.Error +} diff --git a/internal/membershipclient/models/operations/deleteapplication.go b/internal/membershipclient/models/operations/deleteapplication.go new file mode 100644 index 00000000..b00a5460 --- /dev/null +++ b/internal/membershipclient/models/operations/deleteapplication.go @@ -0,0 +1,50 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type DeleteApplicationRequest struct { + ApplicationID string `pathParam:"style=simple,explode=false,name=applicationId"` +} + +func (d *DeleteApplicationRequest) GetApplicationID() string { + if d == nil { + return "" + } + return d.ApplicationID +} + +type DeleteApplicationResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (d DeleteApplicationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(d, "", false) +} + +func (d *DeleteApplicationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &d, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (d *DeleteApplicationResponse) GetHTTPMeta() components.HTTPMetadata { + if d == nil { + return components.HTTPMetadata{} + } + return d.HTTPMeta +} + +func (d *DeleteApplicationResponse) GetError() *components.Error { + if d == nil { + return nil + } + return d.Error +} diff --git a/internal/membershipclient/models/operations/deleteapplicationscope.go b/internal/membershipclient/models/operations/deleteapplicationscope.go new file mode 100644 index 00000000..9a5d2ed7 --- /dev/null +++ b/internal/membershipclient/models/operations/deleteapplicationscope.go @@ -0,0 +1,60 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type DeleteApplicationScopeRequest struct { + // The unique identifier of the application (UUID format) + ApplicationID string `pathParam:"style=simple,explode=false,name=applicationId"` + // The unique identifier of the scope to operate on + ScopeID int64 `pathParam:"style=simple,explode=false,name=scopeID"` +} + +func (d *DeleteApplicationScopeRequest) GetApplicationID() string { + if d == nil { + return "" + } + return d.ApplicationID +} + +func (d *DeleteApplicationScopeRequest) GetScopeID() int64 { + if d == nil { + return 0 + } + return d.ScopeID +} + +type DeleteApplicationScopeResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Invalid request (invalid UUID or empty scope ID) + Error *components.Error +} + +func (d DeleteApplicationScopeResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(d, "", false) +} + +func (d *DeleteApplicationScopeResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &d, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (d *DeleteApplicationScopeResponse) GetHTTPMeta() components.HTTPMetadata { + if d == nil { + return components.HTTPMetadata{} + } + return d.HTTPMeta +} + +func (d *DeleteApplicationScopeResponse) GetError() *components.Error { + if d == nil { + return nil + } + return d.Error +} diff --git a/internal/membershipclient/models/operations/deleteauthenticationprovider.go b/internal/membershipclient/models/operations/deleteauthenticationprovider.go new file mode 100644 index 00000000..c6000c66 --- /dev/null +++ b/internal/membershipclient/models/operations/deleteauthenticationprovider.go @@ -0,0 +1,50 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type DeleteAuthenticationProviderRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` +} + +func (d *DeleteAuthenticationProviderRequest) GetOrganizationID() string { + if d == nil { + return "" + } + return d.OrganizationID +} + +type DeleteAuthenticationProviderResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (d DeleteAuthenticationProviderResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(d, "", false) +} + +func (d *DeleteAuthenticationProviderResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &d, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (d *DeleteAuthenticationProviderResponse) GetHTTPMeta() components.HTTPMetadata { + if d == nil { + return components.HTTPMetadata{} + } + return d.HTTPMeta +} + +func (d *DeleteAuthenticationProviderResponse) GetError() *components.Error { + if d == nil { + return nil + } + return d.Error +} diff --git a/internal/membershipclient/models/operations/deletefeature.go b/internal/membershipclient/models/operations/deletefeature.go new file mode 100644 index 00000000..65e6e3c6 --- /dev/null +++ b/internal/membershipclient/models/operations/deletefeature.go @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type DeleteFeatureRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + Name string `pathParam:"style=simple,explode=false,name=name"` +} + +func (d *DeleteFeatureRequest) GetOrganizationID() string { + if d == nil { + return "" + } + return d.OrganizationID +} + +func (d *DeleteFeatureRequest) GetName() string { + if d == nil { + return "" + } + return d.Name +} + +type DeleteFeatureResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (d DeleteFeatureResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(d, "", false) +} + +func (d *DeleteFeatureResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &d, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (d *DeleteFeatureResponse) GetHTTPMeta() components.HTTPMetadata { + if d == nil { + return components.HTTPMetadata{} + } + return d.HTTPMeta +} + +func (d *DeleteFeatureResponse) GetError() *components.Error { + if d == nil { + return nil + } + return d.Error +} diff --git a/internal/membershipclient/models/operations/deleteinvitation.go b/internal/membershipclient/models/operations/deleteinvitation.go new file mode 100644 index 00000000..d2ca51c0 --- /dev/null +++ b/internal/membershipclient/models/operations/deleteinvitation.go @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type DeleteInvitationRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + InvitationID string `pathParam:"style=simple,explode=false,name=invitationId"` +} + +func (d *DeleteInvitationRequest) GetOrganizationID() string { + if d == nil { + return "" + } + return d.OrganizationID +} + +func (d *DeleteInvitationRequest) GetInvitationID() string { + if d == nil { + return "" + } + return d.InvitationID +} + +type DeleteInvitationResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (d DeleteInvitationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(d, "", false) +} + +func (d *DeleteInvitationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &d, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (d *DeleteInvitationResponse) GetHTTPMeta() components.HTTPMetadata { + if d == nil { + return components.HTTPMetadata{} + } + return d.HTTPMeta +} + +func (d *DeleteInvitationResponse) GetError() *components.Error { + if d == nil { + return nil + } + return d.Error +} diff --git a/internal/membershipclient/models/operations/deleteorganization.go b/internal/membershipclient/models/operations/deleteorganization.go new file mode 100644 index 00000000..073c457c --- /dev/null +++ b/internal/membershipclient/models/operations/deleteorganization.go @@ -0,0 +1,50 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type DeleteOrganizationRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` +} + +func (d *DeleteOrganizationRequest) GetOrganizationID() string { + if d == nil { + return "" + } + return d.OrganizationID +} + +type DeleteOrganizationResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (d DeleteOrganizationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(d, "", false) +} + +func (d *DeleteOrganizationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &d, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (d *DeleteOrganizationResponse) GetHTTPMeta() components.HTTPMetadata { + if d == nil { + return components.HTTPMetadata{} + } + return d.HTTPMeta +} + +func (d *DeleteOrganizationResponse) GetError() *components.Error { + if d == nil { + return nil + } + return d.Error +} diff --git a/internal/membershipclient/models/operations/deleteorganizationclient.go b/internal/membershipclient/models/operations/deleteorganizationclient.go new file mode 100644 index 00000000..1348e712 --- /dev/null +++ b/internal/membershipclient/models/operations/deleteorganizationclient.go @@ -0,0 +1,50 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type DeleteOrganizationClientRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` +} + +func (d *DeleteOrganizationClientRequest) GetOrganizationID() string { + if d == nil { + return "" + } + return d.OrganizationID +} + +type DeleteOrganizationClientResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (d DeleteOrganizationClientResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(d, "", false) +} + +func (d *DeleteOrganizationClientResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &d, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (d *DeleteOrganizationClientResponse) GetHTTPMeta() components.HTTPMetadata { + if d == nil { + return components.HTTPMetadata{} + } + return d.HTTPMeta +} + +func (d *DeleteOrganizationClientResponse) GetError() *components.Error { + if d == nil { + return nil + } + return d.Error +} diff --git a/internal/membershipclient/models/operations/deletepolicy.go b/internal/membershipclient/models/operations/deletepolicy.go new file mode 100644 index 00000000..f0153453 --- /dev/null +++ b/internal/membershipclient/models/operations/deletepolicy.go @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type DeletePolicyRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + PolicyID int64 `pathParam:"style=simple,explode=false,name=policyId"` +} + +func (d *DeletePolicyRequest) GetOrganizationID() string { + if d == nil { + return "" + } + return d.OrganizationID +} + +func (d *DeletePolicyRequest) GetPolicyID() int64 { + if d == nil { + return 0 + } + return d.PolicyID +} + +type DeletePolicyResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (d DeletePolicyResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(d, "", false) +} + +func (d *DeletePolicyResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &d, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (d *DeletePolicyResponse) GetHTTPMeta() components.HTTPMetadata { + if d == nil { + return components.HTTPMetadata{} + } + return d.HTTPMeta +} + +func (d *DeletePolicyResponse) GetError() *components.Error { + if d == nil { + return nil + } + return d.Error +} diff --git a/internal/membershipclient/models/operations/deleteregion.go b/internal/membershipclient/models/operations/deleteregion.go new file mode 100644 index 00000000..ca69fa30 --- /dev/null +++ b/internal/membershipclient/models/operations/deleteregion.go @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type DeleteRegionRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + RegionID string `pathParam:"style=simple,explode=false,name=regionID"` +} + +func (d *DeleteRegionRequest) GetOrganizationID() string { + if d == nil { + return "" + } + return d.OrganizationID +} + +func (d *DeleteRegionRequest) GetRegionID() string { + if d == nil { + return "" + } + return d.RegionID +} + +type DeleteRegionResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (d DeleteRegionResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(d, "", false) +} + +func (d *DeleteRegionResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &d, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (d *DeleteRegionResponse) GetHTTPMeta() components.HTTPMetadata { + if d == nil { + return components.HTTPMetadata{} + } + return d.HTTPMeta +} + +func (d *DeleteRegionResponse) GetError() *components.Error { + if d == nil { + return nil + } + return d.Error +} diff --git a/internal/membershipclient/models/operations/deletestack.go b/internal/membershipclient/models/operations/deletestack.go new file mode 100644 index 00000000..cb5de36e --- /dev/null +++ b/internal/membershipclient/models/operations/deletestack.go @@ -0,0 +1,66 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type DeleteStackRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + StackID string `pathParam:"style=simple,explode=false,name=stackId"` + Force *bool `queryParam:"style=form,explode=true,name=force"` +} + +func (d *DeleteStackRequest) GetOrganizationID() string { + if d == nil { + return "" + } + return d.OrganizationID +} + +func (d *DeleteStackRequest) GetStackID() string { + if d == nil { + return "" + } + return d.StackID +} + +func (d *DeleteStackRequest) GetForce() *bool { + if d == nil { + return nil + } + return d.Force +} + +type DeleteStackResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (d DeleteStackResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(d, "", false) +} + +func (d *DeleteStackResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &d, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (d *DeleteStackResponse) GetHTTPMeta() components.HTTPMetadata { + if d == nil { + return components.HTTPMetadata{} + } + return d.HTTPMeta +} + +func (d *DeleteStackResponse) GetError() *components.Error { + if d == nil { + return nil + } + return d.Error +} diff --git a/internal/membershipclient/models/operations/deletestackuseraccess.go b/internal/membershipclient/models/operations/deletestackuseraccess.go new file mode 100644 index 00000000..6289f542 --- /dev/null +++ b/internal/membershipclient/models/operations/deletestackuseraccess.go @@ -0,0 +1,66 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type DeleteStackUserAccessRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + StackID string `pathParam:"style=simple,explode=false,name=stackId"` + UserID string `pathParam:"style=simple,explode=false,name=userId"` +} + +func (d *DeleteStackUserAccessRequest) GetOrganizationID() string { + if d == nil { + return "" + } + return d.OrganizationID +} + +func (d *DeleteStackUserAccessRequest) GetStackID() string { + if d == nil { + return "" + } + return d.StackID +} + +func (d *DeleteStackUserAccessRequest) GetUserID() string { + if d == nil { + return "" + } + return d.UserID +} + +type DeleteStackUserAccessResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (d DeleteStackUserAccessResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(d, "", false) +} + +func (d *DeleteStackUserAccessResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &d, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (d *DeleteStackUserAccessResponse) GetHTTPMeta() components.HTTPMetadata { + if d == nil { + return components.HTTPMetadata{} + } + return d.HTTPMeta +} + +func (d *DeleteStackUserAccessResponse) GetError() *components.Error { + if d == nil { + return nil + } + return d.Error +} diff --git a/internal/membershipclient/models/operations/deleteuserfromorganization.go b/internal/membershipclient/models/operations/deleteuserfromorganization.go new file mode 100644 index 00000000..6bf44c4d --- /dev/null +++ b/internal/membershipclient/models/operations/deleteuserfromorganization.go @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type DeleteUserFromOrganizationRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + UserID string `pathParam:"style=simple,explode=false,name=userId"` +} + +func (d *DeleteUserFromOrganizationRequest) GetOrganizationID() string { + if d == nil { + return "" + } + return d.OrganizationID +} + +func (d *DeleteUserFromOrganizationRequest) GetUserID() string { + if d == nil { + return "" + } + return d.UserID +} + +type DeleteUserFromOrganizationResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (d DeleteUserFromOrganizationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(d, "", false) +} + +func (d *DeleteUserFromOrganizationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &d, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (d *DeleteUserFromOrganizationResponse) GetHTTPMeta() components.HTTPMetadata { + if d == nil { + return components.HTTPMetadata{} + } + return d.HTTPMeta +} + +func (d *DeleteUserFromOrganizationResponse) GetError() *components.Error { + if d == nil { + return nil + } + return d.Error +} diff --git a/internal/membershipclient/models/operations/disableapplicationfororganization.go b/internal/membershipclient/models/operations/disableapplicationfororganization.go new file mode 100644 index 00000000..50251843 --- /dev/null +++ b/internal/membershipclient/models/operations/disableapplicationfororganization.go @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type DisableApplicationForOrganizationRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + ApplicationID string `pathParam:"style=simple,explode=false,name=applicationId"` +} + +func (d *DisableApplicationForOrganizationRequest) GetOrganizationID() string { + if d == nil { + return "" + } + return d.OrganizationID +} + +func (d *DisableApplicationForOrganizationRequest) GetApplicationID() string { + if d == nil { + return "" + } + return d.ApplicationID +} + +type DisableApplicationForOrganizationResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (d DisableApplicationForOrganizationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(d, "", false) +} + +func (d *DisableApplicationForOrganizationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &d, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (d *DisableApplicationForOrganizationResponse) GetHTTPMeta() components.HTTPMetadata { + if d == nil { + return components.HTTPMetadata{} + } + return d.HTTPMeta +} + +func (d *DisableApplicationForOrganizationResponse) GetError() *components.Error { + if d == nil { + return nil + } + return d.Error +} diff --git a/internal/membershipclient/models/operations/disablemodule.go b/internal/membershipclient/models/operations/disablemodule.go new file mode 100644 index 00000000..847a09c5 --- /dev/null +++ b/internal/membershipclient/models/operations/disablemodule.go @@ -0,0 +1,66 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type DisableModuleRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + StackID string `pathParam:"style=simple,explode=false,name=stackId"` + Name string `queryParam:"style=form,explode=true,name=name"` +} + +func (d *DisableModuleRequest) GetOrganizationID() string { + if d == nil { + return "" + } + return d.OrganizationID +} + +func (d *DisableModuleRequest) GetStackID() string { + if d == nil { + return "" + } + return d.StackID +} + +func (d *DisableModuleRequest) GetName() string { + if d == nil { + return "" + } + return d.Name +} + +type DisableModuleResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (d DisableModuleResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(d, "", false) +} + +func (d *DisableModuleResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &d, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (d *DisableModuleResponse) GetHTTPMeta() components.HTTPMetadata { + if d == nil { + return components.HTTPMetadata{} + } + return d.HTTPMeta +} + +func (d *DisableModuleResponse) GetError() *components.Error { + if d == nil { + return nil + } + return d.Error +} diff --git a/internal/membershipclient/models/operations/disablestack.go b/internal/membershipclient/models/operations/disablestack.go new file mode 100644 index 00000000..72bfc927 --- /dev/null +++ b/internal/membershipclient/models/operations/disablestack.go @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type DisableStackRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + StackID string `pathParam:"style=simple,explode=false,name=stackId"` +} + +func (d *DisableStackRequest) GetOrganizationID() string { + if d == nil { + return "" + } + return d.OrganizationID +} + +func (d *DisableStackRequest) GetStackID() string { + if d == nil { + return "" + } + return d.StackID +} + +type DisableStackResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (d DisableStackResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(d, "", false) +} + +func (d *DisableStackResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &d, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (d *DisableStackResponse) GetHTTPMeta() components.HTTPMetadata { + if d == nil { + return components.HTTPMetadata{} + } + return d.HTTPMeta +} + +func (d *DisableStackResponse) GetError() *components.Error { + if d == nil { + return nil + } + return d.Error +} diff --git a/internal/membershipclient/models/operations/disablestargate.go b/internal/membershipclient/models/operations/disablestargate.go new file mode 100644 index 00000000..06c90747 --- /dev/null +++ b/internal/membershipclient/models/operations/disablestargate.go @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type DisableStargateRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + StackID string `pathParam:"style=simple,explode=false,name=stackId"` +} + +func (d *DisableStargateRequest) GetOrganizationID() string { + if d == nil { + return "" + } + return d.OrganizationID +} + +func (d *DisableStargateRequest) GetStackID() string { + if d == nil { + return "" + } + return d.StackID +} + +type DisableStargateResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (d DisableStargateResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(d, "", false) +} + +func (d *DisableStargateResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &d, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (d *DisableStargateResponse) GetHTTPMeta() components.HTTPMetadata { + if d == nil { + return components.HTTPMetadata{} + } + return d.HTTPMeta +} + +func (d *DisableStargateResponse) GetError() *components.Error { + if d == nil { + return nil + } + return d.Error +} diff --git a/internal/membershipclient/models/operations/enableapplicationfororganization.go b/internal/membershipclient/models/operations/enableapplicationfororganization.go new file mode 100644 index 00000000..361cd979 --- /dev/null +++ b/internal/membershipclient/models/operations/enableapplicationfororganization.go @@ -0,0 +1,67 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type EnableApplicationForOrganizationRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + ApplicationID string `pathParam:"style=simple,explode=false,name=applicationId"` +} + +func (e *EnableApplicationForOrganizationRequest) GetOrganizationID() string { + if e == nil { + return "" + } + return e.OrganizationID +} + +func (e *EnableApplicationForOrganizationRequest) GetApplicationID() string { + if e == nil { + return "" + } + return e.ApplicationID +} + +type EnableApplicationForOrganizationResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Application enabled for organization + EnableApplicationForOrganizationResponse *components.EnableApplicationForOrganizationResponse + // Error + Error *components.Error +} + +func (e EnableApplicationForOrganizationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(e, "", false) +} + +func (e *EnableApplicationForOrganizationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &e, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (e *EnableApplicationForOrganizationResponse) GetHTTPMeta() components.HTTPMetadata { + if e == nil { + return components.HTTPMetadata{} + } + return e.HTTPMeta +} + +func (e *EnableApplicationForOrganizationResponse) GetEnableApplicationForOrganizationResponse() *components.EnableApplicationForOrganizationResponse { + if e == nil { + return nil + } + return e.EnableApplicationForOrganizationResponse +} + +func (e *EnableApplicationForOrganizationResponse) GetError() *components.Error { + if e == nil { + return nil + } + return e.Error +} diff --git a/internal/membershipclient/models/operations/enablemodule.go b/internal/membershipclient/models/operations/enablemodule.go new file mode 100644 index 00000000..3eedda11 --- /dev/null +++ b/internal/membershipclient/models/operations/enablemodule.go @@ -0,0 +1,66 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type EnableModuleRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + StackID string `pathParam:"style=simple,explode=false,name=stackId"` + Name string `queryParam:"style=form,explode=true,name=name"` +} + +func (e *EnableModuleRequest) GetOrganizationID() string { + if e == nil { + return "" + } + return e.OrganizationID +} + +func (e *EnableModuleRequest) GetStackID() string { + if e == nil { + return "" + } + return e.StackID +} + +func (e *EnableModuleRequest) GetName() string { + if e == nil { + return "" + } + return e.Name +} + +type EnableModuleResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (e EnableModuleResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(e, "", false) +} + +func (e *EnableModuleResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &e, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (e *EnableModuleResponse) GetHTTPMeta() components.HTTPMetadata { + if e == nil { + return components.HTTPMetadata{} + } + return e.HTTPMeta +} + +func (e *EnableModuleResponse) GetError() *components.Error { + if e == nil { + return nil + } + return e.Error +} diff --git a/internal/membershipclient/models/operations/enablestack.go b/internal/membershipclient/models/operations/enablestack.go new file mode 100644 index 00000000..6342d5c1 --- /dev/null +++ b/internal/membershipclient/models/operations/enablestack.go @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type EnableStackRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + StackID string `pathParam:"style=simple,explode=false,name=stackId"` +} + +func (e *EnableStackRequest) GetOrganizationID() string { + if e == nil { + return "" + } + return e.OrganizationID +} + +func (e *EnableStackRequest) GetStackID() string { + if e == nil { + return "" + } + return e.StackID +} + +type EnableStackResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (e EnableStackResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(e, "", false) +} + +func (e *EnableStackResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &e, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (e *EnableStackResponse) GetHTTPMeta() components.HTTPMetadata { + if e == nil { + return components.HTTPMetadata{} + } + return e.HTTPMeta +} + +func (e *EnableStackResponse) GetError() *components.Error { + if e == nil { + return nil + } + return e.Error +} diff --git a/internal/membershipclient/models/operations/enablestargate.go b/internal/membershipclient/models/operations/enablestargate.go new file mode 100644 index 00000000..6a15e810 --- /dev/null +++ b/internal/membershipclient/models/operations/enablestargate.go @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type EnableStargateRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + StackID string `pathParam:"style=simple,explode=false,name=stackId"` +} + +func (e *EnableStargateRequest) GetOrganizationID() string { + if e == nil { + return "" + } + return e.OrganizationID +} + +func (e *EnableStargateRequest) GetStackID() string { + if e == nil { + return "" + } + return e.StackID +} + +type EnableStargateResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (e EnableStargateResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(e, "", false) +} + +func (e *EnableStargateResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &e, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (e *EnableStargateResponse) GetHTTPMeta() components.HTTPMetadata { + if e == nil { + return components.HTTPMetadata{} + } + return e.HTTPMeta +} + +func (e *EnableStargateResponse) GetError() *components.Error { + if e == nil { + return nil + } + return e.Error +} diff --git a/internal/membershipclient/models/operations/getapplication.go b/internal/membershipclient/models/operations/getapplication.go new file mode 100644 index 00000000..5cae691e --- /dev/null +++ b/internal/membershipclient/models/operations/getapplication.go @@ -0,0 +1,59 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type GetApplicationRequest struct { + ApplicationID string `pathParam:"style=simple,explode=false,name=applicationId"` +} + +func (g *GetApplicationRequest) GetApplicationID() string { + if g == nil { + return "" + } + return g.ApplicationID +} + +type GetApplicationResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Application details + GetApplicationResponse *components.GetApplicationResponse + // Error + Error *components.Error +} + +func (g GetApplicationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(g, "", false) +} + +func (g *GetApplicationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &g, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (g *GetApplicationResponse) GetHTTPMeta() components.HTTPMetadata { + if g == nil { + return components.HTTPMetadata{} + } + return g.HTTPMeta +} + +func (g *GetApplicationResponse) GetGetApplicationResponse() *components.GetApplicationResponse { + if g == nil { + return nil + } + return g.GetApplicationResponse +} + +func (g *GetApplicationResponse) GetError() *components.Error { + if g == nil { + return nil + } + return g.Error +} diff --git a/internal/membershipclient/models/operations/getorganizationapplication.go b/internal/membershipclient/models/operations/getorganizationapplication.go new file mode 100644 index 00000000..acb7721e --- /dev/null +++ b/internal/membershipclient/models/operations/getorganizationapplication.go @@ -0,0 +1,67 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type GetOrganizationApplicationRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + ApplicationID string `pathParam:"style=simple,explode=false,name=applicationId"` +} + +func (g *GetOrganizationApplicationRequest) GetOrganizationID() string { + if g == nil { + return "" + } + return g.OrganizationID +} + +func (g *GetOrganizationApplicationRequest) GetApplicationID() string { + if g == nil { + return "" + } + return g.ApplicationID +} + +type GetOrganizationApplicationResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Application details + GetApplicationResponse *components.GetApplicationResponse + // Error + Error *components.Error +} + +func (g GetOrganizationApplicationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(g, "", false) +} + +func (g *GetOrganizationApplicationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &g, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (g *GetOrganizationApplicationResponse) GetHTTPMeta() components.HTTPMetadata { + if g == nil { + return components.HTTPMetadata{} + } + return g.HTTPMeta +} + +func (g *GetOrganizationApplicationResponse) GetGetApplicationResponse() *components.GetApplicationResponse { + if g == nil { + return nil + } + return g.GetApplicationResponse +} + +func (g *GetOrganizationApplicationResponse) GetError() *components.Error { + if g == nil { + return nil + } + return g.Error +} diff --git a/internal/membershipclient/models/operations/getregion.go b/internal/membershipclient/models/operations/getregion.go new file mode 100644 index 00000000..cfb619b9 --- /dev/null +++ b/internal/membershipclient/models/operations/getregion.go @@ -0,0 +1,67 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type GetRegionRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + RegionID string `pathParam:"style=simple,explode=false,name=regionID"` +} + +func (g *GetRegionRequest) GetOrganizationID() string { + if g == nil { + return "" + } + return g.OrganizationID +} + +func (g *GetRegionRequest) GetRegionID() string { + if g == nil { + return "" + } + return g.RegionID +} + +type GetRegionResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Get a specific region + GetRegionResponse *components.GetRegionResponse + // Error + Error *components.Error +} + +func (g GetRegionResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(g, "", false) +} + +func (g *GetRegionResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &g, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (g *GetRegionResponse) GetHTTPMeta() components.HTTPMetadata { + if g == nil { + return components.HTTPMetadata{} + } + return g.HTTPMeta +} + +func (g *GetRegionResponse) GetGetRegionResponse() *components.GetRegionResponse { + if g == nil { + return nil + } + return g.GetRegionResponse +} + +func (g *GetRegionResponse) GetError() *components.Error { + if g == nil { + return nil + } + return g.Error +} diff --git a/internal/membershipclient/models/operations/getregionversions.go b/internal/membershipclient/models/operations/getregionversions.go new file mode 100644 index 00000000..894e90db --- /dev/null +++ b/internal/membershipclient/models/operations/getregionversions.go @@ -0,0 +1,67 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type GetRegionVersionsRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + RegionID string `pathParam:"style=simple,explode=false,name=regionID"` +} + +func (g *GetRegionVersionsRequest) GetOrganizationID() string { + if g == nil { + return "" + } + return g.OrganizationID +} + +func (g *GetRegionVersionsRequest) GetRegionID() string { + if g == nil { + return "" + } + return g.RegionID +} + +type GetRegionVersionsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Get a specific region + GetRegionVersionsResponse *components.GetRegionVersionsResponse + // Error + Error *components.Error +} + +func (g GetRegionVersionsResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(g, "", false) +} + +func (g *GetRegionVersionsResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &g, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (g *GetRegionVersionsResponse) GetHTTPMeta() components.HTTPMetadata { + if g == nil { + return components.HTTPMetadata{} + } + return g.HTTPMeta +} + +func (g *GetRegionVersionsResponse) GetGetRegionVersionsResponse() *components.GetRegionVersionsResponse { + if g == nil { + return nil + } + return g.GetRegionVersionsResponse +} + +func (g *GetRegionVersionsResponse) GetError() *components.Error { + if g == nil { + return nil + } + return g.Error +} diff --git a/internal/membershipclient/models/operations/getserverinfo.go b/internal/membershipclient/models/operations/getserverinfo.go new file mode 100644 index 00000000..03a43957 --- /dev/null +++ b/internal/membershipclient/models/operations/getserverinfo.go @@ -0,0 +1,48 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type GetServerInfoResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Server information + ServerInfo *components.ServerInfo + // Error + Error *components.Error +} + +func (g GetServerInfoResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(g, "", false) +} + +func (g *GetServerInfoResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &g, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (g *GetServerInfoResponse) GetHTTPMeta() components.HTTPMetadata { + if g == nil { + return components.HTTPMetadata{} + } + return g.HTTPMeta +} + +func (g *GetServerInfoResponse) GetServerInfo() *components.ServerInfo { + if g == nil { + return nil + } + return g.ServerInfo +} + +func (g *GetServerInfoResponse) GetError() *components.Error { + if g == nil { + return nil + } + return g.Error +} diff --git a/internal/membershipclient/models/operations/getstack.go b/internal/membershipclient/models/operations/getstack.go new file mode 100644 index 00000000..509560f3 --- /dev/null +++ b/internal/membershipclient/models/operations/getstack.go @@ -0,0 +1,67 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type GetStackRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + StackID string `pathParam:"style=simple,explode=false,name=stackId"` +} + +func (g *GetStackRequest) GetOrganizationID() string { + if g == nil { + return "" + } + return g.OrganizationID +} + +func (g *GetStackRequest) GetStackID() string { + if g == nil { + return "" + } + return g.StackID +} + +type GetStackResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + CreateStackResponse *components.CreateStackResponse + // Error + Error *components.Error +} + +func (g GetStackResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(g, "", false) +} + +func (g *GetStackResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &g, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (g *GetStackResponse) GetHTTPMeta() components.HTTPMetadata { + if g == nil { + return components.HTTPMetadata{} + } + return g.HTTPMeta +} + +func (g *GetStackResponse) GetCreateStackResponse() *components.CreateStackResponse { + if g == nil { + return nil + } + return g.CreateStackResponse +} + +func (g *GetStackResponse) GetError() *components.Error { + if g == nil { + return nil + } + return g.Error +} diff --git a/internal/membershipclient/models/operations/listapplications.go b/internal/membershipclient/models/operations/listapplications.go new file mode 100644 index 00000000..a72661d9 --- /dev/null +++ b/internal/membershipclient/models/operations/listapplications.go @@ -0,0 +1,48 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ListApplicationsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // List of applications + ListApplicationsResponse *components.ListApplicationsResponse + // Error + Error *components.Error +} + +func (l ListApplicationsResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListApplicationsResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (l *ListApplicationsResponse) GetHTTPMeta() components.HTTPMetadata { + if l == nil { + return components.HTTPMetadata{} + } + return l.HTTPMeta +} + +func (l *ListApplicationsResponse) GetListApplicationsResponse() *components.ListApplicationsResponse { + if l == nil { + return nil + } + return l.ListApplicationsResponse +} + +func (l *ListApplicationsResponse) GetError() *components.Error { + if l == nil { + return nil + } + return l.Error +} diff --git a/internal/membershipclient/models/operations/listfeatures.go b/internal/membershipclient/models/operations/listfeatures.go new file mode 100644 index 00000000..d953a7c3 --- /dev/null +++ b/internal/membershipclient/models/operations/listfeatures.go @@ -0,0 +1,71 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ListFeaturesRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` +} + +func (l *ListFeaturesRequest) GetOrganizationID() string { + if l == nil { + return "" + } + return l.OrganizationID +} + +// ListFeaturesResponseBody - List of features +type ListFeaturesResponseBody struct { + Data []components.OrganizationFeature `json:"data"` +} + +func (l *ListFeaturesResponseBody) GetData() []components.OrganizationFeature { + if l == nil { + return []components.OrganizationFeature{} + } + return l.Data +} + +type ListFeaturesResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // List of features + Object *ListFeaturesResponseBody + // Error + Error *components.Error +} + +func (l ListFeaturesResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListFeaturesResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (l *ListFeaturesResponse) GetHTTPMeta() components.HTTPMetadata { + if l == nil { + return components.HTTPMetadata{} + } + return l.HTTPMeta +} + +func (l *ListFeaturesResponse) GetObject() *ListFeaturesResponseBody { + if l == nil { + return nil + } + return l.Object +} + +func (l *ListFeaturesResponse) GetError() *components.Error { + if l == nil { + return nil + } + return l.Error +} diff --git a/internal/membershipclient/models/operations/listinvitations.go b/internal/membershipclient/models/operations/listinvitations.go new file mode 100644 index 00000000..4dc1fe40 --- /dev/null +++ b/internal/membershipclient/models/operations/listinvitations.go @@ -0,0 +1,69 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ListInvitationsRequest struct { + // Status of organizations + Status *string `queryParam:"style=form,explode=true,name=status"` + // Status of organizations + Organization *string `queryParam:"style=form,explode=true,name=organization"` +} + +func (l *ListInvitationsRequest) GetStatus() *string { + if l == nil { + return nil + } + return l.Status +} + +func (l *ListInvitationsRequest) GetOrganization() *string { + if l == nil { + return nil + } + return l.Organization +} + +type ListInvitationsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // List of the invitations for the connected user + ListInvitationsResponse *components.ListInvitationsResponse + // Error + Error *components.Error +} + +func (l ListInvitationsResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListInvitationsResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (l *ListInvitationsResponse) GetHTTPMeta() components.HTTPMetadata { + if l == nil { + return components.HTTPMetadata{} + } + return l.HTTPMeta +} + +func (l *ListInvitationsResponse) GetListInvitationsResponse() *components.ListInvitationsResponse { + if l == nil { + return nil + } + return l.ListInvitationsResponse +} + +func (l *ListInvitationsResponse) GetError() *components.Error { + if l == nil { + return nil + } + return l.Error +} diff --git a/internal/membershipclient/models/operations/listlogs.go b/internal/membershipclient/models/operations/listlogs.go new file mode 100644 index 00000000..05793199 --- /dev/null +++ b/internal/membershipclient/models/operations/listlogs.go @@ -0,0 +1,115 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ListLogsRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + StackID *string `queryParam:"style=form,explode=true,name=stackId"` + Cursor *string `queryParam:"style=form,explode=true,name=cursor"` + PageSize *int64 `queryParam:"style=form,explode=true,name=pageSize"` + Action *components.Action `queryParam:"style=form,explode=true,name=action"` + UserID *string `queryParam:"style=form,explode=true,name=userId"` + Key *string `queryParam:"style=form,explode=true,name=key"` + Value *string `queryParam:"style=form,explode=true,name=value"` +} + +func (l *ListLogsRequest) GetOrganizationID() string { + if l == nil { + return "" + } + return l.OrganizationID +} + +func (l *ListLogsRequest) GetStackID() *string { + if l == nil { + return nil + } + return l.StackID +} + +func (l *ListLogsRequest) GetCursor() *string { + if l == nil { + return nil + } + return l.Cursor +} + +func (l *ListLogsRequest) GetPageSize() *int64 { + if l == nil { + return nil + } + return l.PageSize +} + +func (l *ListLogsRequest) GetAction() *components.Action { + if l == nil { + return nil + } + return l.Action +} + +func (l *ListLogsRequest) GetUserID() *string { + if l == nil { + return nil + } + return l.UserID +} + +func (l *ListLogsRequest) GetKey() *string { + if l == nil { + return nil + } + return l.Key +} + +func (l *ListLogsRequest) GetValue() *string { + if l == nil { + return nil + } + return l.Value +} + +type ListLogsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Cursor of logs + LogCursor *components.LogCursor + // Error + Error *components.Error +} + +func (l ListLogsResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListLogsResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (l *ListLogsResponse) GetHTTPMeta() components.HTTPMetadata { + if l == nil { + return components.HTTPMetadata{} + } + return l.HTTPMeta +} + +func (l *ListLogsResponse) GetLogCursor() *components.LogCursor { + if l == nil { + return nil + } + return l.LogCursor +} + +func (l *ListLogsResponse) GetError() *components.Error { + if l == nil { + return nil + } + return l.Error +} diff --git a/internal/membershipclient/models/operations/listmodules.go b/internal/membershipclient/models/operations/listmodules.go new file mode 100644 index 00000000..f830eb20 --- /dev/null +++ b/internal/membershipclient/models/operations/listmodules.go @@ -0,0 +1,67 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ListModulesRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + StackID string `pathParam:"style=simple,explode=false,name=stackId"` +} + +func (l *ListModulesRequest) GetOrganizationID() string { + if l == nil { + return "" + } + return l.OrganizationID +} + +func (l *ListModulesRequest) GetStackID() string { + if l == nil { + return "" + } + return l.StackID +} + +type ListModulesResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // List of modules + ListModulesResponse *components.ListModulesResponse + // Error + Error *components.Error +} + +func (l ListModulesResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListModulesResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (l *ListModulesResponse) GetHTTPMeta() components.HTTPMetadata { + if l == nil { + return components.HTTPMetadata{} + } + return l.HTTPMeta +} + +func (l *ListModulesResponse) GetListModulesResponse() *components.ListModulesResponse { + if l == nil { + return nil + } + return l.ListModulesResponse +} + +func (l *ListModulesResponse) GetError() *components.Error { + if l == nil { + return nil + } + return l.Error +} diff --git a/internal/membershipclient/models/operations/listorganizationapplications.go b/internal/membershipclient/models/operations/listorganizationapplications.go new file mode 100644 index 00000000..4fdb6897 --- /dev/null +++ b/internal/membershipclient/models/operations/listorganizationapplications.go @@ -0,0 +1,86 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ListOrganizationApplicationsRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + PageSize *int64 `default:"15" queryParam:"style=form,explode=true,name=pageSize"` + Page *int64 `default:"0" queryParam:"style=form,explode=true,name=page"` +} + +func (l ListOrganizationApplicationsRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListOrganizationApplicationsRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, []string{"organizationId"}); err != nil { + return err + } + return nil +} + +func (l *ListOrganizationApplicationsRequest) GetOrganizationID() string { + if l == nil { + return "" + } + return l.OrganizationID +} + +func (l *ListOrganizationApplicationsRequest) GetPageSize() *int64 { + if l == nil { + return nil + } + return l.PageSize +} + +func (l *ListOrganizationApplicationsRequest) GetPage() *int64 { + if l == nil { + return nil + } + return l.Page +} + +type ListOrganizationApplicationsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // List of applications enabled for organization + ListApplicationsResponse *components.ListApplicationsResponse + // Error + Error *components.Error +} + +func (l ListOrganizationApplicationsResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListOrganizationApplicationsResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (l *ListOrganizationApplicationsResponse) GetHTTPMeta() components.HTTPMetadata { + if l == nil { + return components.HTTPMetadata{} + } + return l.HTTPMeta +} + +func (l *ListOrganizationApplicationsResponse) GetListApplicationsResponse() *components.ListApplicationsResponse { + if l == nil { + return nil + } + return l.ListApplicationsResponse +} + +func (l *ListOrganizationApplicationsResponse) GetError() *components.Error { + if l == nil { + return nil + } + return l.Error +} diff --git a/internal/membershipclient/models/operations/listorganizationinvitations.go b/internal/membershipclient/models/operations/listorganizationinvitations.go new file mode 100644 index 00000000..59cd880e --- /dev/null +++ b/internal/membershipclient/models/operations/listorganizationinvitations.go @@ -0,0 +1,68 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ListOrganizationInvitationsRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + // Status of organizations + Status *string `queryParam:"style=form,explode=true,name=status"` +} + +func (l *ListOrganizationInvitationsRequest) GetOrganizationID() string { + if l == nil { + return "" + } + return l.OrganizationID +} + +func (l *ListOrganizationInvitationsRequest) GetStatus() *string { + if l == nil { + return nil + } + return l.Status +} + +type ListOrganizationInvitationsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // List of the invitations for the organization + ListInvitationsResponse *components.ListInvitationsResponse + // Error + Error *components.Error +} + +func (l ListOrganizationInvitationsResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListOrganizationInvitationsResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (l *ListOrganizationInvitationsResponse) GetHTTPMeta() components.HTTPMetadata { + if l == nil { + return components.HTTPMetadata{} + } + return l.HTTPMeta +} + +func (l *ListOrganizationInvitationsResponse) GetListInvitationsResponse() *components.ListInvitationsResponse { + if l == nil { + return nil + } + return l.ListInvitationsResponse +} + +func (l *ListOrganizationInvitationsResponse) GetError() *components.Error { + if l == nil { + return nil + } + return l.Error +} diff --git a/internal/membershipclient/models/operations/listorganizations.go b/internal/membershipclient/models/operations/listorganizations.go new file mode 100644 index 00000000..f86ba9d5 --- /dev/null +++ b/internal/membershipclient/models/operations/listorganizations.go @@ -0,0 +1,59 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ListOrganizationsRequest struct { + Expand *bool `queryParam:"style=form,explode=true,name=expand"` +} + +func (l *ListOrganizationsRequest) GetExpand() *bool { + if l == nil { + return nil + } + return l.Expand +} + +type ListOrganizationsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // List of organizations + ListOrganizationExpandedResponse *components.ListOrganizationExpandedResponse + // Error + Error *components.Error +} + +func (l ListOrganizationsResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListOrganizationsResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (l *ListOrganizationsResponse) GetHTTPMeta() components.HTTPMetadata { + if l == nil { + return components.HTTPMetadata{} + } + return l.HTTPMeta +} + +func (l *ListOrganizationsResponse) GetListOrganizationExpandedResponse() *components.ListOrganizationExpandedResponse { + if l == nil { + return nil + } + return l.ListOrganizationExpandedResponse +} + +func (l *ListOrganizationsResponse) GetError() *components.Error { + if l == nil { + return nil + } + return l.Error +} diff --git a/internal/membershipclient/models/operations/listorganizationsexpanded.go b/internal/membershipclient/models/operations/listorganizationsexpanded.go new file mode 100644 index 00000000..7670b075 --- /dev/null +++ b/internal/membershipclient/models/operations/listorganizationsexpanded.go @@ -0,0 +1,39 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ListOrganizationsExpandedResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // List of organizations with expanded data + ListOrganizationExpandedResponse *components.ListOrganizationExpandedResponse +} + +func (l ListOrganizationsExpandedResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListOrganizationsExpandedResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (l *ListOrganizationsExpandedResponse) GetHTTPMeta() components.HTTPMetadata { + if l == nil { + return components.HTTPMetadata{} + } + return l.HTTPMeta +} + +func (l *ListOrganizationsExpandedResponse) GetListOrganizationExpandedResponse() *components.ListOrganizationExpandedResponse { + if l == nil { + return nil + } + return l.ListOrganizationExpandedResponse +} diff --git a/internal/membershipclient/models/operations/listpolicies.go b/internal/membershipclient/models/operations/listpolicies.go new file mode 100644 index 00000000..75a2ebe4 --- /dev/null +++ b/internal/membershipclient/models/operations/listpolicies.go @@ -0,0 +1,59 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ListPoliciesRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` +} + +func (l *ListPoliciesRequest) GetOrganizationID() string { + if l == nil { + return "" + } + return l.OrganizationID +} + +type ListPoliciesResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // List of policies + ListPoliciesResponse *components.ListPoliciesResponse + // Error + Error *components.Error +} + +func (l ListPoliciesResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListPoliciesResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (l *ListPoliciesResponse) GetHTTPMeta() components.HTTPMetadata { + if l == nil { + return components.HTTPMetadata{} + } + return l.HTTPMeta +} + +func (l *ListPoliciesResponse) GetListPoliciesResponse() *components.ListPoliciesResponse { + if l == nil { + return nil + } + return l.ListPoliciesResponse +} + +func (l *ListPoliciesResponse) GetError() *components.Error { + if l == nil { + return nil + } + return l.Error +} diff --git a/internal/membershipclient/models/operations/listregions.go b/internal/membershipclient/models/operations/listregions.go new file mode 100644 index 00000000..e95a7184 --- /dev/null +++ b/internal/membershipclient/models/operations/listregions.go @@ -0,0 +1,59 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ListRegionsRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` +} + +func (l *ListRegionsRequest) GetOrganizationID() string { + if l == nil { + return "" + } + return l.OrganizationID +} + +type ListRegionsResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // List of the regions + ListRegionsResponse *components.ListRegionsResponse + // Error + Error *components.Error +} + +func (l ListRegionsResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListRegionsResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (l *ListRegionsResponse) GetHTTPMeta() components.HTTPMetadata { + if l == nil { + return components.HTTPMetadata{} + } + return l.HTTPMeta +} + +func (l *ListRegionsResponse) GetListRegionsResponse() *components.ListRegionsResponse { + if l == nil { + return nil + } + return l.ListRegionsResponse +} + +func (l *ListRegionsResponse) GetError() *components.Error { + if l == nil { + return nil + } + return l.Error +} diff --git a/internal/membershipclient/models/operations/liststacks.go b/internal/membershipclient/models/operations/liststacks.go new file mode 100644 index 00000000..6afe2d2c --- /dev/null +++ b/internal/membershipclient/models/operations/liststacks.go @@ -0,0 +1,79 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ListStacksRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + // Include deleted and disabled stacks + All *bool `queryParam:"style=form,explode=true,name=all"` + // Include deleted stacks + // + // Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. + Deleted *bool `queryParam:"style=form,explode=true,name=deleted"` +} + +func (l *ListStacksRequest) GetOrganizationID() string { + if l == nil { + return "" + } + return l.OrganizationID +} + +func (l *ListStacksRequest) GetAll() *bool { + if l == nil { + return nil + } + return l.All +} + +func (l *ListStacksRequest) GetDeleted() *bool { + if l == nil { + return nil + } + return l.Deleted +} + +type ListStacksResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // List of stacks + ListStacksResponse *components.ListStacksResponse + // Error + Error *components.Error +} + +func (l ListStacksResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListStacksResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (l *ListStacksResponse) GetHTTPMeta() components.HTTPMetadata { + if l == nil { + return components.HTTPMetadata{} + } + return l.HTTPMeta +} + +func (l *ListStacksResponse) GetListStacksResponse() *components.ListStacksResponse { + if l == nil { + return nil + } + return l.ListStacksResponse +} + +func (l *ListStacksResponse) GetError() *components.Error { + if l == nil { + return nil + } + return l.Error +} diff --git a/internal/membershipclient/models/operations/liststackusersaccesses.go b/internal/membershipclient/models/operations/liststackusersaccesses.go new file mode 100644 index 00000000..c493fa59 --- /dev/null +++ b/internal/membershipclient/models/operations/liststackusersaccesses.go @@ -0,0 +1,67 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ListStackUsersAccessesRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + StackID string `pathParam:"style=simple,explode=false,name=stackId"` +} + +func (l *ListStackUsersAccessesRequest) GetOrganizationID() string { + if l == nil { + return "" + } + return l.OrganizationID +} + +func (l *ListStackUsersAccessesRequest) GetStackID() string { + if l == nil { + return "" + } + return l.StackID +} + +type ListStackUsersAccessesResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Stack users access + StackUserAccessResponse *components.StackUserAccessResponse + // Error + Error *components.Error +} + +func (l ListStackUsersAccessesResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListStackUsersAccessesResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (l *ListStackUsersAccessesResponse) GetHTTPMeta() components.HTTPMetadata { + if l == nil { + return components.HTTPMetadata{} + } + return l.HTTPMeta +} + +func (l *ListStackUsersAccessesResponse) GetStackUserAccessResponse() *components.StackUserAccessResponse { + if l == nil { + return nil + } + return l.StackUserAccessResponse +} + +func (l *ListStackUsersAccessesResponse) GetError() *components.Error { + if l == nil { + return nil + } + return l.Error +} diff --git a/internal/membershipclient/models/operations/listusersoforganization.go b/internal/membershipclient/models/operations/listusersoforganization.go new file mode 100644 index 00000000..08d256b7 --- /dev/null +++ b/internal/membershipclient/models/operations/listusersoforganization.go @@ -0,0 +1,59 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ListUsersOfOrganizationRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` +} + +func (l *ListUsersOfOrganizationRequest) GetOrganizationID() string { + if l == nil { + return "" + } + return l.OrganizationID +} + +type ListUsersOfOrganizationResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // List of users + ListUsersResponse *components.ListUsersResponse + // Error + Error *components.Error +} + +func (l ListUsersOfOrganizationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(l, "", false) +} + +func (l *ListUsersOfOrganizationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &l, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (l *ListUsersOfOrganizationResponse) GetHTTPMeta() components.HTTPMetadata { + if l == nil { + return components.HTTPMetadata{} + } + return l.HTTPMeta +} + +func (l *ListUsersOfOrganizationResponse) GetListUsersResponse() *components.ListUsersResponse { + if l == nil { + return nil + } + return l.ListUsersResponse +} + +func (l *ListUsersOfOrganizationResponse) GetError() *components.Error { + if l == nil { + return nil + } + return l.Error +} diff --git a/internal/membershipclient/models/operations/options.go b/internal/membershipclient/models/operations/options.go new file mode 100644 index 00000000..4a9a2130 --- /dev/null +++ b/internal/membershipclient/models/operations/options.go @@ -0,0 +1,94 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "errors" + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/retry" + "time" +) + +var ErrUnsupportedOption = errors.New("unsupported option") + +const ( + SupportedOptionRetries = "retries" + SupportedOptionTimeout = "timeout" + SupportedOptionAcceptHeaderOverride = "acceptHeaderOverride" + SupportedOptionURLOverride = "urlOverride" +) + +type Options struct { + ServerURL *string + Retries *retry.Config + Timeout *time.Duration + URLOverride *string + SetHeaders map[string]string +} + +type Option func(*Options, ...string) error + +// WithServerURL allows providing an alternative server URL. +func WithServerURL(serverURL string) Option { + return func(opts *Options, supportedOptions ...string) error { + opts.ServerURL = &serverURL + return nil + } +} + +// WithTemplatedServerURL allows providing an alternative server URL with templated parameters. +func WithTemplatedServerURL(serverURL string, params map[string]string) Option { + return func(opts *Options, supportedOptions ...string) error { + if params != nil { + serverURL = utils.ReplaceParameters(serverURL, params) + } + + opts.ServerURL = &serverURL + return nil + } +} + +// WithRetries allows customizing the default retry configuration. +func WithRetries(config retry.Config) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionRetries) { + return ErrUnsupportedOption + } + + opts.Retries = &config + return nil + } +} + +// WithOperationTimeout allows setting the request timeout applied for an operation. +func WithOperationTimeout(timeout time.Duration) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionRetries) { + return ErrUnsupportedOption + } + + opts.Timeout = &timeout + return nil + } +} + +// WithURLOverride allows overriding the URL. +func WithURLOverride(urlOverride string) Option { + return func(opts *Options, supportedOptions ...string) error { + if !utils.Contains(supportedOptions, SupportedOptionURLOverride) { + return ErrUnsupportedOption + } + + opts.URLOverride = &urlOverride + return nil + } +} + +// WithSetHeaders takes a map of headers that will applied to a request. If the +// request contains headers that are in the map then they will be overwritten. +func WithSetHeaders(hdrs map[string]string) Option { + return func(opts *Options, supportedOptions ...string) error { + opts.SetHeaders = hdrs + return nil + } +} diff --git a/internal/membershipclient/models/operations/organizationclientcreate.go b/internal/membershipclient/models/operations/organizationclientcreate.go new file mode 100644 index 00000000..db1b7f8d --- /dev/null +++ b/internal/membershipclient/models/operations/organizationclientcreate.go @@ -0,0 +1,78 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type OrganizationClientCreateRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + Body *components.CreateOrganizationClientRequest `request:"mediaType=application/json"` +} + +func (o OrganizationClientCreateRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(o, "", false) +} + +func (o *OrganizationClientCreateRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &o, "", false, []string{"organizationId"}); err != nil { + return err + } + return nil +} + +func (o *OrganizationClientCreateRequest) GetOrganizationID() string { + if o == nil { + return "" + } + return o.OrganizationID +} + +func (o *OrganizationClientCreateRequest) GetBody() *components.CreateOrganizationClientRequest { + if o == nil { + return nil + } + return o.Body +} + +type OrganizationClientCreateResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Organization client created + CreateOrganizationClientResponse *components.CreateOrganizationClientResponse + // Error + Error *components.Error +} + +func (o OrganizationClientCreateResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(o, "", false) +} + +func (o *OrganizationClientCreateResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &o, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (o *OrganizationClientCreateResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *OrganizationClientCreateResponse) GetCreateOrganizationClientResponse() *components.CreateOrganizationClientResponse { + if o == nil { + return nil + } + return o.CreateOrganizationClientResponse +} + +func (o *OrganizationClientCreateResponse) GetError() *components.Error { + if o == nil { + return nil + } + return o.Error +} diff --git a/internal/membershipclient/models/operations/organizationclientdelete.go b/internal/membershipclient/models/operations/organizationclientdelete.go new file mode 100644 index 00000000..b471fa08 --- /dev/null +++ b/internal/membershipclient/models/operations/organizationclientdelete.go @@ -0,0 +1,58 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type OrganizationClientDeleteRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + ClientID string `pathParam:"style=simple,explode=false,name=clientId"` +} + +func (o *OrganizationClientDeleteRequest) GetOrganizationID() string { + if o == nil { + return "" + } + return o.OrganizationID +} + +func (o *OrganizationClientDeleteRequest) GetClientID() string { + if o == nil { + return "" + } + return o.ClientID +} + +type OrganizationClientDeleteResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (o OrganizationClientDeleteResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(o, "", false) +} + +func (o *OrganizationClientDeleteResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &o, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (o *OrganizationClientDeleteResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *OrganizationClientDeleteResponse) GetError() *components.Error { + if o == nil { + return nil + } + return o.Error +} diff --git a/internal/membershipclient/models/operations/organizationclientread.go b/internal/membershipclient/models/operations/organizationclientread.go new file mode 100644 index 00000000..3ce4a5bb --- /dev/null +++ b/internal/membershipclient/models/operations/organizationclientread.go @@ -0,0 +1,67 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type OrganizationClientReadRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + ClientID string `pathParam:"style=simple,explode=false,name=clientId"` +} + +func (o *OrganizationClientReadRequest) GetOrganizationID() string { + if o == nil { + return "" + } + return o.OrganizationID +} + +func (o *OrganizationClientReadRequest) GetClientID() string { + if o == nil { + return "" + } + return o.ClientID +} + +type OrganizationClientReadResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Organization client details + ReadOrganizationClientResponse *components.ReadOrganizationClientResponse + // Error + Error *components.Error +} + +func (o OrganizationClientReadResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(o, "", false) +} + +func (o *OrganizationClientReadResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &o, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (o *OrganizationClientReadResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *OrganizationClientReadResponse) GetReadOrganizationClientResponse() *components.ReadOrganizationClientResponse { + if o == nil { + return nil + } + return o.ReadOrganizationClientResponse +} + +func (o *OrganizationClientReadResponse) GetError() *components.Error { + if o == nil { + return nil + } + return o.Error +} diff --git a/internal/membershipclient/models/operations/organizationclientsread.go b/internal/membershipclient/models/operations/organizationclientsread.go new file mode 100644 index 00000000..cdc92ac7 --- /dev/null +++ b/internal/membershipclient/models/operations/organizationclientsread.go @@ -0,0 +1,75 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type OrganizationClientsReadRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + Cursor *string `queryParam:"style=form,explode=true,name=cursor"` + PageSize *int64 `queryParam:"style=form,explode=true,name=pageSize"` +} + +func (o *OrganizationClientsReadRequest) GetOrganizationID() string { + if o == nil { + return "" + } + return o.OrganizationID +} + +func (o *OrganizationClientsReadRequest) GetCursor() *string { + if o == nil { + return nil + } + return o.Cursor +} + +func (o *OrganizationClientsReadRequest) GetPageSize() *int64 { + if o == nil { + return nil + } + return o.PageSize +} + +type OrganizationClientsReadResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Organization client + ReadOrganizationClientsResponse *components.ReadOrganizationClientsResponse + // Error + Error *components.Error +} + +func (o OrganizationClientsReadResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(o, "", false) +} + +func (o *OrganizationClientsReadResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &o, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (o *OrganizationClientsReadResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *OrganizationClientsReadResponse) GetReadOrganizationClientsResponse() *components.ReadOrganizationClientsResponse { + if o == nil { + return nil + } + return o.ReadOrganizationClientsResponse +} + +func (o *OrganizationClientsReadResponse) GetError() *components.Error { + if o == nil { + return nil + } + return o.Error +} diff --git a/internal/membershipclient/models/operations/organizationclientupdate.go b/internal/membershipclient/models/operations/organizationclientupdate.go new file mode 100644 index 00000000..94a10484 --- /dev/null +++ b/internal/membershipclient/models/operations/organizationclientupdate.go @@ -0,0 +1,77 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type OrganizationClientUpdateRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + ClientID string `pathParam:"style=simple,explode=false,name=clientId"` + Body *components.UpdateOrganizationClientRequest `request:"mediaType=application/json"` +} + +func (o OrganizationClientUpdateRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(o, "", false) +} + +func (o *OrganizationClientUpdateRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &o, "", false, []string{"organizationId", "clientId"}); err != nil { + return err + } + return nil +} + +func (o *OrganizationClientUpdateRequest) GetOrganizationID() string { + if o == nil { + return "" + } + return o.OrganizationID +} + +func (o *OrganizationClientUpdateRequest) GetClientID() string { + if o == nil { + return "" + } + return o.ClientID +} + +func (o *OrganizationClientUpdateRequest) GetBody() *components.UpdateOrganizationClientRequest { + if o == nil { + return nil + } + return o.Body +} + +type OrganizationClientUpdateResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (o OrganizationClientUpdateResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(o, "", false) +} + +func (o *OrganizationClientUpdateResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &o, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (o *OrganizationClientUpdateResponse) GetHTTPMeta() components.HTTPMetadata { + if o == nil { + return components.HTTPMetadata{} + } + return o.HTTPMeta +} + +func (o *OrganizationClientUpdateResponse) GetError() *components.Error { + if o == nil { + return nil + } + return o.Error +} diff --git a/internal/membershipclient/models/operations/readauthenticationprovider.go b/internal/membershipclient/models/operations/readauthenticationprovider.go new file mode 100644 index 00000000..01eac238 --- /dev/null +++ b/internal/membershipclient/models/operations/readauthenticationprovider.go @@ -0,0 +1,59 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ReadAuthenticationProviderRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` +} + +func (r *ReadAuthenticationProviderRequest) GetOrganizationID() string { + if r == nil { + return "" + } + return r.OrganizationID +} + +type ReadAuthenticationProviderResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Authentication provider details + AuthenticationProviderResponse *components.AuthenticationProviderResponse + // Error + Error *components.Error +} + +func (r ReadAuthenticationProviderResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(r, "", false) +} + +func (r *ReadAuthenticationProviderResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &r, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (r *ReadAuthenticationProviderResponse) GetHTTPMeta() components.HTTPMetadata { + if r == nil { + return components.HTTPMetadata{} + } + return r.HTTPMeta +} + +func (r *ReadAuthenticationProviderResponse) GetAuthenticationProviderResponse() *components.AuthenticationProviderResponse { + if r == nil { + return nil + } + return r.AuthenticationProviderResponse +} + +func (r *ReadAuthenticationProviderResponse) GetError() *components.Error { + if r == nil { + return nil + } + return r.Error +} diff --git a/internal/membershipclient/models/operations/readconnecteduser.go b/internal/membershipclient/models/operations/readconnecteduser.go new file mode 100644 index 00000000..2f71104e --- /dev/null +++ b/internal/membershipclient/models/operations/readconnecteduser.go @@ -0,0 +1,48 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ReadConnectedUserResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Read a user + ReadUserResponse *components.ReadUserResponse + // Error + Error *components.Error +} + +func (r ReadConnectedUserResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(r, "", false) +} + +func (r *ReadConnectedUserResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &r, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (r *ReadConnectedUserResponse) GetHTTPMeta() components.HTTPMetadata { + if r == nil { + return components.HTTPMetadata{} + } + return r.HTTPMeta +} + +func (r *ReadConnectedUserResponse) GetReadUserResponse() *components.ReadUserResponse { + if r == nil { + return nil + } + return r.ReadUserResponse +} + +func (r *ReadConnectedUserResponse) GetError() *components.Error { + if r == nil { + return nil + } + return r.Error +} diff --git a/internal/membershipclient/models/operations/readorganization.go b/internal/membershipclient/models/operations/readorganization.go new file mode 100644 index 00000000..dbdf43dd --- /dev/null +++ b/internal/membershipclient/models/operations/readorganization.go @@ -0,0 +1,67 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ReadOrganizationRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + Expand *bool `queryParam:"style=form,explode=true,name=expand"` +} + +func (r *ReadOrganizationRequest) GetOrganizationID() string { + if r == nil { + return "" + } + return r.OrganizationID +} + +func (r *ReadOrganizationRequest) GetExpand() *bool { + if r == nil { + return nil + } + return r.Expand +} + +type ReadOrganizationResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + ReadOrganizationResponse *components.ReadOrganizationResponse + // Error + Error *components.Error +} + +func (r ReadOrganizationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(r, "", false) +} + +func (r *ReadOrganizationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &r, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (r *ReadOrganizationResponse) GetHTTPMeta() components.HTTPMetadata { + if r == nil { + return components.HTTPMetadata{} + } + return r.HTTPMeta +} + +func (r *ReadOrganizationResponse) GetReadOrganizationResponse() *components.ReadOrganizationResponse { + if r == nil { + return nil + } + return r.ReadOrganizationResponse +} + +func (r *ReadOrganizationResponse) GetError() *components.Error { + if r == nil { + return nil + } + return r.Error +} diff --git a/internal/membershipclient/models/operations/readorganizationclient.go b/internal/membershipclient/models/operations/readorganizationclient.go new file mode 100644 index 00000000..b1b76d81 --- /dev/null +++ b/internal/membershipclient/models/operations/readorganizationclient.go @@ -0,0 +1,59 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ReadOrganizationClientRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` +} + +func (r *ReadOrganizationClientRequest) GetOrganizationID() string { + if r == nil { + return "" + } + return r.OrganizationID +} + +type ReadOrganizationClientResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Organization client + CreateClientResponseResponse *components.CreateClientResponseResponse + // Error + Error *components.Error +} + +func (r ReadOrganizationClientResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(r, "", false) +} + +func (r *ReadOrganizationClientResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &r, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (r *ReadOrganizationClientResponse) GetHTTPMeta() components.HTTPMetadata { + if r == nil { + return components.HTTPMetadata{} + } + return r.HTTPMeta +} + +func (r *ReadOrganizationClientResponse) GetCreateClientResponseResponse() *components.CreateClientResponseResponse { + if r == nil { + return nil + } + return r.CreateClientResponseResponse +} + +func (r *ReadOrganizationClientResponse) GetError() *components.Error { + if r == nil { + return nil + } + return r.Error +} diff --git a/internal/membershipclient/models/operations/readpolicy.go b/internal/membershipclient/models/operations/readpolicy.go new file mode 100644 index 00000000..67e4f22d --- /dev/null +++ b/internal/membershipclient/models/operations/readpolicy.go @@ -0,0 +1,67 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ReadPolicyRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + PolicyID int64 `pathParam:"style=simple,explode=false,name=policyId"` +} + +func (r *ReadPolicyRequest) GetOrganizationID() string { + if r == nil { + return "" + } + return r.OrganizationID +} + +func (r *ReadPolicyRequest) GetPolicyID() int64 { + if r == nil { + return 0 + } + return r.PolicyID +} + +type ReadPolicyResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Policy with scopes + ReadPolicyResponse *components.ReadPolicyResponse + // Error + Error *components.Error +} + +func (r ReadPolicyResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(r, "", false) +} + +func (r *ReadPolicyResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &r, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (r *ReadPolicyResponse) GetHTTPMeta() components.HTTPMetadata { + if r == nil { + return components.HTTPMetadata{} + } + return r.HTTPMeta +} + +func (r *ReadPolicyResponse) GetReadPolicyResponse() *components.ReadPolicyResponse { + if r == nil { + return nil + } + return r.ReadPolicyResponse +} + +func (r *ReadPolicyResponse) GetError() *components.Error { + if r == nil { + return nil + } + return r.Error +} diff --git a/internal/membershipclient/models/operations/readstackuseraccess.go b/internal/membershipclient/models/operations/readstackuseraccess.go new file mode 100644 index 00000000..cf591cc7 --- /dev/null +++ b/internal/membershipclient/models/operations/readstackuseraccess.go @@ -0,0 +1,75 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ReadStackUserAccessRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + StackID string `pathParam:"style=simple,explode=false,name=stackId"` + UserID string `pathParam:"style=simple,explode=false,name=userId"` +} + +func (r *ReadStackUserAccessRequest) GetOrganizationID() string { + if r == nil { + return "" + } + return r.OrganizationID +} + +func (r *ReadStackUserAccessRequest) GetStackID() string { + if r == nil { + return "" + } + return r.StackID +} + +func (r *ReadStackUserAccessRequest) GetUserID() string { + if r == nil { + return "" + } + return r.UserID +} + +type ReadStackUserAccessResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Stack user access + ReadStackUserAccess *components.ReadStackUserAccess + // Error + Error *components.Error +} + +func (r ReadStackUserAccessResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(r, "", false) +} + +func (r *ReadStackUserAccessResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &r, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (r *ReadStackUserAccessResponse) GetHTTPMeta() components.HTTPMetadata { + if r == nil { + return components.HTTPMetadata{} + } + return r.HTTPMeta +} + +func (r *ReadStackUserAccessResponse) GetReadStackUserAccess() *components.ReadStackUserAccess { + if r == nil { + return nil + } + return r.ReadStackUserAccess +} + +func (r *ReadStackUserAccessResponse) GetError() *components.Error { + if r == nil { + return nil + } + return r.Error +} diff --git a/internal/membershipclient/models/operations/readuseroforganization.go b/internal/membershipclient/models/operations/readuseroforganization.go new file mode 100644 index 00000000..627a1749 --- /dev/null +++ b/internal/membershipclient/models/operations/readuseroforganization.go @@ -0,0 +1,67 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type ReadUserOfOrganizationRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + UserID string `pathParam:"style=simple,explode=false,name=userId"` +} + +func (r *ReadUserOfOrganizationRequest) GetOrganizationID() string { + if r == nil { + return "" + } + return r.OrganizationID +} + +func (r *ReadUserOfOrganizationRequest) GetUserID() string { + if r == nil { + return "" + } + return r.UserID +} + +type ReadUserOfOrganizationResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Read a user + ReadOrganizationUserResponse *components.ReadOrganizationUserResponse + // Error + Error *components.Error +} + +func (r ReadUserOfOrganizationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(r, "", false) +} + +func (r *ReadUserOfOrganizationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &r, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (r *ReadUserOfOrganizationResponse) GetHTTPMeta() components.HTTPMetadata { + if r == nil { + return components.HTTPMetadata{} + } + return r.HTTPMeta +} + +func (r *ReadUserOfOrganizationResponse) GetReadOrganizationUserResponse() *components.ReadOrganizationUserResponse { + if r == nil { + return nil + } + return r.ReadOrganizationUserResponse +} + +func (r *ReadUserOfOrganizationResponse) GetError() *components.Error { + if r == nil { + return nil + } + return r.Error +} diff --git a/internal/membershipclient/models/operations/removescopefrompolicy.go b/internal/membershipclient/models/operations/removescopefrompolicy.go new file mode 100644 index 00000000..2d22584b --- /dev/null +++ b/internal/membershipclient/models/operations/removescopefrompolicy.go @@ -0,0 +1,66 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type RemoveScopeFromPolicyRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + PolicyID int64 `pathParam:"style=simple,explode=false,name=policyId"` + ScopeID int64 `pathParam:"style=simple,explode=false,name=scopeId"` +} + +func (r *RemoveScopeFromPolicyRequest) GetOrganizationID() string { + if r == nil { + return "" + } + return r.OrganizationID +} + +func (r *RemoveScopeFromPolicyRequest) GetPolicyID() int64 { + if r == nil { + return 0 + } + return r.PolicyID +} + +func (r *RemoveScopeFromPolicyRequest) GetScopeID() int64 { + if r == nil { + return 0 + } + return r.ScopeID +} + +type RemoveScopeFromPolicyResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (r RemoveScopeFromPolicyResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(r, "", false) +} + +func (r *RemoveScopeFromPolicyResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &r, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (r *RemoveScopeFromPolicyResponse) GetHTTPMeta() components.HTTPMetadata { + if r == nil { + return components.HTTPMetadata{} + } + return r.HTTPMeta +} + +func (r *RemoveScopeFromPolicyResponse) GetError() *components.Error { + if r == nil { + return nil + } + return r.Error +} diff --git a/internal/membershipclient/models/operations/restorestack.go b/internal/membershipclient/models/operations/restorestack.go new file mode 100644 index 00000000..90ff8c5f --- /dev/null +++ b/internal/membershipclient/models/operations/restorestack.go @@ -0,0 +1,67 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type RestoreStackRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + StackID string `pathParam:"style=simple,explode=false,name=stackId"` +} + +func (r *RestoreStackRequest) GetOrganizationID() string { + if r == nil { + return "" + } + return r.OrganizationID +} + +func (r *RestoreStackRequest) GetStackID() string { + if r == nil { + return "" + } + return r.StackID +} + +type RestoreStackResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // OK + CreateStackResponse *components.CreateStackResponse + // Error + Error *components.Error +} + +func (r RestoreStackResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(r, "", false) +} + +func (r *RestoreStackResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &r, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (r *RestoreStackResponse) GetHTTPMeta() components.HTTPMetadata { + if r == nil { + return components.HTTPMetadata{} + } + return r.HTTPMeta +} + +func (r *RestoreStackResponse) GetCreateStackResponse() *components.CreateStackResponse { + if r == nil { + return nil + } + return r.CreateStackResponse +} + +func (r *RestoreStackResponse) GetError() *components.Error { + if r == nil { + return nil + } + return r.Error +} diff --git a/internal/membershipclient/models/operations/updateapplication.go b/internal/membershipclient/models/operations/updateapplication.go new file mode 100644 index 00000000..5a4378cb --- /dev/null +++ b/internal/membershipclient/models/operations/updateapplication.go @@ -0,0 +1,78 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type UpdateApplicationRequest struct { + ApplicationID string `pathParam:"style=simple,explode=false,name=applicationId"` + Body *components.ApplicationData `request:"mediaType=application/json"` +} + +func (u UpdateApplicationRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UpdateApplicationRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, []string{"applicationId"}); err != nil { + return err + } + return nil +} + +func (u *UpdateApplicationRequest) GetApplicationID() string { + if u == nil { + return "" + } + return u.ApplicationID +} + +func (u *UpdateApplicationRequest) GetBody() *components.ApplicationData { + if u == nil { + return nil + } + return u.Body +} + +type UpdateApplicationResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Application updated + UpdateApplicationResponse *components.UpdateApplicationResponse + // Error + Error *components.Error +} + +func (u UpdateApplicationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UpdateApplicationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (u *UpdateApplicationResponse) GetHTTPMeta() components.HTTPMetadata { + if u == nil { + return components.HTTPMetadata{} + } + return u.HTTPMeta +} + +func (u *UpdateApplicationResponse) GetUpdateApplicationResponse() *components.UpdateApplicationResponse { + if u == nil { + return nil + } + return u.UpdateApplicationResponse +} + +func (u *UpdateApplicationResponse) GetError() *components.Error { + if u == nil { + return nil + } + return u.Error +} diff --git a/internal/membershipclient/models/operations/updateorganization.go b/internal/membershipclient/models/operations/updateorganization.go new file mode 100644 index 00000000..84d31e1c --- /dev/null +++ b/internal/membershipclient/models/operations/updateorganization.go @@ -0,0 +1,78 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type UpdateOrganizationRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + Body *components.OrganizationData `request:"mediaType=application/json"` +} + +func (u UpdateOrganizationRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UpdateOrganizationRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, []string{"organizationId"}); err != nil { + return err + } + return nil +} + +func (u *UpdateOrganizationRequest) GetOrganizationID() string { + if u == nil { + return "" + } + return u.OrganizationID +} + +func (u *UpdateOrganizationRequest) GetBody() *components.OrganizationData { + if u == nil { + return nil + } + return u.Body +} + +type UpdateOrganizationResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Organization updated + ReadOrganizationResponse *components.ReadOrganizationResponse + // Error + Error *components.Error +} + +func (u UpdateOrganizationResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UpdateOrganizationResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (u *UpdateOrganizationResponse) GetHTTPMeta() components.HTTPMetadata { + if u == nil { + return components.HTTPMetadata{} + } + return u.HTTPMeta +} + +func (u *UpdateOrganizationResponse) GetReadOrganizationResponse() *components.ReadOrganizationResponse { + if u == nil { + return nil + } + return u.ReadOrganizationResponse +} + +func (u *UpdateOrganizationResponse) GetError() *components.Error { + if u == nil { + return nil + } + return u.Error +} diff --git a/internal/membershipclient/models/operations/updatepolicy.go b/internal/membershipclient/models/operations/updatepolicy.go new file mode 100644 index 00000000..82000884 --- /dev/null +++ b/internal/membershipclient/models/operations/updatepolicy.go @@ -0,0 +1,86 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type UpdatePolicyRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + PolicyID int64 `pathParam:"style=simple,explode=false,name=policyId"` + Body *components.PolicyData `request:"mediaType=application/json"` +} + +func (u UpdatePolicyRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UpdatePolicyRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, []string{"organizationId", "policyId"}); err != nil { + return err + } + return nil +} + +func (u *UpdatePolicyRequest) GetOrganizationID() string { + if u == nil { + return "" + } + return u.OrganizationID +} + +func (u *UpdatePolicyRequest) GetPolicyID() int64 { + if u == nil { + return 0 + } + return u.PolicyID +} + +func (u *UpdatePolicyRequest) GetBody() *components.PolicyData { + if u == nil { + return nil + } + return u.Body +} + +type UpdatePolicyResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Policy updated + UpdatePolicyResponse *components.UpdatePolicyResponse + // Error + Error *components.Error +} + +func (u UpdatePolicyResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UpdatePolicyResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (u *UpdatePolicyResponse) GetHTTPMeta() components.HTTPMetadata { + if u == nil { + return components.HTTPMetadata{} + } + return u.HTTPMeta +} + +func (u *UpdatePolicyResponse) GetUpdatePolicyResponse() *components.UpdatePolicyResponse { + if u == nil { + return nil + } + return u.UpdatePolicyResponse +} + +func (u *UpdatePolicyResponse) GetError() *components.Error { + if u == nil { + return nil + } + return u.Error +} diff --git a/internal/membershipclient/models/operations/updatestack.go b/internal/membershipclient/models/operations/updatestack.go new file mode 100644 index 00000000..2652e934 --- /dev/null +++ b/internal/membershipclient/models/operations/updatestack.go @@ -0,0 +1,86 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type UpdateStackRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + StackID string `pathParam:"style=simple,explode=false,name=stackId"` + Body *components.StackData `request:"mediaType=application/json"` +} + +func (u UpdateStackRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UpdateStackRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, []string{"organizationId", "stackId"}); err != nil { + return err + } + return nil +} + +func (u *UpdateStackRequest) GetOrganizationID() string { + if u == nil { + return "" + } + return u.OrganizationID +} + +func (u *UpdateStackRequest) GetStackID() string { + if u == nil { + return "" + } + return u.StackID +} + +func (u *UpdateStackRequest) GetBody() *components.StackData { + if u == nil { + return nil + } + return u.Body +} + +type UpdateStackResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Updated stack + CreateStackResponse *components.CreateStackResponse + // Error + Error *components.Error +} + +func (u UpdateStackResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UpdateStackResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (u *UpdateStackResponse) GetHTTPMeta() components.HTTPMetadata { + if u == nil { + return components.HTTPMetadata{} + } + return u.HTTPMeta +} + +func (u *UpdateStackResponse) GetCreateStackResponse() *components.CreateStackResponse { + if u == nil { + return nil + } + return u.CreateStackResponse +} + +func (u *UpdateStackResponse) GetError() *components.Error { + if u == nil { + return nil + } + return u.Error +} diff --git a/internal/membershipclient/models/operations/upgradestack.go b/internal/membershipclient/models/operations/upgradestack.go new file mode 100644 index 00000000..b25361be --- /dev/null +++ b/internal/membershipclient/models/operations/upgradestack.go @@ -0,0 +1,77 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type UpgradeStackRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + StackID string `pathParam:"style=simple,explode=false,name=stackId"` + Body *components.StackVersion `request:"mediaType=application/json"` +} + +func (u UpgradeStackRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UpgradeStackRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, []string{"organizationId", "stackId"}); err != nil { + return err + } + return nil +} + +func (u *UpgradeStackRequest) GetOrganizationID() string { + if u == nil { + return "" + } + return u.OrganizationID +} + +func (u *UpgradeStackRequest) GetStackID() string { + if u == nil { + return "" + } + return u.StackID +} + +func (u *UpgradeStackRequest) GetBody() *components.StackVersion { + if u == nil { + return nil + } + return u.Body +} + +type UpgradeStackResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (u UpgradeStackResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UpgradeStackResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (u *UpgradeStackResponse) GetHTTPMeta() components.HTTPMetadata { + if u == nil { + return components.HTTPMetadata{} + } + return u.HTTPMeta +} + +func (u *UpgradeStackResponse) GetError() *components.Error { + if u == nil { + return nil + } + return u.Error +} diff --git a/internal/membershipclient/models/operations/upsertauthenticationprovider.go b/internal/membershipclient/models/operations/upsertauthenticationprovider.go new file mode 100644 index 00000000..3c315a69 --- /dev/null +++ b/internal/membershipclient/models/operations/upsertauthenticationprovider.go @@ -0,0 +1,67 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type UpsertAuthenticationProviderRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + Body *components.AuthenticationProviderData `request:"mediaType=application/json"` +} + +func (u *UpsertAuthenticationProviderRequest) GetOrganizationID() string { + if u == nil { + return "" + } + return u.OrganizationID +} + +func (u *UpsertAuthenticationProviderRequest) GetBody() *components.AuthenticationProviderData { + if u == nil { + return nil + } + return u.Body +} + +type UpsertAuthenticationProviderResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Authentication provider created or updated + AuthenticationProviderResponse *components.AuthenticationProviderResponse + // Error + Error *components.Error +} + +func (u UpsertAuthenticationProviderResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UpsertAuthenticationProviderResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (u *UpsertAuthenticationProviderResponse) GetHTTPMeta() components.HTTPMetadata { + if u == nil { + return components.HTTPMetadata{} + } + return u.HTTPMeta +} + +func (u *UpsertAuthenticationProviderResponse) GetAuthenticationProviderResponse() *components.AuthenticationProviderResponse { + if u == nil { + return nil + } + return u.AuthenticationProviderResponse +} + +func (u *UpsertAuthenticationProviderResponse) GetError() *components.Error { + if u == nil { + return nil + } + return u.Error +} diff --git a/internal/membershipclient/models/operations/upsertorganizationuser.go b/internal/membershipclient/models/operations/upsertorganizationuser.go new file mode 100644 index 00000000..b99dce4c --- /dev/null +++ b/internal/membershipclient/models/operations/upsertorganizationuser.go @@ -0,0 +1,77 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type UpsertOrganizationUserRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + UserID string `pathParam:"style=simple,explode=false,name=userId"` + Body *components.UpdateOrganizationUserRequest `request:"mediaType=application/json"` +} + +func (u UpsertOrganizationUserRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UpsertOrganizationUserRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, []string{"organizationId", "userId"}); err != nil { + return err + } + return nil +} + +func (u *UpsertOrganizationUserRequest) GetOrganizationID() string { + if u == nil { + return "" + } + return u.OrganizationID +} + +func (u *UpsertOrganizationUserRequest) GetUserID() string { + if u == nil { + return "" + } + return u.UserID +} + +func (u *UpsertOrganizationUserRequest) GetBody() *components.UpdateOrganizationUserRequest { + if u == nil { + return nil + } + return u.Body +} + +type UpsertOrganizationUserResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (u UpsertOrganizationUserResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UpsertOrganizationUserResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (u *UpsertOrganizationUserResponse) GetHTTPMeta() components.HTTPMetadata { + if u == nil { + return components.HTTPMetadata{} + } + return u.HTTPMeta +} + +func (u *UpsertOrganizationUserResponse) GetError() *components.Error { + if u == nil { + return nil + } + return u.Error +} diff --git a/internal/membershipclient/models/operations/upsertstackuseraccess.go b/internal/membershipclient/models/operations/upsertstackuseraccess.go new file mode 100644 index 00000000..2168c8ce --- /dev/null +++ b/internal/membershipclient/models/operations/upsertstackuseraccess.go @@ -0,0 +1,85 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package operations + +import ( + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/components" +) + +type UpsertStackUserAccessRequest struct { + OrganizationID string `pathParam:"style=simple,explode=false,name=organizationId"` + StackID string `pathParam:"style=simple,explode=false,name=stackId"` + UserID string `pathParam:"style=simple,explode=false,name=userId"` + Body *components.UpdateStackUserRequest `request:"mediaType=application/json"` +} + +func (u UpsertStackUserAccessRequest) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UpsertStackUserAccessRequest) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, []string{"organizationId", "stackId", "userId"}); err != nil { + return err + } + return nil +} + +func (u *UpsertStackUserAccessRequest) GetOrganizationID() string { + if u == nil { + return "" + } + return u.OrganizationID +} + +func (u *UpsertStackUserAccessRequest) GetStackID() string { + if u == nil { + return "" + } + return u.StackID +} + +func (u *UpsertStackUserAccessRequest) GetUserID() string { + if u == nil { + return "" + } + return u.UserID +} + +func (u *UpsertStackUserAccessRequest) GetBody() *components.UpdateStackUserRequest { + if u == nil { + return nil + } + return u.Body +} + +type UpsertStackUserAccessResponse struct { + HTTPMeta components.HTTPMetadata `json:"-"` + // Error + Error *components.Error +} + +func (u UpsertStackUserAccessResponse) MarshalJSON() ([]byte, error) { + return utils.MarshalJSON(u, "", false) +} + +func (u *UpsertStackUserAccessResponse) UnmarshalJSON(data []byte) error { + if err := utils.UnmarshalJSON(data, &u, "", false, []string{"HttpMeta"}); err != nil { + return err + } + return nil +} + +func (u *UpsertStackUserAccessResponse) GetHTTPMeta() components.HTTPMetadata { + if u == nil { + return components.HTTPMetadata{} + } + return u.HTTPMeta +} + +func (u *UpsertStackUserAccessResponse) GetError() *components.Error { + if u == nil { + return nil + } + return u.Error +} diff --git a/internal/membershipclient/optionalnullable/optionalnullable.go b/internal/membershipclient/optionalnullable/optionalnullable.go new file mode 100644 index 00000000..c6739be0 --- /dev/null +++ b/internal/membershipclient/optionalnullable/optionalnullable.go @@ -0,0 +1,233 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package optionalnullable + +import ( + "bytes" + "encoding/json" + "reflect" +) + +// OptionalNullable represents a field that can distinguish between three states: +// 1. Set to a value: field is present with a non-nil value +// 2. Set to nil: field is present but explicitly set to null in JSON +// 3. Unset: field is omitted from JSON entirely +// +// This type is designed to work with JSON marshaling/unmarshaling and supports +// the `omitempty` struct tag to properly omit unset fields from JSON output. +// +// Usage: +// +// type User struct { +// Name OptionalNullable[string] `json:"name,omitempty"` +// Age OptionalNullable[int] `json:"age,omitempty"` +// Tags OptionalNullable[[]string] `json:"tags,omitempty"` +// } +// +// // Set to value +// name := "John" +// user.Name = From(&name) +// +// // Set to nil (will appear as "name": null in JSON) +// user.Name = From[string](nil) +// +// // Leave unset (will be omitted from JSON with omitempty) +// user := User{} +// +// WARNING: Do NOT use *OptionalNullable[T] as a field type. Always use OptionalNullable[T] directly. +// Using *OptionalNullable[T] will break the omitempty behavior and JSON marshaling. +// +// The type is implemented as a map[bool]*T where: +// - nil map represents unset state +// - Map with true key represents set state (value may be nil) +type OptionalNullable[T any] map[bool]*T + +// From creates a new OptionalNullable with the given value. +// Pass nil to create a OptionalNullable that is set to null. +// Pass a pointer to a value to create a OptionalNullable with that value. +// +// Examples: +// +// hello := "hello" +// From(&hello) // set to "hello" +// From[string](nil) // set to null +func From[T any](value *T) OptionalNullable[T] { + return map[bool]*T{ + true: value, + } +} + +// IsNull returns true if the OptionalNullable is explicitly set to nil. +// Returns false if the OptionalNullable is unset or has a value. +// +// Note: This differs from traditional null checks because unset fields +// return false, not true. Use IsSet() to check if a field was provided. +func (n OptionalNullable[T]) IsNull() bool { + v, ok := n[true] + return ok && v == nil +} + +// IsSet returns true if the OptionalNullable has been explicitly set (to either a value or nil). +// Returns false if the OptionalNullable is unset (omitted from JSON). +// +// This is the key method for distinguishing between: +// - Set to nil: IsSet() = true, IsNull() = true +// - Unset: IsSet() = false, IsNull() = false +func (n OptionalNullable[T]) IsSet() bool { + _, ok := n[true] + return ok +} + +// Get returns the internal pointer and whether the field was set. +// +// Return values: +// - (ptr, true): field was set (ptr may be nil if set to null) +// - (nil, false): field was unset/omitted +// +// This method provides direct access to the internal pointer representation. +func (n OptionalNullable[T]) Get() (*T, bool) { + v, ok := n[true] + return v, ok +} + +// GetOrZero returns the value and whether it was set. +// +// Return values: +// - (value, true): field was set to a non-nil value +// - (zero, true): field was explicitly set to nil +// - (zero, false): field was unset/omitted +// +// Examples: +// +// val, ok := nullable.GetOrZero() +// if !ok { +// // Field was unset/omitted +// } else if nullable.IsNull() { +// // Field was explicitly set to null +// } else { +// // Field has a value: val +// } +func (n OptionalNullable[T]) GetOrZero() (T, bool) { + var zero T + + if v, ok := n[true]; ok { + if v == nil { + return zero, true + } + return *v, true + } + return zero, false +} + +// GetUntyped returns the value as interface{} and whether it was set. +// This is useful for reflection-based code that needs to work with the value +// without knowing the specific type T. +// +// Return values: +// - (value, true): field was set to a non-nil value +// - (nil, true): field was explicitly set to nil +// - (nil, false): field was unset/omitted +func (n OptionalNullable[T]) GetUntyped() (interface{}, bool) { + if v, ok := n[true]; ok { + if v == nil { + return nil, true + } + return *v, true + } + return nil, false +} + +// Set sets the OptionalNullable to the given value pointer. +// Pass nil to set the field to null. +// Pass a pointer to a value to set the field to that value. +// +// Examples: +// +// nullable.Set(ptrFrom("hello")) // set to "hello" +// nullable.Set(nil) // set to null +func (n *OptionalNullable[T]) Set(value *T) { + *n = map[bool]*T{ + true: value, + } +} + +// Unset removes the value, making the field unset/omitted. +// After calling Unset(), IsSet() will return false and the field +// will be omitted from JSON output when using omitempty. +func (n *OptionalNullable[T]) Unset() { + *n = map[bool]*T{} +} + +// MarshalJSON implements json.Marshaler. +// +// Behavior: +// - Unset fields: omitted from JSON when struct field has omitempty tag +// - Null fields: serialized as "null" +// - Value fields: serialized as the actual value +// +// The omitempty behavior works because an empty map is considered +// a zero value by Go's JSON package. +func (n OptionalNullable[T]) MarshalJSON() ([]byte, error) { + if n.IsNull() { + return []byte("null"), nil + } + + return json.Marshal(n[true]) +} + +// UnmarshalJSON implements json.Unmarshaler. +// +// Behavior: +// - "null" in JSON: sets the field to null (IsSet=true, IsNull=true) +// - Any other value: sets the field to that value (IsSet=true, IsNull=false) +// - Missing from JSON: field remains unset (IsSet=false, IsNull=false) +func (n *OptionalNullable[T]) UnmarshalJSON(data []byte) error { + if bytes.Equal(data, []byte("null")) { + n.Set(nil) + return nil + } + var v T + if err := json.Unmarshal(data, &v); err != nil { + return err + } + n.Set(&v) + return nil +} + +// NullableInterface defines the interface that all OptionalNullable[T] types implement. +// This interface provides untyped access to optional nullable values for reflection-based code. +type OptionalNullableInterface interface { + GetUntyped() (interface{}, bool) +} + +// AsOptionalNullable attempts to convert a reflect.Value to a OptionalNullableInterface. +// This is a helper function for reflection-based code that needs to check +// if a value implements the optional nullable interface pattern. +// +// Returns: +// - (nullable, true): if the value implements OptionalNullableInterface +// - (nil, false): if the value does not implement OptionalNullableInterface +// +// Example usage: +// +// if nullable, ok := AsOptionalNullable(reflectValue); ok { +// if value, isSet := nullable.GetUntyped(); isSet { +// // Handle the nullable value +// } +// } +func AsOptionalNullable(v reflect.Value) (OptionalNullableInterface, bool) { + // Check if the value can be converted to an interface first + if !v.CanInterface() { + return nil, false + } + + // Check if the underlying value is a nil map (unset nullable) + if v.Kind() == reflect.Map && v.IsNil() { + return nil, false + } + + if nullable, ok := v.Interface().(OptionalNullableInterface); ok { + return nullable, true + } + return nil, false +} diff --git a/internal/membershipclient/optionalnullable/optionalnullable_test.go b/internal/membershipclient/optionalnullable/optionalnullable_test.go new file mode 100644 index 00000000..e6e5a01c --- /dev/null +++ b/internal/membershipclient/optionalnullable/optionalnullable_test.go @@ -0,0 +1,1806 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package optionalnullable + +import ( + "encoding/json" + "reflect" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// Test helper function to create pointers from values +func ptrFrom[T any](value T) *T { + return &value +} + +// Test helper types for comprehensive testing +type TestStruct struct { + Name string `json:"name"` + Age int `json:"age"` +} + +type TestContainer struct { + StringField OptionalNullable[string] `json:"string_field,omitempty"` + IntField OptionalNullable[int] `json:"int_field,omitempty"` + SliceField OptionalNullable[[]string] `json:"slice_field,omitempty"` + StructField OptionalNullable[TestStruct] `json:"struct_field,omitempty"` +} + +// TestNewNullable tests the From constructor +func TestNewNullable(t *testing.T) { + t.Parallel() + t.Run("with string value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "test", got) + }) + + t.Run("with nil pointer", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "", got) // zero value for string + }) + + t.Run("with int value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom(42)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 42, got) + }) + + t.Run("with slice value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom([]string{"a", "b", "c"})) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b", "c"}, got) + }) + + t.Run("with empty slice", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom([]string{})) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{}, got) + }) + + t.Run("with struct value", func(t *testing.T) { + t.Parallel() + val := TestStruct{Name: "John", Age: 30} + nullable := From(&val) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + v, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, val, v) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, TestStruct{Name: "John", Age: 30}, got) + }) +} + +// TestNewNullableUnset tests the NewNullableUnset constructor +func TestNewNullableUnset(t *testing.T) { + t.Parallel() + t.Run("string type", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // Unset is not null + + got, ok := nullable.GetOrZero() + assert.False(t, ok) + assert.Equal(t, "", got) // zero value for string + }) + + t.Run("int type", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[int] + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // Unset is not null + + got, ok := nullable.GetOrZero() + assert.False(t, ok) + assert.Equal(t, 0, got) // zero value for int + }) + + t.Run("slice type", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[[]string] + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // Unset is not null + + got, ok := nullable.GetOrZero() + assert.False(t, ok) + assert.Nil(t, got) // zero value for slice is nil + }) +} + +// TestIsNull tests the IsNull method +func TestIsNull(t *testing.T) { + t.Parallel() + t.Run("with value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + assert.False(t, nullable.IsNull()) + }) + + t.Run("with nil pointer", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + assert.True(t, nullable.IsNull()) + }) + + t.Run("unset", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + assert.False(t, nullable.IsNull()) + }) +} + +// TestIsSet tests the IsSet method +func TestIsSet(t *testing.T) { + t.Parallel() + t.Run("with value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + assert.True(t, nullable.IsSet()) + }) + + t.Run("with nil pointer", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + assert.True(t, nullable.IsSet()) + }) + + t.Run("unset", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + assert.False(t, nullable.IsSet()) + }) +} + +// TestGet tests the Get method +func TestGet(t *testing.T) { + t.Parallel() + t.Run("with string value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "test", got) + }) + + t.Run("with nil pointer", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "", got) // zero value + }) + + t.Run("unset", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + + got, ok := nullable.GetOrZero() + assert.False(t, ok) + assert.Equal(t, "", got) // zero value + }) + + t.Run("with slice value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom([]string{"a", "b"})) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b"}, got) + }) + + t.Run("with nil slice pointer", func(t *testing.T) { + t.Parallel() + nullable := From[[]string](nil) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Nil(t, got) // zero value for slice is nil + }) +} + +// TestPointer tests the Pointer method +func TestPointer(t *testing.T) { + t.Parallel() + t.Run("with value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + + ptr, ok := nullable.Get() + assert.True(t, ok) + assert.NotNil(t, ptr) + assert.Equal(t, "test", *ptr) + }) + + t.Run("with nil pointer", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + + ptr, ok := nullable.Get() + assert.True(t, ok) + assert.Nil(t, ptr) + }) + + t.Run("unset", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + + ptr, ok := nullable.Get() + assert.False(t, ok) + assert.Nil(t, ptr) + }) +} + +// TestSet tests the Set method +func TestSet(t *testing.T) { + t.Parallel() + t.Run("set string value", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + + // Initially unset + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // Unset is not null + + // Set a value + nullable.Set(ptrFrom("test")) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "test", got) + }) + + t.Run("set int value", func(t *testing.T) { + t.Parallel() + nullable := OptionalNullable[int]{} + + nullable.Set(ptrFrom(42)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 42, got) + }) + + t.Run("set slice value", func(t *testing.T) { + t.Parallel() + nullable := OptionalNullable[[]string]{} + + slice := []string{"a", "b"} + nullable.Set(ptrFrom(slice)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b"}, got) + }) + + t.Run("set empty slice", func(t *testing.T) { + t.Parallel() + nullable := OptionalNullable[[]string]{} + + slice := []string{} + nullable.Set(ptrFrom(slice)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{}, got) + }) + + t.Run("overwrite existing value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("original")) + + // Verify original value + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "original", got) + + // Set new value + nullable.Set(ptrFrom("new")) + + got, ok = nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "new", got) + }) +} + +// TestUnset tests the Unset method +func TestUnset(t *testing.T) { + t.Parallel() + t.Run("unset from value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + + // Initially set + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + // Unset + nullable.Unset() + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // After unset is not null + // Value is now internal to the map implementation + + got, ok := nullable.GetOrZero() + assert.False(t, ok) + assert.Equal(t, "", got) // zero value + }) + + t.Run("unset from nil", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + + // Initially set to nil + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) // Set to nil should be null + + // Unset + nullable.Unset() + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // After unset is not null + }) + + t.Run("unset already unset", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + + // Initially unset + assert.False(t, nullable.IsSet()) + + // Unset again + nullable.Unset() + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) // Empty map is not null + }) +} + +// TestMarshalJSON tests JSON marshaling +func TestMarshalJSON(t *testing.T) { + t.Parallel() + t.Run("marshal string value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `"test"`, string(data)) + }) + + t.Run("marshal int value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom(42)) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `42`, string(data)) + }) + + t.Run("marshal nil value", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `null`, string(data)) + }) + + t.Run("marshal slice value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom([]string{"a", "b", "c"})) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `["a","b","c"]`, string(data)) + }) + + t.Run("marshal empty slice", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom([]string{})) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `[]`, string(data)) + }) + + t.Run("marshal struct value", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom(TestStruct{Name: "John", Age: 30})) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `{"name":"John","age":30}`, string(data)) + }) + + // Note: Unset values are not tested here because the current implementation + // doesn't handle unset fields in marshaling (see TODO in the code) +} + +// TestUnmarshalJSON tests JSON unmarshaling +func TestUnmarshalJSON(t *testing.T) { + t.Parallel() + t.Run("unmarshal string value", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + err := json.Unmarshal([]byte(`"test"`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "test", got) + }) + + t.Run("unmarshal int value", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[int] + err := json.Unmarshal([]byte(`42`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 42, got) + }) + + t.Run("unmarshal null value", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + err := json.Unmarshal([]byte(`null`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "", got) // zero value + }) + + t.Run("unmarshal slice value", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[[]string] + err := json.Unmarshal([]byte(`["a","b","c"]`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b", "c"}, got) + }) + + t.Run("unmarshal empty slice", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[[]string] + err := json.Unmarshal([]byte(`[]`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{}, got) + }) + + t.Run("unmarshal struct value", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[TestStruct] + err := json.Unmarshal([]byte(`{"name":"John","age":30}`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, TestStruct{Name: "John", Age: 30}, got) + }) + + t.Run("unmarshal invalid JSON", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + err := json.Unmarshal([]byte(`invalid`), &nullable) + assert.Error(t, err) + + // Ensure the nullable remains unset after error + assert.False(t, nullable.IsSet()) + }) + + t.Run("unmarshal invalid JSON for int", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[int] + err := json.Unmarshal([]byte(`"not_a_number"`), &nullable) + assert.Error(t, err) + + // Ensure the nullable remains unset after error + assert.False(t, nullable.IsSet()) + }) + + t.Run("unmarshal malformed JSON", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[TestStruct] + err := json.Unmarshal([]byte(`{invalid json`), &nullable) + assert.Error(t, err) + + // Ensure the nullable remains unset after error + assert.False(t, nullable.IsSet()) + }) +} + +// TestJSONRoundTrip tests marshaling and unmarshaling together +func TestJSONRoundTrip(t *testing.T) { + t.Parallel() + t.Run("string value round trip", func(t *testing.T) { + t.Parallel() + nullable1 := From(ptrFrom("test value")) + + // Marshal + data, err := json.Marshal(nullable1) + require.NoError(t, err) + + // Unmarshal + var nullable2 OptionalNullable[string] + err = json.Unmarshal(data, &nullable2) + require.NoError(t, err) + + // Compare + assert.Equal(t, nullable1.IsSet(), nullable2.IsSet()) + assert.Equal(t, nullable1.IsNull(), nullable2.IsNull()) + + got1, ok1 := nullable1.GetOrZero() + got2, ok2 := nullable2.GetOrZero() + assert.Equal(t, ok1, ok2) + assert.Equal(t, got1, got2) + }) + + t.Run("nil value round trip", func(t *testing.T) { + t.Parallel() + nullable1 := From[string](nil) + + // Marshal + data, err := json.Marshal(nullable1) + require.NoError(t, err) + + // Unmarshal + var nullable2 OptionalNullable[string] + err = json.Unmarshal(data, &nullable2) + require.NoError(t, err) + + // Compare + assert.Equal(t, nullable1.IsSet(), nullable2.IsSet()) + assert.Equal(t, nullable1.IsNull(), nullable2.IsNull()) + + got1, ok1 := nullable1.GetOrZero() + got2, ok2 := nullable2.GetOrZero() + assert.Equal(t, ok1, ok2) + assert.Equal(t, got1, got2) + }) + + t.Run("slice round trip", func(t *testing.T) { + t.Parallel() + nullable1 := From(ptrFrom([]string{"a", "b", "c"})) + + // Marshal + data, err := json.Marshal(nullable1) + require.NoError(t, err) + + // Unmarshal + var nullable2 OptionalNullable[[]string] + err = json.Unmarshal(data, &nullable2) + require.NoError(t, err) + + // Compare + assert.Equal(t, nullable1.IsSet(), nullable2.IsSet()) + assert.Equal(t, nullable1.IsNull(), nullable2.IsNull()) + + got1, ok1 := nullable1.GetOrZero() + got2, ok2 := nullable2.GetOrZero() + assert.Equal(t, ok1, ok2) + assert.Equal(t, got1, got2) + }) +} + +// TestJSONToJSONRoundTrip tests starting with JSON and ensuring we can serialize back to the same JSON +func TestJSONToJSONRoundTrip(t *testing.T) { + t.Parallel() + t.Run("string value JSON round trip", func(t *testing.T) { + t.Parallel() + originalJSON := `"hello world"` + + // Unmarshal from JSON + var nullable OptionalNullable[string] + err := json.Unmarshal([]byte(originalJSON), &nullable) + require.NoError(t, err) + + // Verify state + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "hello world", got) + + // Marshal back to JSON + resultJSON, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, originalJSON, string(resultJSON)) + }) + + t.Run("null value JSON round trip", func(t *testing.T) { + t.Parallel() + originalJSON := `null` + + // Unmarshal from JSON + var nullable OptionalNullable[string] + err := json.Unmarshal([]byte(originalJSON), &nullable) + require.NoError(t, err) + + // Verify state + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "", got) // zero value + + // Marshal back to JSON + resultJSON, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, originalJSON, string(resultJSON)) + }) + + t.Run("int value JSON round trip", func(t *testing.T) { + t.Parallel() + originalJSON := `42` + + // Unmarshal from JSON + var nullable OptionalNullable[int] + err := json.Unmarshal([]byte(originalJSON), &nullable) + require.NoError(t, err) + + // Verify state + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 42, got) + + // Marshal back to JSON + resultJSON, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, originalJSON, string(resultJSON)) + }) + + t.Run("slice value JSON round trip", func(t *testing.T) { + t.Parallel() + originalJSON := `["a","b","c"]` + + // Unmarshal from JSON + var nullable OptionalNullable[[]string] + err := json.Unmarshal([]byte(originalJSON), &nullable) + require.NoError(t, err) + + // Verify state + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b", "c"}, got) + + // Marshal back to JSON + resultJSON, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, originalJSON, string(resultJSON)) + }) + + t.Run("empty slice JSON round trip", func(t *testing.T) { + t.Parallel() + originalJSON := `[]` + + // Unmarshal from JSON + var nullable OptionalNullable[[]string] + err := json.Unmarshal([]byte(originalJSON), &nullable) + require.NoError(t, err) + + // Verify state + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{}, got) + + // Marshal back to JSON + resultJSON, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, originalJSON, string(resultJSON)) + }) + + t.Run("struct value JSON round trip", func(t *testing.T) { + t.Parallel() + originalJSON := `{"name":"Alice","age":25}` + + // Unmarshal from JSON + var nullable OptionalNullable[TestStruct] + err := json.Unmarshal([]byte(originalJSON), &nullable) + require.NoError(t, err) + + // Verify state + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, TestStruct{Name: "Alice", Age: 25}, got) + + // Marshal back to JSON + resultJSON, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, originalJSON, string(resultJSON)) + }) +} + +// TestContainerStates tests comprehensive state detection and serialization with TestContainer +func TestContainerStates(t *testing.T) { + t.Parallel() + t.Run("all fields set to values", func(t *testing.T) { + t.Parallel() + container := TestContainer{ + StringField: From(ptrFrom("hello")), + IntField: From(ptrFrom(42)), + SliceField: From(ptrFrom([]string{"a", "b"})), + StructField: From(ptrFrom(TestStruct{Name: "John", Age: 30})), + } + + // Verify all fields are set and not null + assert.True(t, container.StringField.IsSet()) + assert.False(t, container.StringField.IsNull()) + assert.True(t, container.IntField.IsSet()) + assert.False(t, container.IntField.IsNull()) + assert.True(t, container.SliceField.IsSet()) + assert.False(t, container.SliceField.IsNull()) + assert.True(t, container.StructField.IsSet()) + assert.False(t, container.StructField.IsNull()) + + // Verify values + stringVal, ok := container.StringField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "hello", stringVal) + + intVal, ok := container.IntField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 42, intVal) + + sliceVal, ok := container.SliceField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b"}, sliceVal) + + structVal, ok := container.StructField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, TestStruct{Name: "John", Age: 30}, structVal) + + // Test JSON serialization + data, err := json.Marshal(container) + require.NoError(t, err) + + var result map[string]interface{} + err = json.Unmarshal(data, &result) + require.NoError(t, err) + + assert.Equal(t, "hello", result["string_field"]) + assert.Equal(t, float64(42), result["int_field"]) // JSON numbers are float64 + assert.Equal(t, []interface{}{"a", "b"}, result["slice_field"]) + structResult := result["struct_field"].(map[string]interface{}) + assert.Equal(t, "John", structResult["name"]) + assert.Equal(t, float64(30), structResult["age"]) + }) + + t.Run("all fields set to nil", func(t *testing.T) { + t.Parallel() + container := TestContainer{ + StringField: From[string](nil), + IntField: From[int](nil), + SliceField: From[[]string](nil), + StructField: From[TestStruct](nil), + } + + // Verify all fields are set but null + assert.True(t, container.StringField.IsSet()) + assert.True(t, container.StringField.IsNull()) + assert.True(t, container.IntField.IsSet()) + assert.True(t, container.IntField.IsNull()) + assert.True(t, container.SliceField.IsSet()) + assert.True(t, container.SliceField.IsNull()) + assert.True(t, container.StructField.IsSet()) + assert.True(t, container.StructField.IsNull()) + + // Verify GetOrZero() behavior for nil values + stringVal, ok := container.StringField.GetOrZero() + assert.True(t, ok) // set to nil still returns true + assert.Equal(t, "", stringVal) // zero value + + intVal, ok := container.IntField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 0, intVal) // zero value + + sliceVal, ok := container.SliceField.GetOrZero() + assert.True(t, ok) + assert.Nil(t, sliceVal) // zero value for slice is nil + + structVal, ok := container.StructField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, TestStruct{}, structVal) // zero value + + // Test JSON serialization - all should be null + data, err := json.Marshal(container) + require.NoError(t, err) + + var result map[string]interface{} + err = json.Unmarshal(data, &result) + require.NoError(t, err) + + assert.Nil(t, result["string_field"]) + assert.Nil(t, result["int_field"]) + assert.Nil(t, result["slice_field"]) + assert.Nil(t, result["struct_field"]) + }) + + t.Run("all fields unset", func(t *testing.T) { + t.Parallel() + container := TestContainer{} + + // Verify all fields are unset + assert.False(t, container.StringField.IsSet()) + assert.False(t, container.StringField.IsNull()) // unset is not null in new implementation + assert.False(t, container.IntField.IsSet()) + assert.False(t, container.IntField.IsNull()) + assert.False(t, container.SliceField.IsSet()) + assert.False(t, container.SliceField.IsNull()) + assert.False(t, container.StructField.IsSet()) + assert.False(t, container.StructField.IsNull()) + + // Verify GetOrZero() behavior for unset values + stringVal, ok := container.StringField.GetOrZero() + assert.False(t, ok) // unset returns false + assert.Equal(t, "", stringVal) // zero value + + intVal, ok := container.IntField.GetOrZero() + assert.False(t, ok) + assert.Equal(t, 0, intVal) // zero value + + sliceVal, ok := container.SliceField.GetOrZero() + assert.False(t, ok) + assert.Nil(t, sliceVal) // zero value + + structVal, ok := container.StructField.GetOrZero() + assert.False(t, ok) + assert.Equal(t, TestStruct{}, structVal) // zero value + + // Test JSON serialization - unset fields should be omitted due to omitempty + data, err := json.Marshal(container) + require.NoError(t, err) + + var result map[string]interface{} + err = json.Unmarshal(data, &result) + require.NoError(t, err) + + // With omitempty, unset fields should not appear in JSON + assert.NotContains(t, result, "string_field") + assert.NotContains(t, result, "int_field") + assert.NotContains(t, result, "slice_field") + assert.NotContains(t, result, "struct_field") + }) + + t.Run("slice field states: nil vs unset vs empty vs set", func(t *testing.T) { + t.Parallel() + // Test all possible slice states + nilSlice := TestContainer{ + SliceField: From[[]string](nil), // explicitly set to nil + } + unsetSlice := TestContainer{} // unset + emptySlice := TestContainer{ + SliceField: From(ptrFrom([]string{})), // empty slice + } + setSlice := TestContainer{ + SliceField: From(ptrFrom([]string{"a", "b"})), // slice with values + } + + // Verify nil slice + assert.True(t, nilSlice.SliceField.IsSet()) + assert.True(t, nilSlice.SliceField.IsNull()) + val, ok := nilSlice.SliceField.GetOrZero() + assert.True(t, ok) + assert.Nil(t, val) + + // Verify unset slice + assert.False(t, unsetSlice.SliceField.IsSet()) + assert.False(t, unsetSlice.SliceField.IsNull()) // Unset is not null + val, ok = unsetSlice.SliceField.GetOrZero() + assert.False(t, ok) + assert.Nil(t, val) + + // Verify empty slice + assert.True(t, emptySlice.SliceField.IsSet()) + assert.False(t, emptySlice.SliceField.IsNull()) + val, ok = emptySlice.SliceField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{}, val) + + // Verify set slice + assert.True(t, setSlice.SliceField.IsSet()) + assert.False(t, setSlice.SliceField.IsNull()) + val, ok = setSlice.SliceField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, []string{"a", "b"}, val) + + // Test JSON serialization for each state + nilData, err := json.Marshal(nilSlice) + require.NoError(t, err) + assert.Contains(t, string(nilData), `"slice_field":null`) + + unsetData, err := json.Marshal(unsetSlice) + require.NoError(t, err) + assert.NotContains(t, string(unsetData), "slice_field") // omitted due to omitempty + + emptyData, err := json.Marshal(emptySlice) + require.NoError(t, err) + assert.Contains(t, string(emptyData), `"slice_field":[]`) + + setData, err := json.Marshal(setSlice) + require.NoError(t, err) + assert.Contains(t, string(setData), `"slice_field":["a","b"]`) + }) + + t.Run("mixed states container", func(t *testing.T) { + t.Parallel() + container := TestContainer{ + StringField: From(ptrFrom("hello")), // set to value + IntField: From[int](nil), // set to nil + StructField: From(ptrFrom(TestStruct{Name: "Alice", Age: 25})), // set to value + } + + // Verify states + assert.True(t, container.StringField.IsSet()) + assert.False(t, container.StringField.IsNull()) + + assert.True(t, container.IntField.IsSet()) + assert.True(t, container.IntField.IsNull()) + + assert.False(t, container.SliceField.IsSet()) + assert.False(t, container.SliceField.IsNull()) // Unset is not null + + assert.True(t, container.StructField.IsSet()) + assert.False(t, container.StructField.IsNull()) + + // Test JSON serialization + data, err := json.Marshal(container) + require.NoError(t, err) + + var result map[string]interface{} + err = json.Unmarshal(data, &result) + require.NoError(t, err) + + assert.Equal(t, "hello", result["string_field"]) + assert.Nil(t, result["int_field"]) + assert.NotContains(t, result, "slice_field") // unset, so omitted + structResult := result["struct_field"].(map[string]interface{}) + assert.Equal(t, "Alice", structResult["name"]) + assert.Equal(t, float64(25), structResult["age"]) + }) + + t.Run("JSON unmarshaling preserves states", func(t *testing.T) { + t.Parallel() + // JSON with some fields missing, some null, some with values + jsonData := `{ + "string_field": "test", + "int_field": null, + "struct_field": {"name": "Bob", "age": 35} + }` + + var container TestContainer + err := json.Unmarshal([]byte(jsonData), &container) + require.NoError(t, err) + + // string_field: present with value + assert.True(t, container.StringField.IsSet()) + assert.False(t, container.StringField.IsNull()) + stringVal, ok := container.StringField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "test", stringVal) + + // int_field: present but null + assert.True(t, container.IntField.IsSet()) + assert.True(t, container.IntField.IsNull()) + intVal, ok := container.IntField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 0, intVal) // zero value + + // slice_field: missing from JSON, should remain unset + assert.False(t, container.SliceField.IsSet()) + assert.False(t, container.SliceField.IsNull()) // Unset is not null + sliceVal, ok := container.SliceField.GetOrZero() + assert.False(t, ok) + assert.Nil(t, sliceVal) + + // struct_field: present with value + assert.True(t, container.StructField.IsSet()) + assert.False(t, container.StructField.IsNull()) + structVal, ok := container.StructField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, TestStruct{Name: "Bob", Age: 35}, structVal) + }) +} + +// TestNilVsUnsetDistinction tests the key feature of distinguishing nil from unset +func TestNilVsUnsetDistinction(t *testing.T) { + t.Parallel() + t.Run("explicit nil vs unset", func(t *testing.T) { + t.Parallel() + // Explicitly set to nil + explicitNil := From[string](nil) + + // Unset + var unset OptionalNullable[string] + + // Both are null, but only one is set + assert.True(t, explicitNil.IsNull()) + assert.True(t, explicitNil.IsSet()) + + assert.False(t, unset.IsNull()) // Unset is not null + assert.False(t, unset.IsSet()) + + // Get behavior differs + got1, ok1 := explicitNil.GetOrZero() + got2, ok2 := unset.GetOrZero() + + assert.True(t, ok1) // explicitly set to nil returns true + assert.False(t, ok2) // unset returns false + assert.Equal(t, "", got1) // both return zero value + assert.Equal(t, "", got2) + + // Get behavior differs + ptr1, ok1 := explicitNil.Get() + ptr2, ok2 := unset.Get() + + assert.True(t, ok1) // explicitly set to nil returns true + assert.False(t, ok2) // unset returns false + assert.Nil(t, ptr1) // both return nil pointer + assert.Nil(t, ptr2) + }) + + t.Run("empty slice vs nil slice vs unset", func(t *testing.T) { + t.Parallel() + // Empty slice + emptyNullable := From(ptrFrom([]string{})) + + // Nil slice + nilNullable := From[[]string](nil) + + // Unset + var unsetNullable OptionalNullable[[]string] + + // All have different characteristics + assert.True(t, emptyNullable.IsSet()) + assert.False(t, emptyNullable.IsNull()) + + assert.True(t, nilNullable.IsSet()) + assert.True(t, nilNullable.IsNull()) + + assert.False(t, unsetNullable.IsSet()) + assert.False(t, unsetNullable.IsNull()) // Unset is not null + + // Get behavior + got1, ok1 := emptyNullable.GetOrZero() + got2, ok2 := nilNullable.GetOrZero() + got3, ok3 := unsetNullable.GetOrZero() + + assert.True(t, ok1) + assert.Equal(t, []string{}, got1) + + assert.True(t, ok2) + assert.Nil(t, got2) + + assert.False(t, ok3) + assert.Nil(t, got3) + }) +} + +// TestJSONOmitEmpty tests behavior with omitempty tag +func TestJSONOmitEmpty(t *testing.T) { + t.Parallel() + t.Run("marshal with omitempty", func(t *testing.T) { + t.Parallel() + // Test container with various nullable states + container := TestContainer{ + StringField: From(ptrFrom("test")), + IntField: From(ptrFrom(42)), + StructField: From[TestStruct](nil), // explicitly nil + } + + data, err := json.Marshal(container) + require.NoError(t, err) + + // Parse back to verify structure + var result map[string]interface{} + err = json.Unmarshal(data, &result) + require.NoError(t, err) + + // Should contain set fields + assert.Contains(t, result, "string_field") + assert.Contains(t, result, "int_field") + assert.Contains(t, result, "struct_field") + + // Should not contain unset field (due to omitempty) + // Note: This depends on how the marshaling handles unset fields + // The current implementation doesn't handle this case properly (see TODO) + }) + + t.Run("unmarshal missing fields", func(t *testing.T) { + t.Parallel() + // JSON with some fields missing + jsonData := `{"string_field": "test", "int_field": null}` + + var container TestContainer + err := json.Unmarshal([]byte(jsonData), &container) + require.NoError(t, err) + + // Present fields should be set + assert.True(t, container.StringField.IsSet()) + assert.False(t, container.StringField.IsNull()) + got, ok := container.StringField.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "test", got) + + // Null field should be set to nil + assert.True(t, container.IntField.IsSet()) + assert.True(t, container.IntField.IsNull()) + + // Missing fields should remain unset + assert.False(t, container.SliceField.IsSet()) + assert.False(t, container.StructField.IsSet()) + }) +} + +// TestEdgeCases tests various edge cases +func TestEdgeCases(t *testing.T) { + t.Parallel() + t.Run("zero values", func(t *testing.T) { + t.Parallel() + // Test with zero values that are not nil + intNullable := From(ptrFrom(0)) + stringNullable := From(ptrFrom("")) + + assert.True(t, intNullable.IsSet()) + assert.False(t, intNullable.IsNull()) + got, ok := intNullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, 0, got) + + assert.True(t, stringNullable.IsSet()) + assert.False(t, stringNullable.IsNull()) + got2, ok2 := stringNullable.GetOrZero() + assert.True(t, ok2) + assert.Equal(t, "", got2) + }) + + t.Run("pointer to pointer", func(t *testing.T) { + t.Parallel() + // Test with pointer to pointer type + inner := "test" + nullable := From(ptrFrom(&inner)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, &inner, got) + assert.Equal(t, "test", *got) + }) + + t.Run("complex struct", func(t *testing.T) { + t.Parallel() + complexStruct := struct { + Name string + Values []int + Metadata map[string]string + }{ + Name: "complex", + Values: []int{1, 2, 3}, + Metadata: map[string]string{ + "key1": "value1", + "key2": "value2", + }, + } + + nullable := From(ptrFrom(complexStruct)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, complexStruct, got) + }) +} + +// TestDoublePointers tests comprehensive double pointer scenarios +func TestDoublePointers(t *testing.T) { + t.Parallel() + + t.Run("string double pointer with value", func(t *testing.T) { + t.Parallel() + inner := "hello world" + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Equal(t, &inner, got) + assert.Equal(t, "hello world", *got) + }) + + t.Run("int double pointer with value", func(t *testing.T) { + t.Parallel() + inner := 42 + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Equal(t, &inner, got) + assert.Equal(t, 42, *got) + }) + + t.Run("double pointer to nil", func(t *testing.T) { + t.Parallel() + var ptr *string = nil + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Nil(t, got) + }) + + t.Run("nil double pointer", func(t *testing.T) { + t.Parallel() + nullable := From[*string](nil) + + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Nil(t, got) // zero value for **string is nil + }) + + t.Run("unset double pointer", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[*string] + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.False(t, ok) + assert.Nil(t, got) // zero value for **string is nil + }) + + t.Run("double pointer modification", func(t *testing.T) { + t.Parallel() + inner := "original" + ptr := &inner + nullable := From(ptrFrom(ptr)) + + // Verify original value + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "original", *got) + + // Modify through double pointer + *got = "modified" + assert.Equal(t, "modified", inner) + assert.Equal(t, "modified", *got) + }) + + t.Run("double pointer to struct", func(t *testing.T) { + t.Parallel() + inner := TestStruct{Name: "Alice", Age: 30} + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Equal(t, TestStruct{Name: "Alice", Age: 30}, *got) + + // Modify through double pointer + (*got).Name = "Bob" + assert.Equal(t, "Bob", inner.Name) + assert.Equal(t, "Bob", (*got).Name) + }) + + t.Run("double pointer to slice", func(t *testing.T) { + t.Parallel() + inner := []string{"a", "b", "c"} + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Equal(t, []string{"a", "b", "c"}, *got) + + // Modify through double pointer + *got = append(*got, "d") + assert.Equal(t, []string{"a", "b", "c", "d"}, inner) + assert.Equal(t, []string{"a", "b", "c", "d"}, *got) + }) + + t.Run("double pointer to empty slice", func(t *testing.T) { + t.Parallel() + inner := []string{} + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Equal(t, []string{}, *got) + }) + + t.Run("double pointer to nil slice", func(t *testing.T) { + t.Parallel() + var inner []string = nil + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr, got) + assert.Nil(t, *got) + }) + + t.Run("double pointer JSON marshaling", func(t *testing.T) { + t.Parallel() + inner := "json test" + ptr := &inner + nullable := From(ptrFrom(ptr)) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `"json test"`, string(data)) + }) + + t.Run("double pointer JSON unmarshaling", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[*string] + err := json.Unmarshal([]byte(`"json test"`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.NotNil(t, got) + assert.Equal(t, "json test", *got) + }) + + t.Run("double pointer JSON null marshaling", func(t *testing.T) { + t.Parallel() + nullable := From[*string](nil) + + data, err := json.Marshal(nullable) + require.NoError(t, err) + assert.Equal(t, `null`, string(data)) + }) + + t.Run("double pointer JSON null unmarshaling", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[*string] + err := json.Unmarshal([]byte(`null`), &nullable) + require.NoError(t, err) + + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Nil(t, got) + }) + + t.Run("double pointer round trip", func(t *testing.T) { + t.Parallel() + inner := "round trip test" + ptr := &inner + nullable1 := From(ptrFrom(ptr)) + + // Marshal + data, err := json.Marshal(nullable1) + require.NoError(t, err) + + // Unmarshal + var nullable2 OptionalNullable[*string] + err = json.Unmarshal(data, &nullable2) + require.NoError(t, err) + + // Compare states + assert.Equal(t, nullable1.IsSet(), nullable2.IsSet()) + assert.Equal(t, nullable1.IsNull(), nullable2.IsNull()) + + got1, ok1 := nullable1.GetOrZero() + got2, ok2 := nullable2.GetOrZero() + assert.Equal(t, ok1, ok2) + + // Values should be equal + assert.Equal(t, *got1, *got2) + }) + + t.Run("triple pointer", func(t *testing.T) { + t.Parallel() + inner := "triple" + ptr1 := &inner + ptr2 := &ptr1 + nullable := From(ptrFrom(ptr2)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, ptr2, got) + assert.Equal(t, ptr1, *got) + assert.Equal(t, "triple", **got) + }) + + t.Run("double pointer set and unset", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[*string] + + // Initially unset + assert.False(t, nullable.IsSet()) + + // Set to double pointer + inner := "set test" + ptr := &inner + nullable.Set(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "set test", *got) + + // Set to nil + nullable.Set(nil) + + assert.True(t, nullable.IsSet()) + assert.True(t, nullable.IsNull()) + + got, ok = nullable.GetOrZero() + assert.True(t, ok) + assert.Nil(t, got) + + // Unset + nullable.Unset() + + assert.False(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok = nullable.GetOrZero() + assert.False(t, ok) + assert.Nil(t, got) + }) + + t.Run("double pointer Get method", func(t *testing.T) { + t.Parallel() + inner := "get test" + ptr := &inner + nullable := From(ptrFrom(ptr)) + + // Test Get method + gotPtr, ok := nullable.Get() + assert.True(t, ok) + assert.NotNil(t, gotPtr) + assert.Equal(t, ptr, *gotPtr) + assert.Equal(t, "get test", **gotPtr) + + // Test with nil + nilNullable := From[*string](nil) + gotPtr, ok = nilNullable.Get() + assert.True(t, ok) + assert.Nil(t, gotPtr) + + // Test with unset + var unsetNullable OptionalNullable[*string] + gotPtr, ok = unsetNullable.Get() + assert.False(t, ok) + assert.Nil(t, gotPtr) + }) + + t.Run("double pointer zero values", func(t *testing.T) { + t.Parallel() + // Test with zero value string + inner := "" + ptr := &inner + nullable := From(ptrFrom(ptr)) + + assert.True(t, nullable.IsSet()) + assert.False(t, nullable.IsNull()) + + got, ok := nullable.GetOrZero() + assert.True(t, ok) + assert.Equal(t, "", *got) + + // Test with zero value int + innerInt := 0 + ptrInt := &innerInt + nullableInt := From(ptrFrom(ptrInt)) + + assert.True(t, nullableInt.IsSet()) + assert.False(t, nullableInt.IsNull()) + + gotInt, okInt := nullableInt.GetOrZero() + assert.True(t, okInt) + assert.Equal(t, 0, *gotInt) + }) +} + +// TestAsOptionalNullable tests the AsOptionalNullable helper function +func TestAsOptionalNullable(t *testing.T) { + t.Parallel() + + t.Run("with nullable string", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, "test", value) + }) + + t.Run("with nullable int", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom(42)) + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, 42, value) + }) + + t.Run("with nullable nil", func(t *testing.T) { + t.Parallel() + nullable := From[string](nil) + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Nil(t, value) + }) + + t.Run("with unset nullable", func(t *testing.T) { + t.Parallel() + var nullable OptionalNullable[string] + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.False(t, ok) + assert.Nil(t, result) + }) + + t.Run("with non-nullable string", func(t *testing.T) { + t.Parallel() + regularString := "not nullable" + reflectValue := reflect.ValueOf(regularString) + + result, ok := AsOptionalNullable(reflectValue) + assert.False(t, ok) + assert.Nil(t, result) + }) + + t.Run("with non-nullable int", func(t *testing.T) { + t.Parallel() + regularInt := 42 + reflectValue := reflect.ValueOf(regularInt) + + result, ok := AsOptionalNullable(reflectValue) + assert.False(t, ok) + assert.Nil(t, result) + }) + + t.Run("with non-nullable map", func(t *testing.T) { + t.Parallel() + regularMap := map[string]int{"key": 42} + reflectValue := reflect.ValueOf(regularMap) + + result, ok := AsOptionalNullable(reflectValue) + assert.False(t, ok) + assert.Nil(t, result) + }) + + t.Run("with non-nullable struct", func(t *testing.T) { + t.Parallel() + regularStruct := TestStruct{Name: "test", Age: 30} + reflectValue := reflect.ValueOf(regularStruct) + + result, ok := AsOptionalNullable(reflectValue) + assert.False(t, ok) + assert.Nil(t, result) + }) + + t.Run("with nullable double pointer", func(t *testing.T) { + t.Parallel() + inner := "test" + ptr := &inner + nullable := From(ptrFrom(ptr)) + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, ptr, value) + assert.Equal(t, "test", *value.(*string)) + }) + + t.Run("with nullable slice", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom([]string{"a", "b", "c"})) + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, []string{"a", "b", "c"}, value) + }) + + t.Run("with nullable struct", func(t *testing.T) { + t.Parallel() + testStruct := TestStruct{Name: "Alice", Age: 25} + nullable := From(ptrFrom(testStruct)) + reflectValue := reflect.ValueOf(nullable) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, testStruct, value) + }) + + t.Run("with pointer to nullable", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + ptrToNullable := &nullable + reflectValue := reflect.ValueOf(ptrToNullable) + + // This should work since the pointer to nullable still contains a nullable + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, "test", value) + }) + + t.Run("with interface containing nullable", func(t *testing.T) { + t.Parallel() + nullable := From(ptrFrom("test")) + var iface interface{} = nullable + reflectValue := reflect.ValueOf(iface) + + result, ok := AsOptionalNullable(reflectValue) + assert.True(t, ok) + assert.NotNil(t, result) + + value, isSet := result.GetUntyped() + assert.True(t, isSet) + assert.Equal(t, "test", value) + }) +} diff --git a/internal/membershipclient/retry/config.go b/internal/membershipclient/retry/config.go new file mode 100644 index 00000000..aa809fcc --- /dev/null +++ b/internal/membershipclient/retry/config.go @@ -0,0 +1,148 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package retry + +import ( + "errors" + "net/http" + "strconv" + "time" +) + +// BackoffStrategy defines the parameters for exponential backoff. This can be +// used to drive a retry loop for example. +type BackoffStrategy struct { + InitialInterval int + MaxInterval int + Exponent float64 + MaxElapsedTime int +} + +// Config configures a retry policy. +type Config struct { + // Strategy sets the algorithm to use for a retry loop. It can be one of: + // - "backoff": retry with exponential backoff and random jitter. + // - "none" or "": disables retries. + Strategy string + Backoff *BackoffStrategy + RetryConnectionErrors bool +} + +// PermanentError is an error that signals that some operation has terminally +// failed and should not be retried. +type PermanentError struct { + cause error +} + +// Permanent creates a PermanentError that signals to a retry loop that it +// should stop retrying an operation and return the underlying error. +func Permanent(cause error) error { + if IsPermanentError(cause) { + return cause + } + + return &PermanentError{ + cause: cause, + } +} + +func (e *PermanentError) Error() string { + return e.cause.Error() +} + +func (e *PermanentError) Unwrap() error { + return e.cause +} + +// TemporaryError represents a retryable error and signals to a retry loop that +// an operation may be retried with an optional wait interval. +type TemporaryError struct { + wait time.Duration + message string +} + +// Temporary creates a TemporaryError that signals to a retry loop that an +// operation can be retried. The error may also carry details about how long to +// wait before retrying. This wait interval may be used to override the retry +// policy in use. +func Temporary(message string) error { + return &TemporaryError{ + message: message, + } +} + +// TemporaryFromResponse creates a TemporaryError similar to Temporary but +// additionally parses the Retry-After header from a response to determine the +// wait interval before the next retry attempt. +func TemporaryFromResponse(message string, res *http.Response) error { + return &TemporaryError{ + wait: retryIntervalFromResponse(res), + message: message, + } +} + +func (e *TemporaryError) Error() string { + return e.message +} + +// RetryAfter returns the time to wait before retrying the request. The zero +// value should be interpreted by retry loops to mean they should fallback on +// their default policy whether expenonential, constant backoff or something +// else. It does not mean that an operation should be retried immediately. +func (e *TemporaryError) RetryAfter() time.Duration { + return e.wait +} + +func retryIntervalFromResponse(res *http.Response) time.Duration { + if res == nil { + return 0 + } + + retryVal := res.Header.Get("retry-after") + if retryVal == "" { + return 0 + } + + parsedNumber, err := strconv.ParseInt(retryVal, 10, 64) + if err == nil { + if parsedNumber < 0 { + return 0 + } else { + return time.Duration(parsedNumber) * time.Second + } + } + + parsedDate, err := time.Parse(time.RFC1123, retryVal) + if err == nil { + delta := parsedDate.Sub(time.Now()) + if delta < 0 { + return 0 + } else { + return delta + } + } + + return 0 +} + +// IsPermanentError returns true if an error value is or contains a +// PermanentError in its chain of errors. +func IsPermanentError(err error) bool { + if err == nil { + return false + } + + var pe *PermanentError + return errors.As(err, &pe) +} + +// IsTemporaryError returns true if an error value is or contains a +// TemporaryError in its chain of errors. +func IsTemporaryError(err error) bool { + if err == nil { + return false + } + + var pe *TemporaryError + return errors.As(err, &pe) +} diff --git a/internal/membershipclient/sdk.go b/internal/membershipclient/sdk.go new file mode 100644 index 00000000..7d11c3a8 --- /dev/null +++ b/internal/membershipclient/sdk.go @@ -0,0 +1,16346 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package membershipclient + +// Generated from OpenAPI doc version 0.1.0 and generator version 2.763.3 + +import ( + "bytes" + "context" + "fmt" + "github.com/formancehq/fctl/internal/membershipclient/internal/config" + "github.com/formancehq/fctl/internal/membershipclient/internal/hooks" + "github.com/formancehq/fctl/internal/membershipclient/internal/utils" + "github.com/formancehq/fctl/internal/membershipclient/models/apierrors" + "github.com/formancehq/fctl/internal/membershipclient/models/components" + "github.com/formancehq/fctl/internal/membershipclient/models/operations" + "github.com/formancehq/fctl/internal/membershipclient/retry" + "net/http" + "net/url" + "time" +) + +// ServerList contains the list of servers available to the SDK +var ServerList = []string{ + // Local server + "http://localhost:8080", +} + +// HTTPClient provides an interface for supplying the SDK with a custom HTTP client +type HTTPClient interface { + Do(req *http.Request) (*http.Response, error) +} + +// String provides a helper function to return a pointer to a string +func String(s string) *string { return &s } + +// Bool provides a helper function to return a pointer to a bool +func Bool(b bool) *bool { return &b } + +// Int provides a helper function to return a pointer to an int +func Int(i int) *int { return &i } + +// Int64 provides a helper function to return a pointer to an int64 +func Int64(i int64) *int64 { return &i } + +// Float32 provides a helper function to return a pointer to a float32 +func Float32(f float32) *float32 { return &f } + +// Float64 provides a helper function to return a pointer to a float64 +func Float64(f float64) *float64 { return &f } + +// Pointer provides a helper function to return a pointer to a type +func Pointer[T any](v T) *T { return &v } + +type SDK struct { + SDKVersion string + + sdkConfiguration config.SDKConfiguration + hooks *hooks.Hooks +} + +type SDKOption func(*SDK) + +// WithServerURL allows the overriding of the default server URL +func WithServerURL(serverURL string) SDKOption { + return func(sdk *SDK) { + sdk.sdkConfiguration.ServerURL = serverURL + } +} + +// WithTemplatedServerURL allows the overriding of the default server URL with a templated URL populated with the provided parameters +func WithTemplatedServerURL(serverURL string, params map[string]string) SDKOption { + return func(sdk *SDK) { + if params != nil { + serverURL = utils.ReplaceParameters(serverURL, params) + } + + sdk.sdkConfiguration.ServerURL = serverURL + } +} + +// WithServerIndex allows the overriding of the default server by index +func WithServerIndex(serverIndex int) SDKOption { + return func(sdk *SDK) { + if serverIndex < 0 || serverIndex >= len(ServerList) { + panic(fmt.Errorf("server index %d out of range", serverIndex)) + } + + sdk.sdkConfiguration.ServerIndex = serverIndex + } +} + +// WithClient allows the overriding of the default HTTP client used by the SDK +func WithClient(client HTTPClient) SDKOption { + return func(sdk *SDK) { + sdk.sdkConfiguration.Client = client + } +} + +// WithSecurity configures the SDK to use the provided security details +func WithSecurity(oauth2 string) SDKOption { + return func(sdk *SDK) { + security := components.Security{Oauth2: oauth2} + sdk.sdkConfiguration.Security = utils.AsSecuritySource(&security) + } +} + +// WithSecuritySource configures the SDK to invoke the Security Source function on each method call to determine authentication +func WithSecuritySource(security func(context.Context) (components.Security, error)) SDKOption { + return func(sdk *SDK) { + sdk.sdkConfiguration.Security = func(ctx context.Context) (interface{}, error) { + return security(ctx) + } + } +} + +func WithRetryConfig(retryConfig retry.Config) SDKOption { + return func(sdk *SDK) { + sdk.sdkConfiguration.RetryConfig = &retryConfig + } +} + +// WithTimeout Optional request timeout applied to each operation +func WithTimeout(timeout time.Duration) SDKOption { + return func(sdk *SDK) { + sdk.sdkConfiguration.Timeout = &timeout + } +} + +// New creates a new instance of the SDK with the provided options +func New(opts ...SDKOption) *SDK { + sdk := &SDK{ + SDKVersion: "0.1.0", + sdkConfiguration: config.SDKConfiguration{ + UserAgent: "speakeasy-sdk/go 0.1.0 2.763.3 0.1.0 github.com/formancehq/fctl/internal/membershipclient", + ServerList: ServerList, + }, + hooks: hooks.New(), + } + for _, opt := range opts { + opt(sdk) + } + + // Use WithClient to override the default client if you would like to customize the timeout + if sdk.sdkConfiguration.Client == nil { + sdk.sdkConfiguration.Client = &http.Client{Timeout: 60 * time.Second} + } + + sdk.sdkConfiguration = sdk.hooks.SDKInit(sdk.sdkConfiguration) + + return sdk +} + +// GetServerInfo - Get server info +func (s *SDK) GetServerInfo(ctx context.Context, opts ...operations.Option) (*operations.GetServerInfoResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/_info") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getServerInfo", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetServerInfoResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ServerInfo + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ServerInfo = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListOrganizations - List organizations of the connected user +func (s *SDK) ListOrganizations(ctx context.Context, request operations.ListOrganizationsRequest, opts ...operations.Option) (*operations.ListOrganizationsResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/organizations") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listOrganizations", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListOrganizationsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ListOrganizationExpandedResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ListOrganizationExpandedResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// CreateOrganization - Create organization +func (s *SDK) CreateOrganization(ctx context.Context, request *components.CreateOrganizationRequest, opts ...operations.Option) (*operations.CreateOrganizationResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/organizations") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "createOrganization", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Request", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreateOrganizationResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 201: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.CreateOrganizationResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.CreateOrganizationResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListOrganizationsExpanded - List organizations of the connected user with expanded data +// +// Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. +func (s *SDK) ListOrganizationsExpanded(ctx context.Context, opts ...operations.Option) (*operations.ListOrganizationsExpandedResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/organizations/expanded") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listOrganizationsExpanded", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListOrganizationsExpandedResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ListOrganizationExpandedResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ListOrganizationExpandedResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("unknown status code returned", httpRes.StatusCode, string(rawBody), httpRes) + } + + return res, nil + +} + +// ReadOrganization - Read organization +func (s *SDK) ReadOrganization(ctx context.Context, request operations.ReadOrganizationRequest, opts ...operations.Option) (*operations.ReadOrganizationResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "readOrganization", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ReadOrganizationResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ReadOrganizationResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ReadOrganizationResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// UpdateOrganization - Update organization +func (s *SDK) UpdateOrganization(ctx context.Context, request operations.UpdateOrganizationRequest, opts ...operations.Option) (*operations.UpdateOrganizationResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "updateOrganization", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Body", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.UpdateOrganizationResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ReadOrganizationResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ReadOrganizationResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DeleteOrganization - Delete organization +func (s *SDK) DeleteOrganization(ctx context.Context, request operations.DeleteOrganizationRequest, opts ...operations.Option) (*operations.DeleteOrganizationResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteOrganization", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DeleteOrganizationResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ReadAuthenticationProvider - Read authentication provider +func (s *SDK) ReadAuthenticationProvider(ctx context.Context, request operations.ReadAuthenticationProviderRequest, opts ...operations.Option) (*operations.ReadAuthenticationProviderResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/authentication-provider", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "readAuthenticationProvider", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ReadAuthenticationProviderResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.AuthenticationProviderResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.AuthenticationProviderResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// UpsertAuthenticationProvider - Upsert an authentication provider +func (s *SDK) UpsertAuthenticationProvider(ctx context.Context, request operations.UpsertAuthenticationProviderRequest, opts ...operations.Option) (*operations.UpsertAuthenticationProviderResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/authentication-provider", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "upsertAuthenticationProvider", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Body", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.UpsertAuthenticationProviderResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.AuthenticationProviderResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.AuthenticationProviderResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DeleteAuthenticationProvider - Delete authentication provider +func (s *SDK) DeleteAuthenticationProvider(ctx context.Context, request operations.DeleteAuthenticationProviderRequest, opts ...operations.Option) (*operations.DeleteAuthenticationProviderResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/authentication-provider", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteAuthenticationProvider", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DeleteAuthenticationProviderResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListFeatures - List features +func (s *SDK) ListFeatures(ctx context.Context, request operations.ListFeaturesRequest, opts ...operations.Option) (*operations.ListFeaturesResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/features", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listFeatures", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListFeaturesResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out operations.ListFeaturesResponseBody + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Object = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// AddFeatures - Add Features +func (s *SDK) AddFeatures(ctx context.Context, request operations.AddFeaturesRequest, opts ...operations.Option) (*operations.AddFeaturesResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/features", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "addFeatures", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Body", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.AddFeaturesResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DeleteFeature - Delete feature +func (s *SDK) DeleteFeature(ctx context.Context, request operations.DeleteFeatureRequest, opts ...operations.Option) (*operations.DeleteFeatureResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/features/{name}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteFeature", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DeleteFeatureResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ReadOrganizationClient - Read organization client (DEPRECATED) (until 12/31/2025) +// +// Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. +func (s *SDK) ReadOrganizationClient(ctx context.Context, request operations.ReadOrganizationClientRequest, opts ...operations.Option) (*operations.ReadOrganizationClientResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/client", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "readOrganizationClient", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ReadOrganizationClientResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.CreateClientResponseResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.CreateClientResponseResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// CreateOrganizationClient - Create organization client (DEPRECATED) (until 12/31/2025) +// +// Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. +func (s *SDK) CreateOrganizationClient(ctx context.Context, request operations.CreateOrganizationClientRequest, opts ...operations.Option) (*operations.CreateOrganizationClientResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/client", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "createOrganizationClient", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreateOrganizationClientResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 201: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.CreateClientResponseResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.CreateClientResponseResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DeleteOrganizationClient - Delete organization client (DEPRECATED) (until 12/31/2025) +// +// Deprecated: This will be removed in a future release, please migrate away from it as soon as possible. +func (s *SDK) DeleteOrganizationClient(ctx context.Context, request operations.DeleteOrganizationClientRequest, opts ...operations.Option) (*operations.DeleteOrganizationClientResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/client", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteOrganizationClient", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DeleteOrganizationClientResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// OrganizationClientsRead - Read organization clients +func (s *SDK) OrganizationClientsRead(ctx context.Context, request operations.OrganizationClientsReadRequest, opts ...operations.Option) (*operations.OrganizationClientsReadResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/clients", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "organizationClientsRead", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.OrganizationClientsReadResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ReadOrganizationClientsResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ReadOrganizationClientsResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// OrganizationClientCreate - Create organization client +func (s *SDK) OrganizationClientCreate(ctx context.Context, request operations.OrganizationClientCreateRequest, opts ...operations.Option) (*operations.OrganizationClientCreateResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/clients", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "organizationClientCreate", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Body", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.OrganizationClientCreateResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 201: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.CreateOrganizationClientResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.CreateOrganizationClientResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// OrganizationClientRead - Read organization client +func (s *SDK) OrganizationClientRead(ctx context.Context, request operations.OrganizationClientReadRequest, opts ...operations.Option) (*operations.OrganizationClientReadResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/clients/{clientId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "organizationClientRead", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.OrganizationClientReadResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ReadOrganizationClientResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ReadOrganizationClientResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// OrganizationClientDelete - Delete organization client +func (s *SDK) OrganizationClientDelete(ctx context.Context, request operations.OrganizationClientDeleteRequest, opts ...operations.Option) (*operations.OrganizationClientDeleteResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/clients/{clientId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "organizationClientDelete", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.OrganizationClientDeleteResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// OrganizationClientUpdate - Update organization client +func (s *SDK) OrganizationClientUpdate(ctx context.Context, request operations.OrganizationClientUpdateRequest, opts ...operations.Option) (*operations.OrganizationClientUpdateResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/clients/{clientId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "organizationClientUpdate", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Body", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.OrganizationClientUpdateResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListLogs - List logs +func (s *SDK) ListLogs(ctx context.Context, request operations.ListLogsRequest, opts ...operations.Option) (*operations.ListLogsResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/logs", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listLogs", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListLogsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.LogCursor + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.LogCursor = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListUsersOfOrganization - List users of organization +func (s *SDK) ListUsersOfOrganization(ctx context.Context, request operations.ListUsersOfOrganizationRequest, opts ...operations.Option) (*operations.ListUsersOfOrganizationResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/users", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listUsersOfOrganization", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListUsersOfOrganizationResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ListUsersResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ListUsersResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ReadUserOfOrganization - Read user of organization +func (s *SDK) ReadUserOfOrganization(ctx context.Context, request operations.ReadUserOfOrganizationRequest, opts ...operations.Option) (*operations.ReadUserOfOrganizationResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/users/{userId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "readUserOfOrganization", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ReadUserOfOrganizationResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ReadOrganizationUserResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ReadOrganizationUserResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// UpsertOrganizationUser - Update user within an organization +func (s *SDK) UpsertOrganizationUser(ctx context.Context, request operations.UpsertOrganizationUserRequest, opts ...operations.Option) (*operations.UpsertOrganizationUserResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/users/{userId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "upsertOrganizationUser", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Body", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.UpsertOrganizationUserResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DeleteUserFromOrganization - delete user from organization +// The owner of the organization can remove anyone while each user can leave any organization where it is not owner. +func (s *SDK) DeleteUserFromOrganization(ctx context.Context, request operations.DeleteUserFromOrganizationRequest, opts ...operations.Option) (*operations.DeleteUserFromOrganizationResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/users/{userId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteUserFromOrganization", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DeleteUserFromOrganizationResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListPolicies - List policies of organization +func (s *SDK) ListPolicies(ctx context.Context, request operations.ListPoliciesRequest, opts ...operations.Option) (*operations.ListPoliciesResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/policies", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listPolicies", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListPoliciesResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ListPoliciesResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ListPoliciesResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// CreatePolicy - Create policy +func (s *SDK) CreatePolicy(ctx context.Context, request operations.CreatePolicyRequest, opts ...operations.Option) (*operations.CreatePolicyResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/policies", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "createPolicy", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Body", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreatePolicyResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 201: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.CreatePolicyResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.CreatePolicyResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ReadPolicy - Read policy with scopes +func (s *SDK) ReadPolicy(ctx context.Context, request operations.ReadPolicyRequest, opts ...operations.Option) (*operations.ReadPolicyResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/policies/{policyId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "readPolicy", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ReadPolicyResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ReadPolicyResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ReadPolicyResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// UpdatePolicy - Update policy +func (s *SDK) UpdatePolicy(ctx context.Context, request operations.UpdatePolicyRequest, opts ...operations.Option) (*operations.UpdatePolicyResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/policies/{policyId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "updatePolicy", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Body", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.UpdatePolicyResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.UpdatePolicyResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.UpdatePolicyResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DeletePolicy - Delete policy +func (s *SDK) DeletePolicy(ctx context.Context, request operations.DeletePolicyRequest, opts ...operations.Option) (*operations.DeletePolicyResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/policies/{policyId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "deletePolicy", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DeletePolicyResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// AddScopeToPolicy - Add scope to policy +func (s *SDK) AddScopeToPolicy(ctx context.Context, request operations.AddScopeToPolicyRequest, opts ...operations.Option) (*operations.AddScopeToPolicyResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/policies/{policyId}/scopes/{scopeId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "addScopeToPolicy", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.AddScopeToPolicyResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// RemoveScopeFromPolicy - Remove scope from policy +func (s *SDK) RemoveScopeFromPolicy(ctx context.Context, request operations.RemoveScopeFromPolicyRequest, opts ...operations.Option) (*operations.RemoveScopeFromPolicyResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/policies/{policyId}/scopes/{scopeId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "removeScopeFromPolicy", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.RemoveScopeFromPolicyResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListStacks - List stacks +func (s *SDK) ListStacks(ctx context.Context, request operations.ListStacksRequest, opts ...operations.Option) (*operations.ListStacksResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/stacks", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listStacks", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListStacksResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ListStacksResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ListStacksResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// CreateStack - Create stack +func (s *SDK) CreateStack(ctx context.Context, request operations.CreateStackRequest, opts ...operations.Option) (*operations.CreateStackResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/stacks", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "createStack", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Body", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreateStackResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 202: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.CreateStackResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.CreateStackResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListModules - List modules of a stack +func (s *SDK) ListModules(ctx context.Context, request operations.ListModulesRequest, opts ...operations.Option) (*operations.ListModulesResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/stacks/{stackId}/modules", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listModules", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListModulesResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ListModulesResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ListModulesResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// EnableModule - enable module +func (s *SDK) EnableModule(ctx context.Context, request operations.EnableModuleRequest, opts ...operations.Option) (*operations.EnableModuleResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/stacks/{stackId}/modules", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "enableModule", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.EnableModuleResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 202: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DisableModule - disable module +func (s *SDK) DisableModule(ctx context.Context, request operations.DisableModuleRequest, opts ...operations.Option) (*operations.DisableModuleResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/stacks/{stackId}/modules", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "disableModule", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DisableModuleResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 202: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// UpgradeStack - Upgrade stack +func (s *SDK) UpgradeStack(ctx context.Context, request operations.UpgradeStackRequest, opts ...operations.Option) (*operations.UpgradeStackResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/stacks/{stackId}/upgrade", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "upgradeStack", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Body", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.UpgradeStackResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 202: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// GetStack - Find stack +func (s *SDK) GetStack(ctx context.Context, request operations.GetStackRequest, opts ...operations.Option) (*operations.GetStackResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/stacks/{stackId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getStack", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetStackResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.CreateStackResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.CreateStackResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// UpdateStack - Update stack +func (s *SDK) UpdateStack(ctx context.Context, request operations.UpdateStackRequest, opts ...operations.Option) (*operations.UpdateStackResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/stacks/{stackId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "updateStack", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Body", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.UpdateStackResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.CreateStackResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.CreateStackResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DeleteStack - Delete stack +func (s *SDK) DeleteStack(ctx context.Context, request operations.DeleteStackRequest, opts ...operations.Option) (*operations.DeleteStackResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/stacks/{stackId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteStack", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DeleteStackResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListStackUsersAccesses - List stack users accesses within an organization +func (s *SDK) ListStackUsersAccesses(ctx context.Context, request operations.ListStackUsersAccessesRequest, opts ...operations.Option) (*operations.ListStackUsersAccessesResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/stacks/{stackId}/users", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listStackUsersAccesses", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListStackUsersAccessesResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.StackUserAccessResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.StackUserAccessResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ReadStackUserAccess - Read stack user access within an organization +func (s *SDK) ReadStackUserAccess(ctx context.Context, request operations.ReadStackUserAccessRequest, opts ...operations.Option) (*operations.ReadStackUserAccessResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/stacks/{stackId}/users/{userId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "readStackUserAccess", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ReadStackUserAccessResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ReadStackUserAccess + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ReadStackUserAccess = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DeleteStackUserAccess - Delete stack user access within an organization +func (s *SDK) DeleteStackUserAccess(ctx context.Context, request operations.DeleteStackUserAccessRequest, opts ...operations.Option) (*operations.DeleteStackUserAccessResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/stacks/{stackId}/users/{userId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteStackUserAccess", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DeleteStackUserAccessResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// UpsertStackUserAccess - Update stack user access within an organization +func (s *SDK) UpsertStackUserAccess(ctx context.Context, request operations.UpsertStackUserAccessRequest, opts ...operations.Option) (*operations.UpsertStackUserAccessResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/stacks/{stackId}/users/{userId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "upsertStackUserAccess", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Body", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.UpsertStackUserAccessResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DisableStack - Disable stack +func (s *SDK) DisableStack(ctx context.Context, request operations.DisableStackRequest, opts ...operations.Option) (*operations.DisableStackResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/stacks/{stackId}/disable", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "disableStack", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DisableStackResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 202: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// EnableStack - Enable stack +func (s *SDK) EnableStack(ctx context.Context, request operations.EnableStackRequest, opts ...operations.Option) (*operations.EnableStackResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/stacks/{stackId}/enable", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "enableStack", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.EnableStackResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 202: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// RestoreStack - Restore stack +func (s *SDK) RestoreStack(ctx context.Context, request operations.RestoreStackRequest, opts ...operations.Option) (*operations.RestoreStackResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/stacks/{stackId}/restore", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "restoreStack", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.RestoreStackResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 202: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.CreateStackResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.CreateStackResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// EnableStargate - Enable stargate on a stack +func (s *SDK) EnableStargate(ctx context.Context, request operations.EnableStargateRequest, opts ...operations.Option) (*operations.EnableStargateResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/stacks/{stackId}/stargate/enable", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "enableStargate", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.EnableStargateResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 202: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DisableStargate - Disable stargate on a stack +func (s *SDK) DisableStargate(ctx context.Context, request operations.DisableStargateRequest, opts ...operations.Option) (*operations.DisableStargateResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/stacks/{stackId}/stargate/disable", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "disableStargate", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DisableStargateResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 202: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListInvitations - List invitations of the user +func (s *SDK) ListInvitations(ctx context.Context, request operations.ListInvitationsRequest, opts ...operations.Option) (*operations.ListInvitationsResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/me/invitations") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listInvitations", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListInvitationsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ListInvitationsResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ListInvitationsResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// AcceptInvitation - Accept invitation +func (s *SDK) AcceptInvitation(ctx context.Context, request operations.AcceptInvitationRequest, opts ...operations.Option) (*operations.AcceptInvitationResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/me/invitations/{invitationId}/accept", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "acceptInvitation", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.AcceptInvitationResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DeclineInvitation - Decline invitation +func (s *SDK) DeclineInvitation(ctx context.Context, request operations.DeclineInvitationRequest, opts ...operations.Option) (*operations.DeclineInvitationResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/me/invitations/{invitationId}/reject", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "declineInvitation", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DeclineInvitationResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListOrganizationInvitations - List invitations of the organization +func (s *SDK) ListOrganizationInvitations(ctx context.Context, request operations.ListOrganizationInvitationsRequest, opts ...operations.Option) (*operations.ListOrganizationInvitationsResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/invitations", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listOrganizationInvitations", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListOrganizationInvitationsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ListInvitationsResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ListInvitationsResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// CreateInvitation - Create invitation +func (s *SDK) CreateInvitation(ctx context.Context, request operations.CreateInvitationRequest, opts ...operations.Option) (*operations.CreateInvitationResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/invitations", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "createInvitation", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreateInvitationResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + fallthrough + case httpRes.StatusCode == 201: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.CreateInvitationResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.CreateInvitationResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DeleteInvitation - Delete invitation +func (s *SDK) DeleteInvitation(ctx context.Context, request operations.DeleteInvitationRequest, opts ...operations.Option) (*operations.DeleteInvitationResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/invitations/{invitationId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteInvitation", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DeleteInvitationResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListRegions - List regions +func (s *SDK) ListRegions(ctx context.Context, request operations.ListRegionsRequest, opts ...operations.Option) (*operations.ListRegionsResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/regions", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listRegions", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListRegionsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ListRegionsResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ListRegionsResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// CreatePrivateRegion - Create a private region +func (s *SDK) CreatePrivateRegion(ctx context.Context, request operations.CreatePrivateRegionRequest, opts ...operations.Option) (*operations.CreatePrivateRegionResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/regions", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "createPrivateRegion", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Body", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreatePrivateRegionResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.CreatedPrivateRegionResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.CreatedPrivateRegionResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// GetRegion - Get region +func (s *SDK) GetRegion(ctx context.Context, request operations.GetRegionRequest, opts ...operations.Option) (*operations.GetRegionResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/regions/{regionID}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getRegion", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetRegionResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.GetRegionResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.GetRegionResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DeleteRegion - Delete region +func (s *SDK) DeleteRegion(ctx context.Context, request operations.DeleteRegionRequest, opts ...operations.Option) (*operations.DeleteRegionResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/regions/{regionID}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteRegion", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DeleteRegionResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// GetRegionVersions - Get region versions +func (s *SDK) GetRegionVersions(ctx context.Context, request operations.GetRegionVersionsRequest, opts ...operations.Option) (*operations.GetRegionVersionsResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/regions/{regionID}/versions", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getRegionVersions", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetRegionVersionsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.GetRegionVersionsResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.GetRegionVersionsResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListOrganizationApplications - List applications enabled for organization +func (s *SDK) ListOrganizationApplications(ctx context.Context, request operations.ListOrganizationApplicationsRequest, opts ...operations.Option) (*operations.ListOrganizationApplicationsResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/applications", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listOrganizationApplications", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateQueryParams(ctx, req, request, nil); err != nil { + return nil, fmt.Errorf("error populating query params: %w", err) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListOrganizationApplicationsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ListApplicationsResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ListApplicationsResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// GetOrganizationApplication - Get application for organization +func (s *SDK) GetOrganizationApplication(ctx context.Context, request operations.GetOrganizationApplicationRequest, opts ...operations.Option) (*operations.GetOrganizationApplicationResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/applications/{applicationId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getOrganizationApplication", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetOrganizationApplicationResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.GetApplicationResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.GetApplicationResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// EnableApplicationForOrganization - Enable application for organization +func (s *SDK) EnableApplicationForOrganization(ctx context.Context, request operations.EnableApplicationForOrganizationRequest, opts ...operations.Option) (*operations.EnableApplicationForOrganizationResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/applications/{applicationId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "enableApplicationForOrganization", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.EnableApplicationForOrganizationResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 201: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.EnableApplicationForOrganizationResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.EnableApplicationForOrganizationResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DisableApplicationForOrganization - Disable application for organization +func (s *SDK) DisableApplicationForOrganization(ctx context.Context, request operations.DisableApplicationForOrganizationRequest, opts ...operations.Option) (*operations.DisableApplicationForOrganizationResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/organizations/{organizationId}/applications/{applicationId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "disableApplicationForOrganization", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DisableApplicationForOrganizationResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ListApplications - List applications +func (s *SDK) ListApplications(ctx context.Context, opts ...operations.Option) (*operations.ListApplicationsResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/applications") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "listApplications", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ListApplicationsResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ListApplicationsResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ListApplicationsResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// CreateApplication - Create application +func (s *SDK) CreateApplication(ctx context.Context, request *components.ApplicationData, opts ...operations.Option) (*operations.CreateApplicationResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/applications") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "createApplication", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Request", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreateApplicationResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 201: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.CreateApplicationResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.CreateApplicationResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// GetApplication - Get application +func (s *SDK) GetApplication(ctx context.Context, request operations.GetApplicationRequest, opts ...operations.Option) (*operations.GetApplicationResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/applications/{applicationId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "getApplication", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.GetApplicationResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.GetApplicationResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.GetApplicationResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// UpdateApplication - Update application +func (s *SDK) UpdateApplication(ctx context.Context, request operations.UpdateApplicationRequest, opts ...operations.Option) (*operations.UpdateApplicationResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/applications/{applicationId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "updateApplication", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Body", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "PUT", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.UpdateApplicationResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.UpdateApplicationResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.UpdateApplicationResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DeleteApplication - Delete application +func (s *SDK) DeleteApplication(ctx context.Context, request operations.DeleteApplicationRequest, opts ...operations.Option) (*operations.DeleteApplicationResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/applications/{applicationId}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteApplication", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DeleteApplicationResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// CreateApplicationScope - Create application scope +func (s *SDK) CreateApplicationScope(ctx context.Context, request operations.CreateApplicationScopeRequest, opts ...operations.Option) (*operations.CreateApplicationScopeResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/applications/{applicationId}/scopes", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "createApplicationScope", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, true, "Body", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreateApplicationScopeResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 201: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.CreateApplicationScopeResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.CreateApplicationScopeResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// DeleteApplicationScope - Delete application scope +// Delete a specific scope from an application. This operation requires system administrator privileges. +func (s *SDK) DeleteApplicationScope(ctx context.Context, request operations.DeleteApplicationScopeRequest, opts ...operations.Option) (*operations.DeleteApplicationScopeResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := utils.GenerateURL(ctx, baseURL, "/applications/{applicationId}/scopes/{scopeID}", request, nil) + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "deleteApplicationScope", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "DELETE", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "404", "4XX", "500", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.DeleteApplicationScopeResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 204: + case httpRes.StatusCode == 400: + fallthrough + case httpRes.StatusCode == 404: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out apierrors.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + out.HTTPMeta = components.HTTPMetadata{ + Request: req, + Response: httpRes, + } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 500: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out apierrors.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + out.HTTPMeta = components.HTTPMetadata{ + Request: req, + Response: httpRes, + } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// CreateUser - Create user +// Create a new user in the system. This operation requires system administrator privileges. +func (s *SDK) CreateUser(ctx context.Context, request components.CreateUserRequest, opts ...operations.Option) (*operations.CreateUserResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/users") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "createUser", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + bodyReader, reqContentType, err := utils.SerializeRequestBody(ctx, request, false, false, "Request", "json", `request:"mediaType=application/json"`) + if err != nil { + return nil, err + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "POST", opURL, bodyReader) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + if reqContentType != "" { + req.Header.Set("Content-Type", reqContentType) + } + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"400", "4XX", "500", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.CreateUserResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 201: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.CreateUserResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.CreateUserResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 400: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out apierrors.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + out.HTTPMeta = components.HTTPMetadata{ + Request: req, + Response: httpRes, + } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode == 500: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out apierrors.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + out.HTTPMeta = components.HTTPMetadata{ + Request: req, + Response: httpRes, + } + return nil, &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} + +// ReadConnectedUser - Read user +func (s *SDK) ReadConnectedUser(ctx context.Context, opts ...operations.Option) (*operations.ReadConnectedUserResponse, error) { + o := operations.Options{} + supportedOptions := []string{ + operations.SupportedOptionRetries, + operations.SupportedOptionTimeout, + } + + for _, opt := range opts { + if err := opt(&o, supportedOptions...); err != nil { + return nil, fmt.Errorf("error applying option: %w", err) + } + } + + var baseURL string + if o.ServerURL == nil { + baseURL = utils.ReplaceParameters(s.sdkConfiguration.GetServerDetails()) + } else { + baseURL = *o.ServerURL + } + opURL, err := url.JoinPath(baseURL, "/me") + if err != nil { + return nil, fmt.Errorf("error generating URL: %w", err) + } + + hookCtx := hooks.HookContext{ + SDK: s, + SDKConfiguration: s.sdkConfiguration, + BaseURL: baseURL, + Context: ctx, + OperationID: "readConnectedUser", + OAuth2Scopes: nil, + SecuritySource: s.sdkConfiguration.Security, + } + + timeout := o.Timeout + if timeout == nil { + timeout = s.sdkConfiguration.Timeout + } + + if timeout != nil { + var cancel context.CancelFunc + ctx, cancel = context.WithTimeout(ctx, *timeout) + defer cancel() + } + + req, err := http.NewRequestWithContext(ctx, "GET", opURL, nil) + if err != nil { + return nil, fmt.Errorf("error creating request: %w", err) + } + req.Header.Set("Accept", "application/json") + req.Header.Set("User-Agent", s.sdkConfiguration.UserAgent) + + if err := utils.PopulateSecurity(ctx, req, s.sdkConfiguration.Security); err != nil { + return nil, err + } + + for k, v := range o.SetHeaders { + req.Header.Set(k, v) + } + + globalRetryConfig := s.sdkConfiguration.RetryConfig + retryConfig := o.Retries + if retryConfig == nil { + if globalRetryConfig != nil { + retryConfig = globalRetryConfig + } + } + + var httpRes *http.Response + if retryConfig != nil { + httpRes, err = utils.Retry(ctx, utils.Retries{ + Config: retryConfig, + StatusCodes: []string{ + "429", + "500", + "502", + "503", + "504", + }, + }, func() (*http.Response, error) { + if req.Body != nil && req.Body != http.NoBody && req.GetBody != nil { + copyBody, err := req.GetBody() + + if err != nil { + return nil, err + } + + req.Body = copyBody + } + + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + if retry.IsPermanentError(err) || retry.IsTemporaryError(err) { + return nil, err + } + + return nil, retry.Permanent(err) + } + + httpRes, err := s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + } + return httpRes, err + }) + + if err != nil { + return nil, err + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } else { + req, err = s.hooks.BeforeRequest(hooks.BeforeRequestContext{HookContext: hookCtx}, req) + if err != nil { + return nil, err + } + + httpRes, err = s.sdkConfiguration.Client.Do(req) + if err != nil || httpRes == nil { + if err != nil { + err = fmt.Errorf("error sending request: %w", err) + } else { + err = fmt.Errorf("error sending request: no response") + } + + _, err = s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, nil, err) + return nil, err + } else if utils.MatchStatusCodes([]string{"4XX", "5XX"}, httpRes.StatusCode) { + _httpRes, err := s.hooks.AfterError(hooks.AfterErrorContext{HookContext: hookCtx}, httpRes, nil) + if err != nil { + return nil, err + } else if _httpRes != nil { + httpRes = _httpRes + } + } else { + httpRes, err = s.hooks.AfterSuccess(hooks.AfterSuccessContext{HookContext: hookCtx}, httpRes) + if err != nil { + return nil, err + } + } + } + + res := &operations.ReadConnectedUserResponse{ + HTTPMeta: components.HTTPMetadata{ + Request: req, + Response: httpRes, + }, + } + + switch { + case httpRes.StatusCode == 200: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.ReadUserResponse + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.ReadUserResponse = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + case httpRes.StatusCode >= 400 && httpRes.StatusCode < 500: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + case httpRes.StatusCode >= 500 && httpRes.StatusCode < 600: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError("API error occurred", httpRes.StatusCode, string(rawBody), httpRes) + default: + switch { + case utils.MatchContentType(httpRes.Header.Get("Content-Type"), `application/json`): + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + + var out components.Error + if err := utils.UnmarshalJsonFromResponseBody(bytes.NewBuffer(rawBody), &out, ""); err != nil { + return nil, err + } + + res.Error = &out + default: + rawBody, err := utils.ConsumeRawBody(httpRes) + if err != nil { + return nil, err + } + return nil, apierrors.NewAPIError(fmt.Sprintf("unknown content-type received: %s", httpRes.Header.Get("Content-Type")), httpRes.StatusCode, string(rawBody), httpRes) + } + } + + return res, nil + +} diff --git a/internal/membershipclient/types/bigint.go b/internal/membershipclient/types/bigint.go new file mode 100644 index 00000000..9c6a086d --- /dev/null +++ b/internal/membershipclient/types/bigint.go @@ -0,0 +1,21 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +import ( + "fmt" + "math/big" +) + +// MustNewBigIntFromString returns an instance of big.Int from a string +// The string is assumed to be base 10 and if it is not a valid big.Int +// then the function panics. +// Avoid using this function in production code. +func MustNewBigIntFromString(s string) *big.Int { + i, ok := new(big.Int).SetString(s, 10) + if !ok { + panic(fmt.Errorf("failed to parse string as big.Int")) + } + + return i +} diff --git a/internal/membershipclient/types/date.go b/internal/membershipclient/types/date.go new file mode 100644 index 00000000..5b2782f2 --- /dev/null +++ b/internal/membershipclient/types/date.go @@ -0,0 +1,90 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +import ( + "encoding/json" + "fmt" + "strings" + "time" +) + +// Date is a wrapper around time.Time that allows for JSON marshaling a date string formatted as "2006-01-02". +type Date struct { + time.Time +} + +var ( + _ json.Marshaler = &Date{} + _ json.Unmarshaler = &Date{} + _ fmt.Stringer = &Date{} +) + +// NewDate returns an instance of Date from a time.Time. +func NewDate(t time.Time) *Date { + d := DateFromTime(t) + return &d +} + +// DateFromTime returns a Date from a time.Time. +func DateFromTime(t time.Time) Date { + return Date{t} +} + +// NewDateFromString returns an instance of Date from a string formatted as "2006-01-02". +func NewDateFromString(str string) (*Date, error) { + d, err := DateFromString(str) + if err != nil { + return nil, err + } + + return &d, nil +} + +// DateFromString returns a Date from a string formatted as "2006-01-02". +func DateFromString(str string) (Date, error) { + var d Date + var err error + + d.Time, err = time.Parse("2006-01-02", str) + return d, err +} + +// MustNewDateFromString returns an instance of Date from a string formatted as "2006-01-02" or panics. +// Avoid using this function in production code. +func MustNewDateFromString(str string) *Date { + d := MustDateFromString(str) + return &d +} + +// MustDateFromString returns a Date from a string formatted as "2006-01-02" or panics. +// Avoid using this function in production code. +func MustDateFromString(str string) Date { + d, err := DateFromString(str) + if err != nil { + panic(err) + } + return d +} + +func (d Date) GetTime() time.Time { + return d.Time +} + +func (d Date) MarshalJSON() ([]byte, error) { + return []byte(fmt.Sprintf(`"%s"`, d.Time.Format("2006-01-02"))), nil +} + +func (d *Date) UnmarshalJSON(data []byte) error { + var err error + + str := string(data) + str = strings.Trim(str, `"`) + + d.Time, err = time.Parse("2006-01-02", str) + return err +} + +func (d Date) String() string { + return d.Time.Format("2006-01-02") +} diff --git a/internal/membershipclient/types/datetime.go b/internal/membershipclient/types/datetime.go new file mode 100644 index 00000000..3eff332d --- /dev/null +++ b/internal/membershipclient/types/datetime.go @@ -0,0 +1,23 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +import "time" + +// MustTimeFromString returns a time.Time from a string formatted as "2006-01-02T15:04:05Z07:00" or panics. +// Avoid using this function in production code. +func MustTimeFromString(str string) time.Time { + t, err := time.Parse(time.RFC3339, str) + if err != nil { + panic(err) + } + + return t +} + +// MustNewTimeFromString returns an instance of time.Time from a string formatted as "2006-01-02T15:04:05Z07:00" or panics. +// Avoid using this function in production code. +func MustNewTimeFromString(str string) *time.Time { + t := MustTimeFromString(str) + return &t +} diff --git a/internal/membershipclient/types/pointers.go b/internal/membershipclient/types/pointers.go new file mode 100644 index 00000000..35c439d2 --- /dev/null +++ b/internal/membershipclient/types/pointers.go @@ -0,0 +1,11 @@ +// Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + +package types + +func String(s string) *string { return &s } +func Bool(b bool) *bool { return &b } +func Int(i int) *int { return &i } +func Int64(i int64) *int64 { return &i } +func Float32(f float32) *float32 { return &f } +func Float64(f float64) *float64 { return &f } +func Pointer[T any](v T) *T { return &v } diff --git a/membership-swagger.yaml b/membership-swagger.yaml deleted file mode 100644 index 20447164..00000000 --- a/membership-swagger.yaml +++ /dev/null @@ -1,2465 +0,0 @@ -openapi: 3.0.3 -info: - title: Membership API - contact: {} - version: "0.1.0" - -servers: -- url: http://localhost:8080 - description: Local server - -paths: - /_info: - get: - summary: Get server info - operationId: getServerInfo - responses: - 200: - description: Server information - content: - application/json: - schema: - $ref: "#/components/schemas/ServerInfo" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations: - get: - summary: List organizations of the connected user - operationId: listOrganizations - parameters: - - name: expand - in: query - schema: - type: boolean - required: false - responses: - 200: - description: List of organizations - content: - application/json: - schema: - $ref: "#/components/schemas/ListOrganizationExpandedResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - post: - summary: Create organization - operationId: createOrganization - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/CreateOrganizationRequest" - responses: - 201: - description: Organization created - content: - application/json: - schema: - $ref: "#/components/schemas/CreateOrganizationResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - - /organizations/expanded: - get: - summary: List organizations of the connected user with expanded data - operationId: listOrganizationsExpanded - deprecated: true - responses: - 200: - description: List of organizations with expanded data - content: - application/json: - schema: - $ref: "#/components/schemas/ListOrganizationExpandedResponse" - /organizations/{organizationId}: - get: - summary: Read organization - operationId: readOrganization - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: expand - in: query - schema: - type: boolean - required: false - responses: - 200: - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/ReadOrganizationResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - - put: - summary: Update organization - operationId: updateOrganization - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/OrganizationData" - responses: - 200: - description: Organization updated - content: - application/json: - schema: - $ref: "#/components/schemas/ReadOrganizationResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - delete: - summary: Delete organization - operationId: deleteOrganization - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - responses: - 204: - description: Organization deleted - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/authentication-provider: - get: - summary: Read authentication provider - operationId: readAuthenticationProvider - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - responses: - 200: - description: Authentication provider details - content: - application/json: - schema: - $ref: "#/components/schemas/AuthenticationProviderResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - put: - summary: Upsert an authentication provider - operationId: upsertAuthenticationProvider - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/UpsertAuthenticationProviderRequest" - responses: - 200: - description: Authentication provider created or updated - content: - application/json: - schema: - $ref: "#/components/schemas/AuthenticationProviderResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - delete: - summary: Delete authentication provider - operationId: deleteAuthenticationProvider - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - responses: - 204: - description: Authentication provider deleted - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - - /organizations/{organizationId}/features: - get: - summary: List features - operationId: listFeatures - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - responses: - 200: - description: List of features - content: - application/json: - schema: - type: object - required: - - data - properties: - data: - type: array - items: - $ref: "#/components/schemas/OrganizationFeature" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - post: - summary: Add Features - operationId: addFeatures - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - requestBody: - content: - application/json: - schema: - type: object - required: - - features - properties: - features: - type: array - items: - type: string - responses: - 204: - description: Features added - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/features/{name}: - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: name - in: path - schema: - type: string - required: true - delete: - summary: Delete feature - operationId: deleteFeature - responses: - 204: - description: Feature deleted - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/client: - get: - summary: Read organization client (DEPRECATED) (until 12/31/2025) - operationId: readOrganizationClient - deprecated: true - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - responses: - 200: - description: Organization client - content: - application/json: - schema: - $ref: "#/components/schemas/CreateClientResponseResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - put: - summary: Create organization client (DEPRECATED) (until 12/31/2025) - operationId: createOrganizationClient - deprecated: true - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - responses: - 201: - description: Client organization created - content: - application/json: - schema: - $ref: "#/components/schemas/CreateClientResponseResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - delete: - summary: Delete organization client (DEPRECATED) (until 12/31/2025) - operationId: deleteOrganizationClient - deprecated: true - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - responses: - 204: - description: Client deleted - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/clients: - get: - summary: Read organization clients - operationId: organizationClientsRead - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: cursor - in: query - schema: - type: string - - name: pageSize - in: query - schema: - type: integer - minimum: 1 - responses: - 200: - description: Organization client - content: - application/json: - schema: - $ref: "#/components/schemas/ReadOrganizationClientsResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - post: - summary: Create organization client - operationId: organizationClientCreate - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/CreateOrganizationClientRequest" - responses: - 201: - description: Organization client created - content: - application/json: - schema: - $ref: "#/components/schemas/CreateOrganizationClientResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/clients/{clientId}: - get: - summary: Read organization client - operationId: organizationClientRead - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: clientId - in: path - schema: - type: string - required: true - responses: - 200: - description: Organization client details - content: - application/json: - schema: - $ref: "#/components/schemas/ReadOrganizationClientResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - delete: - summary: Delete organization client - operationId: organizationClientDelete - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: clientId - in: path - schema: - type: string - required: true - responses: - 204: - description: Client deleted - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - put: - summary: Update organization client - operationId: organizationClientUpdate - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: clientId - in: path - schema: - type: string - required: true - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/UpdateOrganizationClientRequest" - responses: - 204: - description: Client updated - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/logs: - get: - summary: List logs - operationId: listLogs - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: stackId - in: query - schema: - type: string - required: false - - name: cursor - in: query - schema: - type: string - required: false - - name: pageSize - in: query - schema: - type: integer - minimum: 1 - required: false - - name: action - in: query - schema: - $ref: "#/components/schemas/Action" - required: false - - name: userId - in: query - schema: - type: string - required: false - - name: key - in: query - schema: - type: string - required: false - - name: value - in: query - schema: - type: string - required: false - responses: - 200: - description: Cursor of logs - content: - application/json: - schema: - $ref: "#/components/schemas/LogCursor" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/users: - get: - summary: List users of organization - operationId: listUsersOfOrganization - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - responses: - 200: - description: List of users - content: - application/json: - schema: - $ref: "#/components/schemas/ListUsersResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/users/{userId}: - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: userId - in: path - schema: - type: string - required: true - get: - summary: Read user of organization - operationId: readUserOfOrganization - responses: - 200: - description: Read a user - content: - application/json: - schema: - $ref: "#/components/schemas/ReadOrganizationUserResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - put: - summary: Update user within an organization - operationId: upsertOrganizationUser - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/UpdateOrganizationUserRequest" - responses: - 204: - description: Updated user - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - delete: - summary: delete user from organization - operationId: deleteUserFromOrganization - description: | - The owner of the organization can remove anyone while each user can leave any organization where it is not owner. - responses: - 204: - description: User deleted from organization - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/stacks: - get: - summary: List stacks - operationId: listStacks - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: all - in: query - description: Include deleted and disabled stacks - schema: - type: boolean - required: false - - name: deleted - in: query - description: Include deleted stacks - deprecated: true - schema: - type: boolean - required: false - responses: - 200: - description: List of stacks - content: - application/json: - schema: - $ref: "#/components/schemas/ListStacksResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - post: - summary: Create stack - operationId: createStack - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/CreateStackRequest" - responses: - 202: - description: Stack created - content: - application/json: - schema: - $ref: "#/components/schemas/CreateStackResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/stacks/{stackId}/modules: - get: - summary: List modules of a stack - operationId: listModules - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: stackId - in: path - schema: - type: string - required: true - responses: - 200: - description: List of modules - content: - application/json: - schema: - $ref: "#/components/schemas/ListModulesResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - post: - summary: enable module - operationId: enableModule - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: stackId - in: path - schema: - type: string - required: true - - name: name - in: query - schema: - type: string - required: true - responses: - 202: - description: Module enabled - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - delete: - summary: disable module - operationId: disableModule - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: stackId - in: path - schema: - type: string - required: true - - name: name - in: query - schema: - type: string - required: true - responses: - 202: - description: Module disabled - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - - /organizations/{organizationId}/stacks/{stackId}/upgrade: - put: - summary: Upgrade stack - operationId: upgradeStack - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: stackId - in: path - schema: - type: string - required: true - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/StackVersion" - responses: - 202: - description: Stack upgrade accepted - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/stacks/{stackId}: - get: - summary: Find stack - operationId: getStack - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: stackId - in: path - schema: - type: string - required: true - responses: - 200: - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/ReadStackResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - put: - summary: Update stack - operationId: updateStack - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: stackId - in: path - schema: - type: string - required: true - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/UpdateStackRequest" - responses: - 200: - description: Updated stack - content: - application/json: - schema: - $ref: "#/components/schemas/ReadStackResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - - delete: - summary: Delete stack - operationId: deleteStack - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: stackId - in: path - schema: - type: string - required: true - - name: force - in: query - schema: - type: boolean - required: false - responses: - 204: - description: Stack deleted - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/stacks/{stackId}/users: - get: - summary: List stack users accesses within an organization - operationId: listStackUsersAccesses - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: stackId - in: path - schema: - type: string - required: true - responses: - 200: - description: Stack users access role - content: - application/json: - schema: - $ref: "#/components/schemas/StackUserAccessResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/stacks/{stackId}/users/{userId}: - get: - summary: Read stack user access role within an organization - operationId: readStackUserAccess - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: stackId - in: path - schema: - type: string - required: true - - name: userId - in: path - schema: - type: string - required: true - responses: - 200: - description: Stack user access role - content: - application/json: - schema: - $ref: "#/components/schemas/ReadStackUserAccess" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - delete: - summary: Delete stack user access role within an organization - operationId: deleteStackUserAccess - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: stackId - in: path - schema: - type: string - required: true - - name: userId - in: path - schema: - type: string - required: true - responses: - 204: - description: Updated user - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - put: - summary: Update stack user access role within an organization - operationId: upsertStackUserAccess - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: stackId - in: path - schema: - type: string - required: true - - name: userId - in: path - schema: - type: string - required: true - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/UpdateStackUserRequest" - responses: - 204: - description: Updated user - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/stacks/{stackId}/disable: - put: - summary: Disable stack - operationId: disableStack - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: stackId - in: path - schema: - type: string - required: true - responses: - 202: - description: Stack disabled - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/stacks/{stackId}/enable: - put: - summary: Enable stack - operationId: enableStack - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: stackId - in: path - schema: - type: string - required: true - responses: - 202: - description: Stack enabled - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/stacks/{stackId}/restore: - put: - summary: Restore stack - operationId: restoreStack - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: stackId - in: path - schema: - type: string - required: true - responses: - 202: - description: OK - content: - application/json: - schema: - $ref: "#/components/schemas/ReadStackResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/stacks/{stackId}/stargate/enable: - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: stackId - in: path - schema: - type: string - required: true - put: - summary: Enable stargate on a stack - operationId: enableStargate - responses: - 202: - description: OK - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/stacks/{stackId}/stargate/disable: - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: stackId - in: path - schema: - type: string - required: true - put: - summary: Disable stargate on a stack - operationId: disableStargate - responses: - 202: - description: OK - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /me/invitations: - get: - summary: List invitations of the user - operationId: listInvitations - parameters: - - in: query - name: status - required: false - description: Status of organizations - schema: - type: string - - in: query - name: organization - required: false - description: Status of organizations - schema: - type: string - responses: - 200: - description: List of the invitations for the connected user - content: - application/json: - schema: - $ref: "#/components/schemas/ListInvitationsResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /me/invitations/{invitationId}/accept: - post: - summary: Accept invitation - operationId: acceptInvitation - parameters: - - name: invitationId - in: path - schema: - type: string - required: true - responses: - 204: - description: Invitation accepted - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /me/invitations/{invitationId}/reject: - post: - summary: Decline invitation - operationId: declineInvitation - parameters: - - name: invitationId - in: path - schema: - type: string - required: true - responses: - 204: - description: Invitation declined - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/invitations: - get: - summary: List invitations of the organization - operationId: listOrganizationInvitations - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - in: query - name: status - required: false - description: Status of organizations - schema: - type: string - responses: - 200: - description: List of the invitations for the organization - content: - application/json: - schema: - $ref: "#/components/schemas/ListInvitationsResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - post: - summary: Create invitation - operationId: createInvitation - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: email - in: query - schema: - type: string - required: true - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/InvitationClaim" - responses: - 200: - description: Invitation already sent - content: - application/json: - schema: - $ref: "#/components/schemas/CreateInvitationResponse" - 201: - description: Invitation created - content: - application/json: - schema: - $ref: "#/components/schemas/CreateInvitationResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/invitations/{invitationId}: - delete: - summary: Delete invitation - operationId: deleteInvitation - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: invitationId - in: path - schema: - type: string - required: true - responses: - 204: - description: Invitation deleted - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/regions: - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - get: - summary: List regions - operationId: listRegions - responses: - 200: - description: List of the regions - content: - application/json: - schema: - $ref: "#/components/schemas/ListRegionsResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - post: - summary: Create a private region - operationId: createPrivateRegion - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/CreatePrivateRegionRequest" - responses: - 200: - description: Created region - content: - application/json: - schema: - $ref: "#/components/schemas/CreatedPrivateRegionResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/regions/{regionID}: - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: regionID - in: path - schema: - type: string - required: true - get: - summary: Get region - operationId: getRegion - responses: - 200: - description: Get a specific region - content: - application/json: - schema: - $ref: "#/components/schemas/GetRegionResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - delete: - summary: Delete region - operationId: deleteRegion - responses: - 204: - description: Delete a specific region - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /organizations/{organizationId}/regions/{regionID}/versions: - parameters: - - name: organizationId - in: path - schema: - type: string - required: true - - name: regionID - in: path - schema: - type: string - required: true - get: - summary: Get region versions - operationId: getRegionVersions - responses: - 200: - description: Get a specific region - content: - application/json: - schema: - $ref: "#/components/schemas/GetRegionVersionsResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - /me: - get: - summary: Read user - operationId: readConnectedUser - responses: - 200: - description: Read a user - content: - application/json: - schema: - $ref: "#/components/schemas/ReadUserResponse" - default: - description: Error - content: - application/json: - schema: - $ref: "#/components/schemas/Error" -security: -- oauth2: [] - -components: - securitySchemes: - oauth2: - type: oauth2 - flows: - authorizationCode: - authorizationUrl: /authorize - tokenUrl: /oauth/token - scopes: - openid: Enable OIDC - email: Ask email access - schemas: - Module: - type: object - required: - - name - - state - - status - - lastStatusUpdate - - lastStateUpdate - properties: - name: - type: string - state: - type: string - enum: - - ENABLED - - DISABLED - status: - type: string - enum: - - UNKNOWN - - PROGRESSING - - READY - - DELETED - lastStatusUpdate: - type: string - format: date-time - lastStateUpdate: - type: string - format: date-time - clusterStatus: - type: object - - ListModulesResponse: - type: object - required: - - data - properties: - data: - type: array - items: - $ref: "#/components/schemas/Module" - Action: - type: string - enum: - - agents.connected - - agents.disconnected - - invitations.created - - invitations.accepted - - invitations.rejected - - invitations.cancelled - - organizations.created - - organizations.updated - - organizations.deleted - - organizations.user.deleted - - organizations.user.updated - - regions.created - - regions.deleted - - users.created - - users.deleted - - stacks.disposal - - stacks.disposal-reset - - stacks.warned - - stacks.pruned - - stacks.status.updated - - stacks.created - - stacks.updated - - stacks.deleted - - stacks.restored - - stacks.disabled - - stacks.enabled - - stacks.upgraded - - stacks.stargate.enabled - - stacks.stargate.disabled - - stacks.user.updated - - stacks.user.deleted - - stacks.reachness.updated - - stacks.module.enabled - - stacks.module.disabled - - stacks.module.status.updated - LogCursor: - properties: - data: - allOf: - - $ref: "#/components/schemas/Cursor" - - type: object - properties: - data: - type: array - items: - $ref: "#/components/schemas/Log" - required: - - data - Log: - type: object - required: - - seq - - organizationId - - userId - - action - - date - - data - properties: - seq: - type: string - example: 1e6f8b6e-1b6b-4b3b-8b3b-1b6b4b3b8b3b - organizationId: - type: string - userId: - type: string - action: - type: string - date: - type: string - format: date-time - data: - type: object - Cursor: - type: object - required: - - pageSize - - hasMore - - data - properties: - pageSize: - type: integer - format: int64 - minimum: 1 - maximum: 1000 - example: 15 - hasMore: - type: boolean - example: false - previous: - type: string - example: YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= - next: - type: string - example: "" - OrganizationFeature: - type: object - required: - - name - - organizationID - - createdAt - properties: - organizationID: - type: string - name: - type: string - createdAt: - type: string - format: date-time - CreatePrivateRegionRequest: - type: object - properties: - name: - type: string - required: - - name - CreatedPrivateRegionResponse: - properties: - data: - $ref: "#/components/schemas/PrivateRegion" - required: - - data - PrivateRegion: - allOf: - - $ref: "#/components/schemas/Region" - - type: object - properties: - organizationID: - type: string - creatorID: - type: string - secret: - $ref: "#/components/schemas/PrivateRegionSecret" - required: - - organizationID - - creatorID - PublicRegion: - allOf: - - $ref: "#/components/schemas/Region" - - type: object - properties: - production: - type: boolean - required: - - production - AnyRegion: - allOf: - - $ref: "#/components/schemas/Region" - - type: object - properties: - clientID: - type: string - organizationID: - type: string - creator: - $ref: "#/components/schemas/User" - production: - type: boolean - public: - type: boolean - version: - type: string - agentID: - type: string - outdated: - type: boolean - secret: - $ref: "#/components/schemas/PrivateRegionSecret" - - required: - - public - - agentID - - outdated - PrivateRegionSecret: - type: object - required: - - lastDigits - properties: - lastDigits: - type: string - clear: - type: string - OrganizationData: - type: object - required: - - name - properties: - name: - type: string - description: Organization name - defaultOrganizationAccess: - $ref: "#/components/schemas/Role" - defaultStackAccess: - $ref: "#/components/schemas/Role" - domain: - type: string - description: Organization domain - CreateOrganizationClientRequest: - type: object - properties: - name: - type: string - description: Name of the client - description: - type: string - description: Description of the client - UpdateOrganizationClientRequest: - type: object - required: - - name - properties: - name: - type: string - description: Name of the client - description: - type: string - description: Description of the client - CreateOrganizationClientResponse: - type: object - required: - - data - properties: - data: - $ref: "#/components/schemas/OrganizationClient" - ReadOrganizationClientResponse: - type: object - required: - - data - properties: - data: - $ref: "#/components/schemas/OrganizationClient" - ReadOrganizationClientsResponse: - type: object - required: - - data - properties: - data: - allOf: - - $ref: "#/components/schemas/Cursor" - - type: object - required: - - data - properties: - data: - type: array - items: - $ref: "#/components/schemas/OrganizationClient" - OrganizationClient: - type: object - required: - - id - - secret - - createdAt - - updatedAt - - description - - name - properties: - id: - type: string - description: Organization ID - secret: - type: object - required: - - lastDigits - properties: - lastDigits: - type: string - clear: - type: string - name: - type: string - description: Name of the client - description: - type: string - description: Description of the client - createdAt: - type: string - format: date-time - updatedAt: - type: string - format: date-time - Organization: - allOf: - - $ref: "#/components/schemas/OrganizationData" - - type: object - required: - - id - - ownerId - properties: - id: - type: string - description: Organization ID - ownerId: - type: string - description: Owner ID - availableStacks: - type: integer - description: Number of available stacks - availableSandboxes: - type: integer - description: Number of available sandboxes - createdAt: - type: string - format: date-time - updatedAt: - type: string - format: date-time - StackData: - type: object - required: - - name - properties: - name: - type: string - description: Stack name - metadata: - type: object - additionalProperties: - type: string - StackVersion: - type: object - properties: - version: - type: string - description: Supported only with agent version >= v0.7.0 - StackLifeCycle: - type: object - required: - - status - - state - - expectedStatus - - lastStateUpdate - - lastExpectedStatusUpdate - - lastStatusUpdate - properties: - status: - type: string - enum: - - UNKNOWN - - PROGRESSING - - READY - - DISABLED - - DELETED - state: - type: string - enum: - - ACTIVE - - DISABLED - - DELETED - expectedStatus: - type: string - enum: - - READY - - DISABLED - - DELETED - lastStateUpdate: - type: string - format: date-time - lastExpectedStatusUpdate: - type: string - format: date-time - lastStatusUpdate: - type: string - format: date-time - warnedAt: - type: string - format: date-time - disposableSince: - type: string - format: date-time - - StackReachability: - properties: - reachable: - description: Stack is reachable through Stargate - type: boolean - lastReachableUpdate: - description: Last time the stack was reachable - format: date-time - type: string - required: - - reachable - type: object - Stack: - allOf: - - $ref: "#/components/schemas/StackData" - - $ref: "#/components/schemas/StackVersion" - - $ref: "#/components/schemas/StackLifeCycle" - - $ref: "#/components/schemas/StackReachability" - - type: object - required: - - id - - organizationId - - uri - - regionID - - stargateEnabled - - synchronised - - modules - properties: - id: - type: string - description: Stack ID - organizationId: - type: string - description: Organization ID - uri: - type: string - description: Base stack uri - regionID: - type: string - description: The region where the stack is installed - region: - $ref: "#/components/schemas/Region" - stargateEnabled: - type: boolean - createdAt: - type: string - format: date-time - deletedAt: - type: string - format: date-time - disabledAt: - type: string - format: date-time - auditEnabled: - type: boolean - synchronised: - type: boolean - updatedAt: - type: string - format: date-time - modules: - type: array - items: - $ref: "#/components/schemas/Module" - - UserData: - allOf: - - type: object - properties: - email: - type: string - required: - - email - Role: - type: string - enum: - - NONE - - ADMIN - - GUEST - SystemRole: - type: string - enum: - - USER - - SYSTEM - User: - allOf: - - $ref: "#/components/schemas/UserData" - - type: object - required: - - id - properties: - id: - type: string - description: User ID - - type: object - properties: - role: - $ref: "#/components/schemas/SystemRole" - OrganizationUserArray: - type: array - items: - allOf: - - $ref: "#/components/schemas/OrganizationUser" - ReadOrganizationUserResponse: - type: object - properties: - data: - $ref: "#/components/schemas/OrganizationUser" - OrganizationUser: - allOf: - - type: object - required: - - role - - email - - id - properties: - role: - $ref: "#/components/schemas/Role" - email: - type: string - id: - type: string - - OrganizationArray: - type: array - items: - $ref: "#/components/schemas/Organization" - StackArray: - type: array - items: - $ref: "#/components/schemas/Stack" - UserArray: - type: array - items: - $ref: "#/components/schemas/User" - ReadStackUserAccess: - type: object - properties: - data: - $ref: "#/components/schemas/StackUserAccess" - StackUserAccess: - allOf: - - type: object - required: - - stackId - - userId - - email - - role - properties: - stackId: - type: string - description: Stack ID - userId: - type: string - description: User ID - email: - type: string - description: User email - role: - $ref: "#/components/schemas/Role" - StackUserAccessResponse: - type: object - properties: - data: - $ref: "#/components/schemas/StackUserAccessArray" - StackUserAccessArray: - type: array - items: - $ref: "#/components/schemas/StackUserAccess" - ListOrganizationResponse: - type: object - properties: - data: - $ref: "#/components/schemas/OrganizationArray" - CreateOrganizationRequest: - $ref: "#/components/schemas/OrganizationData" - CreateOrganizationResponse: - type: object - properties: - data: - $ref: "#/components/schemas/OrganizationExpanded" - ReadOrganizationResponse: - type: object - properties: - data: - $ref: "#/components/schemas/OrganizationExpanded" - ListStacksResponse: - type: object - properties: - data: - $ref: "#/components/schemas/StackArray" - ListUsersResponse: - type: object - properties: - data: - $ref: "#/components/schemas/OrganizationUserArray" - CreateStackRequest: - allOf: - - $ref: "#/components/schemas/StackData" - - $ref: "#/components/schemas/StackVersion" - - type: object - properties: - regionID: - type: string - required: - - regionID - UpdateStackRequest: - allOf: - - $ref: "#/components/schemas/StackData" - CreateStackResponse: - type: object - properties: - data: - $ref: "#/components/schemas/Stack" - ReadStackResponse: - $ref: "#/components/schemas/CreateStackResponse" - ReadUserResponse: - type: object - properties: - data: - $ref: "#/components/schemas/User" - ListInvitationsResponse: - type: object - properties: - data: - type: array - items: - $ref: "#/components/schemas/Invitation" - CreateInvitationResponse: - type: object - properties: - data: - $ref: "#/components/schemas/Invitation" - Error: - type: object - properties: - errorCode: - type: string - errorMessage: - type: string - required: - - errorCode - Invitation: - type: object - properties: - id: - type: string - organizationId: - type: string - userEmail: - type: string - status: - type: string - enum: - - PENDING - - ACCEPTED - - REJECTED - - CANCELLED - creationDate: - type: string - format: date-time - updatedAt: - type: string - format: date-tim - role: - $ref: "#/components/schemas/Role" - userId: - type: string - organizationAccess: - $ref: "#/components/schemas/OrganizationUser" - expiresAt: - type: string - format: date-time - creatorId: - type: string - lastUpdate: - type: string - format: date-time - required: - - creationDate - - status - - role - - creatorID - - userEmail - - organizationId - - id - InvitationClaim: - type: object - properties: - role: - $ref: "#/components/schemas/Role" - Region: - type: object - required: - - id - - baseUrl - - active - - createdAt - - name - - capabilities - - agentID - - outdated - properties: - id: - type: string - baseUrl: - type: string - createdAt: - type: string - format: datetime - active: - type: boolean - lastPing: - type: string - format: date-time - name: - type: string - capabilities: - $ref: "#/components/schemas/RegionCapability" - agentID: - type: string - outdated: - type: boolean - creatorId: - type: string - version: - type: string - - RegionCapability: - type: object - properties: - MODULE_LIST: - type: array - items: - type: string - EE: - type: array - items: - type: string - RegionCapabilityKeys: - type: string - enum: - - MODULE_LIST - - EE - ListOrganizationExpandedResponse: - type: object - properties: - data: - type: array - items: - allOf: - - $ref: "#/components/schemas/OrganizationExpanded" - CreateClientResponseResponse: - type: object - properties: - data: - allOf: - - $ref: "#/components/schemas/OrganizationClient" - - type: object - properties: - ownerId: - type: string - description: The ID of the owner of the client (DEPRECATED will be empty) - required: - - ownerId - OrganizationExpanded: - allOf: - - $ref: "#/components/schemas/Organization" - - type: object - properties: - totalStacks: - type: integer - totalUsers: - type: integer - owner: - $ref: "#/components/schemas/User" - ListRegionsResponse: - type: object - properties: - data: - type: array - items: - $ref: "#/components/schemas/AnyRegion" - required: - - data - GetRegionResponse: - type: object - properties: - data: - $ref: "#/components/schemas/AnyRegion" - required: - - data - - ServerInfo: - type: object - required: - - version - properties: - version: - type: string - capabilities: - type: array - items: - allOf: - - $ref: "#/components/schemas/Capability" - consoleURL: - type: string - Capability: - type: string - enum: - - MODULE_SELECTION - Version: - type: object - required: - - name - - versions - - regionID - properties: - name: - type: string - versions: - type: object - additionalProperties: - type: string - regionID: - type: string - UpdateOrganizationUserRequest: - type: object - required: - - role - properties: - role: - $ref: "#/components/schemas/Role" - UpdateStackUserRequest: - type: object - required: - - role - properties: - role: - $ref: "#/components/schemas/Role" - - GetRegionVersionsResponse: - type: object - properties: - data: - type: array - items: - $ref: "#/components/schemas/Version" - required: - - data - - AuthenticationProviderData: - type: object - oneOf: - - $ref: '#/components/schemas/GoogleIDPConfig' - - $ref: '#/components/schemas/MicrosoftIDPConfig' - - $ref: '#/components/schemas/GithubIDPConfig' - - $ref: '#/components/schemas/OIDCConfig' - - BaseProviderConfig: - type: object - required: - - type - - name - - clientID - - clientSecret - properties: - type: - type: string - enum: - - oidc - - google - - github - - microsoft - description: Type of the authentication provider - name: - type: string - description: Name of the authentication provider - clientID: - type: string - description: Client ID for the authentication provider - clientSecret: - type: string - description: Client secret for the authentication provider - - AuthenticationProvider: - type: object - allOf: - - $ref: '#/components/schemas/AuthenticationProviderData' - - type: object - properties: - organizationId: - type: string - description: Unique identifier for the authentication provider - createdAt: - type: string - format: date-time - description: Creation date of the authentication provider - updatedAt: - type: string - format: date-time - description: Last update date of the authentication provider - required: - - organizationId - - createdAt - - updatedAt - - GoogleIDPConfig: - allOf: - - $ref: '#/components/schemas/BaseProviderConfig' - - type: object - required: - - config - properties: - config: - type: object - additionalProperties: false - - MicrosoftIDPConfig: - allOf: - - $ref: '#/components/schemas/BaseProviderConfig' - - type: object - required: - - config - properties: - config: - type: object - properties: - tenant: - type: string - description: Tenant ID for Microsoft authentication - default: 'common' - - GithubIDPConfig: - allOf: - - $ref: '#/components/schemas/BaseProviderConfig' - - type: object - required: - - config - properties: - config: - type: object - additionalProperties: false - - OIDCConfig: - allOf: - - $ref: '#/components/schemas/BaseProviderConfig' - - type: object - required: - - config - properties: - config: - type: object - required: - - issuer - properties: - issuer: - type: string - description: OIDC issuer URL - discoveryPath: - type: string - default: '/.well-known/openid-configuration' - - UpsertAuthenticationProviderRequest: - $ref: "#/components/schemas/AuthenticationProviderData" - - AuthenticationProviderResponse: - type: object - properties: - data: - allOf: - - $ref: "#/components/schemas/AuthenticationProvider" - - type: object - properties: - redirectURI: - type: string - required: - - redirectURI diff --git a/membershipclient/.gitignore b/membershipclient/.gitignore deleted file mode 100644 index daf913b1..00000000 --- a/membershipclient/.gitignore +++ /dev/null @@ -1,24 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test -*.prof diff --git a/membershipclient/.openapi-generator-ignore b/membershipclient/.openapi-generator-ignore deleted file mode 100644 index 7484ee59..00000000 --- a/membershipclient/.openapi-generator-ignore +++ /dev/null @@ -1,23 +0,0 @@ -# OpenAPI Generator Ignore -# Generated by openapi-generator https://github.com/openapitools/openapi-generator - -# Use this file to prevent files from being overwritten by the generator. -# The patterns follow closely to .gitignore or .dockerignore. - -# As an example, the C# client generator defines ApiClient.cs. -# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line: -#ApiClient.cs - -# You can match any string of characters against a directory, file or extension with a single asterisk (*): -#foo/*/qux -# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux - -# You can recursively match patterns against a directory, file or extension with a double asterisk (**): -#foo/**/qux -# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux - -# You can also negate patterns with an exclamation (!). -# For example, you can ignore all files in a docs folder with the file extension .md: -#docs/*.md -# Then explicitly reverse the ignore rule for a single file: -#!docs/README.md diff --git a/membershipclient/.openapi-generator/FILES b/membershipclient/.openapi-generator/FILES deleted file mode 100644 index 2d35bd96..00000000 --- a/membershipclient/.openapi-generator/FILES +++ /dev/null @@ -1,174 +0,0 @@ -.gitignore -.travis.yml -README.md -api/openapi.yaml -api_default.go -client.go -configuration.go -docs/Action.md -docs/AddFeaturesRequest.md -docs/AnyRegion.md -docs/AuthenticationProvider.md -docs/AuthenticationProviderData.md -docs/AuthenticationProviderResponse.md -docs/AuthenticationProviderResponseData.md -docs/BaseProviderConfig.md -docs/Capability.md -docs/CreateClientResponseResponse.md -docs/CreateClientResponseResponseData.md -docs/CreateInvitationResponse.md -docs/CreateOrganizationClientRequest.md -docs/CreateOrganizationClientResponse.md -docs/CreateOrganizationResponse.md -docs/CreatePrivateRegionRequest.md -docs/CreateStackRequest.md -docs/CreateStackResponse.md -docs/CreatedPrivateRegionResponse.md -docs/Cursor.md -docs/DefaultAPI.md -docs/Error.md -docs/GetRegionResponse.md -docs/GetRegionVersionsResponse.md -docs/GithubIDPConfig.md -docs/GoogleIDPConfig.md -docs/Invitation.md -docs/InvitationClaim.md -docs/ListFeatures200Response.md -docs/ListInvitationsResponse.md -docs/ListModulesResponse.md -docs/ListOrganizationExpandedResponse.md -docs/ListOrganizationResponse.md -docs/ListRegionsResponse.md -docs/ListStacksResponse.md -docs/ListUsersResponse.md -docs/Log.md -docs/LogCursor.md -docs/LogCursorData.md -docs/MicrosoftIDPConfig.md -docs/MicrosoftIDPConfigAllOfConfig.md -docs/Module.md -docs/OIDCConfig.md -docs/OIDCConfigAllOfConfig.md -docs/Organization.md -docs/OrganizationClient.md -docs/OrganizationClientSecret.md -docs/OrganizationData.md -docs/OrganizationExpanded.md -docs/OrganizationFeature.md -docs/OrganizationUser.md -docs/PrivateRegion.md -docs/PrivateRegionSecret.md -docs/PublicRegion.md -docs/ReadOrganizationClientResponse.md -docs/ReadOrganizationClientsResponse.md -docs/ReadOrganizationClientsResponseData.md -docs/ReadOrganizationResponse.md -docs/ReadOrganizationUserResponse.md -docs/ReadStackUserAccess.md -docs/ReadUserResponse.md -docs/Region.md -docs/RegionCapability.md -docs/RegionCapabilityKeys.md -docs/Role.md -docs/ServerInfo.md -docs/Stack.md -docs/StackData.md -docs/StackLifeCycle.md -docs/StackReachability.md -docs/StackUserAccess.md -docs/StackUserAccessResponse.md -docs/StackVersion.md -docs/SystemRole.md -docs/UpdateOrganizationClientRequest.md -docs/UpdateOrganizationUserRequest.md -docs/UpdateStackRequest.md -docs/UpdateStackUserRequest.md -docs/User.md -docs/UserData.md -docs/Version.md -git_push.sh -go.mod -go.sum -model_action.go -model_add_features_request.go -model_any_region.go -model_authentication_provider.go -model_authentication_provider_data.go -model_authentication_provider_response.go -model_authentication_provider_response_data.go -model_base_provider_config.go -model_capability.go -model_create_client_response_response.go -model_create_client_response_response_data.go -model_create_invitation_response.go -model_create_organization_client_request.go -model_create_organization_client_response.go -model_create_organization_response.go -model_create_private_region_request.go -model_create_stack_request.go -model_create_stack_response.go -model_created_private_region_response.go -model_cursor.go -model_error.go -model_get_region_response.go -model_get_region_versions_response.go -model_github_idp_config.go -model_google_idp_config.go -model_invitation.go -model_invitation_claim.go -model_list_features_200_response.go -model_list_invitations_response.go -model_list_modules_response.go -model_list_organization_expanded_response.go -model_list_organization_response.go -model_list_regions_response.go -model_list_stacks_response.go -model_list_users_response.go -model_log.go -model_log_cursor.go -model_log_cursor_data.go -model_microsoft_idp_config.go -model_microsoft_idp_config_all_of_config.go -model_module.go -model_oidc_config.go -model_oidc_config_all_of_config.go -model_organization.go -model_organization_client.go -model_organization_client_secret.go -model_organization_data.go -model_organization_expanded.go -model_organization_feature.go -model_organization_user.go -model_private_region.go -model_private_region_secret.go -model_public_region.go -model_read_organization_client_response.go -model_read_organization_clients_response.go -model_read_organization_clients_response_data.go -model_read_organization_response.go -model_read_organization_user_response.go -model_read_stack_user_access.go -model_read_user_response.go -model_region.go -model_region_capability.go -model_region_capability_keys.go -model_role.go -model_server_info.go -model_stack.go -model_stack_data.go -model_stack_life_cycle.go -model_stack_reachability.go -model_stack_user_access.go -model_stack_user_access_response.go -model_stack_version.go -model_system_role.go -model_update_organization_client_request.go -model_update_organization_user_request.go -model_update_stack_request.go -model_update_stack_user_request.go -model_user.go -model_user_data.go -model_version.go -response.go -test/api_default_test.go -utils.go diff --git a/membershipclient/.openapi-generator/VERSION b/membershipclient/.openapi-generator/VERSION deleted file mode 100644 index 971ecb25..00000000 --- a/membershipclient/.openapi-generator/VERSION +++ /dev/null @@ -1 +0,0 @@ -7.16.0 diff --git a/membershipclient/.travis.yml b/membershipclient/.travis.yml deleted file mode 100644 index f5cb2ce9..00000000 --- a/membershipclient/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -language: go - -install: - - go get -d -v . - -script: - - go build -v ./ - diff --git a/membershipclient/README.md b/membershipclient/README.md deleted file mode 100644 index d95efcd0..00000000 --- a/membershipclient/README.md +++ /dev/null @@ -1,277 +0,0 @@ -# Go API client for membershipclient - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -## Overview -This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [OpenAPI-spec](https://www.openapis.org/) from a remote server, you can easily generate an API client. - -- API version: 0.1.0 -- Package version: latest -- Generator version: 7.16.0 -- Build package: org.openapitools.codegen.languages.GoClientCodegen - -## Installation - -Install the following dependencies: - -```sh -go get github.com/stretchr/testify/assert -go get golang.org/x/oauth2 -go get golang.org/x/net/context -``` - -Put the package under your project folder and add the following in import: - -```go -import membershipclient "github.com/formancehq/fctl/membershipclient" -``` - -To use a proxy, set the environment variable `HTTP_PROXY`: - -```go -os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port") -``` - -## Configuration of Server URL - -Default configuration comes with `Servers` field that contains server objects as defined in the OpenAPI specification. - -### Select Server Configuration - -For using other server than the one defined on index 0 set context value `membershipclient.ContextServerIndex` of type `int`. - -```go -ctx := context.WithValue(context.Background(), membershipclient.ContextServerIndex, 1) -``` - -### Templated Server URL - -Templated server URL is formatted using default variables from configuration or from context value `membershipclient.ContextServerVariables` of type `map[string]string`. - -```go -ctx := context.WithValue(context.Background(), membershipclient.ContextServerVariables, map[string]string{ - "basePath": "v2", -}) -``` - -Note, enum values are always validated and all unused variables are silently ignored. - -### URLs Configuration per Operation - -Each operation can use different server URL defined using `OperationServers` map in the `Configuration`. -An operation is uniquely identified by `"{classname}Service.{nickname}"` string. -Similar rules for overriding default operation server index and variables applies by using `membershipclient.ContextOperationServerIndices` and `membershipclient.ContextOperationServerVariables` context maps. - -```go -ctx := context.WithValue(context.Background(), membershipclient.ContextOperationServerIndices, map[string]int{ - "{classname}Service.{nickname}": 2, -}) -ctx = context.WithValue(context.Background(), membershipclient.ContextOperationServerVariables, map[string]map[string]string{ - "{classname}Service.{nickname}": { - "port": "8443", - }, -}) -``` - -## Documentation for API Endpoints - -All URIs are relative to *http://localhost:8080* - -Class | Method | HTTP request | Description ------------- | ------------- | ------------- | ------------- -*DefaultAPI* | [**AcceptInvitation**](docs/DefaultAPI.md#acceptinvitation) | **Post** /me/invitations/{invitationId}/accept | Accept invitation -*DefaultAPI* | [**AddFeatures**](docs/DefaultAPI.md#addfeatures) | **Post** /organizations/{organizationId}/features | Add Features -*DefaultAPI* | [**CreateInvitation**](docs/DefaultAPI.md#createinvitation) | **Post** /organizations/{organizationId}/invitations | Create invitation -*DefaultAPI* | [**CreateOrganization**](docs/DefaultAPI.md#createorganization) | **Post** /organizations | Create organization -*DefaultAPI* | [**CreateOrganizationClient**](docs/DefaultAPI.md#createorganizationclient) | **Put** /organizations/{organizationId}/client | Create organization client (DEPRECATED) (until 12/31/2025) -*DefaultAPI* | [**CreatePrivateRegion**](docs/DefaultAPI.md#createprivateregion) | **Post** /organizations/{organizationId}/regions | Create a private region -*DefaultAPI* | [**CreateStack**](docs/DefaultAPI.md#createstack) | **Post** /organizations/{organizationId}/stacks | Create stack -*DefaultAPI* | [**DeclineInvitation**](docs/DefaultAPI.md#declineinvitation) | **Post** /me/invitations/{invitationId}/reject | Decline invitation -*DefaultAPI* | [**DeleteAuthenticationProvider**](docs/DefaultAPI.md#deleteauthenticationprovider) | **Delete** /organizations/{organizationId}/authentication-provider | Delete authentication provider -*DefaultAPI* | [**DeleteFeature**](docs/DefaultAPI.md#deletefeature) | **Delete** /organizations/{organizationId}/features/{name} | Delete feature -*DefaultAPI* | [**DeleteInvitation**](docs/DefaultAPI.md#deleteinvitation) | **Delete** /organizations/{organizationId}/invitations/{invitationId} | Delete invitation -*DefaultAPI* | [**DeleteOrganization**](docs/DefaultAPI.md#deleteorganization) | **Delete** /organizations/{organizationId} | Delete organization -*DefaultAPI* | [**DeleteOrganizationClient**](docs/DefaultAPI.md#deleteorganizationclient) | **Delete** /organizations/{organizationId}/client | Delete organization client (DEPRECATED) (until 12/31/2025) -*DefaultAPI* | [**DeleteRegion**](docs/DefaultAPI.md#deleteregion) | **Delete** /organizations/{organizationId}/regions/{regionID} | Delete region -*DefaultAPI* | [**DeleteStack**](docs/DefaultAPI.md#deletestack) | **Delete** /organizations/{organizationId}/stacks/{stackId} | Delete stack -*DefaultAPI* | [**DeleteStackUserAccess**](docs/DefaultAPI.md#deletestackuseraccess) | **Delete** /organizations/{organizationId}/stacks/{stackId}/users/{userId} | Delete stack user access role within an organization -*DefaultAPI* | [**DeleteUserFromOrganization**](docs/DefaultAPI.md#deleteuserfromorganization) | **Delete** /organizations/{organizationId}/users/{userId} | delete user from organization -*DefaultAPI* | [**DisableModule**](docs/DefaultAPI.md#disablemodule) | **Delete** /organizations/{organizationId}/stacks/{stackId}/modules | disable module -*DefaultAPI* | [**DisableStack**](docs/DefaultAPI.md#disablestack) | **Put** /organizations/{organizationId}/stacks/{stackId}/disable | Disable stack -*DefaultAPI* | [**DisableStargate**](docs/DefaultAPI.md#disablestargate) | **Put** /organizations/{organizationId}/stacks/{stackId}/stargate/disable | Disable stargate on a stack -*DefaultAPI* | [**EnableModule**](docs/DefaultAPI.md#enablemodule) | **Post** /organizations/{organizationId}/stacks/{stackId}/modules | enable module -*DefaultAPI* | [**EnableStack**](docs/DefaultAPI.md#enablestack) | **Put** /organizations/{organizationId}/stacks/{stackId}/enable | Enable stack -*DefaultAPI* | [**EnableStargate**](docs/DefaultAPI.md#enablestargate) | **Put** /organizations/{organizationId}/stacks/{stackId}/stargate/enable | Enable stargate on a stack -*DefaultAPI* | [**GetRegion**](docs/DefaultAPI.md#getregion) | **Get** /organizations/{organizationId}/regions/{regionID} | Get region -*DefaultAPI* | [**GetRegionVersions**](docs/DefaultAPI.md#getregionversions) | **Get** /organizations/{organizationId}/regions/{regionID}/versions | Get region versions -*DefaultAPI* | [**GetServerInfo**](docs/DefaultAPI.md#getserverinfo) | **Get** /_info | Get server info -*DefaultAPI* | [**GetStack**](docs/DefaultAPI.md#getstack) | **Get** /organizations/{organizationId}/stacks/{stackId} | Find stack -*DefaultAPI* | [**ListFeatures**](docs/DefaultAPI.md#listfeatures) | **Get** /organizations/{organizationId}/features | List features -*DefaultAPI* | [**ListInvitations**](docs/DefaultAPI.md#listinvitations) | **Get** /me/invitations | List invitations of the user -*DefaultAPI* | [**ListLogs**](docs/DefaultAPI.md#listlogs) | **Get** /organizations/{organizationId}/logs | List logs -*DefaultAPI* | [**ListModules**](docs/DefaultAPI.md#listmodules) | **Get** /organizations/{organizationId}/stacks/{stackId}/modules | List modules of a stack -*DefaultAPI* | [**ListOrganizationInvitations**](docs/DefaultAPI.md#listorganizationinvitations) | **Get** /organizations/{organizationId}/invitations | List invitations of the organization -*DefaultAPI* | [**ListOrganizations**](docs/DefaultAPI.md#listorganizations) | **Get** /organizations | List organizations of the connected user -*DefaultAPI* | [**ListOrganizationsExpanded**](docs/DefaultAPI.md#listorganizationsexpanded) | **Get** /organizations/expanded | List organizations of the connected user with expanded data -*DefaultAPI* | [**ListRegions**](docs/DefaultAPI.md#listregions) | **Get** /organizations/{organizationId}/regions | List regions -*DefaultAPI* | [**ListStackUsersAccesses**](docs/DefaultAPI.md#liststackusersaccesses) | **Get** /organizations/{organizationId}/stacks/{stackId}/users | List stack users accesses within an organization -*DefaultAPI* | [**ListStacks**](docs/DefaultAPI.md#liststacks) | **Get** /organizations/{organizationId}/stacks | List stacks -*DefaultAPI* | [**ListUsersOfOrganization**](docs/DefaultAPI.md#listusersoforganization) | **Get** /organizations/{organizationId}/users | List users of organization -*DefaultAPI* | [**OrganizationClientCreate**](docs/DefaultAPI.md#organizationclientcreate) | **Post** /organizations/{organizationId}/clients | Create organization client -*DefaultAPI* | [**OrganizationClientDelete**](docs/DefaultAPI.md#organizationclientdelete) | **Delete** /organizations/{organizationId}/clients/{clientId} | Delete organization client -*DefaultAPI* | [**OrganizationClientRead**](docs/DefaultAPI.md#organizationclientread) | **Get** /organizations/{organizationId}/clients/{clientId} | Read organization client -*DefaultAPI* | [**OrganizationClientUpdate**](docs/DefaultAPI.md#organizationclientupdate) | **Put** /organizations/{organizationId}/clients/{clientId} | Update organization client -*DefaultAPI* | [**OrganizationClientsRead**](docs/DefaultAPI.md#organizationclientsread) | **Get** /organizations/{organizationId}/clients | Read organization clients -*DefaultAPI* | [**ReadAuthenticationProvider**](docs/DefaultAPI.md#readauthenticationprovider) | **Get** /organizations/{organizationId}/authentication-provider | Read authentication provider -*DefaultAPI* | [**ReadConnectedUser**](docs/DefaultAPI.md#readconnecteduser) | **Get** /me | Read user -*DefaultAPI* | [**ReadOrganization**](docs/DefaultAPI.md#readorganization) | **Get** /organizations/{organizationId} | Read organization -*DefaultAPI* | [**ReadOrganizationClient**](docs/DefaultAPI.md#readorganizationclient) | **Get** /organizations/{organizationId}/client | Read organization client (DEPRECATED) (until 12/31/2025) -*DefaultAPI* | [**ReadStackUserAccess**](docs/DefaultAPI.md#readstackuseraccess) | **Get** /organizations/{organizationId}/stacks/{stackId}/users/{userId} | Read stack user access role within an organization -*DefaultAPI* | [**ReadUserOfOrganization**](docs/DefaultAPI.md#readuseroforganization) | **Get** /organizations/{organizationId}/users/{userId} | Read user of organization -*DefaultAPI* | [**RestoreStack**](docs/DefaultAPI.md#restorestack) | **Put** /organizations/{organizationId}/stacks/{stackId}/restore | Restore stack -*DefaultAPI* | [**UpdateOrganization**](docs/DefaultAPI.md#updateorganization) | **Put** /organizations/{organizationId} | Update organization -*DefaultAPI* | [**UpdateStack**](docs/DefaultAPI.md#updatestack) | **Put** /organizations/{organizationId}/stacks/{stackId} | Update stack -*DefaultAPI* | [**UpgradeStack**](docs/DefaultAPI.md#upgradestack) | **Put** /organizations/{organizationId}/stacks/{stackId}/upgrade | Upgrade stack -*DefaultAPI* | [**UpsertAuthenticationProvider**](docs/DefaultAPI.md#upsertauthenticationprovider) | **Put** /organizations/{organizationId}/authentication-provider | Upsert an authentication provider -*DefaultAPI* | [**UpsertOrganizationUser**](docs/DefaultAPI.md#upsertorganizationuser) | **Put** /organizations/{organizationId}/users/{userId} | Update user within an organization -*DefaultAPI* | [**UpsertStackUserAccess**](docs/DefaultAPI.md#upsertstackuseraccess) | **Put** /organizations/{organizationId}/stacks/{stackId}/users/{userId} | Update stack user access role within an organization - - -## Documentation For Models - - - [Action](docs/Action.md) - - [AddFeaturesRequest](docs/AddFeaturesRequest.md) - - [AnyRegion](docs/AnyRegion.md) - - [AuthenticationProvider](docs/AuthenticationProvider.md) - - [AuthenticationProviderData](docs/AuthenticationProviderData.md) - - [AuthenticationProviderResponse](docs/AuthenticationProviderResponse.md) - - [AuthenticationProviderResponseData](docs/AuthenticationProviderResponseData.md) - - [BaseProviderConfig](docs/BaseProviderConfig.md) - - [Capability](docs/Capability.md) - - [CreateClientResponseResponse](docs/CreateClientResponseResponse.md) - - [CreateClientResponseResponseData](docs/CreateClientResponseResponseData.md) - - [CreateInvitationResponse](docs/CreateInvitationResponse.md) - - [CreateOrganizationClientRequest](docs/CreateOrganizationClientRequest.md) - - [CreateOrganizationClientResponse](docs/CreateOrganizationClientResponse.md) - - [CreateOrganizationResponse](docs/CreateOrganizationResponse.md) - - [CreatePrivateRegionRequest](docs/CreatePrivateRegionRequest.md) - - [CreateStackRequest](docs/CreateStackRequest.md) - - [CreateStackResponse](docs/CreateStackResponse.md) - - [CreatedPrivateRegionResponse](docs/CreatedPrivateRegionResponse.md) - - [Cursor](docs/Cursor.md) - - [Error](docs/Error.md) - - [GetRegionResponse](docs/GetRegionResponse.md) - - [GetRegionVersionsResponse](docs/GetRegionVersionsResponse.md) - - [GithubIDPConfig](docs/GithubIDPConfig.md) - - [GoogleIDPConfig](docs/GoogleIDPConfig.md) - - [Invitation](docs/Invitation.md) - - [InvitationClaim](docs/InvitationClaim.md) - - [ListFeatures200Response](docs/ListFeatures200Response.md) - - [ListInvitationsResponse](docs/ListInvitationsResponse.md) - - [ListModulesResponse](docs/ListModulesResponse.md) - - [ListOrganizationExpandedResponse](docs/ListOrganizationExpandedResponse.md) - - [ListOrganizationResponse](docs/ListOrganizationResponse.md) - - [ListRegionsResponse](docs/ListRegionsResponse.md) - - [ListStacksResponse](docs/ListStacksResponse.md) - - [ListUsersResponse](docs/ListUsersResponse.md) - - [Log](docs/Log.md) - - [LogCursor](docs/LogCursor.md) - - [LogCursorData](docs/LogCursorData.md) - - [MicrosoftIDPConfig](docs/MicrosoftIDPConfig.md) - - [MicrosoftIDPConfigAllOfConfig](docs/MicrosoftIDPConfigAllOfConfig.md) - - [Module](docs/Module.md) - - [OIDCConfig](docs/OIDCConfig.md) - - [OIDCConfigAllOfConfig](docs/OIDCConfigAllOfConfig.md) - - [Organization](docs/Organization.md) - - [OrganizationClient](docs/OrganizationClient.md) - - [OrganizationClientSecret](docs/OrganizationClientSecret.md) - - [OrganizationData](docs/OrganizationData.md) - - [OrganizationExpanded](docs/OrganizationExpanded.md) - - [OrganizationFeature](docs/OrganizationFeature.md) - - [OrganizationUser](docs/OrganizationUser.md) - - [PrivateRegion](docs/PrivateRegion.md) - - [PrivateRegionSecret](docs/PrivateRegionSecret.md) - - [PublicRegion](docs/PublicRegion.md) - - [ReadOrganizationClientResponse](docs/ReadOrganizationClientResponse.md) - - [ReadOrganizationClientsResponse](docs/ReadOrganizationClientsResponse.md) - - [ReadOrganizationClientsResponseData](docs/ReadOrganizationClientsResponseData.md) - - [ReadOrganizationResponse](docs/ReadOrganizationResponse.md) - - [ReadOrganizationUserResponse](docs/ReadOrganizationUserResponse.md) - - [ReadStackUserAccess](docs/ReadStackUserAccess.md) - - [ReadUserResponse](docs/ReadUserResponse.md) - - [Region](docs/Region.md) - - [RegionCapability](docs/RegionCapability.md) - - [RegionCapabilityKeys](docs/RegionCapabilityKeys.md) - - [Role](docs/Role.md) - - [ServerInfo](docs/ServerInfo.md) - - [Stack](docs/Stack.md) - - [StackData](docs/StackData.md) - - [StackLifeCycle](docs/StackLifeCycle.md) - - [StackReachability](docs/StackReachability.md) - - [StackUserAccess](docs/StackUserAccess.md) - - [StackUserAccessResponse](docs/StackUserAccessResponse.md) - - [StackVersion](docs/StackVersion.md) - - [SystemRole](docs/SystemRole.md) - - [UpdateOrganizationClientRequest](docs/UpdateOrganizationClientRequest.md) - - [UpdateOrganizationUserRequest](docs/UpdateOrganizationUserRequest.md) - - [UpdateStackRequest](docs/UpdateStackRequest.md) - - [UpdateStackUserRequest](docs/UpdateStackUserRequest.md) - - [User](docs/User.md) - - [UserData](docs/UserData.md) - - [Version](docs/Version.md) - - -## Documentation For Authorization - - -Authentication schemes defined for the API: -### oauth2 - - -- **Type**: OAuth -- **Flow**: accessCode -- **Authorization URL**: /authorize -- **Scopes**: - - **openid**: Enable OIDC - - **email**: Ask email access - -Example - -```go -auth := context.WithValue(context.Background(), membershipclient.ContextAccessToken, "ACCESSTOKENSTRING") -r, err := client.Service.Operation(auth, args) -``` - -Or via OAuth2 module to automatically refresh tokens and perform user authentication. - -```go -import "golang.org/x/oauth2" - -/* Perform OAuth2 round trip request and obtain a token */ - -tokenSource := oauth2cfg.TokenSource(createContext(httpClient), &token) -auth := context.WithValue(oauth2.NoContext, membershipclient.ContextOAuth2, tokenSource) -r, err := client.Service.Operation(auth, args) -``` - - -## Documentation for Utility Methods - -Due to the fact that model structure members are all pointers, this package contains -a number of utility functions to easily obtain pointers to values of basic types. -Each of these functions takes a value of the given basic type and returns a pointer to it: - -* `PtrBool` -* `PtrInt` -* `PtrInt32` -* `PtrInt64` -* `PtrFloat` -* `PtrFloat32` -* `PtrFloat64` -* `PtrString` -* `PtrTime` - -## Author - - - diff --git a/membershipclient/api/openapi.yaml b/membershipclient/api/openapi.yaml deleted file mode 100644 index 127b908f..00000000 --- a/membershipclient/api/openapi.yaml +++ /dev/null @@ -1,3540 +0,0 @@ -openapi: 3.0.3 -info: - contact: {} - title: Membership API - version: 0.1.0 -servers: -- description: Local server - url: http://localhost:8080 -security: -- oauth2: [] -paths: - /_info: - get: - operationId: getServerInfo - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/ServerInfo" - description: Server information - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Get server info - /organizations: - get: - operationId: listOrganizations - parameters: - - explode: true - in: query - name: expand - required: false - schema: - type: boolean - style: form - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/ListOrganizationExpandedResponse" - description: List of organizations - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: List organizations of the connected user - post: - operationId: createOrganization - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/CreateOrganizationRequest" - responses: - "201": - content: - application/json: - schema: - $ref: "#/components/schemas/CreateOrganizationResponse" - description: Organization created - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Create organization - /organizations/expanded: - get: - deprecated: true - operationId: listOrganizationsExpanded - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/ListOrganizationExpandedResponse" - description: List of organizations with expanded data - summary: List organizations of the connected user with expanded data - /organizations/{organizationId}: - delete: - operationId: deleteOrganization - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - responses: - "204": - description: Organization deleted - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Delete organization - get: - operationId: readOrganization - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: true - in: query - name: expand - required: false - schema: - type: boolean - style: form - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/ReadOrganizationResponse" - description: OK - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Read organization - put: - operationId: updateOrganization - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/OrganizationData" - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/ReadOrganizationResponse" - description: Organization updated - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Update organization - /organizations/{organizationId}/authentication-provider: - delete: - operationId: deleteAuthenticationProvider - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - responses: - "204": - description: Authentication provider deleted - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Delete authentication provider - get: - operationId: readAuthenticationProvider - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/AuthenticationProviderResponse" - description: Authentication provider details - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Read authentication provider - put: - operationId: upsertAuthenticationProvider - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/UpsertAuthenticationProviderRequest" - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/AuthenticationProviderResponse" - description: Authentication provider created or updated - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Upsert an authentication provider - /organizations/{organizationId}/features: - get: - operationId: listFeatures - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/listFeatures_200_response" - description: List of features - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: List features - post: - operationId: addFeatures - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/addFeatures_request" - responses: - "204": - description: Features added - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Add Features - /organizations/{organizationId}/features/{name}: - delete: - operationId: deleteFeature - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: name - required: true - schema: - type: string - style: simple - responses: - "204": - description: Feature deleted - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Delete feature - /organizations/{organizationId}/client: - delete: - deprecated: true - operationId: deleteOrganizationClient - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - responses: - "204": - description: Client deleted - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Delete organization client (DEPRECATED) (until 12/31/2025) - get: - deprecated: true - operationId: readOrganizationClient - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/CreateClientResponseResponse" - description: Organization client - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Read organization client (DEPRECATED) (until 12/31/2025) - put: - deprecated: true - operationId: createOrganizationClient - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - responses: - "201": - content: - application/json: - schema: - $ref: "#/components/schemas/CreateClientResponseResponse" - description: Client organization created - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Create organization client (DEPRECATED) (until 12/31/2025) - /organizations/{organizationId}/clients: - get: - operationId: organizationClientsRead - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: true - in: query - name: cursor - required: false - schema: - type: string - style: form - - explode: true - in: query - name: pageSize - required: false - schema: - minimum: 1 - type: integer - style: form - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/ReadOrganizationClientsResponse" - description: Organization client - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Read organization clients - post: - operationId: organizationClientCreate - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/CreateOrganizationClientRequest" - responses: - "201": - content: - application/json: - schema: - $ref: "#/components/schemas/CreateOrganizationClientResponse" - description: Organization client created - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Create organization client - /organizations/{organizationId}/clients/{clientId}: - delete: - operationId: organizationClientDelete - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: clientId - required: true - schema: - type: string - style: simple - responses: - "204": - description: Client deleted - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Delete organization client - get: - operationId: organizationClientRead - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: clientId - required: true - schema: - type: string - style: simple - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/ReadOrganizationClientResponse" - description: Organization client details - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Read organization client - put: - operationId: organizationClientUpdate - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: clientId - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/UpdateOrganizationClientRequest" - responses: - "204": - description: Client updated - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Update organization client - /organizations/{organizationId}/logs: - get: - operationId: listLogs - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: true - in: query - name: stackId - required: false - schema: - type: string - style: form - - explode: true - in: query - name: cursor - required: false - schema: - type: string - style: form - - explode: true - in: query - name: pageSize - required: false - schema: - minimum: 1 - type: integer - style: form - - explode: true - in: query - name: action - required: false - schema: - $ref: "#/components/schemas/Action" - style: form - - explode: true - in: query - name: userId - required: false - schema: - type: string - style: form - - explode: true - in: query - name: key - required: false - schema: - type: string - style: form - - explode: true - in: query - name: value - required: false - schema: - type: string - style: form - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/LogCursor" - description: Cursor of logs - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: List logs - /organizations/{organizationId}/users: - get: - operationId: listUsersOfOrganization - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/ListUsersResponse" - description: List of users - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: List users of organization - /organizations/{organizationId}/users/{userId}: - delete: - description: | - The owner of the organization can remove anyone while each user can leave any organization where it is not owner. - operationId: deleteUserFromOrganization - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: userId - required: true - schema: - type: string - style: simple - responses: - "204": - description: User deleted from organization - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: delete user from organization - get: - operationId: readUserOfOrganization - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: userId - required: true - schema: - type: string - style: simple - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/ReadOrganizationUserResponse" - description: Read a user - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Read user of organization - put: - operationId: upsertOrganizationUser - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: userId - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/UpdateOrganizationUserRequest" - responses: - "204": - description: Updated user - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Update user within an organization - /organizations/{organizationId}/stacks: - get: - operationId: listStacks - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - description: Include deleted and disabled stacks - explode: true - in: query - name: all - required: false - schema: - type: boolean - style: form - - deprecated: true - description: Include deleted stacks - explode: true - in: query - name: deleted - required: false - schema: - type: boolean - style: form - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/ListStacksResponse" - description: List of stacks - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: List stacks - post: - operationId: createStack - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/CreateStackRequest" - responses: - "202": - content: - application/json: - schema: - $ref: "#/components/schemas/CreateStackResponse" - description: Stack created - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Create stack - /organizations/{organizationId}/stacks/{stackId}/modules: - delete: - operationId: disableModule - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: stackId - required: true - schema: - type: string - style: simple - - explode: true - in: query - name: name - required: true - schema: - type: string - style: form - responses: - "202": - description: Module disabled - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: disable module - get: - operationId: listModules - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: stackId - required: true - schema: - type: string - style: simple - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/ListModulesResponse" - description: List of modules - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: List modules of a stack - post: - operationId: enableModule - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: stackId - required: true - schema: - type: string - style: simple - - explode: true - in: query - name: name - required: true - schema: - type: string - style: form - responses: - "202": - description: Module enabled - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: enable module - /organizations/{organizationId}/stacks/{stackId}/upgrade: - put: - operationId: upgradeStack - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: stackId - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/StackVersion" - responses: - "202": - description: Stack upgrade accepted - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Upgrade stack - /organizations/{organizationId}/stacks/{stackId}: - delete: - operationId: deleteStack - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: stackId - required: true - schema: - type: string - style: simple - - explode: true - in: query - name: force - required: false - schema: - type: boolean - style: form - responses: - "204": - description: Stack deleted - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Delete stack - get: - operationId: getStack - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: stackId - required: true - schema: - type: string - style: simple - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/ReadStackResponse" - description: OK - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Find stack - put: - operationId: updateStack - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: stackId - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/UpdateStackRequest" - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/ReadStackResponse" - description: Updated stack - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Update stack - /organizations/{organizationId}/stacks/{stackId}/users: - get: - operationId: listStackUsersAccesses - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: stackId - required: true - schema: - type: string - style: simple - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/StackUserAccessResponse" - description: Stack users access role - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: List stack users accesses within an organization - /organizations/{organizationId}/stacks/{stackId}/users/{userId}: - delete: - operationId: deleteStackUserAccess - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: stackId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: userId - required: true - schema: - type: string - style: simple - responses: - "204": - description: Updated user - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Delete stack user access role within an organization - get: - operationId: readStackUserAccess - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: stackId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: userId - required: true - schema: - type: string - style: simple - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/ReadStackUserAccess" - description: Stack user access role - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Read stack user access role within an organization - put: - operationId: upsertStackUserAccess - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: stackId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: userId - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/UpdateStackUserRequest" - responses: - "204": - description: Updated user - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Update stack user access role within an organization - /organizations/{organizationId}/stacks/{stackId}/disable: - put: - operationId: disableStack - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: stackId - required: true - schema: - type: string - style: simple - responses: - "202": - description: Stack disabled - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Disable stack - /organizations/{organizationId}/stacks/{stackId}/enable: - put: - operationId: enableStack - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: stackId - required: true - schema: - type: string - style: simple - responses: - "202": - description: Stack enabled - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Enable stack - /organizations/{organizationId}/stacks/{stackId}/restore: - put: - operationId: restoreStack - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: stackId - required: true - schema: - type: string - style: simple - responses: - "202": - content: - application/json: - schema: - $ref: "#/components/schemas/ReadStackResponse" - description: OK - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Restore stack - /organizations/{organizationId}/stacks/{stackId}/stargate/enable: - put: - operationId: enableStargate - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: stackId - required: true - schema: - type: string - style: simple - responses: - "202": - description: OK - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Enable stargate on a stack - /organizations/{organizationId}/stacks/{stackId}/stargate/disable: - put: - operationId: disableStargate - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: stackId - required: true - schema: - type: string - style: simple - responses: - "202": - description: OK - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Disable stargate on a stack - /me/invitations: - get: - operationId: listInvitations - parameters: - - description: Status of organizations - explode: true - in: query - name: status - required: false - schema: - type: string - style: form - - description: Status of organizations - explode: true - in: query - name: organization - required: false - schema: - type: string - style: form - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/ListInvitationsResponse" - description: List of the invitations for the connected user - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: List invitations of the user - /me/invitations/{invitationId}/accept: - post: - operationId: acceptInvitation - parameters: - - explode: false - in: path - name: invitationId - required: true - schema: - type: string - style: simple - responses: - "204": - description: Invitation accepted - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Accept invitation - /me/invitations/{invitationId}/reject: - post: - operationId: declineInvitation - parameters: - - explode: false - in: path - name: invitationId - required: true - schema: - type: string - style: simple - responses: - "204": - description: Invitation declined - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Decline invitation - /organizations/{organizationId}/invitations: - get: - operationId: listOrganizationInvitations - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - description: Status of organizations - explode: true - in: query - name: status - required: false - schema: - type: string - style: form - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/ListInvitationsResponse" - description: List of the invitations for the organization - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: List invitations of the organization - post: - operationId: createInvitation - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: true - in: query - name: email - required: true - schema: - type: string - style: form - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/InvitationClaim" - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/CreateInvitationResponse" - description: Invitation already sent - "201": - content: - application/json: - schema: - $ref: "#/components/schemas/CreateInvitationResponse" - description: Invitation created - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Create invitation - /organizations/{organizationId}/invitations/{invitationId}: - delete: - operationId: deleteInvitation - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: invitationId - required: true - schema: - type: string - style: simple - responses: - "204": - description: Invitation deleted - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Delete invitation - /organizations/{organizationId}/regions: - get: - operationId: listRegions - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/ListRegionsResponse" - description: List of the regions - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: List regions - post: - operationId: createPrivateRegion - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - requestBody: - content: - application/json: - schema: - $ref: "#/components/schemas/CreatePrivateRegionRequest" - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/CreatedPrivateRegionResponse" - description: Created region - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Create a private region - /organizations/{organizationId}/regions/{regionID}: - delete: - operationId: deleteRegion - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: regionID - required: true - schema: - type: string - style: simple - responses: - "204": - description: Delete a specific region - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Delete region - get: - operationId: getRegion - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: regionID - required: true - schema: - type: string - style: simple - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/GetRegionResponse" - description: Get a specific region - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Get region - /organizations/{organizationId}/regions/{regionID}/versions: - get: - operationId: getRegionVersions - parameters: - - explode: false - in: path - name: organizationId - required: true - schema: - type: string - style: simple - - explode: false - in: path - name: regionID - required: true - schema: - type: string - style: simple - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/GetRegionVersionsResponse" - description: Get a specific region - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Get region versions - /me: - get: - operationId: readConnectedUser - responses: - "200": - content: - application/json: - schema: - $ref: "#/components/schemas/ReadUserResponse" - description: Read a user - default: - content: - application/json: - schema: - $ref: "#/components/schemas/Error" - description: Error - summary: Read user -components: - schemas: - Module: - example: - lastStateUpdate: 2000-01-23T04:56:07.000+00:00 - name: name - lastStatusUpdate: 2000-01-23T04:56:07.000+00:00 - state: ENABLED - clusterStatus: "{}" - status: UNKNOWN - properties: - name: - type: string - state: - enum: - - ENABLED - - DISABLED - type: string - status: - enum: - - UNKNOWN - - PROGRESSING - - READY - - DELETED - type: string - lastStatusUpdate: - format: date-time - type: string - lastStateUpdate: - format: date-time - type: string - clusterStatus: - type: object - required: - - lastStateUpdate - - lastStatusUpdate - - name - - state - - status - type: object - ListModulesResponse: - example: - data: - - lastStateUpdate: 2000-01-23T04:56:07.000+00:00 - name: name - lastStatusUpdate: 2000-01-23T04:56:07.000+00:00 - state: ENABLED - clusterStatus: "{}" - status: UNKNOWN - - lastStateUpdate: 2000-01-23T04:56:07.000+00:00 - name: name - lastStatusUpdate: 2000-01-23T04:56:07.000+00:00 - state: ENABLED - clusterStatus: "{}" - status: UNKNOWN - properties: - data: - items: - $ref: "#/components/schemas/Module" - type: array - required: - - data - type: object - Action: - enum: - - agents.connected - - agents.disconnected - - invitations.created - - invitations.accepted - - invitations.rejected - - invitations.cancelled - - organizations.created - - organizations.updated - - organizations.deleted - - organizations.user.deleted - - organizations.user.updated - - regions.created - - regions.deleted - - users.created - - users.deleted - - stacks.disposal - - stacks.disposal-reset - - stacks.warned - - stacks.pruned - - stacks.status.updated - - stacks.created - - stacks.updated - - stacks.deleted - - stacks.restored - - stacks.disabled - - stacks.enabled - - stacks.upgraded - - stacks.stargate.enabled - - stacks.stargate.disabled - - stacks.user.updated - - stacks.user.deleted - - stacks.reachness.updated - - stacks.module.enabled - - stacks.module.disabled - - stacks.module.status.updated - type: string - LogCursor: - example: - data: - next: "" - previous: YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= - data: - - organizationId: organizationId - date: 2000-01-23T04:56:07.000+00:00 - data: "{}" - action: action - userId: userId - seq: 1e6f8b6e-1b6b-4b3b-8b3b-1b6b4b3b8b3b - - organizationId: organizationId - date: 2000-01-23T04:56:07.000+00:00 - data: "{}" - action: action - userId: userId - seq: 1e6f8b6e-1b6b-4b3b-8b3b-1b6b4b3b8b3b - hasMore: false - pageSize: 15 - properties: - data: - $ref: "#/components/schemas/LogCursor_data" - required: - - data - Log: - example: - organizationId: organizationId - date: 2000-01-23T04:56:07.000+00:00 - data: "{}" - action: action - userId: userId - seq: 1e6f8b6e-1b6b-4b3b-8b3b-1b6b4b3b8b3b - properties: - seq: - example: 1e6f8b6e-1b6b-4b3b-8b3b-1b6b4b3b8b3b - type: string - organizationId: - type: string - userId: - type: string - action: - type: string - date: - format: date-time - type: string - data: - type: object - required: - - action - - data - - date - - organizationId - - seq - - userId - type: object - Cursor: - properties: - pageSize: - example: 15 - format: int64 - maximum: 1000 - minimum: 1 - type: integer - hasMore: - example: false - type: boolean - previous: - example: YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= - type: string - next: - example: "" - type: string - required: - - data - - hasMore - - pageSize - type: object - OrganizationFeature: - example: - organizationID: organizationID - createdAt: 2000-01-23T04:56:07.000+00:00 - name: name - properties: - organizationID: - type: string - name: - type: string - createdAt: - format: date-time - type: string - required: - - createdAt - - name - - organizationID - type: object - CreatePrivateRegionRequest: - example: - name: name - properties: - name: - type: string - required: - - name - type: object - CreatedPrivateRegionResponse: - example: - data: - agentID: agentID - capabilities: - EE: - - EE - - EE - MODULE_LIST: - - MODULE_LIST - - MODULE_LIST - creatorId: creatorId - creatorID: creatorID - active: true - lastPing: 2000-01-23T04:56:07.000+00:00 - secret: - clear: clear - lastDigits: lastDigits - version: version - organizationID: organizationID - createdAt: createdAt - baseUrl: baseUrl - outdated: true - name: name - id: id - properties: - data: - $ref: "#/components/schemas/PrivateRegion" - required: - - data - PrivateRegion: - allOf: - - $ref: "#/components/schemas/Region" - - properties: - organizationID: - type: string - creatorID: - type: string - secret: - $ref: "#/components/schemas/PrivateRegionSecret" - required: - - creatorID - - organizationID - type: object - example: - agentID: agentID - capabilities: - EE: - - EE - - EE - MODULE_LIST: - - MODULE_LIST - - MODULE_LIST - creatorId: creatorId - creatorID: creatorID - active: true - lastPing: 2000-01-23T04:56:07.000+00:00 - secret: - clear: clear - lastDigits: lastDigits - version: version - organizationID: organizationID - createdAt: createdAt - baseUrl: baseUrl - outdated: true - name: name - id: id - PublicRegion: - allOf: - - $ref: "#/components/schemas/Region" - - properties: - production: - type: boolean - required: - - production - type: object - AnyRegion: - allOf: - - $ref: "#/components/schemas/Region" - - properties: - clientID: - type: string - organizationID: - type: string - creator: - $ref: "#/components/schemas/User" - production: - type: boolean - public: - type: boolean - version: - type: string - agentID: - type: string - outdated: - type: boolean - secret: - $ref: "#/components/schemas/PrivateRegionSecret" - required: - - agentID - - outdated - - public - type: object - example: - agentID: agentID - creator: - role: USER - id: id - email: email - capabilities: - EE: - - EE - - EE - MODULE_LIST: - - MODULE_LIST - - MODULE_LIST - clientID: clientID - production: true - creatorId: creatorId - active: true - lastPing: 2000-01-23T04:56:07.000+00:00 - secret: - clear: clear - lastDigits: lastDigits - version: version - organizationID: organizationID - createdAt: createdAt - baseUrl: baseUrl - outdated: true - public: true - name: name - id: id - PrivateRegionSecret: - example: - clear: clear - lastDigits: lastDigits - properties: - lastDigits: - type: string - clear: - type: string - required: - - lastDigits - type: object - OrganizationData: - example: - defaultOrganizationAccess: NONE - defaultStackAccess: null - domain: domain - name: name - properties: - name: - description: Organization name - type: string - defaultOrganizationAccess: - $ref: "#/components/schemas/Role" - defaultStackAccess: - $ref: "#/components/schemas/Role" - domain: - description: Organization domain - type: string - required: - - name - type: object - CreateOrganizationClientRequest: - example: - name: name - description: description - properties: - name: - description: Name of the client - type: string - description: - description: Description of the client - type: string - type: object - UpdateOrganizationClientRequest: - example: - name: name - description: description - properties: - name: - description: Name of the client - type: string - description: - description: Description of the client - type: string - required: - - name - type: object - CreateOrganizationClientResponse: - example: - data: - createdAt: 2000-01-23T04:56:07.000+00:00 - name: name - description: description - id: id - secret: - clear: clear - lastDigits: lastDigits - updatedAt: 2000-01-23T04:56:07.000+00:00 - properties: - data: - $ref: "#/components/schemas/OrganizationClient" - required: - - data - type: object - ReadOrganizationClientResponse: - example: - data: - createdAt: 2000-01-23T04:56:07.000+00:00 - name: name - description: description - id: id - secret: - clear: clear - lastDigits: lastDigits - updatedAt: 2000-01-23T04:56:07.000+00:00 - properties: - data: - $ref: "#/components/schemas/OrganizationClient" - required: - - data - type: object - ReadOrganizationClientsResponse: - example: - data: - next: "" - previous: YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= - data: - - createdAt: 2000-01-23T04:56:07.000+00:00 - name: name - description: description - id: id - secret: - clear: clear - lastDigits: lastDigits - updatedAt: 2000-01-23T04:56:07.000+00:00 - - createdAt: 2000-01-23T04:56:07.000+00:00 - name: name - description: description - id: id - secret: - clear: clear - lastDigits: lastDigits - updatedAt: 2000-01-23T04:56:07.000+00:00 - hasMore: false - pageSize: 15 - properties: - data: - $ref: "#/components/schemas/ReadOrganizationClientsResponse_data" - required: - - data - type: object - OrganizationClient: - example: - createdAt: 2000-01-23T04:56:07.000+00:00 - name: name - description: description - id: id - secret: - clear: clear - lastDigits: lastDigits - updatedAt: 2000-01-23T04:56:07.000+00:00 - properties: - id: - description: Organization ID - type: string - secret: - $ref: "#/components/schemas/OrganizationClient_secret" - name: - description: Name of the client - type: string - description: - description: Description of the client - type: string - createdAt: - format: date-time - type: string - updatedAt: - format: date-time - type: string - required: - - createdAt - - description - - id - - name - - secret - - updatedAt - type: object - Organization: - allOf: - - $ref: "#/components/schemas/OrganizationData" - - properties: - id: - description: Organization ID - type: string - ownerId: - description: Owner ID - type: string - availableStacks: - description: Number of available stacks - type: integer - availableSandboxes: - description: Number of available sandboxes - type: integer - createdAt: - format: date-time - type: string - updatedAt: - format: date-time - type: string - required: - - id - - ownerId - type: object - StackData: - properties: - name: - description: Stack name - type: string - metadata: - additionalProperties: - type: string - type: object - required: - - name - type: object - StackVersion: - example: - version: version - properties: - version: - description: Supported only with agent version >= v0.7.0 - type: string - type: object - StackLifeCycle: - properties: - status: - enum: - - UNKNOWN - - PROGRESSING - - READY - - DISABLED - - DELETED - type: string - state: - enum: - - ACTIVE - - DISABLED - - DELETED - type: string - expectedStatus: - enum: - - READY - - DISABLED - - DELETED - type: string - lastStateUpdate: - format: date-time - type: string - lastExpectedStatusUpdate: - format: date-time - type: string - lastStatusUpdate: - format: date-time - type: string - warnedAt: - format: date-time - type: string - disposableSince: - format: date-time - type: string - required: - - expectedStatus - - lastExpectedStatusUpdate - - lastStateUpdate - - lastStatusUpdate - - state - - status - type: object - StackReachability: - properties: - reachable: - description: Stack is reachable through Stargate - type: boolean - lastReachableUpdate: - description: Last time the stack was reachable - format: date-time - type: string - required: - - reachable - type: object - Stack: - allOf: - - $ref: "#/components/schemas/StackData" - - $ref: "#/components/schemas/StackVersion" - - $ref: "#/components/schemas/StackLifeCycle" - - $ref: "#/components/schemas/StackReachability" - - properties: - id: - description: Stack ID - type: string - organizationId: - description: Organization ID - type: string - uri: - description: Base stack uri - type: string - regionID: - description: The region where the stack is installed - type: string - region: - $ref: "#/components/schemas/Region" - stargateEnabled: - type: boolean - createdAt: - format: date-time - type: string - deletedAt: - format: date-time - type: string - disabledAt: - format: date-time - type: string - auditEnabled: - type: boolean - synchronised: - type: boolean - updatedAt: - format: date-time - type: string - modules: - items: - $ref: "#/components/schemas/Module" - type: array - required: - - id - - modules - - organizationId - - regionID - - stargateEnabled - - synchronised - - uri - type: object - example: - auditEnabled: true - metadata: - key: metadata - expectedStatus: READY - disabledAt: 2000-01-23T04:56:07.000+00:00 - organizationId: organizationId - lastExpectedStatusUpdate: 2000-01-23T04:56:07.000+00:00 - createdAt: 2000-01-23T04:56:07.000+00:00 - regionID: regionID - warnedAt: 2000-01-23T04:56:07.000+00:00 - lastStateUpdate: 2000-01-23T04:56:07.000+00:00 - lastReachableUpdate: 2000-01-23T04:56:07.000+00:00 - synchronised: true - state: ACTIVE - id: id - updatedAt: 2000-01-23T04:56:07.000+00:00 - lastStatusUpdate: 2000-01-23T04:56:07.000+00:00 - version: version - uri: uri - reachable: true - stargateEnabled: true - modules: - - lastStateUpdate: 2000-01-23T04:56:07.000+00:00 - name: name - lastStatusUpdate: 2000-01-23T04:56:07.000+00:00 - state: ENABLED - clusterStatus: "{}" - status: UNKNOWN - - lastStateUpdate: 2000-01-23T04:56:07.000+00:00 - name: name - lastStatusUpdate: 2000-01-23T04:56:07.000+00:00 - state: ENABLED - clusterStatus: "{}" - status: UNKNOWN - deletedAt: 2000-01-23T04:56:07.000+00:00 - name: name - region: - createdAt: createdAt - baseUrl: baseUrl - agentID: agentID - capabilities: - EE: - - EE - - EE - MODULE_LIST: - - MODULE_LIST - - MODULE_LIST - outdated: true - name: name - creatorId: creatorId - active: true - lastPing: 2000-01-23T04:56:07.000+00:00 - id: id - version: version - disposableSince: 2000-01-23T04:56:07.000+00:00 - status: UNKNOWN - UserData: - allOf: - - properties: - email: - type: string - required: - - email - type: object - Role: - enum: - - NONE - - ADMIN - - GUEST - type: string - SystemRole: - enum: - - USER - - SYSTEM - type: string - User: - allOf: - - $ref: "#/components/schemas/UserData" - - properties: - id: - description: User ID - type: string - required: - - id - type: object - - properties: - role: - $ref: "#/components/schemas/SystemRole" - type: object - example: - role: USER - id: id - email: email - OrganizationUserArray: - items: - allOf: - - $ref: "#/components/schemas/OrganizationUser" - type: array - ReadOrganizationUserResponse: - example: - data: - role: NONE - id: id - email: email - properties: - data: - $ref: "#/components/schemas/OrganizationUser" - type: object - OrganizationUser: - allOf: - - properties: - role: - $ref: "#/components/schemas/Role" - email: - type: string - id: - type: string - required: - - email - - id - - role - type: object - example: - role: NONE - id: id - email: email - OrganizationArray: - items: - $ref: "#/components/schemas/Organization" - type: array - StackArray: - items: - $ref: "#/components/schemas/Stack" - type: array - UserArray: - items: - $ref: "#/components/schemas/User" - type: array - ReadStackUserAccess: - example: - data: - role: NONE - stackId: stackId - userId: userId - email: email - properties: - data: - $ref: "#/components/schemas/StackUserAccess" - type: object - StackUserAccess: - allOf: - - properties: - stackId: - description: Stack ID - type: string - userId: - description: User ID - type: string - email: - description: User email - type: string - role: - $ref: "#/components/schemas/Role" - required: - - email - - role - - stackId - - userId - type: object - example: - role: NONE - stackId: stackId - userId: userId - email: email - StackUserAccessResponse: - example: - data: - - role: NONE - stackId: stackId - userId: userId - email: email - - role: NONE - stackId: stackId - userId: userId - email: email - properties: - data: - items: - $ref: "#/components/schemas/StackUserAccess" - type: array - type: object - StackUserAccessArray: - items: - $ref: "#/components/schemas/StackUserAccess" - type: array - ListOrganizationResponse: - properties: - data: - items: - $ref: "#/components/schemas/Organization" - type: array - type: object - CreateOrganizationRequest: - $ref: "#/components/schemas/OrganizationData" - CreateOrganizationResponse: - example: - data: - owner: - role: USER - id: id - email: email - defaultOrganizationAccess: NONE - totalUsers: 5 - ownerId: ownerId - totalStacks: 1 - createdAt: 2000-01-23T04:56:07.000+00:00 - defaultStackAccess: null - domain: domain - name: name - id: id - availableSandboxes: 6 - availableStacks: 0 - updatedAt: 2000-01-23T04:56:07.000+00:00 - properties: - data: - $ref: "#/components/schemas/OrganizationExpanded" - type: object - ReadOrganizationResponse: - example: - data: - owner: - role: USER - id: id - email: email - defaultOrganizationAccess: NONE - totalUsers: 5 - ownerId: ownerId - totalStacks: 1 - createdAt: 2000-01-23T04:56:07.000+00:00 - defaultStackAccess: null - domain: domain - name: name - id: id - availableSandboxes: 6 - availableStacks: 0 - updatedAt: 2000-01-23T04:56:07.000+00:00 - properties: - data: - $ref: "#/components/schemas/OrganizationExpanded" - type: object - ListStacksResponse: - example: - data: - - auditEnabled: true - metadata: - key: metadata - expectedStatus: READY - disabledAt: 2000-01-23T04:56:07.000+00:00 - organizationId: organizationId - lastExpectedStatusUpdate: 2000-01-23T04:56:07.000+00:00 - createdAt: 2000-01-23T04:56:07.000+00:00 - regionID: regionID - warnedAt: 2000-01-23T04:56:07.000+00:00 - lastStateUpdate: 2000-01-23T04:56:07.000+00:00 - lastReachableUpdate: 2000-01-23T04:56:07.000+00:00 - synchronised: true - state: ACTIVE - id: id - updatedAt: 2000-01-23T04:56:07.000+00:00 - lastStatusUpdate: 2000-01-23T04:56:07.000+00:00 - version: version - uri: uri - reachable: true - stargateEnabled: true - modules: - - lastStateUpdate: 2000-01-23T04:56:07.000+00:00 - name: name - lastStatusUpdate: 2000-01-23T04:56:07.000+00:00 - state: ENABLED - clusterStatus: "{}" - status: UNKNOWN - - lastStateUpdate: 2000-01-23T04:56:07.000+00:00 - name: name - lastStatusUpdate: 2000-01-23T04:56:07.000+00:00 - state: ENABLED - clusterStatus: "{}" - status: UNKNOWN - deletedAt: 2000-01-23T04:56:07.000+00:00 - name: name - region: - createdAt: createdAt - baseUrl: baseUrl - agentID: agentID - capabilities: - EE: - - EE - - EE - MODULE_LIST: - - MODULE_LIST - - MODULE_LIST - outdated: true - name: name - creatorId: creatorId - active: true - lastPing: 2000-01-23T04:56:07.000+00:00 - id: id - version: version - disposableSince: 2000-01-23T04:56:07.000+00:00 - status: UNKNOWN - - auditEnabled: true - metadata: - key: metadata - expectedStatus: READY - disabledAt: 2000-01-23T04:56:07.000+00:00 - organizationId: organizationId - lastExpectedStatusUpdate: 2000-01-23T04:56:07.000+00:00 - createdAt: 2000-01-23T04:56:07.000+00:00 - regionID: regionID - warnedAt: 2000-01-23T04:56:07.000+00:00 - lastStateUpdate: 2000-01-23T04:56:07.000+00:00 - lastReachableUpdate: 2000-01-23T04:56:07.000+00:00 - synchronised: true - state: ACTIVE - id: id - updatedAt: 2000-01-23T04:56:07.000+00:00 - lastStatusUpdate: 2000-01-23T04:56:07.000+00:00 - version: version - uri: uri - reachable: true - stargateEnabled: true - modules: - - lastStateUpdate: 2000-01-23T04:56:07.000+00:00 - name: name - lastStatusUpdate: 2000-01-23T04:56:07.000+00:00 - state: ENABLED - clusterStatus: "{}" - status: UNKNOWN - - lastStateUpdate: 2000-01-23T04:56:07.000+00:00 - name: name - lastStatusUpdate: 2000-01-23T04:56:07.000+00:00 - state: ENABLED - clusterStatus: "{}" - status: UNKNOWN - deletedAt: 2000-01-23T04:56:07.000+00:00 - name: name - region: - createdAt: createdAt - baseUrl: baseUrl - agentID: agentID - capabilities: - EE: - - EE - - EE - MODULE_LIST: - - MODULE_LIST - - MODULE_LIST - outdated: true - name: name - creatorId: creatorId - active: true - lastPing: 2000-01-23T04:56:07.000+00:00 - id: id - version: version - disposableSince: 2000-01-23T04:56:07.000+00:00 - status: UNKNOWN - properties: - data: - items: - $ref: "#/components/schemas/Stack" - type: array - type: object - ListUsersResponse: - example: - data: - - "" - - "" - properties: - data: - items: - allOf: - - $ref: "#/components/schemas/OrganizationUser" - type: array - type: object - CreateStackRequest: - allOf: - - $ref: "#/components/schemas/StackData" - - $ref: "#/components/schemas/StackVersion" - - properties: - regionID: - type: string - required: - - regionID - type: object - example: - metadata: - key: metadata - regionID: regionID - name: name - version: version - UpdateStackRequest: - allOf: - - $ref: "#/components/schemas/StackData" - example: - metadata: - key: metadata - name: name - CreateStackResponse: - example: - data: - auditEnabled: true - metadata: - key: metadata - expectedStatus: READY - disabledAt: 2000-01-23T04:56:07.000+00:00 - organizationId: organizationId - lastExpectedStatusUpdate: 2000-01-23T04:56:07.000+00:00 - createdAt: 2000-01-23T04:56:07.000+00:00 - regionID: regionID - warnedAt: 2000-01-23T04:56:07.000+00:00 - lastStateUpdate: 2000-01-23T04:56:07.000+00:00 - lastReachableUpdate: 2000-01-23T04:56:07.000+00:00 - synchronised: true - state: ACTIVE - id: id - updatedAt: 2000-01-23T04:56:07.000+00:00 - lastStatusUpdate: 2000-01-23T04:56:07.000+00:00 - version: version - uri: uri - reachable: true - stargateEnabled: true - modules: - - lastStateUpdate: 2000-01-23T04:56:07.000+00:00 - name: name - lastStatusUpdate: 2000-01-23T04:56:07.000+00:00 - state: ENABLED - clusterStatus: "{}" - status: UNKNOWN - - lastStateUpdate: 2000-01-23T04:56:07.000+00:00 - name: name - lastStatusUpdate: 2000-01-23T04:56:07.000+00:00 - state: ENABLED - clusterStatus: "{}" - status: UNKNOWN - deletedAt: 2000-01-23T04:56:07.000+00:00 - name: name - region: - createdAt: createdAt - baseUrl: baseUrl - agentID: agentID - capabilities: - EE: - - EE - - EE - MODULE_LIST: - - MODULE_LIST - - MODULE_LIST - outdated: true - name: name - creatorId: creatorId - active: true - lastPing: 2000-01-23T04:56:07.000+00:00 - id: id - version: version - disposableSince: 2000-01-23T04:56:07.000+00:00 - status: UNKNOWN - properties: - data: - $ref: "#/components/schemas/Stack" - type: object - ReadStackResponse: - $ref: "#/components/schemas/CreateStackResponse" - ReadUserResponse: - example: - data: - role: USER - id: id - email: email - properties: - data: - $ref: "#/components/schemas/User" - type: object - ListInvitationsResponse: - example: - data: - - organizationId: organizationId - role: NONE - lastUpdate: 2000-01-23T04:56:07.000+00:00 - creatorId: creatorId - userEmail: userEmail - id: id - creationDate: 2000-01-23T04:56:07.000+00:00 - userId: userId - organizationAccess: - role: NONE - id: id - email: email - expiresAt: 2000-01-23T04:56:07.000+00:00 - status: PENDING - updatedAt: updatedAt - - organizationId: organizationId - role: NONE - lastUpdate: 2000-01-23T04:56:07.000+00:00 - creatorId: creatorId - userEmail: userEmail - id: id - creationDate: 2000-01-23T04:56:07.000+00:00 - userId: userId - organizationAccess: - role: NONE - id: id - email: email - expiresAt: 2000-01-23T04:56:07.000+00:00 - status: PENDING - updatedAt: updatedAt - properties: - data: - items: - $ref: "#/components/schemas/Invitation" - type: array - type: object - CreateInvitationResponse: - example: - data: - organizationId: organizationId - role: NONE - lastUpdate: 2000-01-23T04:56:07.000+00:00 - creatorId: creatorId - userEmail: userEmail - id: id - creationDate: 2000-01-23T04:56:07.000+00:00 - userId: userId - organizationAccess: - role: NONE - id: id - email: email - expiresAt: 2000-01-23T04:56:07.000+00:00 - status: PENDING - updatedAt: updatedAt - properties: - data: - $ref: "#/components/schemas/Invitation" - type: object - Error: - example: - errorMessage: errorMessage - errorCode: errorCode - properties: - errorCode: - type: string - errorMessage: - type: string - required: - - errorCode - type: object - Invitation: - example: - organizationId: organizationId - role: NONE - lastUpdate: 2000-01-23T04:56:07.000+00:00 - creatorId: creatorId - userEmail: userEmail - id: id - creationDate: 2000-01-23T04:56:07.000+00:00 - userId: userId - organizationAccess: - role: NONE - id: id - email: email - expiresAt: 2000-01-23T04:56:07.000+00:00 - status: PENDING - updatedAt: updatedAt - properties: - id: - type: string - organizationId: - type: string - userEmail: - type: string - status: - enum: - - PENDING - - ACCEPTED - - REJECTED - - CANCELLED - type: string - creationDate: - format: date-time - type: string - updatedAt: - format: date-tim - type: string - role: - $ref: "#/components/schemas/Role" - userId: - type: string - organizationAccess: - $ref: "#/components/schemas/OrganizationUser" - expiresAt: - format: date-time - type: string - creatorId: - type: string - lastUpdate: - format: date-time - type: string - required: - - creationDate - - creatorID - - id - - organizationId - - role - - status - - userEmail - type: object - InvitationClaim: - example: - role: NONE - properties: - role: - $ref: "#/components/schemas/Role" - type: object - Region: - example: - createdAt: createdAt - baseUrl: baseUrl - agentID: agentID - capabilities: - EE: - - EE - - EE - MODULE_LIST: - - MODULE_LIST - - MODULE_LIST - outdated: true - name: name - creatorId: creatorId - active: true - lastPing: 2000-01-23T04:56:07.000+00:00 - id: id - version: version - properties: - id: - type: string - baseUrl: - type: string - createdAt: - format: datetime - type: string - active: - type: boolean - lastPing: - format: date-time - type: string - name: - type: string - capabilities: - $ref: "#/components/schemas/RegionCapability" - agentID: - type: string - outdated: - type: boolean - creatorId: - type: string - version: - type: string - required: - - active - - agentID - - baseUrl - - capabilities - - createdAt - - id - - name - - outdated - type: object - RegionCapability: - example: - EE: - - EE - - EE - MODULE_LIST: - - MODULE_LIST - - MODULE_LIST - properties: - MODULE_LIST: - items: - type: string - type: array - EE: - items: - type: string - type: array - type: object - RegionCapabilityKeys: - enum: - - MODULE_LIST - - EE - type: string - ListOrganizationExpandedResponse: - example: - data: - - "" - - "" - properties: - data: - items: - allOf: - - $ref: "#/components/schemas/OrganizationExpanded" - type: array - type: object - CreateClientResponseResponse: - example: - data: - createdAt: 2000-01-23T04:56:07.000+00:00 - name: name - description: description - id: id - secret: - clear: clear - lastDigits: lastDigits - ownerId: ownerId - updatedAt: 2000-01-23T04:56:07.000+00:00 - properties: - data: - $ref: "#/components/schemas/CreateClientResponseResponse_data" - type: object - OrganizationExpanded: - allOf: - - $ref: "#/components/schemas/Organization" - - properties: - totalStacks: - type: integer - totalUsers: - type: integer - owner: - $ref: "#/components/schemas/User" - type: object - example: - owner: - role: USER - id: id - email: email - defaultOrganizationAccess: NONE - totalUsers: 5 - ownerId: ownerId - totalStacks: 1 - createdAt: 2000-01-23T04:56:07.000+00:00 - defaultStackAccess: null - domain: domain - name: name - id: id - availableSandboxes: 6 - availableStacks: 0 - updatedAt: 2000-01-23T04:56:07.000+00:00 - ListRegionsResponse: - example: - data: - - agentID: agentID - creator: - role: USER - id: id - email: email - capabilities: - EE: - - EE - - EE - MODULE_LIST: - - MODULE_LIST - - MODULE_LIST - clientID: clientID - production: true - creatorId: creatorId - active: true - lastPing: 2000-01-23T04:56:07.000+00:00 - secret: - clear: clear - lastDigits: lastDigits - version: version - organizationID: organizationID - createdAt: createdAt - baseUrl: baseUrl - outdated: true - public: true - name: name - id: id - - agentID: agentID - creator: - role: USER - id: id - email: email - capabilities: - EE: - - EE - - EE - MODULE_LIST: - - MODULE_LIST - - MODULE_LIST - clientID: clientID - production: true - creatorId: creatorId - active: true - lastPing: 2000-01-23T04:56:07.000+00:00 - secret: - clear: clear - lastDigits: lastDigits - version: version - organizationID: organizationID - createdAt: createdAt - baseUrl: baseUrl - outdated: true - public: true - name: name - id: id - properties: - data: - items: - $ref: "#/components/schemas/AnyRegion" - type: array - required: - - data - type: object - GetRegionResponse: - example: - data: - agentID: agentID - creator: - role: USER - id: id - email: email - capabilities: - EE: - - EE - - EE - MODULE_LIST: - - MODULE_LIST - - MODULE_LIST - clientID: clientID - production: true - creatorId: creatorId - active: true - lastPing: 2000-01-23T04:56:07.000+00:00 - secret: - clear: clear - lastDigits: lastDigits - version: version - organizationID: organizationID - createdAt: createdAt - baseUrl: baseUrl - outdated: true - public: true - name: name - id: id - properties: - data: - $ref: "#/components/schemas/AnyRegion" - required: - - data - type: object - ServerInfo: - example: - capabilities: - - "" - - "" - consoleURL: consoleURL - version: version - properties: - version: - type: string - capabilities: - items: - allOf: - - $ref: "#/components/schemas/Capability" - type: array - consoleURL: - type: string - required: - - version - type: object - Capability: - enum: - - MODULE_SELECTION - type: string - Version: - example: - versions: - key: versions - regionID: regionID - name: name - properties: - name: - type: string - versions: - additionalProperties: - type: string - type: object - regionID: - type: string - required: - - name - - regionID - - versions - type: object - UpdateOrganizationUserRequest: - example: - role: NONE - properties: - role: - $ref: "#/components/schemas/Role" - required: - - role - type: object - UpdateStackUserRequest: - example: - role: NONE - properties: - role: - $ref: "#/components/schemas/Role" - required: - - role - type: object - GetRegionVersionsResponse: - example: - data: - - versions: - key: versions - regionID: regionID - name: name - - versions: - key: versions - regionID: regionID - name: name - properties: - data: - items: - $ref: "#/components/schemas/Version" - type: array - required: - - data - type: object - AuthenticationProviderData: - oneOf: - - $ref: "#/components/schemas/GoogleIDPConfig" - - $ref: "#/components/schemas/MicrosoftIDPConfig" - - $ref: "#/components/schemas/GithubIDPConfig" - - $ref: "#/components/schemas/OIDCConfig" - type: object - BaseProviderConfig: - properties: - type: - description: Type of the authentication provider - enum: - - oidc - - google - - github - - microsoft - type: string - name: - description: Name of the authentication provider - type: string - clientID: - description: Client ID for the authentication provider - type: string - clientSecret: - description: Client secret for the authentication provider - type: string - required: - - clientID - - clientSecret - - name - - type - type: object - AuthenticationProvider: - allOf: - - $ref: "#/components/schemas/AuthenticationProviderData" - - properties: - organizationId: - description: Unique identifier for the authentication provider - type: string - createdAt: - description: Creation date of the authentication provider - format: date-time - type: string - updatedAt: - description: Last update date of the authentication provider - format: date-time - type: string - required: - - createdAt - - organizationId - - updatedAt - type: object - type: object - GoogleIDPConfig: - allOf: - - $ref: "#/components/schemas/BaseProviderConfig" - - properties: - config: - $ref: "#/components/schemas/GoogleIDPConfig_allOf_config" - required: - - config - type: object - example: - clientID: clientID - name: name - clientSecret: clientSecret - type: oidc - config: null - MicrosoftIDPConfig: - allOf: - - $ref: "#/components/schemas/BaseProviderConfig" - - properties: - config: - $ref: "#/components/schemas/MicrosoftIDPConfig_allOf_config" - required: - - config - type: object - GithubIDPConfig: - allOf: - - $ref: "#/components/schemas/BaseProviderConfig" - - properties: - config: - $ref: "#/components/schemas/GoogleIDPConfig_allOf_config" - required: - - config - type: object - OIDCConfig: - allOf: - - $ref: "#/components/schemas/BaseProviderConfig" - - properties: - config: - $ref: "#/components/schemas/OIDCConfig_allOf_config" - required: - - config - type: object - UpsertAuthenticationProviderRequest: - $ref: "#/components/schemas/AuthenticationProviderData" - AuthenticationProviderResponse: - example: - data: - organizationId: organizationId - redirectURI: redirectURI - createdAt: 2000-01-23T04:56:07.000+00:00 - updatedAt: 2000-01-23T04:56:07.000+00:00 - properties: - data: - $ref: "#/components/schemas/AuthenticationProviderResponse_data" - type: object - listFeatures_200_response: - example: - data: - - organizationID: organizationID - createdAt: 2000-01-23T04:56:07.000+00:00 - name: name - - organizationID: organizationID - createdAt: 2000-01-23T04:56:07.000+00:00 - name: name - properties: - data: - items: - $ref: "#/components/schemas/OrganizationFeature" - type: array - required: - - data - type: object - addFeatures_request: - properties: - features: - items: - type: string - type: array - required: - - features - type: object - LogCursor_data: - allOf: - - $ref: "#/components/schemas/Cursor" - - properties: - data: - items: - $ref: "#/components/schemas/Log" - type: array - type: object - example: - next: "" - previous: YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= - data: - - organizationId: organizationId - date: 2000-01-23T04:56:07.000+00:00 - data: "{}" - action: action - userId: userId - seq: 1e6f8b6e-1b6b-4b3b-8b3b-1b6b4b3b8b3b - - organizationId: organizationId - date: 2000-01-23T04:56:07.000+00:00 - data: "{}" - action: action - userId: userId - seq: 1e6f8b6e-1b6b-4b3b-8b3b-1b6b4b3b8b3b - hasMore: false - pageSize: 15 - ReadOrganizationClientsResponse_data: - allOf: - - $ref: "#/components/schemas/Cursor" - - properties: - data: - items: - $ref: "#/components/schemas/OrganizationClient" - type: array - required: - - data - type: object - example: - next: "" - previous: YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= - data: - - createdAt: 2000-01-23T04:56:07.000+00:00 - name: name - description: description - id: id - secret: - clear: clear - lastDigits: lastDigits - updatedAt: 2000-01-23T04:56:07.000+00:00 - - createdAt: 2000-01-23T04:56:07.000+00:00 - name: name - description: description - id: id - secret: - clear: clear - lastDigits: lastDigits - updatedAt: 2000-01-23T04:56:07.000+00:00 - hasMore: false - pageSize: 15 - OrganizationClient_secret: - example: - clear: clear - lastDigits: lastDigits - properties: - lastDigits: - type: string - clear: - type: string - required: - - lastDigits - type: object - CreateClientResponseResponse_data: - allOf: - - $ref: "#/components/schemas/OrganizationClient" - - properties: - ownerId: - description: The ID of the owner of the client (DEPRECATED will be empty) - type: string - required: - - ownerId - type: object - example: - createdAt: 2000-01-23T04:56:07.000+00:00 - name: name - description: description - id: id - secret: - clear: clear - lastDigits: lastDigits - ownerId: ownerId - updatedAt: 2000-01-23T04:56:07.000+00:00 - GoogleIDPConfig_allOf_config: - type: object - MicrosoftIDPConfig_allOf_config: - properties: - tenant: - default: common - description: Tenant ID for Microsoft authentication - type: string - type: object - OIDCConfig_allOf_config: - properties: - issuer: - description: OIDC issuer URL - type: string - discoveryPath: - default: /.well-known/openid-configuration - type: string - required: - - issuer - type: object - AuthenticationProviderResponse_data: - allOf: - - $ref: "#/components/schemas/AuthenticationProvider" - - properties: - redirectURI: - type: string - required: - - redirectURI - type: object - example: - organizationId: organizationId - redirectURI: redirectURI - createdAt: 2000-01-23T04:56:07.000+00:00 - updatedAt: 2000-01-23T04:56:07.000+00:00 - securitySchemes: - oauth2: - flows: - authorizationCode: - authorizationUrl: /authorize - scopes: - openid: Enable OIDC - email: Ask email access - tokenUrl: /oauth/token - type: oauth2 diff --git a/membershipclient/api_default.go b/membershipclient/api_default.go deleted file mode 100644 index 3cac82c9..00000000 --- a/membershipclient/api_default.go +++ /dev/null @@ -1,6271 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "bytes" - "context" - "io" - "net/http" - "net/url" - "strings" -) - - -// DefaultAPIService DefaultAPI service -type DefaultAPIService service - -type ApiAcceptInvitationRequest struct { - ctx context.Context - ApiService *DefaultAPIService - invitationId string -} - -func (r ApiAcceptInvitationRequest) Execute() (*http.Response, error) { - return r.ApiService.AcceptInvitationExecute(r) -} - -/* -AcceptInvitation Accept invitation - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param invitationId - @return ApiAcceptInvitationRequest -*/ -func (a *DefaultAPIService) AcceptInvitation(ctx context.Context, invitationId string) ApiAcceptInvitationRequest { - return ApiAcceptInvitationRequest{ - ApiService: a, - ctx: ctx, - invitationId: invitationId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) AcceptInvitationExecute(r ApiAcceptInvitationRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.AcceptInvitation") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/me/invitations/{invitationId}/accept" - localVarPath = strings.Replace(localVarPath, "{"+"invitationId"+"}", url.PathEscape(parameterValueToString(r.invitationId, "invitationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiAddFeaturesRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - addFeaturesRequest *AddFeaturesRequest -} - -func (r ApiAddFeaturesRequest) AddFeaturesRequest(addFeaturesRequest AddFeaturesRequest) ApiAddFeaturesRequest { - r.addFeaturesRequest = &addFeaturesRequest - return r -} - -func (r ApiAddFeaturesRequest) Execute() (*http.Response, error) { - return r.ApiService.AddFeaturesExecute(r) -} - -/* -AddFeatures Add Features - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiAddFeaturesRequest -*/ -func (a *DefaultAPIService) AddFeatures(ctx context.Context, organizationId string) ApiAddFeaturesRequest { - return ApiAddFeaturesRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) AddFeaturesExecute(r ApiAddFeaturesRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.AddFeatures") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/features" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - // body params - localVarPostBody = r.addFeaturesRequest - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiCreateInvitationRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - email *string - invitationClaim *InvitationClaim -} - -func (r ApiCreateInvitationRequest) Email(email string) ApiCreateInvitationRequest { - r.email = &email - return r -} - -func (r ApiCreateInvitationRequest) InvitationClaim(invitationClaim InvitationClaim) ApiCreateInvitationRequest { - r.invitationClaim = &invitationClaim - return r -} - -func (r ApiCreateInvitationRequest) Execute() (*CreateInvitationResponse, *http.Response, error) { - return r.ApiService.CreateInvitationExecute(r) -} - -/* -CreateInvitation Create invitation - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiCreateInvitationRequest -*/ -func (a *DefaultAPIService) CreateInvitation(ctx context.Context, organizationId string) ApiCreateInvitationRequest { - return ApiCreateInvitationRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -// @return CreateInvitationResponse -func (a *DefaultAPIService) CreateInvitationExecute(r ApiCreateInvitationRequest) (*CreateInvitationResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *CreateInvitationResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.CreateInvitation") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/invitations" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - if r.email == nil { - return localVarReturnValue, nil, reportError("email is required and must be specified") - } - - parameterAddToHeaderOrQuery(localVarQueryParams, "email", r.email, "form", "") - // to determine the Content-Type header - localVarHTTPContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - // body params - localVarPostBody = r.invitationClaim - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiCreateOrganizationRequest struct { - ctx context.Context - ApiService *DefaultAPIService - body *OrganizationData -} - -func (r ApiCreateOrganizationRequest) Body(body OrganizationData) ApiCreateOrganizationRequest { - r.body = &body - return r -} - -func (r ApiCreateOrganizationRequest) Execute() (*CreateOrganizationResponse, *http.Response, error) { - return r.ApiService.CreateOrganizationExecute(r) -} - -/* -CreateOrganization Create organization - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiCreateOrganizationRequest -*/ -func (a *DefaultAPIService) CreateOrganization(ctx context.Context) ApiCreateOrganizationRequest { - return ApiCreateOrganizationRequest{ - ApiService: a, - ctx: ctx, - } -} - -// Execute executes the request -// @return CreateOrganizationResponse -func (a *DefaultAPIService) CreateOrganizationExecute(r ApiCreateOrganizationRequest) (*CreateOrganizationResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *CreateOrganizationResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.CreateOrganization") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - // body params - localVarPostBody = r.body - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiCreateOrganizationClientRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string -} - -func (r ApiCreateOrganizationClientRequest) Execute() (*CreateClientResponseResponse, *http.Response, error) { - return r.ApiService.CreateOrganizationClientExecute(r) -} - -/* -CreateOrganizationClient Create organization client (DEPRECATED) (until 12/31/2025) - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiCreateOrganizationClientRequest - -Deprecated -*/ -func (a *DefaultAPIService) CreateOrganizationClient(ctx context.Context, organizationId string) ApiCreateOrganizationClientRequest { - return ApiCreateOrganizationClientRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -// @return CreateClientResponseResponse -// Deprecated -func (a *DefaultAPIService) CreateOrganizationClientExecute(r ApiCreateOrganizationClientRequest) (*CreateClientResponseResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPut - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *CreateClientResponseResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.CreateOrganizationClient") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/client" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiCreatePrivateRegionRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - createPrivateRegionRequest *CreatePrivateRegionRequest -} - -func (r ApiCreatePrivateRegionRequest) CreatePrivateRegionRequest(createPrivateRegionRequest CreatePrivateRegionRequest) ApiCreatePrivateRegionRequest { - r.createPrivateRegionRequest = &createPrivateRegionRequest - return r -} - -func (r ApiCreatePrivateRegionRequest) Execute() (*CreatedPrivateRegionResponse, *http.Response, error) { - return r.ApiService.CreatePrivateRegionExecute(r) -} - -/* -CreatePrivateRegion Create a private region - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiCreatePrivateRegionRequest -*/ -func (a *DefaultAPIService) CreatePrivateRegion(ctx context.Context, organizationId string) ApiCreatePrivateRegionRequest { - return ApiCreatePrivateRegionRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -// @return CreatedPrivateRegionResponse -func (a *DefaultAPIService) CreatePrivateRegionExecute(r ApiCreatePrivateRegionRequest) (*CreatedPrivateRegionResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *CreatedPrivateRegionResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.CreatePrivateRegion") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/regions" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - // body params - localVarPostBody = r.createPrivateRegionRequest - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiCreateStackRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - createStackRequest *CreateStackRequest -} - -func (r ApiCreateStackRequest) CreateStackRequest(createStackRequest CreateStackRequest) ApiCreateStackRequest { - r.createStackRequest = &createStackRequest - return r -} - -func (r ApiCreateStackRequest) Execute() (*CreateStackResponse, *http.Response, error) { - return r.ApiService.CreateStackExecute(r) -} - -/* -CreateStack Create stack - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiCreateStackRequest -*/ -func (a *DefaultAPIService) CreateStack(ctx context.Context, organizationId string) ApiCreateStackRequest { - return ApiCreateStackRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -// @return CreateStackResponse -func (a *DefaultAPIService) CreateStackExecute(r ApiCreateStackRequest) (*CreateStackResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *CreateStackResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.CreateStack") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/stacks" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - // body params - localVarPostBody = r.createStackRequest - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiDeclineInvitationRequest struct { - ctx context.Context - ApiService *DefaultAPIService - invitationId string -} - -func (r ApiDeclineInvitationRequest) Execute() (*http.Response, error) { - return r.ApiService.DeclineInvitationExecute(r) -} - -/* -DeclineInvitation Decline invitation - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param invitationId - @return ApiDeclineInvitationRequest -*/ -func (a *DefaultAPIService) DeclineInvitation(ctx context.Context, invitationId string) ApiDeclineInvitationRequest { - return ApiDeclineInvitationRequest{ - ApiService: a, - ctx: ctx, - invitationId: invitationId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) DeclineInvitationExecute(r ApiDeclineInvitationRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.DeclineInvitation") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/me/invitations/{invitationId}/reject" - localVarPath = strings.Replace(localVarPath, "{"+"invitationId"+"}", url.PathEscape(parameterValueToString(r.invitationId, "invitationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiDeleteAuthenticationProviderRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string -} - -func (r ApiDeleteAuthenticationProviderRequest) Execute() (*http.Response, error) { - return r.ApiService.DeleteAuthenticationProviderExecute(r) -} - -/* -DeleteAuthenticationProvider Delete authentication provider - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiDeleteAuthenticationProviderRequest -*/ -func (a *DefaultAPIService) DeleteAuthenticationProvider(ctx context.Context, organizationId string) ApiDeleteAuthenticationProviderRequest { - return ApiDeleteAuthenticationProviderRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) DeleteAuthenticationProviderExecute(r ApiDeleteAuthenticationProviderRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodDelete - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.DeleteAuthenticationProvider") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/authentication-provider" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiDeleteFeatureRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - name string -} - -func (r ApiDeleteFeatureRequest) Execute() (*http.Response, error) { - return r.ApiService.DeleteFeatureExecute(r) -} - -/* -DeleteFeature Delete feature - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param name - @return ApiDeleteFeatureRequest -*/ -func (a *DefaultAPIService) DeleteFeature(ctx context.Context, organizationId string, name string) ApiDeleteFeatureRequest { - return ApiDeleteFeatureRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - name: name, - } -} - -// Execute executes the request -func (a *DefaultAPIService) DeleteFeatureExecute(r ApiDeleteFeatureRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodDelete - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.DeleteFeature") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/features/{name}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"name"+"}", url.PathEscape(parameterValueToString(r.name, "name")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiDeleteInvitationRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - invitationId string -} - -func (r ApiDeleteInvitationRequest) Execute() (*http.Response, error) { - return r.ApiService.DeleteInvitationExecute(r) -} - -/* -DeleteInvitation Delete invitation - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param invitationId - @return ApiDeleteInvitationRequest -*/ -func (a *DefaultAPIService) DeleteInvitation(ctx context.Context, organizationId string, invitationId string) ApiDeleteInvitationRequest { - return ApiDeleteInvitationRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - invitationId: invitationId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) DeleteInvitationExecute(r ApiDeleteInvitationRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodDelete - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.DeleteInvitation") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/invitations/{invitationId}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"invitationId"+"}", url.PathEscape(parameterValueToString(r.invitationId, "invitationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiDeleteOrganizationRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string -} - -func (r ApiDeleteOrganizationRequest) Execute() (*http.Response, error) { - return r.ApiService.DeleteOrganizationExecute(r) -} - -/* -DeleteOrganization Delete organization - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiDeleteOrganizationRequest -*/ -func (a *DefaultAPIService) DeleteOrganization(ctx context.Context, organizationId string) ApiDeleteOrganizationRequest { - return ApiDeleteOrganizationRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) DeleteOrganizationExecute(r ApiDeleteOrganizationRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodDelete - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.DeleteOrganization") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiDeleteOrganizationClientRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string -} - -func (r ApiDeleteOrganizationClientRequest) Execute() (*http.Response, error) { - return r.ApiService.DeleteOrganizationClientExecute(r) -} - -/* -DeleteOrganizationClient Delete organization client (DEPRECATED) (until 12/31/2025) - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiDeleteOrganizationClientRequest - -Deprecated -*/ -func (a *DefaultAPIService) DeleteOrganizationClient(ctx context.Context, organizationId string) ApiDeleteOrganizationClientRequest { - return ApiDeleteOrganizationClientRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -// Deprecated -func (a *DefaultAPIService) DeleteOrganizationClientExecute(r ApiDeleteOrganizationClientRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodDelete - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.DeleteOrganizationClient") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/client" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiDeleteRegionRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - regionID string -} - -func (r ApiDeleteRegionRequest) Execute() (*http.Response, error) { - return r.ApiService.DeleteRegionExecute(r) -} - -/* -DeleteRegion Delete region - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param regionID - @return ApiDeleteRegionRequest -*/ -func (a *DefaultAPIService) DeleteRegion(ctx context.Context, organizationId string, regionID string) ApiDeleteRegionRequest { - return ApiDeleteRegionRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - regionID: regionID, - } -} - -// Execute executes the request -func (a *DefaultAPIService) DeleteRegionExecute(r ApiDeleteRegionRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodDelete - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.DeleteRegion") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/regions/{regionID}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"regionID"+"}", url.PathEscape(parameterValueToString(r.regionID, "regionID")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiDeleteStackRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - stackId string - force *bool -} - -func (r ApiDeleteStackRequest) Force(force bool) ApiDeleteStackRequest { - r.force = &force - return r -} - -func (r ApiDeleteStackRequest) Execute() (*http.Response, error) { - return r.ApiService.DeleteStackExecute(r) -} - -/* -DeleteStack Delete stack - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param stackId - @return ApiDeleteStackRequest -*/ -func (a *DefaultAPIService) DeleteStack(ctx context.Context, organizationId string, stackId string) ApiDeleteStackRequest { - return ApiDeleteStackRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - stackId: stackId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) DeleteStackExecute(r ApiDeleteStackRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodDelete - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.DeleteStack") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/stacks/{stackId}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"stackId"+"}", url.PathEscape(parameterValueToString(r.stackId, "stackId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - if r.force != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "force", r.force, "form", "") - } - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiDeleteStackUserAccessRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - stackId string - userId string -} - -func (r ApiDeleteStackUserAccessRequest) Execute() (*http.Response, error) { - return r.ApiService.DeleteStackUserAccessExecute(r) -} - -/* -DeleteStackUserAccess Delete stack user access role within an organization - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param stackId - @param userId - @return ApiDeleteStackUserAccessRequest -*/ -func (a *DefaultAPIService) DeleteStackUserAccess(ctx context.Context, organizationId string, stackId string, userId string) ApiDeleteStackUserAccessRequest { - return ApiDeleteStackUserAccessRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - stackId: stackId, - userId: userId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) DeleteStackUserAccessExecute(r ApiDeleteStackUserAccessRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodDelete - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.DeleteStackUserAccess") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/stacks/{stackId}/users/{userId}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"stackId"+"}", url.PathEscape(parameterValueToString(r.stackId, "stackId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"userId"+"}", url.PathEscape(parameterValueToString(r.userId, "userId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiDeleteUserFromOrganizationRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - userId string -} - -func (r ApiDeleteUserFromOrganizationRequest) Execute() (*http.Response, error) { - return r.ApiService.DeleteUserFromOrganizationExecute(r) -} - -/* -DeleteUserFromOrganization delete user from organization - -The owner of the organization can remove anyone while each user can leave any organization where it is not owner. - - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param userId - @return ApiDeleteUserFromOrganizationRequest -*/ -func (a *DefaultAPIService) DeleteUserFromOrganization(ctx context.Context, organizationId string, userId string) ApiDeleteUserFromOrganizationRequest { - return ApiDeleteUserFromOrganizationRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - userId: userId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) DeleteUserFromOrganizationExecute(r ApiDeleteUserFromOrganizationRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodDelete - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.DeleteUserFromOrganization") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/users/{userId}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"userId"+"}", url.PathEscape(parameterValueToString(r.userId, "userId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiDisableModuleRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - stackId string - name *string -} - -func (r ApiDisableModuleRequest) Name(name string) ApiDisableModuleRequest { - r.name = &name - return r -} - -func (r ApiDisableModuleRequest) Execute() (*http.Response, error) { - return r.ApiService.DisableModuleExecute(r) -} - -/* -DisableModule disable module - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param stackId - @return ApiDisableModuleRequest -*/ -func (a *DefaultAPIService) DisableModule(ctx context.Context, organizationId string, stackId string) ApiDisableModuleRequest { - return ApiDisableModuleRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - stackId: stackId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) DisableModuleExecute(r ApiDisableModuleRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodDelete - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.DisableModule") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/stacks/{stackId}/modules" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"stackId"+"}", url.PathEscape(parameterValueToString(r.stackId, "stackId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - if r.name == nil { - return nil, reportError("name is required and must be specified") - } - - parameterAddToHeaderOrQuery(localVarQueryParams, "name", r.name, "form", "") - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiDisableStackRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - stackId string -} - -func (r ApiDisableStackRequest) Execute() (*http.Response, error) { - return r.ApiService.DisableStackExecute(r) -} - -/* -DisableStack Disable stack - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param stackId - @return ApiDisableStackRequest -*/ -func (a *DefaultAPIService) DisableStack(ctx context.Context, organizationId string, stackId string) ApiDisableStackRequest { - return ApiDisableStackRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - stackId: stackId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) DisableStackExecute(r ApiDisableStackRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPut - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.DisableStack") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/stacks/{stackId}/disable" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"stackId"+"}", url.PathEscape(parameterValueToString(r.stackId, "stackId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiDisableStargateRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - stackId string -} - -func (r ApiDisableStargateRequest) Execute() (*http.Response, error) { - return r.ApiService.DisableStargateExecute(r) -} - -/* -DisableStargate Disable stargate on a stack - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param stackId - @return ApiDisableStargateRequest -*/ -func (a *DefaultAPIService) DisableStargate(ctx context.Context, organizationId string, stackId string) ApiDisableStargateRequest { - return ApiDisableStargateRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - stackId: stackId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) DisableStargateExecute(r ApiDisableStargateRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPut - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.DisableStargate") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/stacks/{stackId}/stargate/disable" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"stackId"+"}", url.PathEscape(parameterValueToString(r.stackId, "stackId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiEnableModuleRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - stackId string - name *string -} - -func (r ApiEnableModuleRequest) Name(name string) ApiEnableModuleRequest { - r.name = &name - return r -} - -func (r ApiEnableModuleRequest) Execute() (*http.Response, error) { - return r.ApiService.EnableModuleExecute(r) -} - -/* -EnableModule enable module - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param stackId - @return ApiEnableModuleRequest -*/ -func (a *DefaultAPIService) EnableModule(ctx context.Context, organizationId string, stackId string) ApiEnableModuleRequest { - return ApiEnableModuleRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - stackId: stackId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) EnableModuleExecute(r ApiEnableModuleRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.EnableModule") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/stacks/{stackId}/modules" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"stackId"+"}", url.PathEscape(parameterValueToString(r.stackId, "stackId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - if r.name == nil { - return nil, reportError("name is required and must be specified") - } - - parameterAddToHeaderOrQuery(localVarQueryParams, "name", r.name, "form", "") - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiEnableStackRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - stackId string -} - -func (r ApiEnableStackRequest) Execute() (*http.Response, error) { - return r.ApiService.EnableStackExecute(r) -} - -/* -EnableStack Enable stack - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param stackId - @return ApiEnableStackRequest -*/ -func (a *DefaultAPIService) EnableStack(ctx context.Context, organizationId string, stackId string) ApiEnableStackRequest { - return ApiEnableStackRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - stackId: stackId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) EnableStackExecute(r ApiEnableStackRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPut - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.EnableStack") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/stacks/{stackId}/enable" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"stackId"+"}", url.PathEscape(parameterValueToString(r.stackId, "stackId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiEnableStargateRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - stackId string -} - -func (r ApiEnableStargateRequest) Execute() (*http.Response, error) { - return r.ApiService.EnableStargateExecute(r) -} - -/* -EnableStargate Enable stargate on a stack - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param stackId - @return ApiEnableStargateRequest -*/ -func (a *DefaultAPIService) EnableStargate(ctx context.Context, organizationId string, stackId string) ApiEnableStargateRequest { - return ApiEnableStargateRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - stackId: stackId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) EnableStargateExecute(r ApiEnableStargateRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPut - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.EnableStargate") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/stacks/{stackId}/stargate/enable" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"stackId"+"}", url.PathEscape(parameterValueToString(r.stackId, "stackId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiGetRegionRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - regionID string -} - -func (r ApiGetRegionRequest) Execute() (*GetRegionResponse, *http.Response, error) { - return r.ApiService.GetRegionExecute(r) -} - -/* -GetRegion Get region - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param regionID - @return ApiGetRegionRequest -*/ -func (a *DefaultAPIService) GetRegion(ctx context.Context, organizationId string, regionID string) ApiGetRegionRequest { - return ApiGetRegionRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - regionID: regionID, - } -} - -// Execute executes the request -// @return GetRegionResponse -func (a *DefaultAPIService) GetRegionExecute(r ApiGetRegionRequest) (*GetRegionResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *GetRegionResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.GetRegion") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/regions/{regionID}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"regionID"+"}", url.PathEscape(parameterValueToString(r.regionID, "regionID")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiGetRegionVersionsRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - regionID string -} - -func (r ApiGetRegionVersionsRequest) Execute() (*GetRegionVersionsResponse, *http.Response, error) { - return r.ApiService.GetRegionVersionsExecute(r) -} - -/* -GetRegionVersions Get region versions - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param regionID - @return ApiGetRegionVersionsRequest -*/ -func (a *DefaultAPIService) GetRegionVersions(ctx context.Context, organizationId string, regionID string) ApiGetRegionVersionsRequest { - return ApiGetRegionVersionsRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - regionID: regionID, - } -} - -// Execute executes the request -// @return GetRegionVersionsResponse -func (a *DefaultAPIService) GetRegionVersionsExecute(r ApiGetRegionVersionsRequest) (*GetRegionVersionsResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *GetRegionVersionsResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.GetRegionVersions") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/regions/{regionID}/versions" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"regionID"+"}", url.PathEscape(parameterValueToString(r.regionID, "regionID")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiGetServerInfoRequest struct { - ctx context.Context - ApiService *DefaultAPIService -} - -func (r ApiGetServerInfoRequest) Execute() (*ServerInfo, *http.Response, error) { - return r.ApiService.GetServerInfoExecute(r) -} - -/* -GetServerInfo Get server info - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiGetServerInfoRequest -*/ -func (a *DefaultAPIService) GetServerInfo(ctx context.Context) ApiGetServerInfoRequest { - return ApiGetServerInfoRequest{ - ApiService: a, - ctx: ctx, - } -} - -// Execute executes the request -// @return ServerInfo -func (a *DefaultAPIService) GetServerInfoExecute(r ApiGetServerInfoRequest) (*ServerInfo, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ServerInfo - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.GetServerInfo") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/_info" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiGetStackRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - stackId string -} - -func (r ApiGetStackRequest) Execute() (*CreateStackResponse, *http.Response, error) { - return r.ApiService.GetStackExecute(r) -} - -/* -GetStack Find stack - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param stackId - @return ApiGetStackRequest -*/ -func (a *DefaultAPIService) GetStack(ctx context.Context, organizationId string, stackId string) ApiGetStackRequest { - return ApiGetStackRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - stackId: stackId, - } -} - -// Execute executes the request -// @return CreateStackResponse -func (a *DefaultAPIService) GetStackExecute(r ApiGetStackRequest) (*CreateStackResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *CreateStackResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.GetStack") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/stacks/{stackId}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"stackId"+"}", url.PathEscape(parameterValueToString(r.stackId, "stackId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiListFeaturesRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string -} - -func (r ApiListFeaturesRequest) Execute() (*ListFeatures200Response, *http.Response, error) { - return r.ApiService.ListFeaturesExecute(r) -} - -/* -ListFeatures List features - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiListFeaturesRequest -*/ -func (a *DefaultAPIService) ListFeatures(ctx context.Context, organizationId string) ApiListFeaturesRequest { - return ApiListFeaturesRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -// @return ListFeatures200Response -func (a *DefaultAPIService) ListFeaturesExecute(r ApiListFeaturesRequest) (*ListFeatures200Response, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ListFeatures200Response - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListFeatures") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/features" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiListInvitationsRequest struct { - ctx context.Context - ApiService *DefaultAPIService - status *string - organization *string -} - -// Status of organizations -func (r ApiListInvitationsRequest) Status(status string) ApiListInvitationsRequest { - r.status = &status - return r -} - -// Status of organizations -func (r ApiListInvitationsRequest) Organization(organization string) ApiListInvitationsRequest { - r.organization = &organization - return r -} - -func (r ApiListInvitationsRequest) Execute() (*ListInvitationsResponse, *http.Response, error) { - return r.ApiService.ListInvitationsExecute(r) -} - -/* -ListInvitations List invitations of the user - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiListInvitationsRequest -*/ -func (a *DefaultAPIService) ListInvitations(ctx context.Context) ApiListInvitationsRequest { - return ApiListInvitationsRequest{ - ApiService: a, - ctx: ctx, - } -} - -// Execute executes the request -// @return ListInvitationsResponse -func (a *DefaultAPIService) ListInvitationsExecute(r ApiListInvitationsRequest) (*ListInvitationsResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ListInvitationsResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListInvitations") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/me/invitations" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - if r.status != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "status", r.status, "form", "") - } - if r.organization != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "organization", r.organization, "form", "") - } - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiListLogsRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - stackId *string - cursor *string - pageSize *int32 - action *Action - userId *string - key *string - value *string -} - -func (r ApiListLogsRequest) StackId(stackId string) ApiListLogsRequest { - r.stackId = &stackId - return r -} - -func (r ApiListLogsRequest) Cursor(cursor string) ApiListLogsRequest { - r.cursor = &cursor - return r -} - -func (r ApiListLogsRequest) PageSize(pageSize int32) ApiListLogsRequest { - r.pageSize = &pageSize - return r -} - -func (r ApiListLogsRequest) Action(action Action) ApiListLogsRequest { - r.action = &action - return r -} - -func (r ApiListLogsRequest) UserId(userId string) ApiListLogsRequest { - r.userId = &userId - return r -} - -func (r ApiListLogsRequest) Key(key string) ApiListLogsRequest { - r.key = &key - return r -} - -func (r ApiListLogsRequest) Value(value string) ApiListLogsRequest { - r.value = &value - return r -} - -func (r ApiListLogsRequest) Execute() (*LogCursor, *http.Response, error) { - return r.ApiService.ListLogsExecute(r) -} - -/* -ListLogs List logs - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiListLogsRequest -*/ -func (a *DefaultAPIService) ListLogs(ctx context.Context, organizationId string) ApiListLogsRequest { - return ApiListLogsRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -// @return LogCursor -func (a *DefaultAPIService) ListLogsExecute(r ApiListLogsRequest) (*LogCursor, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *LogCursor - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListLogs") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/logs" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - if r.stackId != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "stackId", r.stackId, "form", "") - } - if r.cursor != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "cursor", r.cursor, "form", "") - } - if r.pageSize != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "pageSize", r.pageSize, "form", "") - } - if r.action != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "action", r.action, "form", "") - } - if r.userId != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "userId", r.userId, "form", "") - } - if r.key != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "key", r.key, "form", "") - } - if r.value != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "value", r.value, "form", "") - } - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiListModulesRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - stackId string -} - -func (r ApiListModulesRequest) Execute() (*ListModulesResponse, *http.Response, error) { - return r.ApiService.ListModulesExecute(r) -} - -/* -ListModules List modules of a stack - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param stackId - @return ApiListModulesRequest -*/ -func (a *DefaultAPIService) ListModules(ctx context.Context, organizationId string, stackId string) ApiListModulesRequest { - return ApiListModulesRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - stackId: stackId, - } -} - -// Execute executes the request -// @return ListModulesResponse -func (a *DefaultAPIService) ListModulesExecute(r ApiListModulesRequest) (*ListModulesResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ListModulesResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListModules") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/stacks/{stackId}/modules" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"stackId"+"}", url.PathEscape(parameterValueToString(r.stackId, "stackId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiListOrganizationInvitationsRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - status *string -} - -// Status of organizations -func (r ApiListOrganizationInvitationsRequest) Status(status string) ApiListOrganizationInvitationsRequest { - r.status = &status - return r -} - -func (r ApiListOrganizationInvitationsRequest) Execute() (*ListInvitationsResponse, *http.Response, error) { - return r.ApiService.ListOrganizationInvitationsExecute(r) -} - -/* -ListOrganizationInvitations List invitations of the organization - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiListOrganizationInvitationsRequest -*/ -func (a *DefaultAPIService) ListOrganizationInvitations(ctx context.Context, organizationId string) ApiListOrganizationInvitationsRequest { - return ApiListOrganizationInvitationsRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -// @return ListInvitationsResponse -func (a *DefaultAPIService) ListOrganizationInvitationsExecute(r ApiListOrganizationInvitationsRequest) (*ListInvitationsResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ListInvitationsResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListOrganizationInvitations") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/invitations" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - if r.status != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "status", r.status, "form", "") - } - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiListOrganizationsRequest struct { - ctx context.Context - ApiService *DefaultAPIService - expand *bool -} - -func (r ApiListOrganizationsRequest) Expand(expand bool) ApiListOrganizationsRequest { - r.expand = &expand - return r -} - -func (r ApiListOrganizationsRequest) Execute() (*ListOrganizationExpandedResponse, *http.Response, error) { - return r.ApiService.ListOrganizationsExecute(r) -} - -/* -ListOrganizations List organizations of the connected user - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiListOrganizationsRequest -*/ -func (a *DefaultAPIService) ListOrganizations(ctx context.Context) ApiListOrganizationsRequest { - return ApiListOrganizationsRequest{ - ApiService: a, - ctx: ctx, - } -} - -// Execute executes the request -// @return ListOrganizationExpandedResponse -func (a *DefaultAPIService) ListOrganizationsExecute(r ApiListOrganizationsRequest) (*ListOrganizationExpandedResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ListOrganizationExpandedResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListOrganizations") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - if r.expand != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "expand", r.expand, "form", "") - } - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiListOrganizationsExpandedRequest struct { - ctx context.Context - ApiService *DefaultAPIService -} - -func (r ApiListOrganizationsExpandedRequest) Execute() (*ListOrganizationExpandedResponse, *http.Response, error) { - return r.ApiService.ListOrganizationsExpandedExecute(r) -} - -/* -ListOrganizationsExpanded List organizations of the connected user with expanded data - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiListOrganizationsExpandedRequest - -Deprecated -*/ -func (a *DefaultAPIService) ListOrganizationsExpanded(ctx context.Context) ApiListOrganizationsExpandedRequest { - return ApiListOrganizationsExpandedRequest{ - ApiService: a, - ctx: ctx, - } -} - -// Execute executes the request -// @return ListOrganizationExpandedResponse -// Deprecated -func (a *DefaultAPIService) ListOrganizationsExpandedExecute(r ApiListOrganizationsExpandedRequest) (*ListOrganizationExpandedResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ListOrganizationExpandedResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListOrganizationsExpanded") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/expanded" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiListRegionsRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string -} - -func (r ApiListRegionsRequest) Execute() (*ListRegionsResponse, *http.Response, error) { - return r.ApiService.ListRegionsExecute(r) -} - -/* -ListRegions List regions - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiListRegionsRequest -*/ -func (a *DefaultAPIService) ListRegions(ctx context.Context, organizationId string) ApiListRegionsRequest { - return ApiListRegionsRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -// @return ListRegionsResponse -func (a *DefaultAPIService) ListRegionsExecute(r ApiListRegionsRequest) (*ListRegionsResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ListRegionsResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListRegions") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/regions" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiListStackUsersAccessesRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - stackId string -} - -func (r ApiListStackUsersAccessesRequest) Execute() (*StackUserAccessResponse, *http.Response, error) { - return r.ApiService.ListStackUsersAccessesExecute(r) -} - -/* -ListStackUsersAccesses List stack users accesses within an organization - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param stackId - @return ApiListStackUsersAccessesRequest -*/ -func (a *DefaultAPIService) ListStackUsersAccesses(ctx context.Context, organizationId string, stackId string) ApiListStackUsersAccessesRequest { - return ApiListStackUsersAccessesRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - stackId: stackId, - } -} - -// Execute executes the request -// @return StackUserAccessResponse -func (a *DefaultAPIService) ListStackUsersAccessesExecute(r ApiListStackUsersAccessesRequest) (*StackUserAccessResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *StackUserAccessResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListStackUsersAccesses") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/stacks/{stackId}/users" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"stackId"+"}", url.PathEscape(parameterValueToString(r.stackId, "stackId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiListStacksRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - all *bool - deleted *bool -} - -// Include deleted and disabled stacks -func (r ApiListStacksRequest) All(all bool) ApiListStacksRequest { - r.all = &all - return r -} - -// Include deleted stacks -// Deprecated -func (r ApiListStacksRequest) Deleted(deleted bool) ApiListStacksRequest { - r.deleted = &deleted - return r -} - -func (r ApiListStacksRequest) Execute() (*ListStacksResponse, *http.Response, error) { - return r.ApiService.ListStacksExecute(r) -} - -/* -ListStacks List stacks - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiListStacksRequest -*/ -func (a *DefaultAPIService) ListStacks(ctx context.Context, organizationId string) ApiListStacksRequest { - return ApiListStacksRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -// @return ListStacksResponse -func (a *DefaultAPIService) ListStacksExecute(r ApiListStacksRequest) (*ListStacksResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ListStacksResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListStacks") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/stacks" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - if r.all != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "all", r.all, "form", "") - } - if r.deleted != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "deleted", r.deleted, "form", "") - } - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiListUsersOfOrganizationRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string -} - -func (r ApiListUsersOfOrganizationRequest) Execute() (*ListUsersResponse, *http.Response, error) { - return r.ApiService.ListUsersOfOrganizationExecute(r) -} - -/* -ListUsersOfOrganization List users of organization - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiListUsersOfOrganizationRequest -*/ -func (a *DefaultAPIService) ListUsersOfOrganization(ctx context.Context, organizationId string) ApiListUsersOfOrganizationRequest { - return ApiListUsersOfOrganizationRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -// @return ListUsersResponse -func (a *DefaultAPIService) ListUsersOfOrganizationExecute(r ApiListUsersOfOrganizationRequest) (*ListUsersResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ListUsersResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ListUsersOfOrganization") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/users" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiOrganizationClientCreateRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - createOrganizationClientRequest *CreateOrganizationClientRequest -} - -func (r ApiOrganizationClientCreateRequest) CreateOrganizationClientRequest(createOrganizationClientRequest CreateOrganizationClientRequest) ApiOrganizationClientCreateRequest { - r.createOrganizationClientRequest = &createOrganizationClientRequest - return r -} - -func (r ApiOrganizationClientCreateRequest) Execute() (*CreateOrganizationClientResponse, *http.Response, error) { - return r.ApiService.OrganizationClientCreateExecute(r) -} - -/* -OrganizationClientCreate Create organization client - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiOrganizationClientCreateRequest -*/ -func (a *DefaultAPIService) OrganizationClientCreate(ctx context.Context, organizationId string) ApiOrganizationClientCreateRequest { - return ApiOrganizationClientCreateRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -// @return CreateOrganizationClientResponse -func (a *DefaultAPIService) OrganizationClientCreateExecute(r ApiOrganizationClientCreateRequest) (*CreateOrganizationClientResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPost - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *CreateOrganizationClientResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.OrganizationClientCreate") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/clients" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - // body params - localVarPostBody = r.createOrganizationClientRequest - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiOrganizationClientDeleteRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - clientId string -} - -func (r ApiOrganizationClientDeleteRequest) Execute() (*http.Response, error) { - return r.ApiService.OrganizationClientDeleteExecute(r) -} - -/* -OrganizationClientDelete Delete organization client - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param clientId - @return ApiOrganizationClientDeleteRequest -*/ -func (a *DefaultAPIService) OrganizationClientDelete(ctx context.Context, organizationId string, clientId string) ApiOrganizationClientDeleteRequest { - return ApiOrganizationClientDeleteRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - clientId: clientId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) OrganizationClientDeleteExecute(r ApiOrganizationClientDeleteRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodDelete - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.OrganizationClientDelete") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/clients/{clientId}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"clientId"+"}", url.PathEscape(parameterValueToString(r.clientId, "clientId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiOrganizationClientReadRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - clientId string -} - -func (r ApiOrganizationClientReadRequest) Execute() (*ReadOrganizationClientResponse, *http.Response, error) { - return r.ApiService.OrganizationClientReadExecute(r) -} - -/* -OrganizationClientRead Read organization client - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param clientId - @return ApiOrganizationClientReadRequest -*/ -func (a *DefaultAPIService) OrganizationClientRead(ctx context.Context, organizationId string, clientId string) ApiOrganizationClientReadRequest { - return ApiOrganizationClientReadRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - clientId: clientId, - } -} - -// Execute executes the request -// @return ReadOrganizationClientResponse -func (a *DefaultAPIService) OrganizationClientReadExecute(r ApiOrganizationClientReadRequest) (*ReadOrganizationClientResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ReadOrganizationClientResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.OrganizationClientRead") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/clients/{clientId}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"clientId"+"}", url.PathEscape(parameterValueToString(r.clientId, "clientId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiOrganizationClientUpdateRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - clientId string - updateOrganizationClientRequest *UpdateOrganizationClientRequest -} - -func (r ApiOrganizationClientUpdateRequest) UpdateOrganizationClientRequest(updateOrganizationClientRequest UpdateOrganizationClientRequest) ApiOrganizationClientUpdateRequest { - r.updateOrganizationClientRequest = &updateOrganizationClientRequest - return r -} - -func (r ApiOrganizationClientUpdateRequest) Execute() (*http.Response, error) { - return r.ApiService.OrganizationClientUpdateExecute(r) -} - -/* -OrganizationClientUpdate Update organization client - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param clientId - @return ApiOrganizationClientUpdateRequest -*/ -func (a *DefaultAPIService) OrganizationClientUpdate(ctx context.Context, organizationId string, clientId string) ApiOrganizationClientUpdateRequest { - return ApiOrganizationClientUpdateRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - clientId: clientId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) OrganizationClientUpdateExecute(r ApiOrganizationClientUpdateRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPut - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.OrganizationClientUpdate") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/clients/{clientId}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"clientId"+"}", url.PathEscape(parameterValueToString(r.clientId, "clientId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - // body params - localVarPostBody = r.updateOrganizationClientRequest - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiOrganizationClientsReadRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - cursor *string - pageSize *int32 -} - -func (r ApiOrganizationClientsReadRequest) Cursor(cursor string) ApiOrganizationClientsReadRequest { - r.cursor = &cursor - return r -} - -func (r ApiOrganizationClientsReadRequest) PageSize(pageSize int32) ApiOrganizationClientsReadRequest { - r.pageSize = &pageSize - return r -} - -func (r ApiOrganizationClientsReadRequest) Execute() (*ReadOrganizationClientsResponse, *http.Response, error) { - return r.ApiService.OrganizationClientsReadExecute(r) -} - -/* -OrganizationClientsRead Read organization clients - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiOrganizationClientsReadRequest -*/ -func (a *DefaultAPIService) OrganizationClientsRead(ctx context.Context, organizationId string) ApiOrganizationClientsReadRequest { - return ApiOrganizationClientsReadRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -// @return ReadOrganizationClientsResponse -func (a *DefaultAPIService) OrganizationClientsReadExecute(r ApiOrganizationClientsReadRequest) (*ReadOrganizationClientsResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ReadOrganizationClientsResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.OrganizationClientsRead") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/clients" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - if r.cursor != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "cursor", r.cursor, "form", "") - } - if r.pageSize != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "pageSize", r.pageSize, "form", "") - } - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiReadAuthenticationProviderRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string -} - -func (r ApiReadAuthenticationProviderRequest) Execute() (*AuthenticationProviderResponse, *http.Response, error) { - return r.ApiService.ReadAuthenticationProviderExecute(r) -} - -/* -ReadAuthenticationProvider Read authentication provider - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiReadAuthenticationProviderRequest -*/ -func (a *DefaultAPIService) ReadAuthenticationProvider(ctx context.Context, organizationId string) ApiReadAuthenticationProviderRequest { - return ApiReadAuthenticationProviderRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -// @return AuthenticationProviderResponse -func (a *DefaultAPIService) ReadAuthenticationProviderExecute(r ApiReadAuthenticationProviderRequest) (*AuthenticationProviderResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *AuthenticationProviderResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ReadAuthenticationProvider") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/authentication-provider" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiReadConnectedUserRequest struct { - ctx context.Context - ApiService *DefaultAPIService -} - -func (r ApiReadConnectedUserRequest) Execute() (*ReadUserResponse, *http.Response, error) { - return r.ApiService.ReadConnectedUserExecute(r) -} - -/* -ReadConnectedUser Read user - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @return ApiReadConnectedUserRequest -*/ -func (a *DefaultAPIService) ReadConnectedUser(ctx context.Context) ApiReadConnectedUserRequest { - return ApiReadConnectedUserRequest{ - ApiService: a, - ctx: ctx, - } -} - -// Execute executes the request -// @return ReadUserResponse -func (a *DefaultAPIService) ReadConnectedUserExecute(r ApiReadConnectedUserRequest) (*ReadUserResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ReadUserResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ReadConnectedUser") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/me" - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiReadOrganizationRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - expand *bool -} - -func (r ApiReadOrganizationRequest) Expand(expand bool) ApiReadOrganizationRequest { - r.expand = &expand - return r -} - -func (r ApiReadOrganizationRequest) Execute() (*ReadOrganizationResponse, *http.Response, error) { - return r.ApiService.ReadOrganizationExecute(r) -} - -/* -ReadOrganization Read organization - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiReadOrganizationRequest -*/ -func (a *DefaultAPIService) ReadOrganization(ctx context.Context, organizationId string) ApiReadOrganizationRequest { - return ApiReadOrganizationRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -// @return ReadOrganizationResponse -func (a *DefaultAPIService) ReadOrganizationExecute(r ApiReadOrganizationRequest) (*ReadOrganizationResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ReadOrganizationResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ReadOrganization") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - if r.expand != nil { - parameterAddToHeaderOrQuery(localVarQueryParams, "expand", r.expand, "form", "") - } - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiReadOrganizationClientRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string -} - -func (r ApiReadOrganizationClientRequest) Execute() (*CreateClientResponseResponse, *http.Response, error) { - return r.ApiService.ReadOrganizationClientExecute(r) -} - -/* -ReadOrganizationClient Read organization client (DEPRECATED) (until 12/31/2025) - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiReadOrganizationClientRequest - -Deprecated -*/ -func (a *DefaultAPIService) ReadOrganizationClient(ctx context.Context, organizationId string) ApiReadOrganizationClientRequest { - return ApiReadOrganizationClientRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -// @return CreateClientResponseResponse -// Deprecated -func (a *DefaultAPIService) ReadOrganizationClientExecute(r ApiReadOrganizationClientRequest) (*CreateClientResponseResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *CreateClientResponseResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ReadOrganizationClient") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/client" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiReadStackUserAccessRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - stackId string - userId string -} - -func (r ApiReadStackUserAccessRequest) Execute() (*ReadStackUserAccess, *http.Response, error) { - return r.ApiService.ReadStackUserAccessExecute(r) -} - -/* -ReadStackUserAccess Read stack user access role within an organization - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param stackId - @param userId - @return ApiReadStackUserAccessRequest -*/ -func (a *DefaultAPIService) ReadStackUserAccess(ctx context.Context, organizationId string, stackId string, userId string) ApiReadStackUserAccessRequest { - return ApiReadStackUserAccessRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - stackId: stackId, - userId: userId, - } -} - -// Execute executes the request -// @return ReadStackUserAccess -func (a *DefaultAPIService) ReadStackUserAccessExecute(r ApiReadStackUserAccessRequest) (*ReadStackUserAccess, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ReadStackUserAccess - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ReadStackUserAccess") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/stacks/{stackId}/users/{userId}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"stackId"+"}", url.PathEscape(parameterValueToString(r.stackId, "stackId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"userId"+"}", url.PathEscape(parameterValueToString(r.userId, "userId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiReadUserOfOrganizationRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - userId string -} - -func (r ApiReadUserOfOrganizationRequest) Execute() (*ReadOrganizationUserResponse, *http.Response, error) { - return r.ApiService.ReadUserOfOrganizationExecute(r) -} - -/* -ReadUserOfOrganization Read user of organization - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param userId - @return ApiReadUserOfOrganizationRequest -*/ -func (a *DefaultAPIService) ReadUserOfOrganization(ctx context.Context, organizationId string, userId string) ApiReadUserOfOrganizationRequest { - return ApiReadUserOfOrganizationRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - userId: userId, - } -} - -// Execute executes the request -// @return ReadOrganizationUserResponse -func (a *DefaultAPIService) ReadUserOfOrganizationExecute(r ApiReadUserOfOrganizationRequest) (*ReadOrganizationUserResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodGet - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ReadOrganizationUserResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.ReadUserOfOrganization") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/users/{userId}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"userId"+"}", url.PathEscape(parameterValueToString(r.userId, "userId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiRestoreStackRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - stackId string -} - -func (r ApiRestoreStackRequest) Execute() (*CreateStackResponse, *http.Response, error) { - return r.ApiService.RestoreStackExecute(r) -} - -/* -RestoreStack Restore stack - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param stackId - @return ApiRestoreStackRequest -*/ -func (a *DefaultAPIService) RestoreStack(ctx context.Context, organizationId string, stackId string) ApiRestoreStackRequest { - return ApiRestoreStackRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - stackId: stackId, - } -} - -// Execute executes the request -// @return CreateStackResponse -func (a *DefaultAPIService) RestoreStackExecute(r ApiRestoreStackRequest) (*CreateStackResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPut - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *CreateStackResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.RestoreStack") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/stacks/{stackId}/restore" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"stackId"+"}", url.PathEscape(parameterValueToString(r.stackId, "stackId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiUpdateOrganizationRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - organizationData *OrganizationData -} - -func (r ApiUpdateOrganizationRequest) OrganizationData(organizationData OrganizationData) ApiUpdateOrganizationRequest { - r.organizationData = &organizationData - return r -} - -func (r ApiUpdateOrganizationRequest) Execute() (*ReadOrganizationResponse, *http.Response, error) { - return r.ApiService.UpdateOrganizationExecute(r) -} - -/* -UpdateOrganization Update organization - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiUpdateOrganizationRequest -*/ -func (a *DefaultAPIService) UpdateOrganization(ctx context.Context, organizationId string) ApiUpdateOrganizationRequest { - return ApiUpdateOrganizationRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -// @return ReadOrganizationResponse -func (a *DefaultAPIService) UpdateOrganizationExecute(r ApiUpdateOrganizationRequest) (*ReadOrganizationResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPut - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *ReadOrganizationResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.UpdateOrganization") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - // body params - localVarPostBody = r.organizationData - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiUpdateStackRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - stackId string - updateStackRequest *UpdateStackRequest -} - -func (r ApiUpdateStackRequest) UpdateStackRequest(updateStackRequest UpdateStackRequest) ApiUpdateStackRequest { - r.updateStackRequest = &updateStackRequest - return r -} - -func (r ApiUpdateStackRequest) Execute() (*CreateStackResponse, *http.Response, error) { - return r.ApiService.UpdateStackExecute(r) -} - -/* -UpdateStack Update stack - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param stackId - @return ApiUpdateStackRequest -*/ -func (a *DefaultAPIService) UpdateStack(ctx context.Context, organizationId string, stackId string) ApiUpdateStackRequest { - return ApiUpdateStackRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - stackId: stackId, - } -} - -// Execute executes the request -// @return CreateStackResponse -func (a *DefaultAPIService) UpdateStackExecute(r ApiUpdateStackRequest) (*CreateStackResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPut - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *CreateStackResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.UpdateStack") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/stacks/{stackId}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"stackId"+"}", url.PathEscape(parameterValueToString(r.stackId, "stackId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - // body params - localVarPostBody = r.updateStackRequest - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiUpgradeStackRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - stackId string - stackVersion *StackVersion -} - -func (r ApiUpgradeStackRequest) StackVersion(stackVersion StackVersion) ApiUpgradeStackRequest { - r.stackVersion = &stackVersion - return r -} - -func (r ApiUpgradeStackRequest) Execute() (*http.Response, error) { - return r.ApiService.UpgradeStackExecute(r) -} - -/* -UpgradeStack Upgrade stack - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param stackId - @return ApiUpgradeStackRequest -*/ -func (a *DefaultAPIService) UpgradeStack(ctx context.Context, organizationId string, stackId string) ApiUpgradeStackRequest { - return ApiUpgradeStackRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - stackId: stackId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) UpgradeStackExecute(r ApiUpgradeStackRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPut - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.UpgradeStack") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/stacks/{stackId}/upgrade" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"stackId"+"}", url.PathEscape(parameterValueToString(r.stackId, "stackId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - // body params - localVarPostBody = r.stackVersion - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiUpsertAuthenticationProviderRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - body *AuthenticationProviderData -} - -func (r ApiUpsertAuthenticationProviderRequest) Body(body AuthenticationProviderData) ApiUpsertAuthenticationProviderRequest { - r.body = &body - return r -} - -func (r ApiUpsertAuthenticationProviderRequest) Execute() (*AuthenticationProviderResponse, *http.Response, error) { - return r.ApiService.UpsertAuthenticationProviderExecute(r) -} - -/* -UpsertAuthenticationProvider Upsert an authentication provider - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @return ApiUpsertAuthenticationProviderRequest -*/ -func (a *DefaultAPIService) UpsertAuthenticationProvider(ctx context.Context, organizationId string) ApiUpsertAuthenticationProviderRequest { - return ApiUpsertAuthenticationProviderRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - } -} - -// Execute executes the request -// @return AuthenticationProviderResponse -func (a *DefaultAPIService) UpsertAuthenticationProviderExecute(r ApiUpsertAuthenticationProviderRequest) (*AuthenticationProviderResponse, *http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPut - localVarPostBody interface{} - formFiles []formFile - localVarReturnValue *AuthenticationProviderResponse - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.UpsertAuthenticationProvider") - if err != nil { - return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/authentication-provider" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - // body params - localVarPostBody = r.body - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return localVarReturnValue, nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarReturnValue, localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarReturnValue, localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarReturnValue, localVarHTTPResponse, newErr - } - - err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: err.Error(), - } - return localVarReturnValue, localVarHTTPResponse, newErr - } - - return localVarReturnValue, localVarHTTPResponse, nil -} - -type ApiUpsertOrganizationUserRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - userId string - updateOrganizationUserRequest *UpdateOrganizationUserRequest -} - -func (r ApiUpsertOrganizationUserRequest) UpdateOrganizationUserRequest(updateOrganizationUserRequest UpdateOrganizationUserRequest) ApiUpsertOrganizationUserRequest { - r.updateOrganizationUserRequest = &updateOrganizationUserRequest - return r -} - -func (r ApiUpsertOrganizationUserRequest) Execute() (*http.Response, error) { - return r.ApiService.UpsertOrganizationUserExecute(r) -} - -/* -UpsertOrganizationUser Update user within an organization - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param userId - @return ApiUpsertOrganizationUserRequest -*/ -func (a *DefaultAPIService) UpsertOrganizationUser(ctx context.Context, organizationId string, userId string) ApiUpsertOrganizationUserRequest { - return ApiUpsertOrganizationUserRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - userId: userId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) UpsertOrganizationUserExecute(r ApiUpsertOrganizationUserRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPut - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.UpsertOrganizationUser") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/users/{userId}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"userId"+"}", url.PathEscape(parameterValueToString(r.userId, "userId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - // body params - localVarPostBody = r.updateOrganizationUserRequest - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} - -type ApiUpsertStackUserAccessRequest struct { - ctx context.Context - ApiService *DefaultAPIService - organizationId string - stackId string - userId string - updateStackUserRequest *UpdateStackUserRequest -} - -func (r ApiUpsertStackUserAccessRequest) UpdateStackUserRequest(updateStackUserRequest UpdateStackUserRequest) ApiUpsertStackUserAccessRequest { - r.updateStackUserRequest = &updateStackUserRequest - return r -} - -func (r ApiUpsertStackUserAccessRequest) Execute() (*http.Response, error) { - return r.ApiService.UpsertStackUserAccessExecute(r) -} - -/* -UpsertStackUserAccess Update stack user access role within an organization - - @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background(). - @param organizationId - @param stackId - @param userId - @return ApiUpsertStackUserAccessRequest -*/ -func (a *DefaultAPIService) UpsertStackUserAccess(ctx context.Context, organizationId string, stackId string, userId string) ApiUpsertStackUserAccessRequest { - return ApiUpsertStackUserAccessRequest{ - ApiService: a, - ctx: ctx, - organizationId: organizationId, - stackId: stackId, - userId: userId, - } -} - -// Execute executes the request -func (a *DefaultAPIService) UpsertStackUserAccessExecute(r ApiUpsertStackUserAccessRequest) (*http.Response, error) { - var ( - localVarHTTPMethod = http.MethodPut - localVarPostBody interface{} - formFiles []formFile - ) - - localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "DefaultAPIService.UpsertStackUserAccess") - if err != nil { - return nil, &GenericOpenAPIError{error: err.Error()} - } - - localVarPath := localBasePath + "/organizations/{organizationId}/stacks/{stackId}/users/{userId}" - localVarPath = strings.Replace(localVarPath, "{"+"organizationId"+"}", url.PathEscape(parameterValueToString(r.organizationId, "organizationId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"stackId"+"}", url.PathEscape(parameterValueToString(r.stackId, "stackId")), -1) - localVarPath = strings.Replace(localVarPath, "{"+"userId"+"}", url.PathEscape(parameterValueToString(r.userId, "userId")), -1) - - localVarHeaderParams := make(map[string]string) - localVarQueryParams := url.Values{} - localVarFormParams := url.Values{} - - // to determine the Content-Type header - localVarHTTPContentTypes := []string{"application/json"} - - // set Content-Type header - localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) - if localVarHTTPContentType != "" { - localVarHeaderParams["Content-Type"] = localVarHTTPContentType - } - - // to determine the Accept header - localVarHTTPHeaderAccepts := []string{"application/json"} - - // set Accept header - localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) - if localVarHTTPHeaderAccept != "" { - localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept - } - // body params - localVarPostBody = r.updateStackUserRequest - req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles) - if err != nil { - return nil, err - } - - localVarHTTPResponse, err := a.client.callAPI(req) - if err != nil || localVarHTTPResponse == nil { - return localVarHTTPResponse, err - } - - localVarBody, err := io.ReadAll(localVarHTTPResponse.Body) - localVarHTTPResponse.Body.Close() - localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody)) - if err != nil { - return localVarHTTPResponse, err - } - - if localVarHTTPResponse.StatusCode >= 300 { - newErr := &GenericOpenAPIError{ - body: localVarBody, - error: localVarHTTPResponse.Status, - } - var v Error - err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) - if err != nil { - newErr.error = err.Error() - return localVarHTTPResponse, newErr - } - newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v) - newErr.model = v - return localVarHTTPResponse, newErr - } - - return localVarHTTPResponse, nil -} diff --git a/membershipclient/client.go b/membershipclient/client.go deleted file mode 100644 index 48bf5c7d..00000000 --- a/membershipclient/client.go +++ /dev/null @@ -1,668 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "bytes" - "context" - "encoding/json" - "encoding/xml" - "errors" - "fmt" - "io" - "log" - "mime/multipart" - "net/http" - "net/http/httputil" - "net/url" - "os" - "path/filepath" - "reflect" - "regexp" - "strconv" - "strings" - "time" - "unicode/utf8" - - "golang.org/x/oauth2" -) - -var ( - JsonCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?json)`) - XmlCheck = regexp.MustCompile(`(?i:(?:application|text)/(?:[^;]+\+)?xml)`) - queryParamSplit = regexp.MustCompile(`(^|&)([^&]+)`) - queryDescape = strings.NewReplacer( "%5B", "[", "%5D", "]" ) -) - -// APIClient manages communication with the Membership API API v0.1.0 -// In most cases there should be only one, shared, APIClient. -type APIClient struct { - cfg *Configuration - common service // Reuse a single struct instead of allocating one for each service on the heap. - - // API Services - - DefaultAPI *DefaultAPIService -} - -type service struct { - client *APIClient -} - -// NewAPIClient creates a new API client. Requires a userAgent string describing your application. -// optionally a custom http.Client to allow for advanced features such as caching. -func NewAPIClient(cfg *Configuration) *APIClient { - if cfg.HTTPClient == nil { - cfg.HTTPClient = http.DefaultClient - } - - c := &APIClient{} - c.cfg = cfg - c.common.client = c - - // API Services - c.DefaultAPI = (*DefaultAPIService)(&c.common) - - return c -} - -func atoi(in string) (int, error) { - return strconv.Atoi(in) -} - -// selectHeaderContentType select a content type from the available list. -func selectHeaderContentType(contentTypes []string) string { - if len(contentTypes) == 0 { - return "" - } - if contains(contentTypes, "application/json") { - return "application/json" - } - return contentTypes[0] // use the first content type specified in 'consumes' -} - -// selectHeaderAccept join all accept types and return -func selectHeaderAccept(accepts []string) string { - if len(accepts) == 0 { - return "" - } - - if contains(accepts, "application/json") { - return "application/json" - } - - return strings.Join(accepts, ",") -} - -// contains is a case insensitive match, finding needle in a haystack -func contains(haystack []string, needle string) bool { - for _, a := range haystack { - if strings.EqualFold(a, needle) { - return true - } - } - return false -} - -// Verify optional parameters are of the correct type. -func typeCheckParameter(obj interface{}, expected string, name string) error { - // Make sure there is an object. - if obj == nil { - return nil - } - - // Check the type is as expected. - if reflect.TypeOf(obj).String() != expected { - return fmt.Errorf("expected %s to be of type %s but received %s", name, expected, reflect.TypeOf(obj).String()) - } - return nil -} - -func parameterValueToString( obj interface{}, key string ) string { - if reflect.TypeOf(obj).Kind() != reflect.Ptr { - if actualObj, ok := obj.(interface{ GetActualInstanceValue() interface{} }); ok { - return fmt.Sprintf("%v", actualObj.GetActualInstanceValue()) - } - - return fmt.Sprintf("%v", obj) - } - var param,ok = obj.(MappedNullable) - if !ok { - return "" - } - dataMap,err := param.ToMap() - if err != nil { - return "" - } - return fmt.Sprintf("%v", dataMap[key]) -} - -// parameterAddToHeaderOrQuery adds the provided object to the request header or url query -// supporting deep object syntax -func parameterAddToHeaderOrQuery(headerOrQueryParams interface{}, keyPrefix string, obj interface{}, style string, collectionType string) { - var v = reflect.ValueOf(obj) - var value = "" - if v == reflect.ValueOf(nil) { - value = "null" - } else { - switch v.Kind() { - case reflect.Invalid: - value = "invalid" - - case reflect.Struct: - if t,ok := obj.(MappedNullable); ok { - dataMap,err := t.ToMap() - if err != nil { - return - } - parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, dataMap, style, collectionType) - return - } - if t, ok := obj.(time.Time); ok { - parameterAddToHeaderOrQuery(headerOrQueryParams, keyPrefix, t.Format(time.RFC3339Nano), style, collectionType) - return - } - value = v.Type().String() + " value" - case reflect.Slice: - var indValue = reflect.ValueOf(obj) - if indValue == reflect.ValueOf(nil) { - return - } - var lenIndValue = indValue.Len() - for i:=0;i 0 || (len(formFiles) > 0) { - if body != nil { - return nil, errors.New("Cannot specify postBody and multipart form at the same time.") - } - body = &bytes.Buffer{} - w := multipart.NewWriter(body) - - for k, v := range formParams { - for _, iv := range v { - if strings.HasPrefix(k, "@") { // file - err = addFile(w, k[1:], iv) - if err != nil { - return nil, err - } - } else { // form value - w.WriteField(k, iv) - } - } - } - for _, formFile := range formFiles { - if len(formFile.fileBytes) > 0 && formFile.fileName != "" { - w.Boundary() - part, err := w.CreateFormFile(formFile.formFileName, filepath.Base(formFile.fileName)) - if err != nil { - return nil, err - } - _, err = part.Write(formFile.fileBytes) - if err != nil { - return nil, err - } - } - } - - // Set the Boundary in the Content-Type - headerParams["Content-Type"] = w.FormDataContentType() - - // Set Content-Length - headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) - w.Close() - } - - if strings.HasPrefix(headerParams["Content-Type"], "application/x-www-form-urlencoded") && len(formParams) > 0 { - if body != nil { - return nil, errors.New("Cannot specify postBody and x-www-form-urlencoded form at the same time.") - } - body = &bytes.Buffer{} - body.WriteString(formParams.Encode()) - // Set Content-Length - headerParams["Content-Length"] = fmt.Sprintf("%d", body.Len()) - } - - // Setup path and query parameters - url, err := url.Parse(path) - if err != nil { - return nil, err - } - - // Override request host, if applicable - if c.cfg.Host != "" { - url.Host = c.cfg.Host - } - - // Override request scheme, if applicable - if c.cfg.Scheme != "" { - url.Scheme = c.cfg.Scheme - } - - // Adding Query Param - query := url.Query() - for k, v := range queryParams { - for _, iv := range v { - query.Add(k, iv) - } - } - - // Encode the parameters. - url.RawQuery = queryParamSplit.ReplaceAllStringFunc(query.Encode(), func(s string) string { - pieces := strings.Split(s, "=") - pieces[0] = queryDescape.Replace(pieces[0]) - return strings.Join(pieces, "=") - }) - - // Generate a new request - if body != nil { - localVarRequest, err = http.NewRequest(method, url.String(), body) - } else { - localVarRequest, err = http.NewRequest(method, url.String(), nil) - } - if err != nil { - return nil, err - } - - // add header parameters, if any - if len(headerParams) > 0 { - headers := http.Header{} - for h, v := range headerParams { - headers[h] = []string{v} - } - localVarRequest.Header = headers - } - - // Add the user agent to the request. - localVarRequest.Header.Add("User-Agent", c.cfg.UserAgent) - - if ctx != nil { - // add context to the request - localVarRequest = localVarRequest.WithContext(ctx) - - // Walk through any authentication. - - // OAuth2 authentication - if tok, ok := ctx.Value(ContextOAuth2).(oauth2.TokenSource); ok { - // We were able to grab an oauth2 token from the context - var latestToken *oauth2.Token - if latestToken, err = tok.Token(); err != nil { - return nil, err - } - - latestToken.SetAuthHeader(localVarRequest) - } - - } - - for header, value := range c.cfg.DefaultHeader { - localVarRequest.Header.Add(header, value) - } - return localVarRequest, nil -} - -func (c *APIClient) decode(v interface{}, b []byte, contentType string) (err error) { - if len(b) == 0 { - return nil - } - if s, ok := v.(*string); ok { - *s = string(b) - return nil - } - if f, ok := v.(*os.File); ok { - f, err = os.CreateTemp("", "HttpClientFile") - if err != nil { - return - } - _, err = f.Write(b) - if err != nil { - return - } - _, err = f.Seek(0, io.SeekStart) - return - } - if f, ok := v.(**os.File); ok { - *f, err = os.CreateTemp("", "HttpClientFile") - if err != nil { - return - } - _, err = (*f).Write(b) - if err != nil { - return - } - _, err = (*f).Seek(0, io.SeekStart) - return - } - if XmlCheck.MatchString(contentType) { - if err = xml.Unmarshal(b, v); err != nil { - return err - } - return nil - } - if JsonCheck.MatchString(contentType) { - if actualObj, ok := v.(interface{ GetActualInstance() interface{} }); ok { // oneOf, anyOf schemas - if unmarshalObj, ok := actualObj.(interface{ UnmarshalJSON([]byte) error }); ok { // make sure it has UnmarshalJSON defined - if err = unmarshalObj.UnmarshalJSON(b); err != nil { - return err - } - } else { - return errors.New("Unknown type with GetActualInstance but no unmarshalObj.UnmarshalJSON defined") - } - } else if err = json.Unmarshal(b, v); err != nil { // simple model - return err - } - return nil - } - return errors.New("undefined response type") -} - -// Add a file to the multipart request -func addFile(w *multipart.Writer, fieldName, path string) error { - file, err := os.Open(filepath.Clean(path)) - if err != nil { - return err - } - err = file.Close() - if err != nil { - return err - } - - part, err := w.CreateFormFile(fieldName, filepath.Base(path)) - if err != nil { - return err - } - _, err = io.Copy(part, file) - - return err -} - -// Set request body from an interface{} -func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) { - if bodyBuf == nil { - bodyBuf = &bytes.Buffer{} - } - - if reader, ok := body.(io.Reader); ok { - _, err = bodyBuf.ReadFrom(reader) - } else if fp, ok := body.(*os.File); ok { - _, err = bodyBuf.ReadFrom(fp) - } else if b, ok := body.([]byte); ok { - _, err = bodyBuf.Write(b) - } else if s, ok := body.(string); ok { - _, err = bodyBuf.WriteString(s) - } else if s, ok := body.(*string); ok { - _, err = bodyBuf.WriteString(*s) - } else if JsonCheck.MatchString(contentType) { - err = json.NewEncoder(bodyBuf).Encode(body) - } else if XmlCheck.MatchString(contentType) { - var bs []byte - bs, err = xml.Marshal(body) - if err == nil { - bodyBuf.Write(bs) - } - } - - if err != nil { - return nil, err - } - - if bodyBuf.Len() == 0 { - err = fmt.Errorf("invalid body type %s\n", contentType) - return nil, err - } - return bodyBuf, nil -} - -// detectContentType method is used to figure out `Request.Body` content type for request header -func detectContentType(body interface{}) string { - contentType := "text/plain; charset=utf-8" - kind := reflect.TypeOf(body).Kind() - - switch kind { - case reflect.Struct, reflect.Map, reflect.Ptr: - contentType = "application/json; charset=utf-8" - case reflect.String: - contentType = "text/plain; charset=utf-8" - default: - if b, ok := body.([]byte); ok { - contentType = http.DetectContentType(b) - } else if kind == reflect.Slice { - contentType = "application/json; charset=utf-8" - } - } - - return contentType -} - -// Ripped from https://github.com/gregjones/httpcache/blob/master/httpcache.go -type cacheControl map[string]string - -func parseCacheControl(headers http.Header) cacheControl { - cc := cacheControl{} - ccHeader := headers.Get("Cache-Control") - for _, part := range strings.Split(ccHeader, ",") { - part = strings.Trim(part, " ") - if part == "" { - continue - } - if strings.ContainsRune(part, '=') { - keyval := strings.Split(part, "=") - cc[strings.Trim(keyval[0], " ")] = strings.Trim(keyval[1], ",") - } else { - cc[part] = "" - } - } - return cc -} - -// CacheExpires helper function to determine remaining time before repeating a request. -func CacheExpires(r *http.Response) time.Time { - // Figure out when the cache expires. - var expires time.Time - now, err := time.Parse(time.RFC1123, r.Header.Get("date")) - if err != nil { - return time.Now() - } - respCacheControl := parseCacheControl(r.Header) - - if maxAge, ok := respCacheControl["max-age"]; ok { - lifetime, err := time.ParseDuration(maxAge + "s") - if err != nil { - expires = now - } else { - expires = now.Add(lifetime) - } - } else { - expiresHeader := r.Header.Get("Expires") - if expiresHeader != "" { - expires, err = time.Parse(time.RFC1123, expiresHeader) - if err != nil { - expires = now - } - } - } - return expires -} - -func strlen(s string) int { - return utf8.RuneCountInString(s) -} - -// GenericOpenAPIError Provides access to the body, error and model on returned errors. -type GenericOpenAPIError struct { - body []byte - error string - model interface{} -} - -// Error returns non-empty string if there was an error. -func (e GenericOpenAPIError) Error() string { - return e.error -} - -// Body returns the raw bytes of the response -func (e GenericOpenAPIError) Body() []byte { - return e.body -} - -// Model returns the unpacked model of the error -func (e GenericOpenAPIError) Model() interface{} { - return e.model -} - -// format error message using title and detail when model implements rfc7807 -func formatErrorMessage(status string, v interface{}) string { - str := "" - metaValue := reflect.ValueOf(v).Elem() - - if metaValue.Kind() == reflect.Struct { - field := metaValue.FieldByName("Title") - if field != (reflect.Value{}) { - str = fmt.Sprintf("%s", field.Interface()) - } - - field = metaValue.FieldByName("Detail") - if field != (reflect.Value{}) { - str = fmt.Sprintf("%s (%s)", str, field.Interface()) - } - } - - return strings.TrimSpace(fmt.Sprintf("%s %s", status, str)) -} diff --git a/membershipclient/configuration.go b/membershipclient/configuration.go deleted file mode 100644 index e9227064..00000000 --- a/membershipclient/configuration.go +++ /dev/null @@ -1,218 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "context" - "fmt" - "net/http" - "strings" -) - -// contextKeys are used to identify the type of value in the context. -// Since these are string, it is possible to get a short description of the -// context key for logging and debugging using key.String(). - -type contextKey string - -func (c contextKey) String() string { - return "auth " + string(c) -} - -var ( - // ContextOAuth2 takes an oauth2.TokenSource as authentication for the request. - ContextOAuth2 = contextKey("token") - - // ContextServerIndex uses a server configuration from the index. - ContextServerIndex = contextKey("serverIndex") - - // ContextOperationServerIndices uses a server configuration from the index mapping. - ContextOperationServerIndices = contextKey("serverOperationIndices") - - // ContextServerVariables overrides a server configuration variables. - ContextServerVariables = contextKey("serverVariables") - - // ContextOperationServerVariables overrides a server configuration variables using operation specific values. - ContextOperationServerVariables = contextKey("serverOperationVariables") -) - -// BasicAuth provides basic http authentication to a request passed via context using ContextBasicAuth -type BasicAuth struct { - UserName string `json:"userName,omitempty"` - Password string `json:"password,omitempty"` -} - -// APIKey provides API key based authentication to a request passed via context using ContextAPIKey -type APIKey struct { - Key string - Prefix string -} - -// ServerVariable stores the information about a server variable -type ServerVariable struct { - Description string - DefaultValue string - EnumValues []string -} - -// ServerConfiguration stores the information about a server -type ServerConfiguration struct { - URL string - Description string - Variables map[string]ServerVariable -} - -// ServerConfigurations stores multiple ServerConfiguration items -type ServerConfigurations []ServerConfiguration - -// Configuration stores the configuration of the API client -type Configuration struct { - Host string `json:"host,omitempty"` - Scheme string `json:"scheme,omitempty"` - DefaultHeader map[string]string `json:"defaultHeader,omitempty"` - UserAgent string `json:"userAgent,omitempty"` - Debug bool `json:"debug,omitempty"` - Servers ServerConfigurations - OperationServers map[string]ServerConfigurations - HTTPClient *http.Client -} - -// NewConfiguration returns a new Configuration object -func NewConfiguration() *Configuration { - cfg := &Configuration{ - DefaultHeader: make(map[string]string), - UserAgent: "OpenAPI-Generator/latest/go", - Debug: false, - Servers: ServerConfigurations{ - { - URL: "http://localhost:8080", - Description: "Local server", - }, - }, - OperationServers: map[string]ServerConfigurations{ - }, - } - return cfg -} - -// AddDefaultHeader adds a new HTTP header to the default header in the request -func (c *Configuration) AddDefaultHeader(key string, value string) { - c.DefaultHeader[key] = value -} - -// URL formats template on a index using given variables -func (sc ServerConfigurations) URL(index int, variables map[string]string) (string, error) { - if index < 0 || len(sc) <= index { - return "", fmt.Errorf("index %v out of range %v", index, len(sc)-1) - } - server := sc[index] - url := server.URL - - // go through variables and replace placeholders - for name, variable := range server.Variables { - if value, ok := variables[name]; ok { - found := bool(len(variable.EnumValues) == 0) - for _, enumValue := range variable.EnumValues { - if value == enumValue { - found = true - } - } - if !found { - return "", fmt.Errorf("the variable %s in the server URL has invalid value %v. Must be %v", name, value, variable.EnumValues) - } - url = strings.Replace(url, "{"+name+"}", value, -1) - } else { - url = strings.Replace(url, "{"+name+"}", variable.DefaultValue, -1) - } - } - return url, nil -} - -// ServerURL returns URL based on server settings -func (c *Configuration) ServerURL(index int, variables map[string]string) (string, error) { - return c.Servers.URL(index, variables) -} - -func getServerIndex(ctx context.Context) (int, error) { - si := ctx.Value(ContextServerIndex) - if si != nil { - if index, ok := si.(int); ok { - return index, nil - } - return 0, reportError("Invalid type %T should be int", si) - } - return 0, nil -} - -func getServerOperationIndex(ctx context.Context, endpoint string) (int, error) { - osi := ctx.Value(ContextOperationServerIndices) - if osi != nil { - if operationIndices, ok := osi.(map[string]int); !ok { - return 0, reportError("Invalid type %T should be map[string]int", osi) - } else { - index, ok := operationIndices[endpoint] - if ok { - return index, nil - } - } - } - return getServerIndex(ctx) -} - -func getServerVariables(ctx context.Context) (map[string]string, error) { - sv := ctx.Value(ContextServerVariables) - if sv != nil { - if variables, ok := sv.(map[string]string); ok { - return variables, nil - } - return nil, reportError("ctx value of ContextServerVariables has invalid type %T should be map[string]string", sv) - } - return nil, nil -} - -func getServerOperationVariables(ctx context.Context, endpoint string) (map[string]string, error) { - osv := ctx.Value(ContextOperationServerVariables) - if osv != nil { - if operationVariables, ok := osv.(map[string]map[string]string); !ok { - return nil, reportError("ctx value of ContextOperationServerVariables has invalid type %T should be map[string]map[string]string", osv) - } else { - variables, ok := operationVariables[endpoint] - if ok { - return variables, nil - } - } - } - return getServerVariables(ctx) -} - -// ServerURLWithContext returns a new server URL given an endpoint -func (c *Configuration) ServerURLWithContext(ctx context.Context, endpoint string) (string, error) { - sc, ok := c.OperationServers[endpoint] - if !ok { - sc = c.Servers - } - - if ctx == nil { - return sc.URL(0, nil) - } - - index, err := getServerOperationIndex(ctx, endpoint) - if err != nil { - return "", err - } - - variables, err := getServerOperationVariables(ctx, endpoint) - if err != nil { - return "", err - } - - return sc.URL(index, variables) -} diff --git a/membershipclient/git_push.sh b/membershipclient/git_push.sh deleted file mode 100644 index 9e86723e..00000000 --- a/membershipclient/git_push.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ -# -# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com" - -git_user_id=$1 -git_repo_id=$2 -release_note=$3 -git_host=$4 - -if [ "$git_host" = "" ]; then - git_host="github.com" - echo "[INFO] No command line input provided. Set \$git_host to $git_host" -fi - -if [ "$git_user_id" = "" ]; then - git_user_id="formancehq" - echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id" -fi - -if [ "$git_repo_id" = "" ]; then - git_repo_id="fctl" - echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id" -fi - -if [ "$release_note" = "" ]; then - release_note="Minor update" - echo "[INFO] No command line input provided. Set \$release_note to $release_note" -fi - -# Initialize the local directory as a Git repository -git init - -# Adds the files in the local repository and stages them for commit. -git add . - -# Commits the tracked changes and prepares them to be pushed to a remote repository. -git commit -m "$release_note" - -# Sets the new remote -git_remote=$(git remote) -if [ "$git_remote" = "" ]; then # git remote not defined - - if [ "$GIT_TOKEN" = "" ]; then - echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." - git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git - else - git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git - fi - -fi - -git pull origin master - -# Pushes (Forces) the changes in the local repository up to the remote repository -echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" -git push origin master 2>&1 | grep -v 'To https' diff --git a/membershipclient/go.mod b/membershipclient/go.mod deleted file mode 100644 index 20bc10af..00000000 --- a/membershipclient/go.mod +++ /dev/null @@ -1,9 +0,0 @@ -module github.com/formancehq/fctl/membershipclient - -go 1.23 - -require ( - github.com/stretchr/testify v1.10.0 - golang.org/x/oauth2 v0.27.0 - gopkg.in/validator.v2 v2.0.1 -) diff --git a/membershipclient/go.sum b/membershipclient/go.sum deleted file mode 100644 index c97062a6..00000000 --- a/membershipclient/go.sum +++ /dev/null @@ -1,15 +0,0 @@ -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e h1:bRhVy7zSSasaqNksaRZiA5EEI+Ei4I1nO5Jh72wfHlg= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/oauth2 v0.27.0 h1:da9Vo7/tDv5RH/7nZDz1eMGS/q1Vv1N/7FCrBhI9I3M= -golang.org/x/oauth2 v0.27.0/go.mod h1:onh5ek6nERTohokkhCD/y2cV4Do3fxFHFuAejCkRWT8= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -google.golang.org/appengine v1.4.0 h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -gopkg.in/validator.v2 v2.0.1 h1:xF0KWyGWXm/LM2G1TrEjqOu4pa6coO9AlWSf3msVfDY= -gopkg.in/validator.v2 v2.0.1/go.mod h1:lIUZBlB3Im4s/eYp39Ry/wkR02yOPhZ9IwIRBjuPuG8= diff --git a/membershipclient/model_action.go b/membershipclient/model_action.go deleted file mode 100644 index 60cda4a3..00000000 --- a/membershipclient/model_action.go +++ /dev/null @@ -1,177 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// Action the model 'Action' -type Action string - -// List of Action -const ( - AGENTS_CONNECTED Action = "agents.connected" - AGENTS_DISCONNECTED Action = "agents.disconnected" - INVITATIONS_CREATED Action = "invitations.created" - INVITATIONS_ACCEPTED Action = "invitations.accepted" - INVITATIONS_REJECTED Action = "invitations.rejected" - INVITATIONS_CANCELLED Action = "invitations.cancelled" - ORGANIZATIONS_CREATED Action = "organizations.created" - ORGANIZATIONS_UPDATED Action = "organizations.updated" - ORGANIZATIONS_DELETED Action = "organizations.deleted" - ORGANIZATIONS_USER_DELETED Action = "organizations.user.deleted" - ORGANIZATIONS_USER_UPDATED Action = "organizations.user.updated" - REGIONS_CREATED Action = "regions.created" - REGIONS_DELETED Action = "regions.deleted" - USERS_CREATED Action = "users.created" - USERS_DELETED Action = "users.deleted" - STACKS_DISPOSAL Action = "stacks.disposal" - STACKS_DISPOSAL_RESET Action = "stacks.disposal-reset" - STACKS_WARNED Action = "stacks.warned" - STACKS_PRUNED Action = "stacks.pruned" - STACKS_STATUS_UPDATED Action = "stacks.status.updated" - STACKS_CREATED Action = "stacks.created" - STACKS_UPDATED Action = "stacks.updated" - STACKS_DELETED Action = "stacks.deleted" - STACKS_RESTORED Action = "stacks.restored" - STACKS_DISABLED Action = "stacks.disabled" - STACKS_ENABLED Action = "stacks.enabled" - STACKS_UPGRADED Action = "stacks.upgraded" - STACKS_STARGATE_ENABLED Action = "stacks.stargate.enabled" - STACKS_STARGATE_DISABLED Action = "stacks.stargate.disabled" - STACKS_USER_UPDATED Action = "stacks.user.updated" - STACKS_USER_DELETED Action = "stacks.user.deleted" - STACKS_REACHNESS_UPDATED Action = "stacks.reachness.updated" - STACKS_MODULE_ENABLED Action = "stacks.module.enabled" - STACKS_MODULE_DISABLED Action = "stacks.module.disabled" - STACKS_MODULE_STATUS_UPDATED Action = "stacks.module.status.updated" -) - -// All allowed values of Action enum -var AllowedActionEnumValues = []Action{ - "agents.connected", - "agents.disconnected", - "invitations.created", - "invitations.accepted", - "invitations.rejected", - "invitations.cancelled", - "organizations.created", - "organizations.updated", - "organizations.deleted", - "organizations.user.deleted", - "organizations.user.updated", - "regions.created", - "regions.deleted", - "users.created", - "users.deleted", - "stacks.disposal", - "stacks.disposal-reset", - "stacks.warned", - "stacks.pruned", - "stacks.status.updated", - "stacks.created", - "stacks.updated", - "stacks.deleted", - "stacks.restored", - "stacks.disabled", - "stacks.enabled", - "stacks.upgraded", - "stacks.stargate.enabled", - "stacks.stargate.disabled", - "stacks.user.updated", - "stacks.user.deleted", - "stacks.reachness.updated", - "stacks.module.enabled", - "stacks.module.disabled", - "stacks.module.status.updated", -} - -func (v *Action) UnmarshalJSON(src []byte) error { - var value string - err := json.Unmarshal(src, &value) - if err != nil { - return err - } - enumTypeValue := Action(value) - for _, existing := range AllowedActionEnumValues { - if existing == enumTypeValue { - *v = enumTypeValue - return nil - } - } - - return fmt.Errorf("%+v is not a valid Action", value) -} - -// NewActionFromValue returns a pointer to a valid Action -// for the value passed as argument, or an error if the value passed is not allowed by the enum -func NewActionFromValue(v string) (*Action, error) { - ev := Action(v) - if ev.IsValid() { - return &ev, nil - } else { - return nil, fmt.Errorf("invalid value '%v' for Action: valid values are %v", v, AllowedActionEnumValues) - } -} - -// IsValid return true if the value is valid for the enum, false otherwise -func (v Action) IsValid() bool { - for _, existing := range AllowedActionEnumValues { - if existing == v { - return true - } - } - return false -} - -// Ptr returns reference to Action value -func (v Action) Ptr() *Action { - return &v -} - -type NullableAction struct { - value *Action - isSet bool -} - -func (v NullableAction) Get() *Action { - return v.value -} - -func (v *NullableAction) Set(val *Action) { - v.value = val - v.isSet = true -} - -func (v NullableAction) IsSet() bool { - return v.isSet -} - -func (v *NullableAction) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableAction(val *Action) *NullableAction { - return &NullableAction{value: val, isSet: true} -} - -func (v NullableAction) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableAction) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - diff --git a/membershipclient/model_add_features_request.go b/membershipclient/model_add_features_request.go deleted file mode 100644 index 8183576a..00000000 --- a/membershipclient/model_add_features_request.go +++ /dev/null @@ -1,168 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the AddFeaturesRequest type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &AddFeaturesRequest{} - -// AddFeaturesRequest struct for AddFeaturesRequest -type AddFeaturesRequest struct { - Features []string `json:"features"` - AdditionalProperties map[string]interface{} -} - -type _AddFeaturesRequest AddFeaturesRequest - -// NewAddFeaturesRequest instantiates a new AddFeaturesRequest object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewAddFeaturesRequest(features []string) *AddFeaturesRequest { - this := AddFeaturesRequest{} - this.Features = features - return &this -} - -// NewAddFeaturesRequestWithDefaults instantiates a new AddFeaturesRequest object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewAddFeaturesRequestWithDefaults() *AddFeaturesRequest { - this := AddFeaturesRequest{} - return &this -} - -// GetFeatures returns the Features field value -func (o *AddFeaturesRequest) GetFeatures() []string { - if o == nil { - var ret []string - return ret - } - - return o.Features -} - -// GetFeaturesOk returns a tuple with the Features field value -// and a boolean to check if the value has been set. -func (o *AddFeaturesRequest) GetFeaturesOk() ([]string, bool) { - if o == nil { - return nil, false - } - return o.Features, true -} - -// SetFeatures sets field value -func (o *AddFeaturesRequest) SetFeatures(v []string) { - o.Features = v -} - -func (o AddFeaturesRequest) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o AddFeaturesRequest) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["features"] = o.Features - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *AddFeaturesRequest) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "features", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varAddFeaturesRequest := _AddFeaturesRequest{} - - err = json.Unmarshal(data, &varAddFeaturesRequest) - - if err != nil { - return err - } - - *o = AddFeaturesRequest(varAddFeaturesRequest) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "features") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableAddFeaturesRequest struct { - value *AddFeaturesRequest - isSet bool -} - -func (v NullableAddFeaturesRequest) Get() *AddFeaturesRequest { - return v.value -} - -func (v *NullableAddFeaturesRequest) Set(val *AddFeaturesRequest) { - v.value = val - v.isSet = true -} - -func (v NullableAddFeaturesRequest) IsSet() bool { - return v.isSet -} - -func (v *NullableAddFeaturesRequest) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableAddFeaturesRequest(val *AddFeaturesRequest) *NullableAddFeaturesRequest { - return &NullableAddFeaturesRequest{value: val, isSet: true} -} - -func (v NullableAddFeaturesRequest) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableAddFeaturesRequest) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_any_region.go b/membershipclient/model_any_region.go deleted file mode 100644 index 757527d0..00000000 --- a/membershipclient/model_any_region.go +++ /dev/null @@ -1,697 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "time" - "fmt" -) - -// checks if the AnyRegion type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &AnyRegion{} - -// AnyRegion struct for AnyRegion -type AnyRegion struct { - Id string `json:"id"` - BaseUrl string `json:"baseUrl"` - CreatedAt string `json:"createdAt"` - Active bool `json:"active"` - LastPing *time.Time `json:"lastPing,omitempty"` - Name string `json:"name"` - Capabilities RegionCapability `json:"capabilities"` - AgentID string `json:"agentID"` - Outdated bool `json:"outdated"` - CreatorId *string `json:"creatorId,omitempty"` - Version *string `json:"version,omitempty"` - ClientID *string `json:"clientID,omitempty"` - OrganizationID *string `json:"organizationID,omitempty"` - Creator *User `json:"creator,omitempty"` - Production *bool `json:"production,omitempty"` - Public bool `json:"public"` - Secret *PrivateRegionSecret `json:"secret,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _AnyRegion AnyRegion - -// NewAnyRegion instantiates a new AnyRegion object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewAnyRegion(id string, baseUrl string, createdAt string, active bool, name string, capabilities RegionCapability, agentID string, outdated bool, public bool) *AnyRegion { - this := AnyRegion{} - this.Id = id - this.BaseUrl = baseUrl - this.CreatedAt = createdAt - this.Active = active - this.Name = name - this.Capabilities = capabilities - this.AgentID = agentID - this.Outdated = outdated - this.Public = public - return &this -} - -// NewAnyRegionWithDefaults instantiates a new AnyRegion object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewAnyRegionWithDefaults() *AnyRegion { - this := AnyRegion{} - return &this -} - -// GetId returns the Id field value -func (o *AnyRegion) GetId() string { - if o == nil { - var ret string - return ret - } - - return o.Id -} - -// GetIdOk returns a tuple with the Id field value -// and a boolean to check if the value has been set. -func (o *AnyRegion) GetIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Id, true -} - -// SetId sets field value -func (o *AnyRegion) SetId(v string) { - o.Id = v -} - -// GetBaseUrl returns the BaseUrl field value -func (o *AnyRegion) GetBaseUrl() string { - if o == nil { - var ret string - return ret - } - - return o.BaseUrl -} - -// GetBaseUrlOk returns a tuple with the BaseUrl field value -// and a boolean to check if the value has been set. -func (o *AnyRegion) GetBaseUrlOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.BaseUrl, true -} - -// SetBaseUrl sets field value -func (o *AnyRegion) SetBaseUrl(v string) { - o.BaseUrl = v -} - -// GetCreatedAt returns the CreatedAt field value -func (o *AnyRegion) GetCreatedAt() string { - if o == nil { - var ret string - return ret - } - - return o.CreatedAt -} - -// GetCreatedAtOk returns a tuple with the CreatedAt field value -// and a boolean to check if the value has been set. -func (o *AnyRegion) GetCreatedAtOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.CreatedAt, true -} - -// SetCreatedAt sets field value -func (o *AnyRegion) SetCreatedAt(v string) { - o.CreatedAt = v -} - -// GetActive returns the Active field value -func (o *AnyRegion) GetActive() bool { - if o == nil { - var ret bool - return ret - } - - return o.Active -} - -// GetActiveOk returns a tuple with the Active field value -// and a boolean to check if the value has been set. -func (o *AnyRegion) GetActiveOk() (*bool, bool) { - if o == nil { - return nil, false - } - return &o.Active, true -} - -// SetActive sets field value -func (o *AnyRegion) SetActive(v bool) { - o.Active = v -} - -// GetLastPing returns the LastPing field value if set, zero value otherwise. -func (o *AnyRegion) GetLastPing() time.Time { - if o == nil || IsNil(o.LastPing) { - var ret time.Time - return ret - } - return *o.LastPing -} - -// GetLastPingOk returns a tuple with the LastPing field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *AnyRegion) GetLastPingOk() (*time.Time, bool) { - if o == nil || IsNil(o.LastPing) { - return nil, false - } - return o.LastPing, true -} - -// HasLastPing returns a boolean if a field has been set. -func (o *AnyRegion) HasLastPing() bool { - if o != nil && !IsNil(o.LastPing) { - return true - } - - return false -} - -// SetLastPing gets a reference to the given time.Time and assigns it to the LastPing field. -func (o *AnyRegion) SetLastPing(v time.Time) { - o.LastPing = &v -} - -// GetName returns the Name field value -func (o *AnyRegion) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *AnyRegion) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *AnyRegion) SetName(v string) { - o.Name = v -} - -// GetCapabilities returns the Capabilities field value -func (o *AnyRegion) GetCapabilities() RegionCapability { - if o == nil { - var ret RegionCapability - return ret - } - - return o.Capabilities -} - -// GetCapabilitiesOk returns a tuple with the Capabilities field value -// and a boolean to check if the value has been set. -func (o *AnyRegion) GetCapabilitiesOk() (*RegionCapability, bool) { - if o == nil { - return nil, false - } - return &o.Capabilities, true -} - -// SetCapabilities sets field value -func (o *AnyRegion) SetCapabilities(v RegionCapability) { - o.Capabilities = v -} - -// GetAgentID returns the AgentID field value -func (o *AnyRegion) GetAgentID() string { - if o == nil { - var ret string - return ret - } - - return o.AgentID -} - -// GetAgentIDOk returns a tuple with the AgentID field value -// and a boolean to check if the value has been set. -func (o *AnyRegion) GetAgentIDOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.AgentID, true -} - -// SetAgentID sets field value -func (o *AnyRegion) SetAgentID(v string) { - o.AgentID = v -} - -// GetOutdated returns the Outdated field value -func (o *AnyRegion) GetOutdated() bool { - if o == nil { - var ret bool - return ret - } - - return o.Outdated -} - -// GetOutdatedOk returns a tuple with the Outdated field value -// and a boolean to check if the value has been set. -func (o *AnyRegion) GetOutdatedOk() (*bool, bool) { - if o == nil { - return nil, false - } - return &o.Outdated, true -} - -// SetOutdated sets field value -func (o *AnyRegion) SetOutdated(v bool) { - o.Outdated = v -} - -// GetCreatorId returns the CreatorId field value if set, zero value otherwise. -func (o *AnyRegion) GetCreatorId() string { - if o == nil || IsNil(o.CreatorId) { - var ret string - return ret - } - return *o.CreatorId -} - -// GetCreatorIdOk returns a tuple with the CreatorId field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *AnyRegion) GetCreatorIdOk() (*string, bool) { - if o == nil || IsNil(o.CreatorId) { - return nil, false - } - return o.CreatorId, true -} - -// HasCreatorId returns a boolean if a field has been set. -func (o *AnyRegion) HasCreatorId() bool { - if o != nil && !IsNil(o.CreatorId) { - return true - } - - return false -} - -// SetCreatorId gets a reference to the given string and assigns it to the CreatorId field. -func (o *AnyRegion) SetCreatorId(v string) { - o.CreatorId = &v -} - -// GetVersion returns the Version field value if set, zero value otherwise. -func (o *AnyRegion) GetVersion() string { - if o == nil || IsNil(o.Version) { - var ret string - return ret - } - return *o.Version -} - -// GetVersionOk returns a tuple with the Version field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *AnyRegion) GetVersionOk() (*string, bool) { - if o == nil || IsNil(o.Version) { - return nil, false - } - return o.Version, true -} - -// HasVersion returns a boolean if a field has been set. -func (o *AnyRegion) HasVersion() bool { - if o != nil && !IsNil(o.Version) { - return true - } - - return false -} - -// SetVersion gets a reference to the given string and assigns it to the Version field. -func (o *AnyRegion) SetVersion(v string) { - o.Version = &v -} - -// GetClientID returns the ClientID field value if set, zero value otherwise. -func (o *AnyRegion) GetClientID() string { - if o == nil || IsNil(o.ClientID) { - var ret string - return ret - } - return *o.ClientID -} - -// GetClientIDOk returns a tuple with the ClientID field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *AnyRegion) GetClientIDOk() (*string, bool) { - if o == nil || IsNil(o.ClientID) { - return nil, false - } - return o.ClientID, true -} - -// HasClientID returns a boolean if a field has been set. -func (o *AnyRegion) HasClientID() bool { - if o != nil && !IsNil(o.ClientID) { - return true - } - - return false -} - -// SetClientID gets a reference to the given string and assigns it to the ClientID field. -func (o *AnyRegion) SetClientID(v string) { - o.ClientID = &v -} - -// GetOrganizationID returns the OrganizationID field value if set, zero value otherwise. -func (o *AnyRegion) GetOrganizationID() string { - if o == nil || IsNil(o.OrganizationID) { - var ret string - return ret - } - return *o.OrganizationID -} - -// GetOrganizationIDOk returns a tuple with the OrganizationID field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *AnyRegion) GetOrganizationIDOk() (*string, bool) { - if o == nil || IsNil(o.OrganizationID) { - return nil, false - } - return o.OrganizationID, true -} - -// HasOrganizationID returns a boolean if a field has been set. -func (o *AnyRegion) HasOrganizationID() bool { - if o != nil && !IsNil(o.OrganizationID) { - return true - } - - return false -} - -// SetOrganizationID gets a reference to the given string and assigns it to the OrganizationID field. -func (o *AnyRegion) SetOrganizationID(v string) { - o.OrganizationID = &v -} - -// GetCreator returns the Creator field value if set, zero value otherwise. -func (o *AnyRegion) GetCreator() User { - if o == nil || IsNil(o.Creator) { - var ret User - return ret - } - return *o.Creator -} - -// GetCreatorOk returns a tuple with the Creator field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *AnyRegion) GetCreatorOk() (*User, bool) { - if o == nil || IsNil(o.Creator) { - return nil, false - } - return o.Creator, true -} - -// HasCreator returns a boolean if a field has been set. -func (o *AnyRegion) HasCreator() bool { - if o != nil && !IsNil(o.Creator) { - return true - } - - return false -} - -// SetCreator gets a reference to the given User and assigns it to the Creator field. -func (o *AnyRegion) SetCreator(v User) { - o.Creator = &v -} - -// GetProduction returns the Production field value if set, zero value otherwise. -func (o *AnyRegion) GetProduction() bool { - if o == nil || IsNil(o.Production) { - var ret bool - return ret - } - return *o.Production -} - -// GetProductionOk returns a tuple with the Production field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *AnyRegion) GetProductionOk() (*bool, bool) { - if o == nil || IsNil(o.Production) { - return nil, false - } - return o.Production, true -} - -// HasProduction returns a boolean if a field has been set. -func (o *AnyRegion) HasProduction() bool { - if o != nil && !IsNil(o.Production) { - return true - } - - return false -} - -// SetProduction gets a reference to the given bool and assigns it to the Production field. -func (o *AnyRegion) SetProduction(v bool) { - o.Production = &v -} - -// GetPublic returns the Public field value -func (o *AnyRegion) GetPublic() bool { - if o == nil { - var ret bool - return ret - } - - return o.Public -} - -// GetPublicOk returns a tuple with the Public field value -// and a boolean to check if the value has been set. -func (o *AnyRegion) GetPublicOk() (*bool, bool) { - if o == nil { - return nil, false - } - return &o.Public, true -} - -// SetPublic sets field value -func (o *AnyRegion) SetPublic(v bool) { - o.Public = v -} - -// GetSecret returns the Secret field value if set, zero value otherwise. -func (o *AnyRegion) GetSecret() PrivateRegionSecret { - if o == nil || IsNil(o.Secret) { - var ret PrivateRegionSecret - return ret - } - return *o.Secret -} - -// GetSecretOk returns a tuple with the Secret field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *AnyRegion) GetSecretOk() (*PrivateRegionSecret, bool) { - if o == nil || IsNil(o.Secret) { - return nil, false - } - return o.Secret, true -} - -// HasSecret returns a boolean if a field has been set. -func (o *AnyRegion) HasSecret() bool { - if o != nil && !IsNil(o.Secret) { - return true - } - - return false -} - -// SetSecret gets a reference to the given PrivateRegionSecret and assigns it to the Secret field. -func (o *AnyRegion) SetSecret(v PrivateRegionSecret) { - o.Secret = &v -} - -func (o AnyRegion) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o AnyRegion) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["id"] = o.Id - toSerialize["baseUrl"] = o.BaseUrl - toSerialize["createdAt"] = o.CreatedAt - toSerialize["active"] = o.Active - if !IsNil(o.LastPing) { - toSerialize["lastPing"] = o.LastPing - } - toSerialize["name"] = o.Name - toSerialize["capabilities"] = o.Capabilities - toSerialize["agentID"] = o.AgentID - toSerialize["outdated"] = o.Outdated - if !IsNil(o.CreatorId) { - toSerialize["creatorId"] = o.CreatorId - } - if !IsNil(o.Version) { - toSerialize["version"] = o.Version - } - if !IsNil(o.ClientID) { - toSerialize["clientID"] = o.ClientID - } - if !IsNil(o.OrganizationID) { - toSerialize["organizationID"] = o.OrganizationID - } - if !IsNil(o.Creator) { - toSerialize["creator"] = o.Creator - } - if !IsNil(o.Production) { - toSerialize["production"] = o.Production - } - toSerialize["public"] = o.Public - if !IsNil(o.Secret) { - toSerialize["secret"] = o.Secret - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *AnyRegion) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "id", - "baseUrl", - "createdAt", - "active", - "name", - "capabilities", - "agentID", - "outdated", - "public", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varAnyRegion := _AnyRegion{} - - err = json.Unmarshal(data, &varAnyRegion) - - if err != nil { - return err - } - - *o = AnyRegion(varAnyRegion) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "id") - delete(additionalProperties, "baseUrl") - delete(additionalProperties, "createdAt") - delete(additionalProperties, "active") - delete(additionalProperties, "lastPing") - delete(additionalProperties, "name") - delete(additionalProperties, "capabilities") - delete(additionalProperties, "agentID") - delete(additionalProperties, "outdated") - delete(additionalProperties, "creatorId") - delete(additionalProperties, "version") - delete(additionalProperties, "clientID") - delete(additionalProperties, "organizationID") - delete(additionalProperties, "creator") - delete(additionalProperties, "production") - delete(additionalProperties, "public") - delete(additionalProperties, "secret") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableAnyRegion struct { - value *AnyRegion - isSet bool -} - -func (v NullableAnyRegion) Get() *AnyRegion { - return v.value -} - -func (v *NullableAnyRegion) Set(val *AnyRegion) { - v.value = val - v.isSet = true -} - -func (v NullableAnyRegion) IsSet() bool { - return v.isSet -} - -func (v *NullableAnyRegion) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableAnyRegion(val *AnyRegion) *NullableAnyRegion { - return &NullableAnyRegion{value: val, isSet: true} -} - -func (v NullableAnyRegion) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableAnyRegion) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_authentication_provider.go b/membershipclient/model_authentication_provider.go deleted file mode 100644 index 13735d20..00000000 --- a/membershipclient/model_authentication_provider.go +++ /dev/null @@ -1,379 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "time" - "fmt" -) - -// checks if the AuthenticationProvider type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &AuthenticationProvider{} - -// AuthenticationProvider struct for AuthenticationProvider -type AuthenticationProvider struct { - // Type of the authentication provider - Type string `json:"type"` - // Name of the authentication provider - Name string `json:"name"` - // Client ID for the authentication provider - ClientID string `json:"clientID"` - // Client secret for the authentication provider - ClientSecret string `json:"clientSecret"` - Config OIDCConfigAllOfConfig `json:"config"` - // Unique identifier for the authentication provider - OrganizationId string `json:"organizationId"` - // Creation date of the authentication provider - CreatedAt time.Time `json:"createdAt"` - // Last update date of the authentication provider - UpdatedAt time.Time `json:"updatedAt"` - AdditionalProperties map[string]interface{} -} - -type _AuthenticationProvider AuthenticationProvider - -// NewAuthenticationProvider instantiates a new AuthenticationProvider object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewAuthenticationProvider(type_ string, name string, clientID string, clientSecret string, config OIDCConfigAllOfConfig, organizationId string, createdAt time.Time, updatedAt time.Time) *AuthenticationProvider { - this := AuthenticationProvider{} - this.Type = type_ - this.Name = name - this.ClientID = clientID - this.ClientSecret = clientSecret - this.Config = config - this.OrganizationId = organizationId - this.CreatedAt = createdAt - this.UpdatedAt = updatedAt - return &this -} - -// NewAuthenticationProviderWithDefaults instantiates a new AuthenticationProvider object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewAuthenticationProviderWithDefaults() *AuthenticationProvider { - this := AuthenticationProvider{} - return &this -} - -// GetType returns the Type field value -func (o *AuthenticationProvider) GetType() string { - if o == nil { - var ret string - return ret - } - - return o.Type -} - -// GetTypeOk returns a tuple with the Type field value -// and a boolean to check if the value has been set. -func (o *AuthenticationProvider) GetTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Type, true -} - -// SetType sets field value -func (o *AuthenticationProvider) SetType(v string) { - o.Type = v -} - -// GetName returns the Name field value -func (o *AuthenticationProvider) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *AuthenticationProvider) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *AuthenticationProvider) SetName(v string) { - o.Name = v -} - -// GetClientID returns the ClientID field value -func (o *AuthenticationProvider) GetClientID() string { - if o == nil { - var ret string - return ret - } - - return o.ClientID -} - -// GetClientIDOk returns a tuple with the ClientID field value -// and a boolean to check if the value has been set. -func (o *AuthenticationProvider) GetClientIDOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ClientID, true -} - -// SetClientID sets field value -func (o *AuthenticationProvider) SetClientID(v string) { - o.ClientID = v -} - -// GetClientSecret returns the ClientSecret field value -func (o *AuthenticationProvider) GetClientSecret() string { - if o == nil { - var ret string - return ret - } - - return o.ClientSecret -} - -// GetClientSecretOk returns a tuple with the ClientSecret field value -// and a boolean to check if the value has been set. -func (o *AuthenticationProvider) GetClientSecretOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ClientSecret, true -} - -// SetClientSecret sets field value -func (o *AuthenticationProvider) SetClientSecret(v string) { - o.ClientSecret = v -} - -// GetConfig returns the Config field value -func (o *AuthenticationProvider) GetConfig() OIDCConfigAllOfConfig { - if o == nil { - var ret OIDCConfigAllOfConfig - return ret - } - - return o.Config -} - -// GetConfigOk returns a tuple with the Config field value -// and a boolean to check if the value has been set. -func (o *AuthenticationProvider) GetConfigOk() (*OIDCConfigAllOfConfig, bool) { - if o == nil { - return nil, false - } - return &o.Config, true -} - -// SetConfig sets field value -func (o *AuthenticationProvider) SetConfig(v OIDCConfigAllOfConfig) { - o.Config = v -} - -// GetOrganizationId returns the OrganizationId field value -func (o *AuthenticationProvider) GetOrganizationId() string { - if o == nil { - var ret string - return ret - } - - return o.OrganizationId -} - -// GetOrganizationIdOk returns a tuple with the OrganizationId field value -// and a boolean to check if the value has been set. -func (o *AuthenticationProvider) GetOrganizationIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.OrganizationId, true -} - -// SetOrganizationId sets field value -func (o *AuthenticationProvider) SetOrganizationId(v string) { - o.OrganizationId = v -} - -// GetCreatedAt returns the CreatedAt field value -func (o *AuthenticationProvider) GetCreatedAt() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.CreatedAt -} - -// GetCreatedAtOk returns a tuple with the CreatedAt field value -// and a boolean to check if the value has been set. -func (o *AuthenticationProvider) GetCreatedAtOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.CreatedAt, true -} - -// SetCreatedAt sets field value -func (o *AuthenticationProvider) SetCreatedAt(v time.Time) { - o.CreatedAt = v -} - -// GetUpdatedAt returns the UpdatedAt field value -func (o *AuthenticationProvider) GetUpdatedAt() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.UpdatedAt -} - -// GetUpdatedAtOk returns a tuple with the UpdatedAt field value -// and a boolean to check if the value has been set. -func (o *AuthenticationProvider) GetUpdatedAtOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.UpdatedAt, true -} - -// SetUpdatedAt sets field value -func (o *AuthenticationProvider) SetUpdatedAt(v time.Time) { - o.UpdatedAt = v -} - -func (o AuthenticationProvider) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o AuthenticationProvider) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["type"] = o.Type - toSerialize["name"] = o.Name - toSerialize["clientID"] = o.ClientID - toSerialize["clientSecret"] = o.ClientSecret - toSerialize["config"] = o.Config - toSerialize["organizationId"] = o.OrganizationId - toSerialize["createdAt"] = o.CreatedAt - toSerialize["updatedAt"] = o.UpdatedAt - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *AuthenticationProvider) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "type", - "name", - "clientID", - "clientSecret", - "config", - "organizationId", - "createdAt", - "updatedAt", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varAuthenticationProvider := _AuthenticationProvider{} - - err = json.Unmarshal(data, &varAuthenticationProvider) - - if err != nil { - return err - } - - *o = AuthenticationProvider(varAuthenticationProvider) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "type") - delete(additionalProperties, "name") - delete(additionalProperties, "clientID") - delete(additionalProperties, "clientSecret") - delete(additionalProperties, "config") - delete(additionalProperties, "organizationId") - delete(additionalProperties, "createdAt") - delete(additionalProperties, "updatedAt") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableAuthenticationProvider struct { - value *AuthenticationProvider - isSet bool -} - -func (v NullableAuthenticationProvider) Get() *AuthenticationProvider { - return v.value -} - -func (v *NullableAuthenticationProvider) Set(val *AuthenticationProvider) { - v.value = val - v.isSet = true -} - -func (v NullableAuthenticationProvider) IsSet() bool { - return v.isSet -} - -func (v *NullableAuthenticationProvider) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableAuthenticationProvider(val *AuthenticationProvider) *NullableAuthenticationProvider { - return &NullableAuthenticationProvider{value: val, isSet: true} -} - -func (v NullableAuthenticationProvider) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableAuthenticationProvider) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_authentication_provider_data.go b/membershipclient/model_authentication_provider_data.go deleted file mode 100644 index 0c947461..00000000 --- a/membershipclient/model_authentication_provider_data.go +++ /dev/null @@ -1,247 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" - "gopkg.in/validator.v2" -) - -// AuthenticationProviderData - struct for AuthenticationProviderData -type AuthenticationProviderData struct { - GithubIDPConfig *GithubIDPConfig - GoogleIDPConfig *GoogleIDPConfig - MicrosoftIDPConfig *MicrosoftIDPConfig - OIDCConfig *OIDCConfig -} - -// GithubIDPConfigAsAuthenticationProviderData is a convenience function that returns GithubIDPConfig wrapped in AuthenticationProviderData -func GithubIDPConfigAsAuthenticationProviderData(v *GithubIDPConfig) AuthenticationProviderData { - return AuthenticationProviderData{ - GithubIDPConfig: v, - } -} - -// GoogleIDPConfigAsAuthenticationProviderData is a convenience function that returns GoogleIDPConfig wrapped in AuthenticationProviderData -func GoogleIDPConfigAsAuthenticationProviderData(v *GoogleIDPConfig) AuthenticationProviderData { - return AuthenticationProviderData{ - GoogleIDPConfig: v, - } -} - -// MicrosoftIDPConfigAsAuthenticationProviderData is a convenience function that returns MicrosoftIDPConfig wrapped in AuthenticationProviderData -func MicrosoftIDPConfigAsAuthenticationProviderData(v *MicrosoftIDPConfig) AuthenticationProviderData { - return AuthenticationProviderData{ - MicrosoftIDPConfig: v, - } -} - -// OIDCConfigAsAuthenticationProviderData is a convenience function that returns OIDCConfig wrapped in AuthenticationProviderData -func OIDCConfigAsAuthenticationProviderData(v *OIDCConfig) AuthenticationProviderData { - return AuthenticationProviderData{ - OIDCConfig: v, - } -} - - -// Unmarshal JSON data into one of the pointers in the struct -func (dst *AuthenticationProviderData) UnmarshalJSON(data []byte) error { - var err error - match := 0 - // try to unmarshal data into GithubIDPConfig - err = newStrictDecoder(data).Decode(&dst.GithubIDPConfig) - if err == nil { - jsonGithubIDPConfig, _ := json.Marshal(dst.GithubIDPConfig) - if string(jsonGithubIDPConfig) == "{}" { // empty struct - dst.GithubIDPConfig = nil - } else { - if err = validator.Validate(dst.GithubIDPConfig); err != nil { - dst.GithubIDPConfig = nil - } else { - match++ - } - } - } else { - dst.GithubIDPConfig = nil - } - - // try to unmarshal data into GoogleIDPConfig - err = newStrictDecoder(data).Decode(&dst.GoogleIDPConfig) - if err == nil { - jsonGoogleIDPConfig, _ := json.Marshal(dst.GoogleIDPConfig) - if string(jsonGoogleIDPConfig) == "{}" { // empty struct - dst.GoogleIDPConfig = nil - } else { - if err = validator.Validate(dst.GoogleIDPConfig); err != nil { - dst.GoogleIDPConfig = nil - } else { - match++ - } - } - } else { - dst.GoogleIDPConfig = nil - } - - // try to unmarshal data into MicrosoftIDPConfig - err = newStrictDecoder(data).Decode(&dst.MicrosoftIDPConfig) - if err == nil { - jsonMicrosoftIDPConfig, _ := json.Marshal(dst.MicrosoftIDPConfig) - if string(jsonMicrosoftIDPConfig) == "{}" { // empty struct - dst.MicrosoftIDPConfig = nil - } else { - if err = validator.Validate(dst.MicrosoftIDPConfig); err != nil { - dst.MicrosoftIDPConfig = nil - } else { - match++ - } - } - } else { - dst.MicrosoftIDPConfig = nil - } - - // try to unmarshal data into OIDCConfig - err = newStrictDecoder(data).Decode(&dst.OIDCConfig) - if err == nil { - jsonOIDCConfig, _ := json.Marshal(dst.OIDCConfig) - if string(jsonOIDCConfig) == "{}" { // empty struct - dst.OIDCConfig = nil - } else { - if err = validator.Validate(dst.OIDCConfig); err != nil { - dst.OIDCConfig = nil - } else { - match++ - } - } - } else { - dst.OIDCConfig = nil - } - - if match > 1 { // more than 1 match - // reset to nil - dst.GithubIDPConfig = nil - dst.GoogleIDPConfig = nil - dst.MicrosoftIDPConfig = nil - dst.OIDCConfig = nil - - return fmt.Errorf("data matches more than one schema in oneOf(AuthenticationProviderData)") - } else if match == 1 { - return nil // exactly one match - } else { // no match - return fmt.Errorf("data failed to match schemas in oneOf(AuthenticationProviderData)") - } -} - -// Marshal data from the first non-nil pointers in the struct to JSON -func (src AuthenticationProviderData) MarshalJSON() ([]byte, error) { - if src.GithubIDPConfig != nil { - return json.Marshal(&src.GithubIDPConfig) - } - - if src.GoogleIDPConfig != nil { - return json.Marshal(&src.GoogleIDPConfig) - } - - if src.MicrosoftIDPConfig != nil { - return json.Marshal(&src.MicrosoftIDPConfig) - } - - if src.OIDCConfig != nil { - return json.Marshal(&src.OIDCConfig) - } - - return nil, nil // no data in oneOf schemas -} - -// Get the actual instance -func (obj *AuthenticationProviderData) GetActualInstance() (interface{}) { - if obj == nil { - return nil - } - if obj.GithubIDPConfig != nil { - return obj.GithubIDPConfig - } - - if obj.GoogleIDPConfig != nil { - return obj.GoogleIDPConfig - } - - if obj.MicrosoftIDPConfig != nil { - return obj.MicrosoftIDPConfig - } - - if obj.OIDCConfig != nil { - return obj.OIDCConfig - } - - // all schemas are nil - return nil -} - -// Get the actual instance value -func (obj AuthenticationProviderData) GetActualInstanceValue() (interface{}) { - if obj.GithubIDPConfig != nil { - return *obj.GithubIDPConfig - } - - if obj.GoogleIDPConfig != nil { - return *obj.GoogleIDPConfig - } - - if obj.MicrosoftIDPConfig != nil { - return *obj.MicrosoftIDPConfig - } - - if obj.OIDCConfig != nil { - return *obj.OIDCConfig - } - - // all schemas are nil - return nil -} - -type NullableAuthenticationProviderData struct { - value *AuthenticationProviderData - isSet bool -} - -func (v NullableAuthenticationProviderData) Get() *AuthenticationProviderData { - return v.value -} - -func (v *NullableAuthenticationProviderData) Set(val *AuthenticationProviderData) { - v.value = val - v.isSet = true -} - -func (v NullableAuthenticationProviderData) IsSet() bool { - return v.isSet -} - -func (v *NullableAuthenticationProviderData) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableAuthenticationProviderData(val *AuthenticationProviderData) *NullableAuthenticationProviderData { - return &NullableAuthenticationProviderData{value: val, isSet: true} -} - -func (v NullableAuthenticationProviderData) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableAuthenticationProviderData) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_authentication_provider_response.go b/membershipclient/model_authentication_provider_response.go deleted file mode 100644 index cf12c7b8..00000000 --- a/membershipclient/model_authentication_provider_response.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the AuthenticationProviderResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &AuthenticationProviderResponse{} - -// AuthenticationProviderResponse struct for AuthenticationProviderResponse -type AuthenticationProviderResponse struct { - Data *AuthenticationProviderResponseData `json:"data,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _AuthenticationProviderResponse AuthenticationProviderResponse - -// NewAuthenticationProviderResponse instantiates a new AuthenticationProviderResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewAuthenticationProviderResponse() *AuthenticationProviderResponse { - this := AuthenticationProviderResponse{} - return &this -} - -// NewAuthenticationProviderResponseWithDefaults instantiates a new AuthenticationProviderResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewAuthenticationProviderResponseWithDefaults() *AuthenticationProviderResponse { - this := AuthenticationProviderResponse{} - return &this -} - -// GetData returns the Data field value if set, zero value otherwise. -func (o *AuthenticationProviderResponse) GetData() AuthenticationProviderResponseData { - if o == nil || IsNil(o.Data) { - var ret AuthenticationProviderResponseData - return ret - } - return *o.Data -} - -// GetDataOk returns a tuple with the Data field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *AuthenticationProviderResponse) GetDataOk() (*AuthenticationProviderResponseData, bool) { - if o == nil || IsNil(o.Data) { - return nil, false - } - return o.Data, true -} - -// HasData returns a boolean if a field has been set. -func (o *AuthenticationProviderResponse) HasData() bool { - if o != nil && !IsNil(o.Data) { - return true - } - - return false -} - -// SetData gets a reference to the given AuthenticationProviderResponseData and assigns it to the Data field. -func (o *AuthenticationProviderResponse) SetData(v AuthenticationProviderResponseData) { - o.Data = &v -} - -func (o AuthenticationProviderResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o AuthenticationProviderResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Data) { - toSerialize["data"] = o.Data - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *AuthenticationProviderResponse) UnmarshalJSON(data []byte) (err error) { - varAuthenticationProviderResponse := _AuthenticationProviderResponse{} - - err = json.Unmarshal(data, &varAuthenticationProviderResponse) - - if err != nil { - return err - } - - *o = AuthenticationProviderResponse(varAuthenticationProviderResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableAuthenticationProviderResponse struct { - value *AuthenticationProviderResponse - isSet bool -} - -func (v NullableAuthenticationProviderResponse) Get() *AuthenticationProviderResponse { - return v.value -} - -func (v *NullableAuthenticationProviderResponse) Set(val *AuthenticationProviderResponse) { - v.value = val - v.isSet = true -} - -func (v NullableAuthenticationProviderResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableAuthenticationProviderResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableAuthenticationProviderResponse(val *AuthenticationProviderResponse) *NullableAuthenticationProviderResponse { - return &NullableAuthenticationProviderResponse{value: val, isSet: true} -} - -func (v NullableAuthenticationProviderResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableAuthenticationProviderResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_authentication_provider_response_data.go b/membershipclient/model_authentication_provider_response_data.go deleted file mode 100644 index ac059e76..00000000 --- a/membershipclient/model_authentication_provider_response_data.go +++ /dev/null @@ -1,408 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "time" - "fmt" -) - -// checks if the AuthenticationProviderResponseData type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &AuthenticationProviderResponseData{} - -// AuthenticationProviderResponseData struct for AuthenticationProviderResponseData -type AuthenticationProviderResponseData struct { - // Type of the authentication provider - Type string `json:"type"` - // Name of the authentication provider - Name string `json:"name"` - // Client ID for the authentication provider - ClientID string `json:"clientID"` - // Client secret for the authentication provider - ClientSecret string `json:"clientSecret"` - Config OIDCConfigAllOfConfig `json:"config"` - // Unique identifier for the authentication provider - OrganizationId string `json:"organizationId"` - // Creation date of the authentication provider - CreatedAt time.Time `json:"createdAt"` - // Last update date of the authentication provider - UpdatedAt time.Time `json:"updatedAt"` - RedirectURI string `json:"redirectURI"` - AdditionalProperties map[string]interface{} -} - -type _AuthenticationProviderResponseData AuthenticationProviderResponseData - -// NewAuthenticationProviderResponseData instantiates a new AuthenticationProviderResponseData object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewAuthenticationProviderResponseData(type_ string, name string, clientID string, clientSecret string, config OIDCConfigAllOfConfig, organizationId string, createdAt time.Time, updatedAt time.Time, redirectURI string) *AuthenticationProviderResponseData { - this := AuthenticationProviderResponseData{} - this.Type = type_ - this.Name = name - this.ClientID = clientID - this.ClientSecret = clientSecret - this.Config = config - this.OrganizationId = organizationId - this.CreatedAt = createdAt - this.UpdatedAt = updatedAt - this.RedirectURI = redirectURI - return &this -} - -// NewAuthenticationProviderResponseDataWithDefaults instantiates a new AuthenticationProviderResponseData object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewAuthenticationProviderResponseDataWithDefaults() *AuthenticationProviderResponseData { - this := AuthenticationProviderResponseData{} - return &this -} - -// GetType returns the Type field value -func (o *AuthenticationProviderResponseData) GetType() string { - if o == nil { - var ret string - return ret - } - - return o.Type -} - -// GetTypeOk returns a tuple with the Type field value -// and a boolean to check if the value has been set. -func (o *AuthenticationProviderResponseData) GetTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Type, true -} - -// SetType sets field value -func (o *AuthenticationProviderResponseData) SetType(v string) { - o.Type = v -} - -// GetName returns the Name field value -func (o *AuthenticationProviderResponseData) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *AuthenticationProviderResponseData) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *AuthenticationProviderResponseData) SetName(v string) { - o.Name = v -} - -// GetClientID returns the ClientID field value -func (o *AuthenticationProviderResponseData) GetClientID() string { - if o == nil { - var ret string - return ret - } - - return o.ClientID -} - -// GetClientIDOk returns a tuple with the ClientID field value -// and a boolean to check if the value has been set. -func (o *AuthenticationProviderResponseData) GetClientIDOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ClientID, true -} - -// SetClientID sets field value -func (o *AuthenticationProviderResponseData) SetClientID(v string) { - o.ClientID = v -} - -// GetClientSecret returns the ClientSecret field value -func (o *AuthenticationProviderResponseData) GetClientSecret() string { - if o == nil { - var ret string - return ret - } - - return o.ClientSecret -} - -// GetClientSecretOk returns a tuple with the ClientSecret field value -// and a boolean to check if the value has been set. -func (o *AuthenticationProviderResponseData) GetClientSecretOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ClientSecret, true -} - -// SetClientSecret sets field value -func (o *AuthenticationProviderResponseData) SetClientSecret(v string) { - o.ClientSecret = v -} - -// GetConfig returns the Config field value -func (o *AuthenticationProviderResponseData) GetConfig() OIDCConfigAllOfConfig { - if o == nil { - var ret OIDCConfigAllOfConfig - return ret - } - - return o.Config -} - -// GetConfigOk returns a tuple with the Config field value -// and a boolean to check if the value has been set. -func (o *AuthenticationProviderResponseData) GetConfigOk() (*OIDCConfigAllOfConfig, bool) { - if o == nil { - return nil, false - } - return &o.Config, true -} - -// SetConfig sets field value -func (o *AuthenticationProviderResponseData) SetConfig(v OIDCConfigAllOfConfig) { - o.Config = v -} - -// GetOrganizationId returns the OrganizationId field value -func (o *AuthenticationProviderResponseData) GetOrganizationId() string { - if o == nil { - var ret string - return ret - } - - return o.OrganizationId -} - -// GetOrganizationIdOk returns a tuple with the OrganizationId field value -// and a boolean to check if the value has been set. -func (o *AuthenticationProviderResponseData) GetOrganizationIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.OrganizationId, true -} - -// SetOrganizationId sets field value -func (o *AuthenticationProviderResponseData) SetOrganizationId(v string) { - o.OrganizationId = v -} - -// GetCreatedAt returns the CreatedAt field value -func (o *AuthenticationProviderResponseData) GetCreatedAt() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.CreatedAt -} - -// GetCreatedAtOk returns a tuple with the CreatedAt field value -// and a boolean to check if the value has been set. -func (o *AuthenticationProviderResponseData) GetCreatedAtOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.CreatedAt, true -} - -// SetCreatedAt sets field value -func (o *AuthenticationProviderResponseData) SetCreatedAt(v time.Time) { - o.CreatedAt = v -} - -// GetUpdatedAt returns the UpdatedAt field value -func (o *AuthenticationProviderResponseData) GetUpdatedAt() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.UpdatedAt -} - -// GetUpdatedAtOk returns a tuple with the UpdatedAt field value -// and a boolean to check if the value has been set. -func (o *AuthenticationProviderResponseData) GetUpdatedAtOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.UpdatedAt, true -} - -// SetUpdatedAt sets field value -func (o *AuthenticationProviderResponseData) SetUpdatedAt(v time.Time) { - o.UpdatedAt = v -} - -// GetRedirectURI returns the RedirectURI field value -func (o *AuthenticationProviderResponseData) GetRedirectURI() string { - if o == nil { - var ret string - return ret - } - - return o.RedirectURI -} - -// GetRedirectURIOk returns a tuple with the RedirectURI field value -// and a boolean to check if the value has been set. -func (o *AuthenticationProviderResponseData) GetRedirectURIOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.RedirectURI, true -} - -// SetRedirectURI sets field value -func (o *AuthenticationProviderResponseData) SetRedirectURI(v string) { - o.RedirectURI = v -} - -func (o AuthenticationProviderResponseData) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o AuthenticationProviderResponseData) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["type"] = o.Type - toSerialize["name"] = o.Name - toSerialize["clientID"] = o.ClientID - toSerialize["clientSecret"] = o.ClientSecret - toSerialize["config"] = o.Config - toSerialize["organizationId"] = o.OrganizationId - toSerialize["createdAt"] = o.CreatedAt - toSerialize["updatedAt"] = o.UpdatedAt - toSerialize["redirectURI"] = o.RedirectURI - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *AuthenticationProviderResponseData) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "type", - "name", - "clientID", - "clientSecret", - "config", - "organizationId", - "createdAt", - "updatedAt", - "redirectURI", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varAuthenticationProviderResponseData := _AuthenticationProviderResponseData{} - - err = json.Unmarshal(data, &varAuthenticationProviderResponseData) - - if err != nil { - return err - } - - *o = AuthenticationProviderResponseData(varAuthenticationProviderResponseData) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "type") - delete(additionalProperties, "name") - delete(additionalProperties, "clientID") - delete(additionalProperties, "clientSecret") - delete(additionalProperties, "config") - delete(additionalProperties, "organizationId") - delete(additionalProperties, "createdAt") - delete(additionalProperties, "updatedAt") - delete(additionalProperties, "redirectURI") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableAuthenticationProviderResponseData struct { - value *AuthenticationProviderResponseData - isSet bool -} - -func (v NullableAuthenticationProviderResponseData) Get() *AuthenticationProviderResponseData { - return v.value -} - -func (v *NullableAuthenticationProviderResponseData) Set(val *AuthenticationProviderResponseData) { - v.value = val - v.isSet = true -} - -func (v NullableAuthenticationProviderResponseData) IsSet() bool { - return v.isSet -} - -func (v *NullableAuthenticationProviderResponseData) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableAuthenticationProviderResponseData(val *AuthenticationProviderResponseData) *NullableAuthenticationProviderResponseData { - return &NullableAuthenticationProviderResponseData{value: val, isSet: true} -} - -func (v NullableAuthenticationProviderResponseData) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableAuthenticationProviderResponseData) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_base_provider_config.go b/membershipclient/model_base_provider_config.go deleted file mode 100644 index 0900c1d2..00000000 --- a/membershipclient/model_base_provider_config.go +++ /dev/null @@ -1,259 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the BaseProviderConfig type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &BaseProviderConfig{} - -// BaseProviderConfig struct for BaseProviderConfig -type BaseProviderConfig struct { - // Type of the authentication provider - Type string `json:"type"` - // Name of the authentication provider - Name string `json:"name"` - // Client ID for the authentication provider - ClientID string `json:"clientID"` - // Client secret for the authentication provider - ClientSecret string `json:"clientSecret"` - AdditionalProperties map[string]interface{} -} - -type _BaseProviderConfig BaseProviderConfig - -// NewBaseProviderConfig instantiates a new BaseProviderConfig object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewBaseProviderConfig(type_ string, name string, clientID string, clientSecret string) *BaseProviderConfig { - this := BaseProviderConfig{} - this.Type = type_ - this.Name = name - this.ClientID = clientID - this.ClientSecret = clientSecret - return &this -} - -// NewBaseProviderConfigWithDefaults instantiates a new BaseProviderConfig object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewBaseProviderConfigWithDefaults() *BaseProviderConfig { - this := BaseProviderConfig{} - return &this -} - -// GetType returns the Type field value -func (o *BaseProviderConfig) GetType() string { - if o == nil { - var ret string - return ret - } - - return o.Type -} - -// GetTypeOk returns a tuple with the Type field value -// and a boolean to check if the value has been set. -func (o *BaseProviderConfig) GetTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Type, true -} - -// SetType sets field value -func (o *BaseProviderConfig) SetType(v string) { - o.Type = v -} - -// GetName returns the Name field value -func (o *BaseProviderConfig) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *BaseProviderConfig) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *BaseProviderConfig) SetName(v string) { - o.Name = v -} - -// GetClientID returns the ClientID field value -func (o *BaseProviderConfig) GetClientID() string { - if o == nil { - var ret string - return ret - } - - return o.ClientID -} - -// GetClientIDOk returns a tuple with the ClientID field value -// and a boolean to check if the value has been set. -func (o *BaseProviderConfig) GetClientIDOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ClientID, true -} - -// SetClientID sets field value -func (o *BaseProviderConfig) SetClientID(v string) { - o.ClientID = v -} - -// GetClientSecret returns the ClientSecret field value -func (o *BaseProviderConfig) GetClientSecret() string { - if o == nil { - var ret string - return ret - } - - return o.ClientSecret -} - -// GetClientSecretOk returns a tuple with the ClientSecret field value -// and a boolean to check if the value has been set. -func (o *BaseProviderConfig) GetClientSecretOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ClientSecret, true -} - -// SetClientSecret sets field value -func (o *BaseProviderConfig) SetClientSecret(v string) { - o.ClientSecret = v -} - -func (o BaseProviderConfig) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o BaseProviderConfig) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["type"] = o.Type - toSerialize["name"] = o.Name - toSerialize["clientID"] = o.ClientID - toSerialize["clientSecret"] = o.ClientSecret - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *BaseProviderConfig) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "type", - "name", - "clientID", - "clientSecret", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varBaseProviderConfig := _BaseProviderConfig{} - - err = json.Unmarshal(data, &varBaseProviderConfig) - - if err != nil { - return err - } - - *o = BaseProviderConfig(varBaseProviderConfig) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "type") - delete(additionalProperties, "name") - delete(additionalProperties, "clientID") - delete(additionalProperties, "clientSecret") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableBaseProviderConfig struct { - value *BaseProviderConfig - isSet bool -} - -func (v NullableBaseProviderConfig) Get() *BaseProviderConfig { - return v.value -} - -func (v *NullableBaseProviderConfig) Set(val *BaseProviderConfig) { - v.value = val - v.isSet = true -} - -func (v NullableBaseProviderConfig) IsSet() bool { - return v.isSet -} - -func (v *NullableBaseProviderConfig) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableBaseProviderConfig(val *BaseProviderConfig) *NullableBaseProviderConfig { - return &NullableBaseProviderConfig{value: val, isSet: true} -} - -func (v NullableBaseProviderConfig) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableBaseProviderConfig) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_capability.go b/membershipclient/model_capability.go deleted file mode 100644 index ede8bf6f..00000000 --- a/membershipclient/model_capability.go +++ /dev/null @@ -1,109 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// Capability the model 'Capability' -type Capability string - -// List of Capability -const ( - MODULE_SELECTION Capability = "MODULE_SELECTION" -) - -// All allowed values of Capability enum -var AllowedCapabilityEnumValues = []Capability{ - "MODULE_SELECTION", -} - -func (v *Capability) UnmarshalJSON(src []byte) error { - var value string - err := json.Unmarshal(src, &value) - if err != nil { - return err - } - enumTypeValue := Capability(value) - for _, existing := range AllowedCapabilityEnumValues { - if existing == enumTypeValue { - *v = enumTypeValue - return nil - } - } - - return fmt.Errorf("%+v is not a valid Capability", value) -} - -// NewCapabilityFromValue returns a pointer to a valid Capability -// for the value passed as argument, or an error if the value passed is not allowed by the enum -func NewCapabilityFromValue(v string) (*Capability, error) { - ev := Capability(v) - if ev.IsValid() { - return &ev, nil - } else { - return nil, fmt.Errorf("invalid value '%v' for Capability: valid values are %v", v, AllowedCapabilityEnumValues) - } -} - -// IsValid return true if the value is valid for the enum, false otherwise -func (v Capability) IsValid() bool { - for _, existing := range AllowedCapabilityEnumValues { - if existing == v { - return true - } - } - return false -} - -// Ptr returns reference to Capability value -func (v Capability) Ptr() *Capability { - return &v -} - -type NullableCapability struct { - value *Capability - isSet bool -} - -func (v NullableCapability) Get() *Capability { - return v.value -} - -func (v *NullableCapability) Set(val *Capability) { - v.value = val - v.isSet = true -} - -func (v NullableCapability) IsSet() bool { - return v.isSet -} - -func (v *NullableCapability) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableCapability(val *Capability) *NullableCapability { - return &NullableCapability{value: val, isSet: true} -} - -func (v NullableCapability) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableCapability) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - diff --git a/membershipclient/model_create_client_response.go b/membershipclient/model_create_client_response.go deleted file mode 100644 index 85bfc3d1..00000000 --- a/membershipclient/model_create_client_response.go +++ /dev/null @@ -1,168 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the CreateClientResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &CreateClientResponse{} - -// CreateClientResponse struct for CreateClientResponse -type CreateClientResponse struct { - Data CreateClientResponseData `json:"data"` - AdditionalProperties map[string]interface{} -} - -type _CreateClientResponse CreateClientResponse - -// NewCreateClientResponse instantiates a new CreateClientResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewCreateClientResponse(data CreateClientResponseData) *CreateClientResponse { - this := CreateClientResponse{} - this.Data = data - return &this -} - -// NewCreateClientResponseWithDefaults instantiates a new CreateClientResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewCreateClientResponseWithDefaults() *CreateClientResponse { - this := CreateClientResponse{} - return &this -} - -// GetData returns the Data field value -func (o *CreateClientResponse) GetData() CreateClientResponseData { - if o == nil { - var ret CreateClientResponseData - return ret - } - - return o.Data -} - -// GetDataOk returns a tuple with the Data field value -// and a boolean to check if the value has been set. -func (o *CreateClientResponse) GetDataOk() (*CreateClientResponseData, bool) { - if o == nil { - return nil, false - } - return &o.Data, true -} - -// SetData sets field value -func (o *CreateClientResponse) SetData(v CreateClientResponseData) { - o.Data = v -} - -func (o CreateClientResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o CreateClientResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["data"] = o.Data - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *CreateClientResponse) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "data", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varCreateClientResponse := _CreateClientResponse{} - - err = json.Unmarshal(data, &varCreateClientResponse) - - if err != nil { - return err - } - - *o = CreateClientResponse(varCreateClientResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableCreateClientResponse struct { - value *CreateClientResponse - isSet bool -} - -func (v NullableCreateClientResponse) Get() *CreateClientResponse { - return v.value -} - -func (v *NullableCreateClientResponse) Set(val *CreateClientResponse) { - v.value = val - v.isSet = true -} - -func (v NullableCreateClientResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableCreateClientResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableCreateClientResponse(val *CreateClientResponse) *NullableCreateClientResponse { - return &NullableCreateClientResponse{value: val, isSet: true} -} - -func (v NullableCreateClientResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableCreateClientResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_create_client_response_all_of_secret.go b/membershipclient/model_create_client_response_all_of_secret.go deleted file mode 100644 index 3968ba5b..00000000 --- a/membershipclient/model_create_client_response_all_of_secret.go +++ /dev/null @@ -1,205 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the CreateClientResponseAllOfSecret type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &CreateClientResponseAllOfSecret{} - -// CreateClientResponseAllOfSecret struct for CreateClientResponseAllOfSecret -type CreateClientResponseAllOfSecret struct { - LastDigits string `json:"lastDigits"` - Clear *string `json:"clear,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _CreateClientResponseAllOfSecret CreateClientResponseAllOfSecret - -// NewCreateClientResponseAllOfSecret instantiates a new CreateClientResponseAllOfSecret object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewCreateClientResponseAllOfSecret(lastDigits string) *CreateClientResponseAllOfSecret { - this := CreateClientResponseAllOfSecret{} - this.LastDigits = lastDigits - return &this -} - -// NewCreateClientResponseAllOfSecretWithDefaults instantiates a new CreateClientResponseAllOfSecret object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewCreateClientResponseAllOfSecretWithDefaults() *CreateClientResponseAllOfSecret { - this := CreateClientResponseAllOfSecret{} - return &this -} - -// GetLastDigits returns the LastDigits field value -func (o *CreateClientResponseAllOfSecret) GetLastDigits() string { - if o == nil { - var ret string - return ret - } - - return o.LastDigits -} - -// GetLastDigitsOk returns a tuple with the LastDigits field value -// and a boolean to check if the value has been set. -func (o *CreateClientResponseAllOfSecret) GetLastDigitsOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.LastDigits, true -} - -// SetLastDigits sets field value -func (o *CreateClientResponseAllOfSecret) SetLastDigits(v string) { - o.LastDigits = v -} - -// GetClear returns the Clear field value if set, zero value otherwise. -func (o *CreateClientResponseAllOfSecret) GetClear() string { - if o == nil || IsNil(o.Clear) { - var ret string - return ret - } - return *o.Clear -} - -// GetClearOk returns a tuple with the Clear field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateClientResponseAllOfSecret) GetClearOk() (*string, bool) { - if o == nil || IsNil(o.Clear) { - return nil, false - } - return o.Clear, true -} - -// HasClear returns a boolean if a field has been set. -func (o *CreateClientResponseAllOfSecret) HasClear() bool { - if o != nil && !IsNil(o.Clear) { - return true - } - - return false -} - -// SetClear gets a reference to the given string and assigns it to the Clear field. -func (o *CreateClientResponseAllOfSecret) SetClear(v string) { - o.Clear = &v -} - -func (o CreateClientResponseAllOfSecret) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o CreateClientResponseAllOfSecret) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["lastDigits"] = o.LastDigits - if !IsNil(o.Clear) { - toSerialize["clear"] = o.Clear - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *CreateClientResponseAllOfSecret) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "lastDigits", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varCreateClientResponseAllOfSecret := _CreateClientResponseAllOfSecret{} - - err = json.Unmarshal(data, &varCreateClientResponseAllOfSecret) - - if err != nil { - return err - } - - *o = CreateClientResponseAllOfSecret(varCreateClientResponseAllOfSecret) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "lastDigits") - delete(additionalProperties, "clear") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableCreateClientResponseAllOfSecret struct { - value *CreateClientResponseAllOfSecret - isSet bool -} - -func (v NullableCreateClientResponseAllOfSecret) Get() *CreateClientResponseAllOfSecret { - return v.value -} - -func (v *NullableCreateClientResponseAllOfSecret) Set(val *CreateClientResponseAllOfSecret) { - v.value = val - v.isSet = true -} - -func (v NullableCreateClientResponseAllOfSecret) IsSet() bool { - return v.isSet -} - -func (v *NullableCreateClientResponseAllOfSecret) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableCreateClientResponseAllOfSecret(val *CreateClientResponseAllOfSecret) *NullableCreateClientResponseAllOfSecret { - return &NullableCreateClientResponseAllOfSecret{value: val, isSet: true} -} - -func (v NullableCreateClientResponseAllOfSecret) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableCreateClientResponseAllOfSecret) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_create_client_response_data.go b/membershipclient/model_create_client_response_data.go deleted file mode 100644 index af0e509a..00000000 --- a/membershipclient/model_create_client_response_data.go +++ /dev/null @@ -1,521 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "time" - "fmt" -) - -// checks if the CreateClientResponseData type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &CreateClientResponseData{} - -// CreateClientResponseData struct for CreateClientResponseData -type CreateClientResponseData struct { - // Organization name - Name string `json:"name"` - DefaultOrganizationAccess *Role `json:"defaultOrganizationAccess,omitempty"` - DefaultStackAccess *Role `json:"defaultStackAccess,omitempty"` - // Organization domain - Domain *string `json:"domain,omitempty"` - // Organization ID - Id string `json:"id"` - // Owner ID - OwnerId string `json:"ownerId"` - // Number of available stacks - AvailableStacks *int32 `json:"availableStacks,omitempty"` - // Number of available sandboxes - AvailableSandboxes *int32 `json:"availableSandboxes,omitempty"` - CreatedAt *time.Time `json:"createdAt,omitempty"` - UpdatedAt *time.Time `json:"updatedAt,omitempty"` - Secret CreateClientResponseDataAllOfSecret `json:"secret"` - AdditionalProperties map[string]interface{} -} - -type _CreateClientResponseData CreateClientResponseData - -// NewCreateClientResponseData instantiates a new CreateClientResponseData object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewCreateClientResponseData(name string, id string, ownerId string, secret CreateClientResponseDataAllOfSecret) *CreateClientResponseData { - this := CreateClientResponseData{} - this.Name = name - this.Id = id - this.OwnerId = ownerId - this.Secret = secret - return &this -} - -// NewCreateClientResponseDataWithDefaults instantiates a new CreateClientResponseData object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewCreateClientResponseDataWithDefaults() *CreateClientResponseData { - this := CreateClientResponseData{} - return &this -} - -// GetName returns the Name field value -func (o *CreateClientResponseData) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *CreateClientResponseData) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *CreateClientResponseData) SetName(v string) { - o.Name = v -} - -// GetDefaultOrganizationAccess returns the DefaultOrganizationAccess field value if set, zero value otherwise. -func (o *CreateClientResponseData) GetDefaultOrganizationAccess() Role { - if o == nil || IsNil(o.DefaultOrganizationAccess) { - var ret Role - return ret - } - return *o.DefaultOrganizationAccess -} - -// GetDefaultOrganizationAccessOk returns a tuple with the DefaultOrganizationAccess field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateClientResponseData) GetDefaultOrganizationAccessOk() (*Role, bool) { - if o == nil || IsNil(o.DefaultOrganizationAccess) { - return nil, false - } - return o.DefaultOrganizationAccess, true -} - -// HasDefaultOrganizationAccess returns a boolean if a field has been set. -func (o *CreateClientResponseData) HasDefaultOrganizationAccess() bool { - if o != nil && !IsNil(o.DefaultOrganizationAccess) { - return true - } - - return false -} - -// SetDefaultOrganizationAccess gets a reference to the given Role and assigns it to the DefaultOrganizationAccess field. -func (o *CreateClientResponseData) SetDefaultOrganizationAccess(v Role) { - o.DefaultOrganizationAccess = &v -} - -// GetDefaultStackAccess returns the DefaultStackAccess field value if set, zero value otherwise. -func (o *CreateClientResponseData) GetDefaultStackAccess() Role { - if o == nil || IsNil(o.DefaultStackAccess) { - var ret Role - return ret - } - return *o.DefaultStackAccess -} - -// GetDefaultStackAccessOk returns a tuple with the DefaultStackAccess field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateClientResponseData) GetDefaultStackAccessOk() (*Role, bool) { - if o == nil || IsNil(o.DefaultStackAccess) { - return nil, false - } - return o.DefaultStackAccess, true -} - -// HasDefaultStackAccess returns a boolean if a field has been set. -func (o *CreateClientResponseData) HasDefaultStackAccess() bool { - if o != nil && !IsNil(o.DefaultStackAccess) { - return true - } - - return false -} - -// SetDefaultStackAccess gets a reference to the given Role and assigns it to the DefaultStackAccess field. -func (o *CreateClientResponseData) SetDefaultStackAccess(v Role) { - o.DefaultStackAccess = &v -} - -// GetDomain returns the Domain field value if set, zero value otherwise. -func (o *CreateClientResponseData) GetDomain() string { - if o == nil || IsNil(o.Domain) { - var ret string - return ret - } - return *o.Domain -} - -// GetDomainOk returns a tuple with the Domain field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateClientResponseData) GetDomainOk() (*string, bool) { - if o == nil || IsNil(o.Domain) { - return nil, false - } - return o.Domain, true -} - -// HasDomain returns a boolean if a field has been set. -func (o *CreateClientResponseData) HasDomain() bool { - if o != nil && !IsNil(o.Domain) { - return true - } - - return false -} - -// SetDomain gets a reference to the given string and assigns it to the Domain field. -func (o *CreateClientResponseData) SetDomain(v string) { - o.Domain = &v -} - -// GetId returns the Id field value -func (o *CreateClientResponseData) GetId() string { - if o == nil { - var ret string - return ret - } - - return o.Id -} - -// GetIdOk returns a tuple with the Id field value -// and a boolean to check if the value has been set. -func (o *CreateClientResponseData) GetIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Id, true -} - -// SetId sets field value -func (o *CreateClientResponseData) SetId(v string) { - o.Id = v -} - -// GetOwnerId returns the OwnerId field value -func (o *CreateClientResponseData) GetOwnerId() string { - if o == nil { - var ret string - return ret - } - - return o.OwnerId -} - -// GetOwnerIdOk returns a tuple with the OwnerId field value -// and a boolean to check if the value has been set. -func (o *CreateClientResponseData) GetOwnerIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.OwnerId, true -} - -// SetOwnerId sets field value -func (o *CreateClientResponseData) SetOwnerId(v string) { - o.OwnerId = v -} - -// GetAvailableStacks returns the AvailableStacks field value if set, zero value otherwise. -func (o *CreateClientResponseData) GetAvailableStacks() int32 { - if o == nil || IsNil(o.AvailableStacks) { - var ret int32 - return ret - } - return *o.AvailableStacks -} - -// GetAvailableStacksOk returns a tuple with the AvailableStacks field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateClientResponseData) GetAvailableStacksOk() (*int32, bool) { - if o == nil || IsNil(o.AvailableStacks) { - return nil, false - } - return o.AvailableStacks, true -} - -// HasAvailableStacks returns a boolean if a field has been set. -func (o *CreateClientResponseData) HasAvailableStacks() bool { - if o != nil && !IsNil(o.AvailableStacks) { - return true - } - - return false -} - -// SetAvailableStacks gets a reference to the given int32 and assigns it to the AvailableStacks field. -func (o *CreateClientResponseData) SetAvailableStacks(v int32) { - o.AvailableStacks = &v -} - -// GetAvailableSandboxes returns the AvailableSandboxes field value if set, zero value otherwise. -func (o *CreateClientResponseData) GetAvailableSandboxes() int32 { - if o == nil || IsNil(o.AvailableSandboxes) { - var ret int32 - return ret - } - return *o.AvailableSandboxes -} - -// GetAvailableSandboxesOk returns a tuple with the AvailableSandboxes field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateClientResponseData) GetAvailableSandboxesOk() (*int32, bool) { - if o == nil || IsNil(o.AvailableSandboxes) { - return nil, false - } - return o.AvailableSandboxes, true -} - -// HasAvailableSandboxes returns a boolean if a field has been set. -func (o *CreateClientResponseData) HasAvailableSandboxes() bool { - if o != nil && !IsNil(o.AvailableSandboxes) { - return true - } - - return false -} - -// SetAvailableSandboxes gets a reference to the given int32 and assigns it to the AvailableSandboxes field. -func (o *CreateClientResponseData) SetAvailableSandboxes(v int32) { - o.AvailableSandboxes = &v -} - -// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise. -func (o *CreateClientResponseData) GetCreatedAt() time.Time { - if o == nil || IsNil(o.CreatedAt) { - var ret time.Time - return ret - } - return *o.CreatedAt -} - -// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateClientResponseData) GetCreatedAtOk() (*time.Time, bool) { - if o == nil || IsNil(o.CreatedAt) { - return nil, false - } - return o.CreatedAt, true -} - -// HasCreatedAt returns a boolean if a field has been set. -func (o *CreateClientResponseData) HasCreatedAt() bool { - if o != nil && !IsNil(o.CreatedAt) { - return true - } - - return false -} - -// SetCreatedAt gets a reference to the given time.Time and assigns it to the CreatedAt field. -func (o *CreateClientResponseData) SetCreatedAt(v time.Time) { - o.CreatedAt = &v -} - -// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise. -func (o *CreateClientResponseData) GetUpdatedAt() time.Time { - if o == nil || IsNil(o.UpdatedAt) { - var ret time.Time - return ret - } - return *o.UpdatedAt -} - -// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateClientResponseData) GetUpdatedAtOk() (*time.Time, bool) { - if o == nil || IsNil(o.UpdatedAt) { - return nil, false - } - return o.UpdatedAt, true -} - -// HasUpdatedAt returns a boolean if a field has been set. -func (o *CreateClientResponseData) HasUpdatedAt() bool { - if o != nil && !IsNil(o.UpdatedAt) { - return true - } - - return false -} - -// SetUpdatedAt gets a reference to the given time.Time and assigns it to the UpdatedAt field. -func (o *CreateClientResponseData) SetUpdatedAt(v time.Time) { - o.UpdatedAt = &v -} - -// GetSecret returns the Secret field value -func (o *CreateClientResponseData) GetSecret() CreateClientResponseDataAllOfSecret { - if o == nil { - var ret CreateClientResponseDataAllOfSecret - return ret - } - - return o.Secret -} - -// GetSecretOk returns a tuple with the Secret field value -// and a boolean to check if the value has been set. -func (o *CreateClientResponseData) GetSecretOk() (*CreateClientResponseDataAllOfSecret, bool) { - if o == nil { - return nil, false - } - return &o.Secret, true -} - -// SetSecret sets field value -func (o *CreateClientResponseData) SetSecret(v CreateClientResponseDataAllOfSecret) { - o.Secret = v -} - -func (o CreateClientResponseData) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o CreateClientResponseData) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["name"] = o.Name - if !IsNil(o.DefaultOrganizationAccess) { - toSerialize["defaultOrganizationAccess"] = o.DefaultOrganizationAccess - } - if !IsNil(o.DefaultStackAccess) { - toSerialize["defaultStackAccess"] = o.DefaultStackAccess - } - if !IsNil(o.Domain) { - toSerialize["domain"] = o.Domain - } - toSerialize["id"] = o.Id - toSerialize["ownerId"] = o.OwnerId - if !IsNil(o.AvailableStacks) { - toSerialize["availableStacks"] = o.AvailableStacks - } - if !IsNil(o.AvailableSandboxes) { - toSerialize["availableSandboxes"] = o.AvailableSandboxes - } - if !IsNil(o.CreatedAt) { - toSerialize["createdAt"] = o.CreatedAt - } - if !IsNil(o.UpdatedAt) { - toSerialize["updatedAt"] = o.UpdatedAt - } - toSerialize["secret"] = o.Secret - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *CreateClientResponseData) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "name", - "id", - "ownerId", - "secret", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varCreateClientResponseData := _CreateClientResponseData{} - - err = json.Unmarshal(data, &varCreateClientResponseData) - - if err != nil { - return err - } - - *o = CreateClientResponseData(varCreateClientResponseData) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "name") - delete(additionalProperties, "defaultOrganizationAccess") - delete(additionalProperties, "defaultStackAccess") - delete(additionalProperties, "domain") - delete(additionalProperties, "id") - delete(additionalProperties, "ownerId") - delete(additionalProperties, "availableStacks") - delete(additionalProperties, "availableSandboxes") - delete(additionalProperties, "createdAt") - delete(additionalProperties, "updatedAt") - delete(additionalProperties, "secret") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableCreateClientResponseData struct { - value *CreateClientResponseData - isSet bool -} - -func (v NullableCreateClientResponseData) Get() *CreateClientResponseData { - return v.value -} - -func (v *NullableCreateClientResponseData) Set(val *CreateClientResponseData) { - v.value = val - v.isSet = true -} - -func (v NullableCreateClientResponseData) IsSet() bool { - return v.isSet -} - -func (v *NullableCreateClientResponseData) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableCreateClientResponseData(val *CreateClientResponseData) *NullableCreateClientResponseData { - return &NullableCreateClientResponseData{value: val, isSet: true} -} - -func (v NullableCreateClientResponseData) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableCreateClientResponseData) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_create_client_response_data_all_of_secret.go b/membershipclient/model_create_client_response_data_all_of_secret.go deleted file mode 100644 index abb9ee37..00000000 --- a/membershipclient/model_create_client_response_data_all_of_secret.go +++ /dev/null @@ -1,205 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the CreateClientResponseDataAllOfSecret type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &CreateClientResponseDataAllOfSecret{} - -// CreateClientResponseDataAllOfSecret struct for CreateClientResponseDataAllOfSecret -type CreateClientResponseDataAllOfSecret struct { - LastDigits string `json:"lastDigits"` - Clear *string `json:"clear,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _CreateClientResponseDataAllOfSecret CreateClientResponseDataAllOfSecret - -// NewCreateClientResponseDataAllOfSecret instantiates a new CreateClientResponseDataAllOfSecret object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewCreateClientResponseDataAllOfSecret(lastDigits string) *CreateClientResponseDataAllOfSecret { - this := CreateClientResponseDataAllOfSecret{} - this.LastDigits = lastDigits - return &this -} - -// NewCreateClientResponseDataAllOfSecretWithDefaults instantiates a new CreateClientResponseDataAllOfSecret object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewCreateClientResponseDataAllOfSecretWithDefaults() *CreateClientResponseDataAllOfSecret { - this := CreateClientResponseDataAllOfSecret{} - return &this -} - -// GetLastDigits returns the LastDigits field value -func (o *CreateClientResponseDataAllOfSecret) GetLastDigits() string { - if o == nil { - var ret string - return ret - } - - return o.LastDigits -} - -// GetLastDigitsOk returns a tuple with the LastDigits field value -// and a boolean to check if the value has been set. -func (o *CreateClientResponseDataAllOfSecret) GetLastDigitsOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.LastDigits, true -} - -// SetLastDigits sets field value -func (o *CreateClientResponseDataAllOfSecret) SetLastDigits(v string) { - o.LastDigits = v -} - -// GetClear returns the Clear field value if set, zero value otherwise. -func (o *CreateClientResponseDataAllOfSecret) GetClear() string { - if o == nil || IsNil(o.Clear) { - var ret string - return ret - } - return *o.Clear -} - -// GetClearOk returns a tuple with the Clear field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateClientResponseDataAllOfSecret) GetClearOk() (*string, bool) { - if o == nil || IsNil(o.Clear) { - return nil, false - } - return o.Clear, true -} - -// HasClear returns a boolean if a field has been set. -func (o *CreateClientResponseDataAllOfSecret) HasClear() bool { - if o != nil && !IsNil(o.Clear) { - return true - } - - return false -} - -// SetClear gets a reference to the given string and assigns it to the Clear field. -func (o *CreateClientResponseDataAllOfSecret) SetClear(v string) { - o.Clear = &v -} - -func (o CreateClientResponseDataAllOfSecret) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o CreateClientResponseDataAllOfSecret) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["lastDigits"] = o.LastDigits - if !IsNil(o.Clear) { - toSerialize["clear"] = o.Clear - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *CreateClientResponseDataAllOfSecret) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "lastDigits", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varCreateClientResponseDataAllOfSecret := _CreateClientResponseDataAllOfSecret{} - - err = json.Unmarshal(data, &varCreateClientResponseDataAllOfSecret) - - if err != nil { - return err - } - - *o = CreateClientResponseDataAllOfSecret(varCreateClientResponseDataAllOfSecret) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "lastDigits") - delete(additionalProperties, "clear") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableCreateClientResponseDataAllOfSecret struct { - value *CreateClientResponseDataAllOfSecret - isSet bool -} - -func (v NullableCreateClientResponseDataAllOfSecret) Get() *CreateClientResponseDataAllOfSecret { - return v.value -} - -func (v *NullableCreateClientResponseDataAllOfSecret) Set(val *CreateClientResponseDataAllOfSecret) { - v.value = val - v.isSet = true -} - -func (v NullableCreateClientResponseDataAllOfSecret) IsSet() bool { - return v.isSet -} - -func (v *NullableCreateClientResponseDataAllOfSecret) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableCreateClientResponseDataAllOfSecret(val *CreateClientResponseDataAllOfSecret) *NullableCreateClientResponseDataAllOfSecret { - return &NullableCreateClientResponseDataAllOfSecret{value: val, isSet: true} -} - -func (v NullableCreateClientResponseDataAllOfSecret) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableCreateClientResponseDataAllOfSecret) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_create_client_response_response.go b/membershipclient/model_create_client_response_response.go deleted file mode 100644 index 21803ad5..00000000 --- a/membershipclient/model_create_client_response_response.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the CreateClientResponseResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &CreateClientResponseResponse{} - -// CreateClientResponseResponse struct for CreateClientResponseResponse -type CreateClientResponseResponse struct { - Data *CreateClientResponseResponseData `json:"data,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _CreateClientResponseResponse CreateClientResponseResponse - -// NewCreateClientResponseResponse instantiates a new CreateClientResponseResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewCreateClientResponseResponse() *CreateClientResponseResponse { - this := CreateClientResponseResponse{} - return &this -} - -// NewCreateClientResponseResponseWithDefaults instantiates a new CreateClientResponseResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewCreateClientResponseResponseWithDefaults() *CreateClientResponseResponse { - this := CreateClientResponseResponse{} - return &this -} - -// GetData returns the Data field value if set, zero value otherwise. -func (o *CreateClientResponseResponse) GetData() CreateClientResponseResponseData { - if o == nil || IsNil(o.Data) { - var ret CreateClientResponseResponseData - return ret - } - return *o.Data -} - -// GetDataOk returns a tuple with the Data field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateClientResponseResponse) GetDataOk() (*CreateClientResponseResponseData, bool) { - if o == nil || IsNil(o.Data) { - return nil, false - } - return o.Data, true -} - -// HasData returns a boolean if a field has been set. -func (o *CreateClientResponseResponse) HasData() bool { - if o != nil && !IsNil(o.Data) { - return true - } - - return false -} - -// SetData gets a reference to the given CreateClientResponseResponseData and assigns it to the Data field. -func (o *CreateClientResponseResponse) SetData(v CreateClientResponseResponseData) { - o.Data = &v -} - -func (o CreateClientResponseResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o CreateClientResponseResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Data) { - toSerialize["data"] = o.Data - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *CreateClientResponseResponse) UnmarshalJSON(data []byte) (err error) { - varCreateClientResponseResponse := _CreateClientResponseResponse{} - - err = json.Unmarshal(data, &varCreateClientResponseResponse) - - if err != nil { - return err - } - - *o = CreateClientResponseResponse(varCreateClientResponseResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableCreateClientResponseResponse struct { - value *CreateClientResponseResponse - isSet bool -} - -func (v NullableCreateClientResponseResponse) Get() *CreateClientResponseResponse { - return v.value -} - -func (v *NullableCreateClientResponseResponse) Set(val *CreateClientResponseResponse) { - v.value = val - v.isSet = true -} - -func (v NullableCreateClientResponseResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableCreateClientResponseResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableCreateClientResponseResponse(val *CreateClientResponseResponse) *NullableCreateClientResponseResponse { - return &NullableCreateClientResponseResponse{value: val, isSet: true} -} - -func (v NullableCreateClientResponseResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableCreateClientResponseResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_create_client_response_response_data.go b/membershipclient/model_create_client_response_response_data.go deleted file mode 100644 index bc154b5e..00000000 --- a/membershipclient/model_create_client_response_response_data.go +++ /dev/null @@ -1,347 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "time" - "fmt" -) - -// checks if the CreateClientResponseResponseData type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &CreateClientResponseResponseData{} - -// CreateClientResponseResponseData struct for CreateClientResponseResponseData -type CreateClientResponseResponseData struct { - // Organization ID - Id string `json:"id"` - Secret OrganizationClientSecret `json:"secret"` - // Name of the client - Name string `json:"name"` - // Description of the client - Description string `json:"description"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - // The ID of the owner of the client (DEPRECATED will be empty) - OwnerId string `json:"ownerId"` - AdditionalProperties map[string]interface{} -} - -type _CreateClientResponseResponseData CreateClientResponseResponseData - -// NewCreateClientResponseResponseData instantiates a new CreateClientResponseResponseData object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewCreateClientResponseResponseData(id string, secret OrganizationClientSecret, name string, description string, createdAt time.Time, updatedAt time.Time, ownerId string) *CreateClientResponseResponseData { - this := CreateClientResponseResponseData{} - this.Id = id - this.Secret = secret - this.Name = name - this.Description = description - this.CreatedAt = createdAt - this.UpdatedAt = updatedAt - this.OwnerId = ownerId - return &this -} - -// NewCreateClientResponseResponseDataWithDefaults instantiates a new CreateClientResponseResponseData object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewCreateClientResponseResponseDataWithDefaults() *CreateClientResponseResponseData { - this := CreateClientResponseResponseData{} - return &this -} - -// GetId returns the Id field value -func (o *CreateClientResponseResponseData) GetId() string { - if o == nil { - var ret string - return ret - } - - return o.Id -} - -// GetIdOk returns a tuple with the Id field value -// and a boolean to check if the value has been set. -func (o *CreateClientResponseResponseData) GetIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Id, true -} - -// SetId sets field value -func (o *CreateClientResponseResponseData) SetId(v string) { - o.Id = v -} - -// GetSecret returns the Secret field value -func (o *CreateClientResponseResponseData) GetSecret() OrganizationClientSecret { - if o == nil { - var ret OrganizationClientSecret - return ret - } - - return o.Secret -} - -// GetSecretOk returns a tuple with the Secret field value -// and a boolean to check if the value has been set. -func (o *CreateClientResponseResponseData) GetSecretOk() (*OrganizationClientSecret, bool) { - if o == nil { - return nil, false - } - return &o.Secret, true -} - -// SetSecret sets field value -func (o *CreateClientResponseResponseData) SetSecret(v OrganizationClientSecret) { - o.Secret = v -} - -// GetName returns the Name field value -func (o *CreateClientResponseResponseData) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *CreateClientResponseResponseData) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *CreateClientResponseResponseData) SetName(v string) { - o.Name = v -} - -// GetDescription returns the Description field value -func (o *CreateClientResponseResponseData) GetDescription() string { - if o == nil { - var ret string - return ret - } - - return o.Description -} - -// GetDescriptionOk returns a tuple with the Description field value -// and a boolean to check if the value has been set. -func (o *CreateClientResponseResponseData) GetDescriptionOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Description, true -} - -// SetDescription sets field value -func (o *CreateClientResponseResponseData) SetDescription(v string) { - o.Description = v -} - -// GetCreatedAt returns the CreatedAt field value -func (o *CreateClientResponseResponseData) GetCreatedAt() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.CreatedAt -} - -// GetCreatedAtOk returns a tuple with the CreatedAt field value -// and a boolean to check if the value has been set. -func (o *CreateClientResponseResponseData) GetCreatedAtOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.CreatedAt, true -} - -// SetCreatedAt sets field value -func (o *CreateClientResponseResponseData) SetCreatedAt(v time.Time) { - o.CreatedAt = v -} - -// GetUpdatedAt returns the UpdatedAt field value -func (o *CreateClientResponseResponseData) GetUpdatedAt() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.UpdatedAt -} - -// GetUpdatedAtOk returns a tuple with the UpdatedAt field value -// and a boolean to check if the value has been set. -func (o *CreateClientResponseResponseData) GetUpdatedAtOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.UpdatedAt, true -} - -// SetUpdatedAt sets field value -func (o *CreateClientResponseResponseData) SetUpdatedAt(v time.Time) { - o.UpdatedAt = v -} - -// GetOwnerId returns the OwnerId field value -func (o *CreateClientResponseResponseData) GetOwnerId() string { - if o == nil { - var ret string - return ret - } - - return o.OwnerId -} - -// GetOwnerIdOk returns a tuple with the OwnerId field value -// and a boolean to check if the value has been set. -func (o *CreateClientResponseResponseData) GetOwnerIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.OwnerId, true -} - -// SetOwnerId sets field value -func (o *CreateClientResponseResponseData) SetOwnerId(v string) { - o.OwnerId = v -} - -func (o CreateClientResponseResponseData) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o CreateClientResponseResponseData) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["id"] = o.Id - toSerialize["secret"] = o.Secret - toSerialize["name"] = o.Name - toSerialize["description"] = o.Description - toSerialize["createdAt"] = o.CreatedAt - toSerialize["updatedAt"] = o.UpdatedAt - toSerialize["ownerId"] = o.OwnerId - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *CreateClientResponseResponseData) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "id", - "secret", - "name", - "description", - "createdAt", - "updatedAt", - "ownerId", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varCreateClientResponseResponseData := _CreateClientResponseResponseData{} - - err = json.Unmarshal(data, &varCreateClientResponseResponseData) - - if err != nil { - return err - } - - *o = CreateClientResponseResponseData(varCreateClientResponseResponseData) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "id") - delete(additionalProperties, "secret") - delete(additionalProperties, "name") - delete(additionalProperties, "description") - delete(additionalProperties, "createdAt") - delete(additionalProperties, "updatedAt") - delete(additionalProperties, "ownerId") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableCreateClientResponseResponseData struct { - value *CreateClientResponseResponseData - isSet bool -} - -func (v NullableCreateClientResponseResponseData) Get() *CreateClientResponseResponseData { - return v.value -} - -func (v *NullableCreateClientResponseResponseData) Set(val *CreateClientResponseResponseData) { - v.value = val - v.isSet = true -} - -func (v NullableCreateClientResponseResponseData) IsSet() bool { - return v.isSet -} - -func (v *NullableCreateClientResponseResponseData) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableCreateClientResponseResponseData(val *CreateClientResponseResponseData) *NullableCreateClientResponseResponseData { - return &NullableCreateClientResponseResponseData{value: val, isSet: true} -} - -func (v NullableCreateClientResponseResponseData) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableCreateClientResponseResponseData) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_create_invitation_response.go b/membershipclient/model_create_invitation_response.go deleted file mode 100644 index a83739cb..00000000 --- a/membershipclient/model_create_invitation_response.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the CreateInvitationResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &CreateInvitationResponse{} - -// CreateInvitationResponse struct for CreateInvitationResponse -type CreateInvitationResponse struct { - Data *Invitation `json:"data,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _CreateInvitationResponse CreateInvitationResponse - -// NewCreateInvitationResponse instantiates a new CreateInvitationResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewCreateInvitationResponse() *CreateInvitationResponse { - this := CreateInvitationResponse{} - return &this -} - -// NewCreateInvitationResponseWithDefaults instantiates a new CreateInvitationResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewCreateInvitationResponseWithDefaults() *CreateInvitationResponse { - this := CreateInvitationResponse{} - return &this -} - -// GetData returns the Data field value if set, zero value otherwise. -func (o *CreateInvitationResponse) GetData() Invitation { - if o == nil || IsNil(o.Data) { - var ret Invitation - return ret - } - return *o.Data -} - -// GetDataOk returns a tuple with the Data field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateInvitationResponse) GetDataOk() (*Invitation, bool) { - if o == nil || IsNil(o.Data) { - return nil, false - } - return o.Data, true -} - -// HasData returns a boolean if a field has been set. -func (o *CreateInvitationResponse) HasData() bool { - if o != nil && !IsNil(o.Data) { - return true - } - - return false -} - -// SetData gets a reference to the given Invitation and assigns it to the Data field. -func (o *CreateInvitationResponse) SetData(v Invitation) { - o.Data = &v -} - -func (o CreateInvitationResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o CreateInvitationResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Data) { - toSerialize["data"] = o.Data - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *CreateInvitationResponse) UnmarshalJSON(data []byte) (err error) { - varCreateInvitationResponse := _CreateInvitationResponse{} - - err = json.Unmarshal(data, &varCreateInvitationResponse) - - if err != nil { - return err - } - - *o = CreateInvitationResponse(varCreateInvitationResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableCreateInvitationResponse struct { - value *CreateInvitationResponse - isSet bool -} - -func (v NullableCreateInvitationResponse) Get() *CreateInvitationResponse { - return v.value -} - -func (v *NullableCreateInvitationResponse) Set(val *CreateInvitationResponse) { - v.value = val - v.isSet = true -} - -func (v NullableCreateInvitationResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableCreateInvitationResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableCreateInvitationResponse(val *CreateInvitationResponse) *NullableCreateInvitationResponse { - return &NullableCreateInvitationResponse{value: val, isSet: true} -} - -func (v NullableCreateInvitationResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableCreateInvitationResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_create_organization_client_request.go b/membershipclient/model_create_organization_client_request.go deleted file mode 100644 index 37dc2627..00000000 --- a/membershipclient/model_create_organization_client_request.go +++ /dev/null @@ -1,194 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the CreateOrganizationClientRequest type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &CreateOrganizationClientRequest{} - -// CreateOrganizationClientRequest struct for CreateOrganizationClientRequest -type CreateOrganizationClientRequest struct { - // Name of the client - Name *string `json:"name,omitempty"` - // Description of the client - Description *string `json:"description,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _CreateOrganizationClientRequest CreateOrganizationClientRequest - -// NewCreateOrganizationClientRequest instantiates a new CreateOrganizationClientRequest object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewCreateOrganizationClientRequest() *CreateOrganizationClientRequest { - this := CreateOrganizationClientRequest{} - return &this -} - -// NewCreateOrganizationClientRequestWithDefaults instantiates a new CreateOrganizationClientRequest object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewCreateOrganizationClientRequestWithDefaults() *CreateOrganizationClientRequest { - this := CreateOrganizationClientRequest{} - return &this -} - -// GetName returns the Name field value if set, zero value otherwise. -func (o *CreateOrganizationClientRequest) GetName() string { - if o == nil || IsNil(o.Name) { - var ret string - return ret - } - return *o.Name -} - -// GetNameOk returns a tuple with the Name field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateOrganizationClientRequest) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { - return nil, false - } - return o.Name, true -} - -// HasName returns a boolean if a field has been set. -func (o *CreateOrganizationClientRequest) HasName() bool { - if o != nil && !IsNil(o.Name) { - return true - } - - return false -} - -// SetName gets a reference to the given string and assigns it to the Name field. -func (o *CreateOrganizationClientRequest) SetName(v string) { - o.Name = &v -} - -// GetDescription returns the Description field value if set, zero value otherwise. -func (o *CreateOrganizationClientRequest) GetDescription() string { - if o == nil || IsNil(o.Description) { - var ret string - return ret - } - return *o.Description -} - -// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateOrganizationClientRequest) GetDescriptionOk() (*string, bool) { - if o == nil || IsNil(o.Description) { - return nil, false - } - return o.Description, true -} - -// HasDescription returns a boolean if a field has been set. -func (o *CreateOrganizationClientRequest) HasDescription() bool { - if o != nil && !IsNil(o.Description) { - return true - } - - return false -} - -// SetDescription gets a reference to the given string and assigns it to the Description field. -func (o *CreateOrganizationClientRequest) SetDescription(v string) { - o.Description = &v -} - -func (o CreateOrganizationClientRequest) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o CreateOrganizationClientRequest) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Name) { - toSerialize["name"] = o.Name - } - if !IsNil(o.Description) { - toSerialize["description"] = o.Description - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *CreateOrganizationClientRequest) UnmarshalJSON(data []byte) (err error) { - varCreateOrganizationClientRequest := _CreateOrganizationClientRequest{} - - err = json.Unmarshal(data, &varCreateOrganizationClientRequest) - - if err != nil { - return err - } - - *o = CreateOrganizationClientRequest(varCreateOrganizationClientRequest) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "name") - delete(additionalProperties, "description") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableCreateOrganizationClientRequest struct { - value *CreateOrganizationClientRequest - isSet bool -} - -func (v NullableCreateOrganizationClientRequest) Get() *CreateOrganizationClientRequest { - return v.value -} - -func (v *NullableCreateOrganizationClientRequest) Set(val *CreateOrganizationClientRequest) { - v.value = val - v.isSet = true -} - -func (v NullableCreateOrganizationClientRequest) IsSet() bool { - return v.isSet -} - -func (v *NullableCreateOrganizationClientRequest) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableCreateOrganizationClientRequest(val *CreateOrganizationClientRequest) *NullableCreateOrganizationClientRequest { - return &NullableCreateOrganizationClientRequest{value: val, isSet: true} -} - -func (v NullableCreateOrganizationClientRequest) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableCreateOrganizationClientRequest) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_create_organization_client_response.go b/membershipclient/model_create_organization_client_response.go deleted file mode 100644 index 245c150e..00000000 --- a/membershipclient/model_create_organization_client_response.go +++ /dev/null @@ -1,168 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the CreateOrganizationClientResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &CreateOrganizationClientResponse{} - -// CreateOrganizationClientResponse struct for CreateOrganizationClientResponse -type CreateOrganizationClientResponse struct { - Data OrganizationClient `json:"data"` - AdditionalProperties map[string]interface{} -} - -type _CreateOrganizationClientResponse CreateOrganizationClientResponse - -// NewCreateOrganizationClientResponse instantiates a new CreateOrganizationClientResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewCreateOrganizationClientResponse(data OrganizationClient) *CreateOrganizationClientResponse { - this := CreateOrganizationClientResponse{} - this.Data = data - return &this -} - -// NewCreateOrganizationClientResponseWithDefaults instantiates a new CreateOrganizationClientResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewCreateOrganizationClientResponseWithDefaults() *CreateOrganizationClientResponse { - this := CreateOrganizationClientResponse{} - return &this -} - -// GetData returns the Data field value -func (o *CreateOrganizationClientResponse) GetData() OrganizationClient { - if o == nil { - var ret OrganizationClient - return ret - } - - return o.Data -} - -// GetDataOk returns a tuple with the Data field value -// and a boolean to check if the value has been set. -func (o *CreateOrganizationClientResponse) GetDataOk() (*OrganizationClient, bool) { - if o == nil { - return nil, false - } - return &o.Data, true -} - -// SetData sets field value -func (o *CreateOrganizationClientResponse) SetData(v OrganizationClient) { - o.Data = v -} - -func (o CreateOrganizationClientResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o CreateOrganizationClientResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["data"] = o.Data - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *CreateOrganizationClientResponse) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "data", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varCreateOrganizationClientResponse := _CreateOrganizationClientResponse{} - - err = json.Unmarshal(data, &varCreateOrganizationClientResponse) - - if err != nil { - return err - } - - *o = CreateOrganizationClientResponse(varCreateOrganizationClientResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableCreateOrganizationClientResponse struct { - value *CreateOrganizationClientResponse - isSet bool -} - -func (v NullableCreateOrganizationClientResponse) Get() *CreateOrganizationClientResponse { - return v.value -} - -func (v *NullableCreateOrganizationClientResponse) Set(val *CreateOrganizationClientResponse) { - v.value = val - v.isSet = true -} - -func (v NullableCreateOrganizationClientResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableCreateOrganizationClientResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableCreateOrganizationClientResponse(val *CreateOrganizationClientResponse) *NullableCreateOrganizationClientResponse { - return &NullableCreateOrganizationClientResponse{value: val, isSet: true} -} - -func (v NullableCreateOrganizationClientResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableCreateOrganizationClientResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_create_organization_response.go b/membershipclient/model_create_organization_response.go deleted file mode 100644 index 5e6af79f..00000000 --- a/membershipclient/model_create_organization_response.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the CreateOrganizationResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &CreateOrganizationResponse{} - -// CreateOrganizationResponse struct for CreateOrganizationResponse -type CreateOrganizationResponse struct { - Data *OrganizationExpanded `json:"data,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _CreateOrganizationResponse CreateOrganizationResponse - -// NewCreateOrganizationResponse instantiates a new CreateOrganizationResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewCreateOrganizationResponse() *CreateOrganizationResponse { - this := CreateOrganizationResponse{} - return &this -} - -// NewCreateOrganizationResponseWithDefaults instantiates a new CreateOrganizationResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewCreateOrganizationResponseWithDefaults() *CreateOrganizationResponse { - this := CreateOrganizationResponse{} - return &this -} - -// GetData returns the Data field value if set, zero value otherwise. -func (o *CreateOrganizationResponse) GetData() OrganizationExpanded { - if o == nil || IsNil(o.Data) { - var ret OrganizationExpanded - return ret - } - return *o.Data -} - -// GetDataOk returns a tuple with the Data field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateOrganizationResponse) GetDataOk() (*OrganizationExpanded, bool) { - if o == nil || IsNil(o.Data) { - return nil, false - } - return o.Data, true -} - -// HasData returns a boolean if a field has been set. -func (o *CreateOrganizationResponse) HasData() bool { - if o != nil && !IsNil(o.Data) { - return true - } - - return false -} - -// SetData gets a reference to the given OrganizationExpanded and assigns it to the Data field. -func (o *CreateOrganizationResponse) SetData(v OrganizationExpanded) { - o.Data = &v -} - -func (o CreateOrganizationResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o CreateOrganizationResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Data) { - toSerialize["data"] = o.Data - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *CreateOrganizationResponse) UnmarshalJSON(data []byte) (err error) { - varCreateOrganizationResponse := _CreateOrganizationResponse{} - - err = json.Unmarshal(data, &varCreateOrganizationResponse) - - if err != nil { - return err - } - - *o = CreateOrganizationResponse(varCreateOrganizationResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableCreateOrganizationResponse struct { - value *CreateOrganizationResponse - isSet bool -} - -func (v NullableCreateOrganizationResponse) Get() *CreateOrganizationResponse { - return v.value -} - -func (v *NullableCreateOrganizationResponse) Set(val *CreateOrganizationResponse) { - v.value = val - v.isSet = true -} - -func (v NullableCreateOrganizationResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableCreateOrganizationResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableCreateOrganizationResponse(val *CreateOrganizationResponse) *NullableCreateOrganizationResponse { - return &NullableCreateOrganizationResponse{value: val, isSet: true} -} - -func (v NullableCreateOrganizationResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableCreateOrganizationResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_create_private_region_request.go b/membershipclient/model_create_private_region_request.go deleted file mode 100644 index 8898de2b..00000000 --- a/membershipclient/model_create_private_region_request.go +++ /dev/null @@ -1,168 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the CreatePrivateRegionRequest type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &CreatePrivateRegionRequest{} - -// CreatePrivateRegionRequest struct for CreatePrivateRegionRequest -type CreatePrivateRegionRequest struct { - Name string `json:"name"` - AdditionalProperties map[string]interface{} -} - -type _CreatePrivateRegionRequest CreatePrivateRegionRequest - -// NewCreatePrivateRegionRequest instantiates a new CreatePrivateRegionRequest object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewCreatePrivateRegionRequest(name string) *CreatePrivateRegionRequest { - this := CreatePrivateRegionRequest{} - this.Name = name - return &this -} - -// NewCreatePrivateRegionRequestWithDefaults instantiates a new CreatePrivateRegionRequest object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewCreatePrivateRegionRequestWithDefaults() *CreatePrivateRegionRequest { - this := CreatePrivateRegionRequest{} - return &this -} - -// GetName returns the Name field value -func (o *CreatePrivateRegionRequest) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *CreatePrivateRegionRequest) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *CreatePrivateRegionRequest) SetName(v string) { - o.Name = v -} - -func (o CreatePrivateRegionRequest) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o CreatePrivateRegionRequest) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["name"] = o.Name - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *CreatePrivateRegionRequest) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "name", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varCreatePrivateRegionRequest := _CreatePrivateRegionRequest{} - - err = json.Unmarshal(data, &varCreatePrivateRegionRequest) - - if err != nil { - return err - } - - *o = CreatePrivateRegionRequest(varCreatePrivateRegionRequest) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "name") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableCreatePrivateRegionRequest struct { - value *CreatePrivateRegionRequest - isSet bool -} - -func (v NullableCreatePrivateRegionRequest) Get() *CreatePrivateRegionRequest { - return v.value -} - -func (v *NullableCreatePrivateRegionRequest) Set(val *CreatePrivateRegionRequest) { - v.value = val - v.isSet = true -} - -func (v NullableCreatePrivateRegionRequest) IsSet() bool { - return v.isSet -} - -func (v *NullableCreatePrivateRegionRequest) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableCreatePrivateRegionRequest(val *CreatePrivateRegionRequest) *NullableCreatePrivateRegionRequest { - return &NullableCreatePrivateRegionRequest{value: val, isSet: true} -} - -func (v NullableCreatePrivateRegionRequest) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableCreatePrivateRegionRequest) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_create_stack_request.go b/membershipclient/model_create_stack_request.go deleted file mode 100644 index a3876d1e..00000000 --- a/membershipclient/model_create_stack_request.go +++ /dev/null @@ -1,273 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the CreateStackRequest type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &CreateStackRequest{} - -// CreateStackRequest struct for CreateStackRequest -type CreateStackRequest struct { - // Stack name - Name string `json:"name"` - Metadata *map[string]string `json:"metadata,omitempty"` - // Supported only with agent version >= v0.7.0 - Version *string `json:"version,omitempty"` - RegionID string `json:"regionID"` - AdditionalProperties map[string]interface{} -} - -type _CreateStackRequest CreateStackRequest - -// NewCreateStackRequest instantiates a new CreateStackRequest object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewCreateStackRequest(name string, regionID string) *CreateStackRequest { - this := CreateStackRequest{} - this.Name = name - this.RegionID = regionID - return &this -} - -// NewCreateStackRequestWithDefaults instantiates a new CreateStackRequest object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewCreateStackRequestWithDefaults() *CreateStackRequest { - this := CreateStackRequest{} - return &this -} - -// GetName returns the Name field value -func (o *CreateStackRequest) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *CreateStackRequest) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *CreateStackRequest) SetName(v string) { - o.Name = v -} - -// GetMetadata returns the Metadata field value if set, zero value otherwise. -func (o *CreateStackRequest) GetMetadata() map[string]string { - if o == nil || IsNil(o.Metadata) { - var ret map[string]string - return ret - } - return *o.Metadata -} - -// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateStackRequest) GetMetadataOk() (*map[string]string, bool) { - if o == nil || IsNil(o.Metadata) { - return nil, false - } - return o.Metadata, true -} - -// HasMetadata returns a boolean if a field has been set. -func (o *CreateStackRequest) HasMetadata() bool { - if o != nil && !IsNil(o.Metadata) { - return true - } - - return false -} - -// SetMetadata gets a reference to the given map[string]string and assigns it to the Metadata field. -func (o *CreateStackRequest) SetMetadata(v map[string]string) { - o.Metadata = &v -} - -// GetVersion returns the Version field value if set, zero value otherwise. -func (o *CreateStackRequest) GetVersion() string { - if o == nil || IsNil(o.Version) { - var ret string - return ret - } - return *o.Version -} - -// GetVersionOk returns a tuple with the Version field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateStackRequest) GetVersionOk() (*string, bool) { - if o == nil || IsNil(o.Version) { - return nil, false - } - return o.Version, true -} - -// HasVersion returns a boolean if a field has been set. -func (o *CreateStackRequest) HasVersion() bool { - if o != nil && !IsNil(o.Version) { - return true - } - - return false -} - -// SetVersion gets a reference to the given string and assigns it to the Version field. -func (o *CreateStackRequest) SetVersion(v string) { - o.Version = &v -} - -// GetRegionID returns the RegionID field value -func (o *CreateStackRequest) GetRegionID() string { - if o == nil { - var ret string - return ret - } - - return o.RegionID -} - -// GetRegionIDOk returns a tuple with the RegionID field value -// and a boolean to check if the value has been set. -func (o *CreateStackRequest) GetRegionIDOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.RegionID, true -} - -// SetRegionID sets field value -func (o *CreateStackRequest) SetRegionID(v string) { - o.RegionID = v -} - -func (o CreateStackRequest) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o CreateStackRequest) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["name"] = o.Name - if !IsNil(o.Metadata) { - toSerialize["metadata"] = o.Metadata - } - if !IsNil(o.Version) { - toSerialize["version"] = o.Version - } - toSerialize["regionID"] = o.RegionID - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *CreateStackRequest) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "name", - "regionID", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varCreateStackRequest := _CreateStackRequest{} - - err = json.Unmarshal(data, &varCreateStackRequest) - - if err != nil { - return err - } - - *o = CreateStackRequest(varCreateStackRequest) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "name") - delete(additionalProperties, "metadata") - delete(additionalProperties, "version") - delete(additionalProperties, "regionID") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableCreateStackRequest struct { - value *CreateStackRequest - isSet bool -} - -func (v NullableCreateStackRequest) Get() *CreateStackRequest { - return v.value -} - -func (v *NullableCreateStackRequest) Set(val *CreateStackRequest) { - v.value = val - v.isSet = true -} - -func (v NullableCreateStackRequest) IsSet() bool { - return v.isSet -} - -func (v *NullableCreateStackRequest) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableCreateStackRequest(val *CreateStackRequest) *NullableCreateStackRequest { - return &NullableCreateStackRequest{value: val, isSet: true} -} - -func (v NullableCreateStackRequest) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableCreateStackRequest) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_create_stack_response.go b/membershipclient/model_create_stack_response.go deleted file mode 100644 index a56da17a..00000000 --- a/membershipclient/model_create_stack_response.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the CreateStackResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &CreateStackResponse{} - -// CreateStackResponse struct for CreateStackResponse -type CreateStackResponse struct { - Data *Stack `json:"data,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _CreateStackResponse CreateStackResponse - -// NewCreateStackResponse instantiates a new CreateStackResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewCreateStackResponse() *CreateStackResponse { - this := CreateStackResponse{} - return &this -} - -// NewCreateStackResponseWithDefaults instantiates a new CreateStackResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewCreateStackResponseWithDefaults() *CreateStackResponse { - this := CreateStackResponse{} - return &this -} - -// GetData returns the Data field value if set, zero value otherwise. -func (o *CreateStackResponse) GetData() Stack { - if o == nil || IsNil(o.Data) { - var ret Stack - return ret - } - return *o.Data -} - -// GetDataOk returns a tuple with the Data field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *CreateStackResponse) GetDataOk() (*Stack, bool) { - if o == nil || IsNil(o.Data) { - return nil, false - } - return o.Data, true -} - -// HasData returns a boolean if a field has been set. -func (o *CreateStackResponse) HasData() bool { - if o != nil && !IsNil(o.Data) { - return true - } - - return false -} - -// SetData gets a reference to the given Stack and assigns it to the Data field. -func (o *CreateStackResponse) SetData(v Stack) { - o.Data = &v -} - -func (o CreateStackResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o CreateStackResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Data) { - toSerialize["data"] = o.Data - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *CreateStackResponse) UnmarshalJSON(data []byte) (err error) { - varCreateStackResponse := _CreateStackResponse{} - - err = json.Unmarshal(data, &varCreateStackResponse) - - if err != nil { - return err - } - - *o = CreateStackResponse(varCreateStackResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableCreateStackResponse struct { - value *CreateStackResponse - isSet bool -} - -func (v NullableCreateStackResponse) Get() *CreateStackResponse { - return v.value -} - -func (v *NullableCreateStackResponse) Set(val *CreateStackResponse) { - v.value = val - v.isSet = true -} - -func (v NullableCreateStackResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableCreateStackResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableCreateStackResponse(val *CreateStackResponse) *NullableCreateStackResponse { - return &NullableCreateStackResponse{value: val, isSet: true} -} - -func (v NullableCreateStackResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableCreateStackResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_created_private_region_response.go b/membershipclient/model_created_private_region_response.go deleted file mode 100644 index f2b2cacc..00000000 --- a/membershipclient/model_created_private_region_response.go +++ /dev/null @@ -1,168 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the CreatedPrivateRegionResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &CreatedPrivateRegionResponse{} - -// CreatedPrivateRegionResponse struct for CreatedPrivateRegionResponse -type CreatedPrivateRegionResponse struct { - Data PrivateRegion `json:"data"` - AdditionalProperties map[string]interface{} -} - -type _CreatedPrivateRegionResponse CreatedPrivateRegionResponse - -// NewCreatedPrivateRegionResponse instantiates a new CreatedPrivateRegionResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewCreatedPrivateRegionResponse(data PrivateRegion) *CreatedPrivateRegionResponse { - this := CreatedPrivateRegionResponse{} - this.Data = data - return &this -} - -// NewCreatedPrivateRegionResponseWithDefaults instantiates a new CreatedPrivateRegionResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewCreatedPrivateRegionResponseWithDefaults() *CreatedPrivateRegionResponse { - this := CreatedPrivateRegionResponse{} - return &this -} - -// GetData returns the Data field value -func (o *CreatedPrivateRegionResponse) GetData() PrivateRegion { - if o == nil { - var ret PrivateRegion - return ret - } - - return o.Data -} - -// GetDataOk returns a tuple with the Data field value -// and a boolean to check if the value has been set. -func (o *CreatedPrivateRegionResponse) GetDataOk() (*PrivateRegion, bool) { - if o == nil { - return nil, false - } - return &o.Data, true -} - -// SetData sets field value -func (o *CreatedPrivateRegionResponse) SetData(v PrivateRegion) { - o.Data = v -} - -func (o CreatedPrivateRegionResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o CreatedPrivateRegionResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["data"] = o.Data - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *CreatedPrivateRegionResponse) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "data", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varCreatedPrivateRegionResponse := _CreatedPrivateRegionResponse{} - - err = json.Unmarshal(data, &varCreatedPrivateRegionResponse) - - if err != nil { - return err - } - - *o = CreatedPrivateRegionResponse(varCreatedPrivateRegionResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableCreatedPrivateRegionResponse struct { - value *CreatedPrivateRegionResponse - isSet bool -} - -func (v NullableCreatedPrivateRegionResponse) Get() *CreatedPrivateRegionResponse { - return v.value -} - -func (v *NullableCreatedPrivateRegionResponse) Set(val *CreatedPrivateRegionResponse) { - v.value = val - v.isSet = true -} - -func (v NullableCreatedPrivateRegionResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableCreatedPrivateRegionResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableCreatedPrivateRegionResponse(val *CreatedPrivateRegionResponse) *NullableCreatedPrivateRegionResponse { - return &NullableCreatedPrivateRegionResponse{value: val, isSet: true} -} - -func (v NullableCreatedPrivateRegionResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableCreatedPrivateRegionResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_cursor.go b/membershipclient/model_cursor.go deleted file mode 100644 index 1ae7016b..00000000 --- a/membershipclient/model_cursor.go +++ /dev/null @@ -1,271 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the Cursor type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &Cursor{} - -// Cursor struct for Cursor -type Cursor struct { - PageSize int64 `json:"pageSize"` - HasMore bool `json:"hasMore"` - Previous *string `json:"previous,omitempty"` - Next *string `json:"next,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _Cursor Cursor - -// NewCursor instantiates a new Cursor object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewCursor(pageSize int64, hasMore bool) *Cursor { - this := Cursor{} - this.PageSize = pageSize - this.HasMore = hasMore - return &this -} - -// NewCursorWithDefaults instantiates a new Cursor object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewCursorWithDefaults() *Cursor { - this := Cursor{} - return &this -} - -// GetPageSize returns the PageSize field value -func (o *Cursor) GetPageSize() int64 { - if o == nil { - var ret int64 - return ret - } - - return o.PageSize -} - -// GetPageSizeOk returns a tuple with the PageSize field value -// and a boolean to check if the value has been set. -func (o *Cursor) GetPageSizeOk() (*int64, bool) { - if o == nil { - return nil, false - } - return &o.PageSize, true -} - -// SetPageSize sets field value -func (o *Cursor) SetPageSize(v int64) { - o.PageSize = v -} - -// GetHasMore returns the HasMore field value -func (o *Cursor) GetHasMore() bool { - if o == nil { - var ret bool - return ret - } - - return o.HasMore -} - -// GetHasMoreOk returns a tuple with the HasMore field value -// and a boolean to check if the value has been set. -func (o *Cursor) GetHasMoreOk() (*bool, bool) { - if o == nil { - return nil, false - } - return &o.HasMore, true -} - -// SetHasMore sets field value -func (o *Cursor) SetHasMore(v bool) { - o.HasMore = v -} - -// GetPrevious returns the Previous field value if set, zero value otherwise. -func (o *Cursor) GetPrevious() string { - if o == nil || IsNil(o.Previous) { - var ret string - return ret - } - return *o.Previous -} - -// GetPreviousOk returns a tuple with the Previous field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Cursor) GetPreviousOk() (*string, bool) { - if o == nil || IsNil(o.Previous) { - return nil, false - } - return o.Previous, true -} - -// HasPrevious returns a boolean if a field has been set. -func (o *Cursor) HasPrevious() bool { - if o != nil && !IsNil(o.Previous) { - return true - } - - return false -} - -// SetPrevious gets a reference to the given string and assigns it to the Previous field. -func (o *Cursor) SetPrevious(v string) { - o.Previous = &v -} - -// GetNext returns the Next field value if set, zero value otherwise. -func (o *Cursor) GetNext() string { - if o == nil || IsNil(o.Next) { - var ret string - return ret - } - return *o.Next -} - -// GetNextOk returns a tuple with the Next field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Cursor) GetNextOk() (*string, bool) { - if o == nil || IsNil(o.Next) { - return nil, false - } - return o.Next, true -} - -// HasNext returns a boolean if a field has been set. -func (o *Cursor) HasNext() bool { - if o != nil && !IsNil(o.Next) { - return true - } - - return false -} - -// SetNext gets a reference to the given string and assigns it to the Next field. -func (o *Cursor) SetNext(v string) { - o.Next = &v -} - -func (o Cursor) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o Cursor) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["pageSize"] = o.PageSize - toSerialize["hasMore"] = o.HasMore - if !IsNil(o.Previous) { - toSerialize["previous"] = o.Previous - } - if !IsNil(o.Next) { - toSerialize["next"] = o.Next - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *Cursor) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "pageSize", - "hasMore", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varCursor := _Cursor{} - - err = json.Unmarshal(data, &varCursor) - - if err != nil { - return err - } - - *o = Cursor(varCursor) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "pageSize") - delete(additionalProperties, "hasMore") - delete(additionalProperties, "previous") - delete(additionalProperties, "next") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableCursor struct { - value *Cursor - isSet bool -} - -func (v NullableCursor) Get() *Cursor { - return v.value -} - -func (v *NullableCursor) Set(val *Cursor) { - v.value = val - v.isSet = true -} - -func (v NullableCursor) IsSet() bool { - return v.isSet -} - -func (v *NullableCursor) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableCursor(val *Cursor) *NullableCursor { - return &NullableCursor{value: val, isSet: true} -} - -func (v NullableCursor) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableCursor) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_error.go b/membershipclient/model_error.go deleted file mode 100644 index 521ea854..00000000 --- a/membershipclient/model_error.go +++ /dev/null @@ -1,205 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the Error type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &Error{} - -// Error struct for Error -type Error struct { - ErrorCode string `json:"errorCode"` - ErrorMessage *string `json:"errorMessage,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _Error Error - -// NewError instantiates a new Error object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewError(errorCode string) *Error { - this := Error{} - this.ErrorCode = errorCode - return &this -} - -// NewErrorWithDefaults instantiates a new Error object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewErrorWithDefaults() *Error { - this := Error{} - return &this -} - -// GetErrorCode returns the ErrorCode field value -func (o *Error) GetErrorCode() string { - if o == nil { - var ret string - return ret - } - - return o.ErrorCode -} - -// GetErrorCodeOk returns a tuple with the ErrorCode field value -// and a boolean to check if the value has been set. -func (o *Error) GetErrorCodeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ErrorCode, true -} - -// SetErrorCode sets field value -func (o *Error) SetErrorCode(v string) { - o.ErrorCode = v -} - -// GetErrorMessage returns the ErrorMessage field value if set, zero value otherwise. -func (o *Error) GetErrorMessage() string { - if o == nil || IsNil(o.ErrorMessage) { - var ret string - return ret - } - return *o.ErrorMessage -} - -// GetErrorMessageOk returns a tuple with the ErrorMessage field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Error) GetErrorMessageOk() (*string, bool) { - if o == nil || IsNil(o.ErrorMessage) { - return nil, false - } - return o.ErrorMessage, true -} - -// HasErrorMessage returns a boolean if a field has been set. -func (o *Error) HasErrorMessage() bool { - if o != nil && !IsNil(o.ErrorMessage) { - return true - } - - return false -} - -// SetErrorMessage gets a reference to the given string and assigns it to the ErrorMessage field. -func (o *Error) SetErrorMessage(v string) { - o.ErrorMessage = &v -} - -func (o Error) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o Error) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["errorCode"] = o.ErrorCode - if !IsNil(o.ErrorMessage) { - toSerialize["errorMessage"] = o.ErrorMessage - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *Error) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "errorCode", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varError := _Error{} - - err = json.Unmarshal(data, &varError) - - if err != nil { - return err - } - - *o = Error(varError) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "errorCode") - delete(additionalProperties, "errorMessage") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableError struct { - value *Error - isSet bool -} - -func (v NullableError) Get() *Error { - return v.value -} - -func (v *NullableError) Set(val *Error) { - v.value = val - v.isSet = true -} - -func (v NullableError) IsSet() bool { - return v.isSet -} - -func (v *NullableError) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableError(val *Error) *NullableError { - return &NullableError{value: val, isSet: true} -} - -func (v NullableError) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableError) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_get_region_response.go b/membershipclient/model_get_region_response.go deleted file mode 100644 index 2366d49d..00000000 --- a/membershipclient/model_get_region_response.go +++ /dev/null @@ -1,168 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the GetRegionResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &GetRegionResponse{} - -// GetRegionResponse struct for GetRegionResponse -type GetRegionResponse struct { - Data AnyRegion `json:"data"` - AdditionalProperties map[string]interface{} -} - -type _GetRegionResponse GetRegionResponse - -// NewGetRegionResponse instantiates a new GetRegionResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewGetRegionResponse(data AnyRegion) *GetRegionResponse { - this := GetRegionResponse{} - this.Data = data - return &this -} - -// NewGetRegionResponseWithDefaults instantiates a new GetRegionResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewGetRegionResponseWithDefaults() *GetRegionResponse { - this := GetRegionResponse{} - return &this -} - -// GetData returns the Data field value -func (o *GetRegionResponse) GetData() AnyRegion { - if o == nil { - var ret AnyRegion - return ret - } - - return o.Data -} - -// GetDataOk returns a tuple with the Data field value -// and a boolean to check if the value has been set. -func (o *GetRegionResponse) GetDataOk() (*AnyRegion, bool) { - if o == nil { - return nil, false - } - return &o.Data, true -} - -// SetData sets field value -func (o *GetRegionResponse) SetData(v AnyRegion) { - o.Data = v -} - -func (o GetRegionResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o GetRegionResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["data"] = o.Data - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *GetRegionResponse) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "data", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varGetRegionResponse := _GetRegionResponse{} - - err = json.Unmarshal(data, &varGetRegionResponse) - - if err != nil { - return err - } - - *o = GetRegionResponse(varGetRegionResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableGetRegionResponse struct { - value *GetRegionResponse - isSet bool -} - -func (v NullableGetRegionResponse) Get() *GetRegionResponse { - return v.value -} - -func (v *NullableGetRegionResponse) Set(val *GetRegionResponse) { - v.value = val - v.isSet = true -} - -func (v NullableGetRegionResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableGetRegionResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableGetRegionResponse(val *GetRegionResponse) *NullableGetRegionResponse { - return &NullableGetRegionResponse{value: val, isSet: true} -} - -func (v NullableGetRegionResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableGetRegionResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_get_region_versions_response.go b/membershipclient/model_get_region_versions_response.go deleted file mode 100644 index b95a8e49..00000000 --- a/membershipclient/model_get_region_versions_response.go +++ /dev/null @@ -1,168 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the GetRegionVersionsResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &GetRegionVersionsResponse{} - -// GetRegionVersionsResponse struct for GetRegionVersionsResponse -type GetRegionVersionsResponse struct { - Data []Version `json:"data"` - AdditionalProperties map[string]interface{} -} - -type _GetRegionVersionsResponse GetRegionVersionsResponse - -// NewGetRegionVersionsResponse instantiates a new GetRegionVersionsResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewGetRegionVersionsResponse(data []Version) *GetRegionVersionsResponse { - this := GetRegionVersionsResponse{} - this.Data = data - return &this -} - -// NewGetRegionVersionsResponseWithDefaults instantiates a new GetRegionVersionsResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewGetRegionVersionsResponseWithDefaults() *GetRegionVersionsResponse { - this := GetRegionVersionsResponse{} - return &this -} - -// GetData returns the Data field value -func (o *GetRegionVersionsResponse) GetData() []Version { - if o == nil { - var ret []Version - return ret - } - - return o.Data -} - -// GetDataOk returns a tuple with the Data field value -// and a boolean to check if the value has been set. -func (o *GetRegionVersionsResponse) GetDataOk() ([]Version, bool) { - if o == nil { - return nil, false - } - return o.Data, true -} - -// SetData sets field value -func (o *GetRegionVersionsResponse) SetData(v []Version) { - o.Data = v -} - -func (o GetRegionVersionsResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o GetRegionVersionsResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["data"] = o.Data - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *GetRegionVersionsResponse) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "data", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varGetRegionVersionsResponse := _GetRegionVersionsResponse{} - - err = json.Unmarshal(data, &varGetRegionVersionsResponse) - - if err != nil { - return err - } - - *o = GetRegionVersionsResponse(varGetRegionVersionsResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableGetRegionVersionsResponse struct { - value *GetRegionVersionsResponse - isSet bool -} - -func (v NullableGetRegionVersionsResponse) Get() *GetRegionVersionsResponse { - return v.value -} - -func (v *NullableGetRegionVersionsResponse) Set(val *GetRegionVersionsResponse) { - v.value = val - v.isSet = true -} - -func (v NullableGetRegionVersionsResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableGetRegionVersionsResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableGetRegionVersionsResponse(val *GetRegionVersionsResponse) *NullableGetRegionVersionsResponse { - return &NullableGetRegionVersionsResponse{value: val, isSet: true} -} - -func (v NullableGetRegionVersionsResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableGetRegionVersionsResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_github_idp_config.go b/membershipclient/model_github_idp_config.go deleted file mode 100644 index e28e0359..00000000 --- a/membershipclient/model_github_idp_config.go +++ /dev/null @@ -1,288 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the GithubIDPConfig type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &GithubIDPConfig{} - -// GithubIDPConfig struct for GithubIDPConfig -type GithubIDPConfig struct { - // Type of the authentication provider - Type string `json:"type"` - // Name of the authentication provider - Name string `json:"name"` - // Client ID for the authentication provider - ClientID string `json:"clientID"` - // Client secret for the authentication provider - ClientSecret string `json:"clientSecret"` - Config map[string]interface{} `json:"config"` - AdditionalProperties map[string]interface{} -} - -type _GithubIDPConfig GithubIDPConfig - -// NewGithubIDPConfig instantiates a new GithubIDPConfig object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewGithubIDPConfig(type_ string, name string, clientID string, clientSecret string, config map[string]interface{}) *GithubIDPConfig { - this := GithubIDPConfig{} - this.Type = type_ - this.Name = name - this.ClientID = clientID - this.ClientSecret = clientSecret - this.Config = config - return &this -} - -// NewGithubIDPConfigWithDefaults instantiates a new GithubIDPConfig object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewGithubIDPConfigWithDefaults() *GithubIDPConfig { - this := GithubIDPConfig{} - return &this -} - -// GetType returns the Type field value -func (o *GithubIDPConfig) GetType() string { - if o == nil { - var ret string - return ret - } - - return o.Type -} - -// GetTypeOk returns a tuple with the Type field value -// and a boolean to check if the value has been set. -func (o *GithubIDPConfig) GetTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Type, true -} - -// SetType sets field value -func (o *GithubIDPConfig) SetType(v string) { - o.Type = v -} - -// GetName returns the Name field value -func (o *GithubIDPConfig) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *GithubIDPConfig) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *GithubIDPConfig) SetName(v string) { - o.Name = v -} - -// GetClientID returns the ClientID field value -func (o *GithubIDPConfig) GetClientID() string { - if o == nil { - var ret string - return ret - } - - return o.ClientID -} - -// GetClientIDOk returns a tuple with the ClientID field value -// and a boolean to check if the value has been set. -func (o *GithubIDPConfig) GetClientIDOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ClientID, true -} - -// SetClientID sets field value -func (o *GithubIDPConfig) SetClientID(v string) { - o.ClientID = v -} - -// GetClientSecret returns the ClientSecret field value -func (o *GithubIDPConfig) GetClientSecret() string { - if o == nil { - var ret string - return ret - } - - return o.ClientSecret -} - -// GetClientSecretOk returns a tuple with the ClientSecret field value -// and a boolean to check if the value has been set. -func (o *GithubIDPConfig) GetClientSecretOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ClientSecret, true -} - -// SetClientSecret sets field value -func (o *GithubIDPConfig) SetClientSecret(v string) { - o.ClientSecret = v -} - -// GetConfig returns the Config field value -func (o *GithubIDPConfig) GetConfig() map[string]interface{} { - if o == nil { - var ret map[string]interface{} - return ret - } - - return o.Config -} - -// GetConfigOk returns a tuple with the Config field value -// and a boolean to check if the value has been set. -func (o *GithubIDPConfig) GetConfigOk() (map[string]interface{}, bool) { - if o == nil { - return map[string]interface{}{}, false - } - return o.Config, true -} - -// SetConfig sets field value -func (o *GithubIDPConfig) SetConfig(v map[string]interface{}) { - o.Config = v -} - -func (o GithubIDPConfig) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o GithubIDPConfig) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["type"] = o.Type - toSerialize["name"] = o.Name - toSerialize["clientID"] = o.ClientID - toSerialize["clientSecret"] = o.ClientSecret - toSerialize["config"] = o.Config - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *GithubIDPConfig) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "type", - "name", - "clientID", - "clientSecret", - "config", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varGithubIDPConfig := _GithubIDPConfig{} - - err = json.Unmarshal(data, &varGithubIDPConfig) - - if err != nil { - return err - } - - *o = GithubIDPConfig(varGithubIDPConfig) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "type") - delete(additionalProperties, "name") - delete(additionalProperties, "clientID") - delete(additionalProperties, "clientSecret") - delete(additionalProperties, "config") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableGithubIDPConfig struct { - value *GithubIDPConfig - isSet bool -} - -func (v NullableGithubIDPConfig) Get() *GithubIDPConfig { - return v.value -} - -func (v *NullableGithubIDPConfig) Set(val *GithubIDPConfig) { - v.value = val - v.isSet = true -} - -func (v NullableGithubIDPConfig) IsSet() bool { - return v.isSet -} - -func (v *NullableGithubIDPConfig) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableGithubIDPConfig(val *GithubIDPConfig) *NullableGithubIDPConfig { - return &NullableGithubIDPConfig{value: val, isSet: true} -} - -func (v NullableGithubIDPConfig) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableGithubIDPConfig) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_google_idp_config.go b/membershipclient/model_google_idp_config.go deleted file mode 100644 index 0bdb9728..00000000 --- a/membershipclient/model_google_idp_config.go +++ /dev/null @@ -1,288 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the GoogleIDPConfig type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &GoogleIDPConfig{} - -// GoogleIDPConfig struct for GoogleIDPConfig -type GoogleIDPConfig struct { - // Type of the authentication provider - Type string `json:"type"` - // Name of the authentication provider - Name string `json:"name"` - // Client ID for the authentication provider - ClientID string `json:"clientID"` - // Client secret for the authentication provider - ClientSecret string `json:"clientSecret"` - Config map[string]interface{} `json:"config"` - AdditionalProperties map[string]interface{} -} - -type _GoogleIDPConfig GoogleIDPConfig - -// NewGoogleIDPConfig instantiates a new GoogleIDPConfig object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewGoogleIDPConfig(type_ string, name string, clientID string, clientSecret string, config map[string]interface{}) *GoogleIDPConfig { - this := GoogleIDPConfig{} - this.Type = type_ - this.Name = name - this.ClientID = clientID - this.ClientSecret = clientSecret - this.Config = config - return &this -} - -// NewGoogleIDPConfigWithDefaults instantiates a new GoogleIDPConfig object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewGoogleIDPConfigWithDefaults() *GoogleIDPConfig { - this := GoogleIDPConfig{} - return &this -} - -// GetType returns the Type field value -func (o *GoogleIDPConfig) GetType() string { - if o == nil { - var ret string - return ret - } - - return o.Type -} - -// GetTypeOk returns a tuple with the Type field value -// and a boolean to check if the value has been set. -func (o *GoogleIDPConfig) GetTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Type, true -} - -// SetType sets field value -func (o *GoogleIDPConfig) SetType(v string) { - o.Type = v -} - -// GetName returns the Name field value -func (o *GoogleIDPConfig) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *GoogleIDPConfig) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *GoogleIDPConfig) SetName(v string) { - o.Name = v -} - -// GetClientID returns the ClientID field value -func (o *GoogleIDPConfig) GetClientID() string { - if o == nil { - var ret string - return ret - } - - return o.ClientID -} - -// GetClientIDOk returns a tuple with the ClientID field value -// and a boolean to check if the value has been set. -func (o *GoogleIDPConfig) GetClientIDOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ClientID, true -} - -// SetClientID sets field value -func (o *GoogleIDPConfig) SetClientID(v string) { - o.ClientID = v -} - -// GetClientSecret returns the ClientSecret field value -func (o *GoogleIDPConfig) GetClientSecret() string { - if o == nil { - var ret string - return ret - } - - return o.ClientSecret -} - -// GetClientSecretOk returns a tuple with the ClientSecret field value -// and a boolean to check if the value has been set. -func (o *GoogleIDPConfig) GetClientSecretOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ClientSecret, true -} - -// SetClientSecret sets field value -func (o *GoogleIDPConfig) SetClientSecret(v string) { - o.ClientSecret = v -} - -// GetConfig returns the Config field value -func (o *GoogleIDPConfig) GetConfig() map[string]interface{} { - if o == nil { - var ret map[string]interface{} - return ret - } - - return o.Config -} - -// GetConfigOk returns a tuple with the Config field value -// and a boolean to check if the value has been set. -func (o *GoogleIDPConfig) GetConfigOk() (map[string]interface{}, bool) { - if o == nil { - return map[string]interface{}{}, false - } - return o.Config, true -} - -// SetConfig sets field value -func (o *GoogleIDPConfig) SetConfig(v map[string]interface{}) { - o.Config = v -} - -func (o GoogleIDPConfig) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o GoogleIDPConfig) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["type"] = o.Type - toSerialize["name"] = o.Name - toSerialize["clientID"] = o.ClientID - toSerialize["clientSecret"] = o.ClientSecret - toSerialize["config"] = o.Config - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *GoogleIDPConfig) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "type", - "name", - "clientID", - "clientSecret", - "config", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varGoogleIDPConfig := _GoogleIDPConfig{} - - err = json.Unmarshal(data, &varGoogleIDPConfig) - - if err != nil { - return err - } - - *o = GoogleIDPConfig(varGoogleIDPConfig) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "type") - delete(additionalProperties, "name") - delete(additionalProperties, "clientID") - delete(additionalProperties, "clientSecret") - delete(additionalProperties, "config") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableGoogleIDPConfig struct { - value *GoogleIDPConfig - isSet bool -} - -func (v NullableGoogleIDPConfig) Get() *GoogleIDPConfig { - return v.value -} - -func (v *NullableGoogleIDPConfig) Set(val *GoogleIDPConfig) { - v.value = val - v.isSet = true -} - -func (v NullableGoogleIDPConfig) IsSet() bool { - return v.isSet -} - -func (v *NullableGoogleIDPConfig) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableGoogleIDPConfig(val *GoogleIDPConfig) *NullableGoogleIDPConfig { - return &NullableGoogleIDPConfig{value: val, isSet: true} -} - -func (v NullableGoogleIDPConfig) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableGoogleIDPConfig) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_invitation.go b/membershipclient/model_invitation.go deleted file mode 100644 index b2e7314d..00000000 --- a/membershipclient/model_invitation.go +++ /dev/null @@ -1,536 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "time" - "fmt" -) - -// checks if the Invitation type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &Invitation{} - -// Invitation struct for Invitation -type Invitation struct { - Id string `json:"id"` - OrganizationId string `json:"organizationId"` - UserEmail string `json:"userEmail"` - Status string `json:"status"` - CreationDate time.Time `json:"creationDate"` - UpdatedAt *string `json:"updatedAt,omitempty"` - Role Role `json:"role"` - UserId *string `json:"userId,omitempty"` - OrganizationAccess *OrganizationUser `json:"organizationAccess,omitempty"` - ExpiresAt *time.Time `json:"expiresAt,omitempty"` - CreatorId *string `json:"creatorId,omitempty"` - LastUpdate *time.Time `json:"lastUpdate,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _Invitation Invitation - -// NewInvitation instantiates a new Invitation object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewInvitation(id string, organizationId string, userEmail string, status string, creationDate time.Time, role Role) *Invitation { - this := Invitation{} - this.Id = id - this.OrganizationId = organizationId - this.UserEmail = userEmail - this.Status = status - this.CreationDate = creationDate - this.Role = role - return &this -} - -// NewInvitationWithDefaults instantiates a new Invitation object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewInvitationWithDefaults() *Invitation { - this := Invitation{} - return &this -} - -// GetId returns the Id field value -func (o *Invitation) GetId() string { - if o == nil { - var ret string - return ret - } - - return o.Id -} - -// GetIdOk returns a tuple with the Id field value -// and a boolean to check if the value has been set. -func (o *Invitation) GetIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Id, true -} - -// SetId sets field value -func (o *Invitation) SetId(v string) { - o.Id = v -} - -// GetOrganizationId returns the OrganizationId field value -func (o *Invitation) GetOrganizationId() string { - if o == nil { - var ret string - return ret - } - - return o.OrganizationId -} - -// GetOrganizationIdOk returns a tuple with the OrganizationId field value -// and a boolean to check if the value has been set. -func (o *Invitation) GetOrganizationIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.OrganizationId, true -} - -// SetOrganizationId sets field value -func (o *Invitation) SetOrganizationId(v string) { - o.OrganizationId = v -} - -// GetUserEmail returns the UserEmail field value -func (o *Invitation) GetUserEmail() string { - if o == nil { - var ret string - return ret - } - - return o.UserEmail -} - -// GetUserEmailOk returns a tuple with the UserEmail field value -// and a boolean to check if the value has been set. -func (o *Invitation) GetUserEmailOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.UserEmail, true -} - -// SetUserEmail sets field value -func (o *Invitation) SetUserEmail(v string) { - o.UserEmail = v -} - -// GetStatus returns the Status field value -func (o *Invitation) GetStatus() string { - if o == nil { - var ret string - return ret - } - - return o.Status -} - -// GetStatusOk returns a tuple with the Status field value -// and a boolean to check if the value has been set. -func (o *Invitation) GetStatusOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Status, true -} - -// SetStatus sets field value -func (o *Invitation) SetStatus(v string) { - o.Status = v -} - -// GetCreationDate returns the CreationDate field value -func (o *Invitation) GetCreationDate() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.CreationDate -} - -// GetCreationDateOk returns a tuple with the CreationDate field value -// and a boolean to check if the value has been set. -func (o *Invitation) GetCreationDateOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.CreationDate, true -} - -// SetCreationDate sets field value -func (o *Invitation) SetCreationDate(v time.Time) { - o.CreationDate = v -} - -// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise. -func (o *Invitation) GetUpdatedAt() string { - if o == nil || IsNil(o.UpdatedAt) { - var ret string - return ret - } - return *o.UpdatedAt -} - -// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Invitation) GetUpdatedAtOk() (*string, bool) { - if o == nil || IsNil(o.UpdatedAt) { - return nil, false - } - return o.UpdatedAt, true -} - -// HasUpdatedAt returns a boolean if a field has been set. -func (o *Invitation) HasUpdatedAt() bool { - if o != nil && !IsNil(o.UpdatedAt) { - return true - } - - return false -} - -// SetUpdatedAt gets a reference to the given string and assigns it to the UpdatedAt field. -func (o *Invitation) SetUpdatedAt(v string) { - o.UpdatedAt = &v -} - -// GetRole returns the Role field value -func (o *Invitation) GetRole() Role { - if o == nil { - var ret Role - return ret - } - - return o.Role -} - -// GetRoleOk returns a tuple with the Role field value -// and a boolean to check if the value has been set. -func (o *Invitation) GetRoleOk() (*Role, bool) { - if o == nil { - return nil, false - } - return &o.Role, true -} - -// SetRole sets field value -func (o *Invitation) SetRole(v Role) { - o.Role = v -} - -// GetUserId returns the UserId field value if set, zero value otherwise. -func (o *Invitation) GetUserId() string { - if o == nil || IsNil(o.UserId) { - var ret string - return ret - } - return *o.UserId -} - -// GetUserIdOk returns a tuple with the UserId field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Invitation) GetUserIdOk() (*string, bool) { - if o == nil || IsNil(o.UserId) { - return nil, false - } - return o.UserId, true -} - -// HasUserId returns a boolean if a field has been set. -func (o *Invitation) HasUserId() bool { - if o != nil && !IsNil(o.UserId) { - return true - } - - return false -} - -// SetUserId gets a reference to the given string and assigns it to the UserId field. -func (o *Invitation) SetUserId(v string) { - o.UserId = &v -} - -// GetOrganizationAccess returns the OrganizationAccess field value if set, zero value otherwise. -func (o *Invitation) GetOrganizationAccess() OrganizationUser { - if o == nil || IsNil(o.OrganizationAccess) { - var ret OrganizationUser - return ret - } - return *o.OrganizationAccess -} - -// GetOrganizationAccessOk returns a tuple with the OrganizationAccess field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Invitation) GetOrganizationAccessOk() (*OrganizationUser, bool) { - if o == nil || IsNil(o.OrganizationAccess) { - return nil, false - } - return o.OrganizationAccess, true -} - -// HasOrganizationAccess returns a boolean if a field has been set. -func (o *Invitation) HasOrganizationAccess() bool { - if o != nil && !IsNil(o.OrganizationAccess) { - return true - } - - return false -} - -// SetOrganizationAccess gets a reference to the given OrganizationUser and assigns it to the OrganizationAccess field. -func (o *Invitation) SetOrganizationAccess(v OrganizationUser) { - o.OrganizationAccess = &v -} - -// GetExpiresAt returns the ExpiresAt field value if set, zero value otherwise. -func (o *Invitation) GetExpiresAt() time.Time { - if o == nil || IsNil(o.ExpiresAt) { - var ret time.Time - return ret - } - return *o.ExpiresAt -} - -// GetExpiresAtOk returns a tuple with the ExpiresAt field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Invitation) GetExpiresAtOk() (*time.Time, bool) { - if o == nil || IsNil(o.ExpiresAt) { - return nil, false - } - return o.ExpiresAt, true -} - -// HasExpiresAt returns a boolean if a field has been set. -func (o *Invitation) HasExpiresAt() bool { - if o != nil && !IsNil(o.ExpiresAt) { - return true - } - - return false -} - -// SetExpiresAt gets a reference to the given time.Time and assigns it to the ExpiresAt field. -func (o *Invitation) SetExpiresAt(v time.Time) { - o.ExpiresAt = &v -} - -// GetCreatorId returns the CreatorId field value if set, zero value otherwise. -func (o *Invitation) GetCreatorId() string { - if o == nil || IsNil(o.CreatorId) { - var ret string - return ret - } - return *o.CreatorId -} - -// GetCreatorIdOk returns a tuple with the CreatorId field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Invitation) GetCreatorIdOk() (*string, bool) { - if o == nil || IsNil(o.CreatorId) { - return nil, false - } - return o.CreatorId, true -} - -// HasCreatorId returns a boolean if a field has been set. -func (o *Invitation) HasCreatorId() bool { - if o != nil && !IsNil(o.CreatorId) { - return true - } - - return false -} - -// SetCreatorId gets a reference to the given string and assigns it to the CreatorId field. -func (o *Invitation) SetCreatorId(v string) { - o.CreatorId = &v -} - -// GetLastUpdate returns the LastUpdate field value if set, zero value otherwise. -func (o *Invitation) GetLastUpdate() time.Time { - if o == nil || IsNil(o.LastUpdate) { - var ret time.Time - return ret - } - return *o.LastUpdate -} - -// GetLastUpdateOk returns a tuple with the LastUpdate field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Invitation) GetLastUpdateOk() (*time.Time, bool) { - if o == nil || IsNil(o.LastUpdate) { - return nil, false - } - return o.LastUpdate, true -} - -// HasLastUpdate returns a boolean if a field has been set. -func (o *Invitation) HasLastUpdate() bool { - if o != nil && !IsNil(o.LastUpdate) { - return true - } - - return false -} - -// SetLastUpdate gets a reference to the given time.Time and assigns it to the LastUpdate field. -func (o *Invitation) SetLastUpdate(v time.Time) { - o.LastUpdate = &v -} - -func (o Invitation) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o Invitation) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["id"] = o.Id - toSerialize["organizationId"] = o.OrganizationId - toSerialize["userEmail"] = o.UserEmail - toSerialize["status"] = o.Status - toSerialize["creationDate"] = o.CreationDate - if !IsNil(o.UpdatedAt) { - toSerialize["updatedAt"] = o.UpdatedAt - } - toSerialize["role"] = o.Role - if !IsNil(o.UserId) { - toSerialize["userId"] = o.UserId - } - if !IsNil(o.OrganizationAccess) { - toSerialize["organizationAccess"] = o.OrganizationAccess - } - if !IsNil(o.ExpiresAt) { - toSerialize["expiresAt"] = o.ExpiresAt - } - if !IsNil(o.CreatorId) { - toSerialize["creatorId"] = o.CreatorId - } - if !IsNil(o.LastUpdate) { - toSerialize["lastUpdate"] = o.LastUpdate - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *Invitation) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "id", - "organizationId", - "userEmail", - "status", - "creationDate", - "role", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varInvitation := _Invitation{} - - err = json.Unmarshal(data, &varInvitation) - - if err != nil { - return err - } - - *o = Invitation(varInvitation) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "id") - delete(additionalProperties, "organizationId") - delete(additionalProperties, "userEmail") - delete(additionalProperties, "status") - delete(additionalProperties, "creationDate") - delete(additionalProperties, "updatedAt") - delete(additionalProperties, "role") - delete(additionalProperties, "userId") - delete(additionalProperties, "organizationAccess") - delete(additionalProperties, "expiresAt") - delete(additionalProperties, "creatorId") - delete(additionalProperties, "lastUpdate") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableInvitation struct { - value *Invitation - isSet bool -} - -func (v NullableInvitation) Get() *Invitation { - return v.value -} - -func (v *NullableInvitation) Set(val *Invitation) { - v.value = val - v.isSet = true -} - -func (v NullableInvitation) IsSet() bool { - return v.isSet -} - -func (v *NullableInvitation) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableInvitation(val *Invitation) *NullableInvitation { - return &NullableInvitation{value: val, isSet: true} -} - -func (v NullableInvitation) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableInvitation) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_invitation_claim.go b/membershipclient/model_invitation_claim.go deleted file mode 100644 index b11eea6c..00000000 --- a/membershipclient/model_invitation_claim.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the InvitationClaim type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &InvitationClaim{} - -// InvitationClaim struct for InvitationClaim -type InvitationClaim struct { - Role *Role `json:"role,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _InvitationClaim InvitationClaim - -// NewInvitationClaim instantiates a new InvitationClaim object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewInvitationClaim() *InvitationClaim { - this := InvitationClaim{} - return &this -} - -// NewInvitationClaimWithDefaults instantiates a new InvitationClaim object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewInvitationClaimWithDefaults() *InvitationClaim { - this := InvitationClaim{} - return &this -} - -// GetRole returns the Role field value if set, zero value otherwise. -func (o *InvitationClaim) GetRole() Role { - if o == nil || IsNil(o.Role) { - var ret Role - return ret - } - return *o.Role -} - -// GetRoleOk returns a tuple with the Role field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *InvitationClaim) GetRoleOk() (*Role, bool) { - if o == nil || IsNil(o.Role) { - return nil, false - } - return o.Role, true -} - -// HasRole returns a boolean if a field has been set. -func (o *InvitationClaim) HasRole() bool { - if o != nil && !IsNil(o.Role) { - return true - } - - return false -} - -// SetRole gets a reference to the given Role and assigns it to the Role field. -func (o *InvitationClaim) SetRole(v Role) { - o.Role = &v -} - -func (o InvitationClaim) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o InvitationClaim) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Role) { - toSerialize["role"] = o.Role - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *InvitationClaim) UnmarshalJSON(data []byte) (err error) { - varInvitationClaim := _InvitationClaim{} - - err = json.Unmarshal(data, &varInvitationClaim) - - if err != nil { - return err - } - - *o = InvitationClaim(varInvitationClaim) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "role") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableInvitationClaim struct { - value *InvitationClaim - isSet bool -} - -func (v NullableInvitationClaim) Get() *InvitationClaim { - return v.value -} - -func (v *NullableInvitationClaim) Set(val *InvitationClaim) { - v.value = val - v.isSet = true -} - -func (v NullableInvitationClaim) IsSet() bool { - return v.isSet -} - -func (v *NullableInvitationClaim) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableInvitationClaim(val *InvitationClaim) *NullableInvitationClaim { - return &NullableInvitationClaim{value: val, isSet: true} -} - -func (v NullableInvitationClaim) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableInvitationClaim) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_list_features_200_response.go b/membershipclient/model_list_features_200_response.go deleted file mode 100644 index 9b5607d4..00000000 --- a/membershipclient/model_list_features_200_response.go +++ /dev/null @@ -1,168 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the ListFeatures200Response type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ListFeatures200Response{} - -// ListFeatures200Response struct for ListFeatures200Response -type ListFeatures200Response struct { - Data []OrganizationFeature `json:"data"` - AdditionalProperties map[string]interface{} -} - -type _ListFeatures200Response ListFeatures200Response - -// NewListFeatures200Response instantiates a new ListFeatures200Response object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewListFeatures200Response(data []OrganizationFeature) *ListFeatures200Response { - this := ListFeatures200Response{} - this.Data = data - return &this -} - -// NewListFeatures200ResponseWithDefaults instantiates a new ListFeatures200Response object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewListFeatures200ResponseWithDefaults() *ListFeatures200Response { - this := ListFeatures200Response{} - return &this -} - -// GetData returns the Data field value -func (o *ListFeatures200Response) GetData() []OrganizationFeature { - if o == nil { - var ret []OrganizationFeature - return ret - } - - return o.Data -} - -// GetDataOk returns a tuple with the Data field value -// and a boolean to check if the value has been set. -func (o *ListFeatures200Response) GetDataOk() ([]OrganizationFeature, bool) { - if o == nil { - return nil, false - } - return o.Data, true -} - -// SetData sets field value -func (o *ListFeatures200Response) SetData(v []OrganizationFeature) { - o.Data = v -} - -func (o ListFeatures200Response) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ListFeatures200Response) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["data"] = o.Data - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *ListFeatures200Response) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "data", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varListFeatures200Response := _ListFeatures200Response{} - - err = json.Unmarshal(data, &varListFeatures200Response) - - if err != nil { - return err - } - - *o = ListFeatures200Response(varListFeatures200Response) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableListFeatures200Response struct { - value *ListFeatures200Response - isSet bool -} - -func (v NullableListFeatures200Response) Get() *ListFeatures200Response { - return v.value -} - -func (v *NullableListFeatures200Response) Set(val *ListFeatures200Response) { - v.value = val - v.isSet = true -} - -func (v NullableListFeatures200Response) IsSet() bool { - return v.isSet -} - -func (v *NullableListFeatures200Response) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableListFeatures200Response(val *ListFeatures200Response) *NullableListFeatures200Response { - return &NullableListFeatures200Response{value: val, isSet: true} -} - -func (v NullableListFeatures200Response) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableListFeatures200Response) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_list_invitations_response.go b/membershipclient/model_list_invitations_response.go deleted file mode 100644 index e84a6261..00000000 --- a/membershipclient/model_list_invitations_response.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the ListInvitationsResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ListInvitationsResponse{} - -// ListInvitationsResponse struct for ListInvitationsResponse -type ListInvitationsResponse struct { - Data []Invitation `json:"data,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _ListInvitationsResponse ListInvitationsResponse - -// NewListInvitationsResponse instantiates a new ListInvitationsResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewListInvitationsResponse() *ListInvitationsResponse { - this := ListInvitationsResponse{} - return &this -} - -// NewListInvitationsResponseWithDefaults instantiates a new ListInvitationsResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewListInvitationsResponseWithDefaults() *ListInvitationsResponse { - this := ListInvitationsResponse{} - return &this -} - -// GetData returns the Data field value if set, zero value otherwise. -func (o *ListInvitationsResponse) GetData() []Invitation { - if o == nil || IsNil(o.Data) { - var ret []Invitation - return ret - } - return o.Data -} - -// GetDataOk returns a tuple with the Data field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *ListInvitationsResponse) GetDataOk() ([]Invitation, bool) { - if o == nil || IsNil(o.Data) { - return nil, false - } - return o.Data, true -} - -// HasData returns a boolean if a field has been set. -func (o *ListInvitationsResponse) HasData() bool { - if o != nil && !IsNil(o.Data) { - return true - } - - return false -} - -// SetData gets a reference to the given []Invitation and assigns it to the Data field. -func (o *ListInvitationsResponse) SetData(v []Invitation) { - o.Data = v -} - -func (o ListInvitationsResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ListInvitationsResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Data) { - toSerialize["data"] = o.Data - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *ListInvitationsResponse) UnmarshalJSON(data []byte) (err error) { - varListInvitationsResponse := _ListInvitationsResponse{} - - err = json.Unmarshal(data, &varListInvitationsResponse) - - if err != nil { - return err - } - - *o = ListInvitationsResponse(varListInvitationsResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableListInvitationsResponse struct { - value *ListInvitationsResponse - isSet bool -} - -func (v NullableListInvitationsResponse) Get() *ListInvitationsResponse { - return v.value -} - -func (v *NullableListInvitationsResponse) Set(val *ListInvitationsResponse) { - v.value = val - v.isSet = true -} - -func (v NullableListInvitationsResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableListInvitationsResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableListInvitationsResponse(val *ListInvitationsResponse) *NullableListInvitationsResponse { - return &NullableListInvitationsResponse{value: val, isSet: true} -} - -func (v NullableListInvitationsResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableListInvitationsResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_list_modules_response.go b/membershipclient/model_list_modules_response.go deleted file mode 100644 index 57c4c8d1..00000000 --- a/membershipclient/model_list_modules_response.go +++ /dev/null @@ -1,168 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the ListModulesResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ListModulesResponse{} - -// ListModulesResponse struct for ListModulesResponse -type ListModulesResponse struct { - Data []Module `json:"data"` - AdditionalProperties map[string]interface{} -} - -type _ListModulesResponse ListModulesResponse - -// NewListModulesResponse instantiates a new ListModulesResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewListModulesResponse(data []Module) *ListModulesResponse { - this := ListModulesResponse{} - this.Data = data - return &this -} - -// NewListModulesResponseWithDefaults instantiates a new ListModulesResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewListModulesResponseWithDefaults() *ListModulesResponse { - this := ListModulesResponse{} - return &this -} - -// GetData returns the Data field value -func (o *ListModulesResponse) GetData() []Module { - if o == nil { - var ret []Module - return ret - } - - return o.Data -} - -// GetDataOk returns a tuple with the Data field value -// and a boolean to check if the value has been set. -func (o *ListModulesResponse) GetDataOk() ([]Module, bool) { - if o == nil { - return nil, false - } - return o.Data, true -} - -// SetData sets field value -func (o *ListModulesResponse) SetData(v []Module) { - o.Data = v -} - -func (o ListModulesResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ListModulesResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["data"] = o.Data - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *ListModulesResponse) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "data", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varListModulesResponse := _ListModulesResponse{} - - err = json.Unmarshal(data, &varListModulesResponse) - - if err != nil { - return err - } - - *o = ListModulesResponse(varListModulesResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableListModulesResponse struct { - value *ListModulesResponse - isSet bool -} - -func (v NullableListModulesResponse) Get() *ListModulesResponse { - return v.value -} - -func (v *NullableListModulesResponse) Set(val *ListModulesResponse) { - v.value = val - v.isSet = true -} - -func (v NullableListModulesResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableListModulesResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableListModulesResponse(val *ListModulesResponse) *NullableListModulesResponse { - return &NullableListModulesResponse{value: val, isSet: true} -} - -func (v NullableListModulesResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableListModulesResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_list_organization_expanded_response.go b/membershipclient/model_list_organization_expanded_response.go deleted file mode 100644 index 7b3f0936..00000000 --- a/membershipclient/model_list_organization_expanded_response.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the ListOrganizationExpandedResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ListOrganizationExpandedResponse{} - -// ListOrganizationExpandedResponse struct for ListOrganizationExpandedResponse -type ListOrganizationExpandedResponse struct { - Data []OrganizationExpanded `json:"data,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _ListOrganizationExpandedResponse ListOrganizationExpandedResponse - -// NewListOrganizationExpandedResponse instantiates a new ListOrganizationExpandedResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewListOrganizationExpandedResponse() *ListOrganizationExpandedResponse { - this := ListOrganizationExpandedResponse{} - return &this -} - -// NewListOrganizationExpandedResponseWithDefaults instantiates a new ListOrganizationExpandedResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewListOrganizationExpandedResponseWithDefaults() *ListOrganizationExpandedResponse { - this := ListOrganizationExpandedResponse{} - return &this -} - -// GetData returns the Data field value if set, zero value otherwise. -func (o *ListOrganizationExpandedResponse) GetData() []OrganizationExpanded { - if o == nil || IsNil(o.Data) { - var ret []OrganizationExpanded - return ret - } - return o.Data -} - -// GetDataOk returns a tuple with the Data field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *ListOrganizationExpandedResponse) GetDataOk() ([]OrganizationExpanded, bool) { - if o == nil || IsNil(o.Data) { - return nil, false - } - return o.Data, true -} - -// HasData returns a boolean if a field has been set. -func (o *ListOrganizationExpandedResponse) HasData() bool { - if o != nil && !IsNil(o.Data) { - return true - } - - return false -} - -// SetData gets a reference to the given []OrganizationExpanded and assigns it to the Data field. -func (o *ListOrganizationExpandedResponse) SetData(v []OrganizationExpanded) { - o.Data = v -} - -func (o ListOrganizationExpandedResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ListOrganizationExpandedResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Data) { - toSerialize["data"] = o.Data - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *ListOrganizationExpandedResponse) UnmarshalJSON(data []byte) (err error) { - varListOrganizationExpandedResponse := _ListOrganizationExpandedResponse{} - - err = json.Unmarshal(data, &varListOrganizationExpandedResponse) - - if err != nil { - return err - } - - *o = ListOrganizationExpandedResponse(varListOrganizationExpandedResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableListOrganizationExpandedResponse struct { - value *ListOrganizationExpandedResponse - isSet bool -} - -func (v NullableListOrganizationExpandedResponse) Get() *ListOrganizationExpandedResponse { - return v.value -} - -func (v *NullableListOrganizationExpandedResponse) Set(val *ListOrganizationExpandedResponse) { - v.value = val - v.isSet = true -} - -func (v NullableListOrganizationExpandedResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableListOrganizationExpandedResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableListOrganizationExpandedResponse(val *ListOrganizationExpandedResponse) *NullableListOrganizationExpandedResponse { - return &NullableListOrganizationExpandedResponse{value: val, isSet: true} -} - -func (v NullableListOrganizationExpandedResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableListOrganizationExpandedResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_list_organization_response.go b/membershipclient/model_list_organization_response.go deleted file mode 100644 index 44cbb251..00000000 --- a/membershipclient/model_list_organization_response.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the ListOrganizationResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ListOrganizationResponse{} - -// ListOrganizationResponse struct for ListOrganizationResponse -type ListOrganizationResponse struct { - Data []Organization `json:"data,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _ListOrganizationResponse ListOrganizationResponse - -// NewListOrganizationResponse instantiates a new ListOrganizationResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewListOrganizationResponse() *ListOrganizationResponse { - this := ListOrganizationResponse{} - return &this -} - -// NewListOrganizationResponseWithDefaults instantiates a new ListOrganizationResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewListOrganizationResponseWithDefaults() *ListOrganizationResponse { - this := ListOrganizationResponse{} - return &this -} - -// GetData returns the Data field value if set, zero value otherwise. -func (o *ListOrganizationResponse) GetData() []Organization { - if o == nil || IsNil(o.Data) { - var ret []Organization - return ret - } - return o.Data -} - -// GetDataOk returns a tuple with the Data field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *ListOrganizationResponse) GetDataOk() ([]Organization, bool) { - if o == nil || IsNil(o.Data) { - return nil, false - } - return o.Data, true -} - -// HasData returns a boolean if a field has been set. -func (o *ListOrganizationResponse) HasData() bool { - if o != nil && !IsNil(o.Data) { - return true - } - - return false -} - -// SetData gets a reference to the given []Organization and assigns it to the Data field. -func (o *ListOrganizationResponse) SetData(v []Organization) { - o.Data = v -} - -func (o ListOrganizationResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ListOrganizationResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Data) { - toSerialize["data"] = o.Data - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *ListOrganizationResponse) UnmarshalJSON(data []byte) (err error) { - varListOrganizationResponse := _ListOrganizationResponse{} - - err = json.Unmarshal(data, &varListOrganizationResponse) - - if err != nil { - return err - } - - *o = ListOrganizationResponse(varListOrganizationResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableListOrganizationResponse struct { - value *ListOrganizationResponse - isSet bool -} - -func (v NullableListOrganizationResponse) Get() *ListOrganizationResponse { - return v.value -} - -func (v *NullableListOrganizationResponse) Set(val *ListOrganizationResponse) { - v.value = val - v.isSet = true -} - -func (v NullableListOrganizationResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableListOrganizationResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableListOrganizationResponse(val *ListOrganizationResponse) *NullableListOrganizationResponse { - return &NullableListOrganizationResponse{value: val, isSet: true} -} - -func (v NullableListOrganizationResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableListOrganizationResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_list_regions_response.go b/membershipclient/model_list_regions_response.go deleted file mode 100644 index 99944eb2..00000000 --- a/membershipclient/model_list_regions_response.go +++ /dev/null @@ -1,168 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the ListRegionsResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ListRegionsResponse{} - -// ListRegionsResponse struct for ListRegionsResponse -type ListRegionsResponse struct { - Data []AnyRegion `json:"data"` - AdditionalProperties map[string]interface{} -} - -type _ListRegionsResponse ListRegionsResponse - -// NewListRegionsResponse instantiates a new ListRegionsResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewListRegionsResponse(data []AnyRegion) *ListRegionsResponse { - this := ListRegionsResponse{} - this.Data = data - return &this -} - -// NewListRegionsResponseWithDefaults instantiates a new ListRegionsResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewListRegionsResponseWithDefaults() *ListRegionsResponse { - this := ListRegionsResponse{} - return &this -} - -// GetData returns the Data field value -func (o *ListRegionsResponse) GetData() []AnyRegion { - if o == nil { - var ret []AnyRegion - return ret - } - - return o.Data -} - -// GetDataOk returns a tuple with the Data field value -// and a boolean to check if the value has been set. -func (o *ListRegionsResponse) GetDataOk() ([]AnyRegion, bool) { - if o == nil { - return nil, false - } - return o.Data, true -} - -// SetData sets field value -func (o *ListRegionsResponse) SetData(v []AnyRegion) { - o.Data = v -} - -func (o ListRegionsResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ListRegionsResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["data"] = o.Data - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *ListRegionsResponse) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "data", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varListRegionsResponse := _ListRegionsResponse{} - - err = json.Unmarshal(data, &varListRegionsResponse) - - if err != nil { - return err - } - - *o = ListRegionsResponse(varListRegionsResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableListRegionsResponse struct { - value *ListRegionsResponse - isSet bool -} - -func (v NullableListRegionsResponse) Get() *ListRegionsResponse { - return v.value -} - -func (v *NullableListRegionsResponse) Set(val *ListRegionsResponse) { - v.value = val - v.isSet = true -} - -func (v NullableListRegionsResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableListRegionsResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableListRegionsResponse(val *ListRegionsResponse) *NullableListRegionsResponse { - return &NullableListRegionsResponse{value: val, isSet: true} -} - -func (v NullableListRegionsResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableListRegionsResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_list_stacks_response.go b/membershipclient/model_list_stacks_response.go deleted file mode 100644 index a401e210..00000000 --- a/membershipclient/model_list_stacks_response.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the ListStacksResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ListStacksResponse{} - -// ListStacksResponse struct for ListStacksResponse -type ListStacksResponse struct { - Data []Stack `json:"data,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _ListStacksResponse ListStacksResponse - -// NewListStacksResponse instantiates a new ListStacksResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewListStacksResponse() *ListStacksResponse { - this := ListStacksResponse{} - return &this -} - -// NewListStacksResponseWithDefaults instantiates a new ListStacksResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewListStacksResponseWithDefaults() *ListStacksResponse { - this := ListStacksResponse{} - return &this -} - -// GetData returns the Data field value if set, zero value otherwise. -func (o *ListStacksResponse) GetData() []Stack { - if o == nil || IsNil(o.Data) { - var ret []Stack - return ret - } - return o.Data -} - -// GetDataOk returns a tuple with the Data field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *ListStacksResponse) GetDataOk() ([]Stack, bool) { - if o == nil || IsNil(o.Data) { - return nil, false - } - return o.Data, true -} - -// HasData returns a boolean if a field has been set. -func (o *ListStacksResponse) HasData() bool { - if o != nil && !IsNil(o.Data) { - return true - } - - return false -} - -// SetData gets a reference to the given []Stack and assigns it to the Data field. -func (o *ListStacksResponse) SetData(v []Stack) { - o.Data = v -} - -func (o ListStacksResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ListStacksResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Data) { - toSerialize["data"] = o.Data - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *ListStacksResponse) UnmarshalJSON(data []byte) (err error) { - varListStacksResponse := _ListStacksResponse{} - - err = json.Unmarshal(data, &varListStacksResponse) - - if err != nil { - return err - } - - *o = ListStacksResponse(varListStacksResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableListStacksResponse struct { - value *ListStacksResponse - isSet bool -} - -func (v NullableListStacksResponse) Get() *ListStacksResponse { - return v.value -} - -func (v *NullableListStacksResponse) Set(val *ListStacksResponse) { - v.value = val - v.isSet = true -} - -func (v NullableListStacksResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableListStacksResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableListStacksResponse(val *ListStacksResponse) *NullableListStacksResponse { - return &NullableListStacksResponse{value: val, isSet: true} -} - -func (v NullableListStacksResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableListStacksResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_list_users_response.go b/membershipclient/model_list_users_response.go deleted file mode 100644 index 52843893..00000000 --- a/membershipclient/model_list_users_response.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the ListUsersResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ListUsersResponse{} - -// ListUsersResponse struct for ListUsersResponse -type ListUsersResponse struct { - Data []OrganizationUser `json:"data,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _ListUsersResponse ListUsersResponse - -// NewListUsersResponse instantiates a new ListUsersResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewListUsersResponse() *ListUsersResponse { - this := ListUsersResponse{} - return &this -} - -// NewListUsersResponseWithDefaults instantiates a new ListUsersResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewListUsersResponseWithDefaults() *ListUsersResponse { - this := ListUsersResponse{} - return &this -} - -// GetData returns the Data field value if set, zero value otherwise. -func (o *ListUsersResponse) GetData() []OrganizationUser { - if o == nil || IsNil(o.Data) { - var ret []OrganizationUser - return ret - } - return o.Data -} - -// GetDataOk returns a tuple with the Data field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *ListUsersResponse) GetDataOk() ([]OrganizationUser, bool) { - if o == nil || IsNil(o.Data) { - return nil, false - } - return o.Data, true -} - -// HasData returns a boolean if a field has been set. -func (o *ListUsersResponse) HasData() bool { - if o != nil && !IsNil(o.Data) { - return true - } - - return false -} - -// SetData gets a reference to the given []OrganizationUser and assigns it to the Data field. -func (o *ListUsersResponse) SetData(v []OrganizationUser) { - o.Data = v -} - -func (o ListUsersResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ListUsersResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Data) { - toSerialize["data"] = o.Data - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *ListUsersResponse) UnmarshalJSON(data []byte) (err error) { - varListUsersResponse := _ListUsersResponse{} - - err = json.Unmarshal(data, &varListUsersResponse) - - if err != nil { - return err - } - - *o = ListUsersResponse(varListUsersResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableListUsersResponse struct { - value *ListUsersResponse - isSet bool -} - -func (v NullableListUsersResponse) Get() *ListUsersResponse { - return v.value -} - -func (v *NullableListUsersResponse) Set(val *ListUsersResponse) { - v.value = val - v.isSet = true -} - -func (v NullableListUsersResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableListUsersResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableListUsersResponse(val *ListUsersResponse) *NullableListUsersResponse { - return &NullableListUsersResponse{value: val, isSet: true} -} - -func (v NullableListUsersResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableListUsersResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_log.go b/membershipclient/model_log.go deleted file mode 100644 index 5888d9ed..00000000 --- a/membershipclient/model_log.go +++ /dev/null @@ -1,314 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "time" - "fmt" -) - -// checks if the Log type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &Log{} - -// Log struct for Log -type Log struct { - Seq string `json:"seq"` - OrganizationId string `json:"organizationId"` - UserId string `json:"userId"` - Action string `json:"action"` - Date time.Time `json:"date"` - Data map[string]interface{} `json:"data"` - AdditionalProperties map[string]interface{} -} - -type _Log Log - -// NewLog instantiates a new Log object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewLog(seq string, organizationId string, userId string, action string, date time.Time, data map[string]interface{}) *Log { - this := Log{} - this.Seq = seq - this.OrganizationId = organizationId - this.UserId = userId - this.Action = action - this.Date = date - this.Data = data - return &this -} - -// NewLogWithDefaults instantiates a new Log object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewLogWithDefaults() *Log { - this := Log{} - return &this -} - -// GetSeq returns the Seq field value -func (o *Log) GetSeq() string { - if o == nil { - var ret string - return ret - } - - return o.Seq -} - -// GetSeqOk returns a tuple with the Seq field value -// and a boolean to check if the value has been set. -func (o *Log) GetSeqOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Seq, true -} - -// SetSeq sets field value -func (o *Log) SetSeq(v string) { - o.Seq = v -} - -// GetOrganizationId returns the OrganizationId field value -func (o *Log) GetOrganizationId() string { - if o == nil { - var ret string - return ret - } - - return o.OrganizationId -} - -// GetOrganizationIdOk returns a tuple with the OrganizationId field value -// and a boolean to check if the value has been set. -func (o *Log) GetOrganizationIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.OrganizationId, true -} - -// SetOrganizationId sets field value -func (o *Log) SetOrganizationId(v string) { - o.OrganizationId = v -} - -// GetUserId returns the UserId field value -func (o *Log) GetUserId() string { - if o == nil { - var ret string - return ret - } - - return o.UserId -} - -// GetUserIdOk returns a tuple with the UserId field value -// and a boolean to check if the value has been set. -func (o *Log) GetUserIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.UserId, true -} - -// SetUserId sets field value -func (o *Log) SetUserId(v string) { - o.UserId = v -} - -// GetAction returns the Action field value -func (o *Log) GetAction() string { - if o == nil { - var ret string - return ret - } - - return o.Action -} - -// GetActionOk returns a tuple with the Action field value -// and a boolean to check if the value has been set. -func (o *Log) GetActionOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Action, true -} - -// SetAction sets field value -func (o *Log) SetAction(v string) { - o.Action = v -} - -// GetDate returns the Date field value -func (o *Log) GetDate() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.Date -} - -// GetDateOk returns a tuple with the Date field value -// and a boolean to check if the value has been set. -func (o *Log) GetDateOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.Date, true -} - -// SetDate sets field value -func (o *Log) SetDate(v time.Time) { - o.Date = v -} - -// GetData returns the Data field value -func (o *Log) GetData() map[string]interface{} { - if o == nil { - var ret map[string]interface{} - return ret - } - - return o.Data -} - -// GetDataOk returns a tuple with the Data field value -// and a boolean to check if the value has been set. -func (o *Log) GetDataOk() (map[string]interface{}, bool) { - if o == nil { - return map[string]interface{}{}, false - } - return o.Data, true -} - -// SetData sets field value -func (o *Log) SetData(v map[string]interface{}) { - o.Data = v -} - -func (o Log) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o Log) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["seq"] = o.Seq - toSerialize["organizationId"] = o.OrganizationId - toSerialize["userId"] = o.UserId - toSerialize["action"] = o.Action - toSerialize["date"] = o.Date - toSerialize["data"] = o.Data - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *Log) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "seq", - "organizationId", - "userId", - "action", - "date", - "data", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varLog := _Log{} - - err = json.Unmarshal(data, &varLog) - - if err != nil { - return err - } - - *o = Log(varLog) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "seq") - delete(additionalProperties, "organizationId") - delete(additionalProperties, "userId") - delete(additionalProperties, "action") - delete(additionalProperties, "date") - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableLog struct { - value *Log - isSet bool -} - -func (v NullableLog) Get() *Log { - return v.value -} - -func (v *NullableLog) Set(val *Log) { - v.value = val - v.isSet = true -} - -func (v NullableLog) IsSet() bool { - return v.isSet -} - -func (v *NullableLog) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableLog(val *Log) *NullableLog { - return &NullableLog{value: val, isSet: true} -} - -func (v NullableLog) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableLog) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_log_cursor.go b/membershipclient/model_log_cursor.go deleted file mode 100644 index f61522ad..00000000 --- a/membershipclient/model_log_cursor.go +++ /dev/null @@ -1,168 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the LogCursor type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &LogCursor{} - -// LogCursor struct for LogCursor -type LogCursor struct { - Data LogCursorData `json:"data"` - AdditionalProperties map[string]interface{} -} - -type _LogCursor LogCursor - -// NewLogCursor instantiates a new LogCursor object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewLogCursor(data LogCursorData) *LogCursor { - this := LogCursor{} - this.Data = data - return &this -} - -// NewLogCursorWithDefaults instantiates a new LogCursor object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewLogCursorWithDefaults() *LogCursor { - this := LogCursor{} - return &this -} - -// GetData returns the Data field value -func (o *LogCursor) GetData() LogCursorData { - if o == nil { - var ret LogCursorData - return ret - } - - return o.Data -} - -// GetDataOk returns a tuple with the Data field value -// and a boolean to check if the value has been set. -func (o *LogCursor) GetDataOk() (*LogCursorData, bool) { - if o == nil { - return nil, false - } - return &o.Data, true -} - -// SetData sets field value -func (o *LogCursor) SetData(v LogCursorData) { - o.Data = v -} - -func (o LogCursor) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o LogCursor) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["data"] = o.Data - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *LogCursor) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "data", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varLogCursor := _LogCursor{} - - err = json.Unmarshal(data, &varLogCursor) - - if err != nil { - return err - } - - *o = LogCursor(varLogCursor) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableLogCursor struct { - value *LogCursor - isSet bool -} - -func (v NullableLogCursor) Get() *LogCursor { - return v.value -} - -func (v *NullableLogCursor) Set(val *LogCursor) { - v.value = val - v.isSet = true -} - -func (v NullableLogCursor) IsSet() bool { - return v.isSet -} - -func (v *NullableLogCursor) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableLogCursor(val *LogCursor) *NullableLogCursor { - return &NullableLogCursor{value: val, isSet: true} -} - -func (v NullableLogCursor) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableLogCursor) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_log_cursor_data.go b/membershipclient/model_log_cursor_data.go deleted file mode 100644 index d85419e6..00000000 --- a/membershipclient/model_log_cursor_data.go +++ /dev/null @@ -1,300 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the LogCursorData type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &LogCursorData{} - -// LogCursorData struct for LogCursorData -type LogCursorData struct { - PageSize int64 `json:"pageSize"` - HasMore bool `json:"hasMore"` - Previous *string `json:"previous,omitempty"` - Next *string `json:"next,omitempty"` - Data []Log `json:"data"` - AdditionalProperties map[string]interface{} -} - -type _LogCursorData LogCursorData - -// NewLogCursorData instantiates a new LogCursorData object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewLogCursorData(pageSize int64, hasMore bool, data []Log) *LogCursorData { - this := LogCursorData{} - this.PageSize = pageSize - this.HasMore = hasMore - this.Data = data - return &this -} - -// NewLogCursorDataWithDefaults instantiates a new LogCursorData object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewLogCursorDataWithDefaults() *LogCursorData { - this := LogCursorData{} - return &this -} - -// GetPageSize returns the PageSize field value -func (o *LogCursorData) GetPageSize() int64 { - if o == nil { - var ret int64 - return ret - } - - return o.PageSize -} - -// GetPageSizeOk returns a tuple with the PageSize field value -// and a boolean to check if the value has been set. -func (o *LogCursorData) GetPageSizeOk() (*int64, bool) { - if o == nil { - return nil, false - } - return &o.PageSize, true -} - -// SetPageSize sets field value -func (o *LogCursorData) SetPageSize(v int64) { - o.PageSize = v -} - -// GetHasMore returns the HasMore field value -func (o *LogCursorData) GetHasMore() bool { - if o == nil { - var ret bool - return ret - } - - return o.HasMore -} - -// GetHasMoreOk returns a tuple with the HasMore field value -// and a boolean to check if the value has been set. -func (o *LogCursorData) GetHasMoreOk() (*bool, bool) { - if o == nil { - return nil, false - } - return &o.HasMore, true -} - -// SetHasMore sets field value -func (o *LogCursorData) SetHasMore(v bool) { - o.HasMore = v -} - -// GetPrevious returns the Previous field value if set, zero value otherwise. -func (o *LogCursorData) GetPrevious() string { - if o == nil || IsNil(o.Previous) { - var ret string - return ret - } - return *o.Previous -} - -// GetPreviousOk returns a tuple with the Previous field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *LogCursorData) GetPreviousOk() (*string, bool) { - if o == nil || IsNil(o.Previous) { - return nil, false - } - return o.Previous, true -} - -// HasPrevious returns a boolean if a field has been set. -func (o *LogCursorData) HasPrevious() bool { - if o != nil && !IsNil(o.Previous) { - return true - } - - return false -} - -// SetPrevious gets a reference to the given string and assigns it to the Previous field. -func (o *LogCursorData) SetPrevious(v string) { - o.Previous = &v -} - -// GetNext returns the Next field value if set, zero value otherwise. -func (o *LogCursorData) GetNext() string { - if o == nil || IsNil(o.Next) { - var ret string - return ret - } - return *o.Next -} - -// GetNextOk returns a tuple with the Next field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *LogCursorData) GetNextOk() (*string, bool) { - if o == nil || IsNil(o.Next) { - return nil, false - } - return o.Next, true -} - -// HasNext returns a boolean if a field has been set. -func (o *LogCursorData) HasNext() bool { - if o != nil && !IsNil(o.Next) { - return true - } - - return false -} - -// SetNext gets a reference to the given string and assigns it to the Next field. -func (o *LogCursorData) SetNext(v string) { - o.Next = &v -} - -// GetData returns the Data field value -func (o *LogCursorData) GetData() []Log { - if o == nil { - var ret []Log - return ret - } - - return o.Data -} - -// GetDataOk returns a tuple with the Data field value -// and a boolean to check if the value has been set. -func (o *LogCursorData) GetDataOk() ([]Log, bool) { - if o == nil { - return nil, false - } - return o.Data, true -} - -// SetData sets field value -func (o *LogCursorData) SetData(v []Log) { - o.Data = v -} - -func (o LogCursorData) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o LogCursorData) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["pageSize"] = o.PageSize - toSerialize["hasMore"] = o.HasMore - if !IsNil(o.Previous) { - toSerialize["previous"] = o.Previous - } - if !IsNil(o.Next) { - toSerialize["next"] = o.Next - } - toSerialize["data"] = o.Data - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *LogCursorData) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "pageSize", - "hasMore", - "data", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varLogCursorData := _LogCursorData{} - - err = json.Unmarshal(data, &varLogCursorData) - - if err != nil { - return err - } - - *o = LogCursorData(varLogCursorData) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "pageSize") - delete(additionalProperties, "hasMore") - delete(additionalProperties, "previous") - delete(additionalProperties, "next") - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableLogCursorData struct { - value *LogCursorData - isSet bool -} - -func (v NullableLogCursorData) Get() *LogCursorData { - return v.value -} - -func (v *NullableLogCursorData) Set(val *LogCursorData) { - v.value = val - v.isSet = true -} - -func (v NullableLogCursorData) IsSet() bool { - return v.isSet -} - -func (v *NullableLogCursorData) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableLogCursorData(val *LogCursorData) *NullableLogCursorData { - return &NullableLogCursorData{value: val, isSet: true} -} - -func (v NullableLogCursorData) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableLogCursorData) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_microsoft_idp_config.go b/membershipclient/model_microsoft_idp_config.go deleted file mode 100644 index 6a4cfa6e..00000000 --- a/membershipclient/model_microsoft_idp_config.go +++ /dev/null @@ -1,288 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the MicrosoftIDPConfig type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &MicrosoftIDPConfig{} - -// MicrosoftIDPConfig struct for MicrosoftIDPConfig -type MicrosoftIDPConfig struct { - // Type of the authentication provider - Type string `json:"type"` - // Name of the authentication provider - Name string `json:"name"` - // Client ID for the authentication provider - ClientID string `json:"clientID"` - // Client secret for the authentication provider - ClientSecret string `json:"clientSecret"` - Config MicrosoftIDPConfigAllOfConfig `json:"config"` - AdditionalProperties map[string]interface{} -} - -type _MicrosoftIDPConfig MicrosoftIDPConfig - -// NewMicrosoftIDPConfig instantiates a new MicrosoftIDPConfig object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewMicrosoftIDPConfig(type_ string, name string, clientID string, clientSecret string, config MicrosoftIDPConfigAllOfConfig) *MicrosoftIDPConfig { - this := MicrosoftIDPConfig{} - this.Type = type_ - this.Name = name - this.ClientID = clientID - this.ClientSecret = clientSecret - this.Config = config - return &this -} - -// NewMicrosoftIDPConfigWithDefaults instantiates a new MicrosoftIDPConfig object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewMicrosoftIDPConfigWithDefaults() *MicrosoftIDPConfig { - this := MicrosoftIDPConfig{} - return &this -} - -// GetType returns the Type field value -func (o *MicrosoftIDPConfig) GetType() string { - if o == nil { - var ret string - return ret - } - - return o.Type -} - -// GetTypeOk returns a tuple with the Type field value -// and a boolean to check if the value has been set. -func (o *MicrosoftIDPConfig) GetTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Type, true -} - -// SetType sets field value -func (o *MicrosoftIDPConfig) SetType(v string) { - o.Type = v -} - -// GetName returns the Name field value -func (o *MicrosoftIDPConfig) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *MicrosoftIDPConfig) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *MicrosoftIDPConfig) SetName(v string) { - o.Name = v -} - -// GetClientID returns the ClientID field value -func (o *MicrosoftIDPConfig) GetClientID() string { - if o == nil { - var ret string - return ret - } - - return o.ClientID -} - -// GetClientIDOk returns a tuple with the ClientID field value -// and a boolean to check if the value has been set. -func (o *MicrosoftIDPConfig) GetClientIDOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ClientID, true -} - -// SetClientID sets field value -func (o *MicrosoftIDPConfig) SetClientID(v string) { - o.ClientID = v -} - -// GetClientSecret returns the ClientSecret field value -func (o *MicrosoftIDPConfig) GetClientSecret() string { - if o == nil { - var ret string - return ret - } - - return o.ClientSecret -} - -// GetClientSecretOk returns a tuple with the ClientSecret field value -// and a boolean to check if the value has been set. -func (o *MicrosoftIDPConfig) GetClientSecretOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ClientSecret, true -} - -// SetClientSecret sets field value -func (o *MicrosoftIDPConfig) SetClientSecret(v string) { - o.ClientSecret = v -} - -// GetConfig returns the Config field value -func (o *MicrosoftIDPConfig) GetConfig() MicrosoftIDPConfigAllOfConfig { - if o == nil { - var ret MicrosoftIDPConfigAllOfConfig - return ret - } - - return o.Config -} - -// GetConfigOk returns a tuple with the Config field value -// and a boolean to check if the value has been set. -func (o *MicrosoftIDPConfig) GetConfigOk() (*MicrosoftIDPConfigAllOfConfig, bool) { - if o == nil { - return nil, false - } - return &o.Config, true -} - -// SetConfig sets field value -func (o *MicrosoftIDPConfig) SetConfig(v MicrosoftIDPConfigAllOfConfig) { - o.Config = v -} - -func (o MicrosoftIDPConfig) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o MicrosoftIDPConfig) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["type"] = o.Type - toSerialize["name"] = o.Name - toSerialize["clientID"] = o.ClientID - toSerialize["clientSecret"] = o.ClientSecret - toSerialize["config"] = o.Config - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *MicrosoftIDPConfig) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "type", - "name", - "clientID", - "clientSecret", - "config", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varMicrosoftIDPConfig := _MicrosoftIDPConfig{} - - err = json.Unmarshal(data, &varMicrosoftIDPConfig) - - if err != nil { - return err - } - - *o = MicrosoftIDPConfig(varMicrosoftIDPConfig) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "type") - delete(additionalProperties, "name") - delete(additionalProperties, "clientID") - delete(additionalProperties, "clientSecret") - delete(additionalProperties, "config") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableMicrosoftIDPConfig struct { - value *MicrosoftIDPConfig - isSet bool -} - -func (v NullableMicrosoftIDPConfig) Get() *MicrosoftIDPConfig { - return v.value -} - -func (v *NullableMicrosoftIDPConfig) Set(val *MicrosoftIDPConfig) { - v.value = val - v.isSet = true -} - -func (v NullableMicrosoftIDPConfig) IsSet() bool { - return v.isSet -} - -func (v *NullableMicrosoftIDPConfig) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableMicrosoftIDPConfig(val *MicrosoftIDPConfig) *NullableMicrosoftIDPConfig { - return &NullableMicrosoftIDPConfig{value: val, isSet: true} -} - -func (v NullableMicrosoftIDPConfig) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableMicrosoftIDPConfig) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_microsoft_idp_config_all_of_config.go b/membershipclient/model_microsoft_idp_config_all_of_config.go deleted file mode 100644 index b58c6c99..00000000 --- a/membershipclient/model_microsoft_idp_config_all_of_config.go +++ /dev/null @@ -1,160 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the MicrosoftIDPConfigAllOfConfig type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &MicrosoftIDPConfigAllOfConfig{} - -// MicrosoftIDPConfigAllOfConfig struct for MicrosoftIDPConfigAllOfConfig -type MicrosoftIDPConfigAllOfConfig struct { - // Tenant ID for Microsoft authentication - Tenant *string `json:"tenant,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _MicrosoftIDPConfigAllOfConfig MicrosoftIDPConfigAllOfConfig - -// NewMicrosoftIDPConfigAllOfConfig instantiates a new MicrosoftIDPConfigAllOfConfig object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewMicrosoftIDPConfigAllOfConfig() *MicrosoftIDPConfigAllOfConfig { - this := MicrosoftIDPConfigAllOfConfig{} - var tenant string = "common" - this.Tenant = &tenant - return &this -} - -// NewMicrosoftIDPConfigAllOfConfigWithDefaults instantiates a new MicrosoftIDPConfigAllOfConfig object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewMicrosoftIDPConfigAllOfConfigWithDefaults() *MicrosoftIDPConfigAllOfConfig { - this := MicrosoftIDPConfigAllOfConfig{} - var tenant string = "common" - this.Tenant = &tenant - return &this -} - -// GetTenant returns the Tenant field value if set, zero value otherwise. -func (o *MicrosoftIDPConfigAllOfConfig) GetTenant() string { - if o == nil || IsNil(o.Tenant) { - var ret string - return ret - } - return *o.Tenant -} - -// GetTenantOk returns a tuple with the Tenant field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *MicrosoftIDPConfigAllOfConfig) GetTenantOk() (*string, bool) { - if o == nil || IsNil(o.Tenant) { - return nil, false - } - return o.Tenant, true -} - -// HasTenant returns a boolean if a field has been set. -func (o *MicrosoftIDPConfigAllOfConfig) HasTenant() bool { - if o != nil && !IsNil(o.Tenant) { - return true - } - - return false -} - -// SetTenant gets a reference to the given string and assigns it to the Tenant field. -func (o *MicrosoftIDPConfigAllOfConfig) SetTenant(v string) { - o.Tenant = &v -} - -func (o MicrosoftIDPConfigAllOfConfig) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o MicrosoftIDPConfigAllOfConfig) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Tenant) { - toSerialize["tenant"] = o.Tenant - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *MicrosoftIDPConfigAllOfConfig) UnmarshalJSON(data []byte) (err error) { - varMicrosoftIDPConfigAllOfConfig := _MicrosoftIDPConfigAllOfConfig{} - - err = json.Unmarshal(data, &varMicrosoftIDPConfigAllOfConfig) - - if err != nil { - return err - } - - *o = MicrosoftIDPConfigAllOfConfig(varMicrosoftIDPConfigAllOfConfig) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "tenant") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableMicrosoftIDPConfigAllOfConfig struct { - value *MicrosoftIDPConfigAllOfConfig - isSet bool -} - -func (v NullableMicrosoftIDPConfigAllOfConfig) Get() *MicrosoftIDPConfigAllOfConfig { - return v.value -} - -func (v *NullableMicrosoftIDPConfigAllOfConfig) Set(val *MicrosoftIDPConfigAllOfConfig) { - v.value = val - v.isSet = true -} - -func (v NullableMicrosoftIDPConfigAllOfConfig) IsSet() bool { - return v.isSet -} - -func (v *NullableMicrosoftIDPConfigAllOfConfig) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableMicrosoftIDPConfigAllOfConfig(val *MicrosoftIDPConfigAllOfConfig) *NullableMicrosoftIDPConfigAllOfConfig { - return &NullableMicrosoftIDPConfigAllOfConfig{value: val, isSet: true} -} - -func (v NullableMicrosoftIDPConfigAllOfConfig) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableMicrosoftIDPConfigAllOfConfig) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_module.go b/membershipclient/model_module.go deleted file mode 100644 index a86b9a3e..00000000 --- a/membershipclient/model_module.go +++ /dev/null @@ -1,322 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "time" - "fmt" -) - -// checks if the Module type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &Module{} - -// Module struct for Module -type Module struct { - Name string `json:"name"` - State string `json:"state"` - Status string `json:"status"` - LastStatusUpdate time.Time `json:"lastStatusUpdate"` - LastStateUpdate time.Time `json:"lastStateUpdate"` - ClusterStatus map[string]interface{} `json:"clusterStatus,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _Module Module - -// NewModule instantiates a new Module object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewModule(name string, state string, status string, lastStatusUpdate time.Time, lastStateUpdate time.Time) *Module { - this := Module{} - this.Name = name - this.State = state - this.Status = status - this.LastStatusUpdate = lastStatusUpdate - this.LastStateUpdate = lastStateUpdate - return &this -} - -// NewModuleWithDefaults instantiates a new Module object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewModuleWithDefaults() *Module { - this := Module{} - return &this -} - -// GetName returns the Name field value -func (o *Module) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *Module) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *Module) SetName(v string) { - o.Name = v -} - -// GetState returns the State field value -func (o *Module) GetState() string { - if o == nil { - var ret string - return ret - } - - return o.State -} - -// GetStateOk returns a tuple with the State field value -// and a boolean to check if the value has been set. -func (o *Module) GetStateOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.State, true -} - -// SetState sets field value -func (o *Module) SetState(v string) { - o.State = v -} - -// GetStatus returns the Status field value -func (o *Module) GetStatus() string { - if o == nil { - var ret string - return ret - } - - return o.Status -} - -// GetStatusOk returns a tuple with the Status field value -// and a boolean to check if the value has been set. -func (o *Module) GetStatusOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Status, true -} - -// SetStatus sets field value -func (o *Module) SetStatus(v string) { - o.Status = v -} - -// GetLastStatusUpdate returns the LastStatusUpdate field value -func (o *Module) GetLastStatusUpdate() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.LastStatusUpdate -} - -// GetLastStatusUpdateOk returns a tuple with the LastStatusUpdate field value -// and a boolean to check if the value has been set. -func (o *Module) GetLastStatusUpdateOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.LastStatusUpdate, true -} - -// SetLastStatusUpdate sets field value -func (o *Module) SetLastStatusUpdate(v time.Time) { - o.LastStatusUpdate = v -} - -// GetLastStateUpdate returns the LastStateUpdate field value -func (o *Module) GetLastStateUpdate() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.LastStateUpdate -} - -// GetLastStateUpdateOk returns a tuple with the LastStateUpdate field value -// and a boolean to check if the value has been set. -func (o *Module) GetLastStateUpdateOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.LastStateUpdate, true -} - -// SetLastStateUpdate sets field value -func (o *Module) SetLastStateUpdate(v time.Time) { - o.LastStateUpdate = v -} - -// GetClusterStatus returns the ClusterStatus field value if set, zero value otherwise. -func (o *Module) GetClusterStatus() map[string]interface{} { - if o == nil || IsNil(o.ClusterStatus) { - var ret map[string]interface{} - return ret - } - return o.ClusterStatus -} - -// GetClusterStatusOk returns a tuple with the ClusterStatus field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Module) GetClusterStatusOk() (map[string]interface{}, bool) { - if o == nil || IsNil(o.ClusterStatus) { - return map[string]interface{}{}, false - } - return o.ClusterStatus, true -} - -// HasClusterStatus returns a boolean if a field has been set. -func (o *Module) HasClusterStatus() bool { - if o != nil && !IsNil(o.ClusterStatus) { - return true - } - - return false -} - -// SetClusterStatus gets a reference to the given map[string]interface{} and assigns it to the ClusterStatus field. -func (o *Module) SetClusterStatus(v map[string]interface{}) { - o.ClusterStatus = v -} - -func (o Module) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o Module) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["name"] = o.Name - toSerialize["state"] = o.State - toSerialize["status"] = o.Status - toSerialize["lastStatusUpdate"] = o.LastStatusUpdate - toSerialize["lastStateUpdate"] = o.LastStateUpdate - if !IsNil(o.ClusterStatus) { - toSerialize["clusterStatus"] = o.ClusterStatus - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *Module) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "name", - "state", - "status", - "lastStatusUpdate", - "lastStateUpdate", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varModule := _Module{} - - err = json.Unmarshal(data, &varModule) - - if err != nil { - return err - } - - *o = Module(varModule) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "name") - delete(additionalProperties, "state") - delete(additionalProperties, "status") - delete(additionalProperties, "lastStatusUpdate") - delete(additionalProperties, "lastStateUpdate") - delete(additionalProperties, "clusterStatus") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableModule struct { - value *Module - isSet bool -} - -func (v NullableModule) Get() *Module { - return v.value -} - -func (v *NullableModule) Set(val *Module) { - v.value = val - v.isSet = true -} - -func (v NullableModule) IsSet() bool { - return v.isSet -} - -func (v *NullableModule) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableModule(val *Module) *NullableModule { - return &NullableModule{value: val, isSet: true} -} - -func (v NullableModule) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableModule) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_oidc_config.go b/membershipclient/model_oidc_config.go deleted file mode 100644 index 1f153d95..00000000 --- a/membershipclient/model_oidc_config.go +++ /dev/null @@ -1,288 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the OIDCConfig type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &OIDCConfig{} - -// OIDCConfig struct for OIDCConfig -type OIDCConfig struct { - // Type of the authentication provider - Type string `json:"type"` - // Name of the authentication provider - Name string `json:"name"` - // Client ID for the authentication provider - ClientID string `json:"clientID"` - // Client secret for the authentication provider - ClientSecret string `json:"clientSecret"` - Config OIDCConfigAllOfConfig `json:"config"` - AdditionalProperties map[string]interface{} -} - -type _OIDCConfig OIDCConfig - -// NewOIDCConfig instantiates a new OIDCConfig object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewOIDCConfig(type_ string, name string, clientID string, clientSecret string, config OIDCConfigAllOfConfig) *OIDCConfig { - this := OIDCConfig{} - this.Type = type_ - this.Name = name - this.ClientID = clientID - this.ClientSecret = clientSecret - this.Config = config - return &this -} - -// NewOIDCConfigWithDefaults instantiates a new OIDCConfig object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewOIDCConfigWithDefaults() *OIDCConfig { - this := OIDCConfig{} - return &this -} - -// GetType returns the Type field value -func (o *OIDCConfig) GetType() string { - if o == nil { - var ret string - return ret - } - - return o.Type -} - -// GetTypeOk returns a tuple with the Type field value -// and a boolean to check if the value has been set. -func (o *OIDCConfig) GetTypeOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Type, true -} - -// SetType sets field value -func (o *OIDCConfig) SetType(v string) { - o.Type = v -} - -// GetName returns the Name field value -func (o *OIDCConfig) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *OIDCConfig) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *OIDCConfig) SetName(v string) { - o.Name = v -} - -// GetClientID returns the ClientID field value -func (o *OIDCConfig) GetClientID() string { - if o == nil { - var ret string - return ret - } - - return o.ClientID -} - -// GetClientIDOk returns a tuple with the ClientID field value -// and a boolean to check if the value has been set. -func (o *OIDCConfig) GetClientIDOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ClientID, true -} - -// SetClientID sets field value -func (o *OIDCConfig) SetClientID(v string) { - o.ClientID = v -} - -// GetClientSecret returns the ClientSecret field value -func (o *OIDCConfig) GetClientSecret() string { - if o == nil { - var ret string - return ret - } - - return o.ClientSecret -} - -// GetClientSecretOk returns a tuple with the ClientSecret field value -// and a boolean to check if the value has been set. -func (o *OIDCConfig) GetClientSecretOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ClientSecret, true -} - -// SetClientSecret sets field value -func (o *OIDCConfig) SetClientSecret(v string) { - o.ClientSecret = v -} - -// GetConfig returns the Config field value -func (o *OIDCConfig) GetConfig() OIDCConfigAllOfConfig { - if o == nil { - var ret OIDCConfigAllOfConfig - return ret - } - - return o.Config -} - -// GetConfigOk returns a tuple with the Config field value -// and a boolean to check if the value has been set. -func (o *OIDCConfig) GetConfigOk() (*OIDCConfigAllOfConfig, bool) { - if o == nil { - return nil, false - } - return &o.Config, true -} - -// SetConfig sets field value -func (o *OIDCConfig) SetConfig(v OIDCConfigAllOfConfig) { - o.Config = v -} - -func (o OIDCConfig) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o OIDCConfig) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["type"] = o.Type - toSerialize["name"] = o.Name - toSerialize["clientID"] = o.ClientID - toSerialize["clientSecret"] = o.ClientSecret - toSerialize["config"] = o.Config - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *OIDCConfig) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "type", - "name", - "clientID", - "clientSecret", - "config", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varOIDCConfig := _OIDCConfig{} - - err = json.Unmarshal(data, &varOIDCConfig) - - if err != nil { - return err - } - - *o = OIDCConfig(varOIDCConfig) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "type") - delete(additionalProperties, "name") - delete(additionalProperties, "clientID") - delete(additionalProperties, "clientSecret") - delete(additionalProperties, "config") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableOIDCConfig struct { - value *OIDCConfig - isSet bool -} - -func (v NullableOIDCConfig) Get() *OIDCConfig { - return v.value -} - -func (v *NullableOIDCConfig) Set(val *OIDCConfig) { - v.value = val - v.isSet = true -} - -func (v NullableOIDCConfig) IsSet() bool { - return v.isSet -} - -func (v *NullableOIDCConfig) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableOIDCConfig(val *OIDCConfig) *NullableOIDCConfig { - return &NullableOIDCConfig{value: val, isSet: true} -} - -func (v NullableOIDCConfig) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableOIDCConfig) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_oidc_config_all_of_config.go b/membershipclient/model_oidc_config_all_of_config.go deleted file mode 100644 index e9c542d0..00000000 --- a/membershipclient/model_oidc_config_all_of_config.go +++ /dev/null @@ -1,210 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the OIDCConfigAllOfConfig type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &OIDCConfigAllOfConfig{} - -// OIDCConfigAllOfConfig struct for OIDCConfigAllOfConfig -type OIDCConfigAllOfConfig struct { - // OIDC issuer URL - Issuer string `json:"issuer"` - DiscoveryPath *string `json:"discoveryPath,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _OIDCConfigAllOfConfig OIDCConfigAllOfConfig - -// NewOIDCConfigAllOfConfig instantiates a new OIDCConfigAllOfConfig object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewOIDCConfigAllOfConfig(issuer string) *OIDCConfigAllOfConfig { - this := OIDCConfigAllOfConfig{} - this.Issuer = issuer - var discoveryPath string = "/.well-known/openid-configuration" - this.DiscoveryPath = &discoveryPath - return &this -} - -// NewOIDCConfigAllOfConfigWithDefaults instantiates a new OIDCConfigAllOfConfig object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewOIDCConfigAllOfConfigWithDefaults() *OIDCConfigAllOfConfig { - this := OIDCConfigAllOfConfig{} - var discoveryPath string = "/.well-known/openid-configuration" - this.DiscoveryPath = &discoveryPath - return &this -} - -// GetIssuer returns the Issuer field value -func (o *OIDCConfigAllOfConfig) GetIssuer() string { - if o == nil { - var ret string - return ret - } - - return o.Issuer -} - -// GetIssuerOk returns a tuple with the Issuer field value -// and a boolean to check if the value has been set. -func (o *OIDCConfigAllOfConfig) GetIssuerOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Issuer, true -} - -// SetIssuer sets field value -func (o *OIDCConfigAllOfConfig) SetIssuer(v string) { - o.Issuer = v -} - -// GetDiscoveryPath returns the DiscoveryPath field value if set, zero value otherwise. -func (o *OIDCConfigAllOfConfig) GetDiscoveryPath() string { - if o == nil || IsNil(o.DiscoveryPath) { - var ret string - return ret - } - return *o.DiscoveryPath -} - -// GetDiscoveryPathOk returns a tuple with the DiscoveryPath field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *OIDCConfigAllOfConfig) GetDiscoveryPathOk() (*string, bool) { - if o == nil || IsNil(o.DiscoveryPath) { - return nil, false - } - return o.DiscoveryPath, true -} - -// HasDiscoveryPath returns a boolean if a field has been set. -func (o *OIDCConfigAllOfConfig) HasDiscoveryPath() bool { - if o != nil && !IsNil(o.DiscoveryPath) { - return true - } - - return false -} - -// SetDiscoveryPath gets a reference to the given string and assigns it to the DiscoveryPath field. -func (o *OIDCConfigAllOfConfig) SetDiscoveryPath(v string) { - o.DiscoveryPath = &v -} - -func (o OIDCConfigAllOfConfig) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o OIDCConfigAllOfConfig) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["issuer"] = o.Issuer - if !IsNil(o.DiscoveryPath) { - toSerialize["discoveryPath"] = o.DiscoveryPath - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *OIDCConfigAllOfConfig) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "issuer", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varOIDCConfigAllOfConfig := _OIDCConfigAllOfConfig{} - - err = json.Unmarshal(data, &varOIDCConfigAllOfConfig) - - if err != nil { - return err - } - - *o = OIDCConfigAllOfConfig(varOIDCConfigAllOfConfig) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "issuer") - delete(additionalProperties, "discoveryPath") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableOIDCConfigAllOfConfig struct { - value *OIDCConfigAllOfConfig - isSet bool -} - -func (v NullableOIDCConfigAllOfConfig) Get() *OIDCConfigAllOfConfig { - return v.value -} - -func (v *NullableOIDCConfigAllOfConfig) Set(val *OIDCConfigAllOfConfig) { - v.value = val - v.isSet = true -} - -func (v NullableOIDCConfigAllOfConfig) IsSet() bool { - return v.isSet -} - -func (v *NullableOIDCConfigAllOfConfig) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableOIDCConfigAllOfConfig(val *OIDCConfigAllOfConfig) *NullableOIDCConfigAllOfConfig { - return &NullableOIDCConfigAllOfConfig{value: val, isSet: true} -} - -func (v NullableOIDCConfigAllOfConfig) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableOIDCConfigAllOfConfig) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_organization.go b/membershipclient/model_organization.go deleted file mode 100644 index bd8d9785..00000000 --- a/membershipclient/model_organization.go +++ /dev/null @@ -1,492 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "time" - "fmt" -) - -// checks if the Organization type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &Organization{} - -// Organization struct for Organization -type Organization struct { - // Organization name - Name string `json:"name"` - DefaultOrganizationAccess *Role `json:"defaultOrganizationAccess,omitempty"` - DefaultStackAccess *Role `json:"defaultStackAccess,omitempty"` - // Organization domain - Domain *string `json:"domain,omitempty"` - // Organization ID - Id string `json:"id"` - // Owner ID - OwnerId string `json:"ownerId"` - // Number of available stacks - AvailableStacks *int32 `json:"availableStacks,omitempty"` - // Number of available sandboxes - AvailableSandboxes *int32 `json:"availableSandboxes,omitempty"` - CreatedAt *time.Time `json:"createdAt,omitempty"` - UpdatedAt *time.Time `json:"updatedAt,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _Organization Organization - -// NewOrganization instantiates a new Organization object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewOrganization(name string, id string, ownerId string) *Organization { - this := Organization{} - this.Name = name - this.Id = id - this.OwnerId = ownerId - return &this -} - -// NewOrganizationWithDefaults instantiates a new Organization object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewOrganizationWithDefaults() *Organization { - this := Organization{} - return &this -} - -// GetName returns the Name field value -func (o *Organization) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *Organization) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *Organization) SetName(v string) { - o.Name = v -} - -// GetDefaultOrganizationAccess returns the DefaultOrganizationAccess field value if set, zero value otherwise. -func (o *Organization) GetDefaultOrganizationAccess() Role { - if o == nil || IsNil(o.DefaultOrganizationAccess) { - var ret Role - return ret - } - return *o.DefaultOrganizationAccess -} - -// GetDefaultOrganizationAccessOk returns a tuple with the DefaultOrganizationAccess field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Organization) GetDefaultOrganizationAccessOk() (*Role, bool) { - if o == nil || IsNil(o.DefaultOrganizationAccess) { - return nil, false - } - return o.DefaultOrganizationAccess, true -} - -// HasDefaultOrganizationAccess returns a boolean if a field has been set. -func (o *Organization) HasDefaultOrganizationAccess() bool { - if o != nil && !IsNil(o.DefaultOrganizationAccess) { - return true - } - - return false -} - -// SetDefaultOrganizationAccess gets a reference to the given Role and assigns it to the DefaultOrganizationAccess field. -func (o *Organization) SetDefaultOrganizationAccess(v Role) { - o.DefaultOrganizationAccess = &v -} - -// GetDefaultStackAccess returns the DefaultStackAccess field value if set, zero value otherwise. -func (o *Organization) GetDefaultStackAccess() Role { - if o == nil || IsNil(o.DefaultStackAccess) { - var ret Role - return ret - } - return *o.DefaultStackAccess -} - -// GetDefaultStackAccessOk returns a tuple with the DefaultStackAccess field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Organization) GetDefaultStackAccessOk() (*Role, bool) { - if o == nil || IsNil(o.DefaultStackAccess) { - return nil, false - } - return o.DefaultStackAccess, true -} - -// HasDefaultStackAccess returns a boolean if a field has been set. -func (o *Organization) HasDefaultStackAccess() bool { - if o != nil && !IsNil(o.DefaultStackAccess) { - return true - } - - return false -} - -// SetDefaultStackAccess gets a reference to the given Role and assigns it to the DefaultStackAccess field. -func (o *Organization) SetDefaultStackAccess(v Role) { - o.DefaultStackAccess = &v -} - -// GetDomain returns the Domain field value if set, zero value otherwise. -func (o *Organization) GetDomain() string { - if o == nil || IsNil(o.Domain) { - var ret string - return ret - } - return *o.Domain -} - -// GetDomainOk returns a tuple with the Domain field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Organization) GetDomainOk() (*string, bool) { - if o == nil || IsNil(o.Domain) { - return nil, false - } - return o.Domain, true -} - -// HasDomain returns a boolean if a field has been set. -func (o *Organization) HasDomain() bool { - if o != nil && !IsNil(o.Domain) { - return true - } - - return false -} - -// SetDomain gets a reference to the given string and assigns it to the Domain field. -func (o *Organization) SetDomain(v string) { - o.Domain = &v -} - -// GetId returns the Id field value -func (o *Organization) GetId() string { - if o == nil { - var ret string - return ret - } - - return o.Id -} - -// GetIdOk returns a tuple with the Id field value -// and a boolean to check if the value has been set. -func (o *Organization) GetIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Id, true -} - -// SetId sets field value -func (o *Organization) SetId(v string) { - o.Id = v -} - -// GetOwnerId returns the OwnerId field value -func (o *Organization) GetOwnerId() string { - if o == nil { - var ret string - return ret - } - - return o.OwnerId -} - -// GetOwnerIdOk returns a tuple with the OwnerId field value -// and a boolean to check if the value has been set. -func (o *Organization) GetOwnerIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.OwnerId, true -} - -// SetOwnerId sets field value -func (o *Organization) SetOwnerId(v string) { - o.OwnerId = v -} - -// GetAvailableStacks returns the AvailableStacks field value if set, zero value otherwise. -func (o *Organization) GetAvailableStacks() int32 { - if o == nil || IsNil(o.AvailableStacks) { - var ret int32 - return ret - } - return *o.AvailableStacks -} - -// GetAvailableStacksOk returns a tuple with the AvailableStacks field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Organization) GetAvailableStacksOk() (*int32, bool) { - if o == nil || IsNil(o.AvailableStacks) { - return nil, false - } - return o.AvailableStacks, true -} - -// HasAvailableStacks returns a boolean if a field has been set. -func (o *Organization) HasAvailableStacks() bool { - if o != nil && !IsNil(o.AvailableStacks) { - return true - } - - return false -} - -// SetAvailableStacks gets a reference to the given int32 and assigns it to the AvailableStacks field. -func (o *Organization) SetAvailableStacks(v int32) { - o.AvailableStacks = &v -} - -// GetAvailableSandboxes returns the AvailableSandboxes field value if set, zero value otherwise. -func (o *Organization) GetAvailableSandboxes() int32 { - if o == nil || IsNil(o.AvailableSandboxes) { - var ret int32 - return ret - } - return *o.AvailableSandboxes -} - -// GetAvailableSandboxesOk returns a tuple with the AvailableSandboxes field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Organization) GetAvailableSandboxesOk() (*int32, bool) { - if o == nil || IsNil(o.AvailableSandboxes) { - return nil, false - } - return o.AvailableSandboxes, true -} - -// HasAvailableSandboxes returns a boolean if a field has been set. -func (o *Organization) HasAvailableSandboxes() bool { - if o != nil && !IsNil(o.AvailableSandboxes) { - return true - } - - return false -} - -// SetAvailableSandboxes gets a reference to the given int32 and assigns it to the AvailableSandboxes field. -func (o *Organization) SetAvailableSandboxes(v int32) { - o.AvailableSandboxes = &v -} - -// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise. -func (o *Organization) GetCreatedAt() time.Time { - if o == nil || IsNil(o.CreatedAt) { - var ret time.Time - return ret - } - return *o.CreatedAt -} - -// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Organization) GetCreatedAtOk() (*time.Time, bool) { - if o == nil || IsNil(o.CreatedAt) { - return nil, false - } - return o.CreatedAt, true -} - -// HasCreatedAt returns a boolean if a field has been set. -func (o *Organization) HasCreatedAt() bool { - if o != nil && !IsNil(o.CreatedAt) { - return true - } - - return false -} - -// SetCreatedAt gets a reference to the given time.Time and assigns it to the CreatedAt field. -func (o *Organization) SetCreatedAt(v time.Time) { - o.CreatedAt = &v -} - -// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise. -func (o *Organization) GetUpdatedAt() time.Time { - if o == nil || IsNil(o.UpdatedAt) { - var ret time.Time - return ret - } - return *o.UpdatedAt -} - -// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Organization) GetUpdatedAtOk() (*time.Time, bool) { - if o == nil || IsNil(o.UpdatedAt) { - return nil, false - } - return o.UpdatedAt, true -} - -// HasUpdatedAt returns a boolean if a field has been set. -func (o *Organization) HasUpdatedAt() bool { - if o != nil && !IsNil(o.UpdatedAt) { - return true - } - - return false -} - -// SetUpdatedAt gets a reference to the given time.Time and assigns it to the UpdatedAt field. -func (o *Organization) SetUpdatedAt(v time.Time) { - o.UpdatedAt = &v -} - -func (o Organization) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o Organization) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["name"] = o.Name - if !IsNil(o.DefaultOrganizationAccess) { - toSerialize["defaultOrganizationAccess"] = o.DefaultOrganizationAccess - } - if !IsNil(o.DefaultStackAccess) { - toSerialize["defaultStackAccess"] = o.DefaultStackAccess - } - if !IsNil(o.Domain) { - toSerialize["domain"] = o.Domain - } - toSerialize["id"] = o.Id - toSerialize["ownerId"] = o.OwnerId - if !IsNil(o.AvailableStacks) { - toSerialize["availableStacks"] = o.AvailableStacks - } - if !IsNil(o.AvailableSandboxes) { - toSerialize["availableSandboxes"] = o.AvailableSandboxes - } - if !IsNil(o.CreatedAt) { - toSerialize["createdAt"] = o.CreatedAt - } - if !IsNil(o.UpdatedAt) { - toSerialize["updatedAt"] = o.UpdatedAt - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *Organization) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "name", - "id", - "ownerId", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varOrganization := _Organization{} - - err = json.Unmarshal(data, &varOrganization) - - if err != nil { - return err - } - - *o = Organization(varOrganization) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "name") - delete(additionalProperties, "defaultOrganizationAccess") - delete(additionalProperties, "defaultStackAccess") - delete(additionalProperties, "domain") - delete(additionalProperties, "id") - delete(additionalProperties, "ownerId") - delete(additionalProperties, "availableStacks") - delete(additionalProperties, "availableSandboxes") - delete(additionalProperties, "createdAt") - delete(additionalProperties, "updatedAt") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableOrganization struct { - value *Organization - isSet bool -} - -func (v NullableOrganization) Get() *Organization { - return v.value -} - -func (v *NullableOrganization) Set(val *Organization) { - v.value = val - v.isSet = true -} - -func (v NullableOrganization) IsSet() bool { - return v.isSet -} - -func (v *NullableOrganization) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableOrganization(val *Organization) *NullableOrganization { - return &NullableOrganization{value: val, isSet: true} -} - -func (v NullableOrganization) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableOrganization) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_organization_client.go b/membershipclient/model_organization_client.go deleted file mode 100644 index 303a1736..00000000 --- a/membershipclient/model_organization_client.go +++ /dev/null @@ -1,317 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "time" - "fmt" -) - -// checks if the OrganizationClient type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &OrganizationClient{} - -// OrganizationClient struct for OrganizationClient -type OrganizationClient struct { - // Organization ID - Id string `json:"id"` - Secret OrganizationClientSecret `json:"secret"` - // Name of the client - Name string `json:"name"` - // Description of the client - Description string `json:"description"` - CreatedAt time.Time `json:"createdAt"` - UpdatedAt time.Time `json:"updatedAt"` - AdditionalProperties map[string]interface{} -} - -type _OrganizationClient OrganizationClient - -// NewOrganizationClient instantiates a new OrganizationClient object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewOrganizationClient(id string, secret OrganizationClientSecret, name string, description string, createdAt time.Time, updatedAt time.Time) *OrganizationClient { - this := OrganizationClient{} - this.Id = id - this.Secret = secret - this.Name = name - this.Description = description - this.CreatedAt = createdAt - this.UpdatedAt = updatedAt - return &this -} - -// NewOrganizationClientWithDefaults instantiates a new OrganizationClient object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewOrganizationClientWithDefaults() *OrganizationClient { - this := OrganizationClient{} - return &this -} - -// GetId returns the Id field value -func (o *OrganizationClient) GetId() string { - if o == nil { - var ret string - return ret - } - - return o.Id -} - -// GetIdOk returns a tuple with the Id field value -// and a boolean to check if the value has been set. -func (o *OrganizationClient) GetIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Id, true -} - -// SetId sets field value -func (o *OrganizationClient) SetId(v string) { - o.Id = v -} - -// GetSecret returns the Secret field value -func (o *OrganizationClient) GetSecret() OrganizationClientSecret { - if o == nil { - var ret OrganizationClientSecret - return ret - } - - return o.Secret -} - -// GetSecretOk returns a tuple with the Secret field value -// and a boolean to check if the value has been set. -func (o *OrganizationClient) GetSecretOk() (*OrganizationClientSecret, bool) { - if o == nil { - return nil, false - } - return &o.Secret, true -} - -// SetSecret sets field value -func (o *OrganizationClient) SetSecret(v OrganizationClientSecret) { - o.Secret = v -} - -// GetName returns the Name field value -func (o *OrganizationClient) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *OrganizationClient) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *OrganizationClient) SetName(v string) { - o.Name = v -} - -// GetDescription returns the Description field value -func (o *OrganizationClient) GetDescription() string { - if o == nil { - var ret string - return ret - } - - return o.Description -} - -// GetDescriptionOk returns a tuple with the Description field value -// and a boolean to check if the value has been set. -func (o *OrganizationClient) GetDescriptionOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Description, true -} - -// SetDescription sets field value -func (o *OrganizationClient) SetDescription(v string) { - o.Description = v -} - -// GetCreatedAt returns the CreatedAt field value -func (o *OrganizationClient) GetCreatedAt() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.CreatedAt -} - -// GetCreatedAtOk returns a tuple with the CreatedAt field value -// and a boolean to check if the value has been set. -func (o *OrganizationClient) GetCreatedAtOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.CreatedAt, true -} - -// SetCreatedAt sets field value -func (o *OrganizationClient) SetCreatedAt(v time.Time) { - o.CreatedAt = v -} - -// GetUpdatedAt returns the UpdatedAt field value -func (o *OrganizationClient) GetUpdatedAt() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.UpdatedAt -} - -// GetUpdatedAtOk returns a tuple with the UpdatedAt field value -// and a boolean to check if the value has been set. -func (o *OrganizationClient) GetUpdatedAtOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.UpdatedAt, true -} - -// SetUpdatedAt sets field value -func (o *OrganizationClient) SetUpdatedAt(v time.Time) { - o.UpdatedAt = v -} - -func (o OrganizationClient) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o OrganizationClient) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["id"] = o.Id - toSerialize["secret"] = o.Secret - toSerialize["name"] = o.Name - toSerialize["description"] = o.Description - toSerialize["createdAt"] = o.CreatedAt - toSerialize["updatedAt"] = o.UpdatedAt - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *OrganizationClient) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "id", - "secret", - "name", - "description", - "createdAt", - "updatedAt", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varOrganizationClient := _OrganizationClient{} - - err = json.Unmarshal(data, &varOrganizationClient) - - if err != nil { - return err - } - - *o = OrganizationClient(varOrganizationClient) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "id") - delete(additionalProperties, "secret") - delete(additionalProperties, "name") - delete(additionalProperties, "description") - delete(additionalProperties, "createdAt") - delete(additionalProperties, "updatedAt") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableOrganizationClient struct { - value *OrganizationClient - isSet bool -} - -func (v NullableOrganizationClient) Get() *OrganizationClient { - return v.value -} - -func (v *NullableOrganizationClient) Set(val *OrganizationClient) { - v.value = val - v.isSet = true -} - -func (v NullableOrganizationClient) IsSet() bool { - return v.isSet -} - -func (v *NullableOrganizationClient) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableOrganizationClient(val *OrganizationClient) *NullableOrganizationClient { - return &NullableOrganizationClient{value: val, isSet: true} -} - -func (v NullableOrganizationClient) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableOrganizationClient) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_organization_client_secret.go b/membershipclient/model_organization_client_secret.go deleted file mode 100644 index 598cd93c..00000000 --- a/membershipclient/model_organization_client_secret.go +++ /dev/null @@ -1,205 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the OrganizationClientSecret type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &OrganizationClientSecret{} - -// OrganizationClientSecret struct for OrganizationClientSecret -type OrganizationClientSecret struct { - LastDigits string `json:"lastDigits"` - Clear *string `json:"clear,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _OrganizationClientSecret OrganizationClientSecret - -// NewOrganizationClientSecret instantiates a new OrganizationClientSecret object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewOrganizationClientSecret(lastDigits string) *OrganizationClientSecret { - this := OrganizationClientSecret{} - this.LastDigits = lastDigits - return &this -} - -// NewOrganizationClientSecretWithDefaults instantiates a new OrganizationClientSecret object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewOrganizationClientSecretWithDefaults() *OrganizationClientSecret { - this := OrganizationClientSecret{} - return &this -} - -// GetLastDigits returns the LastDigits field value -func (o *OrganizationClientSecret) GetLastDigits() string { - if o == nil { - var ret string - return ret - } - - return o.LastDigits -} - -// GetLastDigitsOk returns a tuple with the LastDigits field value -// and a boolean to check if the value has been set. -func (o *OrganizationClientSecret) GetLastDigitsOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.LastDigits, true -} - -// SetLastDigits sets field value -func (o *OrganizationClientSecret) SetLastDigits(v string) { - o.LastDigits = v -} - -// GetClear returns the Clear field value if set, zero value otherwise. -func (o *OrganizationClientSecret) GetClear() string { - if o == nil || IsNil(o.Clear) { - var ret string - return ret - } - return *o.Clear -} - -// GetClearOk returns a tuple with the Clear field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *OrganizationClientSecret) GetClearOk() (*string, bool) { - if o == nil || IsNil(o.Clear) { - return nil, false - } - return o.Clear, true -} - -// HasClear returns a boolean if a field has been set. -func (o *OrganizationClientSecret) HasClear() bool { - if o != nil && !IsNil(o.Clear) { - return true - } - - return false -} - -// SetClear gets a reference to the given string and assigns it to the Clear field. -func (o *OrganizationClientSecret) SetClear(v string) { - o.Clear = &v -} - -func (o OrganizationClientSecret) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o OrganizationClientSecret) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["lastDigits"] = o.LastDigits - if !IsNil(o.Clear) { - toSerialize["clear"] = o.Clear - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *OrganizationClientSecret) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "lastDigits", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varOrganizationClientSecret := _OrganizationClientSecret{} - - err = json.Unmarshal(data, &varOrganizationClientSecret) - - if err != nil { - return err - } - - *o = OrganizationClientSecret(varOrganizationClientSecret) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "lastDigits") - delete(additionalProperties, "clear") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableOrganizationClientSecret struct { - value *OrganizationClientSecret - isSet bool -} - -func (v NullableOrganizationClientSecret) Get() *OrganizationClientSecret { - return v.value -} - -func (v *NullableOrganizationClientSecret) Set(val *OrganizationClientSecret) { - v.value = val - v.isSet = true -} - -func (v NullableOrganizationClientSecret) IsSet() bool { - return v.isSet -} - -func (v *NullableOrganizationClientSecret) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableOrganizationClientSecret(val *OrganizationClientSecret) *NullableOrganizationClientSecret { - return &NullableOrganizationClientSecret{value: val, isSet: true} -} - -func (v NullableOrganizationClientSecret) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableOrganizationClientSecret) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_organization_data.go b/membershipclient/model_organization_data.go deleted file mode 100644 index f961f6b7..00000000 --- a/membershipclient/model_organization_data.go +++ /dev/null @@ -1,281 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the OrganizationData type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &OrganizationData{} - -// OrganizationData struct for OrganizationData -type OrganizationData struct { - // Organization name - Name string `json:"name"` - DefaultOrganizationAccess *Role `json:"defaultOrganizationAccess,omitempty"` - DefaultStackAccess *Role `json:"defaultStackAccess,omitempty"` - // Organization domain - Domain *string `json:"domain,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _OrganizationData OrganizationData - -// NewOrganizationData instantiates a new OrganizationData object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewOrganizationData(name string) *OrganizationData { - this := OrganizationData{} - this.Name = name - return &this -} - -// NewOrganizationDataWithDefaults instantiates a new OrganizationData object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewOrganizationDataWithDefaults() *OrganizationData { - this := OrganizationData{} - return &this -} - -// GetName returns the Name field value -func (o *OrganizationData) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *OrganizationData) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *OrganizationData) SetName(v string) { - o.Name = v -} - -// GetDefaultOrganizationAccess returns the DefaultOrganizationAccess field value if set, zero value otherwise. -func (o *OrganizationData) GetDefaultOrganizationAccess() Role { - if o == nil || IsNil(o.DefaultOrganizationAccess) { - var ret Role - return ret - } - return *o.DefaultOrganizationAccess -} - -// GetDefaultOrganizationAccessOk returns a tuple with the DefaultOrganizationAccess field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *OrganizationData) GetDefaultOrganizationAccessOk() (*Role, bool) { - if o == nil || IsNil(o.DefaultOrganizationAccess) { - return nil, false - } - return o.DefaultOrganizationAccess, true -} - -// HasDefaultOrganizationAccess returns a boolean if a field has been set. -func (o *OrganizationData) HasDefaultOrganizationAccess() bool { - if o != nil && !IsNil(o.DefaultOrganizationAccess) { - return true - } - - return false -} - -// SetDefaultOrganizationAccess gets a reference to the given Role and assigns it to the DefaultOrganizationAccess field. -func (o *OrganizationData) SetDefaultOrganizationAccess(v Role) { - o.DefaultOrganizationAccess = &v -} - -// GetDefaultStackAccess returns the DefaultStackAccess field value if set, zero value otherwise. -func (o *OrganizationData) GetDefaultStackAccess() Role { - if o == nil || IsNil(o.DefaultStackAccess) { - var ret Role - return ret - } - return *o.DefaultStackAccess -} - -// GetDefaultStackAccessOk returns a tuple with the DefaultStackAccess field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *OrganizationData) GetDefaultStackAccessOk() (*Role, bool) { - if o == nil || IsNil(o.DefaultStackAccess) { - return nil, false - } - return o.DefaultStackAccess, true -} - -// HasDefaultStackAccess returns a boolean if a field has been set. -func (o *OrganizationData) HasDefaultStackAccess() bool { - if o != nil && !IsNil(o.DefaultStackAccess) { - return true - } - - return false -} - -// SetDefaultStackAccess gets a reference to the given Role and assigns it to the DefaultStackAccess field. -func (o *OrganizationData) SetDefaultStackAccess(v Role) { - o.DefaultStackAccess = &v -} - -// GetDomain returns the Domain field value if set, zero value otherwise. -func (o *OrganizationData) GetDomain() string { - if o == nil || IsNil(o.Domain) { - var ret string - return ret - } - return *o.Domain -} - -// GetDomainOk returns a tuple with the Domain field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *OrganizationData) GetDomainOk() (*string, bool) { - if o == nil || IsNil(o.Domain) { - return nil, false - } - return o.Domain, true -} - -// HasDomain returns a boolean if a field has been set. -func (o *OrganizationData) HasDomain() bool { - if o != nil && !IsNil(o.Domain) { - return true - } - - return false -} - -// SetDomain gets a reference to the given string and assigns it to the Domain field. -func (o *OrganizationData) SetDomain(v string) { - o.Domain = &v -} - -func (o OrganizationData) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o OrganizationData) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["name"] = o.Name - if !IsNil(o.DefaultOrganizationAccess) { - toSerialize["defaultOrganizationAccess"] = o.DefaultOrganizationAccess - } - if !IsNil(o.DefaultStackAccess) { - toSerialize["defaultStackAccess"] = o.DefaultStackAccess - } - if !IsNil(o.Domain) { - toSerialize["domain"] = o.Domain - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *OrganizationData) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "name", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varOrganizationData := _OrganizationData{} - - err = json.Unmarshal(data, &varOrganizationData) - - if err != nil { - return err - } - - *o = OrganizationData(varOrganizationData) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "name") - delete(additionalProperties, "defaultOrganizationAccess") - delete(additionalProperties, "defaultStackAccess") - delete(additionalProperties, "domain") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableOrganizationData struct { - value *OrganizationData - isSet bool -} - -func (v NullableOrganizationData) Get() *OrganizationData { - return v.value -} - -func (v *NullableOrganizationData) Set(val *OrganizationData) { - v.value = val - v.isSet = true -} - -func (v NullableOrganizationData) IsSet() bool { - return v.isSet -} - -func (v *NullableOrganizationData) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableOrganizationData(val *OrganizationData) *NullableOrganizationData { - return &NullableOrganizationData{value: val, isSet: true} -} - -func (v NullableOrganizationData) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableOrganizationData) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_organization_expanded.go b/membershipclient/model_organization_expanded.go deleted file mode 100644 index fded5800..00000000 --- a/membershipclient/model_organization_expanded.go +++ /dev/null @@ -1,603 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "time" - "fmt" -) - -// checks if the OrganizationExpanded type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &OrganizationExpanded{} - -// OrganizationExpanded struct for OrganizationExpanded -type OrganizationExpanded struct { - // Organization name - Name string `json:"name"` - DefaultOrganizationAccess *Role `json:"defaultOrganizationAccess,omitempty"` - DefaultStackAccess *Role `json:"defaultStackAccess,omitempty"` - // Organization domain - Domain *string `json:"domain,omitempty"` - // Organization ID - Id string `json:"id"` - // Owner ID - OwnerId string `json:"ownerId"` - // Number of available stacks - AvailableStacks *int32 `json:"availableStacks,omitempty"` - // Number of available sandboxes - AvailableSandboxes *int32 `json:"availableSandboxes,omitempty"` - CreatedAt *time.Time `json:"createdAt,omitempty"` - UpdatedAt *time.Time `json:"updatedAt,omitempty"` - TotalStacks *int32 `json:"totalStacks,omitempty"` - TotalUsers *int32 `json:"totalUsers,omitempty"` - Owner *User `json:"owner,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _OrganizationExpanded OrganizationExpanded - -// NewOrganizationExpanded instantiates a new OrganizationExpanded object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewOrganizationExpanded(name string, id string, ownerId string) *OrganizationExpanded { - this := OrganizationExpanded{} - this.Name = name - this.Id = id - this.OwnerId = ownerId - return &this -} - -// NewOrganizationExpandedWithDefaults instantiates a new OrganizationExpanded object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewOrganizationExpandedWithDefaults() *OrganizationExpanded { - this := OrganizationExpanded{} - return &this -} - -// GetName returns the Name field value -func (o *OrganizationExpanded) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *OrganizationExpanded) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *OrganizationExpanded) SetName(v string) { - o.Name = v -} - -// GetDefaultOrganizationAccess returns the DefaultOrganizationAccess field value if set, zero value otherwise. -func (o *OrganizationExpanded) GetDefaultOrganizationAccess() Role { - if o == nil || IsNil(o.DefaultOrganizationAccess) { - var ret Role - return ret - } - return *o.DefaultOrganizationAccess -} - -// GetDefaultOrganizationAccessOk returns a tuple with the DefaultOrganizationAccess field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *OrganizationExpanded) GetDefaultOrganizationAccessOk() (*Role, bool) { - if o == nil || IsNil(o.DefaultOrganizationAccess) { - return nil, false - } - return o.DefaultOrganizationAccess, true -} - -// HasDefaultOrganizationAccess returns a boolean if a field has been set. -func (o *OrganizationExpanded) HasDefaultOrganizationAccess() bool { - if o != nil && !IsNil(o.DefaultOrganizationAccess) { - return true - } - - return false -} - -// SetDefaultOrganizationAccess gets a reference to the given Role and assigns it to the DefaultOrganizationAccess field. -func (o *OrganizationExpanded) SetDefaultOrganizationAccess(v Role) { - o.DefaultOrganizationAccess = &v -} - -// GetDefaultStackAccess returns the DefaultStackAccess field value if set, zero value otherwise. -func (o *OrganizationExpanded) GetDefaultStackAccess() Role { - if o == nil || IsNil(o.DefaultStackAccess) { - var ret Role - return ret - } - return *o.DefaultStackAccess -} - -// GetDefaultStackAccessOk returns a tuple with the DefaultStackAccess field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *OrganizationExpanded) GetDefaultStackAccessOk() (*Role, bool) { - if o == nil || IsNil(o.DefaultStackAccess) { - return nil, false - } - return o.DefaultStackAccess, true -} - -// HasDefaultStackAccess returns a boolean if a field has been set. -func (o *OrganizationExpanded) HasDefaultStackAccess() bool { - if o != nil && !IsNil(o.DefaultStackAccess) { - return true - } - - return false -} - -// SetDefaultStackAccess gets a reference to the given Role and assigns it to the DefaultStackAccess field. -func (o *OrganizationExpanded) SetDefaultStackAccess(v Role) { - o.DefaultStackAccess = &v -} - -// GetDomain returns the Domain field value if set, zero value otherwise. -func (o *OrganizationExpanded) GetDomain() string { - if o == nil || IsNil(o.Domain) { - var ret string - return ret - } - return *o.Domain -} - -// GetDomainOk returns a tuple with the Domain field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *OrganizationExpanded) GetDomainOk() (*string, bool) { - if o == nil || IsNil(o.Domain) { - return nil, false - } - return o.Domain, true -} - -// HasDomain returns a boolean if a field has been set. -func (o *OrganizationExpanded) HasDomain() bool { - if o != nil && !IsNil(o.Domain) { - return true - } - - return false -} - -// SetDomain gets a reference to the given string and assigns it to the Domain field. -func (o *OrganizationExpanded) SetDomain(v string) { - o.Domain = &v -} - -// GetId returns the Id field value -func (o *OrganizationExpanded) GetId() string { - if o == nil { - var ret string - return ret - } - - return o.Id -} - -// GetIdOk returns a tuple with the Id field value -// and a boolean to check if the value has been set. -func (o *OrganizationExpanded) GetIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Id, true -} - -// SetId sets field value -func (o *OrganizationExpanded) SetId(v string) { - o.Id = v -} - -// GetOwnerId returns the OwnerId field value -func (o *OrganizationExpanded) GetOwnerId() string { - if o == nil { - var ret string - return ret - } - - return o.OwnerId -} - -// GetOwnerIdOk returns a tuple with the OwnerId field value -// and a boolean to check if the value has been set. -func (o *OrganizationExpanded) GetOwnerIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.OwnerId, true -} - -// SetOwnerId sets field value -func (o *OrganizationExpanded) SetOwnerId(v string) { - o.OwnerId = v -} - -// GetAvailableStacks returns the AvailableStacks field value if set, zero value otherwise. -func (o *OrganizationExpanded) GetAvailableStacks() int32 { - if o == nil || IsNil(o.AvailableStacks) { - var ret int32 - return ret - } - return *o.AvailableStacks -} - -// GetAvailableStacksOk returns a tuple with the AvailableStacks field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *OrganizationExpanded) GetAvailableStacksOk() (*int32, bool) { - if o == nil || IsNil(o.AvailableStacks) { - return nil, false - } - return o.AvailableStacks, true -} - -// HasAvailableStacks returns a boolean if a field has been set. -func (o *OrganizationExpanded) HasAvailableStacks() bool { - if o != nil && !IsNil(o.AvailableStacks) { - return true - } - - return false -} - -// SetAvailableStacks gets a reference to the given int32 and assigns it to the AvailableStacks field. -func (o *OrganizationExpanded) SetAvailableStacks(v int32) { - o.AvailableStacks = &v -} - -// GetAvailableSandboxes returns the AvailableSandboxes field value if set, zero value otherwise. -func (o *OrganizationExpanded) GetAvailableSandboxes() int32 { - if o == nil || IsNil(o.AvailableSandboxes) { - var ret int32 - return ret - } - return *o.AvailableSandboxes -} - -// GetAvailableSandboxesOk returns a tuple with the AvailableSandboxes field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *OrganizationExpanded) GetAvailableSandboxesOk() (*int32, bool) { - if o == nil || IsNil(o.AvailableSandboxes) { - return nil, false - } - return o.AvailableSandboxes, true -} - -// HasAvailableSandboxes returns a boolean if a field has been set. -func (o *OrganizationExpanded) HasAvailableSandboxes() bool { - if o != nil && !IsNil(o.AvailableSandboxes) { - return true - } - - return false -} - -// SetAvailableSandboxes gets a reference to the given int32 and assigns it to the AvailableSandboxes field. -func (o *OrganizationExpanded) SetAvailableSandboxes(v int32) { - o.AvailableSandboxes = &v -} - -// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise. -func (o *OrganizationExpanded) GetCreatedAt() time.Time { - if o == nil || IsNil(o.CreatedAt) { - var ret time.Time - return ret - } - return *o.CreatedAt -} - -// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *OrganizationExpanded) GetCreatedAtOk() (*time.Time, bool) { - if o == nil || IsNil(o.CreatedAt) { - return nil, false - } - return o.CreatedAt, true -} - -// HasCreatedAt returns a boolean if a field has been set. -func (o *OrganizationExpanded) HasCreatedAt() bool { - if o != nil && !IsNil(o.CreatedAt) { - return true - } - - return false -} - -// SetCreatedAt gets a reference to the given time.Time and assigns it to the CreatedAt field. -func (o *OrganizationExpanded) SetCreatedAt(v time.Time) { - o.CreatedAt = &v -} - -// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise. -func (o *OrganizationExpanded) GetUpdatedAt() time.Time { - if o == nil || IsNil(o.UpdatedAt) { - var ret time.Time - return ret - } - return *o.UpdatedAt -} - -// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *OrganizationExpanded) GetUpdatedAtOk() (*time.Time, bool) { - if o == nil || IsNil(o.UpdatedAt) { - return nil, false - } - return o.UpdatedAt, true -} - -// HasUpdatedAt returns a boolean if a field has been set. -func (o *OrganizationExpanded) HasUpdatedAt() bool { - if o != nil && !IsNil(o.UpdatedAt) { - return true - } - - return false -} - -// SetUpdatedAt gets a reference to the given time.Time and assigns it to the UpdatedAt field. -func (o *OrganizationExpanded) SetUpdatedAt(v time.Time) { - o.UpdatedAt = &v -} - -// GetTotalStacks returns the TotalStacks field value if set, zero value otherwise. -func (o *OrganizationExpanded) GetTotalStacks() int32 { - if o == nil || IsNil(o.TotalStacks) { - var ret int32 - return ret - } - return *o.TotalStacks -} - -// GetTotalStacksOk returns a tuple with the TotalStacks field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *OrganizationExpanded) GetTotalStacksOk() (*int32, bool) { - if o == nil || IsNil(o.TotalStacks) { - return nil, false - } - return o.TotalStacks, true -} - -// HasTotalStacks returns a boolean if a field has been set. -func (o *OrganizationExpanded) HasTotalStacks() bool { - if o != nil && !IsNil(o.TotalStacks) { - return true - } - - return false -} - -// SetTotalStacks gets a reference to the given int32 and assigns it to the TotalStacks field. -func (o *OrganizationExpanded) SetTotalStacks(v int32) { - o.TotalStacks = &v -} - -// GetTotalUsers returns the TotalUsers field value if set, zero value otherwise. -func (o *OrganizationExpanded) GetTotalUsers() int32 { - if o == nil || IsNil(o.TotalUsers) { - var ret int32 - return ret - } - return *o.TotalUsers -} - -// GetTotalUsersOk returns a tuple with the TotalUsers field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *OrganizationExpanded) GetTotalUsersOk() (*int32, bool) { - if o == nil || IsNil(o.TotalUsers) { - return nil, false - } - return o.TotalUsers, true -} - -// HasTotalUsers returns a boolean if a field has been set. -func (o *OrganizationExpanded) HasTotalUsers() bool { - if o != nil && !IsNil(o.TotalUsers) { - return true - } - - return false -} - -// SetTotalUsers gets a reference to the given int32 and assigns it to the TotalUsers field. -func (o *OrganizationExpanded) SetTotalUsers(v int32) { - o.TotalUsers = &v -} - -// GetOwner returns the Owner field value if set, zero value otherwise. -func (o *OrganizationExpanded) GetOwner() User { - if o == nil || IsNil(o.Owner) { - var ret User - return ret - } - return *o.Owner -} - -// GetOwnerOk returns a tuple with the Owner field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *OrganizationExpanded) GetOwnerOk() (*User, bool) { - if o == nil || IsNil(o.Owner) { - return nil, false - } - return o.Owner, true -} - -// HasOwner returns a boolean if a field has been set. -func (o *OrganizationExpanded) HasOwner() bool { - if o != nil && !IsNil(o.Owner) { - return true - } - - return false -} - -// SetOwner gets a reference to the given User and assigns it to the Owner field. -func (o *OrganizationExpanded) SetOwner(v User) { - o.Owner = &v -} - -func (o OrganizationExpanded) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o OrganizationExpanded) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["name"] = o.Name - if !IsNil(o.DefaultOrganizationAccess) { - toSerialize["defaultOrganizationAccess"] = o.DefaultOrganizationAccess - } - if !IsNil(o.DefaultStackAccess) { - toSerialize["defaultStackAccess"] = o.DefaultStackAccess - } - if !IsNil(o.Domain) { - toSerialize["domain"] = o.Domain - } - toSerialize["id"] = o.Id - toSerialize["ownerId"] = o.OwnerId - if !IsNil(o.AvailableStacks) { - toSerialize["availableStacks"] = o.AvailableStacks - } - if !IsNil(o.AvailableSandboxes) { - toSerialize["availableSandboxes"] = o.AvailableSandboxes - } - if !IsNil(o.CreatedAt) { - toSerialize["createdAt"] = o.CreatedAt - } - if !IsNil(o.UpdatedAt) { - toSerialize["updatedAt"] = o.UpdatedAt - } - if !IsNil(o.TotalStacks) { - toSerialize["totalStacks"] = o.TotalStacks - } - if !IsNil(o.TotalUsers) { - toSerialize["totalUsers"] = o.TotalUsers - } - if !IsNil(o.Owner) { - toSerialize["owner"] = o.Owner - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *OrganizationExpanded) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "name", - "id", - "ownerId", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varOrganizationExpanded := _OrganizationExpanded{} - - err = json.Unmarshal(data, &varOrganizationExpanded) - - if err != nil { - return err - } - - *o = OrganizationExpanded(varOrganizationExpanded) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "name") - delete(additionalProperties, "defaultOrganizationAccess") - delete(additionalProperties, "defaultStackAccess") - delete(additionalProperties, "domain") - delete(additionalProperties, "id") - delete(additionalProperties, "ownerId") - delete(additionalProperties, "availableStacks") - delete(additionalProperties, "availableSandboxes") - delete(additionalProperties, "createdAt") - delete(additionalProperties, "updatedAt") - delete(additionalProperties, "totalStacks") - delete(additionalProperties, "totalUsers") - delete(additionalProperties, "owner") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableOrganizationExpanded struct { - value *OrganizationExpanded - isSet bool -} - -func (v NullableOrganizationExpanded) Get() *OrganizationExpanded { - return v.value -} - -func (v *NullableOrganizationExpanded) Set(val *OrganizationExpanded) { - v.value = val - v.isSet = true -} - -func (v NullableOrganizationExpanded) IsSet() bool { - return v.isSet -} - -func (v *NullableOrganizationExpanded) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableOrganizationExpanded(val *OrganizationExpanded) *NullableOrganizationExpanded { - return &NullableOrganizationExpanded{value: val, isSet: true} -} - -func (v NullableOrganizationExpanded) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableOrganizationExpanded) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_organization_feature.go b/membershipclient/model_organization_feature.go deleted file mode 100644 index 3a5b38c3..00000000 --- a/membershipclient/model_organization_feature.go +++ /dev/null @@ -1,227 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "time" - "fmt" -) - -// checks if the OrganizationFeature type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &OrganizationFeature{} - -// OrganizationFeature struct for OrganizationFeature -type OrganizationFeature struct { - OrganizationID string `json:"organizationID"` - Name string `json:"name"` - CreatedAt time.Time `json:"createdAt"` - AdditionalProperties map[string]interface{} -} - -type _OrganizationFeature OrganizationFeature - -// NewOrganizationFeature instantiates a new OrganizationFeature object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewOrganizationFeature(organizationID string, name string, createdAt time.Time) *OrganizationFeature { - this := OrganizationFeature{} - this.OrganizationID = organizationID - this.Name = name - this.CreatedAt = createdAt - return &this -} - -// NewOrganizationFeatureWithDefaults instantiates a new OrganizationFeature object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewOrganizationFeatureWithDefaults() *OrganizationFeature { - this := OrganizationFeature{} - return &this -} - -// GetOrganizationID returns the OrganizationID field value -func (o *OrganizationFeature) GetOrganizationID() string { - if o == nil { - var ret string - return ret - } - - return o.OrganizationID -} - -// GetOrganizationIDOk returns a tuple with the OrganizationID field value -// and a boolean to check if the value has been set. -func (o *OrganizationFeature) GetOrganizationIDOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.OrganizationID, true -} - -// SetOrganizationID sets field value -func (o *OrganizationFeature) SetOrganizationID(v string) { - o.OrganizationID = v -} - -// GetName returns the Name field value -func (o *OrganizationFeature) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *OrganizationFeature) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *OrganizationFeature) SetName(v string) { - o.Name = v -} - -// GetCreatedAt returns the CreatedAt field value -func (o *OrganizationFeature) GetCreatedAt() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.CreatedAt -} - -// GetCreatedAtOk returns a tuple with the CreatedAt field value -// and a boolean to check if the value has been set. -func (o *OrganizationFeature) GetCreatedAtOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.CreatedAt, true -} - -// SetCreatedAt sets field value -func (o *OrganizationFeature) SetCreatedAt(v time.Time) { - o.CreatedAt = v -} - -func (o OrganizationFeature) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o OrganizationFeature) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["organizationID"] = o.OrganizationID - toSerialize["name"] = o.Name - toSerialize["createdAt"] = o.CreatedAt - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *OrganizationFeature) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "organizationID", - "name", - "createdAt", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varOrganizationFeature := _OrganizationFeature{} - - err = json.Unmarshal(data, &varOrganizationFeature) - - if err != nil { - return err - } - - *o = OrganizationFeature(varOrganizationFeature) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "organizationID") - delete(additionalProperties, "name") - delete(additionalProperties, "createdAt") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableOrganizationFeature struct { - value *OrganizationFeature - isSet bool -} - -func (v NullableOrganizationFeature) Get() *OrganizationFeature { - return v.value -} - -func (v *NullableOrganizationFeature) Set(val *OrganizationFeature) { - v.value = val - v.isSet = true -} - -func (v NullableOrganizationFeature) IsSet() bool { - return v.isSet -} - -func (v *NullableOrganizationFeature) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableOrganizationFeature(val *OrganizationFeature) *NullableOrganizationFeature { - return &NullableOrganizationFeature{value: val, isSet: true} -} - -func (v NullableOrganizationFeature) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableOrganizationFeature) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_organization_user.go b/membershipclient/model_organization_user.go deleted file mode 100644 index eeb1bb9d..00000000 --- a/membershipclient/model_organization_user.go +++ /dev/null @@ -1,226 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the OrganizationUser type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &OrganizationUser{} - -// OrganizationUser struct for OrganizationUser -type OrganizationUser struct { - Role Role `json:"role"` - Email string `json:"email"` - Id string `json:"id"` - AdditionalProperties map[string]interface{} -} - -type _OrganizationUser OrganizationUser - -// NewOrganizationUser instantiates a new OrganizationUser object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewOrganizationUser(role Role, email string, id string) *OrganizationUser { - this := OrganizationUser{} - this.Role = role - this.Email = email - this.Id = id - return &this -} - -// NewOrganizationUserWithDefaults instantiates a new OrganizationUser object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewOrganizationUserWithDefaults() *OrganizationUser { - this := OrganizationUser{} - return &this -} - -// GetRole returns the Role field value -func (o *OrganizationUser) GetRole() Role { - if o == nil { - var ret Role - return ret - } - - return o.Role -} - -// GetRoleOk returns a tuple with the Role field value -// and a boolean to check if the value has been set. -func (o *OrganizationUser) GetRoleOk() (*Role, bool) { - if o == nil { - return nil, false - } - return &o.Role, true -} - -// SetRole sets field value -func (o *OrganizationUser) SetRole(v Role) { - o.Role = v -} - -// GetEmail returns the Email field value -func (o *OrganizationUser) GetEmail() string { - if o == nil { - var ret string - return ret - } - - return o.Email -} - -// GetEmailOk returns a tuple with the Email field value -// and a boolean to check if the value has been set. -func (o *OrganizationUser) GetEmailOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Email, true -} - -// SetEmail sets field value -func (o *OrganizationUser) SetEmail(v string) { - o.Email = v -} - -// GetId returns the Id field value -func (o *OrganizationUser) GetId() string { - if o == nil { - var ret string - return ret - } - - return o.Id -} - -// GetIdOk returns a tuple with the Id field value -// and a boolean to check if the value has been set. -func (o *OrganizationUser) GetIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Id, true -} - -// SetId sets field value -func (o *OrganizationUser) SetId(v string) { - o.Id = v -} - -func (o OrganizationUser) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o OrganizationUser) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["role"] = o.Role - toSerialize["email"] = o.Email - toSerialize["id"] = o.Id - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *OrganizationUser) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "role", - "email", - "id", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varOrganizationUser := _OrganizationUser{} - - err = json.Unmarshal(data, &varOrganizationUser) - - if err != nil { - return err - } - - *o = OrganizationUser(varOrganizationUser) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "role") - delete(additionalProperties, "email") - delete(additionalProperties, "id") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableOrganizationUser struct { - value *OrganizationUser - isSet bool -} - -func (v NullableOrganizationUser) Get() *OrganizationUser { - return v.value -} - -func (v *NullableOrganizationUser) Set(val *OrganizationUser) { - v.value = val - v.isSet = true -} - -func (v NullableOrganizationUser) IsSet() bool { - return v.isSet -} - -func (v *NullableOrganizationUser) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableOrganizationUser(val *OrganizationUser) *NullableOrganizationUser { - return &NullableOrganizationUser{value: val, isSet: true} -} - -func (v NullableOrganizationUser) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableOrganizationUser) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_private_region.go b/membershipclient/model_private_region.go deleted file mode 100644 index 96ebf81b..00000000 --- a/membershipclient/model_private_region.go +++ /dev/null @@ -1,578 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "time" - "fmt" -) - -// checks if the PrivateRegion type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &PrivateRegion{} - -// PrivateRegion struct for PrivateRegion -type PrivateRegion struct { - Id string `json:"id"` - BaseUrl string `json:"baseUrl"` - CreatedAt string `json:"createdAt"` - Active bool `json:"active"` - LastPing *time.Time `json:"lastPing,omitempty"` - Name string `json:"name"` - Capabilities RegionCapability `json:"capabilities"` - AgentID string `json:"agentID"` - Outdated bool `json:"outdated"` - CreatorId *string `json:"creatorId,omitempty"` - Version *string `json:"version,omitempty"` - OrganizationID string `json:"organizationID"` - CreatorID string `json:"creatorID"` - Secret *PrivateRegionSecret `json:"secret,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _PrivateRegion PrivateRegion - -// NewPrivateRegion instantiates a new PrivateRegion object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewPrivateRegion(id string, baseUrl string, createdAt string, active bool, name string, capabilities RegionCapability, agentID string, outdated bool, organizationID string, creatorID string) *PrivateRegion { - this := PrivateRegion{} - this.Id = id - this.BaseUrl = baseUrl - this.CreatedAt = createdAt - this.Active = active - this.Name = name - this.Capabilities = capabilities - this.AgentID = agentID - this.Outdated = outdated - this.OrganizationID = organizationID - this.CreatorID = creatorID - return &this -} - -// NewPrivateRegionWithDefaults instantiates a new PrivateRegion object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewPrivateRegionWithDefaults() *PrivateRegion { - this := PrivateRegion{} - return &this -} - -// GetId returns the Id field value -func (o *PrivateRegion) GetId() string { - if o == nil { - var ret string - return ret - } - - return o.Id -} - -// GetIdOk returns a tuple with the Id field value -// and a boolean to check if the value has been set. -func (o *PrivateRegion) GetIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Id, true -} - -// SetId sets field value -func (o *PrivateRegion) SetId(v string) { - o.Id = v -} - -// GetBaseUrl returns the BaseUrl field value -func (o *PrivateRegion) GetBaseUrl() string { - if o == nil { - var ret string - return ret - } - - return o.BaseUrl -} - -// GetBaseUrlOk returns a tuple with the BaseUrl field value -// and a boolean to check if the value has been set. -func (o *PrivateRegion) GetBaseUrlOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.BaseUrl, true -} - -// SetBaseUrl sets field value -func (o *PrivateRegion) SetBaseUrl(v string) { - o.BaseUrl = v -} - -// GetCreatedAt returns the CreatedAt field value -func (o *PrivateRegion) GetCreatedAt() string { - if o == nil { - var ret string - return ret - } - - return o.CreatedAt -} - -// GetCreatedAtOk returns a tuple with the CreatedAt field value -// and a boolean to check if the value has been set. -func (o *PrivateRegion) GetCreatedAtOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.CreatedAt, true -} - -// SetCreatedAt sets field value -func (o *PrivateRegion) SetCreatedAt(v string) { - o.CreatedAt = v -} - -// GetActive returns the Active field value -func (o *PrivateRegion) GetActive() bool { - if o == nil { - var ret bool - return ret - } - - return o.Active -} - -// GetActiveOk returns a tuple with the Active field value -// and a boolean to check if the value has been set. -func (o *PrivateRegion) GetActiveOk() (*bool, bool) { - if o == nil { - return nil, false - } - return &o.Active, true -} - -// SetActive sets field value -func (o *PrivateRegion) SetActive(v bool) { - o.Active = v -} - -// GetLastPing returns the LastPing field value if set, zero value otherwise. -func (o *PrivateRegion) GetLastPing() time.Time { - if o == nil || IsNil(o.LastPing) { - var ret time.Time - return ret - } - return *o.LastPing -} - -// GetLastPingOk returns a tuple with the LastPing field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *PrivateRegion) GetLastPingOk() (*time.Time, bool) { - if o == nil || IsNil(o.LastPing) { - return nil, false - } - return o.LastPing, true -} - -// HasLastPing returns a boolean if a field has been set. -func (o *PrivateRegion) HasLastPing() bool { - if o != nil && !IsNil(o.LastPing) { - return true - } - - return false -} - -// SetLastPing gets a reference to the given time.Time and assigns it to the LastPing field. -func (o *PrivateRegion) SetLastPing(v time.Time) { - o.LastPing = &v -} - -// GetName returns the Name field value -func (o *PrivateRegion) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *PrivateRegion) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *PrivateRegion) SetName(v string) { - o.Name = v -} - -// GetCapabilities returns the Capabilities field value -func (o *PrivateRegion) GetCapabilities() RegionCapability { - if o == nil { - var ret RegionCapability - return ret - } - - return o.Capabilities -} - -// GetCapabilitiesOk returns a tuple with the Capabilities field value -// and a boolean to check if the value has been set. -func (o *PrivateRegion) GetCapabilitiesOk() (*RegionCapability, bool) { - if o == nil { - return nil, false - } - return &o.Capabilities, true -} - -// SetCapabilities sets field value -func (o *PrivateRegion) SetCapabilities(v RegionCapability) { - o.Capabilities = v -} - -// GetAgentID returns the AgentID field value -func (o *PrivateRegion) GetAgentID() string { - if o == nil { - var ret string - return ret - } - - return o.AgentID -} - -// GetAgentIDOk returns a tuple with the AgentID field value -// and a boolean to check if the value has been set. -func (o *PrivateRegion) GetAgentIDOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.AgentID, true -} - -// SetAgentID sets field value -func (o *PrivateRegion) SetAgentID(v string) { - o.AgentID = v -} - -// GetOutdated returns the Outdated field value -func (o *PrivateRegion) GetOutdated() bool { - if o == nil { - var ret bool - return ret - } - - return o.Outdated -} - -// GetOutdatedOk returns a tuple with the Outdated field value -// and a boolean to check if the value has been set. -func (o *PrivateRegion) GetOutdatedOk() (*bool, bool) { - if o == nil { - return nil, false - } - return &o.Outdated, true -} - -// SetOutdated sets field value -func (o *PrivateRegion) SetOutdated(v bool) { - o.Outdated = v -} - -// GetCreatorId returns the CreatorId field value if set, zero value otherwise. -func (o *PrivateRegion) GetCreatorId() string { - if o == nil || IsNil(o.CreatorId) { - var ret string - return ret - } - return *o.CreatorId -} - -// GetCreatorIdOk returns a tuple with the CreatorId field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *PrivateRegion) GetCreatorIdOk() (*string, bool) { - if o == nil || IsNil(o.CreatorId) { - return nil, false - } - return o.CreatorId, true -} - -// HasCreatorId returns a boolean if a field has been set. -func (o *PrivateRegion) HasCreatorId() bool { - if o != nil && !IsNil(o.CreatorId) { - return true - } - - return false -} - -// SetCreatorId gets a reference to the given string and assigns it to the CreatorId field. -func (o *PrivateRegion) SetCreatorId(v string) { - o.CreatorId = &v -} - -// GetVersion returns the Version field value if set, zero value otherwise. -func (o *PrivateRegion) GetVersion() string { - if o == nil || IsNil(o.Version) { - var ret string - return ret - } - return *o.Version -} - -// GetVersionOk returns a tuple with the Version field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *PrivateRegion) GetVersionOk() (*string, bool) { - if o == nil || IsNil(o.Version) { - return nil, false - } - return o.Version, true -} - -// HasVersion returns a boolean if a field has been set. -func (o *PrivateRegion) HasVersion() bool { - if o != nil && !IsNil(o.Version) { - return true - } - - return false -} - -// SetVersion gets a reference to the given string and assigns it to the Version field. -func (o *PrivateRegion) SetVersion(v string) { - o.Version = &v -} - -// GetOrganizationID returns the OrganizationID field value -func (o *PrivateRegion) GetOrganizationID() string { - if o == nil { - var ret string - return ret - } - - return o.OrganizationID -} - -// GetOrganizationIDOk returns a tuple with the OrganizationID field value -// and a boolean to check if the value has been set. -func (o *PrivateRegion) GetOrganizationIDOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.OrganizationID, true -} - -// SetOrganizationID sets field value -func (o *PrivateRegion) SetOrganizationID(v string) { - o.OrganizationID = v -} - -// GetCreatorID returns the CreatorID field value -func (o *PrivateRegion) GetCreatorID() string { - if o == nil { - var ret string - return ret - } - - return o.CreatorID -} - -// GetCreatorIDOk returns a tuple with the CreatorID field value -// and a boolean to check if the value has been set. -func (o *PrivateRegion) GetCreatorIDOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.CreatorID, true -} - -// SetCreatorID sets field value -func (o *PrivateRegion) SetCreatorID(v string) { - o.CreatorID = v -} - -// GetSecret returns the Secret field value if set, zero value otherwise. -func (o *PrivateRegion) GetSecret() PrivateRegionSecret { - if o == nil || IsNil(o.Secret) { - var ret PrivateRegionSecret - return ret - } - return *o.Secret -} - -// GetSecretOk returns a tuple with the Secret field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *PrivateRegion) GetSecretOk() (*PrivateRegionSecret, bool) { - if o == nil || IsNil(o.Secret) { - return nil, false - } - return o.Secret, true -} - -// HasSecret returns a boolean if a field has been set. -func (o *PrivateRegion) HasSecret() bool { - if o != nil && !IsNil(o.Secret) { - return true - } - - return false -} - -// SetSecret gets a reference to the given PrivateRegionSecret and assigns it to the Secret field. -func (o *PrivateRegion) SetSecret(v PrivateRegionSecret) { - o.Secret = &v -} - -func (o PrivateRegion) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o PrivateRegion) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["id"] = o.Id - toSerialize["baseUrl"] = o.BaseUrl - toSerialize["createdAt"] = o.CreatedAt - toSerialize["active"] = o.Active - if !IsNil(o.LastPing) { - toSerialize["lastPing"] = o.LastPing - } - toSerialize["name"] = o.Name - toSerialize["capabilities"] = o.Capabilities - toSerialize["agentID"] = o.AgentID - toSerialize["outdated"] = o.Outdated - if !IsNil(o.CreatorId) { - toSerialize["creatorId"] = o.CreatorId - } - if !IsNil(o.Version) { - toSerialize["version"] = o.Version - } - toSerialize["organizationID"] = o.OrganizationID - toSerialize["creatorID"] = o.CreatorID - if !IsNil(o.Secret) { - toSerialize["secret"] = o.Secret - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *PrivateRegion) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "id", - "baseUrl", - "createdAt", - "active", - "name", - "capabilities", - "agentID", - "outdated", - "organizationID", - "creatorID", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varPrivateRegion := _PrivateRegion{} - - err = json.Unmarshal(data, &varPrivateRegion) - - if err != nil { - return err - } - - *o = PrivateRegion(varPrivateRegion) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "id") - delete(additionalProperties, "baseUrl") - delete(additionalProperties, "createdAt") - delete(additionalProperties, "active") - delete(additionalProperties, "lastPing") - delete(additionalProperties, "name") - delete(additionalProperties, "capabilities") - delete(additionalProperties, "agentID") - delete(additionalProperties, "outdated") - delete(additionalProperties, "creatorId") - delete(additionalProperties, "version") - delete(additionalProperties, "organizationID") - delete(additionalProperties, "creatorID") - delete(additionalProperties, "secret") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullablePrivateRegion struct { - value *PrivateRegion - isSet bool -} - -func (v NullablePrivateRegion) Get() *PrivateRegion { - return v.value -} - -func (v *NullablePrivateRegion) Set(val *PrivateRegion) { - v.value = val - v.isSet = true -} - -func (v NullablePrivateRegion) IsSet() bool { - return v.isSet -} - -func (v *NullablePrivateRegion) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullablePrivateRegion(val *PrivateRegion) *NullablePrivateRegion { - return &NullablePrivateRegion{value: val, isSet: true} -} - -func (v NullablePrivateRegion) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullablePrivateRegion) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_private_region_secret.go b/membershipclient/model_private_region_secret.go deleted file mode 100644 index ab8334a1..00000000 --- a/membershipclient/model_private_region_secret.go +++ /dev/null @@ -1,205 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the PrivateRegionSecret type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &PrivateRegionSecret{} - -// PrivateRegionSecret struct for PrivateRegionSecret -type PrivateRegionSecret struct { - LastDigits string `json:"lastDigits"` - Clear *string `json:"clear,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _PrivateRegionSecret PrivateRegionSecret - -// NewPrivateRegionSecret instantiates a new PrivateRegionSecret object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewPrivateRegionSecret(lastDigits string) *PrivateRegionSecret { - this := PrivateRegionSecret{} - this.LastDigits = lastDigits - return &this -} - -// NewPrivateRegionSecretWithDefaults instantiates a new PrivateRegionSecret object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewPrivateRegionSecretWithDefaults() *PrivateRegionSecret { - this := PrivateRegionSecret{} - return &this -} - -// GetLastDigits returns the LastDigits field value -func (o *PrivateRegionSecret) GetLastDigits() string { - if o == nil { - var ret string - return ret - } - - return o.LastDigits -} - -// GetLastDigitsOk returns a tuple with the LastDigits field value -// and a boolean to check if the value has been set. -func (o *PrivateRegionSecret) GetLastDigitsOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.LastDigits, true -} - -// SetLastDigits sets field value -func (o *PrivateRegionSecret) SetLastDigits(v string) { - o.LastDigits = v -} - -// GetClear returns the Clear field value if set, zero value otherwise. -func (o *PrivateRegionSecret) GetClear() string { - if o == nil || IsNil(o.Clear) { - var ret string - return ret - } - return *o.Clear -} - -// GetClearOk returns a tuple with the Clear field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *PrivateRegionSecret) GetClearOk() (*string, bool) { - if o == nil || IsNil(o.Clear) { - return nil, false - } - return o.Clear, true -} - -// HasClear returns a boolean if a field has been set. -func (o *PrivateRegionSecret) HasClear() bool { - if o != nil && !IsNil(o.Clear) { - return true - } - - return false -} - -// SetClear gets a reference to the given string and assigns it to the Clear field. -func (o *PrivateRegionSecret) SetClear(v string) { - o.Clear = &v -} - -func (o PrivateRegionSecret) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o PrivateRegionSecret) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["lastDigits"] = o.LastDigits - if !IsNil(o.Clear) { - toSerialize["clear"] = o.Clear - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *PrivateRegionSecret) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "lastDigits", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varPrivateRegionSecret := _PrivateRegionSecret{} - - err = json.Unmarshal(data, &varPrivateRegionSecret) - - if err != nil { - return err - } - - *o = PrivateRegionSecret(varPrivateRegionSecret) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "lastDigits") - delete(additionalProperties, "clear") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullablePrivateRegionSecret struct { - value *PrivateRegionSecret - isSet bool -} - -func (v NullablePrivateRegionSecret) Get() *PrivateRegionSecret { - return v.value -} - -func (v *NullablePrivateRegionSecret) Set(val *PrivateRegionSecret) { - v.value = val - v.isSet = true -} - -func (v NullablePrivateRegionSecret) IsSet() bool { - return v.isSet -} - -func (v *NullablePrivateRegionSecret) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullablePrivateRegionSecret(val *PrivateRegionSecret) *NullablePrivateRegionSecret { - return &NullablePrivateRegionSecret{value: val, isSet: true} -} - -func (v NullablePrivateRegionSecret) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullablePrivateRegionSecret) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_public_region.go b/membershipclient/model_public_region.go deleted file mode 100644 index e99297a3..00000000 --- a/membershipclient/model_public_region.go +++ /dev/null @@ -1,512 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "time" - "fmt" -) - -// checks if the PublicRegion type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &PublicRegion{} - -// PublicRegion struct for PublicRegion -type PublicRegion struct { - Id string `json:"id"` - BaseUrl string `json:"baseUrl"` - CreatedAt string `json:"createdAt"` - Active bool `json:"active"` - LastPing *time.Time `json:"lastPing,omitempty"` - Name string `json:"name"` - Capabilities RegionCapability `json:"capabilities"` - AgentID string `json:"agentID"` - Outdated bool `json:"outdated"` - CreatorId *string `json:"creatorId,omitempty"` - Version *string `json:"version,omitempty"` - Production bool `json:"production"` - AdditionalProperties map[string]interface{} -} - -type _PublicRegion PublicRegion - -// NewPublicRegion instantiates a new PublicRegion object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewPublicRegion(id string, baseUrl string, createdAt string, active bool, name string, capabilities RegionCapability, agentID string, outdated bool, production bool) *PublicRegion { - this := PublicRegion{} - this.Id = id - this.BaseUrl = baseUrl - this.CreatedAt = createdAt - this.Active = active - this.Name = name - this.Capabilities = capabilities - this.AgentID = agentID - this.Outdated = outdated - this.Production = production - return &this -} - -// NewPublicRegionWithDefaults instantiates a new PublicRegion object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewPublicRegionWithDefaults() *PublicRegion { - this := PublicRegion{} - return &this -} - -// GetId returns the Id field value -func (o *PublicRegion) GetId() string { - if o == nil { - var ret string - return ret - } - - return o.Id -} - -// GetIdOk returns a tuple with the Id field value -// and a boolean to check if the value has been set. -func (o *PublicRegion) GetIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Id, true -} - -// SetId sets field value -func (o *PublicRegion) SetId(v string) { - o.Id = v -} - -// GetBaseUrl returns the BaseUrl field value -func (o *PublicRegion) GetBaseUrl() string { - if o == nil { - var ret string - return ret - } - - return o.BaseUrl -} - -// GetBaseUrlOk returns a tuple with the BaseUrl field value -// and a boolean to check if the value has been set. -func (o *PublicRegion) GetBaseUrlOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.BaseUrl, true -} - -// SetBaseUrl sets field value -func (o *PublicRegion) SetBaseUrl(v string) { - o.BaseUrl = v -} - -// GetCreatedAt returns the CreatedAt field value -func (o *PublicRegion) GetCreatedAt() string { - if o == nil { - var ret string - return ret - } - - return o.CreatedAt -} - -// GetCreatedAtOk returns a tuple with the CreatedAt field value -// and a boolean to check if the value has been set. -func (o *PublicRegion) GetCreatedAtOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.CreatedAt, true -} - -// SetCreatedAt sets field value -func (o *PublicRegion) SetCreatedAt(v string) { - o.CreatedAt = v -} - -// GetActive returns the Active field value -func (o *PublicRegion) GetActive() bool { - if o == nil { - var ret bool - return ret - } - - return o.Active -} - -// GetActiveOk returns a tuple with the Active field value -// and a boolean to check if the value has been set. -func (o *PublicRegion) GetActiveOk() (*bool, bool) { - if o == nil { - return nil, false - } - return &o.Active, true -} - -// SetActive sets field value -func (o *PublicRegion) SetActive(v bool) { - o.Active = v -} - -// GetLastPing returns the LastPing field value if set, zero value otherwise. -func (o *PublicRegion) GetLastPing() time.Time { - if o == nil || IsNil(o.LastPing) { - var ret time.Time - return ret - } - return *o.LastPing -} - -// GetLastPingOk returns a tuple with the LastPing field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *PublicRegion) GetLastPingOk() (*time.Time, bool) { - if o == nil || IsNil(o.LastPing) { - return nil, false - } - return o.LastPing, true -} - -// HasLastPing returns a boolean if a field has been set. -func (o *PublicRegion) HasLastPing() bool { - if o != nil && !IsNil(o.LastPing) { - return true - } - - return false -} - -// SetLastPing gets a reference to the given time.Time and assigns it to the LastPing field. -func (o *PublicRegion) SetLastPing(v time.Time) { - o.LastPing = &v -} - -// GetName returns the Name field value -func (o *PublicRegion) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *PublicRegion) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *PublicRegion) SetName(v string) { - o.Name = v -} - -// GetCapabilities returns the Capabilities field value -func (o *PublicRegion) GetCapabilities() RegionCapability { - if o == nil { - var ret RegionCapability - return ret - } - - return o.Capabilities -} - -// GetCapabilitiesOk returns a tuple with the Capabilities field value -// and a boolean to check if the value has been set. -func (o *PublicRegion) GetCapabilitiesOk() (*RegionCapability, bool) { - if o == nil { - return nil, false - } - return &o.Capabilities, true -} - -// SetCapabilities sets field value -func (o *PublicRegion) SetCapabilities(v RegionCapability) { - o.Capabilities = v -} - -// GetAgentID returns the AgentID field value -func (o *PublicRegion) GetAgentID() string { - if o == nil { - var ret string - return ret - } - - return o.AgentID -} - -// GetAgentIDOk returns a tuple with the AgentID field value -// and a boolean to check if the value has been set. -func (o *PublicRegion) GetAgentIDOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.AgentID, true -} - -// SetAgentID sets field value -func (o *PublicRegion) SetAgentID(v string) { - o.AgentID = v -} - -// GetOutdated returns the Outdated field value -func (o *PublicRegion) GetOutdated() bool { - if o == nil { - var ret bool - return ret - } - - return o.Outdated -} - -// GetOutdatedOk returns a tuple with the Outdated field value -// and a boolean to check if the value has been set. -func (o *PublicRegion) GetOutdatedOk() (*bool, bool) { - if o == nil { - return nil, false - } - return &o.Outdated, true -} - -// SetOutdated sets field value -func (o *PublicRegion) SetOutdated(v bool) { - o.Outdated = v -} - -// GetCreatorId returns the CreatorId field value if set, zero value otherwise. -func (o *PublicRegion) GetCreatorId() string { - if o == nil || IsNil(o.CreatorId) { - var ret string - return ret - } - return *o.CreatorId -} - -// GetCreatorIdOk returns a tuple with the CreatorId field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *PublicRegion) GetCreatorIdOk() (*string, bool) { - if o == nil || IsNil(o.CreatorId) { - return nil, false - } - return o.CreatorId, true -} - -// HasCreatorId returns a boolean if a field has been set. -func (o *PublicRegion) HasCreatorId() bool { - if o != nil && !IsNil(o.CreatorId) { - return true - } - - return false -} - -// SetCreatorId gets a reference to the given string and assigns it to the CreatorId field. -func (o *PublicRegion) SetCreatorId(v string) { - o.CreatorId = &v -} - -// GetVersion returns the Version field value if set, zero value otherwise. -func (o *PublicRegion) GetVersion() string { - if o == nil || IsNil(o.Version) { - var ret string - return ret - } - return *o.Version -} - -// GetVersionOk returns a tuple with the Version field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *PublicRegion) GetVersionOk() (*string, bool) { - if o == nil || IsNil(o.Version) { - return nil, false - } - return o.Version, true -} - -// HasVersion returns a boolean if a field has been set. -func (o *PublicRegion) HasVersion() bool { - if o != nil && !IsNil(o.Version) { - return true - } - - return false -} - -// SetVersion gets a reference to the given string and assigns it to the Version field. -func (o *PublicRegion) SetVersion(v string) { - o.Version = &v -} - -// GetProduction returns the Production field value -func (o *PublicRegion) GetProduction() bool { - if o == nil { - var ret bool - return ret - } - - return o.Production -} - -// GetProductionOk returns a tuple with the Production field value -// and a boolean to check if the value has been set. -func (o *PublicRegion) GetProductionOk() (*bool, bool) { - if o == nil { - return nil, false - } - return &o.Production, true -} - -// SetProduction sets field value -func (o *PublicRegion) SetProduction(v bool) { - o.Production = v -} - -func (o PublicRegion) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o PublicRegion) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["id"] = o.Id - toSerialize["baseUrl"] = o.BaseUrl - toSerialize["createdAt"] = o.CreatedAt - toSerialize["active"] = o.Active - if !IsNil(o.LastPing) { - toSerialize["lastPing"] = o.LastPing - } - toSerialize["name"] = o.Name - toSerialize["capabilities"] = o.Capabilities - toSerialize["agentID"] = o.AgentID - toSerialize["outdated"] = o.Outdated - if !IsNil(o.CreatorId) { - toSerialize["creatorId"] = o.CreatorId - } - if !IsNil(o.Version) { - toSerialize["version"] = o.Version - } - toSerialize["production"] = o.Production - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *PublicRegion) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "id", - "baseUrl", - "createdAt", - "active", - "name", - "capabilities", - "agentID", - "outdated", - "production", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varPublicRegion := _PublicRegion{} - - err = json.Unmarshal(data, &varPublicRegion) - - if err != nil { - return err - } - - *o = PublicRegion(varPublicRegion) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "id") - delete(additionalProperties, "baseUrl") - delete(additionalProperties, "createdAt") - delete(additionalProperties, "active") - delete(additionalProperties, "lastPing") - delete(additionalProperties, "name") - delete(additionalProperties, "capabilities") - delete(additionalProperties, "agentID") - delete(additionalProperties, "outdated") - delete(additionalProperties, "creatorId") - delete(additionalProperties, "version") - delete(additionalProperties, "production") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullablePublicRegion struct { - value *PublicRegion - isSet bool -} - -func (v NullablePublicRegion) Get() *PublicRegion { - return v.value -} - -func (v *NullablePublicRegion) Set(val *PublicRegion) { - v.value = val - v.isSet = true -} - -func (v NullablePublicRegion) IsSet() bool { - return v.isSet -} - -func (v *NullablePublicRegion) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullablePublicRegion(val *PublicRegion) *NullablePublicRegion { - return &NullablePublicRegion{value: val, isSet: true} -} - -func (v NullablePublicRegion) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullablePublicRegion) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_read_organization_client_response.go b/membershipclient/model_read_organization_client_response.go deleted file mode 100644 index d8a9cbd1..00000000 --- a/membershipclient/model_read_organization_client_response.go +++ /dev/null @@ -1,168 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the ReadOrganizationClientResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ReadOrganizationClientResponse{} - -// ReadOrganizationClientResponse struct for ReadOrganizationClientResponse -type ReadOrganizationClientResponse struct { - Data OrganizationClient `json:"data"` - AdditionalProperties map[string]interface{} -} - -type _ReadOrganizationClientResponse ReadOrganizationClientResponse - -// NewReadOrganizationClientResponse instantiates a new ReadOrganizationClientResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewReadOrganizationClientResponse(data OrganizationClient) *ReadOrganizationClientResponse { - this := ReadOrganizationClientResponse{} - this.Data = data - return &this -} - -// NewReadOrganizationClientResponseWithDefaults instantiates a new ReadOrganizationClientResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewReadOrganizationClientResponseWithDefaults() *ReadOrganizationClientResponse { - this := ReadOrganizationClientResponse{} - return &this -} - -// GetData returns the Data field value -func (o *ReadOrganizationClientResponse) GetData() OrganizationClient { - if o == nil { - var ret OrganizationClient - return ret - } - - return o.Data -} - -// GetDataOk returns a tuple with the Data field value -// and a boolean to check if the value has been set. -func (o *ReadOrganizationClientResponse) GetDataOk() (*OrganizationClient, bool) { - if o == nil { - return nil, false - } - return &o.Data, true -} - -// SetData sets field value -func (o *ReadOrganizationClientResponse) SetData(v OrganizationClient) { - o.Data = v -} - -func (o ReadOrganizationClientResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ReadOrganizationClientResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["data"] = o.Data - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *ReadOrganizationClientResponse) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "data", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varReadOrganizationClientResponse := _ReadOrganizationClientResponse{} - - err = json.Unmarshal(data, &varReadOrganizationClientResponse) - - if err != nil { - return err - } - - *o = ReadOrganizationClientResponse(varReadOrganizationClientResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableReadOrganizationClientResponse struct { - value *ReadOrganizationClientResponse - isSet bool -} - -func (v NullableReadOrganizationClientResponse) Get() *ReadOrganizationClientResponse { - return v.value -} - -func (v *NullableReadOrganizationClientResponse) Set(val *ReadOrganizationClientResponse) { - v.value = val - v.isSet = true -} - -func (v NullableReadOrganizationClientResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableReadOrganizationClientResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableReadOrganizationClientResponse(val *ReadOrganizationClientResponse) *NullableReadOrganizationClientResponse { - return &NullableReadOrganizationClientResponse{value: val, isSet: true} -} - -func (v NullableReadOrganizationClientResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableReadOrganizationClientResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_read_organization_clients_response.go b/membershipclient/model_read_organization_clients_response.go deleted file mode 100644 index 1f1831ea..00000000 --- a/membershipclient/model_read_organization_clients_response.go +++ /dev/null @@ -1,168 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the ReadOrganizationClientsResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ReadOrganizationClientsResponse{} - -// ReadOrganizationClientsResponse struct for ReadOrganizationClientsResponse -type ReadOrganizationClientsResponse struct { - Data ReadOrganizationClientsResponseData `json:"data"` - AdditionalProperties map[string]interface{} -} - -type _ReadOrganizationClientsResponse ReadOrganizationClientsResponse - -// NewReadOrganizationClientsResponse instantiates a new ReadOrganizationClientsResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewReadOrganizationClientsResponse(data ReadOrganizationClientsResponseData) *ReadOrganizationClientsResponse { - this := ReadOrganizationClientsResponse{} - this.Data = data - return &this -} - -// NewReadOrganizationClientsResponseWithDefaults instantiates a new ReadOrganizationClientsResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewReadOrganizationClientsResponseWithDefaults() *ReadOrganizationClientsResponse { - this := ReadOrganizationClientsResponse{} - return &this -} - -// GetData returns the Data field value -func (o *ReadOrganizationClientsResponse) GetData() ReadOrganizationClientsResponseData { - if o == nil { - var ret ReadOrganizationClientsResponseData - return ret - } - - return o.Data -} - -// GetDataOk returns a tuple with the Data field value -// and a boolean to check if the value has been set. -func (o *ReadOrganizationClientsResponse) GetDataOk() (*ReadOrganizationClientsResponseData, bool) { - if o == nil { - return nil, false - } - return &o.Data, true -} - -// SetData sets field value -func (o *ReadOrganizationClientsResponse) SetData(v ReadOrganizationClientsResponseData) { - o.Data = v -} - -func (o ReadOrganizationClientsResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ReadOrganizationClientsResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["data"] = o.Data - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *ReadOrganizationClientsResponse) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "data", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varReadOrganizationClientsResponse := _ReadOrganizationClientsResponse{} - - err = json.Unmarshal(data, &varReadOrganizationClientsResponse) - - if err != nil { - return err - } - - *o = ReadOrganizationClientsResponse(varReadOrganizationClientsResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableReadOrganizationClientsResponse struct { - value *ReadOrganizationClientsResponse - isSet bool -} - -func (v NullableReadOrganizationClientsResponse) Get() *ReadOrganizationClientsResponse { - return v.value -} - -func (v *NullableReadOrganizationClientsResponse) Set(val *ReadOrganizationClientsResponse) { - v.value = val - v.isSet = true -} - -func (v NullableReadOrganizationClientsResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableReadOrganizationClientsResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableReadOrganizationClientsResponse(val *ReadOrganizationClientsResponse) *NullableReadOrganizationClientsResponse { - return &NullableReadOrganizationClientsResponse{value: val, isSet: true} -} - -func (v NullableReadOrganizationClientsResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableReadOrganizationClientsResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_read_organization_clients_response_data.go b/membershipclient/model_read_organization_clients_response_data.go deleted file mode 100644 index 71c2ab25..00000000 --- a/membershipclient/model_read_organization_clients_response_data.go +++ /dev/null @@ -1,300 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the ReadOrganizationClientsResponseData type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ReadOrganizationClientsResponseData{} - -// ReadOrganizationClientsResponseData struct for ReadOrganizationClientsResponseData -type ReadOrganizationClientsResponseData struct { - PageSize int64 `json:"pageSize"` - HasMore bool `json:"hasMore"` - Previous *string `json:"previous,omitempty"` - Next *string `json:"next,omitempty"` - Data []OrganizationClient `json:"data"` - AdditionalProperties map[string]interface{} -} - -type _ReadOrganizationClientsResponseData ReadOrganizationClientsResponseData - -// NewReadOrganizationClientsResponseData instantiates a new ReadOrganizationClientsResponseData object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewReadOrganizationClientsResponseData(pageSize int64, hasMore bool, data []OrganizationClient) *ReadOrganizationClientsResponseData { - this := ReadOrganizationClientsResponseData{} - this.PageSize = pageSize - this.HasMore = hasMore - this.Data = data - return &this -} - -// NewReadOrganizationClientsResponseDataWithDefaults instantiates a new ReadOrganizationClientsResponseData object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewReadOrganizationClientsResponseDataWithDefaults() *ReadOrganizationClientsResponseData { - this := ReadOrganizationClientsResponseData{} - return &this -} - -// GetPageSize returns the PageSize field value -func (o *ReadOrganizationClientsResponseData) GetPageSize() int64 { - if o == nil { - var ret int64 - return ret - } - - return o.PageSize -} - -// GetPageSizeOk returns a tuple with the PageSize field value -// and a boolean to check if the value has been set. -func (o *ReadOrganizationClientsResponseData) GetPageSizeOk() (*int64, bool) { - if o == nil { - return nil, false - } - return &o.PageSize, true -} - -// SetPageSize sets field value -func (o *ReadOrganizationClientsResponseData) SetPageSize(v int64) { - o.PageSize = v -} - -// GetHasMore returns the HasMore field value -func (o *ReadOrganizationClientsResponseData) GetHasMore() bool { - if o == nil { - var ret bool - return ret - } - - return o.HasMore -} - -// GetHasMoreOk returns a tuple with the HasMore field value -// and a boolean to check if the value has been set. -func (o *ReadOrganizationClientsResponseData) GetHasMoreOk() (*bool, bool) { - if o == nil { - return nil, false - } - return &o.HasMore, true -} - -// SetHasMore sets field value -func (o *ReadOrganizationClientsResponseData) SetHasMore(v bool) { - o.HasMore = v -} - -// GetPrevious returns the Previous field value if set, zero value otherwise. -func (o *ReadOrganizationClientsResponseData) GetPrevious() string { - if o == nil || IsNil(o.Previous) { - var ret string - return ret - } - return *o.Previous -} - -// GetPreviousOk returns a tuple with the Previous field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *ReadOrganizationClientsResponseData) GetPreviousOk() (*string, bool) { - if o == nil || IsNil(o.Previous) { - return nil, false - } - return o.Previous, true -} - -// HasPrevious returns a boolean if a field has been set. -func (o *ReadOrganizationClientsResponseData) HasPrevious() bool { - if o != nil && !IsNil(o.Previous) { - return true - } - - return false -} - -// SetPrevious gets a reference to the given string and assigns it to the Previous field. -func (o *ReadOrganizationClientsResponseData) SetPrevious(v string) { - o.Previous = &v -} - -// GetNext returns the Next field value if set, zero value otherwise. -func (o *ReadOrganizationClientsResponseData) GetNext() string { - if o == nil || IsNil(o.Next) { - var ret string - return ret - } - return *o.Next -} - -// GetNextOk returns a tuple with the Next field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *ReadOrganizationClientsResponseData) GetNextOk() (*string, bool) { - if o == nil || IsNil(o.Next) { - return nil, false - } - return o.Next, true -} - -// HasNext returns a boolean if a field has been set. -func (o *ReadOrganizationClientsResponseData) HasNext() bool { - if o != nil && !IsNil(o.Next) { - return true - } - - return false -} - -// SetNext gets a reference to the given string and assigns it to the Next field. -func (o *ReadOrganizationClientsResponseData) SetNext(v string) { - o.Next = &v -} - -// GetData returns the Data field value -func (o *ReadOrganizationClientsResponseData) GetData() []OrganizationClient { - if o == nil { - var ret []OrganizationClient - return ret - } - - return o.Data -} - -// GetDataOk returns a tuple with the Data field value -// and a boolean to check if the value has been set. -func (o *ReadOrganizationClientsResponseData) GetDataOk() ([]OrganizationClient, bool) { - if o == nil { - return nil, false - } - return o.Data, true -} - -// SetData sets field value -func (o *ReadOrganizationClientsResponseData) SetData(v []OrganizationClient) { - o.Data = v -} - -func (o ReadOrganizationClientsResponseData) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ReadOrganizationClientsResponseData) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["pageSize"] = o.PageSize - toSerialize["hasMore"] = o.HasMore - if !IsNil(o.Previous) { - toSerialize["previous"] = o.Previous - } - if !IsNil(o.Next) { - toSerialize["next"] = o.Next - } - toSerialize["data"] = o.Data - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *ReadOrganizationClientsResponseData) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "pageSize", - "hasMore", - "data", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varReadOrganizationClientsResponseData := _ReadOrganizationClientsResponseData{} - - err = json.Unmarshal(data, &varReadOrganizationClientsResponseData) - - if err != nil { - return err - } - - *o = ReadOrganizationClientsResponseData(varReadOrganizationClientsResponseData) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "pageSize") - delete(additionalProperties, "hasMore") - delete(additionalProperties, "previous") - delete(additionalProperties, "next") - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableReadOrganizationClientsResponseData struct { - value *ReadOrganizationClientsResponseData - isSet bool -} - -func (v NullableReadOrganizationClientsResponseData) Get() *ReadOrganizationClientsResponseData { - return v.value -} - -func (v *NullableReadOrganizationClientsResponseData) Set(val *ReadOrganizationClientsResponseData) { - v.value = val - v.isSet = true -} - -func (v NullableReadOrganizationClientsResponseData) IsSet() bool { - return v.isSet -} - -func (v *NullableReadOrganizationClientsResponseData) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableReadOrganizationClientsResponseData(val *ReadOrganizationClientsResponseData) *NullableReadOrganizationClientsResponseData { - return &NullableReadOrganizationClientsResponseData{value: val, isSet: true} -} - -func (v NullableReadOrganizationClientsResponseData) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableReadOrganizationClientsResponseData) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_read_organization_response.go b/membershipclient/model_read_organization_response.go deleted file mode 100644 index 3d11cacd..00000000 --- a/membershipclient/model_read_organization_response.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the ReadOrganizationResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ReadOrganizationResponse{} - -// ReadOrganizationResponse struct for ReadOrganizationResponse -type ReadOrganizationResponse struct { - Data *OrganizationExpanded `json:"data,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _ReadOrganizationResponse ReadOrganizationResponse - -// NewReadOrganizationResponse instantiates a new ReadOrganizationResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewReadOrganizationResponse() *ReadOrganizationResponse { - this := ReadOrganizationResponse{} - return &this -} - -// NewReadOrganizationResponseWithDefaults instantiates a new ReadOrganizationResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewReadOrganizationResponseWithDefaults() *ReadOrganizationResponse { - this := ReadOrganizationResponse{} - return &this -} - -// GetData returns the Data field value if set, zero value otherwise. -func (o *ReadOrganizationResponse) GetData() OrganizationExpanded { - if o == nil || IsNil(o.Data) { - var ret OrganizationExpanded - return ret - } - return *o.Data -} - -// GetDataOk returns a tuple with the Data field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *ReadOrganizationResponse) GetDataOk() (*OrganizationExpanded, bool) { - if o == nil || IsNil(o.Data) { - return nil, false - } - return o.Data, true -} - -// HasData returns a boolean if a field has been set. -func (o *ReadOrganizationResponse) HasData() bool { - if o != nil && !IsNil(o.Data) { - return true - } - - return false -} - -// SetData gets a reference to the given OrganizationExpanded and assigns it to the Data field. -func (o *ReadOrganizationResponse) SetData(v OrganizationExpanded) { - o.Data = &v -} - -func (o ReadOrganizationResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ReadOrganizationResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Data) { - toSerialize["data"] = o.Data - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *ReadOrganizationResponse) UnmarshalJSON(data []byte) (err error) { - varReadOrganizationResponse := _ReadOrganizationResponse{} - - err = json.Unmarshal(data, &varReadOrganizationResponse) - - if err != nil { - return err - } - - *o = ReadOrganizationResponse(varReadOrganizationResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableReadOrganizationResponse struct { - value *ReadOrganizationResponse - isSet bool -} - -func (v NullableReadOrganizationResponse) Get() *ReadOrganizationResponse { - return v.value -} - -func (v *NullableReadOrganizationResponse) Set(val *ReadOrganizationResponse) { - v.value = val - v.isSet = true -} - -func (v NullableReadOrganizationResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableReadOrganizationResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableReadOrganizationResponse(val *ReadOrganizationResponse) *NullableReadOrganizationResponse { - return &NullableReadOrganizationResponse{value: val, isSet: true} -} - -func (v NullableReadOrganizationResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableReadOrganizationResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_read_organization_user_response.go b/membershipclient/model_read_organization_user_response.go deleted file mode 100644 index a2724e90..00000000 --- a/membershipclient/model_read_organization_user_response.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the ReadOrganizationUserResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ReadOrganizationUserResponse{} - -// ReadOrganizationUserResponse struct for ReadOrganizationUserResponse -type ReadOrganizationUserResponse struct { - Data *OrganizationUser `json:"data,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _ReadOrganizationUserResponse ReadOrganizationUserResponse - -// NewReadOrganizationUserResponse instantiates a new ReadOrganizationUserResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewReadOrganizationUserResponse() *ReadOrganizationUserResponse { - this := ReadOrganizationUserResponse{} - return &this -} - -// NewReadOrganizationUserResponseWithDefaults instantiates a new ReadOrganizationUserResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewReadOrganizationUserResponseWithDefaults() *ReadOrganizationUserResponse { - this := ReadOrganizationUserResponse{} - return &this -} - -// GetData returns the Data field value if set, zero value otherwise. -func (o *ReadOrganizationUserResponse) GetData() OrganizationUser { - if o == nil || IsNil(o.Data) { - var ret OrganizationUser - return ret - } - return *o.Data -} - -// GetDataOk returns a tuple with the Data field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *ReadOrganizationUserResponse) GetDataOk() (*OrganizationUser, bool) { - if o == nil || IsNil(o.Data) { - return nil, false - } - return o.Data, true -} - -// HasData returns a boolean if a field has been set. -func (o *ReadOrganizationUserResponse) HasData() bool { - if o != nil && !IsNil(o.Data) { - return true - } - - return false -} - -// SetData gets a reference to the given OrganizationUser and assigns it to the Data field. -func (o *ReadOrganizationUserResponse) SetData(v OrganizationUser) { - o.Data = &v -} - -func (o ReadOrganizationUserResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ReadOrganizationUserResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Data) { - toSerialize["data"] = o.Data - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *ReadOrganizationUserResponse) UnmarshalJSON(data []byte) (err error) { - varReadOrganizationUserResponse := _ReadOrganizationUserResponse{} - - err = json.Unmarshal(data, &varReadOrganizationUserResponse) - - if err != nil { - return err - } - - *o = ReadOrganizationUserResponse(varReadOrganizationUserResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableReadOrganizationUserResponse struct { - value *ReadOrganizationUserResponse - isSet bool -} - -func (v NullableReadOrganizationUserResponse) Get() *ReadOrganizationUserResponse { - return v.value -} - -func (v *NullableReadOrganizationUserResponse) Set(val *ReadOrganizationUserResponse) { - v.value = val - v.isSet = true -} - -func (v NullableReadOrganizationUserResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableReadOrganizationUserResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableReadOrganizationUserResponse(val *ReadOrganizationUserResponse) *NullableReadOrganizationUserResponse { - return &NullableReadOrganizationUserResponse{value: val, isSet: true} -} - -func (v NullableReadOrganizationUserResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableReadOrganizationUserResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_read_stack_user_access.go b/membershipclient/model_read_stack_user_access.go deleted file mode 100644 index c43d0199..00000000 --- a/membershipclient/model_read_stack_user_access.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the ReadStackUserAccess type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ReadStackUserAccess{} - -// ReadStackUserAccess struct for ReadStackUserAccess -type ReadStackUserAccess struct { - Data *StackUserAccess `json:"data,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _ReadStackUserAccess ReadStackUserAccess - -// NewReadStackUserAccess instantiates a new ReadStackUserAccess object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewReadStackUserAccess() *ReadStackUserAccess { - this := ReadStackUserAccess{} - return &this -} - -// NewReadStackUserAccessWithDefaults instantiates a new ReadStackUserAccess object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewReadStackUserAccessWithDefaults() *ReadStackUserAccess { - this := ReadStackUserAccess{} - return &this -} - -// GetData returns the Data field value if set, zero value otherwise. -func (o *ReadStackUserAccess) GetData() StackUserAccess { - if o == nil || IsNil(o.Data) { - var ret StackUserAccess - return ret - } - return *o.Data -} - -// GetDataOk returns a tuple with the Data field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *ReadStackUserAccess) GetDataOk() (*StackUserAccess, bool) { - if o == nil || IsNil(o.Data) { - return nil, false - } - return o.Data, true -} - -// HasData returns a boolean if a field has been set. -func (o *ReadStackUserAccess) HasData() bool { - if o != nil && !IsNil(o.Data) { - return true - } - - return false -} - -// SetData gets a reference to the given StackUserAccess and assigns it to the Data field. -func (o *ReadStackUserAccess) SetData(v StackUserAccess) { - o.Data = &v -} - -func (o ReadStackUserAccess) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ReadStackUserAccess) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Data) { - toSerialize["data"] = o.Data - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *ReadStackUserAccess) UnmarshalJSON(data []byte) (err error) { - varReadStackUserAccess := _ReadStackUserAccess{} - - err = json.Unmarshal(data, &varReadStackUserAccess) - - if err != nil { - return err - } - - *o = ReadStackUserAccess(varReadStackUserAccess) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableReadStackUserAccess struct { - value *ReadStackUserAccess - isSet bool -} - -func (v NullableReadStackUserAccess) Get() *ReadStackUserAccess { - return v.value -} - -func (v *NullableReadStackUserAccess) Set(val *ReadStackUserAccess) { - v.value = val - v.isSet = true -} - -func (v NullableReadStackUserAccess) IsSet() bool { - return v.isSet -} - -func (v *NullableReadStackUserAccess) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableReadStackUserAccess(val *ReadStackUserAccess) *NullableReadStackUserAccess { - return &NullableReadStackUserAccess{value: val, isSet: true} -} - -func (v NullableReadStackUserAccess) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableReadStackUserAccess) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_read_user_response.go b/membershipclient/model_read_user_response.go deleted file mode 100644 index c3485024..00000000 --- a/membershipclient/model_read_user_response.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the ReadUserResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ReadUserResponse{} - -// ReadUserResponse struct for ReadUserResponse -type ReadUserResponse struct { - Data *User `json:"data,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _ReadUserResponse ReadUserResponse - -// NewReadUserResponse instantiates a new ReadUserResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewReadUserResponse() *ReadUserResponse { - this := ReadUserResponse{} - return &this -} - -// NewReadUserResponseWithDefaults instantiates a new ReadUserResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewReadUserResponseWithDefaults() *ReadUserResponse { - this := ReadUserResponse{} - return &this -} - -// GetData returns the Data field value if set, zero value otherwise. -func (o *ReadUserResponse) GetData() User { - if o == nil || IsNil(o.Data) { - var ret User - return ret - } - return *o.Data -} - -// GetDataOk returns a tuple with the Data field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *ReadUserResponse) GetDataOk() (*User, bool) { - if o == nil || IsNil(o.Data) { - return nil, false - } - return o.Data, true -} - -// HasData returns a boolean if a field has been set. -func (o *ReadUserResponse) HasData() bool { - if o != nil && !IsNil(o.Data) { - return true - } - - return false -} - -// SetData gets a reference to the given User and assigns it to the Data field. -func (o *ReadUserResponse) SetData(v User) { - o.Data = &v -} - -func (o ReadUserResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ReadUserResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Data) { - toSerialize["data"] = o.Data - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *ReadUserResponse) UnmarshalJSON(data []byte) (err error) { - varReadUserResponse := _ReadUserResponse{} - - err = json.Unmarshal(data, &varReadUserResponse) - - if err != nil { - return err - } - - *o = ReadUserResponse(varReadUserResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableReadUserResponse struct { - value *ReadUserResponse - isSet bool -} - -func (v NullableReadUserResponse) Get() *ReadUserResponse { - return v.value -} - -func (v *NullableReadUserResponse) Set(val *ReadUserResponse) { - v.value = val - v.isSet = true -} - -func (v NullableReadUserResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableReadUserResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableReadUserResponse(val *ReadUserResponse) *NullableReadUserResponse { - return &NullableReadUserResponse{value: val, isSet: true} -} - -func (v NullableReadUserResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableReadUserResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_region.go b/membershipclient/model_region.go deleted file mode 100644 index 0ac9cbe7..00000000 --- a/membershipclient/model_region.go +++ /dev/null @@ -1,483 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "time" - "fmt" -) - -// checks if the Region type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &Region{} - -// Region struct for Region -type Region struct { - Id string `json:"id"` - BaseUrl string `json:"baseUrl"` - CreatedAt string `json:"createdAt"` - Active bool `json:"active"` - LastPing *time.Time `json:"lastPing,omitempty"` - Name string `json:"name"` - Capabilities RegionCapability `json:"capabilities"` - AgentID string `json:"agentID"` - Outdated bool `json:"outdated"` - CreatorId *string `json:"creatorId,omitempty"` - Version *string `json:"version,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _Region Region - -// NewRegion instantiates a new Region object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewRegion(id string, baseUrl string, createdAt string, active bool, name string, capabilities RegionCapability, agentID string, outdated bool) *Region { - this := Region{} - this.Id = id - this.BaseUrl = baseUrl - this.CreatedAt = createdAt - this.Active = active - this.Name = name - this.Capabilities = capabilities - this.AgentID = agentID - this.Outdated = outdated - return &this -} - -// NewRegionWithDefaults instantiates a new Region object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewRegionWithDefaults() *Region { - this := Region{} - return &this -} - -// GetId returns the Id field value -func (o *Region) GetId() string { - if o == nil { - var ret string - return ret - } - - return o.Id -} - -// GetIdOk returns a tuple with the Id field value -// and a boolean to check if the value has been set. -func (o *Region) GetIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Id, true -} - -// SetId sets field value -func (o *Region) SetId(v string) { - o.Id = v -} - -// GetBaseUrl returns the BaseUrl field value -func (o *Region) GetBaseUrl() string { - if o == nil { - var ret string - return ret - } - - return o.BaseUrl -} - -// GetBaseUrlOk returns a tuple with the BaseUrl field value -// and a boolean to check if the value has been set. -func (o *Region) GetBaseUrlOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.BaseUrl, true -} - -// SetBaseUrl sets field value -func (o *Region) SetBaseUrl(v string) { - o.BaseUrl = v -} - -// GetCreatedAt returns the CreatedAt field value -func (o *Region) GetCreatedAt() string { - if o == nil { - var ret string - return ret - } - - return o.CreatedAt -} - -// GetCreatedAtOk returns a tuple with the CreatedAt field value -// and a boolean to check if the value has been set. -func (o *Region) GetCreatedAtOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.CreatedAt, true -} - -// SetCreatedAt sets field value -func (o *Region) SetCreatedAt(v string) { - o.CreatedAt = v -} - -// GetActive returns the Active field value -func (o *Region) GetActive() bool { - if o == nil { - var ret bool - return ret - } - - return o.Active -} - -// GetActiveOk returns a tuple with the Active field value -// and a boolean to check if the value has been set. -func (o *Region) GetActiveOk() (*bool, bool) { - if o == nil { - return nil, false - } - return &o.Active, true -} - -// SetActive sets field value -func (o *Region) SetActive(v bool) { - o.Active = v -} - -// GetLastPing returns the LastPing field value if set, zero value otherwise. -func (o *Region) GetLastPing() time.Time { - if o == nil || IsNil(o.LastPing) { - var ret time.Time - return ret - } - return *o.LastPing -} - -// GetLastPingOk returns a tuple with the LastPing field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Region) GetLastPingOk() (*time.Time, bool) { - if o == nil || IsNil(o.LastPing) { - return nil, false - } - return o.LastPing, true -} - -// HasLastPing returns a boolean if a field has been set. -func (o *Region) HasLastPing() bool { - if o != nil && !IsNil(o.LastPing) { - return true - } - - return false -} - -// SetLastPing gets a reference to the given time.Time and assigns it to the LastPing field. -func (o *Region) SetLastPing(v time.Time) { - o.LastPing = &v -} - -// GetName returns the Name field value -func (o *Region) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *Region) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *Region) SetName(v string) { - o.Name = v -} - -// GetCapabilities returns the Capabilities field value -func (o *Region) GetCapabilities() RegionCapability { - if o == nil { - var ret RegionCapability - return ret - } - - return o.Capabilities -} - -// GetCapabilitiesOk returns a tuple with the Capabilities field value -// and a boolean to check if the value has been set. -func (o *Region) GetCapabilitiesOk() (*RegionCapability, bool) { - if o == nil { - return nil, false - } - return &o.Capabilities, true -} - -// SetCapabilities sets field value -func (o *Region) SetCapabilities(v RegionCapability) { - o.Capabilities = v -} - -// GetAgentID returns the AgentID field value -func (o *Region) GetAgentID() string { - if o == nil { - var ret string - return ret - } - - return o.AgentID -} - -// GetAgentIDOk returns a tuple with the AgentID field value -// and a boolean to check if the value has been set. -func (o *Region) GetAgentIDOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.AgentID, true -} - -// SetAgentID sets field value -func (o *Region) SetAgentID(v string) { - o.AgentID = v -} - -// GetOutdated returns the Outdated field value -func (o *Region) GetOutdated() bool { - if o == nil { - var ret bool - return ret - } - - return o.Outdated -} - -// GetOutdatedOk returns a tuple with the Outdated field value -// and a boolean to check if the value has been set. -func (o *Region) GetOutdatedOk() (*bool, bool) { - if o == nil { - return nil, false - } - return &o.Outdated, true -} - -// SetOutdated sets field value -func (o *Region) SetOutdated(v bool) { - o.Outdated = v -} - -// GetCreatorId returns the CreatorId field value if set, zero value otherwise. -func (o *Region) GetCreatorId() string { - if o == nil || IsNil(o.CreatorId) { - var ret string - return ret - } - return *o.CreatorId -} - -// GetCreatorIdOk returns a tuple with the CreatorId field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Region) GetCreatorIdOk() (*string, bool) { - if o == nil || IsNil(o.CreatorId) { - return nil, false - } - return o.CreatorId, true -} - -// HasCreatorId returns a boolean if a field has been set. -func (o *Region) HasCreatorId() bool { - if o != nil && !IsNil(o.CreatorId) { - return true - } - - return false -} - -// SetCreatorId gets a reference to the given string and assigns it to the CreatorId field. -func (o *Region) SetCreatorId(v string) { - o.CreatorId = &v -} - -// GetVersion returns the Version field value if set, zero value otherwise. -func (o *Region) GetVersion() string { - if o == nil || IsNil(o.Version) { - var ret string - return ret - } - return *o.Version -} - -// GetVersionOk returns a tuple with the Version field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Region) GetVersionOk() (*string, bool) { - if o == nil || IsNil(o.Version) { - return nil, false - } - return o.Version, true -} - -// HasVersion returns a boolean if a field has been set. -func (o *Region) HasVersion() bool { - if o != nil && !IsNil(o.Version) { - return true - } - - return false -} - -// SetVersion gets a reference to the given string and assigns it to the Version field. -func (o *Region) SetVersion(v string) { - o.Version = &v -} - -func (o Region) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o Region) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["id"] = o.Id - toSerialize["baseUrl"] = o.BaseUrl - toSerialize["createdAt"] = o.CreatedAt - toSerialize["active"] = o.Active - if !IsNil(o.LastPing) { - toSerialize["lastPing"] = o.LastPing - } - toSerialize["name"] = o.Name - toSerialize["capabilities"] = o.Capabilities - toSerialize["agentID"] = o.AgentID - toSerialize["outdated"] = o.Outdated - if !IsNil(o.CreatorId) { - toSerialize["creatorId"] = o.CreatorId - } - if !IsNil(o.Version) { - toSerialize["version"] = o.Version - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *Region) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "id", - "baseUrl", - "createdAt", - "active", - "name", - "capabilities", - "agentID", - "outdated", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varRegion := _Region{} - - err = json.Unmarshal(data, &varRegion) - - if err != nil { - return err - } - - *o = Region(varRegion) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "id") - delete(additionalProperties, "baseUrl") - delete(additionalProperties, "createdAt") - delete(additionalProperties, "active") - delete(additionalProperties, "lastPing") - delete(additionalProperties, "name") - delete(additionalProperties, "capabilities") - delete(additionalProperties, "agentID") - delete(additionalProperties, "outdated") - delete(additionalProperties, "creatorId") - delete(additionalProperties, "version") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableRegion struct { - value *Region - isSet bool -} - -func (v NullableRegion) Get() *Region { - return v.value -} - -func (v *NullableRegion) Set(val *Region) { - v.value = val - v.isSet = true -} - -func (v NullableRegion) IsSet() bool { - return v.isSet -} - -func (v *NullableRegion) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableRegion(val *Region) *NullableRegion { - return &NullableRegion{value: val, isSet: true} -} - -func (v NullableRegion) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableRegion) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_region_capability.go b/membershipclient/model_region_capability.go deleted file mode 100644 index 47eb6fca..00000000 --- a/membershipclient/model_region_capability.go +++ /dev/null @@ -1,192 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the RegionCapability type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &RegionCapability{} - -// RegionCapability struct for RegionCapability -type RegionCapability struct { - MODULE_LIST []string `json:"MODULE_LIST,omitempty"` - EE []string `json:"EE,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _RegionCapability RegionCapability - -// NewRegionCapability instantiates a new RegionCapability object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewRegionCapability() *RegionCapability { - this := RegionCapability{} - return &this -} - -// NewRegionCapabilityWithDefaults instantiates a new RegionCapability object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewRegionCapabilityWithDefaults() *RegionCapability { - this := RegionCapability{} - return &this -} - -// GetMODULE_LIST returns the MODULE_LIST field value if set, zero value otherwise. -func (o *RegionCapability) GetMODULE_LIST() []string { - if o == nil || IsNil(o.MODULE_LIST) { - var ret []string - return ret - } - return o.MODULE_LIST -} - -// GetMODULE_LISTOk returns a tuple with the MODULE_LIST field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *RegionCapability) GetMODULE_LISTOk() ([]string, bool) { - if o == nil || IsNil(o.MODULE_LIST) { - return nil, false - } - return o.MODULE_LIST, true -} - -// HasMODULE_LIST returns a boolean if a field has been set. -func (o *RegionCapability) HasMODULE_LIST() bool { - if o != nil && !IsNil(o.MODULE_LIST) { - return true - } - - return false -} - -// SetMODULE_LIST gets a reference to the given []string and assigns it to the MODULE_LIST field. -func (o *RegionCapability) SetMODULE_LIST(v []string) { - o.MODULE_LIST = v -} - -// GetEE returns the EE field value if set, zero value otherwise. -func (o *RegionCapability) GetEE() []string { - if o == nil || IsNil(o.EE) { - var ret []string - return ret - } - return o.EE -} - -// GetEEOk returns a tuple with the EE field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *RegionCapability) GetEEOk() ([]string, bool) { - if o == nil || IsNil(o.EE) { - return nil, false - } - return o.EE, true -} - -// HasEE returns a boolean if a field has been set. -func (o *RegionCapability) HasEE() bool { - if o != nil && !IsNil(o.EE) { - return true - } - - return false -} - -// SetEE gets a reference to the given []string and assigns it to the EE field. -func (o *RegionCapability) SetEE(v []string) { - o.EE = v -} - -func (o RegionCapability) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o RegionCapability) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.MODULE_LIST) { - toSerialize["MODULE_LIST"] = o.MODULE_LIST - } - if !IsNil(o.EE) { - toSerialize["EE"] = o.EE - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *RegionCapability) UnmarshalJSON(data []byte) (err error) { - varRegionCapability := _RegionCapability{} - - err = json.Unmarshal(data, &varRegionCapability) - - if err != nil { - return err - } - - *o = RegionCapability(varRegionCapability) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "MODULE_LIST") - delete(additionalProperties, "EE") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableRegionCapability struct { - value *RegionCapability - isSet bool -} - -func (v NullableRegionCapability) Get() *RegionCapability { - return v.value -} - -func (v *NullableRegionCapability) Set(val *RegionCapability) { - v.value = val - v.isSet = true -} - -func (v NullableRegionCapability) IsSet() bool { - return v.isSet -} - -func (v *NullableRegionCapability) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableRegionCapability(val *RegionCapability) *NullableRegionCapability { - return &NullableRegionCapability{value: val, isSet: true} -} - -func (v NullableRegionCapability) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableRegionCapability) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_region_capability_keys.go b/membershipclient/model_region_capability_keys.go deleted file mode 100644 index 76e65e81..00000000 --- a/membershipclient/model_region_capability_keys.go +++ /dev/null @@ -1,111 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// RegionCapabilityKeys the model 'RegionCapabilityKeys' -type RegionCapabilityKeys string - -// List of RegionCapabilityKeys -const ( - MODULE_LIST RegionCapabilityKeys = "MODULE_LIST" - EE RegionCapabilityKeys = "EE" -) - -// All allowed values of RegionCapabilityKeys enum -var AllowedRegionCapabilityKeysEnumValues = []RegionCapabilityKeys{ - "MODULE_LIST", - "EE", -} - -func (v *RegionCapabilityKeys) UnmarshalJSON(src []byte) error { - var value string - err := json.Unmarshal(src, &value) - if err != nil { - return err - } - enumTypeValue := RegionCapabilityKeys(value) - for _, existing := range AllowedRegionCapabilityKeysEnumValues { - if existing == enumTypeValue { - *v = enumTypeValue - return nil - } - } - - return fmt.Errorf("%+v is not a valid RegionCapabilityKeys", value) -} - -// NewRegionCapabilityKeysFromValue returns a pointer to a valid RegionCapabilityKeys -// for the value passed as argument, or an error if the value passed is not allowed by the enum -func NewRegionCapabilityKeysFromValue(v string) (*RegionCapabilityKeys, error) { - ev := RegionCapabilityKeys(v) - if ev.IsValid() { - return &ev, nil - } else { - return nil, fmt.Errorf("invalid value '%v' for RegionCapabilityKeys: valid values are %v", v, AllowedRegionCapabilityKeysEnumValues) - } -} - -// IsValid return true if the value is valid for the enum, false otherwise -func (v RegionCapabilityKeys) IsValid() bool { - for _, existing := range AllowedRegionCapabilityKeysEnumValues { - if existing == v { - return true - } - } - return false -} - -// Ptr returns reference to RegionCapabilityKeys value -func (v RegionCapabilityKeys) Ptr() *RegionCapabilityKeys { - return &v -} - -type NullableRegionCapabilityKeys struct { - value *RegionCapabilityKeys - isSet bool -} - -func (v NullableRegionCapabilityKeys) Get() *RegionCapabilityKeys { - return v.value -} - -func (v *NullableRegionCapabilityKeys) Set(val *RegionCapabilityKeys) { - v.value = val - v.isSet = true -} - -func (v NullableRegionCapabilityKeys) IsSet() bool { - return v.isSet -} - -func (v *NullableRegionCapabilityKeys) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableRegionCapabilityKeys(val *RegionCapabilityKeys) *NullableRegionCapabilityKeys { - return &NullableRegionCapabilityKeys{value: val, isSet: true} -} - -func (v NullableRegionCapabilityKeys) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableRegionCapabilityKeys) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - diff --git a/membershipclient/model_role.go b/membershipclient/model_role.go deleted file mode 100644 index 5642ac2f..00000000 --- a/membershipclient/model_role.go +++ /dev/null @@ -1,113 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// Role the model 'Role' -type Role string - -// List of Role -const ( - NONE Role = "NONE" - ADMIN Role = "ADMIN" - GUEST Role = "GUEST" -) - -// All allowed values of Role enum -var AllowedRoleEnumValues = []Role{ - "NONE", - "ADMIN", - "GUEST", -} - -func (v *Role) UnmarshalJSON(src []byte) error { - var value string - err := json.Unmarshal(src, &value) - if err != nil { - return err - } - enumTypeValue := Role(value) - for _, existing := range AllowedRoleEnumValues { - if existing == enumTypeValue { - *v = enumTypeValue - return nil - } - } - - return fmt.Errorf("%+v is not a valid Role", value) -} - -// NewRoleFromValue returns a pointer to a valid Role -// for the value passed as argument, or an error if the value passed is not allowed by the enum -func NewRoleFromValue(v string) (*Role, error) { - ev := Role(v) - if ev.IsValid() { - return &ev, nil - } else { - return nil, fmt.Errorf("invalid value '%v' for Role: valid values are %v", v, AllowedRoleEnumValues) - } -} - -// IsValid return true if the value is valid for the enum, false otherwise -func (v Role) IsValid() bool { - for _, existing := range AllowedRoleEnumValues { - if existing == v { - return true - } - } - return false -} - -// Ptr returns reference to Role value -func (v Role) Ptr() *Role { - return &v -} - -type NullableRole struct { - value *Role - isSet bool -} - -func (v NullableRole) Get() *Role { - return v.value -} - -func (v *NullableRole) Set(val *Role) { - v.value = val - v.isSet = true -} - -func (v NullableRole) IsSet() bool { - return v.isSet -} - -func (v *NullableRole) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableRole(val *Role) *NullableRole { - return &NullableRole{value: val, isSet: true} -} - -func (v NullableRole) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableRole) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - diff --git a/membershipclient/model_server_info.go b/membershipclient/model_server_info.go deleted file mode 100644 index 143b73cd..00000000 --- a/membershipclient/model_server_info.go +++ /dev/null @@ -1,242 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the ServerInfo type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &ServerInfo{} - -// ServerInfo struct for ServerInfo -type ServerInfo struct { - Version string `json:"version"` - Capabilities []Capability `json:"capabilities,omitempty"` - ConsoleURL *string `json:"consoleURL,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _ServerInfo ServerInfo - -// NewServerInfo instantiates a new ServerInfo object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewServerInfo(version string) *ServerInfo { - this := ServerInfo{} - this.Version = version - return &this -} - -// NewServerInfoWithDefaults instantiates a new ServerInfo object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewServerInfoWithDefaults() *ServerInfo { - this := ServerInfo{} - return &this -} - -// GetVersion returns the Version field value -func (o *ServerInfo) GetVersion() string { - if o == nil { - var ret string - return ret - } - - return o.Version -} - -// GetVersionOk returns a tuple with the Version field value -// and a boolean to check if the value has been set. -func (o *ServerInfo) GetVersionOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Version, true -} - -// SetVersion sets field value -func (o *ServerInfo) SetVersion(v string) { - o.Version = v -} - -// GetCapabilities returns the Capabilities field value if set, zero value otherwise. -func (o *ServerInfo) GetCapabilities() []Capability { - if o == nil || IsNil(o.Capabilities) { - var ret []Capability - return ret - } - return o.Capabilities -} - -// GetCapabilitiesOk returns a tuple with the Capabilities field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *ServerInfo) GetCapabilitiesOk() ([]Capability, bool) { - if o == nil || IsNil(o.Capabilities) { - return nil, false - } - return o.Capabilities, true -} - -// HasCapabilities returns a boolean if a field has been set. -func (o *ServerInfo) HasCapabilities() bool { - if o != nil && !IsNil(o.Capabilities) { - return true - } - - return false -} - -// SetCapabilities gets a reference to the given []Capability and assigns it to the Capabilities field. -func (o *ServerInfo) SetCapabilities(v []Capability) { - o.Capabilities = v -} - -// GetConsoleURL returns the ConsoleURL field value if set, zero value otherwise. -func (o *ServerInfo) GetConsoleURL() string { - if o == nil || IsNil(o.ConsoleURL) { - var ret string - return ret - } - return *o.ConsoleURL -} - -// GetConsoleURLOk returns a tuple with the ConsoleURL field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *ServerInfo) GetConsoleURLOk() (*string, bool) { - if o == nil || IsNil(o.ConsoleURL) { - return nil, false - } - return o.ConsoleURL, true -} - -// HasConsoleURL returns a boolean if a field has been set. -func (o *ServerInfo) HasConsoleURL() bool { - if o != nil && !IsNil(o.ConsoleURL) { - return true - } - - return false -} - -// SetConsoleURL gets a reference to the given string and assigns it to the ConsoleURL field. -func (o *ServerInfo) SetConsoleURL(v string) { - o.ConsoleURL = &v -} - -func (o ServerInfo) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o ServerInfo) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["version"] = o.Version - if !IsNil(o.Capabilities) { - toSerialize["capabilities"] = o.Capabilities - } - if !IsNil(o.ConsoleURL) { - toSerialize["consoleURL"] = o.ConsoleURL - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *ServerInfo) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "version", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varServerInfo := _ServerInfo{} - - err = json.Unmarshal(data, &varServerInfo) - - if err != nil { - return err - } - - *o = ServerInfo(varServerInfo) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "version") - delete(additionalProperties, "capabilities") - delete(additionalProperties, "consoleURL") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableServerInfo struct { - value *ServerInfo - isSet bool -} - -func (v NullableServerInfo) Get() *ServerInfo { - return v.value -} - -func (v *NullableServerInfo) Set(val *ServerInfo) { - v.value = val - v.isSet = true -} - -func (v NullableServerInfo) IsSet() bool { - return v.isSet -} - -func (v *NullableServerInfo) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableServerInfo(val *ServerInfo) *NullableServerInfo { - return &NullableServerInfo{value: val, isSet: true} -} - -func (v NullableServerInfo) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableServerInfo) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_stack.go b/membershipclient/model_stack.go deleted file mode 100644 index 4d0c036e..00000000 --- a/membershipclient/model_stack.go +++ /dev/null @@ -1,990 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "time" - "fmt" -) - -// checks if the Stack type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &Stack{} - -// Stack struct for Stack -type Stack struct { - // Stack name - Name string `json:"name"` - Metadata *map[string]string `json:"metadata,omitempty"` - // Supported only with agent version >= v0.7.0 - Version *string `json:"version,omitempty"` - Status string `json:"status"` - State string `json:"state"` - ExpectedStatus string `json:"expectedStatus"` - LastStateUpdate time.Time `json:"lastStateUpdate"` - LastExpectedStatusUpdate time.Time `json:"lastExpectedStatusUpdate"` - LastStatusUpdate time.Time `json:"lastStatusUpdate"` - WarnedAt *time.Time `json:"warnedAt,omitempty"` - DisposableSince *time.Time `json:"disposableSince,omitempty"` - // Stack is reachable through Stargate - Reachable bool `json:"reachable"` - // Last time the stack was reachable - LastReachableUpdate *time.Time `json:"lastReachableUpdate,omitempty"` - // Stack ID - Id string `json:"id"` - // Organization ID - OrganizationId string `json:"organizationId"` - // Base stack uri - Uri string `json:"uri"` - // The region where the stack is installed - RegionID string `json:"regionID"` - Region *Region `json:"region,omitempty"` - StargateEnabled bool `json:"stargateEnabled"` - CreatedAt *time.Time `json:"createdAt,omitempty"` - DeletedAt *time.Time `json:"deletedAt,omitempty"` - DisabledAt *time.Time `json:"disabledAt,omitempty"` - AuditEnabled *bool `json:"auditEnabled,omitempty"` - Synchronised bool `json:"synchronised"` - UpdatedAt *time.Time `json:"updatedAt,omitempty"` - Modules []Module `json:"modules"` - AdditionalProperties map[string]interface{} -} - -type _Stack Stack - -// NewStack instantiates a new Stack object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewStack(name string, status string, state string, expectedStatus string, lastStateUpdate time.Time, lastExpectedStatusUpdate time.Time, lastStatusUpdate time.Time, reachable bool, id string, organizationId string, uri string, regionID string, stargateEnabled bool, synchronised bool, modules []Module) *Stack { - this := Stack{} - this.Name = name - this.Status = status - this.State = state - this.ExpectedStatus = expectedStatus - this.LastStateUpdate = lastStateUpdate - this.LastExpectedStatusUpdate = lastExpectedStatusUpdate - this.LastStatusUpdate = lastStatusUpdate - this.Reachable = reachable - this.Id = id - this.OrganizationId = organizationId - this.Uri = uri - this.RegionID = regionID - this.StargateEnabled = stargateEnabled - this.Synchronised = synchronised - this.Modules = modules - return &this -} - -// NewStackWithDefaults instantiates a new Stack object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewStackWithDefaults() *Stack { - this := Stack{} - return &this -} - -// GetName returns the Name field value -func (o *Stack) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *Stack) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *Stack) SetName(v string) { - o.Name = v -} - -// GetMetadata returns the Metadata field value if set, zero value otherwise. -func (o *Stack) GetMetadata() map[string]string { - if o == nil || IsNil(o.Metadata) { - var ret map[string]string - return ret - } - return *o.Metadata -} - -// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Stack) GetMetadataOk() (*map[string]string, bool) { - if o == nil || IsNil(o.Metadata) { - return nil, false - } - return o.Metadata, true -} - -// HasMetadata returns a boolean if a field has been set. -func (o *Stack) HasMetadata() bool { - if o != nil && !IsNil(o.Metadata) { - return true - } - - return false -} - -// SetMetadata gets a reference to the given map[string]string and assigns it to the Metadata field. -func (o *Stack) SetMetadata(v map[string]string) { - o.Metadata = &v -} - -// GetVersion returns the Version field value if set, zero value otherwise. -func (o *Stack) GetVersion() string { - if o == nil || IsNil(o.Version) { - var ret string - return ret - } - return *o.Version -} - -// GetVersionOk returns a tuple with the Version field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Stack) GetVersionOk() (*string, bool) { - if o == nil || IsNil(o.Version) { - return nil, false - } - return o.Version, true -} - -// HasVersion returns a boolean if a field has been set. -func (o *Stack) HasVersion() bool { - if o != nil && !IsNil(o.Version) { - return true - } - - return false -} - -// SetVersion gets a reference to the given string and assigns it to the Version field. -func (o *Stack) SetVersion(v string) { - o.Version = &v -} - -// GetStatus returns the Status field value -func (o *Stack) GetStatus() string { - if o == nil { - var ret string - return ret - } - - return o.Status -} - -// GetStatusOk returns a tuple with the Status field value -// and a boolean to check if the value has been set. -func (o *Stack) GetStatusOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Status, true -} - -// SetStatus sets field value -func (o *Stack) SetStatus(v string) { - o.Status = v -} - -// GetState returns the State field value -func (o *Stack) GetState() string { - if o == nil { - var ret string - return ret - } - - return o.State -} - -// GetStateOk returns a tuple with the State field value -// and a boolean to check if the value has been set. -func (o *Stack) GetStateOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.State, true -} - -// SetState sets field value -func (o *Stack) SetState(v string) { - o.State = v -} - -// GetExpectedStatus returns the ExpectedStatus field value -func (o *Stack) GetExpectedStatus() string { - if o == nil { - var ret string - return ret - } - - return o.ExpectedStatus -} - -// GetExpectedStatusOk returns a tuple with the ExpectedStatus field value -// and a boolean to check if the value has been set. -func (o *Stack) GetExpectedStatusOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ExpectedStatus, true -} - -// SetExpectedStatus sets field value -func (o *Stack) SetExpectedStatus(v string) { - o.ExpectedStatus = v -} - -// GetLastStateUpdate returns the LastStateUpdate field value -func (o *Stack) GetLastStateUpdate() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.LastStateUpdate -} - -// GetLastStateUpdateOk returns a tuple with the LastStateUpdate field value -// and a boolean to check if the value has been set. -func (o *Stack) GetLastStateUpdateOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.LastStateUpdate, true -} - -// SetLastStateUpdate sets field value -func (o *Stack) SetLastStateUpdate(v time.Time) { - o.LastStateUpdate = v -} - -// GetLastExpectedStatusUpdate returns the LastExpectedStatusUpdate field value -func (o *Stack) GetLastExpectedStatusUpdate() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.LastExpectedStatusUpdate -} - -// GetLastExpectedStatusUpdateOk returns a tuple with the LastExpectedStatusUpdate field value -// and a boolean to check if the value has been set. -func (o *Stack) GetLastExpectedStatusUpdateOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.LastExpectedStatusUpdate, true -} - -// SetLastExpectedStatusUpdate sets field value -func (o *Stack) SetLastExpectedStatusUpdate(v time.Time) { - o.LastExpectedStatusUpdate = v -} - -// GetLastStatusUpdate returns the LastStatusUpdate field value -func (o *Stack) GetLastStatusUpdate() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.LastStatusUpdate -} - -// GetLastStatusUpdateOk returns a tuple with the LastStatusUpdate field value -// and a boolean to check if the value has been set. -func (o *Stack) GetLastStatusUpdateOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.LastStatusUpdate, true -} - -// SetLastStatusUpdate sets field value -func (o *Stack) SetLastStatusUpdate(v time.Time) { - o.LastStatusUpdate = v -} - -// GetWarnedAt returns the WarnedAt field value if set, zero value otherwise. -func (o *Stack) GetWarnedAt() time.Time { - if o == nil || IsNil(o.WarnedAt) { - var ret time.Time - return ret - } - return *o.WarnedAt -} - -// GetWarnedAtOk returns a tuple with the WarnedAt field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Stack) GetWarnedAtOk() (*time.Time, bool) { - if o == nil || IsNil(o.WarnedAt) { - return nil, false - } - return o.WarnedAt, true -} - -// HasWarnedAt returns a boolean if a field has been set. -func (o *Stack) HasWarnedAt() bool { - if o != nil && !IsNil(o.WarnedAt) { - return true - } - - return false -} - -// SetWarnedAt gets a reference to the given time.Time and assigns it to the WarnedAt field. -func (o *Stack) SetWarnedAt(v time.Time) { - o.WarnedAt = &v -} - -// GetDisposableSince returns the DisposableSince field value if set, zero value otherwise. -func (o *Stack) GetDisposableSince() time.Time { - if o == nil || IsNil(o.DisposableSince) { - var ret time.Time - return ret - } - return *o.DisposableSince -} - -// GetDisposableSinceOk returns a tuple with the DisposableSince field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Stack) GetDisposableSinceOk() (*time.Time, bool) { - if o == nil || IsNil(o.DisposableSince) { - return nil, false - } - return o.DisposableSince, true -} - -// HasDisposableSince returns a boolean if a field has been set. -func (o *Stack) HasDisposableSince() bool { - if o != nil && !IsNil(o.DisposableSince) { - return true - } - - return false -} - -// SetDisposableSince gets a reference to the given time.Time and assigns it to the DisposableSince field. -func (o *Stack) SetDisposableSince(v time.Time) { - o.DisposableSince = &v -} - -// GetReachable returns the Reachable field value -func (o *Stack) GetReachable() bool { - if o == nil { - var ret bool - return ret - } - - return o.Reachable -} - -// GetReachableOk returns a tuple with the Reachable field value -// and a boolean to check if the value has been set. -func (o *Stack) GetReachableOk() (*bool, bool) { - if o == nil { - return nil, false - } - return &o.Reachable, true -} - -// SetReachable sets field value -func (o *Stack) SetReachable(v bool) { - o.Reachable = v -} - -// GetLastReachableUpdate returns the LastReachableUpdate field value if set, zero value otherwise. -func (o *Stack) GetLastReachableUpdate() time.Time { - if o == nil || IsNil(o.LastReachableUpdate) { - var ret time.Time - return ret - } - return *o.LastReachableUpdate -} - -// GetLastReachableUpdateOk returns a tuple with the LastReachableUpdate field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Stack) GetLastReachableUpdateOk() (*time.Time, bool) { - if o == nil || IsNil(o.LastReachableUpdate) { - return nil, false - } - return o.LastReachableUpdate, true -} - -// HasLastReachableUpdate returns a boolean if a field has been set. -func (o *Stack) HasLastReachableUpdate() bool { - if o != nil && !IsNil(o.LastReachableUpdate) { - return true - } - - return false -} - -// SetLastReachableUpdate gets a reference to the given time.Time and assigns it to the LastReachableUpdate field. -func (o *Stack) SetLastReachableUpdate(v time.Time) { - o.LastReachableUpdate = &v -} - -// GetId returns the Id field value -func (o *Stack) GetId() string { - if o == nil { - var ret string - return ret - } - - return o.Id -} - -// GetIdOk returns a tuple with the Id field value -// and a boolean to check if the value has been set. -func (o *Stack) GetIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Id, true -} - -// SetId sets field value -func (o *Stack) SetId(v string) { - o.Id = v -} - -// GetOrganizationId returns the OrganizationId field value -func (o *Stack) GetOrganizationId() string { - if o == nil { - var ret string - return ret - } - - return o.OrganizationId -} - -// GetOrganizationIdOk returns a tuple with the OrganizationId field value -// and a boolean to check if the value has been set. -func (o *Stack) GetOrganizationIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.OrganizationId, true -} - -// SetOrganizationId sets field value -func (o *Stack) SetOrganizationId(v string) { - o.OrganizationId = v -} - -// GetUri returns the Uri field value -func (o *Stack) GetUri() string { - if o == nil { - var ret string - return ret - } - - return o.Uri -} - -// GetUriOk returns a tuple with the Uri field value -// and a boolean to check if the value has been set. -func (o *Stack) GetUriOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Uri, true -} - -// SetUri sets field value -func (o *Stack) SetUri(v string) { - o.Uri = v -} - -// GetRegionID returns the RegionID field value -func (o *Stack) GetRegionID() string { - if o == nil { - var ret string - return ret - } - - return o.RegionID -} - -// GetRegionIDOk returns a tuple with the RegionID field value -// and a boolean to check if the value has been set. -func (o *Stack) GetRegionIDOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.RegionID, true -} - -// SetRegionID sets field value -func (o *Stack) SetRegionID(v string) { - o.RegionID = v -} - -// GetRegion returns the Region field value if set, zero value otherwise. -func (o *Stack) GetRegion() Region { - if o == nil || IsNil(o.Region) { - var ret Region - return ret - } - return *o.Region -} - -// GetRegionOk returns a tuple with the Region field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Stack) GetRegionOk() (*Region, bool) { - if o == nil || IsNil(o.Region) { - return nil, false - } - return o.Region, true -} - -// HasRegion returns a boolean if a field has been set. -func (o *Stack) HasRegion() bool { - if o != nil && !IsNil(o.Region) { - return true - } - - return false -} - -// SetRegion gets a reference to the given Region and assigns it to the Region field. -func (o *Stack) SetRegion(v Region) { - o.Region = &v -} - -// GetStargateEnabled returns the StargateEnabled field value -func (o *Stack) GetStargateEnabled() bool { - if o == nil { - var ret bool - return ret - } - - return o.StargateEnabled -} - -// GetStargateEnabledOk returns a tuple with the StargateEnabled field value -// and a boolean to check if the value has been set. -func (o *Stack) GetStargateEnabledOk() (*bool, bool) { - if o == nil { - return nil, false - } - return &o.StargateEnabled, true -} - -// SetStargateEnabled sets field value -func (o *Stack) SetStargateEnabled(v bool) { - o.StargateEnabled = v -} - -// GetCreatedAt returns the CreatedAt field value if set, zero value otherwise. -func (o *Stack) GetCreatedAt() time.Time { - if o == nil || IsNil(o.CreatedAt) { - var ret time.Time - return ret - } - return *o.CreatedAt -} - -// GetCreatedAtOk returns a tuple with the CreatedAt field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Stack) GetCreatedAtOk() (*time.Time, bool) { - if o == nil || IsNil(o.CreatedAt) { - return nil, false - } - return o.CreatedAt, true -} - -// HasCreatedAt returns a boolean if a field has been set. -func (o *Stack) HasCreatedAt() bool { - if o != nil && !IsNil(o.CreatedAt) { - return true - } - - return false -} - -// SetCreatedAt gets a reference to the given time.Time and assigns it to the CreatedAt field. -func (o *Stack) SetCreatedAt(v time.Time) { - o.CreatedAt = &v -} - -// GetDeletedAt returns the DeletedAt field value if set, zero value otherwise. -func (o *Stack) GetDeletedAt() time.Time { - if o == nil || IsNil(o.DeletedAt) { - var ret time.Time - return ret - } - return *o.DeletedAt -} - -// GetDeletedAtOk returns a tuple with the DeletedAt field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Stack) GetDeletedAtOk() (*time.Time, bool) { - if o == nil || IsNil(o.DeletedAt) { - return nil, false - } - return o.DeletedAt, true -} - -// HasDeletedAt returns a boolean if a field has been set. -func (o *Stack) HasDeletedAt() bool { - if o != nil && !IsNil(o.DeletedAt) { - return true - } - - return false -} - -// SetDeletedAt gets a reference to the given time.Time and assigns it to the DeletedAt field. -func (o *Stack) SetDeletedAt(v time.Time) { - o.DeletedAt = &v -} - -// GetDisabledAt returns the DisabledAt field value if set, zero value otherwise. -func (o *Stack) GetDisabledAt() time.Time { - if o == nil || IsNil(o.DisabledAt) { - var ret time.Time - return ret - } - return *o.DisabledAt -} - -// GetDisabledAtOk returns a tuple with the DisabledAt field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Stack) GetDisabledAtOk() (*time.Time, bool) { - if o == nil || IsNil(o.DisabledAt) { - return nil, false - } - return o.DisabledAt, true -} - -// HasDisabledAt returns a boolean if a field has been set. -func (o *Stack) HasDisabledAt() bool { - if o != nil && !IsNil(o.DisabledAt) { - return true - } - - return false -} - -// SetDisabledAt gets a reference to the given time.Time and assigns it to the DisabledAt field. -func (o *Stack) SetDisabledAt(v time.Time) { - o.DisabledAt = &v -} - -// GetAuditEnabled returns the AuditEnabled field value if set, zero value otherwise. -func (o *Stack) GetAuditEnabled() bool { - if o == nil || IsNil(o.AuditEnabled) { - var ret bool - return ret - } - return *o.AuditEnabled -} - -// GetAuditEnabledOk returns a tuple with the AuditEnabled field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Stack) GetAuditEnabledOk() (*bool, bool) { - if o == nil || IsNil(o.AuditEnabled) { - return nil, false - } - return o.AuditEnabled, true -} - -// HasAuditEnabled returns a boolean if a field has been set. -func (o *Stack) HasAuditEnabled() bool { - if o != nil && !IsNil(o.AuditEnabled) { - return true - } - - return false -} - -// SetAuditEnabled gets a reference to the given bool and assigns it to the AuditEnabled field. -func (o *Stack) SetAuditEnabled(v bool) { - o.AuditEnabled = &v -} - -// GetSynchronised returns the Synchronised field value -func (o *Stack) GetSynchronised() bool { - if o == nil { - var ret bool - return ret - } - - return o.Synchronised -} - -// GetSynchronisedOk returns a tuple with the Synchronised field value -// and a boolean to check if the value has been set. -func (o *Stack) GetSynchronisedOk() (*bool, bool) { - if o == nil { - return nil, false - } - return &o.Synchronised, true -} - -// SetSynchronised sets field value -func (o *Stack) SetSynchronised(v bool) { - o.Synchronised = v -} - -// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise. -func (o *Stack) GetUpdatedAt() time.Time { - if o == nil || IsNil(o.UpdatedAt) { - var ret time.Time - return ret - } - return *o.UpdatedAt -} - -// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *Stack) GetUpdatedAtOk() (*time.Time, bool) { - if o == nil || IsNil(o.UpdatedAt) { - return nil, false - } - return o.UpdatedAt, true -} - -// HasUpdatedAt returns a boolean if a field has been set. -func (o *Stack) HasUpdatedAt() bool { - if o != nil && !IsNil(o.UpdatedAt) { - return true - } - - return false -} - -// SetUpdatedAt gets a reference to the given time.Time and assigns it to the UpdatedAt field. -func (o *Stack) SetUpdatedAt(v time.Time) { - o.UpdatedAt = &v -} - -// GetModules returns the Modules field value -func (o *Stack) GetModules() []Module { - if o == nil { - var ret []Module - return ret - } - - return o.Modules -} - -// GetModulesOk returns a tuple with the Modules field value -// and a boolean to check if the value has been set. -func (o *Stack) GetModulesOk() ([]Module, bool) { - if o == nil { - return nil, false - } - return o.Modules, true -} - -// SetModules sets field value -func (o *Stack) SetModules(v []Module) { - o.Modules = v -} - -func (o Stack) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o Stack) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["name"] = o.Name - if !IsNil(o.Metadata) { - toSerialize["metadata"] = o.Metadata - } - if !IsNil(o.Version) { - toSerialize["version"] = o.Version - } - toSerialize["status"] = o.Status - toSerialize["state"] = o.State - toSerialize["expectedStatus"] = o.ExpectedStatus - toSerialize["lastStateUpdate"] = o.LastStateUpdate - toSerialize["lastExpectedStatusUpdate"] = o.LastExpectedStatusUpdate - toSerialize["lastStatusUpdate"] = o.LastStatusUpdate - if !IsNil(o.WarnedAt) { - toSerialize["warnedAt"] = o.WarnedAt - } - if !IsNil(o.DisposableSince) { - toSerialize["disposableSince"] = o.DisposableSince - } - toSerialize["reachable"] = o.Reachable - if !IsNil(o.LastReachableUpdate) { - toSerialize["lastReachableUpdate"] = o.LastReachableUpdate - } - toSerialize["id"] = o.Id - toSerialize["organizationId"] = o.OrganizationId - toSerialize["uri"] = o.Uri - toSerialize["regionID"] = o.RegionID - if !IsNil(o.Region) { - toSerialize["region"] = o.Region - } - toSerialize["stargateEnabled"] = o.StargateEnabled - if !IsNil(o.CreatedAt) { - toSerialize["createdAt"] = o.CreatedAt - } - if !IsNil(o.DeletedAt) { - toSerialize["deletedAt"] = o.DeletedAt - } - if !IsNil(o.DisabledAt) { - toSerialize["disabledAt"] = o.DisabledAt - } - if !IsNil(o.AuditEnabled) { - toSerialize["auditEnabled"] = o.AuditEnabled - } - toSerialize["synchronised"] = o.Synchronised - if !IsNil(o.UpdatedAt) { - toSerialize["updatedAt"] = o.UpdatedAt - } - toSerialize["modules"] = o.Modules - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *Stack) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "name", - "status", - "state", - "expectedStatus", - "lastStateUpdate", - "lastExpectedStatusUpdate", - "lastStatusUpdate", - "reachable", - "id", - "organizationId", - "uri", - "regionID", - "stargateEnabled", - "synchronised", - "modules", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varStack := _Stack{} - - err = json.Unmarshal(data, &varStack) - - if err != nil { - return err - } - - *o = Stack(varStack) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "name") - delete(additionalProperties, "metadata") - delete(additionalProperties, "version") - delete(additionalProperties, "status") - delete(additionalProperties, "state") - delete(additionalProperties, "expectedStatus") - delete(additionalProperties, "lastStateUpdate") - delete(additionalProperties, "lastExpectedStatusUpdate") - delete(additionalProperties, "lastStatusUpdate") - delete(additionalProperties, "warnedAt") - delete(additionalProperties, "disposableSince") - delete(additionalProperties, "reachable") - delete(additionalProperties, "lastReachableUpdate") - delete(additionalProperties, "id") - delete(additionalProperties, "organizationId") - delete(additionalProperties, "uri") - delete(additionalProperties, "regionID") - delete(additionalProperties, "region") - delete(additionalProperties, "stargateEnabled") - delete(additionalProperties, "createdAt") - delete(additionalProperties, "deletedAt") - delete(additionalProperties, "disabledAt") - delete(additionalProperties, "auditEnabled") - delete(additionalProperties, "synchronised") - delete(additionalProperties, "updatedAt") - delete(additionalProperties, "modules") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableStack struct { - value *Stack - isSet bool -} - -func (v NullableStack) Get() *Stack { - return v.value -} - -func (v *NullableStack) Set(val *Stack) { - v.value = val - v.isSet = true -} - -func (v NullableStack) IsSet() bool { - return v.isSet -} - -func (v *NullableStack) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableStack(val *Stack) *NullableStack { - return &NullableStack{value: val, isSet: true} -} - -func (v NullableStack) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableStack) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_stack_data.go b/membershipclient/model_stack_data.go deleted file mode 100644 index 769df2b9..00000000 --- a/membershipclient/model_stack_data.go +++ /dev/null @@ -1,206 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the StackData type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &StackData{} - -// StackData struct for StackData -type StackData struct { - // Stack name - Name string `json:"name"` - Metadata *map[string]string `json:"metadata,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _StackData StackData - -// NewStackData instantiates a new StackData object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewStackData(name string) *StackData { - this := StackData{} - this.Name = name - return &this -} - -// NewStackDataWithDefaults instantiates a new StackData object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewStackDataWithDefaults() *StackData { - this := StackData{} - return &this -} - -// GetName returns the Name field value -func (o *StackData) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *StackData) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *StackData) SetName(v string) { - o.Name = v -} - -// GetMetadata returns the Metadata field value if set, zero value otherwise. -func (o *StackData) GetMetadata() map[string]string { - if o == nil || IsNil(o.Metadata) { - var ret map[string]string - return ret - } - return *o.Metadata -} - -// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *StackData) GetMetadataOk() (*map[string]string, bool) { - if o == nil || IsNil(o.Metadata) { - return nil, false - } - return o.Metadata, true -} - -// HasMetadata returns a boolean if a field has been set. -func (o *StackData) HasMetadata() bool { - if o != nil && !IsNil(o.Metadata) { - return true - } - - return false -} - -// SetMetadata gets a reference to the given map[string]string and assigns it to the Metadata field. -func (o *StackData) SetMetadata(v map[string]string) { - o.Metadata = &v -} - -func (o StackData) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o StackData) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["name"] = o.Name - if !IsNil(o.Metadata) { - toSerialize["metadata"] = o.Metadata - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *StackData) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "name", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varStackData := _StackData{} - - err = json.Unmarshal(data, &varStackData) - - if err != nil { - return err - } - - *o = StackData(varStackData) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "name") - delete(additionalProperties, "metadata") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableStackData struct { - value *StackData - isSet bool -} - -func (v NullableStackData) Get() *StackData { - return v.value -} - -func (v *NullableStackData) Set(val *StackData) { - v.value = val - v.isSet = true -} - -func (v NullableStackData) IsSet() bool { - return v.isSet -} - -func (v *NullableStackData) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableStackData(val *StackData) *NullableStackData { - return &NullableStackData{value: val, isSet: true} -} - -func (v NullableStackData) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableStackData) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_stack_life_cycle.go b/membershipclient/model_stack_life_cycle.go deleted file mode 100644 index 03922973..00000000 --- a/membershipclient/model_stack_life_cycle.go +++ /dev/null @@ -1,388 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "time" - "fmt" -) - -// checks if the StackLifeCycle type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &StackLifeCycle{} - -// StackLifeCycle struct for StackLifeCycle -type StackLifeCycle struct { - Status string `json:"status"` - State string `json:"state"` - ExpectedStatus string `json:"expectedStatus"` - LastStateUpdate time.Time `json:"lastStateUpdate"` - LastExpectedStatusUpdate time.Time `json:"lastExpectedStatusUpdate"` - LastStatusUpdate time.Time `json:"lastStatusUpdate"` - WarnedAt *time.Time `json:"warnedAt,omitempty"` - DisposableSince *time.Time `json:"disposableSince,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _StackLifeCycle StackLifeCycle - -// NewStackLifeCycle instantiates a new StackLifeCycle object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewStackLifeCycle(status string, state string, expectedStatus string, lastStateUpdate time.Time, lastExpectedStatusUpdate time.Time, lastStatusUpdate time.Time) *StackLifeCycle { - this := StackLifeCycle{} - this.Status = status - this.State = state - this.ExpectedStatus = expectedStatus - this.LastStateUpdate = lastStateUpdate - this.LastExpectedStatusUpdate = lastExpectedStatusUpdate - this.LastStatusUpdate = lastStatusUpdate - return &this -} - -// NewStackLifeCycleWithDefaults instantiates a new StackLifeCycle object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewStackLifeCycleWithDefaults() *StackLifeCycle { - this := StackLifeCycle{} - return &this -} - -// GetStatus returns the Status field value -func (o *StackLifeCycle) GetStatus() string { - if o == nil { - var ret string - return ret - } - - return o.Status -} - -// GetStatusOk returns a tuple with the Status field value -// and a boolean to check if the value has been set. -func (o *StackLifeCycle) GetStatusOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Status, true -} - -// SetStatus sets field value -func (o *StackLifeCycle) SetStatus(v string) { - o.Status = v -} - -// GetState returns the State field value -func (o *StackLifeCycle) GetState() string { - if o == nil { - var ret string - return ret - } - - return o.State -} - -// GetStateOk returns a tuple with the State field value -// and a boolean to check if the value has been set. -func (o *StackLifeCycle) GetStateOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.State, true -} - -// SetState sets field value -func (o *StackLifeCycle) SetState(v string) { - o.State = v -} - -// GetExpectedStatus returns the ExpectedStatus field value -func (o *StackLifeCycle) GetExpectedStatus() string { - if o == nil { - var ret string - return ret - } - - return o.ExpectedStatus -} - -// GetExpectedStatusOk returns a tuple with the ExpectedStatus field value -// and a boolean to check if the value has been set. -func (o *StackLifeCycle) GetExpectedStatusOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.ExpectedStatus, true -} - -// SetExpectedStatus sets field value -func (o *StackLifeCycle) SetExpectedStatus(v string) { - o.ExpectedStatus = v -} - -// GetLastStateUpdate returns the LastStateUpdate field value -func (o *StackLifeCycle) GetLastStateUpdate() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.LastStateUpdate -} - -// GetLastStateUpdateOk returns a tuple with the LastStateUpdate field value -// and a boolean to check if the value has been set. -func (o *StackLifeCycle) GetLastStateUpdateOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.LastStateUpdate, true -} - -// SetLastStateUpdate sets field value -func (o *StackLifeCycle) SetLastStateUpdate(v time.Time) { - o.LastStateUpdate = v -} - -// GetLastExpectedStatusUpdate returns the LastExpectedStatusUpdate field value -func (o *StackLifeCycle) GetLastExpectedStatusUpdate() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.LastExpectedStatusUpdate -} - -// GetLastExpectedStatusUpdateOk returns a tuple with the LastExpectedStatusUpdate field value -// and a boolean to check if the value has been set. -func (o *StackLifeCycle) GetLastExpectedStatusUpdateOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.LastExpectedStatusUpdate, true -} - -// SetLastExpectedStatusUpdate sets field value -func (o *StackLifeCycle) SetLastExpectedStatusUpdate(v time.Time) { - o.LastExpectedStatusUpdate = v -} - -// GetLastStatusUpdate returns the LastStatusUpdate field value -func (o *StackLifeCycle) GetLastStatusUpdate() time.Time { - if o == nil { - var ret time.Time - return ret - } - - return o.LastStatusUpdate -} - -// GetLastStatusUpdateOk returns a tuple with the LastStatusUpdate field value -// and a boolean to check if the value has been set. -func (o *StackLifeCycle) GetLastStatusUpdateOk() (*time.Time, bool) { - if o == nil { - return nil, false - } - return &o.LastStatusUpdate, true -} - -// SetLastStatusUpdate sets field value -func (o *StackLifeCycle) SetLastStatusUpdate(v time.Time) { - o.LastStatusUpdate = v -} - -// GetWarnedAt returns the WarnedAt field value if set, zero value otherwise. -func (o *StackLifeCycle) GetWarnedAt() time.Time { - if o == nil || IsNil(o.WarnedAt) { - var ret time.Time - return ret - } - return *o.WarnedAt -} - -// GetWarnedAtOk returns a tuple with the WarnedAt field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *StackLifeCycle) GetWarnedAtOk() (*time.Time, bool) { - if o == nil || IsNil(o.WarnedAt) { - return nil, false - } - return o.WarnedAt, true -} - -// HasWarnedAt returns a boolean if a field has been set. -func (o *StackLifeCycle) HasWarnedAt() bool { - if o != nil && !IsNil(o.WarnedAt) { - return true - } - - return false -} - -// SetWarnedAt gets a reference to the given time.Time and assigns it to the WarnedAt field. -func (o *StackLifeCycle) SetWarnedAt(v time.Time) { - o.WarnedAt = &v -} - -// GetDisposableSince returns the DisposableSince field value if set, zero value otherwise. -func (o *StackLifeCycle) GetDisposableSince() time.Time { - if o == nil || IsNil(o.DisposableSince) { - var ret time.Time - return ret - } - return *o.DisposableSince -} - -// GetDisposableSinceOk returns a tuple with the DisposableSince field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *StackLifeCycle) GetDisposableSinceOk() (*time.Time, bool) { - if o == nil || IsNil(o.DisposableSince) { - return nil, false - } - return o.DisposableSince, true -} - -// HasDisposableSince returns a boolean if a field has been set. -func (o *StackLifeCycle) HasDisposableSince() bool { - if o != nil && !IsNil(o.DisposableSince) { - return true - } - - return false -} - -// SetDisposableSince gets a reference to the given time.Time and assigns it to the DisposableSince field. -func (o *StackLifeCycle) SetDisposableSince(v time.Time) { - o.DisposableSince = &v -} - -func (o StackLifeCycle) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o StackLifeCycle) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["status"] = o.Status - toSerialize["state"] = o.State - toSerialize["expectedStatus"] = o.ExpectedStatus - toSerialize["lastStateUpdate"] = o.LastStateUpdate - toSerialize["lastExpectedStatusUpdate"] = o.LastExpectedStatusUpdate - toSerialize["lastStatusUpdate"] = o.LastStatusUpdate - if !IsNil(o.WarnedAt) { - toSerialize["warnedAt"] = o.WarnedAt - } - if !IsNil(o.DisposableSince) { - toSerialize["disposableSince"] = o.DisposableSince - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *StackLifeCycle) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "status", - "state", - "expectedStatus", - "lastStateUpdate", - "lastExpectedStatusUpdate", - "lastStatusUpdate", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varStackLifeCycle := _StackLifeCycle{} - - err = json.Unmarshal(data, &varStackLifeCycle) - - if err != nil { - return err - } - - *o = StackLifeCycle(varStackLifeCycle) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "status") - delete(additionalProperties, "state") - delete(additionalProperties, "expectedStatus") - delete(additionalProperties, "lastStateUpdate") - delete(additionalProperties, "lastExpectedStatusUpdate") - delete(additionalProperties, "lastStatusUpdate") - delete(additionalProperties, "warnedAt") - delete(additionalProperties, "disposableSince") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableStackLifeCycle struct { - value *StackLifeCycle - isSet bool -} - -func (v NullableStackLifeCycle) Get() *StackLifeCycle { - return v.value -} - -func (v *NullableStackLifeCycle) Set(val *StackLifeCycle) { - v.value = val - v.isSet = true -} - -func (v NullableStackLifeCycle) IsSet() bool { - return v.isSet -} - -func (v *NullableStackLifeCycle) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableStackLifeCycle(val *StackLifeCycle) *NullableStackLifeCycle { - return &NullableStackLifeCycle{value: val, isSet: true} -} - -func (v NullableStackLifeCycle) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableStackLifeCycle) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_stack_reachability.go b/membershipclient/model_stack_reachability.go deleted file mode 100644 index d18afdca..00000000 --- a/membershipclient/model_stack_reachability.go +++ /dev/null @@ -1,208 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "time" - "fmt" -) - -// checks if the StackReachability type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &StackReachability{} - -// StackReachability struct for StackReachability -type StackReachability struct { - // Stack is reachable through Stargate - Reachable bool `json:"reachable"` - // Last time the stack was reachable - LastReachableUpdate *time.Time `json:"lastReachableUpdate,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _StackReachability StackReachability - -// NewStackReachability instantiates a new StackReachability object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewStackReachability(reachable bool) *StackReachability { - this := StackReachability{} - this.Reachable = reachable - return &this -} - -// NewStackReachabilityWithDefaults instantiates a new StackReachability object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewStackReachabilityWithDefaults() *StackReachability { - this := StackReachability{} - return &this -} - -// GetReachable returns the Reachable field value -func (o *StackReachability) GetReachable() bool { - if o == nil { - var ret bool - return ret - } - - return o.Reachable -} - -// GetReachableOk returns a tuple with the Reachable field value -// and a boolean to check if the value has been set. -func (o *StackReachability) GetReachableOk() (*bool, bool) { - if o == nil { - return nil, false - } - return &o.Reachable, true -} - -// SetReachable sets field value -func (o *StackReachability) SetReachable(v bool) { - o.Reachable = v -} - -// GetLastReachableUpdate returns the LastReachableUpdate field value if set, zero value otherwise. -func (o *StackReachability) GetLastReachableUpdate() time.Time { - if o == nil || IsNil(o.LastReachableUpdate) { - var ret time.Time - return ret - } - return *o.LastReachableUpdate -} - -// GetLastReachableUpdateOk returns a tuple with the LastReachableUpdate field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *StackReachability) GetLastReachableUpdateOk() (*time.Time, bool) { - if o == nil || IsNil(o.LastReachableUpdate) { - return nil, false - } - return o.LastReachableUpdate, true -} - -// HasLastReachableUpdate returns a boolean if a field has been set. -func (o *StackReachability) HasLastReachableUpdate() bool { - if o != nil && !IsNil(o.LastReachableUpdate) { - return true - } - - return false -} - -// SetLastReachableUpdate gets a reference to the given time.Time and assigns it to the LastReachableUpdate field. -func (o *StackReachability) SetLastReachableUpdate(v time.Time) { - o.LastReachableUpdate = &v -} - -func (o StackReachability) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o StackReachability) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["reachable"] = o.Reachable - if !IsNil(o.LastReachableUpdate) { - toSerialize["lastReachableUpdate"] = o.LastReachableUpdate - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *StackReachability) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "reachable", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varStackReachability := _StackReachability{} - - err = json.Unmarshal(data, &varStackReachability) - - if err != nil { - return err - } - - *o = StackReachability(varStackReachability) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "reachable") - delete(additionalProperties, "lastReachableUpdate") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableStackReachability struct { - value *StackReachability - isSet bool -} - -func (v NullableStackReachability) Get() *StackReachability { - return v.value -} - -func (v *NullableStackReachability) Set(val *StackReachability) { - v.value = val - v.isSet = true -} - -func (v NullableStackReachability) IsSet() bool { - return v.isSet -} - -func (v *NullableStackReachability) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableStackReachability(val *StackReachability) *NullableStackReachability { - return &NullableStackReachability{value: val, isSet: true} -} - -func (v NullableStackReachability) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableStackReachability) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_stack_user_access.go b/membershipclient/model_stack_user_access.go deleted file mode 100644 index 6a607023..00000000 --- a/membershipclient/model_stack_user_access.go +++ /dev/null @@ -1,258 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the StackUserAccess type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &StackUserAccess{} - -// StackUserAccess struct for StackUserAccess -type StackUserAccess struct { - // Stack ID - StackId string `json:"stackId"` - // User ID - UserId string `json:"userId"` - // User email - Email string `json:"email"` - Role Role `json:"role"` - AdditionalProperties map[string]interface{} -} - -type _StackUserAccess StackUserAccess - -// NewStackUserAccess instantiates a new StackUserAccess object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewStackUserAccess(stackId string, userId string, email string, role Role) *StackUserAccess { - this := StackUserAccess{} - this.StackId = stackId - this.UserId = userId - this.Email = email - this.Role = role - return &this -} - -// NewStackUserAccessWithDefaults instantiates a new StackUserAccess object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewStackUserAccessWithDefaults() *StackUserAccess { - this := StackUserAccess{} - return &this -} - -// GetStackId returns the StackId field value -func (o *StackUserAccess) GetStackId() string { - if o == nil { - var ret string - return ret - } - - return o.StackId -} - -// GetStackIdOk returns a tuple with the StackId field value -// and a boolean to check if the value has been set. -func (o *StackUserAccess) GetStackIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.StackId, true -} - -// SetStackId sets field value -func (o *StackUserAccess) SetStackId(v string) { - o.StackId = v -} - -// GetUserId returns the UserId field value -func (o *StackUserAccess) GetUserId() string { - if o == nil { - var ret string - return ret - } - - return o.UserId -} - -// GetUserIdOk returns a tuple with the UserId field value -// and a boolean to check if the value has been set. -func (o *StackUserAccess) GetUserIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.UserId, true -} - -// SetUserId sets field value -func (o *StackUserAccess) SetUserId(v string) { - o.UserId = v -} - -// GetEmail returns the Email field value -func (o *StackUserAccess) GetEmail() string { - if o == nil { - var ret string - return ret - } - - return o.Email -} - -// GetEmailOk returns a tuple with the Email field value -// and a boolean to check if the value has been set. -func (o *StackUserAccess) GetEmailOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Email, true -} - -// SetEmail sets field value -func (o *StackUserAccess) SetEmail(v string) { - o.Email = v -} - -// GetRole returns the Role field value -func (o *StackUserAccess) GetRole() Role { - if o == nil { - var ret Role - return ret - } - - return o.Role -} - -// GetRoleOk returns a tuple with the Role field value -// and a boolean to check if the value has been set. -func (o *StackUserAccess) GetRoleOk() (*Role, bool) { - if o == nil { - return nil, false - } - return &o.Role, true -} - -// SetRole sets field value -func (o *StackUserAccess) SetRole(v Role) { - o.Role = v -} - -func (o StackUserAccess) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o StackUserAccess) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["stackId"] = o.StackId - toSerialize["userId"] = o.UserId - toSerialize["email"] = o.Email - toSerialize["role"] = o.Role - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *StackUserAccess) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "stackId", - "userId", - "email", - "role", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varStackUserAccess := _StackUserAccess{} - - err = json.Unmarshal(data, &varStackUserAccess) - - if err != nil { - return err - } - - *o = StackUserAccess(varStackUserAccess) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "stackId") - delete(additionalProperties, "userId") - delete(additionalProperties, "email") - delete(additionalProperties, "role") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableStackUserAccess struct { - value *StackUserAccess - isSet bool -} - -func (v NullableStackUserAccess) Get() *StackUserAccess { - return v.value -} - -func (v *NullableStackUserAccess) Set(val *StackUserAccess) { - v.value = val - v.isSet = true -} - -func (v NullableStackUserAccess) IsSet() bool { - return v.isSet -} - -func (v *NullableStackUserAccess) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableStackUserAccess(val *StackUserAccess) *NullableStackUserAccess { - return &NullableStackUserAccess{value: val, isSet: true} -} - -func (v NullableStackUserAccess) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableStackUserAccess) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_stack_user_access_response.go b/membershipclient/model_stack_user_access_response.go deleted file mode 100644 index f38703d6..00000000 --- a/membershipclient/model_stack_user_access_response.go +++ /dev/null @@ -1,155 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the StackUserAccessResponse type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &StackUserAccessResponse{} - -// StackUserAccessResponse struct for StackUserAccessResponse -type StackUserAccessResponse struct { - Data []StackUserAccess `json:"data,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _StackUserAccessResponse StackUserAccessResponse - -// NewStackUserAccessResponse instantiates a new StackUserAccessResponse object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewStackUserAccessResponse() *StackUserAccessResponse { - this := StackUserAccessResponse{} - return &this -} - -// NewStackUserAccessResponseWithDefaults instantiates a new StackUserAccessResponse object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewStackUserAccessResponseWithDefaults() *StackUserAccessResponse { - this := StackUserAccessResponse{} - return &this -} - -// GetData returns the Data field value if set, zero value otherwise. -func (o *StackUserAccessResponse) GetData() []StackUserAccess { - if o == nil || IsNil(o.Data) { - var ret []StackUserAccess - return ret - } - return o.Data -} - -// GetDataOk returns a tuple with the Data field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *StackUserAccessResponse) GetDataOk() ([]StackUserAccess, bool) { - if o == nil || IsNil(o.Data) { - return nil, false - } - return o.Data, true -} - -// HasData returns a boolean if a field has been set. -func (o *StackUserAccessResponse) HasData() bool { - if o != nil && !IsNil(o.Data) { - return true - } - - return false -} - -// SetData gets a reference to the given []StackUserAccess and assigns it to the Data field. -func (o *StackUserAccessResponse) SetData(v []StackUserAccess) { - o.Data = v -} - -func (o StackUserAccessResponse) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o StackUserAccessResponse) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Data) { - toSerialize["data"] = o.Data - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *StackUserAccessResponse) UnmarshalJSON(data []byte) (err error) { - varStackUserAccessResponse := _StackUserAccessResponse{} - - err = json.Unmarshal(data, &varStackUserAccessResponse) - - if err != nil { - return err - } - - *o = StackUserAccessResponse(varStackUserAccessResponse) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "data") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableStackUserAccessResponse struct { - value *StackUserAccessResponse - isSet bool -} - -func (v NullableStackUserAccessResponse) Get() *StackUserAccessResponse { - return v.value -} - -func (v *NullableStackUserAccessResponse) Set(val *StackUserAccessResponse) { - v.value = val - v.isSet = true -} - -func (v NullableStackUserAccessResponse) IsSet() bool { - return v.isSet -} - -func (v *NullableStackUserAccessResponse) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableStackUserAccessResponse(val *StackUserAccessResponse) *NullableStackUserAccessResponse { - return &NullableStackUserAccessResponse{value: val, isSet: true} -} - -func (v NullableStackUserAccessResponse) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableStackUserAccessResponse) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_stack_version.go b/membershipclient/model_stack_version.go deleted file mode 100644 index a429d70e..00000000 --- a/membershipclient/model_stack_version.go +++ /dev/null @@ -1,156 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" -) - -// checks if the StackVersion type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &StackVersion{} - -// StackVersion struct for StackVersion -type StackVersion struct { - // Supported only with agent version >= v0.7.0 - Version *string `json:"version,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _StackVersion StackVersion - -// NewStackVersion instantiates a new StackVersion object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewStackVersion() *StackVersion { - this := StackVersion{} - return &this -} - -// NewStackVersionWithDefaults instantiates a new StackVersion object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewStackVersionWithDefaults() *StackVersion { - this := StackVersion{} - return &this -} - -// GetVersion returns the Version field value if set, zero value otherwise. -func (o *StackVersion) GetVersion() string { - if o == nil || IsNil(o.Version) { - var ret string - return ret - } - return *o.Version -} - -// GetVersionOk returns a tuple with the Version field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *StackVersion) GetVersionOk() (*string, bool) { - if o == nil || IsNil(o.Version) { - return nil, false - } - return o.Version, true -} - -// HasVersion returns a boolean if a field has been set. -func (o *StackVersion) HasVersion() bool { - if o != nil && !IsNil(o.Version) { - return true - } - - return false -} - -// SetVersion gets a reference to the given string and assigns it to the Version field. -func (o *StackVersion) SetVersion(v string) { - o.Version = &v -} - -func (o StackVersion) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o StackVersion) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - if !IsNil(o.Version) { - toSerialize["version"] = o.Version - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *StackVersion) UnmarshalJSON(data []byte) (err error) { - varStackVersion := _StackVersion{} - - err = json.Unmarshal(data, &varStackVersion) - - if err != nil { - return err - } - - *o = StackVersion(varStackVersion) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "version") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableStackVersion struct { - value *StackVersion - isSet bool -} - -func (v NullableStackVersion) Get() *StackVersion { - return v.value -} - -func (v *NullableStackVersion) Set(val *StackVersion) { - v.value = val - v.isSet = true -} - -func (v NullableStackVersion) IsSet() bool { - return v.isSet -} - -func (v *NullableStackVersion) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableStackVersion(val *StackVersion) *NullableStackVersion { - return &NullableStackVersion{value: val, isSet: true} -} - -func (v NullableStackVersion) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableStackVersion) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_system_role.go b/membershipclient/model_system_role.go deleted file mode 100644 index 0868c6b3..00000000 --- a/membershipclient/model_system_role.go +++ /dev/null @@ -1,111 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// SystemRole the model 'SystemRole' -type SystemRole string - -// List of SystemRole -const ( - USER SystemRole = "USER" - SYSTEM SystemRole = "SYSTEM" -) - -// All allowed values of SystemRole enum -var AllowedSystemRoleEnumValues = []SystemRole{ - "USER", - "SYSTEM", -} - -func (v *SystemRole) UnmarshalJSON(src []byte) error { - var value string - err := json.Unmarshal(src, &value) - if err != nil { - return err - } - enumTypeValue := SystemRole(value) - for _, existing := range AllowedSystemRoleEnumValues { - if existing == enumTypeValue { - *v = enumTypeValue - return nil - } - } - - return fmt.Errorf("%+v is not a valid SystemRole", value) -} - -// NewSystemRoleFromValue returns a pointer to a valid SystemRole -// for the value passed as argument, or an error if the value passed is not allowed by the enum -func NewSystemRoleFromValue(v string) (*SystemRole, error) { - ev := SystemRole(v) - if ev.IsValid() { - return &ev, nil - } else { - return nil, fmt.Errorf("invalid value '%v' for SystemRole: valid values are %v", v, AllowedSystemRoleEnumValues) - } -} - -// IsValid return true if the value is valid for the enum, false otherwise -func (v SystemRole) IsValid() bool { - for _, existing := range AllowedSystemRoleEnumValues { - if existing == v { - return true - } - } - return false -} - -// Ptr returns reference to SystemRole value -func (v SystemRole) Ptr() *SystemRole { - return &v -} - -type NullableSystemRole struct { - value *SystemRole - isSet bool -} - -func (v NullableSystemRole) Get() *SystemRole { - return v.value -} - -func (v *NullableSystemRole) Set(val *SystemRole) { - v.value = val - v.isSet = true -} - -func (v NullableSystemRole) IsSet() bool { - return v.isSet -} - -func (v *NullableSystemRole) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableSystemRole(val *SystemRole) *NullableSystemRole { - return &NullableSystemRole{value: val, isSet: true} -} - -func (v NullableSystemRole) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableSystemRole) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - diff --git a/membershipclient/model_update_organization_client_request.go b/membershipclient/model_update_organization_client_request.go deleted file mode 100644 index 7e612b24..00000000 --- a/membershipclient/model_update_organization_client_request.go +++ /dev/null @@ -1,207 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the UpdateOrganizationClientRequest type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &UpdateOrganizationClientRequest{} - -// UpdateOrganizationClientRequest struct for UpdateOrganizationClientRequest -type UpdateOrganizationClientRequest struct { - // Name of the client - Name string `json:"name"` - // Description of the client - Description *string `json:"description,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _UpdateOrganizationClientRequest UpdateOrganizationClientRequest - -// NewUpdateOrganizationClientRequest instantiates a new UpdateOrganizationClientRequest object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewUpdateOrganizationClientRequest(name string) *UpdateOrganizationClientRequest { - this := UpdateOrganizationClientRequest{} - this.Name = name - return &this -} - -// NewUpdateOrganizationClientRequestWithDefaults instantiates a new UpdateOrganizationClientRequest object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewUpdateOrganizationClientRequestWithDefaults() *UpdateOrganizationClientRequest { - this := UpdateOrganizationClientRequest{} - return &this -} - -// GetName returns the Name field value -func (o *UpdateOrganizationClientRequest) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *UpdateOrganizationClientRequest) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *UpdateOrganizationClientRequest) SetName(v string) { - o.Name = v -} - -// GetDescription returns the Description field value if set, zero value otherwise. -func (o *UpdateOrganizationClientRequest) GetDescription() string { - if o == nil || IsNil(o.Description) { - var ret string - return ret - } - return *o.Description -} - -// GetDescriptionOk returns a tuple with the Description field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *UpdateOrganizationClientRequest) GetDescriptionOk() (*string, bool) { - if o == nil || IsNil(o.Description) { - return nil, false - } - return o.Description, true -} - -// HasDescription returns a boolean if a field has been set. -func (o *UpdateOrganizationClientRequest) HasDescription() bool { - if o != nil && !IsNil(o.Description) { - return true - } - - return false -} - -// SetDescription gets a reference to the given string and assigns it to the Description field. -func (o *UpdateOrganizationClientRequest) SetDescription(v string) { - o.Description = &v -} - -func (o UpdateOrganizationClientRequest) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o UpdateOrganizationClientRequest) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["name"] = o.Name - if !IsNil(o.Description) { - toSerialize["description"] = o.Description - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *UpdateOrganizationClientRequest) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "name", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varUpdateOrganizationClientRequest := _UpdateOrganizationClientRequest{} - - err = json.Unmarshal(data, &varUpdateOrganizationClientRequest) - - if err != nil { - return err - } - - *o = UpdateOrganizationClientRequest(varUpdateOrganizationClientRequest) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "name") - delete(additionalProperties, "description") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableUpdateOrganizationClientRequest struct { - value *UpdateOrganizationClientRequest - isSet bool -} - -func (v NullableUpdateOrganizationClientRequest) Get() *UpdateOrganizationClientRequest { - return v.value -} - -func (v *NullableUpdateOrganizationClientRequest) Set(val *UpdateOrganizationClientRequest) { - v.value = val - v.isSet = true -} - -func (v NullableUpdateOrganizationClientRequest) IsSet() bool { - return v.isSet -} - -func (v *NullableUpdateOrganizationClientRequest) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableUpdateOrganizationClientRequest(val *UpdateOrganizationClientRequest) *NullableUpdateOrganizationClientRequest { - return &NullableUpdateOrganizationClientRequest{value: val, isSet: true} -} - -func (v NullableUpdateOrganizationClientRequest) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableUpdateOrganizationClientRequest) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_update_organization_user_request.go b/membershipclient/model_update_organization_user_request.go deleted file mode 100644 index 0d01f22f..00000000 --- a/membershipclient/model_update_organization_user_request.go +++ /dev/null @@ -1,168 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the UpdateOrganizationUserRequest type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &UpdateOrganizationUserRequest{} - -// UpdateOrganizationUserRequest struct for UpdateOrganizationUserRequest -type UpdateOrganizationUserRequest struct { - Role Role `json:"role"` - AdditionalProperties map[string]interface{} -} - -type _UpdateOrganizationUserRequest UpdateOrganizationUserRequest - -// NewUpdateOrganizationUserRequest instantiates a new UpdateOrganizationUserRequest object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewUpdateOrganizationUserRequest(role Role) *UpdateOrganizationUserRequest { - this := UpdateOrganizationUserRequest{} - this.Role = role - return &this -} - -// NewUpdateOrganizationUserRequestWithDefaults instantiates a new UpdateOrganizationUserRequest object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewUpdateOrganizationUserRequestWithDefaults() *UpdateOrganizationUserRequest { - this := UpdateOrganizationUserRequest{} - return &this -} - -// GetRole returns the Role field value -func (o *UpdateOrganizationUserRequest) GetRole() Role { - if o == nil { - var ret Role - return ret - } - - return o.Role -} - -// GetRoleOk returns a tuple with the Role field value -// and a boolean to check if the value has been set. -func (o *UpdateOrganizationUserRequest) GetRoleOk() (*Role, bool) { - if o == nil { - return nil, false - } - return &o.Role, true -} - -// SetRole sets field value -func (o *UpdateOrganizationUserRequest) SetRole(v Role) { - o.Role = v -} - -func (o UpdateOrganizationUserRequest) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o UpdateOrganizationUserRequest) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["role"] = o.Role - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *UpdateOrganizationUserRequest) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "role", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varUpdateOrganizationUserRequest := _UpdateOrganizationUserRequest{} - - err = json.Unmarshal(data, &varUpdateOrganizationUserRequest) - - if err != nil { - return err - } - - *o = UpdateOrganizationUserRequest(varUpdateOrganizationUserRequest) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "role") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableUpdateOrganizationUserRequest struct { - value *UpdateOrganizationUserRequest - isSet bool -} - -func (v NullableUpdateOrganizationUserRequest) Get() *UpdateOrganizationUserRequest { - return v.value -} - -func (v *NullableUpdateOrganizationUserRequest) Set(val *UpdateOrganizationUserRequest) { - v.value = val - v.isSet = true -} - -func (v NullableUpdateOrganizationUserRequest) IsSet() bool { - return v.isSet -} - -func (v *NullableUpdateOrganizationUserRequest) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableUpdateOrganizationUserRequest(val *UpdateOrganizationUserRequest) *NullableUpdateOrganizationUserRequest { - return &NullableUpdateOrganizationUserRequest{value: val, isSet: true} -} - -func (v NullableUpdateOrganizationUserRequest) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableUpdateOrganizationUserRequest) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_update_stack_request.go b/membershipclient/model_update_stack_request.go deleted file mode 100644 index e160a5c2..00000000 --- a/membershipclient/model_update_stack_request.go +++ /dev/null @@ -1,206 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the UpdateStackRequest type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &UpdateStackRequest{} - -// UpdateStackRequest struct for UpdateStackRequest -type UpdateStackRequest struct { - // Stack name - Name string `json:"name"` - Metadata *map[string]string `json:"metadata,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _UpdateStackRequest UpdateStackRequest - -// NewUpdateStackRequest instantiates a new UpdateStackRequest object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewUpdateStackRequest(name string) *UpdateStackRequest { - this := UpdateStackRequest{} - this.Name = name - return &this -} - -// NewUpdateStackRequestWithDefaults instantiates a new UpdateStackRequest object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewUpdateStackRequestWithDefaults() *UpdateStackRequest { - this := UpdateStackRequest{} - return &this -} - -// GetName returns the Name field value -func (o *UpdateStackRequest) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *UpdateStackRequest) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *UpdateStackRequest) SetName(v string) { - o.Name = v -} - -// GetMetadata returns the Metadata field value if set, zero value otherwise. -func (o *UpdateStackRequest) GetMetadata() map[string]string { - if o == nil || IsNil(o.Metadata) { - var ret map[string]string - return ret - } - return *o.Metadata -} - -// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *UpdateStackRequest) GetMetadataOk() (*map[string]string, bool) { - if o == nil || IsNil(o.Metadata) { - return nil, false - } - return o.Metadata, true -} - -// HasMetadata returns a boolean if a field has been set. -func (o *UpdateStackRequest) HasMetadata() bool { - if o != nil && !IsNil(o.Metadata) { - return true - } - - return false -} - -// SetMetadata gets a reference to the given map[string]string and assigns it to the Metadata field. -func (o *UpdateStackRequest) SetMetadata(v map[string]string) { - o.Metadata = &v -} - -func (o UpdateStackRequest) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o UpdateStackRequest) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["name"] = o.Name - if !IsNil(o.Metadata) { - toSerialize["metadata"] = o.Metadata - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *UpdateStackRequest) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "name", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varUpdateStackRequest := _UpdateStackRequest{} - - err = json.Unmarshal(data, &varUpdateStackRequest) - - if err != nil { - return err - } - - *o = UpdateStackRequest(varUpdateStackRequest) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "name") - delete(additionalProperties, "metadata") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableUpdateStackRequest struct { - value *UpdateStackRequest - isSet bool -} - -func (v NullableUpdateStackRequest) Get() *UpdateStackRequest { - return v.value -} - -func (v *NullableUpdateStackRequest) Set(val *UpdateStackRequest) { - v.value = val - v.isSet = true -} - -func (v NullableUpdateStackRequest) IsSet() bool { - return v.isSet -} - -func (v *NullableUpdateStackRequest) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableUpdateStackRequest(val *UpdateStackRequest) *NullableUpdateStackRequest { - return &NullableUpdateStackRequest{value: val, isSet: true} -} - -func (v NullableUpdateStackRequest) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableUpdateStackRequest) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_update_stack_user_request.go b/membershipclient/model_update_stack_user_request.go deleted file mode 100644 index 9843774f..00000000 --- a/membershipclient/model_update_stack_user_request.go +++ /dev/null @@ -1,168 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the UpdateStackUserRequest type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &UpdateStackUserRequest{} - -// UpdateStackUserRequest struct for UpdateStackUserRequest -type UpdateStackUserRequest struct { - Role Role `json:"role"` - AdditionalProperties map[string]interface{} -} - -type _UpdateStackUserRequest UpdateStackUserRequest - -// NewUpdateStackUserRequest instantiates a new UpdateStackUserRequest object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewUpdateStackUserRequest(role Role) *UpdateStackUserRequest { - this := UpdateStackUserRequest{} - this.Role = role - return &this -} - -// NewUpdateStackUserRequestWithDefaults instantiates a new UpdateStackUserRequest object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewUpdateStackUserRequestWithDefaults() *UpdateStackUserRequest { - this := UpdateStackUserRequest{} - return &this -} - -// GetRole returns the Role field value -func (o *UpdateStackUserRequest) GetRole() Role { - if o == nil { - var ret Role - return ret - } - - return o.Role -} - -// GetRoleOk returns a tuple with the Role field value -// and a boolean to check if the value has been set. -func (o *UpdateStackUserRequest) GetRoleOk() (*Role, bool) { - if o == nil { - return nil, false - } - return &o.Role, true -} - -// SetRole sets field value -func (o *UpdateStackUserRequest) SetRole(v Role) { - o.Role = v -} - -func (o UpdateStackUserRequest) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o UpdateStackUserRequest) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["role"] = o.Role - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *UpdateStackUserRequest) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "role", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varUpdateStackUserRequest := _UpdateStackUserRequest{} - - err = json.Unmarshal(data, &varUpdateStackUserRequest) - - if err != nil { - return err - } - - *o = UpdateStackUserRequest(varUpdateStackUserRequest) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "role") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableUpdateStackUserRequest struct { - value *UpdateStackUserRequest - isSet bool -} - -func (v NullableUpdateStackUserRequest) Get() *UpdateStackUserRequest { - return v.value -} - -func (v *NullableUpdateStackUserRequest) Set(val *UpdateStackUserRequest) { - v.value = val - v.isSet = true -} - -func (v NullableUpdateStackUserRequest) IsSet() bool { - return v.isSet -} - -func (v *NullableUpdateStackUserRequest) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableUpdateStackUserRequest(val *UpdateStackUserRequest) *NullableUpdateStackUserRequest { - return &NullableUpdateStackUserRequest{value: val, isSet: true} -} - -func (v NullableUpdateStackUserRequest) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableUpdateStackUserRequest) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_user.go b/membershipclient/model_user.go deleted file mode 100644 index 726813ca..00000000 --- a/membershipclient/model_user.go +++ /dev/null @@ -1,235 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the User type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &User{} - -// User struct for User -type User struct { - Email string `json:"email"` - // User ID - Id string `json:"id"` - Role *SystemRole `json:"role,omitempty"` - AdditionalProperties map[string]interface{} -} - -type _User User - -// NewUser instantiates a new User object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewUser(email string, id string) *User { - this := User{} - this.Email = email - this.Id = id - return &this -} - -// NewUserWithDefaults instantiates a new User object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewUserWithDefaults() *User { - this := User{} - return &this -} - -// GetEmail returns the Email field value -func (o *User) GetEmail() string { - if o == nil { - var ret string - return ret - } - - return o.Email -} - -// GetEmailOk returns a tuple with the Email field value -// and a boolean to check if the value has been set. -func (o *User) GetEmailOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Email, true -} - -// SetEmail sets field value -func (o *User) SetEmail(v string) { - o.Email = v -} - -// GetId returns the Id field value -func (o *User) GetId() string { - if o == nil { - var ret string - return ret - } - - return o.Id -} - -// GetIdOk returns a tuple with the Id field value -// and a boolean to check if the value has been set. -func (o *User) GetIdOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Id, true -} - -// SetId sets field value -func (o *User) SetId(v string) { - o.Id = v -} - -// GetRole returns the Role field value if set, zero value otherwise. -func (o *User) GetRole() SystemRole { - if o == nil || IsNil(o.Role) { - var ret SystemRole - return ret - } - return *o.Role -} - -// GetRoleOk returns a tuple with the Role field value if set, nil otherwise -// and a boolean to check if the value has been set. -func (o *User) GetRoleOk() (*SystemRole, bool) { - if o == nil || IsNil(o.Role) { - return nil, false - } - return o.Role, true -} - -// HasRole returns a boolean if a field has been set. -func (o *User) HasRole() bool { - if o != nil && !IsNil(o.Role) { - return true - } - - return false -} - -// SetRole gets a reference to the given SystemRole and assigns it to the Role field. -func (o *User) SetRole(v SystemRole) { - o.Role = &v -} - -func (o User) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o User) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["email"] = o.Email - toSerialize["id"] = o.Id - if !IsNil(o.Role) { - toSerialize["role"] = o.Role - } - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *User) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "email", - "id", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varUser := _User{} - - err = json.Unmarshal(data, &varUser) - - if err != nil { - return err - } - - *o = User(varUser) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "email") - delete(additionalProperties, "id") - delete(additionalProperties, "role") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableUser struct { - value *User - isSet bool -} - -func (v NullableUser) Get() *User { - return v.value -} - -func (v *NullableUser) Set(val *User) { - v.value = val - v.isSet = true -} - -func (v NullableUser) IsSet() bool { - return v.isSet -} - -func (v *NullableUser) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableUser(val *User) *NullableUser { - return &NullableUser{value: val, isSet: true} -} - -func (v NullableUser) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableUser) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_user_data.go b/membershipclient/model_user_data.go deleted file mode 100644 index c0b7b486..00000000 --- a/membershipclient/model_user_data.go +++ /dev/null @@ -1,168 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the UserData type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &UserData{} - -// UserData struct for UserData -type UserData struct { - Email string `json:"email"` - AdditionalProperties map[string]interface{} -} - -type _UserData UserData - -// NewUserData instantiates a new UserData object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewUserData(email string) *UserData { - this := UserData{} - this.Email = email - return &this -} - -// NewUserDataWithDefaults instantiates a new UserData object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewUserDataWithDefaults() *UserData { - this := UserData{} - return &this -} - -// GetEmail returns the Email field value -func (o *UserData) GetEmail() string { - if o == nil { - var ret string - return ret - } - - return o.Email -} - -// GetEmailOk returns a tuple with the Email field value -// and a boolean to check if the value has been set. -func (o *UserData) GetEmailOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Email, true -} - -// SetEmail sets field value -func (o *UserData) SetEmail(v string) { - o.Email = v -} - -func (o UserData) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o UserData) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["email"] = o.Email - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *UserData) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "email", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varUserData := _UserData{} - - err = json.Unmarshal(data, &varUserData) - - if err != nil { - return err - } - - *o = UserData(varUserData) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "email") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableUserData struct { - value *UserData - isSet bool -} - -func (v NullableUserData) Get() *UserData { - return v.value -} - -func (v *NullableUserData) Set(val *UserData) { - v.value = val - v.isSet = true -} - -func (v NullableUserData) IsSet() bool { - return v.isSet -} - -func (v *NullableUserData) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableUserData(val *UserData) *NullableUserData { - return &NullableUserData{value: val, isSet: true} -} - -func (v NullableUserData) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableUserData) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/model_version.go b/membershipclient/model_version.go deleted file mode 100644 index fe42367a..00000000 --- a/membershipclient/model_version.go +++ /dev/null @@ -1,226 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "encoding/json" - "fmt" -) - -// checks if the Version type satisfies the MappedNullable interface at compile time -var _ MappedNullable = &Version{} - -// Version struct for Version -type Version struct { - Name string `json:"name"` - Versions map[string]string `json:"versions"` - RegionID string `json:"regionID"` - AdditionalProperties map[string]interface{} -} - -type _Version Version - -// NewVersion instantiates a new Version object -// This constructor will assign default values to properties that have it defined, -// and makes sure properties required by API are set, but the set of arguments -// will change when the set of required properties is changed -func NewVersion(name string, versions map[string]string, regionID string) *Version { - this := Version{} - this.Name = name - this.Versions = versions - this.RegionID = regionID - return &this -} - -// NewVersionWithDefaults instantiates a new Version object -// This constructor will only assign default values to properties that have it defined, -// but it doesn't guarantee that properties required by API are set -func NewVersionWithDefaults() *Version { - this := Version{} - return &this -} - -// GetName returns the Name field value -func (o *Version) GetName() string { - if o == nil { - var ret string - return ret - } - - return o.Name -} - -// GetNameOk returns a tuple with the Name field value -// and a boolean to check if the value has been set. -func (o *Version) GetNameOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.Name, true -} - -// SetName sets field value -func (o *Version) SetName(v string) { - o.Name = v -} - -// GetVersions returns the Versions field value -func (o *Version) GetVersions() map[string]string { - if o == nil { - var ret map[string]string - return ret - } - - return o.Versions -} - -// GetVersionsOk returns a tuple with the Versions field value -// and a boolean to check if the value has been set. -func (o *Version) GetVersionsOk() (*map[string]string, bool) { - if o == nil { - return nil, false - } - return &o.Versions, true -} - -// SetVersions sets field value -func (o *Version) SetVersions(v map[string]string) { - o.Versions = v -} - -// GetRegionID returns the RegionID field value -func (o *Version) GetRegionID() string { - if o == nil { - var ret string - return ret - } - - return o.RegionID -} - -// GetRegionIDOk returns a tuple with the RegionID field value -// and a boolean to check if the value has been set. -func (o *Version) GetRegionIDOk() (*string, bool) { - if o == nil { - return nil, false - } - return &o.RegionID, true -} - -// SetRegionID sets field value -func (o *Version) SetRegionID(v string) { - o.RegionID = v -} - -func (o Version) MarshalJSON() ([]byte, error) { - toSerialize,err := o.ToMap() - if err != nil { - return []byte{}, err - } - return json.Marshal(toSerialize) -} - -func (o Version) ToMap() (map[string]interface{}, error) { - toSerialize := map[string]interface{}{} - toSerialize["name"] = o.Name - toSerialize["versions"] = o.Versions - toSerialize["regionID"] = o.RegionID - - for key, value := range o.AdditionalProperties { - toSerialize[key] = value - } - - return toSerialize, nil -} - -func (o *Version) UnmarshalJSON(data []byte) (err error) { - // This validates that all required properties are included in the JSON object - // by unmarshalling the object into a generic map with string keys and checking - // that every required field exists as a key in the generic map. - requiredProperties := []string{ - "name", - "versions", - "regionID", - } - - allProperties := make(map[string]interface{}) - - err = json.Unmarshal(data, &allProperties) - - if err != nil { - return err; - } - - for _, requiredProperty := range(requiredProperties) { - if _, exists := allProperties[requiredProperty]; !exists { - return fmt.Errorf("no value given for required property %v", requiredProperty) - } - } - - varVersion := _Version{} - - err = json.Unmarshal(data, &varVersion) - - if err != nil { - return err - } - - *o = Version(varVersion) - - additionalProperties := make(map[string]interface{}) - - if err = json.Unmarshal(data, &additionalProperties); err == nil { - delete(additionalProperties, "name") - delete(additionalProperties, "versions") - delete(additionalProperties, "regionID") - o.AdditionalProperties = additionalProperties - } - - return err -} - -type NullableVersion struct { - value *Version - isSet bool -} - -func (v NullableVersion) Get() *Version { - return v.value -} - -func (v *NullableVersion) Set(val *Version) { - v.value = val - v.isSet = true -} - -func (v NullableVersion) IsSet() bool { - return v.isSet -} - -func (v *NullableVersion) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableVersion(val *Version) *NullableVersion { - return &NullableVersion{value: val, isSet: true} -} - -func (v NullableVersion) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableVersion) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - - diff --git a/membershipclient/response.go b/membershipclient/response.go deleted file mode 100644 index 887747e9..00000000 --- a/membershipclient/response.go +++ /dev/null @@ -1,47 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "net/http" -) - -// APIResponse stores the API response returned by the server. -type APIResponse struct { - *http.Response `json:"-"` - Message string `json:"message,omitempty"` - // Operation is the name of the OpenAPI operation. - Operation string `json:"operation,omitempty"` - // RequestURL is the request URL. This value is always available, even if the - // embedded *http.Response is nil. - RequestURL string `json:"url,omitempty"` - // Method is the HTTP method used for the request. This value is always - // available, even if the embedded *http.Response is nil. - Method string `json:"method,omitempty"` - // Payload holds the contents of the response body (which may be nil or empty). - // This is provided here as the raw response.Body() reader will have already - // been drained. - Payload []byte `json:"-"` -} - -// NewAPIResponse returns a new APIResponse object. -func NewAPIResponse(r *http.Response) *APIResponse { - - response := &APIResponse{Response: r} - return response -} - -// NewAPIResponseWithError returns a new APIResponse object with the provided error message. -func NewAPIResponseWithError(errorMessage string) *APIResponse { - - response := &APIResponse{Message: errorMessage} - return response -} diff --git a/membershipclient/utils.go b/membershipclient/utils.go deleted file mode 100644 index 55985b0d..00000000 --- a/membershipclient/utils.go +++ /dev/null @@ -1,361 +0,0 @@ -/* -Membership API - -No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) - -API version: 0.1.0 -*/ - -// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. - -package membershipclient - -import ( - "bytes" - "encoding/json" - "fmt" - "reflect" - "time" -) - -// PtrBool is a helper routine that returns a pointer to given boolean value. -func PtrBool(v bool) *bool { return &v } - -// PtrInt is a helper routine that returns a pointer to given integer value. -func PtrInt(v int) *int { return &v } - -// PtrInt32 is a helper routine that returns a pointer to given integer value. -func PtrInt32(v int32) *int32 { return &v } - -// PtrInt64 is a helper routine that returns a pointer to given integer value. -func PtrInt64(v int64) *int64 { return &v } - -// PtrFloat32 is a helper routine that returns a pointer to given float value. -func PtrFloat32(v float32) *float32 { return &v } - -// PtrFloat64 is a helper routine that returns a pointer to given float value. -func PtrFloat64(v float64) *float64 { return &v } - -// PtrString is a helper routine that returns a pointer to given string value. -func PtrString(v string) *string { return &v } - -// PtrTime is helper routine that returns a pointer to given Time value. -func PtrTime(v time.Time) *time.Time { return &v } - -type NullableBool struct { - value *bool - isSet bool -} - -func (v NullableBool) Get() *bool { - return v.value -} - -func (v *NullableBool) Set(val *bool) { - v.value = val - v.isSet = true -} - -func (v NullableBool) IsSet() bool { - return v.isSet -} - -func (v *NullableBool) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableBool(val *bool) *NullableBool { - return &NullableBool{value: val, isSet: true} -} - -func (v NullableBool) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableBool) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - -type NullableInt struct { - value *int - isSet bool -} - -func (v NullableInt) Get() *int { - return v.value -} - -func (v *NullableInt) Set(val *int) { - v.value = val - v.isSet = true -} - -func (v NullableInt) IsSet() bool { - return v.isSet -} - -func (v *NullableInt) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableInt(val *int) *NullableInt { - return &NullableInt{value: val, isSet: true} -} - -func (v NullableInt) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableInt) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - -type NullableInt32 struct { - value *int32 - isSet bool -} - -func (v NullableInt32) Get() *int32 { - return v.value -} - -func (v *NullableInt32) Set(val *int32) { - v.value = val - v.isSet = true -} - -func (v NullableInt32) IsSet() bool { - return v.isSet -} - -func (v *NullableInt32) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableInt32(val *int32) *NullableInt32 { - return &NullableInt32{value: val, isSet: true} -} - -func (v NullableInt32) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableInt32) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - -type NullableInt64 struct { - value *int64 - isSet bool -} - -func (v NullableInt64) Get() *int64 { - return v.value -} - -func (v *NullableInt64) Set(val *int64) { - v.value = val - v.isSet = true -} - -func (v NullableInt64) IsSet() bool { - return v.isSet -} - -func (v *NullableInt64) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableInt64(val *int64) *NullableInt64 { - return &NullableInt64{value: val, isSet: true} -} - -func (v NullableInt64) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableInt64) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - -type NullableFloat32 struct { - value *float32 - isSet bool -} - -func (v NullableFloat32) Get() *float32 { - return v.value -} - -func (v *NullableFloat32) Set(val *float32) { - v.value = val - v.isSet = true -} - -func (v NullableFloat32) IsSet() bool { - return v.isSet -} - -func (v *NullableFloat32) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableFloat32(val *float32) *NullableFloat32 { - return &NullableFloat32{value: val, isSet: true} -} - -func (v NullableFloat32) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableFloat32) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - -type NullableFloat64 struct { - value *float64 - isSet bool -} - -func (v NullableFloat64) Get() *float64 { - return v.value -} - -func (v *NullableFloat64) Set(val *float64) { - v.value = val - v.isSet = true -} - -func (v NullableFloat64) IsSet() bool { - return v.isSet -} - -func (v *NullableFloat64) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableFloat64(val *float64) *NullableFloat64 { - return &NullableFloat64{value: val, isSet: true} -} - -func (v NullableFloat64) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableFloat64) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - -type NullableString struct { - value *string - isSet bool -} - -func (v NullableString) Get() *string { - return v.value -} - -func (v *NullableString) Set(val *string) { - v.value = val - v.isSet = true -} - -func (v NullableString) IsSet() bool { - return v.isSet -} - -func (v *NullableString) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableString(val *string) *NullableString { - return &NullableString{value: val, isSet: true} -} - -func (v NullableString) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableString) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - -type NullableTime struct { - value *time.Time - isSet bool -} - -func (v NullableTime) Get() *time.Time { - return v.value -} - -func (v *NullableTime) Set(val *time.Time) { - v.value = val - v.isSet = true -} - -func (v NullableTime) IsSet() bool { - return v.isSet -} - -func (v *NullableTime) Unset() { - v.value = nil - v.isSet = false -} - -func NewNullableTime(val *time.Time) *NullableTime { - return &NullableTime{value: val, isSet: true} -} - -func (v NullableTime) MarshalJSON() ([]byte, error) { - return json.Marshal(v.value) -} - -func (v *NullableTime) UnmarshalJSON(src []byte) error { - v.isSet = true - return json.Unmarshal(src, &v.value) -} - -// IsNil checks if an input is nil -func IsNil(i interface{}) bool { - if i == nil { - return true - } - switch reflect.TypeOf(i).Kind() { - case reflect.Chan, reflect.Func, reflect.Map, reflect.Ptr, reflect.UnsafePointer, reflect.Interface, reflect.Slice: - return reflect.ValueOf(i).IsNil() - case reflect.Array: - return reflect.ValueOf(i).IsZero() - } - return false -} - -type MappedNullable interface { - ToMap() (map[string]interface{}, error) -} - -// A wrapper for strict JSON decoding -func newStrictDecoder(data []byte) *json.Decoder { - dec := json.NewDecoder(bytes.NewBuffer(data)) - dec.DisallowUnknownFields() - return dec -} - -// Prevent trying to import "fmt" -func reportError(format string, a ...interface{}) error { - return fmt.Errorf(format, a...) -} \ No newline at end of file diff --git a/openapi/membership.yaml b/openapi/membership.yaml new file mode 100644 index 00000000..4f6c47ad --- /dev/null +++ b/openapi/membership.yaml @@ -0,0 +1,3491 @@ +openapi: 3.0.3 +info: + title: Membership API + contact: {} + version: "0.1.0" + +servers: + - url: http://localhost:8080 + description: Local server + +paths: + /_info: + get: + summary: Get server info + operationId: getServerInfo + responses: + 200: + description: Server information + content: + application/json: + schema: + $ref: "#/components/schemas/ServerInfo" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations: + get: + summary: List organizations of the connected user + operationId: listOrganizations + security: + - oauth2: [] + parameters: + - name: expand + in: query + schema: + type: boolean + required: false + responses: + 200: + description: List of organizations + content: + application/json: + schema: + $ref: "#/components/schemas/ListOrganizationExpandedResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + summary: Create organization + operationId: createOrganization + security: + - oauth2: [] + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/CreateOrganizationRequest" + responses: + 201: + description: Organization created + content: + application/json: + schema: + $ref: "#/components/schemas/CreateOrganizationResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + + /organizations/expanded: + get: + summary: List organizations of the connected user with expanded data + operationId: listOrganizationsExpanded + security: + - oauth2: [] + deprecated: true + responses: + 200: + description: List of organizations with expanded data + content: + application/json: + schema: + $ref: "#/components/schemas/ListOrganizationExpandedResponse" + /organizations/{organizationId}: + get: + summary: Read organization + operationId: readOrganization + security: + - oauth2: + - organization:Read + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: expand + in: query + schema: + type: boolean + required: false + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ReadOrganizationResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + + put: + summary: Update organization + operationId: updateOrganization + security: + - oauth2: + - organization:Update + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/OrganizationData" + responses: + 200: + description: Organization updated + content: + application/json: + schema: + $ref: "#/components/schemas/ReadOrganizationResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + summary: Delete organization + operationId: deleteOrganization + security: + - oauth2: + - organization:Delete + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + responses: + 204: + description: Organization deleted + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/authentication-provider: + get: + summary: Read authentication provider + operationId: readAuthenticationProvider + security: + - oauth2: + - organization:ReadAuthProvider + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + responses: + 200: + description: Authentication provider details + content: + application/json: + schema: + $ref: "#/components/schemas/AuthenticationProviderResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + put: + summary: Upsert an authentication provider + operationId: upsertAuthenticationProvider + security: + - oauth2: + - organization:UpdateAuthProvider + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/UpsertAuthenticationProviderRequest" + responses: + 200: + description: Authentication provider created or updated + content: + application/json: + schema: + $ref: "#/components/schemas/AuthenticationProviderResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + summary: Delete authentication provider + operationId: deleteAuthenticationProvider + security: + - oauth2: + - organization:DeleteAuthProvider + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + responses: + 204: + description: Authentication provider deleted + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + + /organizations/{organizationId}/features: + get: + summary: List features + operationId: listFeatures + security: + - oauth2: + - organization:ListFeatures + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + responses: + 200: + description: List of features + content: + application/json: + schema: + type: object + required: + - data + properties: + data: + type: array + items: + $ref: "#/components/schemas/OrganizationFeature" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + summary: Add Features + operationId: addFeatures + security: + - oauth2: + - organization:UpdateFeatures + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + requestBody: + content: + application/json: + schema: + type: object + required: + - features + properties: + features: + type: array + items: + type: string + responses: + 204: + description: Features added + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/features/{name}: + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: name + in: path + schema: + type: string + required: true + delete: + summary: Delete feature + operationId: deleteFeature + security: + - oauth2: + - organization:UpdateFeatures + responses: + 204: + description: Feature deleted + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/client: + get: + summary: Read organization client (DEPRECATED) (until 12/31/2025) + operationId: readOrganizationClient + security: + - oauth2: + - organization:ReadClient + deprecated: true + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + responses: + 200: + description: Organization client + content: + application/json: + schema: + $ref: "#/components/schemas/CreateClientResponseResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + put: + summary: Create organization client (DEPRECATED) (until 12/31/2025) + operationId: createOrganizationClient + security: + - oauth2: + - organization:CreateClient + deprecated: true + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + responses: + 201: + description: Client organization created + content: + application/json: + schema: + $ref: "#/components/schemas/CreateClientResponseResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + summary: Delete organization client (DEPRECATED) (until 12/31/2025) + operationId: deleteOrganizationClient + security: + - oauth2: + - organization:DeleteClient + deprecated: true + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + responses: + 204: + description: Client deleted + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/clients: + get: + summary: Read organization clients + operationId: organizationClientsRead + security: + - oauth2: + - organization:ListClients + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: cursor + in: query + schema: + type: string + - name: pageSize + in: query + schema: + type: integer + minimum: 1 + responses: + 200: + description: Organization client + content: + application/json: + schema: + $ref: "#/components/schemas/ReadOrganizationClientsResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + summary: Create organization client + operationId: organizationClientCreate + security: + - oauth2: + - organization:CreateClient + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/CreateOrganizationClientRequest" + responses: + 201: + description: Organization client created + content: + application/json: + schema: + $ref: "#/components/schemas/CreateOrganizationClientResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/clients/{clientId}: + get: + summary: Read organization client + operationId: organizationClientRead + security: + - oauth2: + - organization:ReadClient + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: clientId + in: path + schema: + type: string + required: true + responses: + 200: + description: Organization client details + content: + application/json: + schema: + $ref: "#/components/schemas/ReadOrganizationClientResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + summary: Delete organization client + operationId: organizationClientDelete + security: + - oauth2: + - organization:DeleteClient + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: clientId + in: path + schema: + type: string + required: true + responses: + 204: + description: Client deleted + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + put: + summary: Update organization client + operationId: organizationClientUpdate + security: + - oauth2: + - organization:UpdateClient + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: clientId + in: path + schema: + type: string + required: true + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateOrganizationClientRequest" + responses: + 204: + description: Client updated + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/logs: + get: + summary: List logs + operationId: listLogs + security: + - oauth2: + - organization:ReadLogs + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: stackId + in: query + schema: + type: string + required: false + - name: cursor + in: query + schema: + type: string + required: false + - name: pageSize + in: query + schema: + type: integer + minimum: 1 + required: false + - name: action + in: query + schema: + $ref: "#/components/schemas/Action" + required: false + - name: userId + in: query + schema: + type: string + required: false + - name: key + in: query + schema: + type: string + required: false + - name: value + in: query + schema: + type: string + required: false + responses: + 200: + description: Cursor of logs + content: + application/json: + schema: + $ref: "#/components/schemas/LogCursor" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/users: + get: + summary: List users of organization + operationId: listUsersOfOrganization + security: + - oauth2: + - organization:ListUsers + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + responses: + 200: + description: List of users + content: + application/json: + schema: + $ref: "#/components/schemas/ListUsersResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/users/{userId}: + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: userId + in: path + schema: + type: string + required: true + get: + summary: Read user of organization + operationId: readUserOfOrganization + security: + - oauth2: + - organization:ReadUser + responses: + 200: + description: Read a user + content: + application/json: + schema: + $ref: "#/components/schemas/ReadOrganizationUserResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + put: + summary: Update user within an organization + operationId: upsertOrganizationUser + security: + - oauth2: + - organization:UpdateUser + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateOrganizationUserRequest" + responses: + 204: + description: Updated user + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + summary: delete user from organization + operationId: deleteUserFromOrganization + security: + - oauth2: + - organization:DeleteUser + description: | + The owner of the organization can remove anyone while each user can leave any organization where it is not owner. + responses: + 204: + description: User deleted from organization + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/policies: + get: + summary: List policies of organization + operationId: listPolicies + security: + - oauth2: + - organization:ListPolicies + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + responses: + 200: + description: List of policies + content: + application/json: + schema: + $ref: "#/components/schemas/ListPoliciesResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + summary: Create policy + operationId: createPolicy + security: + - oauth2: + - organization:CreatePolicy + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/CreatePolicyRequest" + responses: + 201: + description: Policy created + content: + application/json: + schema: + $ref: "#/components/schemas/CreatePolicyResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/policies/{policyId}: + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: policyId + in: path + schema: + type: integer + required: true + get: + summary: Read policy with scopes + operationId: readPolicy + security: + - oauth2: + - organization:ReadPolicy + responses: + 200: + description: Policy with scopes + content: + application/json: + schema: + $ref: "#/components/schemas/ReadPolicyResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + put: + summary: Update policy + operationId: updatePolicy + security: + - oauth2: + - organization:UpdatePolicy + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/UpdatePolicyRequest" + responses: + 200: + description: Policy updated + content: + application/json: + schema: + $ref: "#/components/schemas/UpdatePolicyResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + summary: Delete policy + operationId: deletePolicy + security: + - oauth2: + - organization:DeletePolicy + responses: + 204: + description: Policy deleted + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/policies/{policyId}/scopes/{scopeId}: + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: policyId + in: path + schema: + type: integer + required: true + - name: scopeId + in: path + schema: + type: integer + required: true + put: + summary: Add scope to policy + operationId: addScopeToPolicy + security: + - oauth2: + - organization:UpdatePolicy + responses: + 204: + description: Scope added to policy + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + summary: Remove scope from policy + operationId: removeScopeFromPolicy + security: + - oauth2: + - organization:UpdatePolicy + responses: + 204: + description: Scope removed from policy + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/stacks: + get: + summary: List stacks + operationId: listStacks + security: + - oauth2: + - organization:ListStacks + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: all + in: query + description: Include deleted and disabled stacks + schema: + type: boolean + required: false + - name: deleted + in: query + description: Include deleted stacks + deprecated: true + schema: + type: boolean + required: false + responses: + 200: + description: List of stacks + content: + application/json: + schema: + $ref: "#/components/schemas/ListStacksResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + summary: Create stack + operationId: createStack + security: + - oauth2: + - organization:CreateStack + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/CreateStackRequest" + responses: + 202: + description: Stack created + content: + application/json: + schema: + $ref: "#/components/schemas/CreateStackResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/stacks/{stackId}/modules: + get: + summary: List modules of a stack + operationId: listModules + security: + - oauth2: + - organization:ListStackModules + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: stackId + in: path + schema: + type: string + required: true + responses: + 200: + description: List of modules + content: + application/json: + schema: + $ref: "#/components/schemas/ListModulesResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + summary: enable module + operationId: enableModule + security: + - oauth2: + - organization:EnableStackModulesEnable + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: stackId + in: path + schema: + type: string + required: true + - name: name + in: query + schema: + type: string + required: true + responses: + 202: + description: Module enabled + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + summary: disable module + operationId: disableModule + security: + - oauth2: + - organization:DisableStackModule + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: stackId + in: path + schema: + type: string + required: true + - name: name + in: query + schema: + type: string + required: true + responses: + 202: + description: Module disabled + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + + /organizations/{organizationId}/stacks/{stackId}/upgrade: + put: + summary: Upgrade stack + operationId: upgradeStack + security: + - oauth2: + - organization:UpgradeStack + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: stackId + in: path + schema: + type: string + required: true + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/StackVersion" + responses: + 202: + description: Stack upgrade accepted + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/stacks/{stackId}: + get: + summary: Find stack + operationId: getStack + security: + - oauth2: + - organization:ReadStack + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: stackId + in: path + schema: + type: string + required: true + responses: + 200: + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ReadStackResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + put: + summary: Update stack + operationId: updateStack + security: + - oauth2: + - organization:UpdateStack + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: stackId + in: path + schema: + type: string + required: true + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateStackRequest" + responses: + 200: + description: Updated stack + content: + application/json: + schema: + $ref: "#/components/schemas/ReadStackResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + + delete: + summary: Delete stack + operationId: deleteStack + security: + - oauth2: + - organization:DeleteStack + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: stackId + in: path + schema: + type: string + required: true + - name: force + in: query + schema: + type: boolean + required: false + responses: + 204: + description: Stack deleted + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/stacks/{stackId}/users: + get: + summary: List stack users accesses within an organization + operationId: listStackUsersAccesses + security: + - oauth2: + - organization:ListStackUsers + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: stackId + in: path + schema: + type: string + required: true + responses: + 200: + description: Stack users access + content: + application/json: + schema: + $ref: "#/components/schemas/StackUserAccessResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/stacks/{stackId}/users/{userId}: + get: + summary: Read stack user access within an organization + operationId: readStackUserAccess + security: + - oauth2: + - organization:ReadStackUser + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: stackId + in: path + schema: + type: string + required: true + - name: userId + in: path + schema: + type: string + required: true + responses: + 200: + description: Stack user access + content: + application/json: + schema: + $ref: "#/components/schemas/ReadStackUserAccess" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + summary: Delete stack user access within an organization + operationId: deleteStackUserAccess + security: + - oauth2: + - organization:DeleteStackUser + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: stackId + in: path + schema: + type: string + required: true + - name: userId + in: path + schema: + type: string + required: true + responses: + 204: + description: Updated user + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + put: + summary: Update stack user access within an organization + operationId: upsertStackUserAccess + security: + - oauth2: + - organization:CreateStackUser + - organization:UpdateStackUser + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: stackId + in: path + schema: + type: string + required: true + - name: userId + in: path + schema: + type: string + required: true + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateStackUserRequest" + responses: + 204: + description: Updated user + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/stacks/{stackId}/disable: + put: + summary: Disable stack + operationId: disableStack + security: + - oauth2: + - organization:DisableStack + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: stackId + in: path + schema: + type: string + required: true + responses: + 202: + description: Stack disabled + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/stacks/{stackId}/enable: + put: + summary: Enable stack + operationId: enableStack + security: + - oauth2: + - organization:EnableStack + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: stackId + in: path + schema: + type: string + required: true + responses: + 202: + description: Stack enabled + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/stacks/{stackId}/restore: + put: + summary: Restore stack + operationId: restoreStack + security: + - oauth2: + - organization:RestoreStack + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: stackId + in: path + schema: + type: string + required: true + responses: + 202: + description: OK + content: + application/json: + schema: + $ref: "#/components/schemas/ReadStackResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/stacks/{stackId}/stargate/enable: + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: stackId + in: path + schema: + type: string + required: true + put: + summary: Enable stargate on a stack + operationId: enableStargate + security: + - oauth2: + - organization:EnableStackModule + responses: + 202: + description: OK + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/stacks/{stackId}/stargate/disable: + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: stackId + in: path + schema: + type: string + required: true + put: + summary: Disable stargate on a stack + operationId: disableStargate + security: + - oauth2: + - organization:DisableStackModule + responses: + 202: + description: OK + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /me/invitations: + get: + summary: List invitations of the user + operationId: listInvitations + security: + - oauth2: [] + parameters: + - in: query + name: status + required: false + description: Status of organizations + schema: + type: string + - in: query + name: organization + required: false + description: Status of organizations + schema: + type: string + responses: + 200: + description: List of the invitations for the connected user + content: + application/json: + schema: + $ref: "#/components/schemas/ListInvitationsResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /me/invitations/{invitationId}/accept: + post: + summary: Accept invitation + operationId: acceptInvitation + security: + - oauth2: [] + parameters: + - name: invitationId + in: path + schema: + type: string + required: true + responses: + 204: + description: Invitation accepted + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /me/invitations/{invitationId}/reject: + post: + summary: Decline invitation + operationId: declineInvitation + security: + - oauth2: [] + parameters: + - name: invitationId + in: path + schema: + type: string + required: true + responses: + 204: + description: Invitation declined + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/invitations: + get: + summary: List invitations of the organization + operationId: listOrganizationInvitations + security: + - oauth2: + - organization:ListInvitations + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - in: query + name: status + required: false + description: Status of organizations + schema: + type: string + responses: + 200: + description: List of the invitations for the organization + content: + application/json: + schema: + $ref: "#/components/schemas/ListInvitationsResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + summary: Create invitation + operationId: createInvitation + security: + - oauth2: + - organization:CreateInvitation + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: email + in: query + schema: + type: string + required: true + responses: + 200: + description: Invitation already sent + content: + application/json: + schema: + $ref: "#/components/schemas/CreateInvitationResponse" + 201: + description: Invitation created + content: + application/json: + schema: + $ref: "#/components/schemas/CreateInvitationResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/invitations/{invitationId}: + delete: + summary: Delete invitation + operationId: deleteInvitation + security: + - oauth2: + - organization:DeleteInvitation + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: invitationId + in: path + schema: + type: string + required: true + responses: + 204: + description: Invitation deleted + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/regions: + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + + get: + summary: List regions + operationId: listRegions + security: + - oauth2: + - organization:ListRegions + responses: + 200: + description: List of the regions + content: + application/json: + schema: + $ref: "#/components/schemas/ListRegionsResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + summary: Create a private region + operationId: createPrivateRegion + security: + - oauth2: + - organization:CreateRegion + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/CreatePrivateRegionRequest" + responses: + 200: + description: Created region + content: + application/json: + schema: + $ref: "#/components/schemas/CreatedPrivateRegionResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/regions/{regionID}: + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: regionID + in: path + schema: + type: string + required: true + get: + summary: Get region + operationId: getRegion + security: + - oauth2: + - organization:ReadRegion + responses: + 200: + description: Get a specific region + content: + application/json: + schema: + $ref: "#/components/schemas/GetRegionResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + summary: Delete region + operationId: deleteRegion + security: + - oauth2: + - organization:DeleteRegion + responses: + 204: + description: Delete a specific region + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/regions/{regionID}/versions: + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: regionID + in: path + schema: + type: string + required: true + get: + summary: Get region versions + operationId: getRegionVersions + security: + - oauth2: + - organization:ReadRegion + responses: + 200: + description: Get a specific region + content: + application/json: + schema: + $ref: "#/components/schemas/GetRegionVersionsResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/applications: + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + get: + summary: List applications enabled for organization + operationId: listOrganizationApplications + security: + - oauth2: + - organization:Read + parameters: + - name: pageSize + in: query + schema: + type: integer + default: 15 + required: false + - name: page + in: query + schema: + type: integer + default: 0 + required: false + responses: + 200: + description: List of applications enabled for organization + content: + application/json: + schema: + $ref: "#/components/schemas/ListApplicationsResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /organizations/{organizationId}/applications/{applicationId}: + parameters: + - name: organizationId + in: path + schema: + type: string + required: true + - name: applicationId + in: path + schema: + type: string + required: true + get: + summary: Get application for organization + operationId: getOrganizationApplication + security: + - oauth2: + - organization:Read + responses: + 200: + description: Application details + content: + application/json: + schema: + $ref: "#/components/schemas/GetApplicationResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + put: + summary: Enable application for organization + operationId: enableApplicationForOrganization + security: + - oauth2: + - system:Admin + responses: + 201: + description: Application enabled for organization + content: + application/json: + schema: + $ref: "#/components/schemas/EnableApplicationForOrganizationResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + summary: Disable application for organization + operationId: disableApplicationForOrganization + security: + - oauth2: + - system:Admin + responses: + 204: + description: Application disabled for organization + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /applications: + get: + summary: List applications + operationId: listApplications + security: + - oauth2: + - system:Admin + responses: + 200: + description: List of applications + content: + application/json: + schema: + $ref: "#/components/schemas/ListApplicationsResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + post: + summary: Create application + operationId: createApplication + security: + - oauth2: + - system:Admin + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/ApplicationData" + responses: + 201: + description: Application created + content: + application/json: + schema: + $ref: "#/components/schemas/CreateApplicationResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /applications/{applicationId}: + parameters: + - name: applicationId + in: path + schema: + type: string + required: true + get: + summary: Get application + operationId: getApplication + security: + - oauth2: + - system:Admin + responses: + 200: + description: Application details + content: + application/json: + schema: + $ref: "#/components/schemas/GetApplicationResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + put: + summary: Update application + operationId: updateApplication + security: + - oauth2: + - system:Admin + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/ApplicationData" + responses: + 200: + description: Application updated + content: + application/json: + schema: + $ref: "#/components/schemas/UpdateApplicationResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + delete: + summary: Delete application + operationId: deleteApplication + security: + - oauth2: + - system:Admin + responses: + 204: + description: Application deleted + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /applications/{applicationId}/scopes: + parameters: + - name: applicationId + in: path + description: The unique identifier of the application (UUID format) + schema: + type: string + format: uuid + required: true + example: "550e8400-e29b-41d4-a716-446655440000" + post: + summary: Create application scope + operationId: createApplicationScope + security: + - oauth2: + - system:Admin + requestBody: + content: + application/json: + schema: + $ref: "#/components/schemas/CreateApplicationScopeRequest" + responses: + 201: + description: Application scope created + content: + application/json: + schema: + $ref: "#/components/schemas/CreateApplicationScopeResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /applications/{applicationId}/scopes/{scopeID}: + parameters: + - name: applicationId + in: path + description: The unique identifier of the application (UUID format) + schema: + type: string + format: uuid + required: true + example: "550e8400-e29b-41d4-a716-446655440000" + - name: scopeID + in: path + description: The unique identifier of the scope to operate on + schema: + type: integer + required: true + + delete: + summary: Delete application scope + description: Delete a specific scope from an application. This operation requires system administrator privileges. + operationId: deleteApplicationScope + security: + - oauth2: + - system:Admin + responses: + 204: + description: Application scope deleted successfully + 400: + description: Invalid request (invalid UUID or empty scope ID) + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + 404: + description: Application or scope not found + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + 500: + description: Internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /users: + post: + summary: Create user + description: Create a new user in the system. This operation requires system administrator privileges. + operationId: createUser + security: + - oauth2: + - system:Admin + requestBody: + required: true + content: + application/json: + schema: + $ref: "#/components/schemas/CreateUserRequest" + responses: + 201: + description: User created successfully + content: + application/json: + schema: + $ref: "#/components/schemas/CreateUserResponse" + 400: + description: Invalid request (missing or invalid email) + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + 500: + description: Internal server error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" + /me: + get: + summary: Read user + operationId: readConnectedUser + security: + - oauth2: [] + responses: + 200: + description: Read a user + content: + application/json: + schema: + $ref: "#/components/schemas/ReadUserResponse" + default: + description: Error + content: + application/json: + schema: + $ref: "#/components/schemas/Error" +security: + - oauth2: [] + +components: + securitySchemes: + oauth2: + type: oauth2 + flows: + authorizationCode: + authorizationUrl: /authorize + tokenUrl: /oauth/token + scopes: + # OIDC Standard Scopes + openid: Enable OIDC + profile: Access to user profile information + email: Access to email address + phone: Access to phone number + address: Access to postal address + offline_access: Allows obtaining refresh token + # Extended OIDC Scopes + accesses: Includes organization and stack access information in tokens + keep_refresh_token: Keep refresh token across sessions + remember_me: Enable remember me functionality + on_behalf: Allow to provide id_token usable as id_token_hint for quick reauthentication + # System Scopes + system:Admin: Full system administration access + # Stack Scopes + stack:Read: Read-only access to stack services + stack:Write: Write access to stack services + # Organization Scopes + organization:Read: Read organization details + organization:Create: Create organization + organization:Update: Update organization details + organization:Delete: Delete organization + # User Management Scopes + organization:ListUsers: List organization users + organization:ReadUser: Read user details + organization:CreateUser: Create/Invite users to organization + organization:UpdateUser: Update user details + organization:DeleteUser: Remove users from organization + # Policy Management Scopes + organization:ListPolicies: List organization policies + organization:ReadPolicy: Read policy details + organization:CreatePolicy: Create policies + organization:UpdatePolicy: Update policies and manage their scopes + organization:DeletePolicy: Delete policies + # Invitation Management Scopes + organization:ListInvitations: List organization invitations + organization:ReadInvitation: Read invitation details + organization:CreateInvitation: Create invitations + organization:UpdateInvitation: Update invitations + organization:AcceptInvitation: Accept invitations + organization:RejectInvitation: Reject invitations + organization:DeleteInvitation: Delete invitations + # Region Management Scopes + organization:ListRegions: List organization regions + organization:ReadRegion: Read region details + organization:CreateRegion: Create regions + organization:UpdateRegion: Update regions + organization:DeleteRegion: Delete regions + # Stack Management Scopes + organization:ListStacks: List organization stacks + organization:ReadStack: Read stack details + organization:CreateStack: Create stacks + organization:UpdateStack: Update stacks + organization:DeleteStack: Delete stacks + organization:EnableStack: Enable stacks + organization:DisableStack: Disable stacks + organization:RestoreStack: Restore stacks + organization:UpgradeStack: Upgrade stacks + # Stack Users Management Scopes + organization:ListStackUsers: List stack users + organization:ReadStackUser: Read stack user details + organization:CreateStackUser: Add users to stack + organization:UpdateStackUser: Update stack user access + organization:DeleteStackUser: Remove users from stack + # Stack Modules Management Scopes + organization:ListStackModules: List stack modules + organization:EnableStackModule: Enable stack modules + organization:DisableStackModule: Disable stack modules + # Client Management Scopes + organization:ListClients: List organization clients + organization:ReadClient: Read client details + organization:CreateClient: Create clients + organization:UpdateClient: Update clients + organization:DeleteClient: Delete clients + # Authentication Provider Scopes + organization:ReadAuthProvider: Read authentication provider configuration + organization:UpdateAuthProvider: Update authentication provider configuration + organization:DeleteAuthProvider: Delete authentication provider configuration + # Logs Scopes + organization:ReadLogs: Read organization logs + # Features Scopes + organization:ListFeatures: List organization features + organization:ReadFeature: Read feature details + organization:UpdateFeatures: Update organization features + schemas: + Module: + type: object + required: + - name + - state + - status + - lastStatusUpdate + - lastStateUpdate + properties: + name: + type: string + state: + type: string + enum: + - ENABLED + - DISABLED + status: + type: string + enum: + - UNKNOWN + - PROGRESSING + - READY + - DELETED + lastStatusUpdate: + type: string + format: date-time + lastStateUpdate: + type: string + format: date-time + clusterStatus: + type: object + + ListModulesResponse: + type: object + required: + - data + properties: + data: + type: array + items: + $ref: "#/components/schemas/Module" + Action: + type: string + enum: + - agents.connected + - agents.disconnected + - invitations.created + - invitations.accepted + - invitations.rejected + - invitations.cancelled + - organizations.created + - organizations.updated + - organizations.deleted + - organizations.user.deleted + - organizations.user.updated + - regions.created + - regions.deleted + - users.created + - users.deleted + - stacks.disposal + - stacks.disposal-reset + - stacks.warned + - stacks.pruned + - stacks.status.updated + - stacks.created + - stacks.updated + - stacks.deleted + - stacks.restored + - stacks.disabled + - stacks.enabled + - stacks.upgraded + - stacks.stargate.enabled + - stacks.stargate.disabled + - stacks.user.updated + - stacks.user.deleted + - stacks.reachness.updated + - stacks.module.enabled + - stacks.module.disabled + - stacks.module.status.updated + - policies.created + - policies.updated + - policies.deleted + - policies.scope.added + - policies.scope.removed + LogCursor: + properties: + data: + allOf: + - $ref: "#/components/schemas/Cursor" + - type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/Log" + required: + - data + Log: + type: object + required: + - seq + - organizationId + - userId + - action + - date + - data + properties: + seq: + type: string + example: 1e6f8b6e-1b6b-4b3b-8b3b-1b6b4b3b8b3b + organizationId: + type: string + userId: + type: string + action: + type: string + date: + type: string + format: date-time + data: + type: object + Cursor: + type: object + required: + - pageSize + - hasMore + - data + properties: + pageSize: + type: integer + format: int64 + minimum: 1 + maximum: 1000 + example: 15 + hasMore: + type: boolean + example: false + previous: + type: string + example: YXVsdCBhbmQgYSBtYXhpbXVtIG1heF9yZXN1bHRzLol= + next: + type: string + example: "" + OrganizationFeature: + type: object + required: + - name + - organizationID + - createdAt + properties: + organizationID: + type: string + name: + type: string + createdAt: + type: string + format: date-time + CreatePrivateRegionRequest: + type: object + properties: + name: + type: string + required: + - name + CreatedPrivateRegionResponse: + properties: + data: + $ref: "#/components/schemas/PrivateRegion" + required: + - data + PrivateRegion: + allOf: + - $ref: "#/components/schemas/Region" + - type: object + properties: + organizationID: + type: string + creatorID: + type: string + secret: + $ref: "#/components/schemas/PrivateRegionSecret" + required: + - organizationID + - creatorID + PublicRegion: + allOf: + - $ref: "#/components/schemas/Region" + - type: object + properties: + production: + type: boolean + required: + - production + AnyRegion: + allOf: + - $ref: "#/components/schemas/Region" + - type: object + properties: + clientID: + type: string + organizationID: + type: string + creator: + $ref: "#/components/schemas/User" + production: + type: boolean + public: + type: boolean + version: + type: string + agentID: + type: string + outdated: + type: boolean + secret: + $ref: "#/components/schemas/PrivateRegionSecret" + + required: + - public + - agentID + - outdated + PrivateRegionSecret: + type: object + required: + - lastDigits + properties: + lastDigits: + type: string + clear: + type: string + OrganizationData: + type: object + required: + - name + - defaultPolicyID + properties: + name: + type: string + description: Organization name + domain: + type: string + description: Organization domain + defaultPolicyID: + type: integer + description: Default policy ID applied to new users + nullable: true + CreateOrganizationClientRequest: + type: object + properties: + name: + type: string + description: Name of the client + description: + type: string + description: Description of the client + UpdateOrganizationClientRequest: + type: object + required: + - name + properties: + name: + type: string + description: Name of the client + description: + type: string + description: Description of the client + CreateOrganizationClientResponse: + type: object + required: + - data + properties: + data: + $ref: "#/components/schemas/OrganizationClient" + ReadOrganizationClientResponse: + type: object + required: + - data + properties: + data: + $ref: "#/components/schemas/OrganizationClient" + ReadOrganizationClientsResponse: + type: object + required: + - data + properties: + data: + allOf: + - $ref: "#/components/schemas/Cursor" + - type: object + required: + - data + properties: + data: + type: array + items: + $ref: "#/components/schemas/OrganizationClient" + OrganizationClient: + type: object + required: + - id + - secret + - createdAt + - updatedAt + - description + - name + properties: + id: + type: string + description: Organization ID + secret: + type: object + required: + - lastDigits + properties: + lastDigits: + type: string + clear: + type: string + name: + type: string + description: Name of the client + description: + type: string + description: Description of the client + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + Organization: + allOf: + - $ref: "#/components/schemas/OrganizationData" + - type: object + required: + - id + - ownerId + properties: + id: + type: string + description: Organization ID + ownerId: + type: string + description: Owner ID + availableStacks: + type: integer + description: Number of available stacks + availableSandboxes: + type: integer + description: Number of available sandboxes + createdAt: + type: string + format: date-time + updatedAt: + type: string + format: date-time + StackData: + type: object + required: + - name + properties: + name: + type: string + description: Stack name + metadata: + type: object + additionalProperties: + type: string + StackVersion: + type: object + properties: + version: + type: string + description: Supported only with agent version >= v0.7.0 + StackLifeCycle: + type: object + required: + - status + - state + - expectedStatus + - lastStateUpdate + - lastExpectedStatusUpdate + - lastStatusUpdate + properties: + status: + type: string + enum: + - UNKNOWN + - PROGRESSING + - READY + - DISABLED + - DELETED + state: + type: string + enum: + - ACTIVE + - DISABLED + - DELETED + expectedStatus: + type: string + enum: + - READY + - DISABLED + - DELETED + lastStateUpdate: + type: string + format: date-time + lastExpectedStatusUpdate: + type: string + format: date-time + lastStatusUpdate: + type: string + format: date-time + warnedAt: + type: string + format: date-time + disposableSince: + type: string + format: date-time + + StackReachability: + properties: + reachable: + description: Stack is reachable through Stargate + type: boolean + lastReachableUpdate: + description: Last time the stack was reachable + format: date-time + type: string + required: + - reachable + type: object + Stack: + allOf: + - $ref: "#/components/schemas/StackData" + - $ref: "#/components/schemas/StackVersion" + - $ref: "#/components/schemas/StackLifeCycle" + - $ref: "#/components/schemas/StackReachability" + - type: object + required: + - id + - organizationId + - uri + - regionID + - stargateEnabled + - synchronised + - modules + properties: + id: + type: string + description: Stack ID + organizationId: + type: string + description: Organization ID + uri: + type: string + description: Base stack uri + regionID: + type: string + description: The region where the stack is installed + region: + $ref: "#/components/schemas/Region" + stargateEnabled: + type: boolean + createdAt: + type: string + format: date-time + deletedAt: + type: string + format: date-time + disabledAt: + type: string + format: date-time + auditEnabled: + type: boolean + synchronised: + type: boolean + updatedAt: + type: string + format: date-time + modules: + type: array + items: + $ref: "#/components/schemas/Module" + + UserData: + allOf: + - type: object + properties: + email: + type: string + required: + - email + SystemRole: + type: string + enum: + - USER + - SYSTEM + User: + allOf: + - $ref: "#/components/schemas/UserData" + - type: object + required: + - id + properties: + id: + type: string + description: User ID + - type: object + properties: + role: + $ref: "#/components/schemas/SystemRole" + CreateUserRequest: + type: object + required: + - email + properties: + email: + type: string + format: email + description: Email address of the user to create + example: "user@example.com" + CreateUserResponse: + type: object + properties: + data: + $ref: "#/components/schemas/User" + OrganizationUserArray: + type: array + items: + allOf: + - $ref: "#/components/schemas/OrganizationUser" + ReadOrganizationUserResponse: + type: object + properties: + data: + $ref: "#/components/schemas/OrganizationUser" + OrganizationUser: + allOf: + - type: object + required: + - email + - id + - policyId + properties: + email: + type: string + id: + type: string + policyId: + type: integer + description: Policy ID applied to the user + + OrganizationArray: + type: array + items: + $ref: "#/components/schemas/Organization" + StackArray: + type: array + items: + $ref: "#/components/schemas/Stack" + UserArray: + type: array + items: + $ref: "#/components/schemas/User" + ReadStackUserAccess: + type: object + properties: + data: + $ref: "#/components/schemas/StackUserAccess" + StackUserAccess: + allOf: + - type: object + required: + - stackId + - userId + - email + - policyId + properties: + stackId: + type: string + description: Stack ID + userId: + type: string + description: User ID + email: + type: string + description: User email + policyId: + type: integer + description: Policy ID applied to the user for the stack + StackUserAccessResponse: + type: object + properties: + data: + $ref: "#/components/schemas/StackUserAccessArray" + StackUserAccessArray: + type: array + items: + $ref: "#/components/schemas/StackUserAccess" + ListOrganizationResponse: + type: object + properties: + data: + $ref: "#/components/schemas/OrganizationArray" + CreateOrganizationRequest: + type: object + required: + - name + properties: + name: + type: string + description: Organization name + domain: + type: string + description: Organization domain + defaultPolicyID: + type: integer + description: Default policy ID applied to new users + ownerID: + type: string + description: User ID of the owner of the organization (only when used with a non user agent) + CreateOrganizationResponse: + type: object + properties: + data: + $ref: "#/components/schemas/OrganizationExpanded" + ReadOrganizationResponse: + type: object + properties: + data: + $ref: "#/components/schemas/OrganizationExpanded" + ListStacksResponse: + type: object + properties: + data: + $ref: "#/components/schemas/StackArray" + ListUsersResponse: + type: object + properties: + data: + $ref: "#/components/schemas/OrganizationUserArray" + CreateStackRequest: + allOf: + - $ref: "#/components/schemas/StackData" + - $ref: "#/components/schemas/StackVersion" + - type: object + properties: + regionID: + type: string + required: + - regionID + UpdateStackRequest: + allOf: + - $ref: "#/components/schemas/StackData" + CreateStackResponse: + type: object + properties: + data: + $ref: "#/components/schemas/Stack" + ReadStackResponse: + $ref: "#/components/schemas/CreateStackResponse" + ReadUserResponse: + type: object + properties: + data: + $ref: "#/components/schemas/User" + ListInvitationsResponse: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/Invitation" + CreateInvitationResponse: + type: object + properties: + data: + $ref: "#/components/schemas/Invitation" + Error: + type: object + properties: + errorCode: + type: string + errorMessage: + type: string + required: + - errorCode + Invitation: + type: object + properties: + id: + type: string + organizationId: + type: string + userEmail: + type: string + status: + type: string + enum: + - PENDING + - ACCEPTED + - REJECTED + - CANCELLED + creationDate: + type: string + format: date-time + updatedAt: + type: string + format: date-tim + userId: + type: string + organizationAccess: + $ref: "#/components/schemas/OrganizationUser" + expiresAt: + type: string + format: date-time + creatorId: + type: string + lastUpdate: + type: string + format: date-time + required: + - creationDate + - status + - creatorID + - userEmail + - organizationId + - id + - policyId + Region: + type: object + required: + - id + - baseUrl + - active + - createdAt + - name + - capabilities + - agentID + - outdated + properties: + id: + type: string + baseUrl: + type: string + createdAt: + type: string + format: datetime + active: + type: boolean + lastPing: + type: string + format: date-time + name: + type: string + capabilities: + $ref: "#/components/schemas/RegionCapability" + agentID: + type: string + outdated: + type: boolean + creatorId: + type: string + version: + type: string + + RegionCapability: + type: object + properties: + MODULE_LIST: + type: array + items: + type: string + EE: + type: array + items: + type: string + RegionCapabilityKeys: + type: string + enum: + - MODULE_LIST + - EE + ListOrganizationExpandedResponse: + type: object + properties: + data: + type: array + items: + allOf: + - $ref: "#/components/schemas/OrganizationExpanded" + CreateClientResponseResponse: + type: object + properties: + data: + allOf: + - $ref: "#/components/schemas/OrganizationClient" + - type: object + properties: + ownerId: + type: string + description: The ID of the owner of the client (DEPRECATED will be empty) + required: + - ownerId + OrganizationExpanded: + allOf: + - $ref: "#/components/schemas/Organization" + - type: object + properties: + totalStacks: + type: integer + totalUsers: + type: integer + owner: + $ref: "#/components/schemas/User" + ListRegionsResponse: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/AnyRegion" + required: + - data + GetRegionResponse: + type: object + properties: + data: + $ref: "#/components/schemas/AnyRegion" + required: + - data + + ServerInfo: + type: object + required: + - version + properties: + version: + type: string + capabilities: + type: array + items: + allOf: + - $ref: "#/components/schemas/Capability" + consoleURL: + type: string + Capability: + type: string + enum: + - MODULE_SELECTION + Version: + type: object + required: + - name + - versions + - regionID + properties: + name: + type: string + versions: + type: object + additionalProperties: + type: string + regionID: + type: string + deprecated: + type: boolean + description: Indicates if this version is deprecated and should not be used + UpdateOrganizationUserRequest: + type: object + properties: + policyId: + type: integer + description: Policy ID applied to the user + UpdateStackUserRequest: + type: object + required: + - policyId + properties: + policyId: + type: integer + + GetRegionVersionsResponse: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/Version" + required: + - data + + AuthenticationProviderData: + type: object + oneOf: + - $ref: '#/components/schemas/GoogleIDPConfig' + - $ref: '#/components/schemas/MicrosoftIDPConfig' + - $ref: '#/components/schemas/GithubIDPConfig' + - $ref: '#/components/schemas/OIDCConfig' + + BaseProviderConfig: + type: object + required: + - type + - name + - clientID + - clientSecret + properties: + type: + type: string + enum: + - oidc + - google + - github + - microsoft + description: Type of the authentication provider + name: + type: string + description: Name of the authentication provider + clientID: + type: string + description: Client ID for the authentication provider + clientSecret: + type: string + description: Client secret for the authentication provider + + AuthenticationProvider: + type: object + allOf: + - $ref: '#/components/schemas/AuthenticationProviderData' + - type: object + properties: + organizationId: + type: string + description: Unique identifier for the authentication provider + createdAt: + type: string + format: date-time + description: Creation date of the authentication provider + updatedAt: + type: string + format: date-time + description: Last update date of the authentication provider + required: + - organizationId + - createdAt + - updatedAt + + GoogleIDPConfig: + allOf: + - $ref: '#/components/schemas/BaseProviderConfig' + - type: object + required: + - config + properties: + config: + type: object + additionalProperties: false + + MicrosoftIDPConfig: + allOf: + - $ref: '#/components/schemas/BaseProviderConfig' + - type: object + required: + - config + properties: + config: + type: object + properties: + tenant: + type: string + description: Tenant ID for Microsoft authentication + default: 'common' + + GithubIDPConfig: + allOf: + - $ref: '#/components/schemas/BaseProviderConfig' + - type: object + required: + - config + properties: + config: + type: object + additionalProperties: false + + OIDCConfig: + allOf: + - $ref: '#/components/schemas/BaseProviderConfig' + - type: object + required: + - config + properties: + config: + type: object + required: + - issuer + properties: + issuer: + type: string + description: OIDC issuer URL + discoveryPath: + type: string + default: '/.well-known/openid-configuration' + + UpsertAuthenticationProviderRequest: + $ref: "#/components/schemas/AuthenticationProviderData" + + AuthenticationProviderResponse: + type: object + properties: + data: + allOf: + - $ref: "#/components/schemas/AuthenticationProvider" + - type: object + properties: + redirectURI: + type: string + required: + - redirectURI + + PolicyData: + type: object + required: + - name + properties: + name: + type: string + description: Policy name + description: + type: string + description: Policy description + + Policy: + allOf: + - $ref: "#/components/schemas/PolicyData" + - type: object + required: + - id + - protected + - createdAt + - updatedAt + properties: + id: + type: integer + description: Policy ID + organizationId: + type: string + description: Organization ID + protected: + type: boolean + description: Whether the policy is protected from modification + scopes: + type: array + items: + $ref: "#/components/schemas/Scope" + description: List of scopes assigned to the policy (only present when fetched via GET endpoint) + createdAt: + type: string + format: date-time + description: Creation date + updatedAt: + type: string + format: date-time + description: Last update date + + CreatePolicyRequest: + $ref: "#/components/schemas/PolicyData" + + CreatePolicyResponse: + type: object + properties: + data: + $ref: "#/components/schemas/Policy" + + ReadPolicyResponse: + type: object + properties: + data: + $ref: "#/components/schemas/Policy" + + UpdatePolicyRequest: + $ref: "#/components/schemas/PolicyData" + + UpdatePolicyResponse: + type: object + properties: + data: + $ref: "#/components/schemas/Policy" + + ListPoliciesResponse: + type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/Policy" + + ApplicationData: + type: object + required: + - name + - url + - alias + properties: + name: + type: string + description: Application name + description: + type: string + description: Application description + url: + type: string + format: uri + description: Application URL (must be unique) + alias: + type: string + description: Application alias + + Application: + allOf: + - $ref: "#/components/schemas/ApplicationData" + - type: object + required: + - id + - createdAt + - updatedAt + properties: + id: + type: string + description: Application ID + createdAt: + type: string + format: date-time + description: Creation date + updatedAt: + type: string + format: date-time + description: Last update date + ApplicationWithScope: + allOf: + - $ref: "#/components/schemas/Application" + - type: object + required: + - scopes + properties: + scopes: + type: array + description: List of scopes associated with this application + items: + $ref: "#/components/schemas/Scope" + + ListApplicationsResponse: + type: object + properties: + cursor: + allOf: + - $ref: "#/components/schemas/Cursor" + - type: object + properties: + data: + type: array + items: + $ref: "#/components/schemas/Application" + required: + - data + + CreateApplicationResponse: + type: object + properties: + data: + $ref: "#/components/schemas/Application" + + GetApplicationResponse: + type: object + properties: + data: + $ref: "#/components/schemas/ApplicationWithScope" + + UpdateApplicationResponse: + type: object + properties: + data: + $ref: "#/components/schemas/Application" + + CreateApplicationScopeRequest: + type: object + required: + - label + properties: + description: + type: string + description: Scope description + label: + type: string + description: The OAuth2 scope label (e.g., "custom:read") + + CreateApplicationScopeResponse: + type: object + properties: + data: + $ref: "#/components/schemas/Scope" + + UpdateApplicationScopeRequest: + type: object + properties: + description: + type: string + description: Scope description + + UpdateApplicationScopeResponse: + type: object + properties: + data: + $ref: "#/components/schemas/Scope" + + Scope: + type: object + required: + - id + - label + - protected + - createdAt + - updatedAt + properties: + id: + type: integer + description: Scope ID + label: + type: string + description: The OAuth2 scope label (e.g., "custom:read") + description: + type: string + description: Scope description + applicationId: + type: string + description: Application ID (null for global scopes) + protected: + type: boolean + description: Whether the scope is protected + default: false + createdAt: + type: string + format: date-time + description: Creation timestamp + updatedAt: + type: string + format: date-time + description: Last update timestamp + + OrganizationApplication: + type: object + required: + - organizationId + - applicationId + - createdAt + properties: + organizationId: + type: string + description: Organization ID + applicationId: + type: string + description: Application ID + createdAt: + type: string + format: date-time + description: Creation date + + EnableApplicationForOrganizationResponse: + type: object + properties: + data: + $ref: "#/components/schemas/OrganizationApplication" diff --git a/pkg/approval.go b/pkg/approval.go index cbc8886c..b00dd0c7 100644 --- a/pkg/approval.go +++ b/pkg/approval.go @@ -7,8 +7,6 @@ import ( "github.com/pkg/errors" "github.com/pterm/pterm" "github.com/spf13/cobra" - - "github.com/formancehq/fctl/membershipclient" ) var ErrMissingApproval = errors.New("Missing approval.") @@ -23,28 +21,17 @@ var interactiveContinue = pterm.InteractiveContinuePrinter{ } const ( - ProtectedStackMetadata = "github.com/formancehq/fctl/protected" - confirmFlag = "confirm" + confirmFlag = "confirm" ) -func IsProtectedStack(stack *membershipclient.Stack) bool { - return stack.Metadata != nil && (*stack.Metadata)[ProtectedStackMetadata] == "Yes" -} - -func NeedConfirm(cmd *cobra.Command, stack *membershipclient.Stack) bool { - if !IsProtectedStack(stack) { - return false - } +func NeedConfirm(cmd *cobra.Command) bool { if GetBool(cmd, confirmFlag) { return false } return true } -func CheckStackApprobation(cmd *cobra.Command, stack *membershipclient.Stack, disclaimer string, args ...any) bool { - if !IsProtectedStack(stack) { - return true - } +func CheckStackApprobation(cmd *cobra.Command, disclaimer string, args ...any) bool { if GetBool(cmd, confirmFlag) { return true } diff --git a/pkg/authentication.go b/pkg/authentication.go new file mode 100644 index 00000000..21a6826f --- /dev/null +++ b/pkg/authentication.go @@ -0,0 +1,445 @@ +package fctl + +import ( + "bytes" + "context" + "encoding/json" + "errors" + "fmt" + "net/http" + "net/url" + "strings" + + "github.com/spf13/cobra" + "golang.org/x/oauth2" + + "github.com/formancehq/go-libs/collectionutils" + "github.com/formancehq/go-libs/v3/oidc" + "github.com/formancehq/go-libs/v3/oidc/client" + "github.com/formancehq/go-libs/v3/time" +) + +var ( + OrganizationScopes = []string{ + "organization:Read", + "organization:Create", + "organization:Update", + "organization:Delete", + "organization:ListUsers", + "organization:ReadUser", + "organization:CreateUser", + "organization:UpdateUser", + "organization:DeleteUser", + "organization:ListPolicies", + "organization:ReadPolicy", + "organization:CreatePolicy", + "organization:UpdatePolicy", + "organization:DeletePolicy", + "organization:ListInvitations", + "organization:ReadInvitation", + "organization:CreateInvitation", + "organization:UpdateInvitation", + "organization:AcceptInvitation", + "organization:RejectInvitation", + "organization:DeleteInvitation", + "organization:ListRegions", + "organization:ReadRegion", + "organization:CreateRegion", + "organization:UpdateRegion", + "organization:DeleteRegion", + "organization:ListStacks", + "organization:ReadStack", + "organization:CreateStack", + "organization:UpdateStack", + "organization:DeleteStack", + "organization:EnableStack", + "organization:DisableStack", + "organization:RestoreStack", + "organization:UpgradeStack", + "organization:ListStackUsers", + "organization:ReadStackUser", + "organization:CreateStackUser", + "organization:UpdateStackUser", + "organization:DeleteStackUser", + "organization:ListStackModules", + "organization:EnableStackModule", + "organization:DisableStackModule", + "organization:ListClients", + "organization:ReadClient", + "organization:CreateClient", + "organization:UpdateClient", + "organization:DeleteClient", + "organization:ReadAuthProvider", + "organization:UpdateAuthProvider", + "organization:DeleteAuthProvider", + "organization:ReadLogs", + "organization:ListFeatures", + "organization:ReadFeature", + } + StackScopes = []string{ + "stack:Read", + "stack:Write", + } +) + +type AuthenticationOption func(url.Values) + +func AuthenticateWithScopes(scopes ...string) AuthenticationOption { + return func(values url.Values) { + values.Set("scope", strings.Join(scopes, " ")) + } +} + +func AuthenticateWithIDTokenHint(idToken string) AuthenticationOption { + return func(values url.Values) { + values.Set("id_token_hint", idToken) + } +} + +func AuthenticateWithPrompt(prompt ...string) AuthenticationOption { + return func(values url.Values) { + values.Set("prompt", strings.Join(prompt, " ")) + } +} + +func AuthenticateWithOrganizationID(organization string) AuthenticationOption { + return func(values url.Values) { + values.Set("organization_id", organization) + } +} + +func AuthenticateWithResource(resource string) AuthenticationOption { + return func(values url.Values) { + values.Set("resource", resource) + } +} + +type TokenOption func(url.Values) + +func RequestResource(resource string) TokenOption { + return func(values url.Values) { + values.Set("resource", resource) + } +} + +func initiateDeviceAuthorizationFlow(relyingParty client.RelyingParty, options ...AuthenticationOption) (*oidc.DeviceAuthorizationResponse, error) { + form := url.Values{} + for _, option := range options { + option(form) + } + + body := strings.NewReader(form.Encode()) + req, err := http.NewRequest(http.MethodPost, relyingParty.GetDeviceAuthorizationEndpoint(), body) + if err != nil { + return nil, err + } + req.SetBasicAuth(AuthClient, "") + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + + httpResponse, err := relyingParty.HttpClient().Do(req) + if err != nil { + return nil, err + } + defer func() { + _ = httpResponse.Body.Close() + }() + + oidcResponse := oidc.DeviceAuthorizationResponse{} + if err := json.NewDecoder(httpResponse.Body).Decode(&oidcResponse); err != nil { + return nil, err + } + + return &oidcResponse, nil +} + +func Authenticate( + ctx context.Context, + relyingParty client.RelyingParty, + dialog Dialog, + authenticationOptions []AuthenticationOption, + tokenOptions []TokenOption, +) (*Tokens, error) { + + deviceCode, err := initiateDeviceAuthorizationFlow(relyingParty, authenticationOptions...) + if err != nil { + return nil, fmt.Errorf("failed to initiate device authorization flow: %w", err) + } + + uri, err := url.Parse(deviceCode.VerificationURI) + if err != nil { + panic(err) + } + query := uri.Query() + query.Set("user_code", deviceCode.UserCode) + uri.RawQuery = query.Encode() + + if err := OpenURL(uri.String()); err != nil { + if !errors.Is(err, ErrOpeningBrowser) { + return nil, err + } + + dialog.Info("No browser detected") + dialog.Info("Please open the following URL in your browser:" + uri.String()) + } else { + dialog.Info("A browser window has been opened on " + uri.String()) + } + dialog.Info("Waiting for authentication...") + + rsp, err := client.DeviceAccessToken[*IDTokenClaims]( + ctx, + deviceCode.DeviceCode, + time.Duration(deviceCode.Interval)*time.Second, + relyingParty, + collectionutils.Map(tokenOptions, func(option TokenOption) func(url.Values) { + return option + })..., + ) + if err != nil { + return nil, fmt.Errorf("failed to get access token: %w", err) + } + + idTokenClaims := &IDTokenClaims{} + if _, err := oidc.ParseToken(rsp.IDToken, idTokenClaims); err != nil { + return nil, fmt.Errorf("failed to parse id token: %w", err) + } + + accessTokenClaims := AccessTokenClaims{} + if _, err := oidc.ParseToken(rsp.AccessToken, &accessTokenClaims); err != nil { + return nil, fmt.Errorf("failed to parse access token: %w", err) + } + + return &Tokens{ + Access: AccessToken{ + TokenWithClaims: TokenWithClaims[AccessTokenClaims]{ + Token: rsp.AccessToken, + Claims: accessTokenClaims, + }, + Refresh: rsp.RefreshToken, + }, + ID: IDToken{ + Token: rsp.IDToken, + Claims: *idTokenClaims, + }, + }, nil +} + +func Refresh(ctx context.Context, relyingParty client.RelyingParty, token AccessToken) (*AccessToken, error) { + newToken, err := client.RefreshTokens[*IDTokenClaims](ctx, relyingParty, token.Refresh, "", "") + if err != nil { + return nil, newErrInvalidAuthentication(err) + } + + claims := AccessTokenClaims{} + _, err = oidc.ParseToken(newToken.AccessToken, &claims) + if err != nil { + return nil, newErrInvalidAuthentication(err) + } + + token.Token = newToken.AccessToken + token.Refresh = newToken.RefreshToken + token.Claims = claims + + return &AccessToken{ + TokenWithClaims: TokenWithClaims[AccessTokenClaims]{ + Token: newToken.AccessToken, + Claims: claims, + }, + Refresh: newToken.RefreshToken, + }, nil +} + +func FetchStackToken(ctx context.Context, httpClient *http.Client, stackURI, token string) (*oauth2.Token, error) { + + form := url.Values{ + "grant_type": []string{"urn:ietf:params:oauth:grant-type:jwt-bearer"}, + "assertion": []string{token}, + "scope": []string{strings.Join([]string{oidc.ScopeOpenID, oidc.ScopeEmail}, " ")}, + } + + stackDiscoveryConfiguration, err := client.Discover[oidc.DiscoveryConfiguration](ctx, stackURI+"/api/auth", httpClient) + if err != nil { + return nil, err + } + + req, err := http.NewRequestWithContext(ctx, http.MethodPost, stackDiscoveryConfiguration.TokenEndpoint, + bytes.NewBufferString(form.Encode())) + if err != nil { + return nil, err + } + req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + + now := time.Now() + ret, err := httpClient.Do(req) + if err != nil { + return nil, err + } + + switch ret.StatusCode { + case http.StatusUnauthorized: + return nil, newErrUnauthorized() + case http.StatusForbidden: + return nil, newErrForbidden() + case http.StatusOK: + stackToken := &oauth2.Token{} + if err := json.NewDecoder(ret.Body).Decode(stackToken); err != nil { + return nil, err + } + + if stackToken.Expiry.IsZero() { + stackToken.Expiry = now.Add(time.Duration(stackToken.ExpiresIn) * time.Second).Time + } + + return stackToken, nil + default: + return nil, newUnexpectedStatusCodeError(ret.StatusCode) + } +} + +func UserInfo(cmd *cobra.Command, relyingParty client.RelyingParty, token AccessToken) (*UserClaims, error) { + ui, err := client.Userinfo[*oidc.UserInfo](cmd.Context(), token.Token, "Bearer", relyingParty) + if err != nil { + return nil, err + } + + claims := &UserClaims{} + claims.Email = ui.Email + claims.Subject = ui.Subject + + return claims, nil +} + +type TokenWithClaims[T any] struct { + Token string `json:"token"` + Claims T `json:"claims"` +} + +type AccessTokenClaims struct { + oidc.TokenClaims + Scopes oidc.SpaceDelimitedArray `json:"scope,omitempty"` + OrganizationID string `json:"organization_id"` +} + +type AccessToken struct { + TokenWithClaims[AccessTokenClaims] + Refresh string `json:"refreshToken"` +} + +func (t AccessToken) ToOAuth2() *oauth2.Token { + return &oauth2.Token{ + AccessToken: t.Token, + TokenType: "Bearer", + Expiry: t.Claims.Expiration.AsTime().Time, + } +} + +func (t AccessToken) Expired() bool { // todo: define a delta on time + return t.Claims.Expiration.AsTime().Before(time.Now()) +} + +type IDToken = TokenWithClaims[IDTokenClaims] + +type Tokens struct { + Access AccessToken `json:"accessToken"` + ID IDToken `json:"idToken"` +} + +type IDTokenClaims struct { + oidc.TokenClaims + NotBefore oidc.Time `json:"nbf,omitempty"` + AccessTokenHash string `json:"at_hash,omitempty"` + CodeHash string `json:"c_hash,omitempty"` + SessionID string `json:"sid,omitempty"` + oidc.UserInfoProfile + oidc.UserInfoEmail + oidc.UserInfoPhone + Address *oidc.UserInfoAddress `json:"address,omitempty"` + Organizations []OrganizationAccess `json:"org"` +} + +func (i IDTokenClaims) GetExpiration() time.Time { + return i.Expiration.AsTime() +} + +func (i IDTokenClaims) GetIssuedAt() time.Time { + return i.IssuedAt.AsTime() +} + +func (i IDTokenClaims) GetAuthTime() time.Time { + return i.AuthTime.AsTime() +} + +func (i IDTokenClaims) GetAccessTokenHash() string { + return i.AccessTokenHash +} + +func (i IDTokenClaims) GetOrganizationAccess(id string) *OrganizationAccess { + for _, organization := range i.Organizations { + if organization.ID == id { + return &organization + } + } + return nil +} + +func (i IDTokenClaims) HasOrganizationAccess(id string) bool { + return i.GetOrganizationAccess(id) != nil +} + +func (i IDTokenClaims) HasApplicationsAccess(organizationID string, alias string) bool { + organizationAccess := i.GetOrganizationAccess(organizationID) + if organizationAccess == nil { + return false + } + for _, application := range organizationAccess.Applications { + if application.Alias == alias { + return true + } + } + return false +} + +func (i IDTokenClaims) HasStackAccess(organizationID string, stackID string) bool { + organizationAccess := i.GetOrganizationAccess(organizationID) + if organizationAccess == nil { + return false + } + return organizationAccess.GetStackAccess(stackID) != nil +} + +type StackAccess struct { + ID string `json:"id"` + DisplayName string `json:"displayName"` + URI string `json:"uri"` + Scopes []string `json:"scopes"` +} +type OrganizationAccess struct { + ID string `json:"id"` + DisplayName string `json:"displayName"` + Stacks []StackAccess `json:"stacks"` + Applications []ApplicationAccess `json:"applications"` +} + +func (o *OrganizationAccess) GetStackAccess(stackID string) *StackAccess { + if o == nil { + return nil + } + for _, stack := range o.Stacks { + if stack.ID == stackID { + return &stack + } + } + return nil +} + +type OrganizationsClaim []OrganizationAccess +type UserClaims struct { + Email string `json:"email"` + Subject string `json:"sub"` + Org OrganizationsClaim `json:"org"` +} + +type ApplicationAccess struct { + Alias string `json:"alias"` + ID string `json:"id"` + Name string `json:"name"` +} diff --git a/pkg/claims.go b/pkg/claims.go deleted file mode 100644 index c8a9c4eb..00000000 --- a/pkg/claims.go +++ /dev/null @@ -1,17 +0,0 @@ -package fctl - -type stackClaim struct { - ID string `json:"id"` - DisplayName string `json:"displayName"` -} -type organizationClaim struct { - ID string `json:"id"` - DisplayName string `json:"displayName"` - Stacks []stackClaim `json:"stacks"` -} -type organizationsClaim []organizationClaim -type userClaims struct { - Email string `json:"email"` - Subject string `json:"sub"` - Org organizationsClaim `json:"org"` -} diff --git a/pkg/clients.go b/pkg/clients.go index 027c6ab6..427eb1fe 100644 --- a/pkg/clients.go +++ b/pkg/clients.go @@ -2,17 +2,24 @@ package fctl import ( "context" + "errors" "fmt" - "net/http" + "slices" + "strings" + "sync" "time" "github.com/spf13/cobra" "golang.org/x/oauth2" formance "github.com/formancehq/formance-sdk-go/v3" - "github.com/formancehq/go-libs/logging" + "github.com/formancehq/go-libs/collectionutils" + "github.com/formancehq/go-libs/v3/oidc" + "github.com/formancehq/go-libs/v3/oidc/client" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/deployserverclient" + "github.com/formancehq/fctl/internal/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" ) func getVersion(cmd *cobra.Command) string { @@ -25,105 +32,566 @@ func getVersion(cmd *cobra.Command) string { return "cmd.Version" } -type MembershipClient struct { - profile *Profile - *membershipclient.APIClient +func EnsureMembershipAccess( + cmd *cobra.Command, + relyingParty client.RelyingParty, + dialog Dialog, + profileName string, + profile Profile, +) (*AccessToken, error) { + if !profile.IsConnected() { + return nil, fmt.Errorf("profile %s is not connected, please log in", profileName) + } + authenticate := func() (*Tokens, error) { + return Authenticate( + cmd.Context(), + relyingParty, + dialog, + []AuthenticationOption{ + AuthenticateWithScopes( + oidc.ScopeOpenID, + oidc.ScopeOfflineAccess, + "accesses", + "on_behalf", + ), + AuthenticateWithPrompt("no-org"), + AuthenticateWithIDTokenHint(profile.RootTokens.ID.Token), + }, + []TokenOption{}, + ) + } + + originalToken := &profile.RootTokens.Access + + token := originalToken + if token == nil { + tokens, err := authenticate() + if err != nil { + return nil, fmt.Errorf("failed to authenticate for organization: %w", err) + } + + token = &tokens.Access + } else if token.Expired() { // todo: define a delta on time + refreshed, err := Refresh(cmd.Context(), relyingParty, *token) + if err != nil { + oidcErr := &oidc.Error{} + if !errors.As(err, &oidcErr) { + return nil, fmt.Errorf("failed to refresh stack token: %w", err) + } + + if oidcErr.ErrorType != oidc.InvalidToken { + return nil, fmt.Errorf("received unexpected oauth2 error while refreshing token: %w", err) + } + + tokens, err := authenticate() + if err != nil { + return nil, fmt.Errorf("failed to authenticate for stack: %w", err) + } + + token = &tokens.Access + } else { + token = refreshed + } + } + + if token != originalToken { + profile.RootTokens.Access = *token + if err := WriteProfile(cmd, profileName, profile); err != nil { + return nil, err + } + } + + return token, nil } -func (c *MembershipClient) GetProfile() *Profile { - return c.profile +func EnsureOrganizationAccess( + cmd *cobra.Command, + relyingParty client.RelyingParty, + dialog Dialog, + profileName string, + profile Profile, + organizationID string, +) (*AccessToken, error) { + if !profile.RootTokens.ID.Claims.HasOrganizationAccess(organizationID) { + return nil, fmt.Errorf("no access to organization %s found in your authentication profile, "+ + "please log in again and/or check you still have access to the organization", organizationID) + } + + authenticate := func() (*Tokens, error) { + return Authenticate( + cmd.Context(), + relyingParty, + dialog, + []AuthenticationOption{ + AuthenticateWithOrganizationID(organizationID), + AuthenticateWithIDTokenHint(profile.RootTokens.ID.Token), + AuthenticateWithScopes(append(OrganizationScopes, oidc.ScopeOpenID, oidc.ScopeOfflineAccess)...), + }, + []TokenOption{}, + ) + } + + originalOrganizationToken, err := ReadOrganizationToken(cmd, profileName, organizationID) + if err != nil { + return nil, err + } + organizationToken := originalOrganizationToken + if organizationToken == nil { + tokens, err := authenticate() + if err != nil { + return nil, fmt.Errorf("failed to authenticate for organization: %w", err) + } + + organizationToken = &tokens.Access + } else if organizationToken.Expired() { // todo: define a delta on time + refreshed, err := Refresh(cmd.Context(), relyingParty, *organizationToken) + if err != nil { + oidcErr := &oidc.Error{} + if !errors.As(err, &oidcErr) { + return nil, fmt.Errorf("failed to refresh stack token: %w", err) + } + + if oidcErr.ErrorType != oidc.InvalidToken { + return nil, fmt.Errorf("received unexpected oauth2 error while refreshing token: %w", err) + } + + tokens, err := authenticate() + if err != nil { + return nil, fmt.Errorf("failed to authenticate for stack: %w", err) + } + + organizationToken = &tokens.Access + } else { + organizationToken = refreshed + } + } + + if organizationToken != originalOrganizationToken { + if err := WriteOrganizationToken(cmd, profileName, *organizationToken); err != nil { + return nil, err + } + } + + return organizationToken, nil } -func (c *MembershipClient) RefreshIfNeeded(cmd *cobra.Command) error { - logging.Debug("Refreshing membership client") - token, err := c.profile.GetToken(cmd.Context(), c.GetConfig().HTTPClient) +func EnsureStackAccess( + cmd *cobra.Command, + relyingParty client.RelyingParty, + dialog Dialog, + profileName string, + profile Profile, + organizationID, stackID string, +) (*AccessToken, *StackAccess, error) { + if !profile.RootTokens.ID.Claims.HasOrganizationAccess(organizationID) { + return nil, nil, fmt.Errorf("no access to organization %s found in your authentication profile, "+ + "please log in again and/or check you still have access to the organization", organizationID) + } + + if !profile.RootTokens.ID.Claims.HasStackAccess(organizationID, stackID) { + return nil, nil, fmt.Errorf("no access to stack %s on organization %s found in your authentication profile, "+ + "please log in again and/or check you still have access to the organization", stackID, organizationID) + } + + stackAccess := profile.RootTokens.ID.Claims. + GetOrganizationAccess(organizationID). + GetStackAccess(stackID) + stackScopes := collectionutils.Filter(stackAccess.Scopes, func(s string) bool { + return slices.Contains(StackScopes, s) + }) + if len(stackScopes) == 0 { + return nil, nil, fmt.Errorf("no access to stack %s on organization %s found in your authentication profile, "+ + "please log in again and/or check you still have access to the organization", stackID, organizationID) + } + resource := "stack://" + organizationID + "/" + stackID + "|" + strings.Join(stackScopes, " ") + + authenticate := func() (*Tokens, error) { + return Authenticate( + cmd.Context(), + relyingParty, + dialog, + []AuthenticationOption{ + AuthenticateWithOrganizationID(organizationID), + AuthenticateWithIDTokenHint(profile.RootTokens.ID.Token), + AuthenticateWithResource(resource), + AuthenticateWithScopes(oidc.ScopeOpenID, oidc.ScopeOfflineAccess), + }, + []TokenOption{ + RequestResource(resource), + }, + ) + } + + originalToken, err := ReadStackToken(cmd, profileName, organizationID, stackID) if err != nil { - return err + return nil, nil, err + } + + stackToken := originalToken + if stackToken == nil { + tokens, err := authenticate() + if err != nil { + return nil, nil, fmt.Errorf("failed to authenticate for stack: %w", err) + } + + stackToken = &tokens.Access + } else if stackToken.Expired() { + refreshed, err := Refresh(cmd.Context(), relyingParty, *stackToken) + if err != nil { + oidcErr := &oidc.Error{} + if !errors.As(err, &oidcErr) { + return nil, nil, fmt.Errorf("failed to refresh stack token: %w", err) + } + + if oidcErr.ErrorType != oidc.InvalidToken { + return nil, nil, fmt.Errorf("received unexpected oauth2 error while refreshing token: %w", err) + } + + tokens, err := authenticate() + if err != nil { + return nil, nil, fmt.Errorf("failed to authenticate for stack: %w", err) + } + + stackToken = &tokens.Access + } else { + stackToken = refreshed + } + } + + if stackToken != originalToken { + if err := WriteStackToken(cmd, profileName, stackID, *stackToken); err != nil { + return nil, nil, err + } } - config := c.GetConfig() - config.AddDefaultHeader("Authorization", fmt.Sprintf("Bearer %s", token.AccessToken)) - c.APIClient = membershipclient.NewAPIClient(config) - return err + return stackToken, stackAccess, nil } -func NewMembershipClient(cmd *cobra.Command, cfg *Config) (*MembershipClient, error) { - profile := GetCurrentProfile(cmd, cfg) - httpClient := GetHttpClient(cmd, map[string][]string{}) - configuration := membershipclient.NewConfiguration() - configuration.HTTPClient = httpClient - configuration.UserAgent = "fctl/" + getVersion(cmd) - configuration.Servers[0].URL = profile.GetMembershipURI() - client := &MembershipClient{ - APIClient: membershipclient.NewAPIClient(configuration), - profile: profile, +func EnsureAppAccess( + cmd *cobra.Command, + relyingParty client.RelyingParty, + dialog Dialog, + profileName string, + profile Profile, + organizationID string, + appAlias string, + appScopes []string, +) (*AccessToken, error) { + if !profile.RootTokens.ID.Claims.HasApplicationsAccess(organizationID, appAlias) { + return nil, fmt.Errorf("no access to application '%s' on organization %s found in your authentication profile, "+ + "please log in again and/or check you still have access to the organization", appAlias, organizationID) } - err := client.RefreshIfNeeded(cmd) + + resource := "app://" + appAlias + "|" + strings.Join(appScopes, " ") + + authenticate := func() (*Tokens, error) { + return Authenticate( + cmd.Context(), + relyingParty, + dialog, + []AuthenticationOption{ + AuthenticateWithOrganizationID(organizationID), + AuthenticateWithIDTokenHint(profile.RootTokens.ID.Token), + AuthenticateWithResource(resource), + AuthenticateWithScopes(oidc.ScopeOpenID, oidc.ScopeOfflineAccess), + }, + []TokenOption{ + RequestResource(resource), + }, + ) + } + + originalAppToken, err := ReadAppToken(cmd, profileName, organizationID, appAlias) if err != nil { return nil, err } - return client, nil + appToken := originalAppToken + if appToken == nil { + tokens, err := authenticate() + if err != nil { + return nil, fmt.Errorf("failed to authenticate for organization: %w", err) + } + + appToken = &tokens.Access + } else if appToken.Expired() { // todo: define a delta on time + refreshed, err := Refresh(cmd.Context(), relyingParty, *appToken) + if err != nil { + oidcErr := &oidc.Error{} + if !errors.As(err, &oidcErr) { + return nil, fmt.Errorf("failed to refresh app token: %w", err) + } + + if oidcErr.ErrorType != oidc.InvalidToken { + return nil, fmt.Errorf("received unexpected oauth2 error while refreshing token: %w", err) + } + + tokens, err := authenticate() + if err != nil { + return nil, fmt.Errorf("failed to authenticate for stack: %w", err) + } + + appToken = &tokens.Access + } else { + appToken = refreshed + } + } + + if appToken != originalAppToken { + if err := WriteAppToken(cmd, profileName, appAlias, *appToken); err != nil { + return nil, err + } + } + + return appToken, nil } -func MembershipServerInfo(ctx context.Context, client *membershipclient.DefaultAPIService) (*membershipclient.ServerInfo, error) { - serverInfo, response, err := client.GetServerInfo(ctx).Execute() +func NewMembershipClient( + cmd *cobra.Command, + relyingParty client.RelyingParty, + dialog Dialog, + profileName string, + profile Profile, +) (*membershipclient.SDK, error) { + + accessToken, err := EnsureMembershipAccess( + cmd, + relyingParty, + dialog, + profileName, + profile, + ) if err != nil { return nil, err } - if response.StatusCode != 200 { - return nil, fmt.Errorf("unexpected status code: %d", response.StatusCode) + + return membershipclient.New( + membershipclient.WithServerURL(profile.GetMembershipURI()), + membershipclient.WithClient(relyingParty.HttpClient()), + membershipclient.WithSecurity(fmt.Sprintf("Bearer %s", accessToken.Token)), + ), nil +} + +func NewMembershipClientForOrganization( + cmd *cobra.Command, + relyingParty client.RelyingParty, + dialog Dialog, + profileName string, + profile Profile, + organizationID string, +) (*membershipclient.SDK, error) { + + organizationToken, err := EnsureOrganizationAccess( + cmd, + relyingParty, + dialog, + profileName, + profile, + organizationID, + ) + if err != nil { + return nil, err + } + + return membershipclient.New( + membershipclient.WithServerURL(profile.GetMembershipURI()), + membershipclient.WithClient(relyingParty.HttpClient()), + membershipclient.WithSecurity(fmt.Sprintf("Bearer %s", organizationToken.Token)), + ), nil +} + +func NewMembershipClientForOrganizationFromFlags( + cmd *cobra.Command, + relyingParty client.RelyingParty, + dialog Dialog, + profileName string, + profile Profile, +) (string, *membershipclient.SDK, error) { + + organizationID, err := ResolveOrganizationID(cmd, profile) + if err != nil { + return "", nil, err } - return serverInfo, nil + + client, err := NewMembershipClientForOrganization(cmd, relyingParty, dialog, profileName, profile, organizationID) + + return organizationID, client, err } -func NewStackClient(cmd *cobra.Command, cfg *Config, stack *membershipclient.Stack) (*formance.Formance, error) { +func NewStackClient( + cmd *cobra.Command, + relyingParty client.RelyingParty, + dialog Dialog, + profileName string, + profile Profile, + organizationID, stackID string, +) (*formance.Formance, error) { + + stackToken, stackAccess, err := EnsureStackAccess( + cmd, + relyingParty, + dialog, + profileName, + profile, + organizationID, + stackID, + ) + if err != nil { + return nil, err + } + + token, err := FetchStackToken(cmd.Context(), relyingParty.HttpClient(), stackAccess.URI, stackToken.Token) + if err != nil { + return nil, err + } + return formance.New( - formance.WithServerURL(stack.Uri), - formance.WithClient( - &http.Client{ - Transport: NewStackHTTPTransport( - cmd, - GetCurrentProfile(cmd, cfg), - stack, - map[string][]string{ - "User-Agent": {"fctl/" + getVersion(cmd)}, - }, - ), - }, - ), + formance.WithServerURL(stackAccess.URI), + formance.WithClient(oauth2.NewClient( + context.WithValue(cmd.Context(), oauth2.HTTPClient, relyingParty.HttpClient()), + oauth2.StaticTokenSource(token), + )), + ), nil +} + +func NewStackClientFromFlags( + cmd *cobra.Command, + relyingParty client.RelyingParty, + dialog Dialog, + profileName string, + profile Profile, +) (*formance.Formance, error) { + + organizationID, stackID, err := ResolveStackID(cmd, profile) + if err != nil { + return nil, err + } + + return NewStackClient(cmd, relyingParty, dialog, profileName, profile, organizationID, stackID) +} + +func NewAppDeployClient( + cmd *cobra.Command, + relyingParty client.RelyingParty, + dialog Dialog, + profileName string, + profile Profile, + organizationID string, +) (*deployserverclient.DeployServer, error) { + + appToken, err := EnsureAppAccess( + cmd, + relyingParty, + dialog, + profileName, + profile, + organizationID, + "deploy", + []string{}, + ) + if err != nil { + return nil, err + } + + return deployserverclient.New( + deployserverclient.WithServerURL(collectionutils.Filter(appToken.Claims.Audience, func(audience string) bool { + return audience != AuthClient + })[0]), + deployserverclient.WithClient(oauth2.NewClient( + context.WithValue(cmd.Context(), oauth2.HTTPClient, relyingParty.HttpClient()), + oauth2.StaticTokenSource(appToken.ToOAuth2()), + )), ), nil } -type stackHttpTransport struct { - profile *Profile - authHttpClient *http.Client - stack *membershipclient.Stack - token *oauth2.Token - underlyingTransport http.RoundTripper +// todo: deploy use membership token, we have to rely on membership applications +func NewAppDeployClientFromFlags( + cmd *cobra.Command, + relyingParty client.RelyingParty, + dialog Dialog, + profileName string, + profile Profile, +) (string, *deployserverclient.DeployServer, error) { + + organizationID, err := ResolveOrganizationID(cmd, profile) + if err != nil { + return "", nil, err + } + + deployClient, err := NewAppDeployClient(cmd, relyingParty, dialog, profileName, profile, organizationID) + if err != nil { + return "", nil, err + } + + return organizationID, deployClient, nil +} + +type stackTokenSource struct { + mu sync.Mutex + + // Membership token + stackToken AccessToken + + // Token obtained from stack auth server + accessToken *oauth2.Token + + stackAccess *StackAccess + relyingParty client.RelyingParty + onRefresh func(newToken AccessToken) error } -func (s *stackHttpTransport) RoundTrip(request *http.Request) (*http.Response, error) { - if s.token == nil || time.Now().After(s.token.Expiry.Add(-10*time.Second)) { - token, err := s.profile.GetStackToken(request.Context(), s.authHttpClient, s.stack) +func (t *stackTokenSource) Token() (*oauth2.Token, error) { + t.mu.Lock() + defer t.mu.Unlock() + + if t.accessToken == nil || t.accessToken.Expiry.Before(time.Now()) { + if t.stackToken.Expired() { + newStackToken, err := Refresh(context.Background(), t.relyingParty, t.stackToken) + if err != nil { + return nil, err + } + t.stackToken = *newStackToken + if err := t.onRefresh(*newStackToken); err != nil { + return nil, err + } + } + + token, err := FetchStackToken(context.Background(), t.relyingParty.HttpClient(), t.stackAccess.URI, t.stackToken.Token) if err != nil { return nil, err } - s.token = token - } - request.Header.Set("Authorization", fmt.Sprintf("Bearer %s", s.token.AccessToken)) + t.accessToken = token + } - return s.underlyingTransport.RoundTrip(request) + return t.accessToken, nil } -func NewStackHTTPTransport(cmd *cobra.Command, profile *Profile, stack *membershipclient.Stack, defaultHeaders map[string][]string) *stackHttpTransport { - return &stackHttpTransport{ - underlyingTransport: NewHTTPTransport(cmd, defaultHeaders), - authHttpClient: GetHttpClient(cmd, map[string][]string{}), - profile: profile, - stack: stack, +var _ oauth2.TokenSource = &stackTokenSource{} + +func NewStackTokenSource( + stackToken AccessToken, + stackAccess *StackAccess, + relyingParty client.RelyingParty, + onRefresh func(newToken AccessToken) error, +) oauth2.TokenSource { + return &stackTokenSource{ + stackToken: stackToken, + stackAccess: stackAccess, + relyingParty: relyingParty, + onRefresh: onRefresh, } } -var _ http.RoundTripper = &stackHttpTransport{} +func MembershipServerInfo(ctx context.Context, apiClient *membershipclient.SDK) (*components.ServerInfo, error) { + response, err := apiClient.GetServerInfo(ctx) + if err != nil { + return nil, err + } + + if response.ServerInfo == nil { + return nil, fmt.Errorf("unexpected response: no server info") + } + + return response.ServerInfo, nil +} diff --git a/pkg/command.go b/pkg/command.go index d79f4623..ad6e122f 100644 --- a/pkg/command.go +++ b/pkg/command.go @@ -2,13 +2,12 @@ package fctl import ( "encoding/json" + "fmt" "github.com/TylerBrock/colorjson" "github.com/pkg/errors" "github.com/segmentio/ksuid" "github.com/spf13/cobra" - - "github.com/formancehq/fctl/membershipclient" ) var ( @@ -17,88 +16,77 @@ var ( ErrNoStackSpecified = errors.New("no stack specified: use --stack=") ) -func GetSelectedOrganization(cmd *cobra.Command) string { +func GetSelectedOrganizationID(cmd *cobra.Command) string { return GetString(cmd, organizationFlag) } -func RetrieveOrganizationIDFromFlagOrProfile(cmd *cobra.Command, cfg *Config) (string, error) { - if id := GetSelectedOrganization(cmd); id != "" { +func ResolveOrganizationID(cmd *cobra.Command, profile Profile) (string, error) { + if id := GetSelectedOrganizationID(cmd); id != "" { return id, nil } - if defaultOrganization := GetCurrentProfile(cmd, cfg).GetDefaultOrganization(); defaultOrganization != "" { - return defaultOrganization, nil + if profile.DefaultOrganization != "" { + return profile.DefaultOrganization, nil + } + + if len(profile.RootTokens.ID.Claims.Organizations) == 0 { + return "", ErrOrganizationNotSpecified } - return "", ErrOrganizationNotSpecified + if len(profile.RootTokens.ID.Claims.Organizations) > 1 { + return "", ErrMultipleOrganizationsFound + } + + return profile.RootTokens.ID.Claims.Organizations[0].ID, nil } -func ResolveOrganizationID(cmd *cobra.Command, cfg *Config, client *membershipclient.DefaultAPIService) (string, error) { - if id, err := RetrieveOrganizationIDFromFlagOrProfile(cmd, cfg); err == nil { +func GetSelectedStackID(cmd *cobra.Command, profile Profile) (string, error) { + if id := GetString(cmd, stackFlag); id != "" { return id, nil } - organizations, _, err := client.ListOrganizations(cmd.Context()).Execute() + return profile.DefaultStack, nil +} + +func ResolveStackID(cmd *cobra.Command, profile Profile) (string, string, error) { + + organizationID, err := ResolveOrganizationID(cmd, profile) if err != nil { - return "", errors.Wrap(err, "listing organizations") + return "", "", err } - if len(organizations.Data) == 0 { - return "", errors.New("no organizations found") + stackID, err := GetSelectedStackID(cmd, profile) + if err != nil { + return "", "", err } - if len(organizations.Data) > 1 { - return "", ErrMultipleOrganizationsFound + if stackID != "" { + return organizationID, stackID, nil } - return organizations.Data[0].Id, nil -} - -func GetSelectedStackIDError(cmd *cobra.Command, cfg *Config) (string, error) { - if str := GetSelectedStackID(cmd, cfg); str != "" { - return str, nil + if !profile.IsConnected() { + return "", "", ErrOrganizationNotSpecified } - return "", ErrNoStackSpecified -} -func GetSelectedStackID(cmd *cobra.Command, cfg *Config) string { - if id := GetString(cmd, stackFlag); id != "" { - return id - } - pf := cfg.GetCurrentProfile() - if pf != nil { - if pf.defaultStack != "" { - return pf.defaultStack + var organizationClaim *OrganizationAccess + for _, organization := range profile.RootTokens.ID.Claims.Organizations { + if organization.ID == organizationID { + organizationClaim = &organization + break } } - - return "" -} - -func ResolveStack(cmd *cobra.Command, cfg *Config, organizationID string) (*membershipclient.Stack, error) { - client, err := NewMembershipClient(cmd, cfg) - if err != nil { - return nil, err + if organizationClaim == nil { + return "", "", ErrOrganizationNotSpecified } - if id := GetSelectedStackID(cmd, cfg); id != "" { - response, _, err := client.DefaultAPI.GetStack(cmd.Context(), organizationID, id).Execute() - if err != nil { - return nil, err - } - return response.Data, nil + if len(organizationClaim.Stacks) == 0 { + return "", "", ErrNoStackSpecified } - stacks, _, err := client.DefaultAPI.ListStacks(cmd.Context(), organizationID).Execute() - if err != nil { - return nil, errors.Wrap(err, "listing stacks") + if len(organizationClaim.Stacks) > 1 { + return "", "", fmt.Errorf("found more than one stack and no stack specified") } - if len(stacks.Data) == 0 { - return nil, errors.New("no stacks found") - } - if len(stacks.Data) > 1 { - return nil, errors.New("found more than one stack and no stack specified") - } - return &(stacks.Data[0]), nil + + return organizationID, organizationClaim.Stacks[0].ID, nil } type CommandOption interface { @@ -343,15 +331,15 @@ func NewCommand(use string, opts ...CommandOption) *cobra.Command { Use: use, PersistentPostRun: func(cmd *cobra.Command, args []string) { if GetBool(cmd, TelemetryFlag) { - cfg, err := GetConfig(cmd) + cfg, err := LoadConfig(cmd) if err != nil { return } - if cfg.GetUniqueID() == "" { + if cfg.UniqueID == "" { uniqueID := ksuid.New().String() - cfg.SetUniqueID(uniqueID) - err = cfg.Persist() + cfg.UniqueID = uniqueID + err = WriteConfig(cmd, *cfg) if err != nil { return } diff --git a/pkg/config.go b/pkg/config.go index 8b537a29..05ff022b 100644 --- a/pkg/config.go +++ b/pkg/config.go @@ -1,147 +1,63 @@ package fctl import ( - "encoding/json" + "os" + "path/filepath" - "github.com/pkg/errors" "github.com/spf13/cobra" ) -type persistedConfig struct { - CurrentProfile string `json:"currentProfile"` - Profiles map[string]*Profile `json:"profiles"` - UniqueID string `json:"uniqueID"` -} +const ( + DefaultMembershipURI = "https://app.formance.cloud/api" + DefaultConsoleURL = "https://portal.formance.cloud" +) type Config struct { - currentProfile string - uniqueID string - profiles map[string]*Profile - manager *ConfigManager -} - -func (c *Config) MarshalJSON() ([]byte, error) { - return json.Marshal(persistedConfig{ - CurrentProfile: c.currentProfile, - Profiles: c.profiles, - UniqueID: c.uniqueID, - }) + CurrentProfile string `json:"currentProfile"` + UniqueID string `json:"uniqueID,omitempty"` } -func (c *Config) UnmarshalJSON(data []byte) error { - cfg := &persistedConfig{} - if err := json.Unmarshal(data, cfg); err != nil { - return err +func GetCurrentProfileName(cmd *cobra.Command, config Config) string { + if profile := GetString(cmd, ProfileFlag); profile != "" { + return profile } - *c = Config{ - currentProfile: cfg.CurrentProfile, - profiles: cfg.Profiles, - uniqueID: cfg.UniqueID, + currentProfileName := config.CurrentProfile + if currentProfileName == "" { + currentProfileName = "default" } - return nil + return currentProfileName } -func (c *Config) GetProfile(name string) *Profile { - p := c.profiles[name] - if p != nil { - p.config = c - } - return p +func LoadConfigDir(cmd *cobra.Command) string { + return GetString(cmd, ConfigDir) } -func (c *Config) GetProfileOrDefault(name string, membershipUri string) *Profile { - p := c.GetProfile(name) - if p == nil { - if c.profiles == nil { - c.profiles = map[string]*Profile{} - } - f := &Profile{ - membershipURI: membershipUri, - config: c, - } - c.profiles[name] = f - return f - } - return p +func LoadConfigFilePath(cmd *cobra.Command) string { + return GetFilePath(cmd, "config.yml") } -func (c *Config) GetCurrentProfile() *Profile { - return c.GetProfileOrDefault(c.currentProfile, DefaultMembershipURI) +func GetFilePath(cmd *cobra.Command, filename string) string { + return filepath.Join(LoadConfigDir(cmd), filename) } -func (c *Config) DeleteProfile(s string) error { - _, ok := c.profiles[s] - if !ok { - return errors.New("not found") - } - delete(c.profiles, s) - return nil +func UpsertConfigDir(cmd *cobra.Command) error { + return os.MkdirAll(LoadConfigDir(cmd), 0700) } -func (c *Config) ResetProfile(s string) error { - _, ok := c.profiles[s] - if !ok { - return errors.New("not found") - } - c.profiles[s] = &Profile{ - membershipURI: DefaultMembershipURI, - config: c, +func LoadConfig(cmd *cobra.Command) (*Config, error) { + v, err := ReadJSONFile[Config](cmd, "config.yml") + if os.IsNotExist(err) { + return &Config{ + CurrentProfile: "default", + }, nil } - return nil -} - -func (c *Config) Persist() error { - return c.manager.UpdateConfig(c) -} - -func (c *Config) SetCurrentProfile(name string, profile *Profile) { - c.profiles[name] = profile - c.currentProfile = name -} - -func (c *Config) SetUniqueID(id string) { - c.uniqueID = id -} - -func (c *Config) SetProfile(name string, profile *Profile) { - c.profiles[name] = profile -} - -func (c *Config) GetUniqueID() string { - return c.uniqueID -} - -func (c *Config) GetProfiles() map[string]*Profile { - return c.profiles -} - -func (c *Config) GetCurrentProfileName() string { - return c.currentProfile -} - -func (c *Config) SetCurrentProfileName(s string) { - c.currentProfile = s -} - -func GetConfig(cmd *cobra.Command) (*Config, error) { - return GetConfigManager(cmd).Load() + return v, err } -func GetConfigManager(cmd *cobra.Command) *ConfigManager { - return NewConfigManager(GetString(cmd, FileFlag)) -} - -func GetCurrentProfileName(cmd *cobra.Command, config *Config) string { - if profile := GetString(cmd, ProfileFlag); profile != "" { - return profile - } - currentProfileName := config.GetCurrentProfileName() - if currentProfileName == "" { - currentProfileName = "default" +func WriteConfig(cmd *cobra.Command, config Config) error { + if err := UpsertConfigDir(cmd); err != nil { + return err } - return currentProfileName -} -func GetCurrentProfile(cmd *cobra.Command, cfg *Config) *Profile { - return cfg.GetProfileOrDefault(GetCurrentProfileName(cmd, cfg), DefaultMembershipURI) + return WriteJSONFile(LoadConfigFilePath(cmd), config) } diff --git a/pkg/dialog.go b/pkg/dialog.go new file mode 100644 index 00000000..16480d4a --- /dev/null +++ b/pkg/dialog.go @@ -0,0 +1,21 @@ +package fctl + +import ( + "fmt" + + "github.com/pterm/pterm" +) + +type Dialog interface { + Info(msg string, args ...any) +} + +type ptermDialog struct{} + +func (p ptermDialog) Info(msg string, args ...any) { + pterm.DefaultLogger.Info(fmt.Sprintf(msg, args...)) +} + +func NewPTermDialog() Dialog { + return &ptermDialog{} +} diff --git a/pkg/errors.go b/pkg/errors.go new file mode 100644 index 00000000..9641dc3a --- /dev/null +++ b/pkg/errors.go @@ -0,0 +1,52 @@ +package fctl + +import "fmt" + +type ErrUnauthorized struct { +} + +func (e ErrUnauthorized) Is(target error) bool { + _, ok := target.(*ErrUnauthorized) + return ok +} + +func (e *ErrUnauthorized) Error() string { + return "unauthorized access" +} + +func newErrUnauthorized() error { + return &ErrUnauthorized{} +} + +type ErrForbidden struct { +} + +func (e ErrForbidden) Is(target error) bool { + _, ok := target.(*ErrForbidden) + return ok +} + +func (e *ErrForbidden) Error() string { + return "forbidden access" +} + +func newErrForbidden() error { + return &ErrForbidden{} +} + +type UnexpectedStatusCodeError struct { + StatusCode int +} + +func (e UnexpectedStatusCodeError) Is(target error) bool { + _, ok := target.(*UnexpectedStatusCodeError) + return ok +} + +func (e *UnexpectedStatusCodeError) Error() string { + return fmt.Sprintf("unexpected status code: %d", e.StatusCode) +} + +func newUnexpectedStatusCodeError(statusCode int) error { + return &UnexpectedStatusCodeError{StatusCode: statusCode} +} diff --git a/pkg/file.go b/pkg/file.go index bd80a5ae..6637ab54 100644 --- a/pkg/file.go +++ b/pkg/file.go @@ -7,14 +7,12 @@ import ( "github.com/pkg/errors" "github.com/spf13/cobra" - - "github.com/formancehq/fctl/membershipclient" ) -func ReadFile(cmd *cobra.Command, stack *membershipclient.Stack, where string) (string, error) { +func ReadFile(cmd *cobra.Command, where string) (string, error) { var ret string if where == "-" { - if NeedConfirm(cmd, stack) { + if NeedConfirm(cmd) { return "", errors.New("You need to use --confirm flag to use stdin") } data, err := io.ReadAll(cmd.InOrStdin()) diff --git a/pkg/flags.go b/pkg/flags.go index 614db283..16ac7f6a 100644 --- a/pkg/flags.go +++ b/pkg/flags.go @@ -12,7 +12,7 @@ import ( const ( MembershipURIFlag = "membership-uri" - FileFlag = "config" + ConfigDir = "config-dir" ProfileFlag = "profile" OutputFlag = "output" DebugFlag = "debug" @@ -20,7 +20,6 @@ const ( TelemetryFlag = "telemetry" stackFlag = "stack" organizationFlag = "organization" - FrameworkURIFlag = "framework-uri" ) func GetBool(cmd *cobra.Command, flagName string) bool { diff --git a/pkg/http.go b/pkg/http.go index 183b6660..4034b938 100644 --- a/pkg/http.go +++ b/pkg/http.go @@ -13,11 +13,10 @@ import ( "github.com/spf13/cobra" ) -func GetHttpClient(cmd *cobra.Command, defaultHeaders map[string][]string) *http.Client { - return NewHTTPClient( - cmd, - defaultHeaders, - ) +func GetHttpClient(cmd *cobra.Command) *http.Client { + return &http.Client{ + Transport: NewHTTPTransport(cmd), + } } type RoundTripperFn func(req *http.Request) (*http.Response, error) @@ -87,24 +86,7 @@ func debugRoundTripper(rt http.RoundTripper) RoundTripperFn { } } -func defaultHeadersRoundTripper(rt http.RoundTripper, headers map[string][]string) RoundTripperFn { - return func(req *http.Request) (*http.Response, error) { - for k, v := range headers { - for _, vv := range v { - req.Header.Add(k, vv) - } - } - return rt.RoundTrip(req) - } -} - -func NewHTTPClient(cmd *cobra.Command, defaultHeaders map[string][]string) *http.Client { - return &http.Client{ - Transport: NewHTTPTransport(cmd, defaultHeaders), - } -} - -func NewHTTPTransport(cmd *cobra.Command, defaultHeaders map[string][]string) http.RoundTripper { +func NewHTTPTransport(cmd *cobra.Command) http.RoundTripper { var transport http.RoundTripper = &http.Transport{ TLSClientConfig: &tls.Config{ @@ -114,8 +96,33 @@ func NewHTTPTransport(cmd *cobra.Command, defaultHeaders map[string][]string) ht if GetBool(cmd, DebugFlag) { transport = debugRoundTripper(transport) } - if len(defaultHeaders) > 0 { - transport = defaultHeadersRoundTripper(transport, defaultHeaders) + + return newInjectHTTPHeadersRoundTripper( + http.Header{ + "User-Agent": []string{fmt.Sprintf("fctl/%s", getVersion(cmd))}, + }, + transport, + ) +} + +type injectHTTPHeadersRoundTripper struct { + headers http.Header + next http.RoundTripper +} + +func (rt *injectHTTPHeadersRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { + req = req.Clone(req.Context()) + for key, values := range rt.headers { + for _, value := range values { + req.Header.Add(key, value) + } + } + return rt.next.RoundTrip(req) +} + +func newInjectHTTPHeadersRoundTripper(headers http.Header, next http.RoundTripper) http.RoundTripper { + return &injectHTTPHeadersRoundTripper{ + headers: headers, + next: next, } - return transport } diff --git a/pkg/manager.go b/pkg/manager.go deleted file mode 100644 index c53fde51..00000000 --- a/pkg/manager.go +++ /dev/null @@ -1,70 +0,0 @@ -package fctl - -import ( - "encoding/json" - "os" - "path" -) - -const ( - DefaultMembershipURI = "https://app.formance.cloud/api" - DefaultConsoleURL = "https://portal.formance.cloud" -) - -type ConfigManager struct { - configFilePath string -} - -func (m *ConfigManager) Load() (*Config, error) { - f, err := os.Open(m.configFilePath) - if err != nil { - if os.IsNotExist(err) { - return &Config{ - profiles: map[string]*Profile{}, - manager: m, - }, nil - } - return nil, err - } - defer func() { - _ = f.Close() - }() - - cfg := &Config{} - if err := json.NewDecoder(f).Decode(cfg); err != nil { - return nil, err - } - cfg.manager = m - if cfg.profiles == nil { - cfg.profiles = map[string]*Profile{} - } - - return cfg, nil -} - -func (m *ConfigManager) UpdateConfig(config *Config) error { - if err := os.MkdirAll(path.Dir(m.configFilePath), 0700); err != nil { - return err - } - - f, err := os.OpenFile(m.configFilePath, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) - if err != nil { - return err - } - defer func() { - _ = f.Close() - }() - - enc := json.NewEncoder(f) - enc.SetIndent("", " ") - if err := enc.Encode(config); err != nil { - return err - } - return nil -} - -func NewConfigManager(configFilePath string) *ConfigManager { - return &ConfigManager{ - configFilePath: configFilePath, - } -} diff --git a/pkg/organization.go b/pkg/organization.go index 0413b390..a9432615 100644 --- a/pkg/organization.go +++ b/pkg/organization.go @@ -2,108 +2,32 @@ package fctl import ( "fmt" + "strings" "github.com/spf13/cobra" - "github.com/formancehq/go-libs/collectionutils" - - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/go-libs/v3/collectionutils" ) -type OrganizationStore struct { - *MembershipStore - organizationId string -} - -func (cns OrganizationStore) Client() *membershipclient.DefaultAPIService { - return cns.MembershipClient.DefaultAPI -} - -func (cns OrganizationStore) OrganizationId() string { - return cns.organizationId -} - -func (cns *OrganizationStore) NewStackStore(os *OrganizationStore, stackId string) *MembershipStackStore { - return &MembershipStackStore{ - OrganizationStore: os, - stackId: stackId, - } -} - -func (cns *OrganizationStore) CheckRegionCapability(key string, checker func([]any) bool) func(cmd *cobra.Command, args []string) (err error) { - return func(cmd *cobra.Command, args []string) (err error) { - stack, err := ResolveStack(cmd, cns.Config, cns.organizationId) - if err != nil { - return - } - - region, _, err := cns.Client().GetRegion(cmd.Context(), cns.organizationId, stack.RegionID).Execute() - if err != nil { - return - } - - capabilities, err := StructToMap(region.Data.Capabilities) - if err != nil { - return - } - - if value, ok := capabilities[key]; ok { - if values := value.([]interface{}); len(values) > 0 { - if !checker(values) { - return fmt.Errorf("unsupported membership server version: %s", value) - } - - } - } - return - } -} - -func NewOrganizationStore(store *MembershipStore, organization string) *OrganizationStore { - return &OrganizationStore{ - MembershipStore: store, - organizationId: organization, - } -} - -func NewMembershipOrganizationStore(cmd *cobra.Command) error { - if err := NewMembershipStore(cmd); err != nil { - return err - } - - store := GetMembershipStore(cmd.Context()) - organization, err := ResolveOrganizationID(cmd, store.Config, store.Client()) +func OrganizationCompletion(cmd *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) { + cfg, err := LoadConfig(cmd) if err != nil { - return err + return nil, cobra.ShellCompDirectiveError } - cmd.SetContext(ContextWithOrganizationStore(cmd.Context(), NewOrganizationStore(store, organization))) - - return nil -} - -func OrganizationCompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if err := NewMembershipStore(cmd); err != nil { - return []string{}, cobra.ShellCompDirectiveError - } - - mbStore := GetMembershipStore(cmd.Context()) - if mbStore == nil { - return []string{}, cobra.ShellCompDirectiveNoFileComp - } - - ret, res, err := mbStore.Client().ListOrganizations(cmd.Context()).Execute() + profile, _, err := LoadCurrentProfile(cmd, *cfg) if err != nil { - return []string{}, cobra.ShellCompDirectiveError + return nil, cobra.ShellCompDirectiveError } - if res.StatusCode > 300 { - return []string{}, cobra.ShellCompDirectiveError - } + organizationClaims := profile.RootTokens.ID.Claims.Organizations + organizationClaims = collectionutils.Filter(organizationClaims, func(s OrganizationAccess) bool { + return toComplete == "" || strings.HasPrefix(s.ID, toComplete) + }) - opts := collectionutils.Reduce(ret.Data, func(acc []string, o membershipclient.OrganizationExpanded) []string { - return append(acc, fmt.Sprintf("%s\t%s", o.Id, o.Name)) - }, []string{}) + ret := collectionutils.Map(organizationClaims, func(from OrganizationAccess) string { + return fmt.Sprintf("%s\t%s", from.ID, from.DisplayName) + }) - return opts, cobra.ShellCompDirectiveNoFileComp + return ret, cobra.ShellCompDirectiveNoFileComp } diff --git a/pkg/printer/cursor.go b/pkg/printer/cursor.go index 18626352..c33b092d 100644 --- a/pkg/printer/cursor.go +++ b/pkg/printer/cursor.go @@ -5,11 +5,16 @@ import ( "io" "github.com/pterm/pterm" - - "github.com/formancehq/fctl/membershipclient" ) -func Cursor(writer io.Writer, cursor *membershipclient.Cursor) error { +type CursorData struct { + HasMore bool + Next *string + PageSize int64 + Previous *string +} + +func Cursor(writer io.Writer, cursor *CursorData) error { tableData := pterm.TableData{} tableData = append(tableData, []string{pterm.LightCyan("HasMore"), fmt.Sprintf("%v", cursor.HasMore)}) tableData = append(tableData, []string{pterm.LightCyan("PageSize"), fmt.Sprintf("%d", cursor.PageSize)}) diff --git a/pkg/printer/log.go b/pkg/printer/log.go index 527cdbc3..99061b7f 100644 --- a/pkg/printer/log.go +++ b/pkg/printer/log.go @@ -8,35 +8,36 @@ import ( "github.com/formancehq/go-libs/time" - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient/models/components" fctl "github.com/formancehq/fctl/pkg" ) -func LogCursor(writer io.Writer, cursor *membershipclient.LogCursorData, withData bool) error { +func LogCursor(writer io.Writer, cursor *components.LogCursorData, withData bool) error { header := []string{"Identifier", "User", "Date", "Action"} if withData { header = append(header, "Data") } - tableData := fctl.Map(cursor.Data, func(log membershipclient.Log) []string { + tableData := fctl.Map(cursor.GetData(), func(log components.Log) []string { line := []string{ - log.Seq, + log.GetSeq(), func() string { - if log.UserId == "" { + if log.GetUserID() == "" { return "SYSTEM" } - return log.UserId + return log.GetUserID() }(), - log.Date.Format(time.DateFormat), - log.Action, + log.GetDate().Format(time.DateFormat), + log.GetAction(), } if withData { line = append(line, func() string { - if log.Data == nil { + data := log.GetData() + if data == (components.LogData{}) { return "" } - return fmt.Sprintf("%v", log.Data) + return fmt.Sprintf("%v", data) }()) } @@ -53,10 +54,10 @@ func LogCursor(writer io.Writer, cursor *membershipclient.LogCursorData, withDat return err } - return Cursor(writer, &membershipclient.Cursor{ - HasMore: cursor.HasMore, - PageSize: cursor.PageSize, - Next: cursor.Next, - Previous: cursor.Previous, + return Cursor(writer, &CursorData{ + HasMore: cursor.GetHasMore(), + PageSize: cursor.GetPageSize(), + Next: cursor.GetNext(), + Previous: cursor.GetPrevious(), }) } diff --git a/pkg/profile.go b/pkg/profile.go index aa5c4472..04781388 100644 --- a/pkg/profile.go +++ b/pkg/profile.go @@ -1,28 +1,15 @@ package fctl import ( - "bytes" - "context" - "encoding/json" - "fmt" - "io" - "net/http" - "net/url" + "io/fs" + "os" + "path/filepath" "sort" - "strings" - "time" - "github.com/golang-jwt/jwt" "github.com/pkg/errors" "github.com/spf13/cobra" - "github.com/zitadel/oidc/v2/pkg/client" - "github.com/zitadel/oidc/v2/pkg/client/rp" - "github.com/zitadel/oidc/v2/pkg/oidc" - "golang.org/x/oauth2" - "github.com/formancehq/go-libs/logging" - - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/go-libs/v3/oidc/client" ) type ErrInvalidAuthentication struct { @@ -54,288 +41,210 @@ func newErrInvalidAuthentication(err error) *ErrInvalidAuthentication { const AuthClient = "fctl" -type persistedProfile struct { - MembershipURI string `json:"membershipURI"` - Token *oidc.AccessTokenResponse `json:"token"` - DefaultOrganization string `json:"defaultOrganization"` - DefaultStack string `json:"defaultStack"` -} - type Profile struct { - membershipURI string - token *oidc.AccessTokenResponse - - defaultOrganization string - defaultStack string + MembershipURI string `json:"membershipURI"` + RootTokens *Tokens `json:"rootTokens"` - config *Config + DefaultOrganization string `json:"defaultOrganization"` + DefaultStack string `json:"defaultStack"` } -func (p *Profile) ServicesBaseUrl(stack *membershipclient.Stack) *url.URL { - baseUrl, err := url.Parse(stack.Uri) - if err != nil { - panic(err) - } - return baseUrl +func (p *Profile) UpdateRootToken(tokens *Tokens) { + p.RootTokens = tokens } -func (p *Profile) ApiUrl(stack *membershipclient.Stack, service string) *url.URL { - url := p.ServicesBaseUrl(stack) - url.Path = "/api/" + service - return url -} - -func (p *Profile) UpdateToken(token *oidc.AccessTokenResponse) { - p.token = token +func (p *Profile) GetMembershipURI() string { + return p.MembershipURI } -func (p *Profile) SetMembershipURI(v string) { - p.membershipURI = v +func (p *Profile) GetDefaultOrganization() string { + return p.DefaultOrganization } -func (p *Profile) MarshalJSON() ([]byte, error) { - return json.Marshal(persistedProfile{ - MembershipURI: p.membershipURI, - Token: p.token, - DefaultOrganization: p.defaultOrganization, - DefaultStack: p.defaultStack, - }) +func (p *Profile) GetDefaultStack() string { + return p.DefaultStack } -func (p *Profile) UnmarshalJSON(data []byte) error { - cfg := &persistedProfile{} - if err := json.Unmarshal(data, cfg); err != nil { - return err - } - *p = Profile{ - membershipURI: cfg.MembershipURI, - token: cfg.Token, - defaultOrganization: cfg.DefaultOrganization, - defaultStack: cfg.DefaultStack, - } - return nil +func (p *Profile) GetRootToken() (*AccessToken, error) { + return &p.RootTokens.Access, nil } -func (p *Profile) GetMembershipURI() string { - return p.membershipURI +func (p *Profile) GetClaims() (AccessTokenClaims, error) { + return p.RootTokens.Access.Claims, nil } -func (p *Profile) GetDefaultOrganization() string { - return p.defaultOrganization +func (p *Profile) SetDefaultOrganization(o string) { + p.DefaultOrganization = o } -func (p *Profile) GetDefaultStack() string { - return p.defaultStack +func (p *Profile) IsConnected() bool { + return p.RootTokens != nil } -func (p *Profile) GetToken(ctx context.Context, httpClient *http.Client) (*oauth2.Token, error) { - logging.FromContext(ctx).Debug("Check token from profile") - if p.token == nil { - return nil, errors.New("not authenticated") +func LoadCurrentProfile(cmd *cobra.Command, cfg Config) (*Profile, string, error) { + currentProfileName := GetCurrentProfileName(cmd, cfg) + profile, err := LoadProfile(cmd, currentProfileName) + if errors.Is(err, &fs.PathError{}) || errors.Is(err, os.ErrNotExist) { + return &Profile{ + MembershipURI: DefaultMembershipURI, + }, currentProfileName, nil } - logging.FromContext(ctx).Debug("Has been authenticated") - if p.token != nil { - claims := &oidc.AccessTokenClaims{} - _, err := oidc.ParseToken(p.token.AccessToken, claims) - if err != nil { - return nil, newErrInvalidAuthentication(errors.Wrap(err, "parsing token")) - } - logging.FromContext(ctx).Debugf("Token has expired ? %s in %s", BoolToString(claims.Expiration.AsTime().Before(time.Now())), time.Since(claims.Expiration.AsTime()).String()) - if claims.Expiration.AsTime().Before(time.Now()) { - relyingParty, err := GetAuthRelyingParty(httpClient, p.membershipURI) - if err != nil { - return nil, err - } - newToken, err := rp.RefreshAccessToken(relyingParty, p.token.RefreshToken, "", "") - if err != nil { - return nil, newErrInvalidAuthentication(errors.Wrap(err, "refreshing token")) - } + return profile, currentProfileName, err +} - p.UpdateToken(&oidc.AccessTokenResponse{ - AccessToken: newToken.AccessToken, - TokenType: newToken.TokenType, - RefreshToken: newToken.RefreshToken, - IDToken: newToken.Extra("id_token").(string), - }) - if err := p.config.Persist(); err != nil { - return nil, err - } - logging.FromContext(ctx).Debug("Token refreshed and persisted") - } - } - claims := &oidc.AccessTokenClaims{} - _, err := oidc.ParseToken(p.token.AccessToken, claims) +func LoadAndAuthenticateCurrentProfileWithConfig(cmd *cobra.Command, cfg Config) (*Profile, string, client.RelyingParty, error) { + + profile, profileName, err := LoadCurrentProfile(cmd, cfg) if err != nil { - return nil, newErrInvalidAuthentication(err) + return nil, "", nil, err } - return &oauth2.Token{ - AccessToken: p.token.AccessToken, - TokenType: p.token.TokenType, - RefreshToken: p.token.RefreshToken, - Expiry: claims.Expiration.AsTime(), - }, nil -} -func (p *Profile) GetClaims() (jwt.MapClaims, error) { - claims := jwt.MapClaims{} - parser := jwt.Parser{} - _, _, err := parser.ParseUnverified(p.token.AccessToken, claims) + relyingParty, err := GetAuthRelyingParty(cmd.Context(), GetHttpClient(cmd), profile.GetMembershipURI()) if err != nil { - return nil, err + return nil, "", nil, err } - return claims, nil -} -func (p *Profile) GetUserInfo(cmd *cobra.Command) (*userClaims, error) { - claims := &userClaims{} - if p.token == nil || p.token.IDToken == "" { - return nil, errors.New("not authenticated") + if !profile.IsConnected() { + return nil, "", nil, newErrInvalidAuthentication(errors.New("not authenticated, please run 'fctl login'")) } - _, err := oidc.ParseToken(p.token.IDToken, claims) - if err != nil { - return nil, err - } + return profile, profileName, relyingParty, nil +} - mbClient, err := NewMembershipClient(cmd, p.config) - if err != nil { - return nil, err - } - token, err := mbClient.GetProfile().GetToken(cmd.Context(), mbClient.GetConfig().HTTPClient) +func LoadAndAuthenticateCurrentProfile(cmd *cobra.Command) (*Config, *Profile, string, client.RelyingParty, error) { + cfg, err := LoadConfig(cmd) if err != nil { - return nil, err - } - relyingParty, err := GetAuthRelyingParty(mbClient.GetConfig().HTTPClient, p.membershipURI) - if err != nil { - return nil, err + return nil, nil, "", nil, err } - ui, err := rp.Userinfo(token.AccessToken, token.TokenType, claims.Subject, relyingParty) + profile, profileName, relyingParty, err := LoadAndAuthenticateCurrentProfileWithConfig(cmd, *cfg) if err != nil { - return nil, err + return nil, nil, "", nil, err } - claims.Email = ui.Email - claims.Subject = ui.Subject - - return claims, nil + return cfg, profile, profileName, relyingParty, nil } -func (p *Profile) GetStackToken(ctx context.Context, httpClient *http.Client, stack *membershipclient.Stack) (*oauth2.Token, error) { +type CurrentProfile Profile - form := url.Values{ - "grant_type": []string{string(oidc.GrantTypeTokenExchange)}, - "audience": []string{fmt.Sprintf("stack://%s/%s", stack.OrganizationId, stack.Id)}, - "subject_token": []string{p.token.AccessToken}, - "subject_token_type": []string{"urn:ietf:params:oauth:token-type:access_token"}, - } +func ListProfiles(cmd *cobra.Command, filters ...func(string) bool) ([]string, error) { - membershipDiscoveryConfiguration, err := client.Discover(p.membershipURI, httpClient) - if err != nil { - return nil, err - } + ret := make([]string, 0) - req, err := http.NewRequestWithContext(ctx, http.MethodPost, membershipDiscoveryConfiguration.TokenEndpoint, - bytes.NewBufferString(form.Encode())) + dir, err := os.ReadDir(GetFilePath(cmd, "profiles")) if err != nil { return nil, err } - req.SetBasicAuth(AuthClient, "") - req.Header.Set("Content-Type", "application/x-www-form-urlencoded") - ret, err := httpClient.Do(req) - if err != nil { - return nil, err - } - defer func() { - _ = ret.Body.Close() - }() - - if ret.StatusCode != http.StatusOK { - data, err := io.ReadAll(ret.Body) - if err != nil { - panic(err) +l: + for _, d := range dir { + if d.IsDir() { + name := d.Name() + for _, filter := range filters { + if !filter(name) { + continue l + } + } + + ret = append(ret, name) } - return nil, errors.New(string(data)) } - securityToken := oauth2.Token{} - if err := json.NewDecoder(ret.Body).Decode(&securityToken); err != nil { - return nil, err - } + sort.Strings(ret) + return ret, nil +} - apiUrl := p.ApiUrl(stack, "auth") - form = url.Values{ - "grant_type": []string{"urn:ietf:params:oauth:grant-type:jwt-bearer"}, - "assertion": []string{securityToken.AccessToken}, - "scope": []string{"openid email"}, - } +func LoadProfile(cmd *cobra.Command, name string) (*Profile, error) { + return ReadJSONFile[Profile](cmd, filepath.Join("profiles", name, "profile.json")) +} - stackDiscoveryConfiguration, err := client.Discover(apiUrl.String(), httpClient) - if err != nil { - return nil, err +func WriteProfile(cmd *cobra.Command, name string, profile Profile) error { + profileDir := GetFilePath(cmd, filepath.Join("profiles", name)) + if err := os.MkdirAll(profileDir, 0700); err != nil { + return err } - req, err = http.NewRequestWithContext(ctx, http.MethodPost, stackDiscoveryConfiguration.TokenEndpoint, - bytes.NewBufferString(form.Encode())) - if err != nil { - return nil, err - } - req.Header.Set("Content-Type", "application/x-www-form-urlencoded") + return WriteJSONFile(filepath.Join(profileDir, "profile.json"), profile) +} - now := time.Now() - ret, err = httpClient.Do(req) +func DeleteProfile(cmd *cobra.Command, name string) error { + profileDir := GetFilePath(cmd, filepath.Join("profiles", name)) + return os.RemoveAll(profileDir) +} + +func RenameProfile(cmd *cobra.Command, oldName, newName string) error { + oldProfileDir := GetFilePath(cmd, filepath.Join("profiles", oldName)) + newProfileDir := GetFilePath(cmd, filepath.Join("profiles", newName)) + return os.Rename(oldProfileDir, newProfileDir) +} + +func ResetProfile(cmd *cobra.Command, name string) error { + profile, err := LoadProfile(cmd, name) if err != nil { - return nil, err + return err } + profile.MembershipURI = DefaultMembershipURI - if ret.StatusCode != http.StatusOK { - data, err := io.ReadAll(ret.Body) - if err != nil { - panic(err) - } - return nil, errors.New(string(data)) + return WriteProfile(cmd, name, *profile) +} + +func WriteOrganizationToken(cmd *cobra.Command, profileName string, token AccessToken) error { + profileDir := GetFilePath(cmd, filepath.Join("profiles", profileName, "organizations", token.Claims.OrganizationID)) + if err := os.MkdirAll(profileDir, 0700); err != nil { + return err } - stackToken := &oauth2.Token{} - if err := json.NewDecoder(ret.Body).Decode(stackToken); err != nil { + return WriteJSONFile(filepath.Join(profileDir, "accesses.json"), token) +} + +func ReadOrganizationToken(cmd *cobra.Command, profileName, organizationID string) (*AccessToken, error) { + ret, err := ReadJSONFile[AccessToken](cmd, filepath.Join("profiles", profileName, "organizations", organizationID, "accesses.json")) + if err != nil { + if errors.Is(err, &fs.PathError{}) || errors.Is(err, os.ErrNotExist) { + return nil, nil + } return nil, err } + return ret, nil +} - if stackToken.Expiry.IsZero() { - stackToken.Expiry = now.Add(time.Duration(stackToken.ExpiresIn) * time.Second) +func WriteStackToken(cmd *cobra.Command, profileName, stackID string, token AccessToken) error { + profileDir := GetFilePath(cmd, filepath.Join("profiles", profileName, "organizations", token.Claims.OrganizationID, "stacks", stackID)) + if err := os.MkdirAll(profileDir, 0700); err != nil { + return err } - return stackToken, nil + return WriteJSONFile(filepath.Join(profileDir, "accesses.json"), token) } -func (p *Profile) SetDefaultOrganization(o string) { - p.defaultOrganization = o +func ReadStackToken(cmd *cobra.Command, profileName, organizationID, stackID string) (*AccessToken, error) { + ret, err := ReadJSONFile[AccessToken](cmd, filepath.Join("profiles", profileName, "organizations", organizationID, "stacks", stackID, "accesses.json")) + if err != nil { + if errors.Is(err, &fs.PathError{}) || errors.Is(err, os.ErrNotExist) { + return nil, nil + } + return nil, err + } + return ret, nil } -func (p *Profile) SetDefaultStack(s string) { - p.defaultStack = s -} +func WriteAppToken(cmd *cobra.Command, profileName, appAlias string, token AccessToken) error { + profileDir := GetFilePath(cmd, filepath.Join("profiles", profileName, "organizations", token.Claims.OrganizationID, "apps", appAlias)) + if err := os.MkdirAll(profileDir, 0700); err != nil { + return err + } -func (p *Profile) IsConnected() bool { - return p.token != nil + return WriteJSONFile(filepath.Join(profileDir, "accesses.json"), token) } -type CurrentProfile Profile - -func ListProfiles(cmd *cobra.Command, toComplete string) ([]string, error) { - config, err := GetConfig(cmd) +func ReadAppToken(cmd *cobra.Command, profileName, organizationID, appAlias string) (*AccessToken, error) { + ret, err := ReadJSONFile[AccessToken](cmd, filepath.Join("profiles", profileName, "organizations", organizationID, "apps", appAlias, "accesses.json")) if err != nil { - return []string{}, nil - } - - ret := make([]string, 0) - for p := range config.GetProfiles() { - if strings.HasPrefix(p, toComplete) { - ret = append(ret, p) + if errors.Is(err, &fs.PathError{}) || errors.Is(err, os.ErrNotExist) { + return nil, nil } + return nil, err } - sort.Strings(ret) return ret, nil } diff --git a/pkg/ptr.go b/pkg/ptr.go index 434fa617..69310dfb 100644 --- a/pkg/ptr.go +++ b/pkg/ptr.go @@ -1,7 +1,5 @@ package fctl -import "time" - func BoolToString(v bool) string { if !v { return "No" @@ -22,10 +20,3 @@ func StringPointerToString(v *string) string { } return *v } - -func TimePointerToString(v *time.Time) string { - if v == nil { - return "Never" - } - return v.String() -} diff --git a/pkg/relyingparty.go b/pkg/relyingparty.go index ee08ea28..09809685 100644 --- a/pkg/relyingparty.go +++ b/pkg/relyingparty.go @@ -1,12 +1,23 @@ package fctl import ( + "context" "net/http" - "github.com/zitadel/oidc/v2/pkg/client/rp" + "github.com/pterm/pterm" + + "github.com/formancehq/go-libs/v3/oidc/client" ) -func GetAuthRelyingParty(httpClient *http.Client, membershipURI string) (rp.RelyingParty, error) { - return rp.NewRelyingPartyOIDC(membershipURI, AuthClient, "", - "", []string{"openid", "email", "offline_access", "supertoken", "accesses"}, rp.WithHTTPClient(httpClient)) +func GetAuthRelyingParty(ctx context.Context, httpClient *http.Client, membershipURI string) (client.RelyingParty, error) { + pterm.Debug.Println("Getting auth relying party on membership URI:", membershipURI) + return client.NewRelyingPartyOIDC( + ctx, + membershipURI, + AuthClient, + "", + "", + []string{}, + client.WithHTTPClient(httpClient), + ) } diff --git a/pkg/stack.go b/pkg/stack.go index 8c213af7..45c4de6e 100644 --- a/pkg/stack.go +++ b/pkg/stack.go @@ -2,87 +2,41 @@ package fctl import ( "fmt" + "strings" "github.com/spf13/cobra" - "github.com/formancehq/go-libs/collectionutils" - - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/go-libs/v3/collectionutils" ) -type MembershipStackStore struct { - *OrganizationStore - stackId string -} - -func (cns MembershipStackStore) StackId() string { - return cns.stackId -} - -func NewMembershipStackStore(cmd *cobra.Command) error { - cfg, err := GetConfig(cmd) +func StackCompletion(cmd *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective) { + cfg, err := LoadConfig(cmd) if err != nil { - return fmt.Errorf("failed to get config: %w", err) + return nil, cobra.ShellCompDirectiveError } - stackId, err := GetSelectedStackIDError(cmd, cfg) + profile, _, err := LoadCurrentProfile(cmd, *cfg) if err != nil { - return err + return nil, cobra.ShellCompDirectiveError } - store := GetOrganizationStore(cmd) - cmd.SetContext(ContextWithMembershipStackStore( - cmd.Context(), - &MembershipStackStore{ - OrganizationStore: store, - stackId: stackId, - }, - )) - - return nil -} - -func StackCompletion(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { - if err := NewMembershipStore(cmd); err != nil { - return []string{}, cobra.ShellCompDirectiveError - } - - var organization string - if orgaFlag := cmd.Flag(organizationFlag); orgaFlag != nil { - organization = orgaFlag.Value.String() - } + organizationID, _ := ResolveOrganizationID(cmd, *profile) - mbStore := GetMembershipStore(cmd.Context()) - if mbStore == nil { - return []string{}, cobra.ShellCompDirectiveNoFileComp - } - - if organization == "" { - if mbStore.Config == nil { - return []string{}, cobra.ShellCompDirectiveNoFileComp - } - p := mbStore.Config.GetProfile(GetCurrentProfileName(cmd, mbStore.Config)) - if p != nil { - organization = p.GetDefaultOrganization() - } - } - - if organization == "" { - return []string{}, cobra.ShellCompDirectiveNoFileComp - } - - ret, res, err := mbStore.Client().ListStacks(cmd.Context(), organization).Execute() - if err != nil { - return []string{}, cobra.ShellCompDirectiveError - } - - if res.StatusCode > 300 { - return []string{}, cobra.ShellCompDirectiveError - } + organizationClaims := profile.RootTokens.ID.Claims.Organizations + organizationClaims = collectionutils.Filter(organizationClaims, func(s OrganizationAccess) bool { + return strings.HasPrefix(s.ID, organizationID) + }) + stackClaims := collectionutils.Map(organizationClaims, func(s OrganizationAccess) []StackAccess { + return s.Stacks + }) + stackList := collectionutils.Flatten(stackClaims) + stackList = collectionutils.Filter(stackList, func(s StackAccess) bool { + return toComplete == "" || strings.HasPrefix(s.ID, toComplete) + }) - opts := collectionutils.Reduce(ret.Data, func(acc []string, s membershipclient.Stack) []string { - return append(acc, fmt.Sprintf("%s\t%s", s.Id, s.Name)) - }, []string{}) + ret := collectionutils.Map(stackList, func(from StackAccess) string { + return fmt.Sprintf("%s\t%s", from.ID, from.DisplayName) + }) - return opts, cobra.ShellCompDirectiveNoFileComp + return ret, cobra.ShellCompDirectiveNoFileComp } diff --git a/pkg/stores.go b/pkg/stores.go deleted file mode 100644 index 5e7f33b3..00000000 --- a/pkg/stores.go +++ /dev/null @@ -1,209 +0,0 @@ -package fctl - -import ( - "context" - "fmt" - "net/http" - - "github.com/spf13/cobra" - - v2 "github.com/formancehq/formance-sdk-go/v3" - - "github.com/formancehq/fctl/internal/deployserverclient" - "github.com/formancehq/fctl/membershipclient" -) - -var ( - storeKey string = "_stores" - stackKey = "_stack" - membershipKey string = "_membership" - orgKey = "_membership_organization" - membershipStackKey = "_membership_stack" - deployServerKey = struct{}{} -) - -func GetOrganizationStore(cmd *cobra.Command) *OrganizationStore { - return GetStore(cmd.Context(), orgKey).(*OrganizationStore) -} - -func GetMembershipStackStore(ctx context.Context) *MembershipStackStore { - return GetStore(ctx, membershipStackKey).(*MembershipStackStore) -} - -func ContextWithOrganizationStore(ctx context.Context, store *OrganizationStore) context.Context { - return ContextWithStore(ctx, orgKey, store) -} - -func ContextWithMembershipStackStore(ctx context.Context, store *MembershipStackStore) context.Context { - return ContextWithStore(ctx, membershipStackKey, store) -} - -func ContextWithStore(ctx context.Context, key string, store interface{}) context.Context { - var stores map[string]interface{} - stores, ok := ctx.Value(storeKey).(map[string]interface{}) - if !ok { - stores = map[string]interface{}{} - } - stores[key] = store - - return context.WithValue(ctx, storeKey, stores) -} - -func GetStore(ctx context.Context, key string) any { - stores, ok := ctx.Value(storeKey).(map[string]interface{}) - if !ok { - return nil - } - store, ok := stores[key] - if !ok { - return nil - } - return store -} - -type StackStore struct { - Config *Config - stack *membershipclient.Stack - stackClient *v2.Formance - organizationId string -} - -func (cns StackStore) Client() *v2.Formance { - return cns.stackClient -} - -func (cns StackStore) Stack() *membershipclient.Stack { - return cns.stack -} - -func (cns StackStore) OrganizationId() string { - return cns.organizationId -} - -func StackNode(config *Config, stack *membershipclient.Stack, organization string, stackClient *v2.Formance) *StackStore { - return &StackStore{ - Config: config, - stack: stack, - organizationId: organization, - stackClient: stackClient, - } -} - -func GetStackStore(ctx context.Context) *StackStore { - return GetStore(ctx, stackKey).(*StackStore) -} - -func ContextWithStackStore(ctx context.Context, store *StackStore) context.Context { - return ContextWithStore(ctx, stackKey, store) -} - -func NewStackStore(cmd *cobra.Command) error { - cfg, err := GetConfig(cmd) - if err != nil { - return err - } - apiClient, err := NewMembershipClient(cmd, cfg) - if err != nil { - return err - } - organizationID, err := ResolveOrganizationID(cmd, cfg, apiClient.DefaultAPI) - if err != nil { - return err - } - - stack, err := ResolveStack(cmd, cfg, organizationID) - if err != nil { - return err - } - - stackClient, err := NewStackClient(cmd, cfg, stack) - if err != nil { - return err - } - cmd.SetContext(ContextWithStackStore(cmd.Context(), StackNode(cfg, stack, organizationID, stackClient))) - return nil -} - -type MembershipStore struct { - Config *Config - MembershipClient *MembershipClient -} - -func (cns MembershipStore) Client() *membershipclient.DefaultAPIService { - return cns.MembershipClient.DefaultAPI -} - -func MembershipNode(config *Config, apiClient *MembershipClient) *MembershipStore { - return &MembershipStore{ - Config: config, - MembershipClient: apiClient, - } -} - -func GetMembershipStore(ctx context.Context) *MembershipStore { - return GetStore(ctx, membershipKey).(*MembershipStore) -} - -func ContextWithMembershipStore(ctx context.Context, store *MembershipStore) context.Context { - return ContextWithStore(ctx, membershipKey, store) -} - -func NewMembershipStore(cmd *cobra.Command) error { - cfg, err := GetConfig(cmd) - if err != nil { - return err - } - - apiClient, err := NewMembershipClient(cmd, cfg) - if err != nil { - return err - } - cmd.SetContext(ContextWithMembershipStore(cmd.Context(), MembershipNode(cfg, apiClient))) - return nil -} - -func ContextWithDeployServerStore(ctx context.Context, store *DeployServerStore) context.Context { - return context.WithValue(ctx, deployServerKey, store) -} - -func GetDeployServerStore(ctx context.Context) *DeployServerStore { - return ctx.Value(deployServerKey).(*DeployServerStore) -} - -type DeployServerStore struct { - Cli *deployserverclient.DeployServer -} - -func NewDeployServerStore(cmd *cobra.Command) error { - rt := NewHTTPTransport(cmd, map[string][]string{}) - sdkOptions := []deployserverclient.SDKOption{ - deployserverclient.WithClient(&http.Client{ - Transport: RoundTripperFn(func(req *http.Request) (*http.Response, error) { - cfg, err := GetConfig(cmd) - if err != nil { - return nil, err - } - - token, err := cfg.GetCurrentProfile().GetToken(cmd.Context(), GetHttpClient(cmd, map[string][]string{})) - if err != nil { - return nil, err - } - req.Header.Set("Authorization", "Bearer "+token.AccessToken) - return rt.RoundTrip(req) - }), - }), - } - uri := GetString(cmd, FrameworkURIFlag) - if uri == "" { - return fmt.Errorf("--%s is required", FrameworkURIFlag) - } else { - sdkOptions = append(sdkOptions, deployserverclient.WithServerURL(uri)) - } - - cli := deployserverclient.New(sdkOptions...) - - cmd.SetContext(ContextWithDeployServerStore(cmd.Context(), &DeployServerStore{ - Cli: cli, - })) - return nil -} diff --git a/pkg/theme.go b/pkg/theme.go index ffefc85f..950c5f0b 100644 --- a/pkg/theme.go +++ b/pkg/theme.go @@ -9,11 +9,10 @@ var ( StyleRed = pterm.NewStyle(pterm.FgLightRed) StyleCyan = pterm.NewStyle(pterm.FgLightCyan) - BasicText = pterm.DefaultBasicText - BasicTextGreen = pterm.DefaultBasicText.WithStyle(StyleGreen) - BasicTextRed = pterm.DefaultBasicText.WithStyle(StyleRed) - BasicTextCyan = pterm.DefaultBasicText.WithStyle(StyleCyan) - Section = pterm.SectionPrinter{ + BasicText = pterm.DefaultBasicText + BasicTextRed = pterm.DefaultBasicText.WithStyle(StyleRed) + BasicTextCyan = pterm.DefaultBasicText.WithStyle(StyleCyan) + Section = pterm.SectionPrinter{ Style: &pterm.ThemeDefault.SectionStyle, Level: 1, TopPadding: 0, diff --git a/pkg/utils.go b/pkg/utils.go index 2e9ae101..d528c09e 100644 --- a/pkg/utils.go +++ b/pkg/utils.go @@ -5,8 +5,13 @@ import ( "errors" "fmt" "net/url" + "os" "os/exec" + "path" + "path/filepath" "runtime" + + "github.com/spf13/cobra" ) func StructToMap(obj interface{}) (newMap map[string]interface{}, err error) { @@ -35,14 +40,6 @@ func MapMap[KEY comparable, VALUE any, DST any](srcs map[KEY]VALUE, mapper func( return ret } -func MapKeys[K comparable, V any](m map[K]V) []K { - ret := make([]K, 0) - for k := range m { - ret = append(ret, k) - } - return ret -} - func Prepend[V any](array []V, items ...V) []V { return append(items, array...) } @@ -57,10 +54,10 @@ func ContainValue[V comparable](array []V, value V) bool { } var ( - ErrOpenningBrowser = errors.New("opening browser") + ErrOpeningBrowser = errors.New("opening browser") ) -func Open(urlString string) error { +func OpenURL(urlString string) error { var ( cmd string args []string @@ -86,5 +83,44 @@ func Open(urlString string) error { return exec.Command(cmd, args...).Start() //nolint:gosec } - return ErrOpenningBrowser + return ErrOpeningBrowser +} + +func ReadJSONFile[V any](cmd *cobra.Command, filePath string) (*V, error) { + f, err := os.Open(GetFilePath(cmd, filePath)) + if err != nil { + return nil, err + } + defer func() { + _ = f.Close() + }() + + v := new(V) + if err := json.NewDecoder(f).Decode(v); err != nil { + return nil, err + } + + return v, nil +} + +func WriteJSONFile(filePath string, data any) error { + dir := path.Dir(filePath) + if err := os.MkdirAll(dir, 0700); err != nil { + return err + } + + f, err := os.OpenFile(filepath.Clean(filePath), os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0600) + if err != nil { + return err + } + defer func() { + _ = f.Close() + }() + + enc := json.NewEncoder(f) + enc.SetIndent("", " ") + if err := enc.Encode(data); err != nil { + return err + } + return nil } diff --git a/pkg/versions.go b/pkg/versions.go deleted file mode 100644 index 4865ff5f..00000000 --- a/pkg/versions.go +++ /dev/null @@ -1,48 +0,0 @@ -package fctl - -import ( - "fmt" - - "github.com/spf13/cobra" - "golang.org/x/mod/semver" - - "github.com/formancehq/go-libs/collectionutils" - - "github.com/formancehq/fctl/membershipclient" -) - -func CheckMembershipVersion(version string) func(cmd *cobra.Command, args []string) error { - return func(cmd *cobra.Command, args []string) error { - store := GetMembershipStore(cmd.Context()) - serverInfo, err := MembershipServerInfo(cmd.Context(), store.Client()) - if err != nil { - return err - } - if !semver.IsValid(serverInfo.Version) { - return nil - } - - if semver.Compare(serverInfo.Version, version) >= 0 { - return nil - } - - return fmt.Errorf("unsupported membership server version: %s", version) - } - -} - -func CheckMembershipCapabilities(capability membershipclient.Capability) func(cmd *cobra.Command, args []string) error { - return func(cmd *cobra.Command, args []string) error { - store := GetMembershipStore(cmd.Context()) - serverInfo, err := MembershipServerInfo(cmd.Context(), store.Client()) - if err != nil { - return err - } - - if collectionutils.Contains(serverInfo.Capabilities, capability) { - return nil - } - - return fmt.Errorf("unsupported membership server capability: %s", capability) - } -} diff --git a/renovate.json b/renovate.json index 5ddbd3ec..73098e6a 100644 --- a/renovate.json +++ b/renovate.json @@ -4,7 +4,7 @@ "github>formancehq/shared-config//renovate/presets/golang" ], "ignoreDeps": [ - "github.com/formancehq/fctl/membershipclient" + "github.com/formancehq/fctl/internal/membershipclient" ], "ignorePaths": ["**/membershipclient/**"] }