From cd21e058c800a11338084f8cf7a47033bc2c4e72 Mon Sep 17 00:00:00 2001 From: Toma Puljak Date: Tue, 13 Aug 2024 12:54:02 +0200 Subject: [PATCH] fix: proper API JSON validation (#905) BREAKING CHANGE: The swagger definition changed significantly and now all request objects must be properly structured Signed-off-by: Toma Puljak --- .github/workflows/lint_pr.yaml | 1 - hack/swagger.sh | 7 +- internal/cmd/tailscale/connection.go | 9 +- internal/util/apiclient/api_client.go | 6 +- internal/util/apiclient/conversion/project.go | 56 +- pkg/agent/agent.go | 24 +- pkg/agent/tailscale/server.go | 2 +- pkg/api/controllers/gitprovider/dto/dto.go | 15 + .../gitprovider/dto/repository_url.go | 8 - .../controllers/gitprovider/gitprovider.go | 19 +- pkg/api/controllers/provider/dto/dto.go | 8 +- pkg/api/controllers/workspace/dto/dto.go | 4 +- pkg/api/controllers/workspace/project.go | 2 +- pkg/api/docs/docs.go | 190 ++++++- pkg/api/docs/swagger.json | 190 ++++++- pkg/api/docs/swagger.yaml | 151 +++++- pkg/api/validator.go | 72 ++- pkg/apiclient/README.md | 1 + pkg/apiclient/api/openapi.yaml | 156 +++++- pkg/apiclient/api_git_provider.go | 4 +- pkg/apiclient/docs/ApiKey.md | 23 +- pkg/apiclient/docs/ContainerRegistry.md | 23 +- pkg/apiclient/docs/ContainerRegistryAPI.md | 2 +- pkg/apiclient/docs/CreateProjectConfigDTO.md | 23 +- .../docs/CreateProjectConfigSourceDTO.md | 9 +- pkg/apiclient/docs/CreateWorkspaceDTO.md | 23 +- pkg/apiclient/docs/DevcontainerConfig.md | 9 +- pkg/apiclient/docs/FRPSConfig.md | 23 +- pkg/apiclient/docs/FileStatus.md | 30 +- pkg/apiclient/docs/GitBranch.md | 16 +- pkg/apiclient/docs/GitNamespace.md | 16 +- pkg/apiclient/docs/GitProvider.md | 23 +- pkg/apiclient/docs/GitProviderAPI.md | 6 +- pkg/apiclient/docs/GitPullRequest.md | 51 +- pkg/apiclient/docs/GitRepository.md | 44 +- pkg/apiclient/docs/GitStatus.md | 16 +- pkg/apiclient/docs/GitUser.md | 30 +- pkg/apiclient/docs/InstallProviderRequest.md | 16 +- pkg/apiclient/docs/NetworkKey.md | 9 +- pkg/apiclient/docs/ProfileAPI.md | 2 +- pkg/apiclient/docs/ProfileData.md | 9 +- pkg/apiclient/docs/Project.md | 58 +- pkg/apiclient/docs/ProjectConfig.md | 44 +- pkg/apiclient/docs/ProjectConfigAPI.md | 2 +- pkg/apiclient/docs/ProjectInfo.md | 30 +- pkg/apiclient/docs/ProjectState.md | 23 +- pkg/apiclient/docs/Provider.md | 16 +- pkg/apiclient/docs/ProviderAPI.md | 2 +- pkg/apiclient/docs/ProviderProviderInfo.md | 16 +- pkg/apiclient/docs/ProviderTarget.md | 23 +- pkg/apiclient/docs/RepositoryUrl.md | 9 +- pkg/apiclient/docs/ServerAPI.md | 2 +- pkg/apiclient/docs/ServerConfig.md | 100 +--- pkg/apiclient/docs/SetGitProviderConfig.md | 124 +++++ pkg/apiclient/docs/SetProjectState.md | 9 +- pkg/apiclient/docs/TargetAPI.md | 2 +- pkg/apiclient/docs/Workspace.md | 30 +- pkg/apiclient/docs/WorkspaceAPI.md | 4 +- pkg/apiclient/docs/WorkspaceDTO.md | 30 +- pkg/apiclient/docs/WorkspaceInfo.md | 16 +- pkg/apiclient/model_api_key.go | 140 ++--- pkg/apiclient/model_container_registry.go | 140 ++--- .../model_create_project_config_dto.go | 150 ++--- .../model_create_project_config_source_dto.go | 76 ++- pkg/apiclient/model_create_workspace_dto.go | 104 ++-- pkg/apiclient/model_devcontainer_config.go | 76 ++- pkg/apiclient/model_file_status.go | 172 +++--- pkg/apiclient/model_frps_config.go | 140 ++--- pkg/apiclient/model_git_branch.go | 108 ++-- pkg/apiclient/model_git_namespace.go | 108 ++-- pkg/apiclient/model_git_provider.go | 140 ++--- pkg/apiclient/model_git_pull_request.go | 274 +++++----- pkg/apiclient/model_git_repository.go | 242 ++++----- pkg/apiclient/model_git_status.go | 102 ++-- pkg/apiclient/model_git_user.go | 172 +++--- .../model_install_provider_request.go | 108 ++-- pkg/apiclient/model_network_key.go | 76 ++- pkg/apiclient/model_profile_data.go | 76 ++- pkg/apiclient/model_project.go | 310 +++++------ pkg/apiclient/model_project_config.go | 240 ++++---- pkg/apiclient/model_project_info.go | 176 +++--- pkg/apiclient/model_project_state.go | 140 ++--- pkg/apiclient/model_provider.go | 108 ++-- pkg/apiclient/model_provider_provider_info.go | 108 ++-- pkg/apiclient/model_provider_target.go | 140 ++--- pkg/apiclient/model_repository_url.go | 76 ++- pkg/apiclient/model_server_config.go | 512 ++++++++---------- .../model_set_git_provider_config.go | 256 +++++++++ pkg/apiclient/model_set_project_state.go | 76 ++- pkg/apiclient/model_workspace.go | 166 +++--- pkg/apiclient/model_workspace_dto.go | 168 +++--- pkg/apiclient/model_workspace_info.go | 104 ++-- pkg/apikey/apikey.go | 6 +- pkg/build/build.go | 12 +- pkg/build/runner_config.go | 6 +- pkg/cmd/apikey/generate.go | 8 +- pkg/cmd/apikey/revoke.go | 14 +- pkg/cmd/containerregistry/delete.go | 2 +- pkg/cmd/containerregistry/set.go | 16 +- pkg/cmd/gitprovider/add.go | 14 +- pkg/cmd/gitprovider/delete.go | 10 +- pkg/cmd/gitprovider/list.go | 6 +- pkg/cmd/ports/forward.go | 14 +- pkg/cmd/profiledata/env/list.go | 8 +- pkg/cmd/profiledata/env/set.go | 6 +- pkg/cmd/projectconfig/add.go | 16 +- pkg/cmd/projectconfig/delete.go | 2 +- pkg/cmd/projectconfig/setdefault.go | 2 +- pkg/cmd/projectconfig/update.go | 24 +- pkg/cmd/provider/install.go | 16 +- pkg/cmd/provider/uninstall.go | 4 +- pkg/cmd/provider/update.go | 16 +- pkg/cmd/target/remove.go | 10 +- pkg/cmd/target/set.go | 14 +- pkg/cmd/workspace/code.go | 14 +- pkg/cmd/workspace/create.go | 36 +- pkg/cmd/workspace/delete.go | 18 +- pkg/cmd/workspace/ssh.go | 8 +- pkg/cmd/workspace/start.go | 20 +- pkg/cmd/workspace/stop.go | 8 +- pkg/cmd/workspace/util/add_from_config.go | 8 +- pkg/cmd/workspace/util/branch_wizard.go | 12 +- pkg/cmd/workspace/util/creation_data.go | 43 +- pkg/cmd/workspace/util/repository_wizard.go | 8 +- pkg/cmd/workspace/util/workspace.go | 3 +- pkg/cmd/workspacemode/git_cred.go | 4 +- pkg/containerregistry/container_registry.go | 6 +- pkg/gitprovider/git_provider.go | 18 +- pkg/gitprovider/types.go | 56 +- pkg/profiledata/profile_data.go | 2 +- pkg/provider/types.go | 10 +- pkg/server/projectconfig/dto/projectconfig.go | 14 +- pkg/server/types.go | 40 +- pkg/server/workspaces/create.go | 2 +- pkg/server/workspaces/dto/workspace.go | 10 +- pkg/views/containerregistry/list/view.go | 12 +- pkg/views/containerregistry/select.go | 6 +- pkg/views/containerregistry/view.go | 8 +- pkg/views/gitprovider/select.go | 20 +- pkg/views/projectconfig/info/view.go | 26 +- pkg/views/projectconfig/list/view.go | 10 +- pkg/views/provider/list.go | 8 +- pkg/views/provider/select.go | 2 +- pkg/views/provider/view.go | 6 +- pkg/views/server/apikey/create.go | 2 +- pkg/views/server/apikey/list.go | 8 +- pkg/views/server/apikey/select.go | 2 +- pkg/views/server/apikey/view.go | 6 +- pkg/views/server/configure.go | 38 +- pkg/views/target/list/view.go | 14 +- pkg/views/target/select.go | 4 +- pkg/views/target/set.go | 8 +- pkg/views/target/view.go | 9 +- pkg/views/workspace/create/configuration.go | 8 +- pkg/views/workspace/create/summary.go | 20 +- pkg/views/workspace/create/view.go | 2 +- pkg/views/workspace/info/view.go | 47 +- pkg/views/workspace/list/view.go | 59 +- pkg/views/workspace/selection/branch.go | 8 +- pkg/views/workspace/selection/namespace.go | 4 +- pkg/views/workspace/selection/project.go | 7 +- .../workspace/selection/projectconfig.go | 15 +- .../workspace/selection/projectrequest.go | 10 +- pkg/views/workspace/selection/pullrequest.go | 10 +- pkg/views/workspace/selection/repository.go | 9 +- pkg/views/workspace/selection/workspace.go | 22 +- .../project/buildconfig/buildconfig.go | 4 +- pkg/workspace/project/config/config.go | 14 +- pkg/workspace/project/project.go | 34 +- pkg/workspace/workspace.go | 14 +- 170 files changed, 4405 insertions(+), 3489 deletions(-) create mode 100644 pkg/api/controllers/gitprovider/dto/dto.go delete mode 100644 pkg/api/controllers/gitprovider/dto/repository_url.go create mode 100644 pkg/apiclient/docs/SetGitProviderConfig.md create mode 100644 pkg/apiclient/model_set_git_provider_config.go diff --git a/.github/workflows/lint_pr.yaml b/.github/workflows/lint_pr.yaml index cce90bac99..faebcec796 100644 --- a/.github/workflows/lint_pr.yaml +++ b/.github/workflows/lint_pr.yaml @@ -34,7 +34,6 @@ jobs: run: | go install github.com/swaggo/swag/cmd/swag@v1.16.3 ./hack/swagger.sh - go fmt ./... git diff --exit-code pkg/apiclient/* || (echo "API clients are out of sync! Please generate with './hack/swagger.sh' and commit" && exit 1) git diff --exit-code '**/*.go' || (echo "Code is not formatted! Please run 'go fmt ./...' and commit" && exit 1) cli-docs: diff --git a/hack/swagger.sh b/hack/swagger.sh index fe207934cf..5822290902 100755 --- a/hack/swagger.sh +++ b/hack/swagger.sh @@ -2,4 +2,9 @@ # SPDX-License-Identifier: Apache-2.0 (cd pkg && swag fmt && swag init --parseDependency --parseInternal --parseDepth 1 -o api/docs -g api/server.go) -GO_POST_PROCESS_FILE="/usr/local/bin/gofmt -w" GIT_USER_ID=daytonaio GIT_REPO_ID=daytona npx --yes @openapitools/openapi-generator-cli generate -i pkg/api/docs/swagger.json -g go --package-name=apiclient --additional-properties=isGoSubmodule=true -o pkg/apiclient && rm -rf pkg/apiclient/.openapi-generator/FILES \ No newline at end of file + +rm pkg/apiclient/*.go +rm -rf pkg/apiclient/docs + +GO_POST_PROCESS_FILE="/usr/local/bin/gofmt -w" GIT_USER_ID=daytonaio GIT_REPO_ID=daytona npx --yes @openapitools/openapi-generator-cli generate -i pkg/api/docs/swagger.json -g go --package-name=apiclient --additional-properties=isGoSubmodule=true -o pkg/apiclient && rm -rf pkg/apiclient/.openapi-generator/FILES +go fmt ./... \ No newline at end of file diff --git a/internal/cmd/tailscale/connection.go b/internal/cmd/tailscale/connection.go index 0528f4a752..bd5177a462 100644 --- a/internal/cmd/tailscale/connection.go +++ b/internal/cmd/tailscale/connection.go @@ -42,13 +42,16 @@ func GetConnection(profile *config.Profile) (*tsnet.Server, error) { var controlURL string if strings.Contains(profile.Api.Url, "localhost") || strings.Contains(profile.Api.Url, "0.0.0.0") || strings.Contains(profile.Api.Url, "127.0.0.1") { - controlURL = fmt.Sprintf("http://localhost:%d", *serverConfig.HeadscalePort) + controlURL = fmt.Sprintf("http://localhost:%d", serverConfig.HeadscalePort) } else { - controlURL = util.GetFrpcHeadscaleUrl(*serverConfig.Frps.Protocol, *serverConfig.Id, *serverConfig.Frps.Domain) + if serverConfig.Frps == nil { + return nil, fmt.Errorf("frps config is missing") + } + controlURL = util.GetFrpcHeadscaleUrl(serverConfig.Frps.Protocol, serverConfig.Id, serverConfig.Frps.Domain) } return tailscale.GetConnection(&tailscale.TsnetConnConfig{ - AuthKey: *networkKey.Key, + AuthKey: networkKey.Key, ControlURL: controlURL, Dir: filepath.Join(configDir, "tailscale", cliId), Logf: func(format string, args ...any) {}, diff --git a/internal/util/apiclient/api_client.go b/internal/util/apiclient/api_client.go index 154486b1f4..f4a4dfbc1c 100644 --- a/internal/util/apiclient/api_client.go +++ b/internal/util/apiclient/api_client.go @@ -176,12 +176,12 @@ func GetFirstWorkspaceProjectName(workspaceId string, projectName string, profil return "", errors.New("no projects found in workspace") } - return *wsInfo.Projects[0].Name, nil + return wsInfo.Projects[0].Name, nil } for _, project := range wsInfo.Projects { - if *project.Name == projectName { - return *project.Name, nil + if project.Name == projectName { + return project.Name, nil } } diff --git a/internal/util/apiclient/conversion/project.go b/internal/util/apiclient/conversion/project.go index 440545d172..9cf1305f53 100644 --- a/internal/util/apiclient/conversion/project.go +++ b/internal/util/apiclient/conversion/project.go @@ -18,21 +18,21 @@ func ToProject(projectDTO *apiclient.Project) *project.Project { } repository := &gitprovider.GitRepository{ - Id: *projectDTO.Repository.Id, - Name: *projectDTO.Repository.Name, + Id: projectDTO.Repository.Id, + Name: projectDTO.Repository.Name, Branch: projectDTO.Repository.Branch, - Owner: *projectDTO.Repository.Owner, + Owner: projectDTO.Repository.Owner, Path: projectDTO.Repository.Path, - Sha: *projectDTO.Repository.Sha, - Source: *projectDTO.Repository.Source, - Url: *projectDTO.Repository.Url, + Sha: projectDTO.Repository.Sha, + Source: projectDTO.Repository.Source, + Url: projectDTO.Repository.Url, } var projectState *project.ProjectState if projectDTO.State != nil { - uptime := *projectDTO.State.Uptime + uptime := projectDTO.State.Uptime projectState = &project.ProjectState{ - UpdatedAt: *projectDTO.State.UpdatedAt, + UpdatedAt: projectDTO.State.UpdatedAt, Uptime: uint64(uptime), GitStatus: ToGitStatus(projectDTO.State.GitStatus), } @@ -41,23 +41,23 @@ func ToProject(projectDTO *apiclient.Project) *project.Project { var projectBuild *buildconfig.ProjectBuildConfig if projectDTO.BuildConfig != nil { projectBuild = &buildconfig.ProjectBuildConfig{} - if projectDTO.BuildConfig.Devcontainer != nil && projectDTO.BuildConfig.Devcontainer.FilePath != nil { + if projectDTO.BuildConfig.Devcontainer != nil { projectBuild.Devcontainer = &buildconfig.DevcontainerConfig{ - FilePath: *projectDTO.BuildConfig.Devcontainer.FilePath, + FilePath: projectDTO.BuildConfig.Devcontainer.FilePath, } } } project := &project.Project{ ProjectConfig: config.ProjectConfig{ - Name: *projectDTO.Name, - Image: *projectDTO.Image, - User: *projectDTO.User, + Name: projectDTO.Name, + Image: projectDTO.Image, + User: projectDTO.User, BuildConfig: projectBuild, Repository: repository, }, - Target: *projectDTO.Target, - WorkspaceId: *projectDTO.WorkspaceId, + Target: projectDTO.Target, + WorkspaceId: projectDTO.WorkspaceId, State: projectState, } @@ -69,18 +69,14 @@ func ToProject(projectDTO *apiclient.Project) *project.Project { return project } -func ToGitStatus(gitStatusDTO *apiclient.GitStatus) *project.GitStatus { - if gitStatusDTO == nil { - return nil - } - +func ToGitStatus(gitStatusDTO apiclient.GitStatus) *project.GitStatus { files := []*project.FileStatus{} for _, fileDTO := range gitStatusDTO.FileStatus { - staging := project.Status(string(*fileDTO.Staging)) - worktree := project.Status(string(*fileDTO.Worktree)) + staging := project.Status(string(fileDTO.Staging)) + worktree := project.Status(string(fileDTO.Worktree)) file := &project.FileStatus{ - Name: *fileDTO.Name, - Extra: *fileDTO.Extra, + Name: fileDTO.Name, + Extra: fileDTO.Extra, Staging: staging, Worktree: worktree, } @@ -88,7 +84,7 @@ func ToGitStatus(gitStatusDTO *apiclient.GitStatus) *project.GitStatus { } return &project.GitStatus{ - CurrentBranch: *gitStatusDTO.CurrentBranch, + CurrentBranch: gitStatusDTO.CurrentBranch, Files: files, } } @@ -103,16 +99,16 @@ func ToGitStatusDTO(gitStatus *project.GitStatus) *apiclient.GitStatus { staging := apiclient.Status(string(file.Staging)) worktree := apiclient.Status(string(file.Worktree)) fileDTO := apiclient.FileStatus{ - Name: &file.Name, - Extra: &file.Extra, - Staging: &staging, - Worktree: &worktree, + Name: file.Name, + Extra: file.Extra, + Staging: staging, + Worktree: worktree, } fileStatusDTO = append(fileStatusDTO, fileDTO) } return &apiclient.GitStatus{ - CurrentBranch: &gitStatus.CurrentBranch, + CurrentBranch: gitStatus.CurrentBranch, FileStatus: fileStatusDTO, } } diff --git a/pkg/agent/agent.go b/pkg/agent/agent.go index 0bc1a04d64..7c428609a3 100644 --- a/pkg/agent/agent.go +++ b/pkg/agent/agent.go @@ -65,12 +65,8 @@ func (a *Agent) startProjectMode() error { var auth *http.BasicAuth if gitProvider != nil { auth = &http.BasicAuth{} - if gitProvider.Username != nil { - auth.Username = *gitProvider.Username - } - if gitProvider.Token != nil { - auth.Password = *gitProvider.Token - } + auth.Username = gitProvider.Username + auth.Password = gitProvider.Token } exists, err := a.Git.RepositoryExists(project) @@ -103,15 +99,15 @@ func (a *Agent) startProjectMode() error { var gitUser *gitprovider.GitUser if gitProvider != nil { - user, err := a.getGitUser(*gitProvider.Id) + user, err := a.getGitUser(gitProvider.Id) if err != nil { log.Error(fmt.Sprintf("failed to get git user data: %s", err)) } else { gitUser = &gitprovider.GitUser{ - Email: *user.Email, - Name: *user.Name, - Id: *user.Id, - Username: *user.Username, + Email: user.Email, + Name: user.Name, + Id: user.Id, + Username: user.Username, } } } @@ -149,7 +145,7 @@ func (a *Agent) getProject() (*project.Project, error) { } for _, project := range workspace.Projects { - if *project.Name == a.Config.ProjectName { + if project.Name == a.Config.ProjectName { return conversion.ToProject(&project), nil } } @@ -228,7 +224,7 @@ func (a *Agent) setDefaultConfig() error { // Agent uptime in seconds func (a *Agent) uptime() int32 { - return int32(time.Since(a.startTime).Seconds()) + return max(int32(time.Since(a.startTime).Seconds()), 1) } func (a *Agent) updateProjectState() error { @@ -244,7 +240,7 @@ func (a *Agent) updateProjectState() error { uptime := a.uptime() res, err := apiClient.WorkspaceAPI.SetProjectState(context.Background(), a.Config.WorkspaceId, a.Config.ProjectName).SetState(apiclient.SetProjectState{ - Uptime: &uptime, + Uptime: uptime, GitStatus: conversion.ToGitStatusDTO(gitStatus), }).Execute() if err != nil { diff --git a/pkg/agent/tailscale/server.go b/pkg/agent/tailscale/server.go index 04fcef1b68..3932ac99b9 100644 --- a/pkg/agent/tailscale/server.go +++ b/pkg/agent/tailscale/server.go @@ -78,7 +78,7 @@ func (s *Server) getNetworkKey() (string, error) { return s.getNetworkKey() } - return *networkKey.Key, nil + return networkKey.Key, nil } func (s *Server) getTsnetServer() (*tsnet.Server, error) { diff --git a/pkg/api/controllers/gitprovider/dto/dto.go b/pkg/api/controllers/gitprovider/dto/dto.go new file mode 100644 index 0000000000..c37e891644 --- /dev/null +++ b/pkg/api/controllers/gitprovider/dto/dto.go @@ -0,0 +1,15 @@ +// Copyright 2024 Daytona Platforms Inc. +// SPDX-License-Identifier: Apache-2.0 + +package dto + +type RepositoryUrl struct { + URL string `json:"url" validate:"required"` +} // @name RepositoryUrl + +type SetGitProviderConfig struct { + Id string `json:"id" validate:"required"` + Username *string `json:"username" validate:"optional"` + Token string `json:"token" validate:"required"` + BaseApiUrl *string `json:"baseApiUrl,omitempty" validate:"optional"` +} // @name SetGitProviderConfig diff --git a/pkg/api/controllers/gitprovider/dto/repository_url.go b/pkg/api/controllers/gitprovider/dto/repository_url.go deleted file mode 100644 index 0112482181..0000000000 --- a/pkg/api/controllers/gitprovider/dto/repository_url.go +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2024 Daytona Platforms Inc. -// SPDX-License-Identifier: Apache-2.0 - -package dto - -type RepositoryUrl struct { - URL string `json:"url"` -} // @name RepositoryUrl diff --git a/pkg/api/controllers/gitprovider/gitprovider.go b/pkg/api/controllers/gitprovider/gitprovider.go index 01672c2fa9..0e7f20b917 100644 --- a/pkg/api/controllers/gitprovider/gitprovider.go +++ b/pkg/api/controllers/gitprovider/gitprovider.go @@ -9,6 +9,7 @@ import ( "net/url" + "github.com/daytonaio/daytona/pkg/api/controllers/gitprovider/dto" "github.com/daytonaio/daytona/pkg/gitprovider" "github.com/daytonaio/daytona/pkg/server" "github.com/gin-gonic/gin" @@ -109,24 +110,34 @@ func GetGitProviderIdForUrl(ctx *gin.Context) { // @Tags gitProvider // @Summary Set Git provider // @Description Set Git provider -// @Param gitProviderConfig body gitprovider.GitProviderConfig true "Git provider" +// @Param gitProviderConfig body SetGitProviderConfig true "Git provider" // @Produce json // @Success 200 // @Router /gitprovider [put] // // @id SetGitProvider func SetGitProvider(ctx *gin.Context) { - var gitProviderData gitprovider.GitProviderConfig + var setConfigDto dto.SetGitProviderConfig - err := ctx.BindJSON(&gitProviderData) + err := ctx.BindJSON(&setConfigDto) if err != nil { ctx.AbortWithError(http.StatusBadRequest, fmt.Errorf("invalid request body: %s", err.Error())) return } + gitProviderConfig := gitprovider.GitProviderConfig{ + Id: setConfigDto.Id, + Token: setConfigDto.Token, + BaseApiUrl: setConfigDto.BaseApiUrl, + } + + if setConfigDto.Username != nil { + gitProviderConfig.Username = *setConfigDto.Username + } + server := server.GetInstance(nil) - err = server.GitProviderService.SetGitProviderConfig(&gitProviderData) + err = server.GitProviderService.SetGitProviderConfig(&gitProviderConfig) if err != nil { ctx.AbortWithError(http.StatusBadRequest, fmt.Errorf("failed to set git provider: %s", err.Error())) return diff --git a/pkg/api/controllers/provider/dto/dto.go b/pkg/api/controllers/provider/dto/dto.go index a0ac21a7ed..8d19d40d87 100644 --- a/pkg/api/controllers/provider/dto/dto.go +++ b/pkg/api/controllers/provider/dto/dto.go @@ -8,11 +8,11 @@ import ( ) type Provider struct { - Name string `json:"name"` - Version string `json:"version"` + Name string `json:"name" validate:"required"` + Version string `json:"version" validate:"required"` } // @name Provider type InstallProviderRequest struct { - Name string `json:"name"` - DownloadUrls map[os.OperatingSystem]string `json:"downloadUrls"` + Name string `json:"name" validate:"required"` + DownloadUrls map[os.OperatingSystem]string `json:"downloadUrls" validate:"required"` } // @name InstallProviderRequest diff --git a/pkg/api/controllers/workspace/dto/dto.go b/pkg/api/controllers/workspace/dto/dto.go index e31f28695d..ae4501c0b4 100644 --- a/pkg/api/controllers/workspace/dto/dto.go +++ b/pkg/api/controllers/workspace/dto/dto.go @@ -8,6 +8,6 @@ import ( ) type SetProjectState struct { - Uptime uint64 `json:"uptime"` - GitStatus project.GitStatus `json:"gitStatus"` + Uptime uint64 `json:"uptime" validate:"required"` + GitStatus *project.GitStatus `json:"gitStatus,omitempty" validate:"optional"` } // @name SetProjectState diff --git a/pkg/api/controllers/workspace/project.go b/pkg/api/controllers/workspace/project.go index 89983ef3f3..e8d6da62ea 100644 --- a/pkg/api/controllers/workspace/project.go +++ b/pkg/api/controllers/workspace/project.go @@ -42,7 +42,7 @@ func SetProjectState(ctx *gin.Context) { _, err = server.WorkspaceService.SetProjectState(workspaceId, projectId, &project.ProjectState{ Uptime: setProjectStateDTO.Uptime, UpdatedAt: time.Now().Format(time.RFC1123), - GitStatus: &setProjectStateDTO.GitStatus, + GitStatus: setProjectStateDTO.GitStatus, }) if err != nil { ctx.AbortWithError(http.StatusInternalServerError, fmt.Errorf("failed to stop workspace %s: %s", workspaceId, err.Error())) diff --git a/pkg/api/docs/docs.go b/pkg/api/docs/docs.go index 2a3a960e92..1311686d1b 100644 --- a/pkg/api/docs/docs.go +++ b/pkg/api/docs/docs.go @@ -238,7 +238,7 @@ const docTemplate = `{ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/GitProvider" + "$ref": "#/definitions/SetGitProviderConfig" } } ], @@ -1341,6 +1341,11 @@ const docTemplate = `{ "definitions": { "ApiKey": { "type": "object", + "required": [ + "keyHash", + "name", + "type" + ], "properties": { "keyHash": { "type": "string" @@ -1356,6 +1361,11 @@ const docTemplate = `{ }, "ContainerRegistry": { "type": "object", + "required": [ + "password", + "server", + "username" + ], "properties": { "password": { "type": "string" @@ -1370,6 +1380,11 @@ const docTemplate = `{ }, "CreateProjectConfigDTO": { "type": "object", + "required": [ + "envVars", + "name", + "source" + ], "properties": { "buildConfig": { "$ref": "#/definitions/ProjectBuildConfig" @@ -1396,6 +1411,9 @@ const docTemplate = `{ }, "CreateProjectConfigSourceDTO": { "type": "object", + "required": [ + "repository" + ], "properties": { "repository": { "$ref": "#/definitions/GitRepository" @@ -1405,7 +1423,10 @@ const docTemplate = `{ "CreateWorkspaceDTO": { "type": "object", "required": [ - "projects" + "id", + "name", + "projects", + "target" ], "properties": { "id": { @@ -1427,6 +1448,9 @@ const docTemplate = `{ }, "DevcontainerConfig": { "type": "object", + "required": [ + "filePath" + ], "properties": { "filePath": { "type": "string" @@ -1435,6 +1459,11 @@ const docTemplate = `{ }, "FRPSConfig": { "type": "object", + "required": [ + "domain", + "port", + "protocol" + ], "properties": { "domain": { "type": "string" @@ -1449,6 +1478,12 @@ const docTemplate = `{ }, "FileStatus": { "type": "object", + "required": [ + "extra", + "name", + "staging", + "worktree" + ], "properties": { "extra": { "type": "string" @@ -1466,6 +1501,10 @@ const docTemplate = `{ }, "GitBranch": { "type": "object", + "required": [ + "name", + "sha" + ], "properties": { "name": { "type": "string" @@ -1477,6 +1516,10 @@ const docTemplate = `{ }, "GitNamespace": { "type": "object", + "required": [ + "id", + "name" + ], "properties": { "id": { "type": "string" @@ -1488,6 +1531,11 @@ const docTemplate = `{ }, "GitProvider": { "type": "object", + "required": [ + "id", + "token", + "username" + ], "properties": { "baseApiUrl": { "type": "string" @@ -1505,6 +1553,15 @@ const docTemplate = `{ }, "GitPullRequest": { "type": "object", + "required": [ + "branch", + "name", + "sha", + "sourceRepoId", + "sourceRepoName", + "sourceRepoOwner", + "sourceRepoUrl" + ], "properties": { "branch": { "type": "string" @@ -1531,6 +1588,14 @@ const docTemplate = `{ }, "GitRepository": { "type": "object", + "required": [ + "id", + "name", + "owner", + "sha", + "source", + "url" + ], "properties": { "branch": { "type": "string" @@ -1563,6 +1628,10 @@ const docTemplate = `{ }, "GitStatus": { "type": "object", + "required": [ + "currentBranch", + "fileStatus" + ], "properties": { "currentBranch": { "type": "string" @@ -1577,6 +1646,12 @@ const docTemplate = `{ }, "GitUser": { "type": "object", + "required": [ + "email", + "id", + "name", + "username" + ], "properties": { "email": { "type": "string" @@ -1594,6 +1669,10 @@ const docTemplate = `{ }, "InstallProviderRequest": { "type": "object", + "required": [ + "downloadUrls", + "name" + ], "properties": { "downloadUrls": { "type": "object", @@ -1608,6 +1687,9 @@ const docTemplate = `{ }, "NetworkKey": { "type": "object", + "required": [ + "key" + ], "properties": { "key": { "type": "string" @@ -1616,6 +1698,9 @@ const docTemplate = `{ }, "ProfileData": { "type": "object", + "required": [ + "envVars" + ], "properties": { "envVars": { "type": "object", @@ -1627,6 +1712,16 @@ const docTemplate = `{ }, "Project": { "type": "object", + "required": [ + "default", + "envVars", + "image", + "name", + "repository", + "target", + "user", + "workspaceId" + ], "properties": { "buildConfig": { "$ref": "#/definitions/ProjectBuildConfig" @@ -1673,6 +1768,14 @@ const docTemplate = `{ }, "ProjectConfig": { "type": "object", + "required": [ + "default", + "envVars", + "image", + "name", + "repository", + "user" + ], "properties": { "buildConfig": { "$ref": "#/definitions/ProjectBuildConfig" @@ -1702,6 +1805,12 @@ const docTemplate = `{ }, "ProjectInfo": { "type": "object", + "required": [ + "created", + "isRunning", + "name", + "workspaceId" + ], "properties": { "created": { "type": "string" @@ -1722,6 +1831,11 @@ const docTemplate = `{ }, "ProjectState": { "type": "object", + "required": [ + "gitStatus", + "updatedAt", + "uptime" + ], "properties": { "gitStatus": { "$ref": "#/definitions/GitStatus" @@ -1736,6 +1850,10 @@ const docTemplate = `{ }, "Provider": { "type": "object", + "required": [ + "name", + "version" + ], "properties": { "name": { "type": "string" @@ -1747,6 +1865,11 @@ const docTemplate = `{ }, "ProviderTarget": { "type": "object", + "required": [ + "name", + "options", + "providerInfo" + ], "properties": { "name": { "type": "string" @@ -1768,6 +1891,9 @@ const docTemplate = `{ }, "RepositoryUrl": { "type": "object", + "required": [ + "url" + ], "properties": { "url": { "type": "string" @@ -1776,6 +1902,22 @@ const docTemplate = `{ }, "ServerConfig": { "type": "object", + "required": [ + "apiPort", + "binariesPath", + "builderImage", + "builderRegistryServer", + "defaultProjectImage", + "defaultProjectUser", + "headscalePort", + "id", + "localBuilderRegistryImage", + "localBuilderRegistryPort", + "logFilePath", + "providersDir", + "registryUrl", + "serverDownloadUrl" + ], "properties": { "apiPort": { "type": "integer" @@ -1827,8 +1969,32 @@ const docTemplate = `{ } } }, + "SetGitProviderConfig": { + "type": "object", + "required": [ + "id", + "token" + ], + "properties": { + "baseApiUrl": { + "type": "string" + }, + "id": { + "type": "string" + }, + "token": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, "SetProjectState": { "type": "object", + "required": [ + "uptime" + ], "properties": { "gitStatus": { "$ref": "#/definitions/GitStatus" @@ -1863,6 +2029,12 @@ const docTemplate = `{ }, "Workspace": { "type": "object", + "required": [ + "id", + "name", + "projects", + "target" + ], "properties": { "id": { "type": "string" @@ -1883,6 +2055,12 @@ const docTemplate = `{ }, "WorkspaceDTO": { "type": "object", + "required": [ + "id", + "name", + "projects", + "target" + ], "properties": { "id": { "type": "string" @@ -1906,6 +2084,10 @@ const docTemplate = `{ }, "WorkspaceInfo": { "type": "object", + "required": [ + "name", + "projects" + ], "properties": { "name": { "type": "string" @@ -1936,6 +2118,10 @@ const docTemplate = `{ }, "provider.ProviderInfo": { "type": "object", + "required": [ + "name", + "version" + ], "properties": { "name": { "type": "string" diff --git a/pkg/api/docs/swagger.json b/pkg/api/docs/swagger.json index c790a82eaf..96d3232b42 100644 --- a/pkg/api/docs/swagger.json +++ b/pkg/api/docs/swagger.json @@ -235,7 +235,7 @@ "in": "body", "required": true, "schema": { - "$ref": "#/definitions/GitProvider" + "$ref": "#/definitions/SetGitProviderConfig" } } ], @@ -1338,6 +1338,11 @@ "definitions": { "ApiKey": { "type": "object", + "required": [ + "keyHash", + "name", + "type" + ], "properties": { "keyHash": { "type": "string" @@ -1353,6 +1358,11 @@ }, "ContainerRegistry": { "type": "object", + "required": [ + "password", + "server", + "username" + ], "properties": { "password": { "type": "string" @@ -1367,6 +1377,11 @@ }, "CreateProjectConfigDTO": { "type": "object", + "required": [ + "envVars", + "name", + "source" + ], "properties": { "buildConfig": { "$ref": "#/definitions/ProjectBuildConfig" @@ -1393,6 +1408,9 @@ }, "CreateProjectConfigSourceDTO": { "type": "object", + "required": [ + "repository" + ], "properties": { "repository": { "$ref": "#/definitions/GitRepository" @@ -1402,7 +1420,10 @@ "CreateWorkspaceDTO": { "type": "object", "required": [ - "projects" + "id", + "name", + "projects", + "target" ], "properties": { "id": { @@ -1424,6 +1445,9 @@ }, "DevcontainerConfig": { "type": "object", + "required": [ + "filePath" + ], "properties": { "filePath": { "type": "string" @@ -1432,6 +1456,11 @@ }, "FRPSConfig": { "type": "object", + "required": [ + "domain", + "port", + "protocol" + ], "properties": { "domain": { "type": "string" @@ -1446,6 +1475,12 @@ }, "FileStatus": { "type": "object", + "required": [ + "extra", + "name", + "staging", + "worktree" + ], "properties": { "extra": { "type": "string" @@ -1463,6 +1498,10 @@ }, "GitBranch": { "type": "object", + "required": [ + "name", + "sha" + ], "properties": { "name": { "type": "string" @@ -1474,6 +1513,10 @@ }, "GitNamespace": { "type": "object", + "required": [ + "id", + "name" + ], "properties": { "id": { "type": "string" @@ -1485,6 +1528,11 @@ }, "GitProvider": { "type": "object", + "required": [ + "id", + "token", + "username" + ], "properties": { "baseApiUrl": { "type": "string" @@ -1502,6 +1550,15 @@ }, "GitPullRequest": { "type": "object", + "required": [ + "branch", + "name", + "sha", + "sourceRepoId", + "sourceRepoName", + "sourceRepoOwner", + "sourceRepoUrl" + ], "properties": { "branch": { "type": "string" @@ -1528,6 +1585,14 @@ }, "GitRepository": { "type": "object", + "required": [ + "id", + "name", + "owner", + "sha", + "source", + "url" + ], "properties": { "branch": { "type": "string" @@ -1560,6 +1625,10 @@ }, "GitStatus": { "type": "object", + "required": [ + "currentBranch", + "fileStatus" + ], "properties": { "currentBranch": { "type": "string" @@ -1574,6 +1643,12 @@ }, "GitUser": { "type": "object", + "required": [ + "email", + "id", + "name", + "username" + ], "properties": { "email": { "type": "string" @@ -1591,6 +1666,10 @@ }, "InstallProviderRequest": { "type": "object", + "required": [ + "downloadUrls", + "name" + ], "properties": { "downloadUrls": { "type": "object", @@ -1605,6 +1684,9 @@ }, "NetworkKey": { "type": "object", + "required": [ + "key" + ], "properties": { "key": { "type": "string" @@ -1613,6 +1695,9 @@ }, "ProfileData": { "type": "object", + "required": [ + "envVars" + ], "properties": { "envVars": { "type": "object", @@ -1624,6 +1709,16 @@ }, "Project": { "type": "object", + "required": [ + "default", + "envVars", + "image", + "name", + "repository", + "target", + "user", + "workspaceId" + ], "properties": { "buildConfig": { "$ref": "#/definitions/ProjectBuildConfig" @@ -1670,6 +1765,14 @@ }, "ProjectConfig": { "type": "object", + "required": [ + "default", + "envVars", + "image", + "name", + "repository", + "user" + ], "properties": { "buildConfig": { "$ref": "#/definitions/ProjectBuildConfig" @@ -1699,6 +1802,12 @@ }, "ProjectInfo": { "type": "object", + "required": [ + "created", + "isRunning", + "name", + "workspaceId" + ], "properties": { "created": { "type": "string" @@ -1719,6 +1828,11 @@ }, "ProjectState": { "type": "object", + "required": [ + "gitStatus", + "updatedAt", + "uptime" + ], "properties": { "gitStatus": { "$ref": "#/definitions/GitStatus" @@ -1733,6 +1847,10 @@ }, "Provider": { "type": "object", + "required": [ + "name", + "version" + ], "properties": { "name": { "type": "string" @@ -1744,6 +1862,11 @@ }, "ProviderTarget": { "type": "object", + "required": [ + "name", + "options", + "providerInfo" + ], "properties": { "name": { "type": "string" @@ -1765,6 +1888,9 @@ }, "RepositoryUrl": { "type": "object", + "required": [ + "url" + ], "properties": { "url": { "type": "string" @@ -1773,6 +1899,22 @@ }, "ServerConfig": { "type": "object", + "required": [ + "apiPort", + "binariesPath", + "builderImage", + "builderRegistryServer", + "defaultProjectImage", + "defaultProjectUser", + "headscalePort", + "id", + "localBuilderRegistryImage", + "localBuilderRegistryPort", + "logFilePath", + "providersDir", + "registryUrl", + "serverDownloadUrl" + ], "properties": { "apiPort": { "type": "integer" @@ -1824,8 +1966,32 @@ } } }, + "SetGitProviderConfig": { + "type": "object", + "required": [ + "id", + "token" + ], + "properties": { + "baseApiUrl": { + "type": "string" + }, + "id": { + "type": "string" + }, + "token": { + "type": "string" + }, + "username": { + "type": "string" + } + } + }, "SetProjectState": { "type": "object", + "required": [ + "uptime" + ], "properties": { "gitStatus": { "$ref": "#/definitions/GitStatus" @@ -1860,6 +2026,12 @@ }, "Workspace": { "type": "object", + "required": [ + "id", + "name", + "projects", + "target" + ], "properties": { "id": { "type": "string" @@ -1880,6 +2052,12 @@ }, "WorkspaceDTO": { "type": "object", + "required": [ + "id", + "name", + "projects", + "target" + ], "properties": { "id": { "type": "string" @@ -1903,6 +2081,10 @@ }, "WorkspaceInfo": { "type": "object", + "required": [ + "name", + "projects" + ], "properties": { "name": { "type": "string" @@ -1933,6 +2115,10 @@ }, "provider.ProviderInfo": { "type": "object", + "required": [ + "name", + "version" + ], "properties": { "name": { "type": "string" diff --git a/pkg/api/docs/swagger.yaml b/pkg/api/docs/swagger.yaml index 0f031d704d..de4d6c3c8e 100644 --- a/pkg/api/docs/swagger.yaml +++ b/pkg/api/docs/swagger.yaml @@ -9,6 +9,10 @@ definitions: type: string type: $ref: '#/definitions/apikey.ApiKeyType' + required: + - keyHash + - name + - type type: object ContainerRegistry: properties: @@ -18,6 +22,10 @@ definitions: type: string username: type: string + required: + - password + - server + - username type: object CreateProjectConfigDTO: properties: @@ -35,11 +43,17 @@ definitions: $ref: '#/definitions/CreateProjectConfigSourceDTO' user: type: string + required: + - envVars + - name + - source type: object CreateProjectConfigSourceDTO: properties: repository: $ref: '#/definitions/GitRepository' + required: + - repository type: object CreateWorkspaceDTO: properties: @@ -54,12 +68,17 @@ definitions: target: type: string required: + - id + - name - projects + - target type: object DevcontainerConfig: properties: filePath: type: string + required: + - filePath type: object FRPSConfig: properties: @@ -69,6 +88,10 @@ definitions: type: integer protocol: type: string + required: + - domain + - port + - protocol type: object FileStatus: properties: @@ -80,6 +103,11 @@ definitions: $ref: '#/definitions/Status' worktree: $ref: '#/definitions/Status' + required: + - extra + - name + - staging + - worktree type: object GitBranch: properties: @@ -87,6 +115,9 @@ definitions: type: string sha: type: string + required: + - name + - sha type: object GitNamespace: properties: @@ -94,6 +125,9 @@ definitions: type: string name: type: string + required: + - id + - name type: object GitProvider: properties: @@ -105,6 +139,10 @@ definitions: type: string username: type: string + required: + - id + - token + - username type: object GitPullRequest: properties: @@ -122,6 +160,14 @@ definitions: type: string sourceRepoUrl: type: string + required: + - branch + - name + - sha + - sourceRepoId + - sourceRepoName + - sourceRepoOwner + - sourceRepoUrl type: object GitRepository: properties: @@ -143,6 +189,13 @@ definitions: type: string url: type: string + required: + - id + - name + - owner + - sha + - source + - url type: object GitStatus: properties: @@ -152,6 +205,9 @@ definitions: items: $ref: '#/definitions/FileStatus' type: array + required: + - currentBranch + - fileStatus type: object GitUser: properties: @@ -163,6 +219,11 @@ definitions: type: string username: type: string + required: + - email + - id + - name + - username type: object InstallProviderRequest: properties: @@ -172,11 +233,16 @@ definitions: type: object name: type: string + required: + - downloadUrls + - name type: object NetworkKey: properties: key: type: string + required: + - key type: object ProfileData: properties: @@ -184,6 +250,8 @@ definitions: additionalProperties: type: string type: object + required: + - envVars type: object Project: properties: @@ -209,6 +277,15 @@ definitions: type: string workspaceId: type: string + required: + - default + - envVars + - image + - name + - repository + - target + - user + - workspaceId type: object ProjectBuildConfig: properties: @@ -233,6 +310,13 @@ definitions: $ref: '#/definitions/GitRepository' user: type: string + required: + - default + - envVars + - image + - name + - repository + - user type: object ProjectInfo: properties: @@ -246,6 +330,11 @@ definitions: type: string workspaceId: type: string + required: + - created + - isRunning + - name + - workspaceId type: object ProjectState: properties: @@ -255,6 +344,10 @@ definitions: type: string uptime: type: integer + required: + - gitStatus + - updatedAt + - uptime type: object Provider: properties: @@ -262,6 +355,9 @@ definitions: type: string version: type: string + required: + - name + - version type: object ProviderTarget: properties: @@ -272,6 +368,10 @@ definitions: type: string providerInfo: $ref: '#/definitions/provider.ProviderInfo' + required: + - name + - options + - providerInfo type: object ProviderTargetManifest: additionalProperties: @@ -281,6 +381,8 @@ definitions: properties: url: type: string + required: + - url type: object ServerConfig: properties: @@ -316,6 +418,35 @@ definitions: type: string serverDownloadUrl: type: string + required: + - apiPort + - binariesPath + - builderImage + - builderRegistryServer + - defaultProjectImage + - defaultProjectUser + - headscalePort + - id + - localBuilderRegistryImage + - localBuilderRegistryPort + - logFilePath + - providersDir + - registryUrl + - serverDownloadUrl + type: object + SetGitProviderConfig: + properties: + baseApiUrl: + type: string + id: + type: string + token: + type: string + username: + type: string + required: + - id + - token type: object SetProjectState: properties: @@ -323,6 +454,8 @@ definitions: $ref: '#/definitions/GitStatus' uptime: type: integer + required: + - uptime type: object Status: enum: @@ -356,6 +489,11 @@ definitions: type: array target: type: string + required: + - id + - name + - projects + - target type: object WorkspaceDTO: properties: @@ -371,6 +509,11 @@ definitions: type: array target: type: string + required: + - id + - name + - projects + - target type: object WorkspaceInfo: properties: @@ -382,6 +525,9 @@ definitions: type: array providerMetadata: type: string + required: + - name + - projects type: object apikey.ApiKeyType: enum: @@ -399,6 +545,9 @@ definitions: type: string version: type: string + required: + - name + - version type: object provider.ProviderTargetProperty: properties: @@ -597,7 +746,7 @@ paths: name: gitProviderConfig required: true schema: - $ref: '#/definitions/GitProvider' + $ref: '#/definitions/SetGitProviderConfig' produces: - application/json responses: diff --git a/pkg/api/validator.go b/pkg/api/validator.go index a7c1493bcd..58b2b68c9d 100644 --- a/pkg/api/validator.go +++ b/pkg/api/validator.go @@ -5,6 +5,8 @@ package api import ( "reflect" + "strconv" + "strings" "sync" "github.com/gin-gonic/gin/binding" @@ -18,16 +20,54 @@ type defaultValidator struct { var _ binding.StructValidator = &defaultValidator{} -func (v *defaultValidator) ValidateStruct(obj interface{}) error { - if kindOfData(obj) == reflect.Struct { - v.lazyinit() +type SliceValidationError []error - if err := v.validate.Struct(obj); err != nil { - return err +func (err SliceValidationError) Error() string { + if len(err) == 0 { + return "" + } + + var b strings.Builder + for i := 0; i < len(err); i++ { + if err[i] != nil { + if b.Len() > 0 { + b.WriteString("\n") + } + b.WriteString("[" + strconv.Itoa(i) + "]: " + err[i].Error()) } } + return b.String() +} + +func (v *defaultValidator) ValidateStruct(obj any) error { + if obj == nil { + return nil + } - return nil + value := reflect.ValueOf(obj) + switch value.Kind() { + case reflect.Ptr: + if value.Elem().Kind() != reflect.Struct { + return v.ValidateStruct(value.Elem().Interface()) + } + return v.validateStruct(obj) + case reflect.Struct: + return v.validateStruct(obj) + case reflect.Slice, reflect.Array: + count := value.Len() + validateRet := make(SliceValidationError, 0) + for i := 0; i < count; i++ { + if err := v.ValidateStruct(value.Index(i).Interface()); err != nil { + validateRet = append(validateRet, err) + } + } + if len(validateRet) == 0 { + return nil + } + return validateRet + default: + return nil + } } func (v *defaultValidator) Engine() interface{} { @@ -35,19 +75,17 @@ func (v *defaultValidator) Engine() interface{} { return v.validate } +func (v *defaultValidator) validateStruct(obj any) error { + v.lazyinit() + return v.validate.Struct(obj) +} + func (v *defaultValidator) lazyinit() { v.once.Do(func() { v.validate = validator.New(validator.WithRequiredStructEnabled()) + v.validate.SetTagName("validate") + _ = v.validate.RegisterValidation("optional", func(fl validator.FieldLevel) bool { + return true + }, true) }) } - -func kindOfData(data interface{}) reflect.Kind { - value := reflect.ValueOf(data) - valueType := value.Kind() - - if valueType == reflect.Ptr { - valueType = value.Elem().Kind() - } - - return valueType -} diff --git a/pkg/apiclient/README.md b/pkg/apiclient/README.md index 3daec14b3f..b74fc9fdec 100644 --- a/pkg/apiclient/README.md +++ b/pkg/apiclient/README.md @@ -159,6 +159,7 @@ Class | Method | HTTP request | Description - [ProviderTarget](docs/ProviderTarget.md) - [RepositoryUrl](docs/RepositoryUrl.md) - [ServerConfig](docs/ServerConfig.md) + - [SetGitProviderConfig](docs/SetGitProviderConfig.md) - [SetProjectState](docs/SetProjectState.md) - [Status](docs/Status.md) - [Workspace](docs/Workspace.md) diff --git a/pkg/apiclient/api/openapi.yaml b/pkg/apiclient/api/openapi.yaml index 29679e835a..61c035bb4d 100644 --- a/pkg/apiclient/api/openapi.yaml +++ b/pkg/apiclient/api/openapi.yaml @@ -165,7 +165,7 @@ paths: content: '*/*': schema: - $ref: '#/components/schemas/GitProvider' + $ref: '#/components/schemas/SetGitProviderConfig' description: Git provider required: true responses: @@ -967,6 +967,10 @@ components: type: string type: $ref: '#/components/schemas/apikey.ApiKeyType' + required: + - keyHash + - name + - type type: object ContainerRegistry: example: @@ -980,6 +984,10 @@ components: type: string username: type: string + required: + - password + - server + - username type: object CreateProjectConfigDTO: example: @@ -1017,6 +1025,10 @@ components: $ref: '#/components/schemas/CreateProjectConfigSourceDTO' user: type: string + required: + - envVars + - name + - source type: object CreateProjectConfigSourceDTO: example: @@ -1033,6 +1045,8 @@ components: properties: repository: $ref: '#/components/schemas/GitRepository' + required: + - repository type: object CreateWorkspaceDTO: example: @@ -1090,7 +1104,10 @@ components: target: type: string required: + - id + - name - projects + - target type: object DevcontainerConfig: example: @@ -1098,6 +1115,8 @@ components: properties: filePath: type: string + required: + - filePath type: object FRPSConfig: example: @@ -1111,6 +1130,10 @@ components: type: integer protocol: type: string + required: + - domain + - port + - protocol type: object FileStatus: example: @@ -1127,6 +1150,11 @@ components: $ref: '#/components/schemas/Status' worktree: $ref: '#/components/schemas/Status' + required: + - extra + - name + - staging + - worktree type: object GitBranch: example: @@ -1137,6 +1165,9 @@ components: type: string sha: type: string + required: + - name + - sha type: object GitNamespace: example: @@ -1147,6 +1178,9 @@ components: type: string name: type: string + required: + - id + - name type: object GitProvider: example: @@ -1163,6 +1197,10 @@ components: type: string username: type: string + required: + - id + - token + - username type: object GitPullRequest: example: @@ -1188,6 +1226,14 @@ components: type: string sourceRepoUrl: type: string + required: + - branch + - name + - sha + - sourceRepoId + - sourceRepoName + - sourceRepoOwner + - sourceRepoUrl type: object GitRepository: example: @@ -1219,6 +1265,13 @@ components: type: string url: type: string + required: + - id + - name + - owner + - sha + - source + - url type: object GitStatus: example: @@ -1239,6 +1292,9 @@ components: items: $ref: '#/components/schemas/FileStatus' type: array + required: + - currentBranch + - fileStatus type: object GitUser: example: @@ -1255,6 +1311,11 @@ components: type: string username: type: string + required: + - email + - id + - name + - username type: object InstallProviderRequest: example: @@ -1268,6 +1329,9 @@ components: type: object name: type: string + required: + - downloadUrls + - name type: object NetworkKey: example: @@ -1275,6 +1339,8 @@ components: properties: key: type: string + required: + - key type: object ProfileData: example: @@ -1285,6 +1351,8 @@ components: additionalProperties: type: string type: object + required: + - envVars type: object Project: example: @@ -1346,6 +1414,15 @@ components: type: string workspaceId: type: string + required: + - default + - envVars + - image + - name + - repository + - target + - user + - workspaceId type: object ProjectBuildConfig: example: @@ -1393,6 +1470,13 @@ components: $ref: '#/components/schemas/GitRepository' user: type: string + required: + - default + - envVars + - image + - name + - repository + - user type: object ProjectInfo: example: @@ -1412,6 +1496,11 @@ components: type: string workspaceId: type: string + required: + - created + - isRunning + - name + - workspaceId type: object ProjectState: example: @@ -1435,6 +1524,10 @@ components: type: string uptime: type: integer + required: + - gitStatus + - updatedAt + - uptime type: object Provider: example: @@ -1445,6 +1538,9 @@ components: type: string version: type: string + required: + - name + - version type: object ProviderTarget: example: @@ -1461,6 +1557,10 @@ components: type: string providerInfo: $ref: '#/components/schemas/provider.ProviderInfo' + required: + - name + - options + - providerInfo type: object ProviderTargetManifest: additionalProperties: @@ -1472,6 +1572,8 @@ components: properties: url: type: string + required: + - url type: object ServerConfig: example: @@ -1527,6 +1629,40 @@ components: type: string serverDownloadUrl: type: string + required: + - apiPort + - binariesPath + - builderImage + - builderRegistryServer + - defaultProjectImage + - defaultProjectUser + - headscalePort + - id + - localBuilderRegistryImage + - localBuilderRegistryPort + - logFilePath + - providersDir + - registryUrl + - serverDownloadUrl + type: object + SetGitProviderConfig: + example: + baseApiUrl: baseApiUrl + id: id + token: token + username: username + properties: + baseApiUrl: + type: string + id: + type: string + token: + type: string + username: + type: string + required: + - id + - token type: object SetProjectState: example: @@ -1547,6 +1683,8 @@ components: $ref: '#/components/schemas/GitStatus' uptime: type: integer + required: + - uptime type: object Status: enum: @@ -1655,6 +1793,11 @@ components: type: array target: type: string + required: + - id + - name + - projects + - target type: object WorkspaceDTO: example: @@ -1759,6 +1902,11 @@ components: type: array target: type: string + required: + - id + - name + - projects + - target type: object WorkspaceInfo: example: @@ -1784,6 +1932,9 @@ components: type: array providerMetadata: type: string + required: + - name + - projects type: object apikey.ApiKeyType: enum: @@ -1804,6 +1955,9 @@ components: type: string version: type: string + required: + - name + - version type: object provider.ProviderTargetProperty: properties: diff --git a/pkg/apiclient/api_git_provider.go b/pkg/apiclient/api_git_provider.go index 7724b2212d..e8aabe8f89 100644 --- a/pkg/apiclient/api_git_provider.go +++ b/pkg/apiclient/api_git_provider.go @@ -1335,11 +1335,11 @@ func (a *GitProviderAPIService) RemoveGitProviderExecute(r ApiRemoveGitProviderR type ApiSetGitProviderRequest struct { ctx context.Context ApiService *GitProviderAPIService - gitProviderConfig *GitProvider + gitProviderConfig *SetGitProviderConfig } // Git provider -func (r ApiSetGitProviderRequest) GitProviderConfig(gitProviderConfig GitProvider) ApiSetGitProviderRequest { +func (r ApiSetGitProviderRequest) GitProviderConfig(gitProviderConfig SetGitProviderConfig) ApiSetGitProviderRequest { r.gitProviderConfig = &gitProviderConfig return r } diff --git a/pkg/apiclient/docs/ApiKey.md b/pkg/apiclient/docs/ApiKey.md index c6e78fbcc5..46fbd9b5dd 100644 --- a/pkg/apiclient/docs/ApiKey.md +++ b/pkg/apiclient/docs/ApiKey.md @@ -4,15 +4,15 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**KeyHash** | Pointer to **string** | | [optional] -**Name** | Pointer to **string** | Project or client name | [optional] -**Type** | Pointer to [**ApikeyApiKeyType**](ApikeyApiKeyType.md) | | [optional] +**KeyHash** | **string** | | +**Name** | **string** | Project or client name | +**Type** | [**ApikeyApiKeyType**](ApikeyApiKeyType.md) | | ## Methods ### NewApiKey -`func NewApiKey() *ApiKey` +`func NewApiKey(keyHash string, name string, type_ ApikeyApiKeyType, ) *ApiKey` NewApiKey instantiates a new ApiKey object This constructor will assign default values to properties that have it defined, @@ -46,11 +46,6 @@ and a boolean to check if the value has been set. SetKeyHash sets KeyHash field to given value. -### HasKeyHash - -`func (o *ApiKey) HasKeyHash() bool` - -HasKeyHash returns a boolean if a field has been set. ### GetName @@ -71,11 +66,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *ApiKey) HasName() bool` - -HasName returns a boolean if a field has been set. ### GetType @@ -96,11 +86,6 @@ and a boolean to check if the value has been set. SetType sets Type field to given value. -### HasType - -`func (o *ApiKey) HasType() bool` - -HasType returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/ContainerRegistry.md b/pkg/apiclient/docs/ContainerRegistry.md index b27e5a202b..01a8520448 100644 --- a/pkg/apiclient/docs/ContainerRegistry.md +++ b/pkg/apiclient/docs/ContainerRegistry.md @@ -4,15 +4,15 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Password** | Pointer to **string** | | [optional] -**Server** | Pointer to **string** | | [optional] -**Username** | Pointer to **string** | | [optional] +**Password** | **string** | | +**Server** | **string** | | +**Username** | **string** | | ## Methods ### NewContainerRegistry -`func NewContainerRegistry() *ContainerRegistry` +`func NewContainerRegistry(password string, server string, username string, ) *ContainerRegistry` NewContainerRegistry instantiates a new ContainerRegistry object This constructor will assign default values to properties that have it defined, @@ -46,11 +46,6 @@ and a boolean to check if the value has been set. SetPassword sets Password field to given value. -### HasPassword - -`func (o *ContainerRegistry) HasPassword() bool` - -HasPassword returns a boolean if a field has been set. ### GetServer @@ -71,11 +66,6 @@ and a boolean to check if the value has been set. SetServer sets Server field to given value. -### HasServer - -`func (o *ContainerRegistry) HasServer() bool` - -HasServer returns a boolean if a field has been set. ### GetUsername @@ -96,11 +86,6 @@ and a boolean to check if the value has been set. SetUsername sets Username field to given value. -### HasUsername - -`func (o *ContainerRegistry) HasUsername() bool` - -HasUsername returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/ContainerRegistryAPI.md b/pkg/apiclient/docs/ContainerRegistryAPI.md index 7653c75bb6..fe3c0dcbd1 100644 --- a/pkg/apiclient/docs/ContainerRegistryAPI.md +++ b/pkg/apiclient/docs/ContainerRegistryAPI.md @@ -232,7 +232,7 @@ import ( func main() { server := "server_example" // string | Container Registry server name - containerRegistry := *openapiclient.NewContainerRegistry() // ContainerRegistry | Container Registry credentials to set + containerRegistry := *openapiclient.NewContainerRegistry("Password_example", "Server_example", "Username_example") // ContainerRegistry | Container Registry credentials to set configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) diff --git a/pkg/apiclient/docs/CreateProjectConfigDTO.md b/pkg/apiclient/docs/CreateProjectConfigDTO.md index d9ee0604ec..99ffd0118c 100644 --- a/pkg/apiclient/docs/CreateProjectConfigDTO.md +++ b/pkg/apiclient/docs/CreateProjectConfigDTO.md @@ -5,17 +5,17 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **BuildConfig** | Pointer to [**ProjectBuildConfig**](ProjectBuildConfig.md) | | [optional] -**EnvVars** | Pointer to **map[string]string** | | [optional] +**EnvVars** | **map[string]string** | | **Image** | Pointer to **string** | | [optional] -**Name** | Pointer to **string** | | [optional] -**Source** | Pointer to [**CreateProjectConfigSourceDTO**](CreateProjectConfigSourceDTO.md) | | [optional] +**Name** | **string** | | +**Source** | [**CreateProjectConfigSourceDTO**](CreateProjectConfigSourceDTO.md) | | **User** | Pointer to **string** | | [optional] ## Methods ### NewCreateProjectConfigDTO -`func NewCreateProjectConfigDTO() *CreateProjectConfigDTO` +`func NewCreateProjectConfigDTO(envVars map[string]string, name string, source CreateProjectConfigSourceDTO, ) *CreateProjectConfigDTO` NewCreateProjectConfigDTO instantiates a new CreateProjectConfigDTO object This constructor will assign default values to properties that have it defined, @@ -74,11 +74,6 @@ and a boolean to check if the value has been set. SetEnvVars sets EnvVars field to given value. -### HasEnvVars - -`func (o *CreateProjectConfigDTO) HasEnvVars() bool` - -HasEnvVars returns a boolean if a field has been set. ### GetImage @@ -124,11 +119,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *CreateProjectConfigDTO) HasName() bool` - -HasName returns a boolean if a field has been set. ### GetSource @@ -149,11 +139,6 @@ and a boolean to check if the value has been set. SetSource sets Source field to given value. -### HasSource - -`func (o *CreateProjectConfigDTO) HasSource() bool` - -HasSource returns a boolean if a field has been set. ### GetUser diff --git a/pkg/apiclient/docs/CreateProjectConfigSourceDTO.md b/pkg/apiclient/docs/CreateProjectConfigSourceDTO.md index ac1691fef1..5f926439fd 100644 --- a/pkg/apiclient/docs/CreateProjectConfigSourceDTO.md +++ b/pkg/apiclient/docs/CreateProjectConfigSourceDTO.md @@ -4,13 +4,13 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Repository** | Pointer to [**GitRepository**](GitRepository.md) | | [optional] +**Repository** | [**GitRepository**](GitRepository.md) | | ## Methods ### NewCreateProjectConfigSourceDTO -`func NewCreateProjectConfigSourceDTO() *CreateProjectConfigSourceDTO` +`func NewCreateProjectConfigSourceDTO(repository GitRepository, ) *CreateProjectConfigSourceDTO` NewCreateProjectConfigSourceDTO instantiates a new CreateProjectConfigSourceDTO object This constructor will assign default values to properties that have it defined, @@ -44,11 +44,6 @@ and a boolean to check if the value has been set. SetRepository sets Repository field to given value. -### HasRepository - -`func (o *CreateProjectConfigSourceDTO) HasRepository() bool` - -HasRepository returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/CreateWorkspaceDTO.md b/pkg/apiclient/docs/CreateWorkspaceDTO.md index 12c2c215a5..1dff4deecc 100644 --- a/pkg/apiclient/docs/CreateWorkspaceDTO.md +++ b/pkg/apiclient/docs/CreateWorkspaceDTO.md @@ -4,16 +4,16 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Id** | Pointer to **string** | | [optional] -**Name** | Pointer to **string** | | [optional] +**Id** | **string** | | +**Name** | **string** | | **Projects** | [**[]CreateProjectConfigDTO**](CreateProjectConfigDTO.md) | | -**Target** | Pointer to **string** | | [optional] +**Target** | **string** | | ## Methods ### NewCreateWorkspaceDTO -`func NewCreateWorkspaceDTO(projects []CreateProjectConfigDTO, ) *CreateWorkspaceDTO` +`func NewCreateWorkspaceDTO(id string, name string, projects []CreateProjectConfigDTO, target string, ) *CreateWorkspaceDTO` NewCreateWorkspaceDTO instantiates a new CreateWorkspaceDTO object This constructor will assign default values to properties that have it defined, @@ -47,11 +47,6 @@ and a boolean to check if the value has been set. SetId sets Id field to given value. -### HasId - -`func (o *CreateWorkspaceDTO) HasId() bool` - -HasId returns a boolean if a field has been set. ### GetName @@ -72,11 +67,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *CreateWorkspaceDTO) HasName() bool` - -HasName returns a boolean if a field has been set. ### GetProjects @@ -117,11 +107,6 @@ and a boolean to check if the value has been set. SetTarget sets Target field to given value. -### HasTarget - -`func (o *CreateWorkspaceDTO) HasTarget() bool` - -HasTarget returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/DevcontainerConfig.md b/pkg/apiclient/docs/DevcontainerConfig.md index 0d7976a87c..0afcfff96f 100644 --- a/pkg/apiclient/docs/DevcontainerConfig.md +++ b/pkg/apiclient/docs/DevcontainerConfig.md @@ -4,13 +4,13 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**FilePath** | Pointer to **string** | | [optional] +**FilePath** | **string** | | ## Methods ### NewDevcontainerConfig -`func NewDevcontainerConfig() *DevcontainerConfig` +`func NewDevcontainerConfig(filePath string, ) *DevcontainerConfig` NewDevcontainerConfig instantiates a new DevcontainerConfig object This constructor will assign default values to properties that have it defined, @@ -44,11 +44,6 @@ and a boolean to check if the value has been set. SetFilePath sets FilePath field to given value. -### HasFilePath - -`func (o *DevcontainerConfig) HasFilePath() bool` - -HasFilePath returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/FRPSConfig.md b/pkg/apiclient/docs/FRPSConfig.md index 9092449617..575230e882 100644 --- a/pkg/apiclient/docs/FRPSConfig.md +++ b/pkg/apiclient/docs/FRPSConfig.md @@ -4,15 +4,15 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Domain** | Pointer to **string** | | [optional] -**Port** | Pointer to **int32** | | [optional] -**Protocol** | Pointer to **string** | | [optional] +**Domain** | **string** | | +**Port** | **int32** | | +**Protocol** | **string** | | ## Methods ### NewFRPSConfig -`func NewFRPSConfig() *FRPSConfig` +`func NewFRPSConfig(domain string, port int32, protocol string, ) *FRPSConfig` NewFRPSConfig instantiates a new FRPSConfig object This constructor will assign default values to properties that have it defined, @@ -46,11 +46,6 @@ and a boolean to check if the value has been set. SetDomain sets Domain field to given value. -### HasDomain - -`func (o *FRPSConfig) HasDomain() bool` - -HasDomain returns a boolean if a field has been set. ### GetPort @@ -71,11 +66,6 @@ and a boolean to check if the value has been set. SetPort sets Port field to given value. -### HasPort - -`func (o *FRPSConfig) HasPort() bool` - -HasPort returns a boolean if a field has been set. ### GetProtocol @@ -96,11 +86,6 @@ and a boolean to check if the value has been set. SetProtocol sets Protocol field to given value. -### HasProtocol - -`func (o *FRPSConfig) HasProtocol() bool` - -HasProtocol returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/FileStatus.md b/pkg/apiclient/docs/FileStatus.md index f14100eeb9..e680d67662 100644 --- a/pkg/apiclient/docs/FileStatus.md +++ b/pkg/apiclient/docs/FileStatus.md @@ -4,16 +4,16 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Extra** | Pointer to **string** | | [optional] -**Name** | Pointer to **string** | | [optional] -**Staging** | Pointer to [**Status**](Status.md) | | [optional] -**Worktree** | Pointer to [**Status**](Status.md) | | [optional] +**Extra** | **string** | | +**Name** | **string** | | +**Staging** | [**Status**](Status.md) | | +**Worktree** | [**Status**](Status.md) | | ## Methods ### NewFileStatus -`func NewFileStatus() *FileStatus` +`func NewFileStatus(extra string, name string, staging Status, worktree Status, ) *FileStatus` NewFileStatus instantiates a new FileStatus object This constructor will assign default values to properties that have it defined, @@ -47,11 +47,6 @@ and a boolean to check if the value has been set. SetExtra sets Extra field to given value. -### HasExtra - -`func (o *FileStatus) HasExtra() bool` - -HasExtra returns a boolean if a field has been set. ### GetName @@ -72,11 +67,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *FileStatus) HasName() bool` - -HasName returns a boolean if a field has been set. ### GetStaging @@ -97,11 +87,6 @@ and a boolean to check if the value has been set. SetStaging sets Staging field to given value. -### HasStaging - -`func (o *FileStatus) HasStaging() bool` - -HasStaging returns a boolean if a field has been set. ### GetWorktree @@ -122,11 +107,6 @@ and a boolean to check if the value has been set. SetWorktree sets Worktree field to given value. -### HasWorktree - -`func (o *FileStatus) HasWorktree() bool` - -HasWorktree returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/GitBranch.md b/pkg/apiclient/docs/GitBranch.md index d24cb07230..23a185e095 100644 --- a/pkg/apiclient/docs/GitBranch.md +++ b/pkg/apiclient/docs/GitBranch.md @@ -4,14 +4,14 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Name** | Pointer to **string** | | [optional] -**Sha** | Pointer to **string** | | [optional] +**Name** | **string** | | +**Sha** | **string** | | ## Methods ### NewGitBranch -`func NewGitBranch() *GitBranch` +`func NewGitBranch(name string, sha string, ) *GitBranch` NewGitBranch instantiates a new GitBranch object This constructor will assign default values to properties that have it defined, @@ -45,11 +45,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *GitBranch) HasName() bool` - -HasName returns a boolean if a field has been set. ### GetSha @@ -70,11 +65,6 @@ and a boolean to check if the value has been set. SetSha sets Sha field to given value. -### HasSha - -`func (o *GitBranch) HasSha() bool` - -HasSha returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/GitNamespace.md b/pkg/apiclient/docs/GitNamespace.md index cbd5abfed5..e46e28d46a 100644 --- a/pkg/apiclient/docs/GitNamespace.md +++ b/pkg/apiclient/docs/GitNamespace.md @@ -4,14 +4,14 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Id** | Pointer to **string** | | [optional] -**Name** | Pointer to **string** | | [optional] +**Id** | **string** | | +**Name** | **string** | | ## Methods ### NewGitNamespace -`func NewGitNamespace() *GitNamespace` +`func NewGitNamespace(id string, name string, ) *GitNamespace` NewGitNamespace instantiates a new GitNamespace object This constructor will assign default values to properties that have it defined, @@ -45,11 +45,6 @@ and a boolean to check if the value has been set. SetId sets Id field to given value. -### HasId - -`func (o *GitNamespace) HasId() bool` - -HasId returns a boolean if a field has been set. ### GetName @@ -70,11 +65,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *GitNamespace) HasName() bool` - -HasName returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/GitProvider.md b/pkg/apiclient/docs/GitProvider.md index 3ac31cc169..74e57a986e 100644 --- a/pkg/apiclient/docs/GitProvider.md +++ b/pkg/apiclient/docs/GitProvider.md @@ -5,15 +5,15 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **BaseApiUrl** | Pointer to **string** | | [optional] -**Id** | Pointer to **string** | | [optional] -**Token** | Pointer to **string** | | [optional] -**Username** | Pointer to **string** | | [optional] +**Id** | **string** | | +**Token** | **string** | | +**Username** | **string** | | ## Methods ### NewGitProvider -`func NewGitProvider() *GitProvider` +`func NewGitProvider(id string, token string, username string, ) *GitProvider` NewGitProvider instantiates a new GitProvider object This constructor will assign default values to properties that have it defined, @@ -72,11 +72,6 @@ and a boolean to check if the value has been set. SetId sets Id field to given value. -### HasId - -`func (o *GitProvider) HasId() bool` - -HasId returns a boolean if a field has been set. ### GetToken @@ -97,11 +92,6 @@ and a boolean to check if the value has been set. SetToken sets Token field to given value. -### HasToken - -`func (o *GitProvider) HasToken() bool` - -HasToken returns a boolean if a field has been set. ### GetUsername @@ -122,11 +112,6 @@ and a boolean to check if the value has been set. SetUsername sets Username field to given value. -### HasUsername - -`func (o *GitProvider) HasUsername() bool` - -HasUsername returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/GitProviderAPI.md b/pkg/apiclient/docs/GitProviderAPI.md index c871cfc66a..bd5ee2f539 100644 --- a/pkg/apiclient/docs/GitProviderAPI.md +++ b/pkg/apiclient/docs/GitProviderAPI.md @@ -615,7 +615,7 @@ import ( ) func main() { - repository := *openapiclient.NewGitRepository() // GitRepository | Git repository + repository := *openapiclient.NewGitRepository("Id_example", "Name_example", "Owner_example", "Sha_example", "Source_example", "Url_example") // GitRepository | Git repository configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) @@ -810,7 +810,7 @@ import ( ) func main() { - gitProviderConfig := *openapiclient.NewGitProvider() // GitProvider | Git provider + gitProviderConfig := *openapiclient.NewSetGitProviderConfig("Id_example", "Token_example") // SetGitProviderConfig | Git provider configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) @@ -833,7 +833,7 @@ Other parameters are passed through a pointer to a apiSetGitProviderRequest stru Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- - **gitProviderConfig** | [**GitProvider**](GitProvider.md) | Git provider | + **gitProviderConfig** | [**SetGitProviderConfig**](SetGitProviderConfig.md) | Git provider | ### Return type diff --git a/pkg/apiclient/docs/GitPullRequest.md b/pkg/apiclient/docs/GitPullRequest.md index 3d296246ae..a5dd5b2fbc 100644 --- a/pkg/apiclient/docs/GitPullRequest.md +++ b/pkg/apiclient/docs/GitPullRequest.md @@ -4,19 +4,19 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Branch** | Pointer to **string** | | [optional] -**Name** | Pointer to **string** | | [optional] -**Sha** | Pointer to **string** | | [optional] -**SourceRepoId** | Pointer to **string** | | [optional] -**SourceRepoName** | Pointer to **string** | | [optional] -**SourceRepoOwner** | Pointer to **string** | | [optional] -**SourceRepoUrl** | Pointer to **string** | | [optional] +**Branch** | **string** | | +**Name** | **string** | | +**Sha** | **string** | | +**SourceRepoId** | **string** | | +**SourceRepoName** | **string** | | +**SourceRepoOwner** | **string** | | +**SourceRepoUrl** | **string** | | ## Methods ### NewGitPullRequest -`func NewGitPullRequest() *GitPullRequest` +`func NewGitPullRequest(branch string, name string, sha string, sourceRepoId string, sourceRepoName string, sourceRepoOwner string, sourceRepoUrl string, ) *GitPullRequest` NewGitPullRequest instantiates a new GitPullRequest object This constructor will assign default values to properties that have it defined, @@ -50,11 +50,6 @@ and a boolean to check if the value has been set. SetBranch sets Branch field to given value. -### HasBranch - -`func (o *GitPullRequest) HasBranch() bool` - -HasBranch returns a boolean if a field has been set. ### GetName @@ -75,11 +70,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *GitPullRequest) HasName() bool` - -HasName returns a boolean if a field has been set. ### GetSha @@ -100,11 +90,6 @@ and a boolean to check if the value has been set. SetSha sets Sha field to given value. -### HasSha - -`func (o *GitPullRequest) HasSha() bool` - -HasSha returns a boolean if a field has been set. ### GetSourceRepoId @@ -125,11 +110,6 @@ and a boolean to check if the value has been set. SetSourceRepoId sets SourceRepoId field to given value. -### HasSourceRepoId - -`func (o *GitPullRequest) HasSourceRepoId() bool` - -HasSourceRepoId returns a boolean if a field has been set. ### GetSourceRepoName @@ -150,11 +130,6 @@ and a boolean to check if the value has been set. SetSourceRepoName sets SourceRepoName field to given value. -### HasSourceRepoName - -`func (o *GitPullRequest) HasSourceRepoName() bool` - -HasSourceRepoName returns a boolean if a field has been set. ### GetSourceRepoOwner @@ -175,11 +150,6 @@ and a boolean to check if the value has been set. SetSourceRepoOwner sets SourceRepoOwner field to given value. -### HasSourceRepoOwner - -`func (o *GitPullRequest) HasSourceRepoOwner() bool` - -HasSourceRepoOwner returns a boolean if a field has been set. ### GetSourceRepoUrl @@ -200,11 +170,6 @@ and a boolean to check if the value has been set. SetSourceRepoUrl sets SourceRepoUrl field to given value. -### HasSourceRepoUrl - -`func (o *GitPullRequest) HasSourceRepoUrl() bool` - -HasSourceRepoUrl returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/GitRepository.md b/pkg/apiclient/docs/GitRepository.md index 24ddde3d0b..293393d354 100644 --- a/pkg/apiclient/docs/GitRepository.md +++ b/pkg/apiclient/docs/GitRepository.md @@ -5,20 +5,20 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **Branch** | Pointer to **string** | | [optional] -**Id** | Pointer to **string** | | [optional] -**Name** | Pointer to **string** | | [optional] -**Owner** | Pointer to **string** | | [optional] +**Id** | **string** | | +**Name** | **string** | | +**Owner** | **string** | | **Path** | Pointer to **string** | | [optional] **PrNumber** | Pointer to **int32** | | [optional] -**Sha** | Pointer to **string** | | [optional] -**Source** | Pointer to **string** | | [optional] -**Url** | Pointer to **string** | | [optional] +**Sha** | **string** | | +**Source** | **string** | | +**Url** | **string** | | ## Methods ### NewGitRepository -`func NewGitRepository() *GitRepository` +`func NewGitRepository(id string, name string, owner string, sha string, source string, url string, ) *GitRepository` NewGitRepository instantiates a new GitRepository object This constructor will assign default values to properties that have it defined, @@ -77,11 +77,6 @@ and a boolean to check if the value has been set. SetId sets Id field to given value. -### HasId - -`func (o *GitRepository) HasId() bool` - -HasId returns a boolean if a field has been set. ### GetName @@ -102,11 +97,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *GitRepository) HasName() bool` - -HasName returns a boolean if a field has been set. ### GetOwner @@ -127,11 +117,6 @@ and a boolean to check if the value has been set. SetOwner sets Owner field to given value. -### HasOwner - -`func (o *GitRepository) HasOwner() bool` - -HasOwner returns a boolean if a field has been set. ### GetPath @@ -202,11 +187,6 @@ and a boolean to check if the value has been set. SetSha sets Sha field to given value. -### HasSha - -`func (o *GitRepository) HasSha() bool` - -HasSha returns a boolean if a field has been set. ### GetSource @@ -227,11 +207,6 @@ and a boolean to check if the value has been set. SetSource sets Source field to given value. -### HasSource - -`func (o *GitRepository) HasSource() bool` - -HasSource returns a boolean if a field has been set. ### GetUrl @@ -252,11 +227,6 @@ and a boolean to check if the value has been set. SetUrl sets Url field to given value. -### HasUrl - -`func (o *GitRepository) HasUrl() bool` - -HasUrl returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/GitStatus.md b/pkg/apiclient/docs/GitStatus.md index 26c55febd5..5379cbd6c5 100644 --- a/pkg/apiclient/docs/GitStatus.md +++ b/pkg/apiclient/docs/GitStatus.md @@ -4,14 +4,14 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**CurrentBranch** | Pointer to **string** | | [optional] -**FileStatus** | Pointer to [**[]FileStatus**](FileStatus.md) | | [optional] +**CurrentBranch** | **string** | | +**FileStatus** | [**[]FileStatus**](FileStatus.md) | | ## Methods ### NewGitStatus -`func NewGitStatus() *GitStatus` +`func NewGitStatus(currentBranch string, fileStatus []FileStatus, ) *GitStatus` NewGitStatus instantiates a new GitStatus object This constructor will assign default values to properties that have it defined, @@ -45,11 +45,6 @@ and a boolean to check if the value has been set. SetCurrentBranch sets CurrentBranch field to given value. -### HasCurrentBranch - -`func (o *GitStatus) HasCurrentBranch() bool` - -HasCurrentBranch returns a boolean if a field has been set. ### GetFileStatus @@ -70,11 +65,6 @@ and a boolean to check if the value has been set. SetFileStatus sets FileStatus field to given value. -### HasFileStatus - -`func (o *GitStatus) HasFileStatus() bool` - -HasFileStatus returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/GitUser.md b/pkg/apiclient/docs/GitUser.md index d1577eca94..cdf0bbd3f0 100644 --- a/pkg/apiclient/docs/GitUser.md +++ b/pkg/apiclient/docs/GitUser.md @@ -4,16 +4,16 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Email** | Pointer to **string** | | [optional] -**Id** | Pointer to **string** | | [optional] -**Name** | Pointer to **string** | | [optional] -**Username** | Pointer to **string** | | [optional] +**Email** | **string** | | +**Id** | **string** | | +**Name** | **string** | | +**Username** | **string** | | ## Methods ### NewGitUser -`func NewGitUser() *GitUser` +`func NewGitUser(email string, id string, name string, username string, ) *GitUser` NewGitUser instantiates a new GitUser object This constructor will assign default values to properties that have it defined, @@ -47,11 +47,6 @@ and a boolean to check if the value has been set. SetEmail sets Email field to given value. -### HasEmail - -`func (o *GitUser) HasEmail() bool` - -HasEmail returns a boolean if a field has been set. ### GetId @@ -72,11 +67,6 @@ and a boolean to check if the value has been set. SetId sets Id field to given value. -### HasId - -`func (o *GitUser) HasId() bool` - -HasId returns a boolean if a field has been set. ### GetName @@ -97,11 +87,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *GitUser) HasName() bool` - -HasName returns a boolean if a field has been set. ### GetUsername @@ -122,11 +107,6 @@ and a boolean to check if the value has been set. SetUsername sets Username field to given value. -### HasUsername - -`func (o *GitUser) HasUsername() bool` - -HasUsername returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/InstallProviderRequest.md b/pkg/apiclient/docs/InstallProviderRequest.md index 728e39fbb5..4e1677ed24 100644 --- a/pkg/apiclient/docs/InstallProviderRequest.md +++ b/pkg/apiclient/docs/InstallProviderRequest.md @@ -4,14 +4,14 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**DownloadUrls** | Pointer to **map[string]string** | | [optional] -**Name** | Pointer to **string** | | [optional] +**DownloadUrls** | **map[string]string** | | +**Name** | **string** | | ## Methods ### NewInstallProviderRequest -`func NewInstallProviderRequest() *InstallProviderRequest` +`func NewInstallProviderRequest(downloadUrls map[string]string, name string, ) *InstallProviderRequest` NewInstallProviderRequest instantiates a new InstallProviderRequest object This constructor will assign default values to properties that have it defined, @@ -45,11 +45,6 @@ and a boolean to check if the value has been set. SetDownloadUrls sets DownloadUrls field to given value. -### HasDownloadUrls - -`func (o *InstallProviderRequest) HasDownloadUrls() bool` - -HasDownloadUrls returns a boolean if a field has been set. ### GetName @@ -70,11 +65,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *InstallProviderRequest) HasName() bool` - -HasName returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/NetworkKey.md b/pkg/apiclient/docs/NetworkKey.md index 63e666eeca..7043106510 100644 --- a/pkg/apiclient/docs/NetworkKey.md +++ b/pkg/apiclient/docs/NetworkKey.md @@ -4,13 +4,13 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Key** | Pointer to **string** | | [optional] +**Key** | **string** | | ## Methods ### NewNetworkKey -`func NewNetworkKey() *NetworkKey` +`func NewNetworkKey(key string, ) *NetworkKey` NewNetworkKey instantiates a new NetworkKey object This constructor will assign default values to properties that have it defined, @@ -44,11 +44,6 @@ and a boolean to check if the value has been set. SetKey sets Key field to given value. -### HasKey - -`func (o *NetworkKey) HasKey() bool` - -HasKey returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/ProfileAPI.md b/pkg/apiclient/docs/ProfileAPI.md index db9b99fc85..45e45d2fad 100644 --- a/pkg/apiclient/docs/ProfileAPI.md +++ b/pkg/apiclient/docs/ProfileAPI.md @@ -151,7 +151,7 @@ import ( ) func main() { - profileData := *openapiclient.NewProfileData() // ProfileData | Profile data + profileData := *openapiclient.NewProfileData(map[string]string{"key": "Inner_example"}) // ProfileData | Profile data configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) diff --git a/pkg/apiclient/docs/ProfileData.md b/pkg/apiclient/docs/ProfileData.md index 5d6f20236e..eaa420b011 100644 --- a/pkg/apiclient/docs/ProfileData.md +++ b/pkg/apiclient/docs/ProfileData.md @@ -4,13 +4,13 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**EnvVars** | Pointer to **map[string]string** | | [optional] +**EnvVars** | **map[string]string** | | ## Methods ### NewProfileData -`func NewProfileData() *ProfileData` +`func NewProfileData(envVars map[string]string, ) *ProfileData` NewProfileData instantiates a new ProfileData object This constructor will assign default values to properties that have it defined, @@ -44,11 +44,6 @@ and a boolean to check if the value has been set. SetEnvVars sets EnvVars field to given value. -### HasEnvVars - -`func (o *ProfileData) HasEnvVars() bool` - -HasEnvVars returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/Project.md b/pkg/apiclient/docs/Project.md index 7131d72995..7e50e1fc8a 100644 --- a/pkg/apiclient/docs/Project.md +++ b/pkg/apiclient/docs/Project.md @@ -5,21 +5,21 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **BuildConfig** | Pointer to [**ProjectBuildConfig**](ProjectBuildConfig.md) | | [optional] -**Default** | Pointer to **bool** | | [optional] -**EnvVars** | Pointer to **map[string]string** | | [optional] -**Image** | Pointer to **string** | | [optional] -**Name** | Pointer to **string** | | [optional] -**Repository** | Pointer to [**GitRepository**](GitRepository.md) | | [optional] +**Default** | **bool** | | +**EnvVars** | **map[string]string** | | +**Image** | **string** | | +**Name** | **string** | | +**Repository** | [**GitRepository**](GitRepository.md) | | **State** | Pointer to [**ProjectState**](ProjectState.md) | | [optional] -**Target** | Pointer to **string** | | [optional] -**User** | Pointer to **string** | | [optional] -**WorkspaceId** | Pointer to **string** | | [optional] +**Target** | **string** | | +**User** | **string** | | +**WorkspaceId** | **string** | | ## Methods ### NewProject -`func NewProject() *Project` +`func NewProject(default_ bool, envVars map[string]string, image string, name string, repository GitRepository, target string, user string, workspaceId string, ) *Project` NewProject instantiates a new Project object This constructor will assign default values to properties that have it defined, @@ -78,11 +78,6 @@ and a boolean to check if the value has been set. SetDefault sets Default field to given value. -### HasDefault - -`func (o *Project) HasDefault() bool` - -HasDefault returns a boolean if a field has been set. ### GetEnvVars @@ -103,11 +98,6 @@ and a boolean to check if the value has been set. SetEnvVars sets EnvVars field to given value. -### HasEnvVars - -`func (o *Project) HasEnvVars() bool` - -HasEnvVars returns a boolean if a field has been set. ### GetImage @@ -128,11 +118,6 @@ and a boolean to check if the value has been set. SetImage sets Image field to given value. -### HasImage - -`func (o *Project) HasImage() bool` - -HasImage returns a boolean if a field has been set. ### GetName @@ -153,11 +138,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *Project) HasName() bool` - -HasName returns a boolean if a field has been set. ### GetRepository @@ -178,11 +158,6 @@ and a boolean to check if the value has been set. SetRepository sets Repository field to given value. -### HasRepository - -`func (o *Project) HasRepository() bool` - -HasRepository returns a boolean if a field has been set. ### GetState @@ -228,11 +203,6 @@ and a boolean to check if the value has been set. SetTarget sets Target field to given value. -### HasTarget - -`func (o *Project) HasTarget() bool` - -HasTarget returns a boolean if a field has been set. ### GetUser @@ -253,11 +223,6 @@ and a boolean to check if the value has been set. SetUser sets User field to given value. -### HasUser - -`func (o *Project) HasUser() bool` - -HasUser returns a boolean if a field has been set. ### GetWorkspaceId @@ -278,11 +243,6 @@ and a boolean to check if the value has been set. SetWorkspaceId sets WorkspaceId field to given value. -### HasWorkspaceId - -`func (o *Project) HasWorkspaceId() bool` - -HasWorkspaceId returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/ProjectConfig.md b/pkg/apiclient/docs/ProjectConfig.md index c51b954524..6cba46b6fc 100644 --- a/pkg/apiclient/docs/ProjectConfig.md +++ b/pkg/apiclient/docs/ProjectConfig.md @@ -5,18 +5,18 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **BuildConfig** | Pointer to [**ProjectBuildConfig**](ProjectBuildConfig.md) | | [optional] -**Default** | Pointer to **bool** | | [optional] -**EnvVars** | Pointer to **map[string]string** | | [optional] -**Image** | Pointer to **string** | | [optional] -**Name** | Pointer to **string** | | [optional] -**Repository** | Pointer to [**GitRepository**](GitRepository.md) | | [optional] -**User** | Pointer to **string** | | [optional] +**Default** | **bool** | | +**EnvVars** | **map[string]string** | | +**Image** | **string** | | +**Name** | **string** | | +**Repository** | [**GitRepository**](GitRepository.md) | | +**User** | **string** | | ## Methods ### NewProjectConfig -`func NewProjectConfig() *ProjectConfig` +`func NewProjectConfig(default_ bool, envVars map[string]string, image string, name string, repository GitRepository, user string, ) *ProjectConfig` NewProjectConfig instantiates a new ProjectConfig object This constructor will assign default values to properties that have it defined, @@ -75,11 +75,6 @@ and a boolean to check if the value has been set. SetDefault sets Default field to given value. -### HasDefault - -`func (o *ProjectConfig) HasDefault() bool` - -HasDefault returns a boolean if a field has been set. ### GetEnvVars @@ -100,11 +95,6 @@ and a boolean to check if the value has been set. SetEnvVars sets EnvVars field to given value. -### HasEnvVars - -`func (o *ProjectConfig) HasEnvVars() bool` - -HasEnvVars returns a boolean if a field has been set. ### GetImage @@ -125,11 +115,6 @@ and a boolean to check if the value has been set. SetImage sets Image field to given value. -### HasImage - -`func (o *ProjectConfig) HasImage() bool` - -HasImage returns a boolean if a field has been set. ### GetName @@ -150,11 +135,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *ProjectConfig) HasName() bool` - -HasName returns a boolean if a field has been set. ### GetRepository @@ -175,11 +155,6 @@ and a boolean to check if the value has been set. SetRepository sets Repository field to given value. -### HasRepository - -`func (o *ProjectConfig) HasRepository() bool` - -HasRepository returns a boolean if a field has been set. ### GetUser @@ -200,11 +175,6 @@ and a boolean to check if the value has been set. SetUser sets User field to given value. -### HasUser - -`func (o *ProjectConfig) HasUser() bool` - -HasUser returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/ProjectConfigAPI.md b/pkg/apiclient/docs/ProjectConfigAPI.md index 5a5c28d659..0578353928 100644 --- a/pkg/apiclient/docs/ProjectConfigAPI.md +++ b/pkg/apiclient/docs/ProjectConfigAPI.md @@ -371,7 +371,7 @@ import ( ) func main() { - projectConfig := *openapiclient.NewCreateProjectConfigDTO() // CreateProjectConfigDTO | Project config + projectConfig := *openapiclient.NewCreateProjectConfigDTO(map[string]string{"key": "Inner_example"}, "Name_example", *openapiclient.NewCreateProjectConfigSourceDTO(*openapiclient.NewGitRepository("Id_example", "Name_example", "Owner_example", "Sha_example", "Source_example", "Url_example"))) // CreateProjectConfigDTO | Project config configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) diff --git a/pkg/apiclient/docs/ProjectInfo.md b/pkg/apiclient/docs/ProjectInfo.md index b16a143ec3..78cd60e751 100644 --- a/pkg/apiclient/docs/ProjectInfo.md +++ b/pkg/apiclient/docs/ProjectInfo.md @@ -4,17 +4,17 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Created** | Pointer to **string** | | [optional] -**IsRunning** | Pointer to **bool** | | [optional] -**Name** | Pointer to **string** | | [optional] +**Created** | **string** | | +**IsRunning** | **bool** | | +**Name** | **string** | | **ProviderMetadata** | Pointer to **string** | | [optional] -**WorkspaceId** | Pointer to **string** | | [optional] +**WorkspaceId** | **string** | | ## Methods ### NewProjectInfo -`func NewProjectInfo() *ProjectInfo` +`func NewProjectInfo(created string, isRunning bool, name string, workspaceId string, ) *ProjectInfo` NewProjectInfo instantiates a new ProjectInfo object This constructor will assign default values to properties that have it defined, @@ -48,11 +48,6 @@ and a boolean to check if the value has been set. SetCreated sets Created field to given value. -### HasCreated - -`func (o *ProjectInfo) HasCreated() bool` - -HasCreated returns a boolean if a field has been set. ### GetIsRunning @@ -73,11 +68,6 @@ and a boolean to check if the value has been set. SetIsRunning sets IsRunning field to given value. -### HasIsRunning - -`func (o *ProjectInfo) HasIsRunning() bool` - -HasIsRunning returns a boolean if a field has been set. ### GetName @@ -98,11 +88,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *ProjectInfo) HasName() bool` - -HasName returns a boolean if a field has been set. ### GetProviderMetadata @@ -148,11 +133,6 @@ and a boolean to check if the value has been set. SetWorkspaceId sets WorkspaceId field to given value. -### HasWorkspaceId - -`func (o *ProjectInfo) HasWorkspaceId() bool` - -HasWorkspaceId returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/ProjectState.md b/pkg/apiclient/docs/ProjectState.md index 3dff9ee2b3..ebc9d14409 100644 --- a/pkg/apiclient/docs/ProjectState.md +++ b/pkg/apiclient/docs/ProjectState.md @@ -4,15 +4,15 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**GitStatus** | Pointer to [**GitStatus**](GitStatus.md) | | [optional] -**UpdatedAt** | Pointer to **string** | | [optional] -**Uptime** | Pointer to **int32** | | [optional] +**GitStatus** | [**GitStatus**](GitStatus.md) | | +**UpdatedAt** | **string** | | +**Uptime** | **int32** | | ## Methods ### NewProjectState -`func NewProjectState() *ProjectState` +`func NewProjectState(gitStatus GitStatus, updatedAt string, uptime int32, ) *ProjectState` NewProjectState instantiates a new ProjectState object This constructor will assign default values to properties that have it defined, @@ -46,11 +46,6 @@ and a boolean to check if the value has been set. SetGitStatus sets GitStatus field to given value. -### HasGitStatus - -`func (o *ProjectState) HasGitStatus() bool` - -HasGitStatus returns a boolean if a field has been set. ### GetUpdatedAt @@ -71,11 +66,6 @@ and a boolean to check if the value has been set. SetUpdatedAt sets UpdatedAt field to given value. -### HasUpdatedAt - -`func (o *ProjectState) HasUpdatedAt() bool` - -HasUpdatedAt returns a boolean if a field has been set. ### GetUptime @@ -96,11 +86,6 @@ and a boolean to check if the value has been set. SetUptime sets Uptime field to given value. -### HasUptime - -`func (o *ProjectState) HasUptime() bool` - -HasUptime returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/Provider.md b/pkg/apiclient/docs/Provider.md index 3536a6c095..2b4295ba6e 100644 --- a/pkg/apiclient/docs/Provider.md +++ b/pkg/apiclient/docs/Provider.md @@ -4,14 +4,14 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Name** | Pointer to **string** | | [optional] -**Version** | Pointer to **string** | | [optional] +**Name** | **string** | | +**Version** | **string** | | ## Methods ### NewProvider -`func NewProvider() *Provider` +`func NewProvider(name string, version string, ) *Provider` NewProvider instantiates a new Provider object This constructor will assign default values to properties that have it defined, @@ -45,11 +45,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *Provider) HasName() bool` - -HasName returns a boolean if a field has been set. ### GetVersion @@ -70,11 +65,6 @@ and a boolean to check if the value has been set. SetVersion sets Version field to given value. -### HasVersion - -`func (o *Provider) HasVersion() bool` - -HasVersion returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/ProviderAPI.md b/pkg/apiclient/docs/ProviderAPI.md index 4ba2eaed59..748cea7525 100644 --- a/pkg/apiclient/docs/ProviderAPI.md +++ b/pkg/apiclient/docs/ProviderAPI.md @@ -102,7 +102,7 @@ import ( ) func main() { - provider := *openapiclient.NewInstallProviderRequest() // InstallProviderRequest | Provider to install + provider := *openapiclient.NewInstallProviderRequest(map[string]string{"key": "Inner_example"}, "Name_example") // InstallProviderRequest | Provider to install configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) diff --git a/pkg/apiclient/docs/ProviderProviderInfo.md b/pkg/apiclient/docs/ProviderProviderInfo.md index 5cb8d136c2..0c26eb8899 100644 --- a/pkg/apiclient/docs/ProviderProviderInfo.md +++ b/pkg/apiclient/docs/ProviderProviderInfo.md @@ -4,14 +4,14 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Name** | Pointer to **string** | | [optional] -**Version** | Pointer to **string** | | [optional] +**Name** | **string** | | +**Version** | **string** | | ## Methods ### NewProviderProviderInfo -`func NewProviderProviderInfo() *ProviderProviderInfo` +`func NewProviderProviderInfo(name string, version string, ) *ProviderProviderInfo` NewProviderProviderInfo instantiates a new ProviderProviderInfo object This constructor will assign default values to properties that have it defined, @@ -45,11 +45,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *ProviderProviderInfo) HasName() bool` - -HasName returns a boolean if a field has been set. ### GetVersion @@ -70,11 +65,6 @@ and a boolean to check if the value has been set. SetVersion sets Version field to given value. -### HasVersion - -`func (o *ProviderProviderInfo) HasVersion() bool` - -HasVersion returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/ProviderTarget.md b/pkg/apiclient/docs/ProviderTarget.md index 54bbed40ed..08ab4e874c 100644 --- a/pkg/apiclient/docs/ProviderTarget.md +++ b/pkg/apiclient/docs/ProviderTarget.md @@ -4,15 +4,15 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Name** | Pointer to **string** | | [optional] -**Options** | Pointer to **string** | JSON encoded map of options | [optional] -**ProviderInfo** | Pointer to [**ProviderProviderInfo**](ProviderProviderInfo.md) | | [optional] +**Name** | **string** | | +**Options** | **string** | JSON encoded map of options | +**ProviderInfo** | [**ProviderProviderInfo**](ProviderProviderInfo.md) | | ## Methods ### NewProviderTarget -`func NewProviderTarget() *ProviderTarget` +`func NewProviderTarget(name string, options string, providerInfo ProviderProviderInfo, ) *ProviderTarget` NewProviderTarget instantiates a new ProviderTarget object This constructor will assign default values to properties that have it defined, @@ -46,11 +46,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *ProviderTarget) HasName() bool` - -HasName returns a boolean if a field has been set. ### GetOptions @@ -71,11 +66,6 @@ and a boolean to check if the value has been set. SetOptions sets Options field to given value. -### HasOptions - -`func (o *ProviderTarget) HasOptions() bool` - -HasOptions returns a boolean if a field has been set. ### GetProviderInfo @@ -96,11 +86,6 @@ and a boolean to check if the value has been set. SetProviderInfo sets ProviderInfo field to given value. -### HasProviderInfo - -`func (o *ProviderTarget) HasProviderInfo() bool` - -HasProviderInfo returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/RepositoryUrl.md b/pkg/apiclient/docs/RepositoryUrl.md index 420579fef2..975af7b5a2 100644 --- a/pkg/apiclient/docs/RepositoryUrl.md +++ b/pkg/apiclient/docs/RepositoryUrl.md @@ -4,13 +4,13 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Url** | Pointer to **string** | | [optional] +**Url** | **string** | | ## Methods ### NewRepositoryUrl -`func NewRepositoryUrl() *RepositoryUrl` +`func NewRepositoryUrl(url string, ) *RepositoryUrl` NewRepositoryUrl instantiates a new RepositoryUrl object This constructor will assign default values to properties that have it defined, @@ -44,11 +44,6 @@ and a boolean to check if the value has been set. SetUrl sets Url field to given value. -### HasUrl - -`func (o *RepositoryUrl) HasUrl() bool` - -HasUrl returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/ServerAPI.md b/pkg/apiclient/docs/ServerAPI.md index 902a268902..83ca8b7481 100644 --- a/pkg/apiclient/docs/ServerAPI.md +++ b/pkg/apiclient/docs/ServerAPI.md @@ -153,7 +153,7 @@ import ( ) func main() { - config := *openapiclient.NewServerConfig() // ServerConfig | Server configuration + config := *openapiclient.NewServerConfig(int32(123), "BinariesPath_example", "BuilderImage_example", "BuilderRegistryServer_example", "DefaultProjectImage_example", "DefaultProjectUser_example", int32(123), "Id_example", "LocalBuilderRegistryImage_example", int32(123), "LogFilePath_example", "ProvidersDir_example", "RegistryUrl_example", "ServerDownloadUrl_example") // ServerConfig | Server configuration configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) diff --git a/pkg/apiclient/docs/ServerConfig.md b/pkg/apiclient/docs/ServerConfig.md index c0634b381f..8bde056e15 100644 --- a/pkg/apiclient/docs/ServerConfig.md +++ b/pkg/apiclient/docs/ServerConfig.md @@ -4,28 +4,28 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**ApiPort** | Pointer to **int32** | | [optional] -**BinariesPath** | Pointer to **string** | | [optional] +**ApiPort** | **int32** | | +**BinariesPath** | **string** | | **BuildImageNamespace** | Pointer to **string** | | [optional] -**BuilderImage** | Pointer to **string** | | [optional] -**BuilderRegistryServer** | Pointer to **string** | | [optional] -**DefaultProjectImage** | Pointer to **string** | | [optional] -**DefaultProjectUser** | Pointer to **string** | | [optional] +**BuilderImage** | **string** | | +**BuilderRegistryServer** | **string** | | +**DefaultProjectImage** | **string** | | +**DefaultProjectUser** | **string** | | **Frps** | Pointer to [**FRPSConfig**](FRPSConfig.md) | | [optional] -**HeadscalePort** | Pointer to **int32** | | [optional] -**Id** | Pointer to **string** | | [optional] -**LocalBuilderRegistryImage** | Pointer to **string** | | [optional] -**LocalBuilderRegistryPort** | Pointer to **int32** | | [optional] -**LogFilePath** | Pointer to **string** | | [optional] -**ProvidersDir** | Pointer to **string** | | [optional] -**RegistryUrl** | Pointer to **string** | | [optional] -**ServerDownloadUrl** | Pointer to **string** | | [optional] +**HeadscalePort** | **int32** | | +**Id** | **string** | | +**LocalBuilderRegistryImage** | **string** | | +**LocalBuilderRegistryPort** | **int32** | | +**LogFilePath** | **string** | | +**ProvidersDir** | **string** | | +**RegistryUrl** | **string** | | +**ServerDownloadUrl** | **string** | | ## Methods ### NewServerConfig -`func NewServerConfig() *ServerConfig` +`func NewServerConfig(apiPort int32, binariesPath string, builderImage string, builderRegistryServer string, defaultProjectImage string, defaultProjectUser string, headscalePort int32, id string, localBuilderRegistryImage string, localBuilderRegistryPort int32, logFilePath string, providersDir string, registryUrl string, serverDownloadUrl string, ) *ServerConfig` NewServerConfig instantiates a new ServerConfig object This constructor will assign default values to properties that have it defined, @@ -59,11 +59,6 @@ and a boolean to check if the value has been set. SetApiPort sets ApiPort field to given value. -### HasApiPort - -`func (o *ServerConfig) HasApiPort() bool` - -HasApiPort returns a boolean if a field has been set. ### GetBinariesPath @@ -84,11 +79,6 @@ and a boolean to check if the value has been set. SetBinariesPath sets BinariesPath field to given value. -### HasBinariesPath - -`func (o *ServerConfig) HasBinariesPath() bool` - -HasBinariesPath returns a boolean if a field has been set. ### GetBuildImageNamespace @@ -134,11 +124,6 @@ and a boolean to check if the value has been set. SetBuilderImage sets BuilderImage field to given value. -### HasBuilderImage - -`func (o *ServerConfig) HasBuilderImage() bool` - -HasBuilderImage returns a boolean if a field has been set. ### GetBuilderRegistryServer @@ -159,11 +144,6 @@ and a boolean to check if the value has been set. SetBuilderRegistryServer sets BuilderRegistryServer field to given value. -### HasBuilderRegistryServer - -`func (o *ServerConfig) HasBuilderRegistryServer() bool` - -HasBuilderRegistryServer returns a boolean if a field has been set. ### GetDefaultProjectImage @@ -184,11 +164,6 @@ and a boolean to check if the value has been set. SetDefaultProjectImage sets DefaultProjectImage field to given value. -### HasDefaultProjectImage - -`func (o *ServerConfig) HasDefaultProjectImage() bool` - -HasDefaultProjectImage returns a boolean if a field has been set. ### GetDefaultProjectUser @@ -209,11 +184,6 @@ and a boolean to check if the value has been set. SetDefaultProjectUser sets DefaultProjectUser field to given value. -### HasDefaultProjectUser - -`func (o *ServerConfig) HasDefaultProjectUser() bool` - -HasDefaultProjectUser returns a boolean if a field has been set. ### GetFrps @@ -259,11 +229,6 @@ and a boolean to check if the value has been set. SetHeadscalePort sets HeadscalePort field to given value. -### HasHeadscalePort - -`func (o *ServerConfig) HasHeadscalePort() bool` - -HasHeadscalePort returns a boolean if a field has been set. ### GetId @@ -284,11 +249,6 @@ and a boolean to check if the value has been set. SetId sets Id field to given value. -### HasId - -`func (o *ServerConfig) HasId() bool` - -HasId returns a boolean if a field has been set. ### GetLocalBuilderRegistryImage @@ -309,11 +269,6 @@ and a boolean to check if the value has been set. SetLocalBuilderRegistryImage sets LocalBuilderRegistryImage field to given value. -### HasLocalBuilderRegistryImage - -`func (o *ServerConfig) HasLocalBuilderRegistryImage() bool` - -HasLocalBuilderRegistryImage returns a boolean if a field has been set. ### GetLocalBuilderRegistryPort @@ -334,11 +289,6 @@ and a boolean to check if the value has been set. SetLocalBuilderRegistryPort sets LocalBuilderRegistryPort field to given value. -### HasLocalBuilderRegistryPort - -`func (o *ServerConfig) HasLocalBuilderRegistryPort() bool` - -HasLocalBuilderRegistryPort returns a boolean if a field has been set. ### GetLogFilePath @@ -359,11 +309,6 @@ and a boolean to check if the value has been set. SetLogFilePath sets LogFilePath field to given value. -### HasLogFilePath - -`func (o *ServerConfig) HasLogFilePath() bool` - -HasLogFilePath returns a boolean if a field has been set. ### GetProvidersDir @@ -384,11 +329,6 @@ and a boolean to check if the value has been set. SetProvidersDir sets ProvidersDir field to given value. -### HasProvidersDir - -`func (o *ServerConfig) HasProvidersDir() bool` - -HasProvidersDir returns a boolean if a field has been set. ### GetRegistryUrl @@ -409,11 +349,6 @@ and a boolean to check if the value has been set. SetRegistryUrl sets RegistryUrl field to given value. -### HasRegistryUrl - -`func (o *ServerConfig) HasRegistryUrl() bool` - -HasRegistryUrl returns a boolean if a field has been set. ### GetServerDownloadUrl @@ -434,11 +369,6 @@ and a boolean to check if the value has been set. SetServerDownloadUrl sets ServerDownloadUrl field to given value. -### HasServerDownloadUrl - -`func (o *ServerConfig) HasServerDownloadUrl() bool` - -HasServerDownloadUrl returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/SetGitProviderConfig.md b/pkg/apiclient/docs/SetGitProviderConfig.md new file mode 100644 index 0000000000..184bd74519 --- /dev/null +++ b/pkg/apiclient/docs/SetGitProviderConfig.md @@ -0,0 +1,124 @@ +# SetGitProviderConfig + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**BaseApiUrl** | Pointer to **string** | | [optional] +**Id** | **string** | | +**Token** | **string** | | +**Username** | Pointer to **string** | | [optional] + +## Methods + +### NewSetGitProviderConfig + +`func NewSetGitProviderConfig(id string, token string, ) *SetGitProviderConfig` + +NewSetGitProviderConfig instantiates a new SetGitProviderConfig 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 + +### NewSetGitProviderConfigWithDefaults + +`func NewSetGitProviderConfigWithDefaults() *SetGitProviderConfig` + +NewSetGitProviderConfigWithDefaults instantiates a new SetGitProviderConfig 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 + +### GetBaseApiUrl + +`func (o *SetGitProviderConfig) GetBaseApiUrl() string` + +GetBaseApiUrl returns the BaseApiUrl field if non-nil, zero value otherwise. + +### GetBaseApiUrlOk + +`func (o *SetGitProviderConfig) GetBaseApiUrlOk() (*string, bool)` + +GetBaseApiUrlOk returns a tuple with the BaseApiUrl field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetBaseApiUrl + +`func (o *SetGitProviderConfig) SetBaseApiUrl(v string)` + +SetBaseApiUrl sets BaseApiUrl field to given value. + +### HasBaseApiUrl + +`func (o *SetGitProviderConfig) HasBaseApiUrl() bool` + +HasBaseApiUrl returns a boolean if a field has been set. + +### GetId + +`func (o *SetGitProviderConfig) GetId() string` + +GetId returns the Id field if non-nil, zero value otherwise. + +### GetIdOk + +`func (o *SetGitProviderConfig) GetIdOk() (*string, bool)` + +GetIdOk returns a tuple with the Id field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetId + +`func (o *SetGitProviderConfig) SetId(v string)` + +SetId sets Id field to given value. + + +### GetToken + +`func (o *SetGitProviderConfig) GetToken() string` + +GetToken returns the Token field if non-nil, zero value otherwise. + +### GetTokenOk + +`func (o *SetGitProviderConfig) GetTokenOk() (*string, bool)` + +GetTokenOk returns a tuple with the Token field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetToken + +`func (o *SetGitProviderConfig) SetToken(v string)` + +SetToken sets Token field to given value. + + +### GetUsername + +`func (o *SetGitProviderConfig) GetUsername() string` + +GetUsername returns the Username field if non-nil, zero value otherwise. + +### GetUsernameOk + +`func (o *SetGitProviderConfig) GetUsernameOk() (*string, bool)` + +GetUsernameOk returns a tuple with the Username field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetUsername + +`func (o *SetGitProviderConfig) SetUsername(v string)` + +SetUsername sets Username field to given value. + +### HasUsername + +`func (o *SetGitProviderConfig) HasUsername() bool` + +HasUsername returns a boolean if a field has been set. + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/pkg/apiclient/docs/SetProjectState.md b/pkg/apiclient/docs/SetProjectState.md index 96e2644468..662ed9d98f 100644 --- a/pkg/apiclient/docs/SetProjectState.md +++ b/pkg/apiclient/docs/SetProjectState.md @@ -5,13 +5,13 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **GitStatus** | Pointer to [**GitStatus**](GitStatus.md) | | [optional] -**Uptime** | Pointer to **int32** | | [optional] +**Uptime** | **int32** | | ## Methods ### NewSetProjectState -`func NewSetProjectState() *SetProjectState` +`func NewSetProjectState(uptime int32, ) *SetProjectState` NewSetProjectState instantiates a new SetProjectState object This constructor will assign default values to properties that have it defined, @@ -70,11 +70,6 @@ and a boolean to check if the value has been set. SetUptime sets Uptime field to given value. -### HasUptime - -`func (o *SetProjectState) HasUptime() bool` - -HasUptime returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/TargetAPI.md b/pkg/apiclient/docs/TargetAPI.md index 7fc6d026c3..0458163bb1 100644 --- a/pkg/apiclient/docs/TargetAPI.md +++ b/pkg/apiclient/docs/TargetAPI.md @@ -160,7 +160,7 @@ import ( ) func main() { - target := *openapiclient.NewProviderTarget() // ProviderTarget | Target to set + target := *openapiclient.NewProviderTarget("Name_example", "Options_example", *openapiclient.NewProviderProviderInfo("Name_example", "Version_example")) // ProviderTarget | Target to set configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) diff --git a/pkg/apiclient/docs/Workspace.md b/pkg/apiclient/docs/Workspace.md index d1b698182b..296d9e30c9 100644 --- a/pkg/apiclient/docs/Workspace.md +++ b/pkg/apiclient/docs/Workspace.md @@ -4,16 +4,16 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Id** | Pointer to **string** | | [optional] -**Name** | Pointer to **string** | | [optional] -**Projects** | Pointer to [**[]Project**](Project.md) | | [optional] -**Target** | Pointer to **string** | | [optional] +**Id** | **string** | | +**Name** | **string** | | +**Projects** | [**[]Project**](Project.md) | | +**Target** | **string** | | ## Methods ### NewWorkspace -`func NewWorkspace() *Workspace` +`func NewWorkspace(id string, name string, projects []Project, target string, ) *Workspace` NewWorkspace instantiates a new Workspace object This constructor will assign default values to properties that have it defined, @@ -47,11 +47,6 @@ and a boolean to check if the value has been set. SetId sets Id field to given value. -### HasId - -`func (o *Workspace) HasId() bool` - -HasId returns a boolean if a field has been set. ### GetName @@ -72,11 +67,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *Workspace) HasName() bool` - -HasName returns a boolean if a field has been set. ### GetProjects @@ -97,11 +87,6 @@ and a boolean to check if the value has been set. SetProjects sets Projects field to given value. -### HasProjects - -`func (o *Workspace) HasProjects() bool` - -HasProjects returns a boolean if a field has been set. ### GetTarget @@ -122,11 +107,6 @@ and a boolean to check if the value has been set. SetTarget sets Target field to given value. -### HasTarget - -`func (o *Workspace) HasTarget() bool` - -HasTarget returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/WorkspaceAPI.md b/pkg/apiclient/docs/WorkspaceAPI.md index cbb54565ff..511a1aaa69 100644 --- a/pkg/apiclient/docs/WorkspaceAPI.md +++ b/pkg/apiclient/docs/WorkspaceAPI.md @@ -37,7 +37,7 @@ import ( ) func main() { - workspace := *openapiclient.NewCreateWorkspaceDTO([]openapiclient.CreateProjectConfigDTO{*openapiclient.NewCreateProjectConfigDTO()}) // CreateWorkspaceDTO | Create workspace + workspace := *openapiclient.NewCreateWorkspaceDTO("Id_example", "Name_example", []openapiclient.CreateProjectConfigDTO{*openapiclient.NewCreateProjectConfigDTO(map[string]string{"key": "Inner_example"}, "Name_example", *openapiclient.NewCreateProjectConfigSourceDTO(*openapiclient.NewGitRepository("Id_example", "Name_example", "Owner_example", "Sha_example", "Source_example", "Url_example")))}, "Target_example") // CreateWorkspaceDTO | Create workspace configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) @@ -311,7 +311,7 @@ import ( func main() { workspaceId := "workspaceId_example" // string | Workspace ID or Name projectId := "projectId_example" // string | Project ID - setState := *openapiclient.NewSetProjectState() // SetProjectState | Set State + setState := *openapiclient.NewSetProjectState(int32(123)) // SetProjectState | Set State configuration := openapiclient.NewConfiguration() apiClient := openapiclient.NewAPIClient(configuration) diff --git a/pkg/apiclient/docs/WorkspaceDTO.md b/pkg/apiclient/docs/WorkspaceDTO.md index c90470ce3f..9a0ce569c3 100644 --- a/pkg/apiclient/docs/WorkspaceDTO.md +++ b/pkg/apiclient/docs/WorkspaceDTO.md @@ -4,17 +4,17 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Id** | Pointer to **string** | | [optional] +**Id** | **string** | | **Info** | Pointer to [**WorkspaceInfo**](WorkspaceInfo.md) | | [optional] -**Name** | Pointer to **string** | | [optional] -**Projects** | Pointer to [**[]Project**](Project.md) | | [optional] -**Target** | Pointer to **string** | | [optional] +**Name** | **string** | | +**Projects** | [**[]Project**](Project.md) | | +**Target** | **string** | | ## Methods ### NewWorkspaceDTO -`func NewWorkspaceDTO() *WorkspaceDTO` +`func NewWorkspaceDTO(id string, name string, projects []Project, target string, ) *WorkspaceDTO` NewWorkspaceDTO instantiates a new WorkspaceDTO object This constructor will assign default values to properties that have it defined, @@ -48,11 +48,6 @@ and a boolean to check if the value has been set. SetId sets Id field to given value. -### HasId - -`func (o *WorkspaceDTO) HasId() bool` - -HasId returns a boolean if a field has been set. ### GetInfo @@ -98,11 +93,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *WorkspaceDTO) HasName() bool` - -HasName returns a boolean if a field has been set. ### GetProjects @@ -123,11 +113,6 @@ and a boolean to check if the value has been set. SetProjects sets Projects field to given value. -### HasProjects - -`func (o *WorkspaceDTO) HasProjects() bool` - -HasProjects returns a boolean if a field has been set. ### GetTarget @@ -148,11 +133,6 @@ and a boolean to check if the value has been set. SetTarget sets Target field to given value. -### HasTarget - -`func (o *WorkspaceDTO) HasTarget() bool` - -HasTarget returns a boolean if a field has been set. [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/pkg/apiclient/docs/WorkspaceInfo.md b/pkg/apiclient/docs/WorkspaceInfo.md index df78c44125..e0468ccaf0 100644 --- a/pkg/apiclient/docs/WorkspaceInfo.md +++ b/pkg/apiclient/docs/WorkspaceInfo.md @@ -4,15 +4,15 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**Name** | Pointer to **string** | | [optional] -**Projects** | Pointer to [**[]ProjectInfo**](ProjectInfo.md) | | [optional] +**Name** | **string** | | +**Projects** | [**[]ProjectInfo**](ProjectInfo.md) | | **ProviderMetadata** | Pointer to **string** | | [optional] ## Methods ### NewWorkspaceInfo -`func NewWorkspaceInfo() *WorkspaceInfo` +`func NewWorkspaceInfo(name string, projects []ProjectInfo, ) *WorkspaceInfo` NewWorkspaceInfo instantiates a new WorkspaceInfo object This constructor will assign default values to properties that have it defined, @@ -46,11 +46,6 @@ and a boolean to check if the value has been set. SetName sets Name field to given value. -### HasName - -`func (o *WorkspaceInfo) HasName() bool` - -HasName returns a boolean if a field has been set. ### GetProjects @@ -71,11 +66,6 @@ and a boolean to check if the value has been set. SetProjects sets Projects field to given value. -### HasProjects - -`func (o *WorkspaceInfo) HasProjects() bool` - -HasProjects returns a boolean if a field has been set. ### GetProviderMetadata diff --git a/pkg/apiclient/model_api_key.go b/pkg/apiclient/model_api_key.go index 75a42af4e2..4a891d3af3 100644 --- a/pkg/apiclient/model_api_key.go +++ b/pkg/apiclient/model_api_key.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the ApiKey type satisfies the MappedNullable interface at compile time @@ -19,18 +21,23 @@ var _ MappedNullable = &ApiKey{} // ApiKey struct for ApiKey type ApiKey struct { - KeyHash *string `json:"keyHash,omitempty"` + KeyHash string `json:"keyHash"` // Project or client name - Name *string `json:"name,omitempty"` - Type *ApikeyApiKeyType `json:"type,omitempty"` + Name string `json:"name"` + Type ApikeyApiKeyType `json:"type"` } +type _ApiKey ApiKey + // NewApiKey instantiates a new ApiKey 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 NewApiKey() *ApiKey { +func NewApiKey(keyHash string, name string, type_ ApikeyApiKeyType) *ApiKey { this := ApiKey{} + this.KeyHash = keyHash + this.Name = name + this.Type = type_ return &this } @@ -42,100 +49,76 @@ func NewApiKeyWithDefaults() *ApiKey { return &this } -// GetKeyHash returns the KeyHash field value if set, zero value otherwise. +// GetKeyHash returns the KeyHash field value func (o *ApiKey) GetKeyHash() string { - if o == nil || IsNil(o.KeyHash) { + if o == nil { var ret string return ret } - return *o.KeyHash + + return o.KeyHash } -// GetKeyHashOk returns a tuple with the KeyHash field value if set, nil otherwise +// GetKeyHashOk returns a tuple with the KeyHash field value // and a boolean to check if the value has been set. func (o *ApiKey) GetKeyHashOk() (*string, bool) { - if o == nil || IsNil(o.KeyHash) { + if o == nil { return nil, false } - return o.KeyHash, true -} - -// HasKeyHash returns a boolean if a field has been set. -func (o *ApiKey) HasKeyHash() bool { - if o != nil && !IsNil(o.KeyHash) { - return true - } - - return false + return &o.KeyHash, true } -// SetKeyHash gets a reference to the given string and assigns it to the KeyHash field. +// SetKeyHash sets field value func (o *ApiKey) SetKeyHash(v string) { - o.KeyHash = &v + o.KeyHash = v } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *ApiKey) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *ApiKey) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true -} - -// HasName returns a boolean if a field has been set. -func (o *ApiKey) HasName() bool { - if o != nil && !IsNil(o.Name) { - return true - } - - return false + return &o.Name, true } -// SetName gets a reference to the given string and assigns it to the Name field. +// SetName sets field value func (o *ApiKey) SetName(v string) { - o.Name = &v + o.Name = v } -// GetType returns the Type field value if set, zero value otherwise. +// GetType returns the Type field value func (o *ApiKey) GetType() ApikeyApiKeyType { - if o == nil || IsNil(o.Type) { + if o == nil { var ret ApikeyApiKeyType return ret } - return *o.Type + + return o.Type } -// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// GetTypeOk returns a tuple with the Type field value // and a boolean to check if the value has been set. func (o *ApiKey) GetTypeOk() (*ApikeyApiKeyType, bool) { - if o == nil || IsNil(o.Type) { + if o == nil { return nil, false } - return o.Type, true -} - -// HasType returns a boolean if a field has been set. -func (o *ApiKey) HasType() bool { - if o != nil && !IsNil(o.Type) { - return true - } - - return false + return &o.Type, true } -// SetType gets a reference to the given ApikeyApiKeyType and assigns it to the Type field. +// SetType sets field value func (o *ApiKey) SetType(v ApikeyApiKeyType) { - o.Type = &v + o.Type = v } func (o ApiKey) MarshalJSON() ([]byte, error) { @@ -148,16 +131,49 @@ func (o ApiKey) MarshalJSON() ([]byte, error) { func (o ApiKey) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.KeyHash) { - toSerialize["keyHash"] = o.KeyHash + toSerialize["keyHash"] = o.KeyHash + toSerialize["name"] = o.Name + toSerialize["type"] = o.Type + return toSerialize, nil +} + +func (o *ApiKey) 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{ + "keyHash", + "name", + "type", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - if !IsNil(o.Name) { - toSerialize["name"] = o.Name + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } } - if !IsNil(o.Type) { - toSerialize["type"] = o.Type + + varApiKey := _ApiKey{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varApiKey) + + if err != nil { + return err } - return toSerialize, nil + + *o = ApiKey(varApiKey) + + return err } type NullableApiKey struct { diff --git a/pkg/apiclient/model_container_registry.go b/pkg/apiclient/model_container_registry.go index 7a61092aa7..dbe38007b7 100644 --- a/pkg/apiclient/model_container_registry.go +++ b/pkg/apiclient/model_container_registry.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the ContainerRegistry type satisfies the MappedNullable interface at compile time @@ -19,17 +21,22 @@ var _ MappedNullable = &ContainerRegistry{} // ContainerRegistry struct for ContainerRegistry type ContainerRegistry struct { - Password *string `json:"password,omitempty"` - Server *string `json:"server,omitempty"` - Username *string `json:"username,omitempty"` + Password string `json:"password"` + Server string `json:"server"` + Username string `json:"username"` } +type _ContainerRegistry ContainerRegistry + // NewContainerRegistry instantiates a new ContainerRegistry 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 NewContainerRegistry() *ContainerRegistry { +func NewContainerRegistry(password string, server string, username string) *ContainerRegistry { this := ContainerRegistry{} + this.Password = password + this.Server = server + this.Username = username return &this } @@ -41,100 +48,76 @@ func NewContainerRegistryWithDefaults() *ContainerRegistry { return &this } -// GetPassword returns the Password field value if set, zero value otherwise. +// GetPassword returns the Password field value func (o *ContainerRegistry) GetPassword() string { - if o == nil || IsNil(o.Password) { + if o == nil { var ret string return ret } - return *o.Password + + return o.Password } -// GetPasswordOk returns a tuple with the Password field value if set, nil otherwise +// GetPasswordOk returns a tuple with the Password field value // and a boolean to check if the value has been set. func (o *ContainerRegistry) GetPasswordOk() (*string, bool) { - if o == nil || IsNil(o.Password) { + if o == nil { return nil, false } - return o.Password, true -} - -// HasPassword returns a boolean if a field has been set. -func (o *ContainerRegistry) HasPassword() bool { - if o != nil && !IsNil(o.Password) { - return true - } - - return false + return &o.Password, true } -// SetPassword gets a reference to the given string and assigns it to the Password field. +// SetPassword sets field value func (o *ContainerRegistry) SetPassword(v string) { - o.Password = &v + o.Password = v } -// GetServer returns the Server field value if set, zero value otherwise. +// GetServer returns the Server field value func (o *ContainerRegistry) GetServer() string { - if o == nil || IsNil(o.Server) { + if o == nil { var ret string return ret } - return *o.Server + + return o.Server } -// GetServerOk returns a tuple with the Server field value if set, nil otherwise +// GetServerOk returns a tuple with the Server field value // and a boolean to check if the value has been set. func (o *ContainerRegistry) GetServerOk() (*string, bool) { - if o == nil || IsNil(o.Server) { + if o == nil { return nil, false } - return o.Server, true -} - -// HasServer returns a boolean if a field has been set. -func (o *ContainerRegistry) HasServer() bool { - if o != nil && !IsNil(o.Server) { - return true - } - - return false + return &o.Server, true } -// SetServer gets a reference to the given string and assigns it to the Server field. +// SetServer sets field value func (o *ContainerRegistry) SetServer(v string) { - o.Server = &v + o.Server = v } -// GetUsername returns the Username field value if set, zero value otherwise. +// GetUsername returns the Username field value func (o *ContainerRegistry) GetUsername() string { - if o == nil || IsNil(o.Username) { + if o == nil { var ret string return ret } - return *o.Username + + return o.Username } -// GetUsernameOk returns a tuple with the Username field value if set, nil otherwise +// GetUsernameOk returns a tuple with the Username field value // and a boolean to check if the value has been set. func (o *ContainerRegistry) GetUsernameOk() (*string, bool) { - if o == nil || IsNil(o.Username) { + if o == nil { return nil, false } - return o.Username, true -} - -// HasUsername returns a boolean if a field has been set. -func (o *ContainerRegistry) HasUsername() bool { - if o != nil && !IsNil(o.Username) { - return true - } - - return false + return &o.Username, true } -// SetUsername gets a reference to the given string and assigns it to the Username field. +// SetUsername sets field value func (o *ContainerRegistry) SetUsername(v string) { - o.Username = &v + o.Username = v } func (o ContainerRegistry) MarshalJSON() ([]byte, error) { @@ -147,16 +130,49 @@ func (o ContainerRegistry) MarshalJSON() ([]byte, error) { func (o ContainerRegistry) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Password) { - toSerialize["password"] = o.Password + toSerialize["password"] = o.Password + toSerialize["server"] = o.Server + toSerialize["username"] = o.Username + return toSerialize, nil +} + +func (o *ContainerRegistry) 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{ + "password", + "server", + "username", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - if !IsNil(o.Server) { - toSerialize["server"] = o.Server + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } } - if !IsNil(o.Username) { - toSerialize["username"] = o.Username + + varContainerRegistry := _ContainerRegistry{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varContainerRegistry) + + if err != nil { + return err } - return toSerialize, nil + + *o = ContainerRegistry(varContainerRegistry) + + return err } type NullableContainerRegistry struct { diff --git a/pkg/apiclient/model_create_project_config_dto.go b/pkg/apiclient/model_create_project_config_dto.go index 2bc7fda3d1..6c780164f2 100644 --- a/pkg/apiclient/model_create_project_config_dto.go +++ b/pkg/apiclient/model_create_project_config_dto.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the CreateProjectConfigDTO type satisfies the MappedNullable interface at compile time @@ -19,20 +21,25 @@ var _ MappedNullable = &CreateProjectConfigDTO{} // CreateProjectConfigDTO struct for CreateProjectConfigDTO type CreateProjectConfigDTO struct { - BuildConfig *ProjectBuildConfig `json:"buildConfig,omitempty"` - EnvVars *map[string]string `json:"envVars,omitempty"` - Image *string `json:"image,omitempty"` - Name *string `json:"name,omitempty"` - Source *CreateProjectConfigSourceDTO `json:"source,omitempty"` - User *string `json:"user,omitempty"` + BuildConfig *ProjectBuildConfig `json:"buildConfig,omitempty"` + EnvVars map[string]string `json:"envVars"` + Image *string `json:"image,omitempty"` + Name string `json:"name"` + Source CreateProjectConfigSourceDTO `json:"source"` + User *string `json:"user,omitempty"` } +type _CreateProjectConfigDTO CreateProjectConfigDTO + // NewCreateProjectConfigDTO instantiates a new CreateProjectConfigDTO 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 NewCreateProjectConfigDTO() *CreateProjectConfigDTO { +func NewCreateProjectConfigDTO(envVars map[string]string, name string, source CreateProjectConfigSourceDTO) *CreateProjectConfigDTO { this := CreateProjectConfigDTO{} + this.EnvVars = envVars + this.Name = name + this.Source = source return &this } @@ -76,36 +83,28 @@ func (o *CreateProjectConfigDTO) SetBuildConfig(v ProjectBuildConfig) { o.BuildConfig = &v } -// GetEnvVars returns the EnvVars field value if set, zero value otherwise. +// GetEnvVars returns the EnvVars field value func (o *CreateProjectConfigDTO) GetEnvVars() map[string]string { - if o == nil || IsNil(o.EnvVars) { + if o == nil { var ret map[string]string return ret } - return *o.EnvVars + + return o.EnvVars } -// GetEnvVarsOk returns a tuple with the EnvVars field value if set, nil otherwise +// GetEnvVarsOk returns a tuple with the EnvVars field value // and a boolean to check if the value has been set. func (o *CreateProjectConfigDTO) GetEnvVarsOk() (*map[string]string, bool) { - if o == nil || IsNil(o.EnvVars) { + if o == nil { return nil, false } - return o.EnvVars, true + return &o.EnvVars, true } -// HasEnvVars returns a boolean if a field has been set. -func (o *CreateProjectConfigDTO) HasEnvVars() bool { - if o != nil && !IsNil(o.EnvVars) { - return true - } - - return false -} - -// SetEnvVars gets a reference to the given map[string]string and assigns it to the EnvVars field. +// SetEnvVars sets field value func (o *CreateProjectConfigDTO) SetEnvVars(v map[string]string) { - o.EnvVars = &v + o.EnvVars = v } // GetImage returns the Image field value if set, zero value otherwise. @@ -140,68 +139,52 @@ func (o *CreateProjectConfigDTO) SetImage(v string) { o.Image = &v } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *CreateProjectConfigDTO) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *CreateProjectConfigDTO) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true + return &o.Name, true } -// HasName returns a boolean if a field has been set. -func (o *CreateProjectConfigDTO) 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. +// SetName sets field value func (o *CreateProjectConfigDTO) SetName(v string) { - o.Name = &v + o.Name = v } -// GetSource returns the Source field value if set, zero value otherwise. +// GetSource returns the Source field value func (o *CreateProjectConfigDTO) GetSource() CreateProjectConfigSourceDTO { - if o == nil || IsNil(o.Source) { + if o == nil { var ret CreateProjectConfigSourceDTO return ret } - return *o.Source + + return o.Source } -// GetSourceOk returns a tuple with the Source field value if set, nil otherwise +// GetSourceOk returns a tuple with the Source field value // and a boolean to check if the value has been set. func (o *CreateProjectConfigDTO) GetSourceOk() (*CreateProjectConfigSourceDTO, bool) { - if o == nil || IsNil(o.Source) { + if o == nil { return nil, false } - return o.Source, true -} - -// HasSource returns a boolean if a field has been set. -func (o *CreateProjectConfigDTO) HasSource() bool { - if o != nil && !IsNil(o.Source) { - return true - } - - return false + return &o.Source, true } -// SetSource gets a reference to the given CreateProjectConfigSourceDTO and assigns it to the Source field. +// SetSource sets field value func (o *CreateProjectConfigDTO) SetSource(v CreateProjectConfigSourceDTO) { - o.Source = &v + o.Source = v } // GetUser returns the User field value if set, zero value otherwise. @@ -249,24 +232,57 @@ func (o CreateProjectConfigDTO) ToMap() (map[string]interface{}, error) { if !IsNil(o.BuildConfig) { toSerialize["buildConfig"] = o.BuildConfig } - if !IsNil(o.EnvVars) { - toSerialize["envVars"] = o.EnvVars - } + toSerialize["envVars"] = o.EnvVars if !IsNil(o.Image) { toSerialize["image"] = o.Image } - if !IsNil(o.Name) { - toSerialize["name"] = o.Name - } - if !IsNil(o.Source) { - toSerialize["source"] = o.Source - } + toSerialize["name"] = o.Name + toSerialize["source"] = o.Source if !IsNil(o.User) { toSerialize["user"] = o.User } return toSerialize, nil } +func (o *CreateProjectConfigDTO) 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{ + "envVars", + "name", + "source", + } + + 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) + } + } + + varCreateProjectConfigDTO := _CreateProjectConfigDTO{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varCreateProjectConfigDTO) + + if err != nil { + return err + } + + *o = CreateProjectConfigDTO(varCreateProjectConfigDTO) + + return err +} + type NullableCreateProjectConfigDTO struct { value *CreateProjectConfigDTO isSet bool diff --git a/pkg/apiclient/model_create_project_config_source_dto.go b/pkg/apiclient/model_create_project_config_source_dto.go index 4a90e5c795..ea38356c91 100644 --- a/pkg/apiclient/model_create_project_config_source_dto.go +++ b/pkg/apiclient/model_create_project_config_source_dto.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the CreateProjectConfigSourceDTO type satisfies the MappedNullable interface at compile time @@ -19,15 +21,18 @@ var _ MappedNullable = &CreateProjectConfigSourceDTO{} // CreateProjectConfigSourceDTO struct for CreateProjectConfigSourceDTO type CreateProjectConfigSourceDTO struct { - Repository *GitRepository `json:"repository,omitempty"` + Repository GitRepository `json:"repository"` } +type _CreateProjectConfigSourceDTO CreateProjectConfigSourceDTO + // NewCreateProjectConfigSourceDTO instantiates a new CreateProjectConfigSourceDTO 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 NewCreateProjectConfigSourceDTO() *CreateProjectConfigSourceDTO { +func NewCreateProjectConfigSourceDTO(repository GitRepository) *CreateProjectConfigSourceDTO { this := CreateProjectConfigSourceDTO{} + this.Repository = repository return &this } @@ -39,36 +44,28 @@ func NewCreateProjectConfigSourceDTOWithDefaults() *CreateProjectConfigSourceDTO return &this } -// GetRepository returns the Repository field value if set, zero value otherwise. +// GetRepository returns the Repository field value func (o *CreateProjectConfigSourceDTO) GetRepository() GitRepository { - if o == nil || IsNil(o.Repository) { + if o == nil { var ret GitRepository return ret } - return *o.Repository + + return o.Repository } -// GetRepositoryOk returns a tuple with the Repository field value if set, nil otherwise +// GetRepositoryOk returns a tuple with the Repository field value // and a boolean to check if the value has been set. func (o *CreateProjectConfigSourceDTO) GetRepositoryOk() (*GitRepository, bool) { - if o == nil || IsNil(o.Repository) { + if o == nil { return nil, false } - return o.Repository, true -} - -// HasRepository returns a boolean if a field has been set. -func (o *CreateProjectConfigSourceDTO) HasRepository() bool { - if o != nil && !IsNil(o.Repository) { - return true - } - - return false + return &o.Repository, true } -// SetRepository gets a reference to the given GitRepository and assigns it to the Repository field. +// SetRepository sets field value func (o *CreateProjectConfigSourceDTO) SetRepository(v GitRepository) { - o.Repository = &v + o.Repository = v } func (o CreateProjectConfigSourceDTO) MarshalJSON() ([]byte, error) { @@ -81,12 +78,47 @@ func (o CreateProjectConfigSourceDTO) MarshalJSON() ([]byte, error) { func (o CreateProjectConfigSourceDTO) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Repository) { - toSerialize["repository"] = o.Repository - } + toSerialize["repository"] = o.Repository return toSerialize, nil } +func (o *CreateProjectConfigSourceDTO) 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{ + "repository", + } + + 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) + } + } + + varCreateProjectConfigSourceDTO := _CreateProjectConfigSourceDTO{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varCreateProjectConfigSourceDTO) + + if err != nil { + return err + } + + *o = CreateProjectConfigSourceDTO(varCreateProjectConfigSourceDTO) + + return err +} + type NullableCreateProjectConfigSourceDTO struct { value *CreateProjectConfigSourceDTO isSet bool diff --git a/pkg/apiclient/model_create_workspace_dto.go b/pkg/apiclient/model_create_workspace_dto.go index a922226f73..3dc67c32bd 100644 --- a/pkg/apiclient/model_create_workspace_dto.go +++ b/pkg/apiclient/model_create_workspace_dto.go @@ -21,10 +21,10 @@ var _ MappedNullable = &CreateWorkspaceDTO{} // CreateWorkspaceDTO struct for CreateWorkspaceDTO type CreateWorkspaceDTO struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` + Id string `json:"id"` + Name string `json:"name"` Projects []CreateProjectConfigDTO `json:"projects"` - Target *string `json:"target,omitempty"` + Target string `json:"target"` } type _CreateWorkspaceDTO CreateWorkspaceDTO @@ -33,9 +33,12 @@ type _CreateWorkspaceDTO CreateWorkspaceDTO // 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 NewCreateWorkspaceDTO(projects []CreateProjectConfigDTO) *CreateWorkspaceDTO { +func NewCreateWorkspaceDTO(id string, name string, projects []CreateProjectConfigDTO, target string) *CreateWorkspaceDTO { this := CreateWorkspaceDTO{} + this.Id = id + this.Name = name this.Projects = projects + this.Target = target return &this } @@ -47,68 +50,52 @@ func NewCreateWorkspaceDTOWithDefaults() *CreateWorkspaceDTO { return &this } -// GetId returns the Id field value if set, zero value otherwise. +// GetId returns the Id field value func (o *CreateWorkspaceDTO) GetId() string { - if o == nil || IsNil(o.Id) { + if o == nil { var ret string return ret } - return *o.Id + + return o.Id } -// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// GetIdOk returns a tuple with the Id field value // and a boolean to check if the value has been set. func (o *CreateWorkspaceDTO) GetIdOk() (*string, bool) { - if o == nil || IsNil(o.Id) { + if o == nil { return nil, false } - return o.Id, true -} - -// HasId returns a boolean if a field has been set. -func (o *CreateWorkspaceDTO) HasId() bool { - if o != nil && !IsNil(o.Id) { - return true - } - - return false + return &o.Id, true } -// SetId gets a reference to the given string and assigns it to the Id field. +// SetId sets field value func (o *CreateWorkspaceDTO) SetId(v string) { - o.Id = &v + o.Id = v } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *CreateWorkspaceDTO) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *CreateWorkspaceDTO) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true -} - -// HasName returns a boolean if a field has been set. -func (o *CreateWorkspaceDTO) HasName() bool { - if o != nil && !IsNil(o.Name) { - return true - } - - return false + return &o.Name, true } -// SetName gets a reference to the given string and assigns it to the Name field. +// SetName sets field value func (o *CreateWorkspaceDTO) SetName(v string) { - o.Name = &v + o.Name = v } // GetProjects returns the Projects field value @@ -135,36 +122,28 @@ func (o *CreateWorkspaceDTO) SetProjects(v []CreateProjectConfigDTO) { o.Projects = v } -// GetTarget returns the Target field value if set, zero value otherwise. +// GetTarget returns the Target field value func (o *CreateWorkspaceDTO) GetTarget() string { - if o == nil || IsNil(o.Target) { + if o == nil { var ret string return ret } - return *o.Target + + return o.Target } -// GetTargetOk returns a tuple with the Target field value if set, nil otherwise +// GetTargetOk returns a tuple with the Target field value // and a boolean to check if the value has been set. func (o *CreateWorkspaceDTO) GetTargetOk() (*string, bool) { - if o == nil || IsNil(o.Target) { + if o == nil { return nil, false } - return o.Target, true -} - -// HasTarget returns a boolean if a field has been set. -func (o *CreateWorkspaceDTO) HasTarget() bool { - if o != nil && !IsNil(o.Target) { - return true - } - - return false + return &o.Target, true } -// SetTarget gets a reference to the given string and assigns it to the Target field. +// SetTarget sets field value func (o *CreateWorkspaceDTO) SetTarget(v string) { - o.Target = &v + o.Target = v } func (o CreateWorkspaceDTO) MarshalJSON() ([]byte, error) { @@ -177,16 +156,10 @@ func (o CreateWorkspaceDTO) MarshalJSON() ([]byte, error) { func (o CreateWorkspaceDTO) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Id) { - toSerialize["id"] = o.Id - } - if !IsNil(o.Name) { - toSerialize["name"] = o.Name - } + toSerialize["id"] = o.Id + toSerialize["name"] = o.Name toSerialize["projects"] = o.Projects - if !IsNil(o.Target) { - toSerialize["target"] = o.Target - } + toSerialize["target"] = o.Target return toSerialize, nil } @@ -195,7 +168,10 @@ func (o *CreateWorkspaceDTO) UnmarshalJSON(data []byte) (err error) { // 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", + "name", "projects", + "target", } allProperties := make(map[string]interface{}) diff --git a/pkg/apiclient/model_devcontainer_config.go b/pkg/apiclient/model_devcontainer_config.go index de272fd136..7126e1fa8f 100644 --- a/pkg/apiclient/model_devcontainer_config.go +++ b/pkg/apiclient/model_devcontainer_config.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the DevcontainerConfig type satisfies the MappedNullable interface at compile time @@ -19,15 +21,18 @@ var _ MappedNullable = &DevcontainerConfig{} // DevcontainerConfig struct for DevcontainerConfig type DevcontainerConfig struct { - FilePath *string `json:"filePath,omitempty"` + FilePath string `json:"filePath"` } +type _DevcontainerConfig DevcontainerConfig + // NewDevcontainerConfig instantiates a new DevcontainerConfig 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 NewDevcontainerConfig() *DevcontainerConfig { +func NewDevcontainerConfig(filePath string) *DevcontainerConfig { this := DevcontainerConfig{} + this.FilePath = filePath return &this } @@ -39,36 +44,28 @@ func NewDevcontainerConfigWithDefaults() *DevcontainerConfig { return &this } -// GetFilePath returns the FilePath field value if set, zero value otherwise. +// GetFilePath returns the FilePath field value func (o *DevcontainerConfig) GetFilePath() string { - if o == nil || IsNil(o.FilePath) { + if o == nil { var ret string return ret } - return *o.FilePath + + return o.FilePath } -// GetFilePathOk returns a tuple with the FilePath field value if set, nil otherwise +// GetFilePathOk returns a tuple with the FilePath field value // and a boolean to check if the value has been set. func (o *DevcontainerConfig) GetFilePathOk() (*string, bool) { - if o == nil || IsNil(o.FilePath) { + if o == nil { return nil, false } - return o.FilePath, true -} - -// HasFilePath returns a boolean if a field has been set. -func (o *DevcontainerConfig) HasFilePath() bool { - if o != nil && !IsNil(o.FilePath) { - return true - } - - return false + return &o.FilePath, true } -// SetFilePath gets a reference to the given string and assigns it to the FilePath field. +// SetFilePath sets field value func (o *DevcontainerConfig) SetFilePath(v string) { - o.FilePath = &v + o.FilePath = v } func (o DevcontainerConfig) MarshalJSON() ([]byte, error) { @@ -81,12 +78,47 @@ func (o DevcontainerConfig) MarshalJSON() ([]byte, error) { func (o DevcontainerConfig) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.FilePath) { - toSerialize["filePath"] = o.FilePath - } + toSerialize["filePath"] = o.FilePath return toSerialize, nil } +func (o *DevcontainerConfig) 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{ + "filePath", + } + + 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) + } + } + + varDevcontainerConfig := _DevcontainerConfig{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varDevcontainerConfig) + + if err != nil { + return err + } + + *o = DevcontainerConfig(varDevcontainerConfig) + + return err +} + type NullableDevcontainerConfig struct { value *DevcontainerConfig isSet bool diff --git a/pkg/apiclient/model_file_status.go b/pkg/apiclient/model_file_status.go index a3823002a5..02442a3283 100644 --- a/pkg/apiclient/model_file_status.go +++ b/pkg/apiclient/model_file_status.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the FileStatus type satisfies the MappedNullable interface at compile time @@ -19,18 +21,24 @@ var _ MappedNullable = &FileStatus{} // FileStatus struct for FileStatus type FileStatus struct { - Extra *string `json:"extra,omitempty"` - Name *string `json:"name,omitempty"` - Staging *Status `json:"staging,omitempty"` - Worktree *Status `json:"worktree,omitempty"` + Extra string `json:"extra"` + Name string `json:"name"` + Staging Status `json:"staging"` + Worktree Status `json:"worktree"` } +type _FileStatus FileStatus + // NewFileStatus instantiates a new FileStatus 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 NewFileStatus() *FileStatus { +func NewFileStatus(extra string, name string, staging Status, worktree Status) *FileStatus { this := FileStatus{} + this.Extra = extra + this.Name = name + this.Staging = staging + this.Worktree = worktree return &this } @@ -42,132 +50,100 @@ func NewFileStatusWithDefaults() *FileStatus { return &this } -// GetExtra returns the Extra field value if set, zero value otherwise. +// GetExtra returns the Extra field value func (o *FileStatus) GetExtra() string { - if o == nil || IsNil(o.Extra) { + if o == nil { var ret string return ret } - return *o.Extra + + return o.Extra } -// GetExtraOk returns a tuple with the Extra field value if set, nil otherwise +// GetExtraOk returns a tuple with the Extra field value // and a boolean to check if the value has been set. func (o *FileStatus) GetExtraOk() (*string, bool) { - if o == nil || IsNil(o.Extra) { + if o == nil { return nil, false } - return o.Extra, true + return &o.Extra, true } -// HasExtra returns a boolean if a field has been set. -func (o *FileStatus) HasExtra() bool { - if o != nil && !IsNil(o.Extra) { - return true - } - - return false -} - -// SetExtra gets a reference to the given string and assigns it to the Extra field. +// SetExtra sets field value func (o *FileStatus) SetExtra(v string) { - o.Extra = &v + o.Extra = v } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *FileStatus) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *FileStatus) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true -} - -// HasName returns a boolean if a field has been set. -func (o *FileStatus) HasName() bool { - if o != nil && !IsNil(o.Name) { - return true - } - - return false + return &o.Name, true } -// SetName gets a reference to the given string and assigns it to the Name field. +// SetName sets field value func (o *FileStatus) SetName(v string) { - o.Name = &v + o.Name = v } -// GetStaging returns the Staging field value if set, zero value otherwise. +// GetStaging returns the Staging field value func (o *FileStatus) GetStaging() Status { - if o == nil || IsNil(o.Staging) { + if o == nil { var ret Status return ret } - return *o.Staging + + return o.Staging } -// GetStagingOk returns a tuple with the Staging field value if set, nil otherwise +// GetStagingOk returns a tuple with the Staging field value // and a boolean to check if the value has been set. func (o *FileStatus) GetStagingOk() (*Status, bool) { - if o == nil || IsNil(o.Staging) { + if o == nil { return nil, false } - return o.Staging, true + return &o.Staging, true } -// HasStaging returns a boolean if a field has been set. -func (o *FileStatus) HasStaging() bool { - if o != nil && !IsNil(o.Staging) { - return true - } - - return false -} - -// SetStaging gets a reference to the given Status and assigns it to the Staging field. +// SetStaging sets field value func (o *FileStatus) SetStaging(v Status) { - o.Staging = &v + o.Staging = v } -// GetWorktree returns the Worktree field value if set, zero value otherwise. +// GetWorktree returns the Worktree field value func (o *FileStatus) GetWorktree() Status { - if o == nil || IsNil(o.Worktree) { + if o == nil { var ret Status return ret } - return *o.Worktree + + return o.Worktree } -// GetWorktreeOk returns a tuple with the Worktree field value if set, nil otherwise +// GetWorktreeOk returns a tuple with the Worktree field value // and a boolean to check if the value has been set. func (o *FileStatus) GetWorktreeOk() (*Status, bool) { - if o == nil || IsNil(o.Worktree) { + if o == nil { return nil, false } - return o.Worktree, true -} - -// HasWorktree returns a boolean if a field has been set. -func (o *FileStatus) HasWorktree() bool { - if o != nil && !IsNil(o.Worktree) { - return true - } - - return false + return &o.Worktree, true } -// SetWorktree gets a reference to the given Status and assigns it to the Worktree field. +// SetWorktree sets field value func (o *FileStatus) SetWorktree(v Status) { - o.Worktree = &v + o.Worktree = v } func (o FileStatus) MarshalJSON() ([]byte, error) { @@ -180,19 +156,51 @@ func (o FileStatus) MarshalJSON() ([]byte, error) { func (o FileStatus) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Extra) { - toSerialize["extra"] = o.Extra + toSerialize["extra"] = o.Extra + toSerialize["name"] = o.Name + toSerialize["staging"] = o.Staging + toSerialize["worktree"] = o.Worktree + return toSerialize, nil +} + +func (o *FileStatus) 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{ + "extra", + "name", + "staging", + "worktree", } - if !IsNil(o.Name) { - toSerialize["name"] = o.Name + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - if !IsNil(o.Staging) { - toSerialize["staging"] = o.Staging + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } } - if !IsNil(o.Worktree) { - toSerialize["worktree"] = o.Worktree + + varFileStatus := _FileStatus{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varFileStatus) + + if err != nil { + return err } - return toSerialize, nil + + *o = FileStatus(varFileStatus) + + return err } type NullableFileStatus struct { diff --git a/pkg/apiclient/model_frps_config.go b/pkg/apiclient/model_frps_config.go index 12cec3e863..53a3c93008 100644 --- a/pkg/apiclient/model_frps_config.go +++ b/pkg/apiclient/model_frps_config.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the FRPSConfig type satisfies the MappedNullable interface at compile time @@ -19,17 +21,22 @@ var _ MappedNullable = &FRPSConfig{} // FRPSConfig struct for FRPSConfig type FRPSConfig struct { - Domain *string `json:"domain,omitempty"` - Port *int32 `json:"port,omitempty"` - Protocol *string `json:"protocol,omitempty"` + Domain string `json:"domain"` + Port int32 `json:"port"` + Protocol string `json:"protocol"` } +type _FRPSConfig FRPSConfig + // NewFRPSConfig instantiates a new FRPSConfig 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 NewFRPSConfig() *FRPSConfig { +func NewFRPSConfig(domain string, port int32, protocol string) *FRPSConfig { this := FRPSConfig{} + this.Domain = domain + this.Port = port + this.Protocol = protocol return &this } @@ -41,100 +48,76 @@ func NewFRPSConfigWithDefaults() *FRPSConfig { return &this } -// GetDomain returns the Domain field value if set, zero value otherwise. +// GetDomain returns the Domain field value func (o *FRPSConfig) GetDomain() string { - if o == nil || IsNil(o.Domain) { + if o == nil { var ret string return ret } - return *o.Domain + + return o.Domain } -// GetDomainOk returns a tuple with the Domain field value if set, nil otherwise +// GetDomainOk returns a tuple with the Domain field value // and a boolean to check if the value has been set. func (o *FRPSConfig) GetDomainOk() (*string, bool) { - if o == nil || IsNil(o.Domain) { + if o == nil { return nil, false } - return o.Domain, true -} - -// HasDomain returns a boolean if a field has been set. -func (o *FRPSConfig) HasDomain() bool { - if o != nil && !IsNil(o.Domain) { - return true - } - - return false + return &o.Domain, true } -// SetDomain gets a reference to the given string and assigns it to the Domain field. +// SetDomain sets field value func (o *FRPSConfig) SetDomain(v string) { - o.Domain = &v + o.Domain = v } -// GetPort returns the Port field value if set, zero value otherwise. +// GetPort returns the Port field value func (o *FRPSConfig) GetPort() int32 { - if o == nil || IsNil(o.Port) { + if o == nil { var ret int32 return ret } - return *o.Port + + return o.Port } -// GetPortOk returns a tuple with the Port field value if set, nil otherwise +// GetPortOk returns a tuple with the Port field value // and a boolean to check if the value has been set. func (o *FRPSConfig) GetPortOk() (*int32, bool) { - if o == nil || IsNil(o.Port) { + if o == nil { return nil, false } - return o.Port, true -} - -// HasPort returns a boolean if a field has been set. -func (o *FRPSConfig) HasPort() bool { - if o != nil && !IsNil(o.Port) { - return true - } - - return false + return &o.Port, true } -// SetPort gets a reference to the given int32 and assigns it to the Port field. +// SetPort sets field value func (o *FRPSConfig) SetPort(v int32) { - o.Port = &v + o.Port = v } -// GetProtocol returns the Protocol field value if set, zero value otherwise. +// GetProtocol returns the Protocol field value func (o *FRPSConfig) GetProtocol() string { - if o == nil || IsNil(o.Protocol) { + if o == nil { var ret string return ret } - return *o.Protocol + + return o.Protocol } -// GetProtocolOk returns a tuple with the Protocol field value if set, nil otherwise +// GetProtocolOk returns a tuple with the Protocol field value // and a boolean to check if the value has been set. func (o *FRPSConfig) GetProtocolOk() (*string, bool) { - if o == nil || IsNil(o.Protocol) { + if o == nil { return nil, false } - return o.Protocol, true -} - -// HasProtocol returns a boolean if a field has been set. -func (o *FRPSConfig) HasProtocol() bool { - if o != nil && !IsNil(o.Protocol) { - return true - } - - return false + return &o.Protocol, true } -// SetProtocol gets a reference to the given string and assigns it to the Protocol field. +// SetProtocol sets field value func (o *FRPSConfig) SetProtocol(v string) { - o.Protocol = &v + o.Protocol = v } func (o FRPSConfig) MarshalJSON() ([]byte, error) { @@ -147,16 +130,49 @@ func (o FRPSConfig) MarshalJSON() ([]byte, error) { func (o FRPSConfig) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Domain) { - toSerialize["domain"] = o.Domain + toSerialize["domain"] = o.Domain + toSerialize["port"] = o.Port + toSerialize["protocol"] = o.Protocol + return toSerialize, nil +} + +func (o *FRPSConfig) 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{ + "domain", + "port", + "protocol", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - if !IsNil(o.Port) { - toSerialize["port"] = o.Port + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } } - if !IsNil(o.Protocol) { - toSerialize["protocol"] = o.Protocol + + varFRPSConfig := _FRPSConfig{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varFRPSConfig) + + if err != nil { + return err } - return toSerialize, nil + + *o = FRPSConfig(varFRPSConfig) + + return err } type NullableFRPSConfig struct { diff --git a/pkg/apiclient/model_git_branch.go b/pkg/apiclient/model_git_branch.go index c28f9769a9..f66681326b 100644 --- a/pkg/apiclient/model_git_branch.go +++ b/pkg/apiclient/model_git_branch.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the GitBranch type satisfies the MappedNullable interface at compile time @@ -19,16 +21,20 @@ var _ MappedNullable = &GitBranch{} // GitBranch struct for GitBranch type GitBranch struct { - Name *string `json:"name,omitempty"` - Sha *string `json:"sha,omitempty"` + Name string `json:"name"` + Sha string `json:"sha"` } +type _GitBranch GitBranch + // NewGitBranch instantiates a new GitBranch 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 NewGitBranch() *GitBranch { +func NewGitBranch(name string, sha string) *GitBranch { this := GitBranch{} + this.Name = name + this.Sha = sha return &this } @@ -40,68 +46,52 @@ func NewGitBranchWithDefaults() *GitBranch { return &this } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *GitBranch) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *GitBranch) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true + return &o.Name, true } -// HasName returns a boolean if a field has been set. -func (o *GitBranch) 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. +// SetName sets field value func (o *GitBranch) SetName(v string) { - o.Name = &v + o.Name = v } -// GetSha returns the Sha field value if set, zero value otherwise. +// GetSha returns the Sha field value func (o *GitBranch) GetSha() string { - if o == nil || IsNil(o.Sha) { + if o == nil { var ret string return ret } - return *o.Sha + + return o.Sha } -// GetShaOk returns a tuple with the Sha field value if set, nil otherwise +// GetShaOk returns a tuple with the Sha field value // and a boolean to check if the value has been set. func (o *GitBranch) GetShaOk() (*string, bool) { - if o == nil || IsNil(o.Sha) { + if o == nil { return nil, false } - return o.Sha, true + return &o.Sha, true } -// HasSha returns a boolean if a field has been set. -func (o *GitBranch) HasSha() bool { - if o != nil && !IsNil(o.Sha) { - return true - } - - return false -} - -// SetSha gets a reference to the given string and assigns it to the Sha field. +// SetSha sets field value func (o *GitBranch) SetSha(v string) { - o.Sha = &v + o.Sha = v } func (o GitBranch) MarshalJSON() ([]byte, error) { @@ -114,13 +104,47 @@ func (o GitBranch) MarshalJSON() ([]byte, error) { func (o GitBranch) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Name) { - toSerialize["name"] = o.Name + toSerialize["name"] = o.Name + toSerialize["sha"] = o.Sha + return toSerialize, nil +} + +func (o *GitBranch) 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", + "sha", } - if !IsNil(o.Sha) { - toSerialize["sha"] = o.Sha + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - return toSerialize, nil + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varGitBranch := _GitBranch{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varGitBranch) + + if err != nil { + return err + } + + *o = GitBranch(varGitBranch) + + return err } type NullableGitBranch struct { diff --git a/pkg/apiclient/model_git_namespace.go b/pkg/apiclient/model_git_namespace.go index ab5fb30005..86b79b2df4 100644 --- a/pkg/apiclient/model_git_namespace.go +++ b/pkg/apiclient/model_git_namespace.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the GitNamespace type satisfies the MappedNullable interface at compile time @@ -19,16 +21,20 @@ var _ MappedNullable = &GitNamespace{} // GitNamespace struct for GitNamespace type GitNamespace struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` + Id string `json:"id"` + Name string `json:"name"` } +type _GitNamespace GitNamespace + // NewGitNamespace instantiates a new GitNamespace 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 NewGitNamespace() *GitNamespace { +func NewGitNamespace(id string, name string) *GitNamespace { this := GitNamespace{} + this.Id = id + this.Name = name return &this } @@ -40,68 +46,52 @@ func NewGitNamespaceWithDefaults() *GitNamespace { return &this } -// GetId returns the Id field value if set, zero value otherwise. +// GetId returns the Id field value func (o *GitNamespace) GetId() string { - if o == nil || IsNil(o.Id) { + if o == nil { var ret string return ret } - return *o.Id + + return o.Id } -// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// GetIdOk returns a tuple with the Id field value // and a boolean to check if the value has been set. func (o *GitNamespace) GetIdOk() (*string, bool) { - if o == nil || IsNil(o.Id) { + if o == nil { return nil, false } - return o.Id, true + return &o.Id, true } -// HasId returns a boolean if a field has been set. -func (o *GitNamespace) HasId() bool { - if o != nil && !IsNil(o.Id) { - return true - } - - return false -} - -// SetId gets a reference to the given string and assigns it to the Id field. +// SetId sets field value func (o *GitNamespace) SetId(v string) { - o.Id = &v + o.Id = v } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *GitNamespace) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *GitNamespace) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true + return &o.Name, true } -// HasName returns a boolean if a field has been set. -func (o *GitNamespace) 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. +// SetName sets field value func (o *GitNamespace) SetName(v string) { - o.Name = &v + o.Name = v } func (o GitNamespace) MarshalJSON() ([]byte, error) { @@ -114,13 +104,47 @@ func (o GitNamespace) MarshalJSON() ([]byte, error) { func (o GitNamespace) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Id) { - toSerialize["id"] = o.Id + toSerialize["id"] = o.Id + toSerialize["name"] = o.Name + return toSerialize, nil +} + +func (o *GitNamespace) 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", + "name", } - if !IsNil(o.Name) { - toSerialize["name"] = o.Name + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - return toSerialize, nil + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varGitNamespace := _GitNamespace{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varGitNamespace) + + if err != nil { + return err + } + + *o = GitNamespace(varGitNamespace) + + return err } type NullableGitNamespace struct { diff --git a/pkg/apiclient/model_git_provider.go b/pkg/apiclient/model_git_provider.go index 7e539ea35c..f4af818674 100644 --- a/pkg/apiclient/model_git_provider.go +++ b/pkg/apiclient/model_git_provider.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the GitProvider type satisfies the MappedNullable interface at compile time @@ -20,17 +22,22 @@ var _ MappedNullable = &GitProvider{} // GitProvider struct for GitProvider type GitProvider struct { BaseApiUrl *string `json:"baseApiUrl,omitempty"` - Id *string `json:"id,omitempty"` - Token *string `json:"token,omitempty"` - Username *string `json:"username,omitempty"` + Id string `json:"id"` + Token string `json:"token"` + Username string `json:"username"` } +type _GitProvider GitProvider + // NewGitProvider instantiates a new GitProvider 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 NewGitProvider() *GitProvider { +func NewGitProvider(id string, token string, username string) *GitProvider { this := GitProvider{} + this.Id = id + this.Token = token + this.Username = username return &this } @@ -74,100 +81,76 @@ func (o *GitProvider) SetBaseApiUrl(v string) { o.BaseApiUrl = &v } -// GetId returns the Id field value if set, zero value otherwise. +// GetId returns the Id field value func (o *GitProvider) GetId() string { - if o == nil || IsNil(o.Id) { + if o == nil { var ret string return ret } - return *o.Id + + return o.Id } -// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// GetIdOk returns a tuple with the Id field value // and a boolean to check if the value has been set. func (o *GitProvider) GetIdOk() (*string, bool) { - if o == nil || IsNil(o.Id) { + if o == nil { return nil, false } - return o.Id, true -} - -// HasId returns a boolean if a field has been set. -func (o *GitProvider) HasId() bool { - if o != nil && !IsNil(o.Id) { - return true - } - - return false + return &o.Id, true } -// SetId gets a reference to the given string and assigns it to the Id field. +// SetId sets field value func (o *GitProvider) SetId(v string) { - o.Id = &v + o.Id = v } -// GetToken returns the Token field value if set, zero value otherwise. +// GetToken returns the Token field value func (o *GitProvider) GetToken() string { - if o == nil || IsNil(o.Token) { + if o == nil { var ret string return ret } - return *o.Token + + return o.Token } -// GetTokenOk returns a tuple with the Token field value if set, nil otherwise +// GetTokenOk returns a tuple with the Token field value // and a boolean to check if the value has been set. func (o *GitProvider) GetTokenOk() (*string, bool) { - if o == nil || IsNil(o.Token) { + if o == nil { return nil, false } - return o.Token, true + return &o.Token, true } -// HasToken returns a boolean if a field has been set. -func (o *GitProvider) HasToken() bool { - if o != nil && !IsNil(o.Token) { - return true - } - - return false -} - -// SetToken gets a reference to the given string and assigns it to the Token field. +// SetToken sets field value func (o *GitProvider) SetToken(v string) { - o.Token = &v + o.Token = v } -// GetUsername returns the Username field value if set, zero value otherwise. +// GetUsername returns the Username field value func (o *GitProvider) GetUsername() string { - if o == nil || IsNil(o.Username) { + if o == nil { var ret string return ret } - return *o.Username + + return o.Username } -// GetUsernameOk returns a tuple with the Username field value if set, nil otherwise +// GetUsernameOk returns a tuple with the Username field value // and a boolean to check if the value has been set. func (o *GitProvider) GetUsernameOk() (*string, bool) { - if o == nil || IsNil(o.Username) { + if o == nil { return nil, false } - return o.Username, true -} - -// HasUsername returns a boolean if a field has been set. -func (o *GitProvider) HasUsername() bool { - if o != nil && !IsNil(o.Username) { - return true - } - - return false + return &o.Username, true } -// SetUsername gets a reference to the given string and assigns it to the Username field. +// SetUsername sets field value func (o *GitProvider) SetUsername(v string) { - o.Username = &v + o.Username = v } func (o GitProvider) MarshalJSON() ([]byte, error) { @@ -183,16 +166,49 @@ func (o GitProvider) ToMap() (map[string]interface{}, error) { if !IsNil(o.BaseApiUrl) { toSerialize["baseApiUrl"] = o.BaseApiUrl } - if !IsNil(o.Id) { - toSerialize["id"] = o.Id + toSerialize["id"] = o.Id + toSerialize["token"] = o.Token + toSerialize["username"] = o.Username + return toSerialize, nil +} + +func (o *GitProvider) 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", + "token", + "username", } - if !IsNil(o.Token) { - toSerialize["token"] = o.Token + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - if !IsNil(o.Username) { - toSerialize["username"] = o.Username + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } } - return toSerialize, nil + + varGitProvider := _GitProvider{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varGitProvider) + + if err != nil { + return err + } + + *o = GitProvider(varGitProvider) + + return err } type NullableGitProvider struct { diff --git a/pkg/apiclient/model_git_pull_request.go b/pkg/apiclient/model_git_pull_request.go index 28dbc77650..c13416a442 100644 --- a/pkg/apiclient/model_git_pull_request.go +++ b/pkg/apiclient/model_git_pull_request.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the GitPullRequest type satisfies the MappedNullable interface at compile time @@ -19,21 +21,30 @@ var _ MappedNullable = &GitPullRequest{} // GitPullRequest struct for GitPullRequest type GitPullRequest struct { - Branch *string `json:"branch,omitempty"` - Name *string `json:"name,omitempty"` - Sha *string `json:"sha,omitempty"` - SourceRepoId *string `json:"sourceRepoId,omitempty"` - SourceRepoName *string `json:"sourceRepoName,omitempty"` - SourceRepoOwner *string `json:"sourceRepoOwner,omitempty"` - SourceRepoUrl *string `json:"sourceRepoUrl,omitempty"` + Branch string `json:"branch"` + Name string `json:"name"` + Sha string `json:"sha"` + SourceRepoId string `json:"sourceRepoId"` + SourceRepoName string `json:"sourceRepoName"` + SourceRepoOwner string `json:"sourceRepoOwner"` + SourceRepoUrl string `json:"sourceRepoUrl"` } +type _GitPullRequest GitPullRequest + // NewGitPullRequest instantiates a new GitPullRequest 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 NewGitPullRequest() *GitPullRequest { +func NewGitPullRequest(branch string, name string, sha string, sourceRepoId string, sourceRepoName string, sourceRepoOwner string, sourceRepoUrl string) *GitPullRequest { this := GitPullRequest{} + this.Branch = branch + this.Name = name + this.Sha = sha + this.SourceRepoId = sourceRepoId + this.SourceRepoName = sourceRepoName + this.SourceRepoOwner = sourceRepoOwner + this.SourceRepoUrl = sourceRepoUrl return &this } @@ -45,228 +56,172 @@ func NewGitPullRequestWithDefaults() *GitPullRequest { return &this } -// GetBranch returns the Branch field value if set, zero value otherwise. +// GetBranch returns the Branch field value func (o *GitPullRequest) GetBranch() string { - if o == nil || IsNil(o.Branch) { + if o == nil { var ret string return ret } - return *o.Branch + + return o.Branch } -// GetBranchOk returns a tuple with the Branch field value if set, nil otherwise +// GetBranchOk returns a tuple with the Branch field value // and a boolean to check if the value has been set. func (o *GitPullRequest) GetBranchOk() (*string, bool) { - if o == nil || IsNil(o.Branch) { + if o == nil { return nil, false } - return o.Branch, true + return &o.Branch, true } -// HasBranch returns a boolean if a field has been set. -func (o *GitPullRequest) HasBranch() bool { - if o != nil && !IsNil(o.Branch) { - return true - } - - return false -} - -// SetBranch gets a reference to the given string and assigns it to the Branch field. +// SetBranch sets field value func (o *GitPullRequest) SetBranch(v string) { - o.Branch = &v + o.Branch = v } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *GitPullRequest) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *GitPullRequest) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true + return &o.Name, true } -// HasName returns a boolean if a field has been set. -func (o *GitPullRequest) 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. +// SetName sets field value func (o *GitPullRequest) SetName(v string) { - o.Name = &v + o.Name = v } -// GetSha returns the Sha field value if set, zero value otherwise. +// GetSha returns the Sha field value func (o *GitPullRequest) GetSha() string { - if o == nil || IsNil(o.Sha) { + if o == nil { var ret string return ret } - return *o.Sha + + return o.Sha } -// GetShaOk returns a tuple with the Sha field value if set, nil otherwise +// GetShaOk returns a tuple with the Sha field value // and a boolean to check if the value has been set. func (o *GitPullRequest) GetShaOk() (*string, bool) { - if o == nil || IsNil(o.Sha) { + if o == nil { return nil, false } - return o.Sha, true + return &o.Sha, true } -// HasSha returns a boolean if a field has been set. -func (o *GitPullRequest) HasSha() bool { - if o != nil && !IsNil(o.Sha) { - return true - } - - return false -} - -// SetSha gets a reference to the given string and assigns it to the Sha field. +// SetSha sets field value func (o *GitPullRequest) SetSha(v string) { - o.Sha = &v + o.Sha = v } -// GetSourceRepoId returns the SourceRepoId field value if set, zero value otherwise. +// GetSourceRepoId returns the SourceRepoId field value func (o *GitPullRequest) GetSourceRepoId() string { - if o == nil || IsNil(o.SourceRepoId) { + if o == nil { var ret string return ret } - return *o.SourceRepoId + + return o.SourceRepoId } -// GetSourceRepoIdOk returns a tuple with the SourceRepoId field value if set, nil otherwise +// GetSourceRepoIdOk returns a tuple with the SourceRepoId field value // and a boolean to check if the value has been set. func (o *GitPullRequest) GetSourceRepoIdOk() (*string, bool) { - if o == nil || IsNil(o.SourceRepoId) { + if o == nil { return nil, false } - return o.SourceRepoId, true -} - -// HasSourceRepoId returns a boolean if a field has been set. -func (o *GitPullRequest) HasSourceRepoId() bool { - if o != nil && !IsNil(o.SourceRepoId) { - return true - } - - return false + return &o.SourceRepoId, true } -// SetSourceRepoId gets a reference to the given string and assigns it to the SourceRepoId field. +// SetSourceRepoId sets field value func (o *GitPullRequest) SetSourceRepoId(v string) { - o.SourceRepoId = &v + o.SourceRepoId = v } -// GetSourceRepoName returns the SourceRepoName field value if set, zero value otherwise. +// GetSourceRepoName returns the SourceRepoName field value func (o *GitPullRequest) GetSourceRepoName() string { - if o == nil || IsNil(o.SourceRepoName) { + if o == nil { var ret string return ret } - return *o.SourceRepoName + + return o.SourceRepoName } -// GetSourceRepoNameOk returns a tuple with the SourceRepoName field value if set, nil otherwise +// GetSourceRepoNameOk returns a tuple with the SourceRepoName field value // and a boolean to check if the value has been set. func (o *GitPullRequest) GetSourceRepoNameOk() (*string, bool) { - if o == nil || IsNil(o.SourceRepoName) { + if o == nil { return nil, false } - return o.SourceRepoName, true -} - -// HasSourceRepoName returns a boolean if a field has been set. -func (o *GitPullRequest) HasSourceRepoName() bool { - if o != nil && !IsNil(o.SourceRepoName) { - return true - } - - return false + return &o.SourceRepoName, true } -// SetSourceRepoName gets a reference to the given string and assigns it to the SourceRepoName field. +// SetSourceRepoName sets field value func (o *GitPullRequest) SetSourceRepoName(v string) { - o.SourceRepoName = &v + o.SourceRepoName = v } -// GetSourceRepoOwner returns the SourceRepoOwner field value if set, zero value otherwise. +// GetSourceRepoOwner returns the SourceRepoOwner field value func (o *GitPullRequest) GetSourceRepoOwner() string { - if o == nil || IsNil(o.SourceRepoOwner) { + if o == nil { var ret string return ret } - return *o.SourceRepoOwner + + return o.SourceRepoOwner } -// GetSourceRepoOwnerOk returns a tuple with the SourceRepoOwner field value if set, nil otherwise +// GetSourceRepoOwnerOk returns a tuple with the SourceRepoOwner field value // and a boolean to check if the value has been set. func (o *GitPullRequest) GetSourceRepoOwnerOk() (*string, bool) { - if o == nil || IsNil(o.SourceRepoOwner) { + if o == nil { return nil, false } - return o.SourceRepoOwner, true + return &o.SourceRepoOwner, true } -// HasSourceRepoOwner returns a boolean if a field has been set. -func (o *GitPullRequest) HasSourceRepoOwner() bool { - if o != nil && !IsNil(o.SourceRepoOwner) { - return true - } - - return false -} - -// SetSourceRepoOwner gets a reference to the given string and assigns it to the SourceRepoOwner field. +// SetSourceRepoOwner sets field value func (o *GitPullRequest) SetSourceRepoOwner(v string) { - o.SourceRepoOwner = &v + o.SourceRepoOwner = v } -// GetSourceRepoUrl returns the SourceRepoUrl field value if set, zero value otherwise. +// GetSourceRepoUrl returns the SourceRepoUrl field value func (o *GitPullRequest) GetSourceRepoUrl() string { - if o == nil || IsNil(o.SourceRepoUrl) { + if o == nil { var ret string return ret } - return *o.SourceRepoUrl + + return o.SourceRepoUrl } -// GetSourceRepoUrlOk returns a tuple with the SourceRepoUrl field value if set, nil otherwise +// GetSourceRepoUrlOk returns a tuple with the SourceRepoUrl field value // and a boolean to check if the value has been set. func (o *GitPullRequest) GetSourceRepoUrlOk() (*string, bool) { - if o == nil || IsNil(o.SourceRepoUrl) { + if o == nil { return nil, false } - return o.SourceRepoUrl, true -} - -// HasSourceRepoUrl returns a boolean if a field has been set. -func (o *GitPullRequest) HasSourceRepoUrl() bool { - if o != nil && !IsNil(o.SourceRepoUrl) { - return true - } - - return false + return &o.SourceRepoUrl, true } -// SetSourceRepoUrl gets a reference to the given string and assigns it to the SourceRepoUrl field. +// SetSourceRepoUrl sets field value func (o *GitPullRequest) SetSourceRepoUrl(v string) { - o.SourceRepoUrl = &v + o.SourceRepoUrl = v } func (o GitPullRequest) MarshalJSON() ([]byte, error) { @@ -279,28 +234,57 @@ func (o GitPullRequest) MarshalJSON() ([]byte, error) { func (o GitPullRequest) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Branch) { - toSerialize["branch"] = o.Branch - } - if !IsNil(o.Name) { - toSerialize["name"] = o.Name - } - if !IsNil(o.Sha) { - toSerialize["sha"] = o.Sha - } - if !IsNil(o.SourceRepoId) { - toSerialize["sourceRepoId"] = o.SourceRepoId + toSerialize["branch"] = o.Branch + toSerialize["name"] = o.Name + toSerialize["sha"] = o.Sha + toSerialize["sourceRepoId"] = o.SourceRepoId + toSerialize["sourceRepoName"] = o.SourceRepoName + toSerialize["sourceRepoOwner"] = o.SourceRepoOwner + toSerialize["sourceRepoUrl"] = o.SourceRepoUrl + return toSerialize, nil +} + +func (o *GitPullRequest) 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{ + "branch", + "name", + "sha", + "sourceRepoId", + "sourceRepoName", + "sourceRepoOwner", + "sourceRepoUrl", } - if !IsNil(o.SourceRepoName) { - toSerialize["sourceRepoName"] = o.SourceRepoName + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - if !IsNil(o.SourceRepoOwner) { - toSerialize["sourceRepoOwner"] = o.SourceRepoOwner + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } } - if !IsNil(o.SourceRepoUrl) { - toSerialize["sourceRepoUrl"] = o.SourceRepoUrl + + varGitPullRequest := _GitPullRequest{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varGitPullRequest) + + if err != nil { + return err } - return toSerialize, nil + + *o = GitPullRequest(varGitPullRequest) + + return err } type NullableGitPullRequest struct { diff --git a/pkg/apiclient/model_git_repository.go b/pkg/apiclient/model_git_repository.go index fdc1feecaf..5bc13c6c17 100644 --- a/pkg/apiclient/model_git_repository.go +++ b/pkg/apiclient/model_git_repository.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the GitRepository type satisfies the MappedNullable interface at compile time @@ -20,22 +22,30 @@ var _ MappedNullable = &GitRepository{} // GitRepository struct for GitRepository type GitRepository struct { Branch *string `json:"branch,omitempty"` - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Owner *string `json:"owner,omitempty"` + Id string `json:"id"` + Name string `json:"name"` + Owner string `json:"owner"` Path *string `json:"path,omitempty"` PrNumber *int32 `json:"prNumber,omitempty"` - Sha *string `json:"sha,omitempty"` - Source *string `json:"source,omitempty"` - Url *string `json:"url,omitempty"` + Sha string `json:"sha"` + Source string `json:"source"` + Url string `json:"url"` } +type _GitRepository GitRepository + // NewGitRepository instantiates a new GitRepository 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 NewGitRepository() *GitRepository { +func NewGitRepository(id string, name string, owner string, sha string, source string, url string) *GitRepository { this := GitRepository{} + this.Id = id + this.Name = name + this.Owner = owner + this.Sha = sha + this.Source = source + this.Url = url return &this } @@ -79,100 +89,76 @@ func (o *GitRepository) SetBranch(v string) { o.Branch = &v } -// GetId returns the Id field value if set, zero value otherwise. +// GetId returns the Id field value func (o *GitRepository) GetId() string { - if o == nil || IsNil(o.Id) { + if o == nil { var ret string return ret } - return *o.Id + + return o.Id } -// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// GetIdOk returns a tuple with the Id field value // and a boolean to check if the value has been set. func (o *GitRepository) GetIdOk() (*string, bool) { - if o == nil || IsNil(o.Id) { + if o == nil { return nil, false } - return o.Id, true -} - -// HasId returns a boolean if a field has been set. -func (o *GitRepository) HasId() bool { - if o != nil && !IsNil(o.Id) { - return true - } - - return false + return &o.Id, true } -// SetId gets a reference to the given string and assigns it to the Id field. +// SetId sets field value func (o *GitRepository) SetId(v string) { - o.Id = &v + o.Id = v } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *GitRepository) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *GitRepository) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true -} - -// HasName returns a boolean if a field has been set. -func (o *GitRepository) HasName() bool { - if o != nil && !IsNil(o.Name) { - return true - } - - return false + return &o.Name, true } -// SetName gets a reference to the given string and assigns it to the Name field. +// SetName sets field value func (o *GitRepository) SetName(v string) { - o.Name = &v + o.Name = v } -// GetOwner returns the Owner field value if set, zero value otherwise. +// GetOwner returns the Owner field value func (o *GitRepository) GetOwner() string { - if o == nil || IsNil(o.Owner) { + if o == nil { var ret string return ret } - return *o.Owner + + return o.Owner } -// GetOwnerOk returns a tuple with the Owner field value if set, nil otherwise +// GetOwnerOk returns a tuple with the Owner field value // and a boolean to check if the value has been set. func (o *GitRepository) GetOwnerOk() (*string, bool) { - if o == nil || IsNil(o.Owner) { + if o == nil { return nil, false } - return o.Owner, true + return &o.Owner, true } -// HasOwner returns a boolean if a field has been set. -func (o *GitRepository) HasOwner() bool { - if o != nil && !IsNil(o.Owner) { - return true - } - - return false -} - -// SetOwner gets a reference to the given string and assigns it to the Owner field. +// SetOwner sets field value func (o *GitRepository) SetOwner(v string) { - o.Owner = &v + o.Owner = v } // GetPath returns the Path field value if set, zero value otherwise. @@ -239,100 +225,76 @@ func (o *GitRepository) SetPrNumber(v int32) { o.PrNumber = &v } -// GetSha returns the Sha field value if set, zero value otherwise. +// GetSha returns the Sha field value func (o *GitRepository) GetSha() string { - if o == nil || IsNil(o.Sha) { + if o == nil { var ret string return ret } - return *o.Sha + + return o.Sha } -// GetShaOk returns a tuple with the Sha field value if set, nil otherwise +// GetShaOk returns a tuple with the Sha field value // and a boolean to check if the value has been set. func (o *GitRepository) GetShaOk() (*string, bool) { - if o == nil || IsNil(o.Sha) { + if o == nil { return nil, false } - return o.Sha, true + return &o.Sha, true } -// HasSha returns a boolean if a field has been set. -func (o *GitRepository) HasSha() bool { - if o != nil && !IsNil(o.Sha) { - return true - } - - return false -} - -// SetSha gets a reference to the given string and assigns it to the Sha field. +// SetSha sets field value func (o *GitRepository) SetSha(v string) { - o.Sha = &v + o.Sha = v } -// GetSource returns the Source field value if set, zero value otherwise. +// GetSource returns the Source field value func (o *GitRepository) GetSource() string { - if o == nil || IsNil(o.Source) { + if o == nil { var ret string return ret } - return *o.Source + + return o.Source } -// GetSourceOk returns a tuple with the Source field value if set, nil otherwise +// GetSourceOk returns a tuple with the Source field value // and a boolean to check if the value has been set. func (o *GitRepository) GetSourceOk() (*string, bool) { - if o == nil || IsNil(o.Source) { + if o == nil { return nil, false } - return o.Source, true -} - -// HasSource returns a boolean if a field has been set. -func (o *GitRepository) HasSource() bool { - if o != nil && !IsNil(o.Source) { - return true - } - - return false + return &o.Source, true } -// SetSource gets a reference to the given string and assigns it to the Source field. +// SetSource sets field value func (o *GitRepository) SetSource(v string) { - o.Source = &v + o.Source = v } -// GetUrl returns the Url field value if set, zero value otherwise. +// GetUrl returns the Url field value func (o *GitRepository) GetUrl() string { - if o == nil || IsNil(o.Url) { + if o == nil { var ret string return ret } - return *o.Url + + return o.Url } -// GetUrlOk returns a tuple with the Url field value if set, nil otherwise +// GetUrlOk returns a tuple with the Url field value // and a boolean to check if the value has been set. func (o *GitRepository) GetUrlOk() (*string, bool) { - if o == nil || IsNil(o.Url) { + if o == nil { return nil, false } - return o.Url, true -} - -// HasUrl returns a boolean if a field has been set. -func (o *GitRepository) HasUrl() bool { - if o != nil && !IsNil(o.Url) { - return true - } - - return false + return &o.Url, true } -// SetUrl gets a reference to the given string and assigns it to the Url field. +// SetUrl sets field value func (o *GitRepository) SetUrl(v string) { - o.Url = &v + o.Url = v } func (o GitRepository) MarshalJSON() ([]byte, error) { @@ -348,31 +310,61 @@ func (o GitRepository) ToMap() (map[string]interface{}, error) { if !IsNil(o.Branch) { toSerialize["branch"] = o.Branch } - if !IsNil(o.Id) { - toSerialize["id"] = o.Id - } - if !IsNil(o.Name) { - toSerialize["name"] = o.Name - } - if !IsNil(o.Owner) { - toSerialize["owner"] = o.Owner - } + toSerialize["id"] = o.Id + toSerialize["name"] = o.Name + toSerialize["owner"] = o.Owner if !IsNil(o.Path) { toSerialize["path"] = o.Path } if !IsNil(o.PrNumber) { toSerialize["prNumber"] = o.PrNumber } - if !IsNil(o.Sha) { - toSerialize["sha"] = o.Sha + toSerialize["sha"] = o.Sha + toSerialize["source"] = o.Source + toSerialize["url"] = o.Url + return toSerialize, nil +} + +func (o *GitRepository) 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", + "name", + "owner", + "sha", + "source", + "url", } - if !IsNil(o.Source) { - toSerialize["source"] = o.Source + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - if !IsNil(o.Url) { - toSerialize["url"] = o.Url + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } } - return toSerialize, nil + + varGitRepository := _GitRepository{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varGitRepository) + + if err != nil { + return err + } + + *o = GitRepository(varGitRepository) + + return err } type NullableGitRepository struct { diff --git a/pkg/apiclient/model_git_status.go b/pkg/apiclient/model_git_status.go index 31b87e0782..f91ee1dc94 100644 --- a/pkg/apiclient/model_git_status.go +++ b/pkg/apiclient/model_git_status.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the GitStatus type satisfies the MappedNullable interface at compile time @@ -19,16 +21,20 @@ var _ MappedNullable = &GitStatus{} // GitStatus struct for GitStatus type GitStatus struct { - CurrentBranch *string `json:"currentBranch,omitempty"` - FileStatus []FileStatus `json:"fileStatus,omitempty"` + CurrentBranch string `json:"currentBranch"` + FileStatus []FileStatus `json:"fileStatus"` } +type _GitStatus GitStatus + // NewGitStatus instantiates a new GitStatus 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 NewGitStatus() *GitStatus { +func NewGitStatus(currentBranch string, fileStatus []FileStatus) *GitStatus { this := GitStatus{} + this.CurrentBranch = currentBranch + this.FileStatus = fileStatus return &this } @@ -40,66 +46,50 @@ func NewGitStatusWithDefaults() *GitStatus { return &this } -// GetCurrentBranch returns the CurrentBranch field value if set, zero value otherwise. +// GetCurrentBranch returns the CurrentBranch field value func (o *GitStatus) GetCurrentBranch() string { - if o == nil || IsNil(o.CurrentBranch) { + if o == nil { var ret string return ret } - return *o.CurrentBranch + + return o.CurrentBranch } -// GetCurrentBranchOk returns a tuple with the CurrentBranch field value if set, nil otherwise +// GetCurrentBranchOk returns a tuple with the CurrentBranch field value // and a boolean to check if the value has been set. func (o *GitStatus) GetCurrentBranchOk() (*string, bool) { - if o == nil || IsNil(o.CurrentBranch) { + if o == nil { return nil, false } - return o.CurrentBranch, true + return &o.CurrentBranch, true } -// HasCurrentBranch returns a boolean if a field has been set. -func (o *GitStatus) HasCurrentBranch() bool { - if o != nil && !IsNil(o.CurrentBranch) { - return true - } - - return false -} - -// SetCurrentBranch gets a reference to the given string and assigns it to the CurrentBranch field. +// SetCurrentBranch sets field value func (o *GitStatus) SetCurrentBranch(v string) { - o.CurrentBranch = &v + o.CurrentBranch = v } -// GetFileStatus returns the FileStatus field value if set, zero value otherwise. +// GetFileStatus returns the FileStatus field value func (o *GitStatus) GetFileStatus() []FileStatus { - if o == nil || IsNil(o.FileStatus) { + if o == nil { var ret []FileStatus return ret } + return o.FileStatus } -// GetFileStatusOk returns a tuple with the FileStatus field value if set, nil otherwise +// GetFileStatusOk returns a tuple with the FileStatus field value // and a boolean to check if the value has been set. func (o *GitStatus) GetFileStatusOk() ([]FileStatus, bool) { - if o == nil || IsNil(o.FileStatus) { + if o == nil { return nil, false } return o.FileStatus, true } -// HasFileStatus returns a boolean if a field has been set. -func (o *GitStatus) HasFileStatus() bool { - if o != nil && !IsNil(o.FileStatus) { - return true - } - - return false -} - -// SetFileStatus gets a reference to the given []FileStatus and assigns it to the FileStatus field. +// SetFileStatus sets field value func (o *GitStatus) SetFileStatus(v []FileStatus) { o.FileStatus = v } @@ -114,13 +104,47 @@ func (o GitStatus) MarshalJSON() ([]byte, error) { func (o GitStatus) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.CurrentBranch) { - toSerialize["currentBranch"] = o.CurrentBranch + toSerialize["currentBranch"] = o.CurrentBranch + toSerialize["fileStatus"] = o.FileStatus + return toSerialize, nil +} + +func (o *GitStatus) 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{ + "currentBranch", + "fileStatus", } - if !IsNil(o.FileStatus) { - toSerialize["fileStatus"] = o.FileStatus + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - return toSerialize, nil + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varGitStatus := _GitStatus{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varGitStatus) + + if err != nil { + return err + } + + *o = GitStatus(varGitStatus) + + return err } type NullableGitStatus struct { diff --git a/pkg/apiclient/model_git_user.go b/pkg/apiclient/model_git_user.go index d04d35288c..cdbcc33953 100644 --- a/pkg/apiclient/model_git_user.go +++ b/pkg/apiclient/model_git_user.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the GitUser type satisfies the MappedNullable interface at compile time @@ -19,18 +21,24 @@ var _ MappedNullable = &GitUser{} // GitUser struct for GitUser type GitUser struct { - Email *string `json:"email,omitempty"` - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Username *string `json:"username,omitempty"` + Email string `json:"email"` + Id string `json:"id"` + Name string `json:"name"` + Username string `json:"username"` } +type _GitUser GitUser + // NewGitUser instantiates a new GitUser 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 NewGitUser() *GitUser { +func NewGitUser(email string, id string, name string, username string) *GitUser { this := GitUser{} + this.Email = email + this.Id = id + this.Name = name + this.Username = username return &this } @@ -42,132 +50,100 @@ func NewGitUserWithDefaults() *GitUser { return &this } -// GetEmail returns the Email field value if set, zero value otherwise. +// GetEmail returns the Email field value func (o *GitUser) GetEmail() string { - if o == nil || IsNil(o.Email) { + if o == nil { var ret string return ret } - return *o.Email + + return o.Email } -// GetEmailOk returns a tuple with the Email field value if set, nil otherwise +// GetEmailOk returns a tuple with the Email field value // and a boolean to check if the value has been set. func (o *GitUser) GetEmailOk() (*string, bool) { - if o == nil || IsNil(o.Email) { + if o == nil { return nil, false } - return o.Email, true + return &o.Email, true } -// HasEmail returns a boolean if a field has been set. -func (o *GitUser) HasEmail() bool { - if o != nil && !IsNil(o.Email) { - return true - } - - return false -} - -// SetEmail gets a reference to the given string and assigns it to the Email field. +// SetEmail sets field value func (o *GitUser) SetEmail(v string) { - o.Email = &v + o.Email = v } -// GetId returns the Id field value if set, zero value otherwise. +// GetId returns the Id field value func (o *GitUser) GetId() string { - if o == nil || IsNil(o.Id) { + if o == nil { var ret string return ret } - return *o.Id + + return o.Id } -// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// GetIdOk returns a tuple with the Id field value // and a boolean to check if the value has been set. func (o *GitUser) GetIdOk() (*string, bool) { - if o == nil || IsNil(o.Id) { + if o == nil { return nil, false } - return o.Id, true -} - -// HasId returns a boolean if a field has been set. -func (o *GitUser) HasId() bool { - if o != nil && !IsNil(o.Id) { - return true - } - - return false + return &o.Id, true } -// SetId gets a reference to the given string and assigns it to the Id field. +// SetId sets field value func (o *GitUser) SetId(v string) { - o.Id = &v + o.Id = v } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *GitUser) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *GitUser) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true + return &o.Name, true } -// HasName returns a boolean if a field has been set. -func (o *GitUser) 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. +// SetName sets field value func (o *GitUser) SetName(v string) { - o.Name = &v + o.Name = v } -// GetUsername returns the Username field value if set, zero value otherwise. +// GetUsername returns the Username field value func (o *GitUser) GetUsername() string { - if o == nil || IsNil(o.Username) { + if o == nil { var ret string return ret } - return *o.Username + + return o.Username } -// GetUsernameOk returns a tuple with the Username field value if set, nil otherwise +// GetUsernameOk returns a tuple with the Username field value // and a boolean to check if the value has been set. func (o *GitUser) GetUsernameOk() (*string, bool) { - if o == nil || IsNil(o.Username) { + if o == nil { return nil, false } - return o.Username, true -} - -// HasUsername returns a boolean if a field has been set. -func (o *GitUser) HasUsername() bool { - if o != nil && !IsNil(o.Username) { - return true - } - - return false + return &o.Username, true } -// SetUsername gets a reference to the given string and assigns it to the Username field. +// SetUsername sets field value func (o *GitUser) SetUsername(v string) { - o.Username = &v + o.Username = v } func (o GitUser) MarshalJSON() ([]byte, error) { @@ -180,19 +156,51 @@ func (o GitUser) MarshalJSON() ([]byte, error) { func (o GitUser) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Email) { - toSerialize["email"] = o.Email + toSerialize["email"] = o.Email + toSerialize["id"] = o.Id + toSerialize["name"] = o.Name + toSerialize["username"] = o.Username + return toSerialize, nil +} + +func (o *GitUser) 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", + "name", + "username", } - if !IsNil(o.Id) { - toSerialize["id"] = o.Id + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - if !IsNil(o.Name) { - toSerialize["name"] = o.Name + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } } - if !IsNil(o.Username) { - toSerialize["username"] = o.Username + + varGitUser := _GitUser{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varGitUser) + + if err != nil { + return err } - return toSerialize, nil + + *o = GitUser(varGitUser) + + return err } type NullableGitUser struct { diff --git a/pkg/apiclient/model_install_provider_request.go b/pkg/apiclient/model_install_provider_request.go index c547612309..de1ab67098 100644 --- a/pkg/apiclient/model_install_provider_request.go +++ b/pkg/apiclient/model_install_provider_request.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the InstallProviderRequest type satisfies the MappedNullable interface at compile time @@ -19,16 +21,20 @@ var _ MappedNullable = &InstallProviderRequest{} // InstallProviderRequest struct for InstallProviderRequest type InstallProviderRequest struct { - DownloadUrls *map[string]string `json:"downloadUrls,omitempty"` - Name *string `json:"name,omitempty"` + DownloadUrls map[string]string `json:"downloadUrls"` + Name string `json:"name"` } +type _InstallProviderRequest InstallProviderRequest + // NewInstallProviderRequest instantiates a new InstallProviderRequest 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 NewInstallProviderRequest() *InstallProviderRequest { +func NewInstallProviderRequest(downloadUrls map[string]string, name string) *InstallProviderRequest { this := InstallProviderRequest{} + this.DownloadUrls = downloadUrls + this.Name = name return &this } @@ -40,68 +46,52 @@ func NewInstallProviderRequestWithDefaults() *InstallProviderRequest { return &this } -// GetDownloadUrls returns the DownloadUrls field value if set, zero value otherwise. +// GetDownloadUrls returns the DownloadUrls field value func (o *InstallProviderRequest) GetDownloadUrls() map[string]string { - if o == nil || IsNil(o.DownloadUrls) { + if o == nil { var ret map[string]string return ret } - return *o.DownloadUrls + + return o.DownloadUrls } -// GetDownloadUrlsOk returns a tuple with the DownloadUrls field value if set, nil otherwise +// GetDownloadUrlsOk returns a tuple with the DownloadUrls field value // and a boolean to check if the value has been set. func (o *InstallProviderRequest) GetDownloadUrlsOk() (*map[string]string, bool) { - if o == nil || IsNil(o.DownloadUrls) { + if o == nil { return nil, false } - return o.DownloadUrls, true + return &o.DownloadUrls, true } -// HasDownloadUrls returns a boolean if a field has been set. -func (o *InstallProviderRequest) HasDownloadUrls() bool { - if o != nil && !IsNil(o.DownloadUrls) { - return true - } - - return false -} - -// SetDownloadUrls gets a reference to the given map[string]string and assigns it to the DownloadUrls field. +// SetDownloadUrls sets field value func (o *InstallProviderRequest) SetDownloadUrls(v map[string]string) { - o.DownloadUrls = &v + o.DownloadUrls = v } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *InstallProviderRequest) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *InstallProviderRequest) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true + return &o.Name, true } -// HasName returns a boolean if a field has been set. -func (o *InstallProviderRequest) 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. +// SetName sets field value func (o *InstallProviderRequest) SetName(v string) { - o.Name = &v + o.Name = v } func (o InstallProviderRequest) MarshalJSON() ([]byte, error) { @@ -114,13 +104,47 @@ func (o InstallProviderRequest) MarshalJSON() ([]byte, error) { func (o InstallProviderRequest) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.DownloadUrls) { - toSerialize["downloadUrls"] = o.DownloadUrls + toSerialize["downloadUrls"] = o.DownloadUrls + toSerialize["name"] = o.Name + return toSerialize, nil +} + +func (o *InstallProviderRequest) 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{ + "downloadUrls", + "name", } - if !IsNil(o.Name) { - toSerialize["name"] = o.Name + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - return toSerialize, nil + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varInstallProviderRequest := _InstallProviderRequest{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varInstallProviderRequest) + + if err != nil { + return err + } + + *o = InstallProviderRequest(varInstallProviderRequest) + + return err } type NullableInstallProviderRequest struct { diff --git a/pkg/apiclient/model_network_key.go b/pkg/apiclient/model_network_key.go index c33490d98b..c4f8858a4b 100644 --- a/pkg/apiclient/model_network_key.go +++ b/pkg/apiclient/model_network_key.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the NetworkKey type satisfies the MappedNullable interface at compile time @@ -19,15 +21,18 @@ var _ MappedNullable = &NetworkKey{} // NetworkKey struct for NetworkKey type NetworkKey struct { - Key *string `json:"key,omitempty"` + Key string `json:"key"` } +type _NetworkKey NetworkKey + // NewNetworkKey instantiates a new NetworkKey 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 NewNetworkKey() *NetworkKey { +func NewNetworkKey(key string) *NetworkKey { this := NetworkKey{} + this.Key = key return &this } @@ -39,36 +44,28 @@ func NewNetworkKeyWithDefaults() *NetworkKey { return &this } -// GetKey returns the Key field value if set, zero value otherwise. +// GetKey returns the Key field value func (o *NetworkKey) GetKey() string { - if o == nil || IsNil(o.Key) { + if o == nil { var ret string return ret } - return *o.Key + + return o.Key } -// GetKeyOk returns a tuple with the Key field value if set, nil otherwise +// GetKeyOk returns a tuple with the Key field value // and a boolean to check if the value has been set. func (o *NetworkKey) GetKeyOk() (*string, bool) { - if o == nil || IsNil(o.Key) { + if o == nil { return nil, false } - return o.Key, true -} - -// HasKey returns a boolean if a field has been set. -func (o *NetworkKey) HasKey() bool { - if o != nil && !IsNil(o.Key) { - return true - } - - return false + return &o.Key, true } -// SetKey gets a reference to the given string and assigns it to the Key field. +// SetKey sets field value func (o *NetworkKey) SetKey(v string) { - o.Key = &v + o.Key = v } func (o NetworkKey) MarshalJSON() ([]byte, error) { @@ -81,12 +78,47 @@ func (o NetworkKey) MarshalJSON() ([]byte, error) { func (o NetworkKey) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Key) { - toSerialize["key"] = o.Key - } + toSerialize["key"] = o.Key return toSerialize, nil } +func (o *NetworkKey) 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{ + "key", + } + + 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) + } + } + + varNetworkKey := _NetworkKey{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varNetworkKey) + + if err != nil { + return err + } + + *o = NetworkKey(varNetworkKey) + + return err +} + type NullableNetworkKey struct { value *NetworkKey isSet bool diff --git a/pkg/apiclient/model_profile_data.go b/pkg/apiclient/model_profile_data.go index f98ab2acd7..d7eabbe8f4 100644 --- a/pkg/apiclient/model_profile_data.go +++ b/pkg/apiclient/model_profile_data.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the ProfileData type satisfies the MappedNullable interface at compile time @@ -19,15 +21,18 @@ var _ MappedNullable = &ProfileData{} // ProfileData struct for ProfileData type ProfileData struct { - EnvVars *map[string]string `json:"envVars,omitempty"` + EnvVars map[string]string `json:"envVars"` } +type _ProfileData ProfileData + // NewProfileData instantiates a new ProfileData 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 NewProfileData() *ProfileData { +func NewProfileData(envVars map[string]string) *ProfileData { this := ProfileData{} + this.EnvVars = envVars return &this } @@ -39,36 +44,28 @@ func NewProfileDataWithDefaults() *ProfileData { return &this } -// GetEnvVars returns the EnvVars field value if set, zero value otherwise. +// GetEnvVars returns the EnvVars field value func (o *ProfileData) GetEnvVars() map[string]string { - if o == nil || IsNil(o.EnvVars) { + if o == nil { var ret map[string]string return ret } - return *o.EnvVars + + return o.EnvVars } -// GetEnvVarsOk returns a tuple with the EnvVars field value if set, nil otherwise +// GetEnvVarsOk returns a tuple with the EnvVars field value // and a boolean to check if the value has been set. func (o *ProfileData) GetEnvVarsOk() (*map[string]string, bool) { - if o == nil || IsNil(o.EnvVars) { + if o == nil { return nil, false } - return o.EnvVars, true -} - -// HasEnvVars returns a boolean if a field has been set. -func (o *ProfileData) HasEnvVars() bool { - if o != nil && !IsNil(o.EnvVars) { - return true - } - - return false + return &o.EnvVars, true } -// SetEnvVars gets a reference to the given map[string]string and assigns it to the EnvVars field. +// SetEnvVars sets field value func (o *ProfileData) SetEnvVars(v map[string]string) { - o.EnvVars = &v + o.EnvVars = v } func (o ProfileData) MarshalJSON() ([]byte, error) { @@ -81,12 +78,47 @@ func (o ProfileData) MarshalJSON() ([]byte, error) { func (o ProfileData) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.EnvVars) { - toSerialize["envVars"] = o.EnvVars - } + toSerialize["envVars"] = o.EnvVars return toSerialize, nil } +func (o *ProfileData) 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{ + "envVars", + } + + 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) + } + } + + varProfileData := _ProfileData{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varProfileData) + + if err != nil { + return err + } + + *o = ProfileData(varProfileData) + + return err +} + type NullableProfileData struct { value *ProfileData isSet bool diff --git a/pkg/apiclient/model_project.go b/pkg/apiclient/model_project.go index 51b27c9793..28bec3e3ec 100644 --- a/pkg/apiclient/model_project.go +++ b/pkg/apiclient/model_project.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the Project type satisfies the MappedNullable interface at compile time @@ -20,23 +22,33 @@ var _ MappedNullable = &Project{} // Project struct for Project type Project struct { BuildConfig *ProjectBuildConfig `json:"buildConfig,omitempty"` - Default *bool `json:"default,omitempty"` - EnvVars *map[string]string `json:"envVars,omitempty"` - Image *string `json:"image,omitempty"` - Name *string `json:"name,omitempty"` - Repository *GitRepository `json:"repository,omitempty"` + Default bool `json:"default"` + EnvVars map[string]string `json:"envVars"` + Image string `json:"image"` + Name string `json:"name"` + Repository GitRepository `json:"repository"` State *ProjectState `json:"state,omitempty"` - Target *string `json:"target,omitempty"` - User *string `json:"user,omitempty"` - WorkspaceId *string `json:"workspaceId,omitempty"` + Target string `json:"target"` + User string `json:"user"` + WorkspaceId string `json:"workspaceId"` } +type _Project Project + // NewProject instantiates a new Project 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 NewProject() *Project { +func NewProject(default_ bool, envVars map[string]string, image string, name string, repository GitRepository, target string, user string, workspaceId string) *Project { this := Project{} + this.Default = default_ + this.EnvVars = envVars + this.Image = image + this.Name = name + this.Repository = repository + this.Target = target + this.User = user + this.WorkspaceId = workspaceId return &this } @@ -80,164 +92,124 @@ func (o *Project) SetBuildConfig(v ProjectBuildConfig) { o.BuildConfig = &v } -// GetDefault returns the Default field value if set, zero value otherwise. +// GetDefault returns the Default field value func (o *Project) GetDefault() bool { - if o == nil || IsNil(o.Default) { + if o == nil { var ret bool return ret } - return *o.Default + + return o.Default } -// GetDefaultOk returns a tuple with the Default field value if set, nil otherwise +// GetDefaultOk returns a tuple with the Default field value // and a boolean to check if the value has been set. func (o *Project) GetDefaultOk() (*bool, bool) { - if o == nil || IsNil(o.Default) { + if o == nil { return nil, false } - return o.Default, true -} - -// HasDefault returns a boolean if a field has been set. -func (o *Project) HasDefault() bool { - if o != nil && !IsNil(o.Default) { - return true - } - - return false + return &o.Default, true } -// SetDefault gets a reference to the given bool and assigns it to the Default field. +// SetDefault sets field value func (o *Project) SetDefault(v bool) { - o.Default = &v + o.Default = v } -// GetEnvVars returns the EnvVars field value if set, zero value otherwise. +// GetEnvVars returns the EnvVars field value func (o *Project) GetEnvVars() map[string]string { - if o == nil || IsNil(o.EnvVars) { + if o == nil { var ret map[string]string return ret } - return *o.EnvVars + + return o.EnvVars } -// GetEnvVarsOk returns a tuple with the EnvVars field value if set, nil otherwise +// GetEnvVarsOk returns a tuple with the EnvVars field value // and a boolean to check if the value has been set. func (o *Project) GetEnvVarsOk() (*map[string]string, bool) { - if o == nil || IsNil(o.EnvVars) { + if o == nil { return nil, false } - return o.EnvVars, true -} - -// HasEnvVars returns a boolean if a field has been set. -func (o *Project) HasEnvVars() bool { - if o != nil && !IsNil(o.EnvVars) { - return true - } - - return false + return &o.EnvVars, true } -// SetEnvVars gets a reference to the given map[string]string and assigns it to the EnvVars field. +// SetEnvVars sets field value func (o *Project) SetEnvVars(v map[string]string) { - o.EnvVars = &v + o.EnvVars = v } -// GetImage returns the Image field value if set, zero value otherwise. +// GetImage returns the Image field value func (o *Project) GetImage() string { - if o == nil || IsNil(o.Image) { + if o == nil { var ret string return ret } - return *o.Image + + return o.Image } -// GetImageOk returns a tuple with the Image field value if set, nil otherwise +// GetImageOk returns a tuple with the Image field value // and a boolean to check if the value has been set. func (o *Project) GetImageOk() (*string, bool) { - if o == nil || IsNil(o.Image) { + if o == nil { return nil, false } - return o.Image, true + return &o.Image, true } -// HasImage returns a boolean if a field has been set. -func (o *Project) HasImage() bool { - if o != nil && !IsNil(o.Image) { - return true - } - - return false -} - -// SetImage gets a reference to the given string and assigns it to the Image field. +// SetImage sets field value func (o *Project) SetImage(v string) { - o.Image = &v + o.Image = v } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *Project) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *Project) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true -} - -// HasName returns a boolean if a field has been set. -func (o *Project) HasName() bool { - if o != nil && !IsNil(o.Name) { - return true - } - - return false + return &o.Name, true } -// SetName gets a reference to the given string and assigns it to the Name field. +// SetName sets field value func (o *Project) SetName(v string) { - o.Name = &v + o.Name = v } -// GetRepository returns the Repository field value if set, zero value otherwise. +// GetRepository returns the Repository field value func (o *Project) GetRepository() GitRepository { - if o == nil || IsNil(o.Repository) { + if o == nil { var ret GitRepository return ret } - return *o.Repository + + return o.Repository } -// GetRepositoryOk returns a tuple with the Repository field value if set, nil otherwise +// GetRepositoryOk returns a tuple with the Repository field value // and a boolean to check if the value has been set. func (o *Project) GetRepositoryOk() (*GitRepository, bool) { - if o == nil || IsNil(o.Repository) { + if o == nil { return nil, false } - return o.Repository, true + return &o.Repository, true } -// HasRepository returns a boolean if a field has been set. -func (o *Project) HasRepository() bool { - if o != nil && !IsNil(o.Repository) { - return true - } - - return false -} - -// SetRepository gets a reference to the given GitRepository and assigns it to the Repository field. +// SetRepository sets field value func (o *Project) SetRepository(v GitRepository) { - o.Repository = &v + o.Repository = v } // GetState returns the State field value if set, zero value otherwise. @@ -272,100 +244,76 @@ func (o *Project) SetState(v ProjectState) { o.State = &v } -// GetTarget returns the Target field value if set, zero value otherwise. +// GetTarget returns the Target field value func (o *Project) GetTarget() string { - if o == nil || IsNil(o.Target) { + if o == nil { var ret string return ret } - return *o.Target + + return o.Target } -// GetTargetOk returns a tuple with the Target field value if set, nil otherwise +// GetTargetOk returns a tuple with the Target field value // and a boolean to check if the value has been set. func (o *Project) GetTargetOk() (*string, bool) { - if o == nil || IsNil(o.Target) { + if o == nil { return nil, false } - return o.Target, true -} - -// HasTarget returns a boolean if a field has been set. -func (o *Project) HasTarget() bool { - if o != nil && !IsNil(o.Target) { - return true - } - - return false + return &o.Target, true } -// SetTarget gets a reference to the given string and assigns it to the Target field. +// SetTarget sets field value func (o *Project) SetTarget(v string) { - o.Target = &v + o.Target = v } -// GetUser returns the User field value if set, zero value otherwise. +// GetUser returns the User field value func (o *Project) GetUser() string { - if o == nil || IsNil(o.User) { + if o == nil { var ret string return ret } - return *o.User + + return o.User } -// GetUserOk returns a tuple with the User field value if set, nil otherwise +// GetUserOk returns a tuple with the User field value // and a boolean to check if the value has been set. func (o *Project) GetUserOk() (*string, bool) { - if o == nil || IsNil(o.User) { + if o == nil { return nil, false } - return o.User, true -} - -// HasUser returns a boolean if a field has been set. -func (o *Project) HasUser() bool { - if o != nil && !IsNil(o.User) { - return true - } - - return false + return &o.User, true } -// SetUser gets a reference to the given string and assigns it to the User field. +// SetUser sets field value func (o *Project) SetUser(v string) { - o.User = &v + o.User = v } -// GetWorkspaceId returns the WorkspaceId field value if set, zero value otherwise. +// GetWorkspaceId returns the WorkspaceId field value func (o *Project) GetWorkspaceId() string { - if o == nil || IsNil(o.WorkspaceId) { + if o == nil { var ret string return ret } - return *o.WorkspaceId + + return o.WorkspaceId } -// GetWorkspaceIdOk returns a tuple with the WorkspaceId field value if set, nil otherwise +// GetWorkspaceIdOk returns a tuple with the WorkspaceId field value // and a boolean to check if the value has been set. func (o *Project) GetWorkspaceIdOk() (*string, bool) { - if o == nil || IsNil(o.WorkspaceId) { + if o == nil { return nil, false } - return o.WorkspaceId, true -} - -// HasWorkspaceId returns a boolean if a field has been set. -func (o *Project) HasWorkspaceId() bool { - if o != nil && !IsNil(o.WorkspaceId) { - return true - } - - return false + return &o.WorkspaceId, true } -// SetWorkspaceId gets a reference to the given string and assigns it to the WorkspaceId field. +// SetWorkspaceId sets field value func (o *Project) SetWorkspaceId(v string) { - o.WorkspaceId = &v + o.WorkspaceId = v } func (o Project) MarshalJSON() ([]byte, error) { @@ -381,34 +329,62 @@ func (o Project) ToMap() (map[string]interface{}, error) { if !IsNil(o.BuildConfig) { toSerialize["buildConfig"] = o.BuildConfig } - if !IsNil(o.Default) { - toSerialize["default"] = o.Default - } - if !IsNil(o.EnvVars) { - toSerialize["envVars"] = o.EnvVars - } - if !IsNil(o.Image) { - toSerialize["image"] = o.Image - } - if !IsNil(o.Name) { - toSerialize["name"] = o.Name - } - if !IsNil(o.Repository) { - toSerialize["repository"] = o.Repository - } + toSerialize["default"] = o.Default + toSerialize["envVars"] = o.EnvVars + toSerialize["image"] = o.Image + toSerialize["name"] = o.Name + toSerialize["repository"] = o.Repository if !IsNil(o.State) { toSerialize["state"] = o.State } - if !IsNil(o.Target) { - toSerialize["target"] = o.Target + toSerialize["target"] = o.Target + toSerialize["user"] = o.User + toSerialize["workspaceId"] = o.WorkspaceId + return toSerialize, nil +} + +func (o *Project) 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{ + "default", + "envVars", + "image", + "name", + "repository", + "target", + "user", + "workspaceId", } - if !IsNil(o.User) { - toSerialize["user"] = o.User + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - if !IsNil(o.WorkspaceId) { - toSerialize["workspaceId"] = o.WorkspaceId + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } } - return toSerialize, nil + + varProject := _Project{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varProject) + + if err != nil { + return err + } + + *o = Project(varProject) + + return err } type NullableProject struct { diff --git a/pkg/apiclient/model_project_config.go b/pkg/apiclient/model_project_config.go index f7ff4be9be..80d3e786f2 100644 --- a/pkg/apiclient/model_project_config.go +++ b/pkg/apiclient/model_project_config.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the ProjectConfig type satisfies the MappedNullable interface at compile time @@ -20,20 +22,28 @@ var _ MappedNullable = &ProjectConfig{} // ProjectConfig struct for ProjectConfig type ProjectConfig struct { BuildConfig *ProjectBuildConfig `json:"buildConfig,omitempty"` - Default *bool `json:"default,omitempty"` - EnvVars *map[string]string `json:"envVars,omitempty"` - Image *string `json:"image,omitempty"` - Name *string `json:"name,omitempty"` - Repository *GitRepository `json:"repository,omitempty"` - User *string `json:"user,omitempty"` + Default bool `json:"default"` + EnvVars map[string]string `json:"envVars"` + Image string `json:"image"` + Name string `json:"name"` + Repository GitRepository `json:"repository"` + User string `json:"user"` } +type _ProjectConfig ProjectConfig + // NewProjectConfig instantiates a new ProjectConfig 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 NewProjectConfig() *ProjectConfig { +func NewProjectConfig(default_ bool, envVars map[string]string, image string, name string, repository GitRepository, user string) *ProjectConfig { this := ProjectConfig{} + this.Default = default_ + this.EnvVars = envVars + this.Image = image + this.Name = name + this.Repository = repository + this.User = user return &this } @@ -77,196 +87,148 @@ func (o *ProjectConfig) SetBuildConfig(v ProjectBuildConfig) { o.BuildConfig = &v } -// GetDefault returns the Default field value if set, zero value otherwise. +// GetDefault returns the Default field value func (o *ProjectConfig) GetDefault() bool { - if o == nil || IsNil(o.Default) { + if o == nil { var ret bool return ret } - return *o.Default + + return o.Default } -// GetDefaultOk returns a tuple with the Default field value if set, nil otherwise +// GetDefaultOk returns a tuple with the Default field value // and a boolean to check if the value has been set. func (o *ProjectConfig) GetDefaultOk() (*bool, bool) { - if o == nil || IsNil(o.Default) { + if o == nil { return nil, false } - return o.Default, true -} - -// HasDefault returns a boolean if a field has been set. -func (o *ProjectConfig) HasDefault() bool { - if o != nil && !IsNil(o.Default) { - return true - } - - return false + return &o.Default, true } -// SetDefault gets a reference to the given bool and assigns it to the Default field. +// SetDefault sets field value func (o *ProjectConfig) SetDefault(v bool) { - o.Default = &v + o.Default = v } -// GetEnvVars returns the EnvVars field value if set, zero value otherwise. +// GetEnvVars returns the EnvVars field value func (o *ProjectConfig) GetEnvVars() map[string]string { - if o == nil || IsNil(o.EnvVars) { + if o == nil { var ret map[string]string return ret } - return *o.EnvVars + + return o.EnvVars } -// GetEnvVarsOk returns a tuple with the EnvVars field value if set, nil otherwise +// GetEnvVarsOk returns a tuple with the EnvVars field value // and a boolean to check if the value has been set. func (o *ProjectConfig) GetEnvVarsOk() (*map[string]string, bool) { - if o == nil || IsNil(o.EnvVars) { + if o == nil { return nil, false } - return o.EnvVars, true -} - -// HasEnvVars returns a boolean if a field has been set. -func (o *ProjectConfig) HasEnvVars() bool { - if o != nil && !IsNil(o.EnvVars) { - return true - } - - return false + return &o.EnvVars, true } -// SetEnvVars gets a reference to the given map[string]string and assigns it to the EnvVars field. +// SetEnvVars sets field value func (o *ProjectConfig) SetEnvVars(v map[string]string) { - o.EnvVars = &v + o.EnvVars = v } -// GetImage returns the Image field value if set, zero value otherwise. +// GetImage returns the Image field value func (o *ProjectConfig) GetImage() string { - if o == nil || IsNil(o.Image) { + if o == nil { var ret string return ret } - return *o.Image + + return o.Image } -// GetImageOk returns a tuple with the Image field value if set, nil otherwise +// GetImageOk returns a tuple with the Image field value // and a boolean to check if the value has been set. func (o *ProjectConfig) GetImageOk() (*string, bool) { - if o == nil || IsNil(o.Image) { + if o == nil { return nil, false } - return o.Image, true -} - -// HasImage returns a boolean if a field has been set. -func (o *ProjectConfig) HasImage() bool { - if o != nil && !IsNil(o.Image) { - return true - } - - return false + return &o.Image, true } -// SetImage gets a reference to the given string and assigns it to the Image field. +// SetImage sets field value func (o *ProjectConfig) SetImage(v string) { - o.Image = &v + o.Image = v } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *ProjectConfig) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *ProjectConfig) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true + return &o.Name, true } -// HasName returns a boolean if a field has been set. -func (o *ProjectConfig) 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. +// SetName sets field value func (o *ProjectConfig) SetName(v string) { - o.Name = &v + o.Name = v } -// GetRepository returns the Repository field value if set, zero value otherwise. +// GetRepository returns the Repository field value func (o *ProjectConfig) GetRepository() GitRepository { - if o == nil || IsNil(o.Repository) { + if o == nil { var ret GitRepository return ret } - return *o.Repository + + return o.Repository } -// GetRepositoryOk returns a tuple with the Repository field value if set, nil otherwise +// GetRepositoryOk returns a tuple with the Repository field value // and a boolean to check if the value has been set. func (o *ProjectConfig) GetRepositoryOk() (*GitRepository, bool) { - if o == nil || IsNil(o.Repository) { + if o == nil { return nil, false } - return o.Repository, true + return &o.Repository, true } -// HasRepository returns a boolean if a field has been set. -func (o *ProjectConfig) HasRepository() bool { - if o != nil && !IsNil(o.Repository) { - return true - } - - return false -} - -// SetRepository gets a reference to the given GitRepository and assigns it to the Repository field. +// SetRepository sets field value func (o *ProjectConfig) SetRepository(v GitRepository) { - o.Repository = &v + o.Repository = v } -// GetUser returns the User field value if set, zero value otherwise. +// GetUser returns the User field value func (o *ProjectConfig) GetUser() string { - if o == nil || IsNil(o.User) { + if o == nil { var ret string return ret } - return *o.User + + return o.User } -// GetUserOk returns a tuple with the User field value if set, nil otherwise +// GetUserOk returns a tuple with the User field value // and a boolean to check if the value has been set. func (o *ProjectConfig) GetUserOk() (*string, bool) { - if o == nil || IsNil(o.User) { + if o == nil { return nil, false } - return o.User, true + return &o.User, true } -// HasUser returns a boolean if a field has been set. -func (o *ProjectConfig) HasUser() bool { - if o != nil && !IsNil(o.User) { - return true - } - - return false -} - -// SetUser gets a reference to the given string and assigns it to the User field. +// SetUser sets field value func (o *ProjectConfig) SetUser(v string) { - o.User = &v + o.User = v } func (o ProjectConfig) MarshalJSON() ([]byte, error) { @@ -282,25 +244,55 @@ func (o ProjectConfig) ToMap() (map[string]interface{}, error) { if !IsNil(o.BuildConfig) { toSerialize["buildConfig"] = o.BuildConfig } - if !IsNil(o.Default) { - toSerialize["default"] = o.Default - } - if !IsNil(o.EnvVars) { - toSerialize["envVars"] = o.EnvVars - } - if !IsNil(o.Image) { - toSerialize["image"] = o.Image + toSerialize["default"] = o.Default + toSerialize["envVars"] = o.EnvVars + toSerialize["image"] = o.Image + toSerialize["name"] = o.Name + toSerialize["repository"] = o.Repository + toSerialize["user"] = o.User + return toSerialize, nil +} + +func (o *ProjectConfig) 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{ + "default", + "envVars", + "image", + "name", + "repository", + "user", } - if !IsNil(o.Name) { - toSerialize["name"] = o.Name + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - if !IsNil(o.Repository) { - toSerialize["repository"] = o.Repository + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } } - if !IsNil(o.User) { - toSerialize["user"] = o.User + + varProjectConfig := _ProjectConfig{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varProjectConfig) + + if err != nil { + return err } - return toSerialize, nil + + *o = ProjectConfig(varProjectConfig) + + return err } type NullableProjectConfig struct { diff --git a/pkg/apiclient/model_project_info.go b/pkg/apiclient/model_project_info.go index 1c8f3681a3..15d0072ba8 100644 --- a/pkg/apiclient/model_project_info.go +++ b/pkg/apiclient/model_project_info.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the ProjectInfo type satisfies the MappedNullable interface at compile time @@ -19,19 +21,25 @@ var _ MappedNullable = &ProjectInfo{} // ProjectInfo struct for ProjectInfo type ProjectInfo struct { - Created *string `json:"created,omitempty"` - IsRunning *bool `json:"isRunning,omitempty"` - Name *string `json:"name,omitempty"` + Created string `json:"created"` + IsRunning bool `json:"isRunning"` + Name string `json:"name"` ProviderMetadata *string `json:"providerMetadata,omitempty"` - WorkspaceId *string `json:"workspaceId,omitempty"` + WorkspaceId string `json:"workspaceId"` } +type _ProjectInfo ProjectInfo + // NewProjectInfo instantiates a new ProjectInfo 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 NewProjectInfo() *ProjectInfo { +func NewProjectInfo(created string, isRunning bool, name string, workspaceId string) *ProjectInfo { this := ProjectInfo{} + this.Created = created + this.IsRunning = isRunning + this.Name = name + this.WorkspaceId = workspaceId return &this } @@ -43,100 +51,76 @@ func NewProjectInfoWithDefaults() *ProjectInfo { return &this } -// GetCreated returns the Created field value if set, zero value otherwise. +// GetCreated returns the Created field value func (o *ProjectInfo) GetCreated() string { - if o == nil || IsNil(o.Created) { + if o == nil { var ret string return ret } - return *o.Created + + return o.Created } -// GetCreatedOk returns a tuple with the Created field value if set, nil otherwise +// GetCreatedOk returns a tuple with the Created field value // and a boolean to check if the value has been set. func (o *ProjectInfo) GetCreatedOk() (*string, bool) { - if o == nil || IsNil(o.Created) { + if o == nil { return nil, false } - return o.Created, true -} - -// HasCreated returns a boolean if a field has been set. -func (o *ProjectInfo) HasCreated() bool { - if o != nil && !IsNil(o.Created) { - return true - } - - return false + return &o.Created, true } -// SetCreated gets a reference to the given string and assigns it to the Created field. +// SetCreated sets field value func (o *ProjectInfo) SetCreated(v string) { - o.Created = &v + o.Created = v } -// GetIsRunning returns the IsRunning field value if set, zero value otherwise. +// GetIsRunning returns the IsRunning field value func (o *ProjectInfo) GetIsRunning() bool { - if o == nil || IsNil(o.IsRunning) { + if o == nil { var ret bool return ret } - return *o.IsRunning + + return o.IsRunning } -// GetIsRunningOk returns a tuple with the IsRunning field value if set, nil otherwise +// GetIsRunningOk returns a tuple with the IsRunning field value // and a boolean to check if the value has been set. func (o *ProjectInfo) GetIsRunningOk() (*bool, bool) { - if o == nil || IsNil(o.IsRunning) { + if o == nil { return nil, false } - return o.IsRunning, true -} - -// HasIsRunning returns a boolean if a field has been set. -func (o *ProjectInfo) HasIsRunning() bool { - if o != nil && !IsNil(o.IsRunning) { - return true - } - - return false + return &o.IsRunning, true } -// SetIsRunning gets a reference to the given bool and assigns it to the IsRunning field. +// SetIsRunning sets field value func (o *ProjectInfo) SetIsRunning(v bool) { - o.IsRunning = &v + o.IsRunning = v } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *ProjectInfo) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *ProjectInfo) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true -} - -// HasName returns a boolean if a field has been set. -func (o *ProjectInfo) HasName() bool { - if o != nil && !IsNil(o.Name) { - return true - } - - return false + return &o.Name, true } -// SetName gets a reference to the given string and assigns it to the Name field. +// SetName sets field value func (o *ProjectInfo) SetName(v string) { - o.Name = &v + o.Name = v } // GetProviderMetadata returns the ProviderMetadata field value if set, zero value otherwise. @@ -171,36 +155,28 @@ func (o *ProjectInfo) SetProviderMetadata(v string) { o.ProviderMetadata = &v } -// GetWorkspaceId returns the WorkspaceId field value if set, zero value otherwise. +// GetWorkspaceId returns the WorkspaceId field value func (o *ProjectInfo) GetWorkspaceId() string { - if o == nil || IsNil(o.WorkspaceId) { + if o == nil { var ret string return ret } - return *o.WorkspaceId + + return o.WorkspaceId } -// GetWorkspaceIdOk returns a tuple with the WorkspaceId field value if set, nil otherwise +// GetWorkspaceIdOk returns a tuple with the WorkspaceId field value // and a boolean to check if the value has been set. func (o *ProjectInfo) GetWorkspaceIdOk() (*string, bool) { - if o == nil || IsNil(o.WorkspaceId) { + if o == nil { return nil, false } - return o.WorkspaceId, true -} - -// HasWorkspaceId returns a boolean if a field has been set. -func (o *ProjectInfo) HasWorkspaceId() bool { - if o != nil && !IsNil(o.WorkspaceId) { - return true - } - - return false + return &o.WorkspaceId, true } -// SetWorkspaceId gets a reference to the given string and assigns it to the WorkspaceId field. +// SetWorkspaceId sets field value func (o *ProjectInfo) SetWorkspaceId(v string) { - o.WorkspaceId = &v + o.WorkspaceId = v } func (o ProjectInfo) MarshalJSON() ([]byte, error) { @@ -213,22 +189,54 @@ func (o ProjectInfo) MarshalJSON() ([]byte, error) { func (o ProjectInfo) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Created) { - toSerialize["created"] = o.Created + toSerialize["created"] = o.Created + toSerialize["isRunning"] = o.IsRunning + toSerialize["name"] = o.Name + if !IsNil(o.ProviderMetadata) { + toSerialize["providerMetadata"] = o.ProviderMetadata } - if !IsNil(o.IsRunning) { - toSerialize["isRunning"] = o.IsRunning + toSerialize["workspaceId"] = o.WorkspaceId + return toSerialize, nil +} + +func (o *ProjectInfo) 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{ + "created", + "isRunning", + "name", + "workspaceId", } - if !IsNil(o.Name) { - toSerialize["name"] = o.Name + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - if !IsNil(o.ProviderMetadata) { - toSerialize["providerMetadata"] = o.ProviderMetadata + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } } - if !IsNil(o.WorkspaceId) { - toSerialize["workspaceId"] = o.WorkspaceId + + varProjectInfo := _ProjectInfo{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varProjectInfo) + + if err != nil { + return err } - return toSerialize, nil + + *o = ProjectInfo(varProjectInfo) + + return err } type NullableProjectInfo struct { diff --git a/pkg/apiclient/model_project_state.go b/pkg/apiclient/model_project_state.go index fd49661a6c..01508341d0 100644 --- a/pkg/apiclient/model_project_state.go +++ b/pkg/apiclient/model_project_state.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the ProjectState type satisfies the MappedNullable interface at compile time @@ -19,17 +21,22 @@ var _ MappedNullable = &ProjectState{} // ProjectState struct for ProjectState type ProjectState struct { - GitStatus *GitStatus `json:"gitStatus,omitempty"` - UpdatedAt *string `json:"updatedAt,omitempty"` - Uptime *int32 `json:"uptime,omitempty"` + GitStatus GitStatus `json:"gitStatus"` + UpdatedAt string `json:"updatedAt"` + Uptime int32 `json:"uptime"` } +type _ProjectState ProjectState + // NewProjectState instantiates a new ProjectState 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 NewProjectState() *ProjectState { +func NewProjectState(gitStatus GitStatus, updatedAt string, uptime int32) *ProjectState { this := ProjectState{} + this.GitStatus = gitStatus + this.UpdatedAt = updatedAt + this.Uptime = uptime return &this } @@ -41,100 +48,76 @@ func NewProjectStateWithDefaults() *ProjectState { return &this } -// GetGitStatus returns the GitStatus field value if set, zero value otherwise. +// GetGitStatus returns the GitStatus field value func (o *ProjectState) GetGitStatus() GitStatus { - if o == nil || IsNil(o.GitStatus) { + if o == nil { var ret GitStatus return ret } - return *o.GitStatus + + return o.GitStatus } -// GetGitStatusOk returns a tuple with the GitStatus field value if set, nil otherwise +// GetGitStatusOk returns a tuple with the GitStatus field value // and a boolean to check if the value has been set. func (o *ProjectState) GetGitStatusOk() (*GitStatus, bool) { - if o == nil || IsNil(o.GitStatus) { + if o == nil { return nil, false } - return o.GitStatus, true -} - -// HasGitStatus returns a boolean if a field has been set. -func (o *ProjectState) HasGitStatus() bool { - if o != nil && !IsNil(o.GitStatus) { - return true - } - - return false + return &o.GitStatus, true } -// SetGitStatus gets a reference to the given GitStatus and assigns it to the GitStatus field. +// SetGitStatus sets field value func (o *ProjectState) SetGitStatus(v GitStatus) { - o.GitStatus = &v + o.GitStatus = v } -// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise. +// GetUpdatedAt returns the UpdatedAt field value func (o *ProjectState) GetUpdatedAt() string { - if o == nil || IsNil(o.UpdatedAt) { + if o == nil { var ret string return ret } - return *o.UpdatedAt + + return o.UpdatedAt } -// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value // and a boolean to check if the value has been set. func (o *ProjectState) GetUpdatedAtOk() (*string, bool) { - if o == nil || IsNil(o.UpdatedAt) { + if o == nil { return nil, false } - return o.UpdatedAt, true -} - -// HasUpdatedAt returns a boolean if a field has been set. -func (o *ProjectState) HasUpdatedAt() bool { - if o != nil && !IsNil(o.UpdatedAt) { - return true - } - - return false + return &o.UpdatedAt, true } -// SetUpdatedAt gets a reference to the given string and assigns it to the UpdatedAt field. +// SetUpdatedAt sets field value func (o *ProjectState) SetUpdatedAt(v string) { - o.UpdatedAt = &v + o.UpdatedAt = v } -// GetUptime returns the Uptime field value if set, zero value otherwise. +// GetUptime returns the Uptime field value func (o *ProjectState) GetUptime() int32 { - if o == nil || IsNil(o.Uptime) { + if o == nil { var ret int32 return ret } - return *o.Uptime + + return o.Uptime } -// GetUptimeOk returns a tuple with the Uptime field value if set, nil otherwise +// GetUptimeOk returns a tuple with the Uptime field value // and a boolean to check if the value has been set. func (o *ProjectState) GetUptimeOk() (*int32, bool) { - if o == nil || IsNil(o.Uptime) { + if o == nil { return nil, false } - return o.Uptime, true -} - -// HasUptime returns a boolean if a field has been set. -func (o *ProjectState) HasUptime() bool { - if o != nil && !IsNil(o.Uptime) { - return true - } - - return false + return &o.Uptime, true } -// SetUptime gets a reference to the given int32 and assigns it to the Uptime field. +// SetUptime sets field value func (o *ProjectState) SetUptime(v int32) { - o.Uptime = &v + o.Uptime = v } func (o ProjectState) MarshalJSON() ([]byte, error) { @@ -147,16 +130,49 @@ func (o ProjectState) MarshalJSON() ([]byte, error) { func (o ProjectState) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.GitStatus) { - toSerialize["gitStatus"] = o.GitStatus + toSerialize["gitStatus"] = o.GitStatus + toSerialize["updatedAt"] = o.UpdatedAt + toSerialize["uptime"] = o.Uptime + return toSerialize, nil +} + +func (o *ProjectState) 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{ + "gitStatus", + "updatedAt", + "uptime", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - if !IsNil(o.UpdatedAt) { - toSerialize["updatedAt"] = o.UpdatedAt + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } } - if !IsNil(o.Uptime) { - toSerialize["uptime"] = o.Uptime + + varProjectState := _ProjectState{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varProjectState) + + if err != nil { + return err } - return toSerialize, nil + + *o = ProjectState(varProjectState) + + return err } type NullableProjectState struct { diff --git a/pkg/apiclient/model_provider.go b/pkg/apiclient/model_provider.go index 620e368b1e..61f7064db9 100644 --- a/pkg/apiclient/model_provider.go +++ b/pkg/apiclient/model_provider.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the Provider type satisfies the MappedNullable interface at compile time @@ -19,16 +21,20 @@ var _ MappedNullable = &Provider{} // Provider struct for Provider type Provider struct { - Name *string `json:"name,omitempty"` - Version *string `json:"version,omitempty"` + Name string `json:"name"` + Version string `json:"version"` } +type _Provider Provider + // NewProvider instantiates a new Provider 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 NewProvider() *Provider { +func NewProvider(name string, version string) *Provider { this := Provider{} + this.Name = name + this.Version = version return &this } @@ -40,68 +46,52 @@ func NewProviderWithDefaults() *Provider { return &this } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *Provider) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *Provider) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true + return &o.Name, true } -// HasName returns a boolean if a field has been set. -func (o *Provider) 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. +// SetName sets field value func (o *Provider) SetName(v string) { - o.Name = &v + o.Name = v } -// GetVersion returns the Version field value if set, zero value otherwise. +// GetVersion returns the Version field value func (o *Provider) GetVersion() string { - if o == nil || IsNil(o.Version) { + if o == nil { var ret string return ret } - return *o.Version + + return o.Version } -// GetVersionOk returns a tuple with the Version field value if set, nil otherwise +// GetVersionOk returns a tuple with the Version field value // and a boolean to check if the value has been set. func (o *Provider) GetVersionOk() (*string, bool) { - if o == nil || IsNil(o.Version) { + if o == nil { return nil, false } - return o.Version, true + return &o.Version, true } -// HasVersion returns a boolean if a field has been set. -func (o *Provider) 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. +// SetVersion sets field value func (o *Provider) SetVersion(v string) { - o.Version = &v + o.Version = v } func (o Provider) MarshalJSON() ([]byte, error) { @@ -114,13 +104,47 @@ func (o Provider) MarshalJSON() ([]byte, error) { func (o Provider) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Name) { - toSerialize["name"] = o.Name + toSerialize["name"] = o.Name + toSerialize["version"] = o.Version + return toSerialize, nil +} + +func (o *Provider) 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", + "version", } - if !IsNil(o.Version) { - toSerialize["version"] = o.Version + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - return toSerialize, nil + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varProvider := _Provider{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varProvider) + + if err != nil { + return err + } + + *o = Provider(varProvider) + + return err } type NullableProvider struct { diff --git a/pkg/apiclient/model_provider_provider_info.go b/pkg/apiclient/model_provider_provider_info.go index df7fb9cfd6..645752124c 100644 --- a/pkg/apiclient/model_provider_provider_info.go +++ b/pkg/apiclient/model_provider_provider_info.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the ProviderProviderInfo type satisfies the MappedNullable interface at compile time @@ -19,16 +21,20 @@ var _ MappedNullable = &ProviderProviderInfo{} // ProviderProviderInfo struct for ProviderProviderInfo type ProviderProviderInfo struct { - Name *string `json:"name,omitempty"` - Version *string `json:"version,omitempty"` + Name string `json:"name"` + Version string `json:"version"` } +type _ProviderProviderInfo ProviderProviderInfo + // NewProviderProviderInfo instantiates a new ProviderProviderInfo 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 NewProviderProviderInfo() *ProviderProviderInfo { +func NewProviderProviderInfo(name string, version string) *ProviderProviderInfo { this := ProviderProviderInfo{} + this.Name = name + this.Version = version return &this } @@ -40,68 +46,52 @@ func NewProviderProviderInfoWithDefaults() *ProviderProviderInfo { return &this } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *ProviderProviderInfo) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *ProviderProviderInfo) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true + return &o.Name, true } -// HasName returns a boolean if a field has been set. -func (o *ProviderProviderInfo) 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. +// SetName sets field value func (o *ProviderProviderInfo) SetName(v string) { - o.Name = &v + o.Name = v } -// GetVersion returns the Version field value if set, zero value otherwise. +// GetVersion returns the Version field value func (o *ProviderProviderInfo) GetVersion() string { - if o == nil || IsNil(o.Version) { + if o == nil { var ret string return ret } - return *o.Version + + return o.Version } -// GetVersionOk returns a tuple with the Version field value if set, nil otherwise +// GetVersionOk returns a tuple with the Version field value // and a boolean to check if the value has been set. func (o *ProviderProviderInfo) GetVersionOk() (*string, bool) { - if o == nil || IsNil(o.Version) { + if o == nil { return nil, false } - return o.Version, true + return &o.Version, true } -// HasVersion returns a boolean if a field has been set. -func (o *ProviderProviderInfo) 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. +// SetVersion sets field value func (o *ProviderProviderInfo) SetVersion(v string) { - o.Version = &v + o.Version = v } func (o ProviderProviderInfo) MarshalJSON() ([]byte, error) { @@ -114,13 +104,47 @@ func (o ProviderProviderInfo) MarshalJSON() ([]byte, error) { func (o ProviderProviderInfo) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Name) { - toSerialize["name"] = o.Name + toSerialize["name"] = o.Name + toSerialize["version"] = o.Version + return toSerialize, nil +} + +func (o *ProviderProviderInfo) 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", + "version", } - if !IsNil(o.Version) { - toSerialize["version"] = o.Version + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - return toSerialize, nil + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } + } + + varProviderProviderInfo := _ProviderProviderInfo{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varProviderProviderInfo) + + if err != nil { + return err + } + + *o = ProviderProviderInfo(varProviderProviderInfo) + + return err } type NullableProviderProviderInfo struct { diff --git a/pkg/apiclient/model_provider_target.go b/pkg/apiclient/model_provider_target.go index 8ff4c8e3f2..ff5803ec83 100644 --- a/pkg/apiclient/model_provider_target.go +++ b/pkg/apiclient/model_provider_target.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the ProviderTarget type satisfies the MappedNullable interface at compile time @@ -19,18 +21,23 @@ var _ MappedNullable = &ProviderTarget{} // ProviderTarget struct for ProviderTarget type ProviderTarget struct { - Name *string `json:"name,omitempty"` + Name string `json:"name"` // JSON encoded map of options - Options *string `json:"options,omitempty"` - ProviderInfo *ProviderProviderInfo `json:"providerInfo,omitempty"` + Options string `json:"options"` + ProviderInfo ProviderProviderInfo `json:"providerInfo"` } +type _ProviderTarget ProviderTarget + // NewProviderTarget instantiates a new ProviderTarget 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 NewProviderTarget() *ProviderTarget { +func NewProviderTarget(name string, options string, providerInfo ProviderProviderInfo) *ProviderTarget { this := ProviderTarget{} + this.Name = name + this.Options = options + this.ProviderInfo = providerInfo return &this } @@ -42,100 +49,76 @@ func NewProviderTargetWithDefaults() *ProviderTarget { return &this } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *ProviderTarget) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *ProviderTarget) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true -} - -// HasName returns a boolean if a field has been set. -func (o *ProviderTarget) HasName() bool { - if o != nil && !IsNil(o.Name) { - return true - } - - return false + return &o.Name, true } -// SetName gets a reference to the given string and assigns it to the Name field. +// SetName sets field value func (o *ProviderTarget) SetName(v string) { - o.Name = &v + o.Name = v } -// GetOptions returns the Options field value if set, zero value otherwise. +// GetOptions returns the Options field value func (o *ProviderTarget) GetOptions() string { - if o == nil || IsNil(o.Options) { + if o == nil { var ret string return ret } - return *o.Options + + return o.Options } -// GetOptionsOk returns a tuple with the Options field value if set, nil otherwise +// GetOptionsOk returns a tuple with the Options field value // and a boolean to check if the value has been set. func (o *ProviderTarget) GetOptionsOk() (*string, bool) { - if o == nil || IsNil(o.Options) { + if o == nil { return nil, false } - return o.Options, true -} - -// HasOptions returns a boolean if a field has been set. -func (o *ProviderTarget) HasOptions() bool { - if o != nil && !IsNil(o.Options) { - return true - } - - return false + return &o.Options, true } -// SetOptions gets a reference to the given string and assigns it to the Options field. +// SetOptions sets field value func (o *ProviderTarget) SetOptions(v string) { - o.Options = &v + o.Options = v } -// GetProviderInfo returns the ProviderInfo field value if set, zero value otherwise. +// GetProviderInfo returns the ProviderInfo field value func (o *ProviderTarget) GetProviderInfo() ProviderProviderInfo { - if o == nil || IsNil(o.ProviderInfo) { + if o == nil { var ret ProviderProviderInfo return ret } - return *o.ProviderInfo + + return o.ProviderInfo } -// GetProviderInfoOk returns a tuple with the ProviderInfo field value if set, nil otherwise +// GetProviderInfoOk returns a tuple with the ProviderInfo field value // and a boolean to check if the value has been set. func (o *ProviderTarget) GetProviderInfoOk() (*ProviderProviderInfo, bool) { - if o == nil || IsNil(o.ProviderInfo) { + if o == nil { return nil, false } - return o.ProviderInfo, true -} - -// HasProviderInfo returns a boolean if a field has been set. -func (o *ProviderTarget) HasProviderInfo() bool { - if o != nil && !IsNil(o.ProviderInfo) { - return true - } - - return false + return &o.ProviderInfo, true } -// SetProviderInfo gets a reference to the given ProviderProviderInfo and assigns it to the ProviderInfo field. +// SetProviderInfo sets field value func (o *ProviderTarget) SetProviderInfo(v ProviderProviderInfo) { - o.ProviderInfo = &v + o.ProviderInfo = v } func (o ProviderTarget) MarshalJSON() ([]byte, error) { @@ -148,16 +131,49 @@ func (o ProviderTarget) MarshalJSON() ([]byte, error) { func (o ProviderTarget) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Name) { - toSerialize["name"] = o.Name + toSerialize["name"] = o.Name + toSerialize["options"] = o.Options + toSerialize["providerInfo"] = o.ProviderInfo + return toSerialize, nil +} + +func (o *ProviderTarget) 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", + "options", + "providerInfo", + } + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - if !IsNil(o.Options) { - toSerialize["options"] = o.Options + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } } - if !IsNil(o.ProviderInfo) { - toSerialize["providerInfo"] = o.ProviderInfo + + varProviderTarget := _ProviderTarget{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varProviderTarget) + + if err != nil { + return err } - return toSerialize, nil + + *o = ProviderTarget(varProviderTarget) + + return err } type NullableProviderTarget struct { diff --git a/pkg/apiclient/model_repository_url.go b/pkg/apiclient/model_repository_url.go index 5cb077d33e..48002dff8a 100644 --- a/pkg/apiclient/model_repository_url.go +++ b/pkg/apiclient/model_repository_url.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the RepositoryUrl type satisfies the MappedNullable interface at compile time @@ -19,15 +21,18 @@ var _ MappedNullable = &RepositoryUrl{} // RepositoryUrl struct for RepositoryUrl type RepositoryUrl struct { - Url *string `json:"url,omitempty"` + Url string `json:"url"` } +type _RepositoryUrl RepositoryUrl + // NewRepositoryUrl instantiates a new RepositoryUrl 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 NewRepositoryUrl() *RepositoryUrl { +func NewRepositoryUrl(url string) *RepositoryUrl { this := RepositoryUrl{} + this.Url = url return &this } @@ -39,36 +44,28 @@ func NewRepositoryUrlWithDefaults() *RepositoryUrl { return &this } -// GetUrl returns the Url field value if set, zero value otherwise. +// GetUrl returns the Url field value func (o *RepositoryUrl) GetUrl() string { - if o == nil || IsNil(o.Url) { + if o == nil { var ret string return ret } - return *o.Url + + return o.Url } -// GetUrlOk returns a tuple with the Url field value if set, nil otherwise +// GetUrlOk returns a tuple with the Url field value // and a boolean to check if the value has been set. func (o *RepositoryUrl) GetUrlOk() (*string, bool) { - if o == nil || IsNil(o.Url) { + if o == nil { return nil, false } - return o.Url, true -} - -// HasUrl returns a boolean if a field has been set. -func (o *RepositoryUrl) HasUrl() bool { - if o != nil && !IsNil(o.Url) { - return true - } - - return false + return &o.Url, true } -// SetUrl gets a reference to the given string and assigns it to the Url field. +// SetUrl sets field value func (o *RepositoryUrl) SetUrl(v string) { - o.Url = &v + o.Url = v } func (o RepositoryUrl) MarshalJSON() ([]byte, error) { @@ -81,12 +78,47 @@ func (o RepositoryUrl) MarshalJSON() ([]byte, error) { func (o RepositoryUrl) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Url) { - toSerialize["url"] = o.Url - } + toSerialize["url"] = o.Url return toSerialize, nil } +func (o *RepositoryUrl) 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{ + "url", + } + + 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) + } + } + + varRepositoryUrl := _RepositoryUrl{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varRepositoryUrl) + + if err != nil { + return err + } + + *o = RepositoryUrl(varRepositoryUrl) + + return err +} + type NullableRepositoryUrl struct { value *RepositoryUrl isSet bool diff --git a/pkg/apiclient/model_server_config.go b/pkg/apiclient/model_server_config.go index a9670919ed..c306852dff 100644 --- a/pkg/apiclient/model_server_config.go +++ b/pkg/apiclient/model_server_config.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the ServerConfig type satisfies the MappedNullable interface at compile time @@ -19,30 +21,46 @@ var _ MappedNullable = &ServerConfig{} // ServerConfig struct for ServerConfig type ServerConfig struct { - ApiPort *int32 `json:"apiPort,omitempty"` - BinariesPath *string `json:"binariesPath,omitempty"` + ApiPort int32 `json:"apiPort"` + BinariesPath string `json:"binariesPath"` BuildImageNamespace *string `json:"buildImageNamespace,omitempty"` - BuilderImage *string `json:"builderImage,omitempty"` - BuilderRegistryServer *string `json:"builderRegistryServer,omitempty"` - DefaultProjectImage *string `json:"defaultProjectImage,omitempty"` - DefaultProjectUser *string `json:"defaultProjectUser,omitempty"` + BuilderImage string `json:"builderImage"` + BuilderRegistryServer string `json:"builderRegistryServer"` + DefaultProjectImage string `json:"defaultProjectImage"` + DefaultProjectUser string `json:"defaultProjectUser"` Frps *FRPSConfig `json:"frps,omitempty"` - HeadscalePort *int32 `json:"headscalePort,omitempty"` - Id *string `json:"id,omitempty"` - LocalBuilderRegistryImage *string `json:"localBuilderRegistryImage,omitempty"` - LocalBuilderRegistryPort *int32 `json:"localBuilderRegistryPort,omitempty"` - LogFilePath *string `json:"logFilePath,omitempty"` - ProvidersDir *string `json:"providersDir,omitempty"` - RegistryUrl *string `json:"registryUrl,omitempty"` - ServerDownloadUrl *string `json:"serverDownloadUrl,omitempty"` + HeadscalePort int32 `json:"headscalePort"` + Id string `json:"id"` + LocalBuilderRegistryImage string `json:"localBuilderRegistryImage"` + LocalBuilderRegistryPort int32 `json:"localBuilderRegistryPort"` + LogFilePath string `json:"logFilePath"` + ProvidersDir string `json:"providersDir"` + RegistryUrl string `json:"registryUrl"` + ServerDownloadUrl string `json:"serverDownloadUrl"` } +type _ServerConfig ServerConfig + // NewServerConfig instantiates a new ServerConfig 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 NewServerConfig() *ServerConfig { +func NewServerConfig(apiPort int32, binariesPath string, builderImage string, builderRegistryServer string, defaultProjectImage string, defaultProjectUser string, headscalePort int32, id string, localBuilderRegistryImage string, localBuilderRegistryPort int32, logFilePath string, providersDir string, registryUrl string, serverDownloadUrl string) *ServerConfig { this := ServerConfig{} + this.ApiPort = apiPort + this.BinariesPath = binariesPath + this.BuilderImage = builderImage + this.BuilderRegistryServer = builderRegistryServer + this.DefaultProjectImage = defaultProjectImage + this.DefaultProjectUser = defaultProjectUser + this.HeadscalePort = headscalePort + this.Id = id + this.LocalBuilderRegistryImage = localBuilderRegistryImage + this.LocalBuilderRegistryPort = localBuilderRegistryPort + this.LogFilePath = logFilePath + this.ProvidersDir = providersDir + this.RegistryUrl = registryUrl + this.ServerDownloadUrl = serverDownloadUrl return &this } @@ -54,68 +72,52 @@ func NewServerConfigWithDefaults() *ServerConfig { return &this } -// GetApiPort returns the ApiPort field value if set, zero value otherwise. +// GetApiPort returns the ApiPort field value func (o *ServerConfig) GetApiPort() int32 { - if o == nil || IsNil(o.ApiPort) { + if o == nil { var ret int32 return ret } - return *o.ApiPort + + return o.ApiPort } -// GetApiPortOk returns a tuple with the ApiPort field value if set, nil otherwise +// GetApiPortOk returns a tuple with the ApiPort field value // and a boolean to check if the value has been set. func (o *ServerConfig) GetApiPortOk() (*int32, bool) { - if o == nil || IsNil(o.ApiPort) { + if o == nil { return nil, false } - return o.ApiPort, true -} - -// HasApiPort returns a boolean if a field has been set. -func (o *ServerConfig) HasApiPort() bool { - if o != nil && !IsNil(o.ApiPort) { - return true - } - - return false + return &o.ApiPort, true } -// SetApiPort gets a reference to the given int32 and assigns it to the ApiPort field. +// SetApiPort sets field value func (o *ServerConfig) SetApiPort(v int32) { - o.ApiPort = &v + o.ApiPort = v } -// GetBinariesPath returns the BinariesPath field value if set, zero value otherwise. +// GetBinariesPath returns the BinariesPath field value func (o *ServerConfig) GetBinariesPath() string { - if o == nil || IsNil(o.BinariesPath) { + if o == nil { var ret string return ret } - return *o.BinariesPath + + return o.BinariesPath } -// GetBinariesPathOk returns a tuple with the BinariesPath field value if set, nil otherwise +// GetBinariesPathOk returns a tuple with the BinariesPath field value // and a boolean to check if the value has been set. func (o *ServerConfig) GetBinariesPathOk() (*string, bool) { - if o == nil || IsNil(o.BinariesPath) { + if o == nil { return nil, false } - return o.BinariesPath, true -} - -// HasBinariesPath returns a boolean if a field has been set. -func (o *ServerConfig) HasBinariesPath() bool { - if o != nil && !IsNil(o.BinariesPath) { - return true - } - - return false + return &o.BinariesPath, true } -// SetBinariesPath gets a reference to the given string and assigns it to the BinariesPath field. +// SetBinariesPath sets field value func (o *ServerConfig) SetBinariesPath(v string) { - o.BinariesPath = &v + o.BinariesPath = v } // GetBuildImageNamespace returns the BuildImageNamespace field value if set, zero value otherwise. @@ -150,132 +152,100 @@ func (o *ServerConfig) SetBuildImageNamespace(v string) { o.BuildImageNamespace = &v } -// GetBuilderImage returns the BuilderImage field value if set, zero value otherwise. +// GetBuilderImage returns the BuilderImage field value func (o *ServerConfig) GetBuilderImage() string { - if o == nil || IsNil(o.BuilderImage) { + if o == nil { var ret string return ret } - return *o.BuilderImage + + return o.BuilderImage } -// GetBuilderImageOk returns a tuple with the BuilderImage field value if set, nil otherwise +// GetBuilderImageOk returns a tuple with the BuilderImage field value // and a boolean to check if the value has been set. func (o *ServerConfig) GetBuilderImageOk() (*string, bool) { - if o == nil || IsNil(o.BuilderImage) { + if o == nil { return nil, false } - return o.BuilderImage, true + return &o.BuilderImage, true } -// HasBuilderImage returns a boolean if a field has been set. -func (o *ServerConfig) HasBuilderImage() bool { - if o != nil && !IsNil(o.BuilderImage) { - return true - } - - return false -} - -// SetBuilderImage gets a reference to the given string and assigns it to the BuilderImage field. +// SetBuilderImage sets field value func (o *ServerConfig) SetBuilderImage(v string) { - o.BuilderImage = &v + o.BuilderImage = v } -// GetBuilderRegistryServer returns the BuilderRegistryServer field value if set, zero value otherwise. +// GetBuilderRegistryServer returns the BuilderRegistryServer field value func (o *ServerConfig) GetBuilderRegistryServer() string { - if o == nil || IsNil(o.BuilderRegistryServer) { + if o == nil { var ret string return ret } - return *o.BuilderRegistryServer + + return o.BuilderRegistryServer } -// GetBuilderRegistryServerOk returns a tuple with the BuilderRegistryServer field value if set, nil otherwise +// GetBuilderRegistryServerOk returns a tuple with the BuilderRegistryServer field value // and a boolean to check if the value has been set. func (o *ServerConfig) GetBuilderRegistryServerOk() (*string, bool) { - if o == nil || IsNil(o.BuilderRegistryServer) { + if o == nil { return nil, false } - return o.BuilderRegistryServer, true + return &o.BuilderRegistryServer, true } -// HasBuilderRegistryServer returns a boolean if a field has been set. -func (o *ServerConfig) HasBuilderRegistryServer() bool { - if o != nil && !IsNil(o.BuilderRegistryServer) { - return true - } - - return false -} - -// SetBuilderRegistryServer gets a reference to the given string and assigns it to the BuilderRegistryServer field. +// SetBuilderRegistryServer sets field value func (o *ServerConfig) SetBuilderRegistryServer(v string) { - o.BuilderRegistryServer = &v + o.BuilderRegistryServer = v } -// GetDefaultProjectImage returns the DefaultProjectImage field value if set, zero value otherwise. +// GetDefaultProjectImage returns the DefaultProjectImage field value func (o *ServerConfig) GetDefaultProjectImage() string { - if o == nil || IsNil(o.DefaultProjectImage) { + if o == nil { var ret string return ret } - return *o.DefaultProjectImage + + return o.DefaultProjectImage } -// GetDefaultProjectImageOk returns a tuple with the DefaultProjectImage field value if set, nil otherwise +// GetDefaultProjectImageOk returns a tuple with the DefaultProjectImage field value // and a boolean to check if the value has been set. func (o *ServerConfig) GetDefaultProjectImageOk() (*string, bool) { - if o == nil || IsNil(o.DefaultProjectImage) { + if o == nil { return nil, false } - return o.DefaultProjectImage, true -} - -// HasDefaultProjectImage returns a boolean if a field has been set. -func (o *ServerConfig) HasDefaultProjectImage() bool { - if o != nil && !IsNil(o.DefaultProjectImage) { - return true - } - - return false + return &o.DefaultProjectImage, true } -// SetDefaultProjectImage gets a reference to the given string and assigns it to the DefaultProjectImage field. +// SetDefaultProjectImage sets field value func (o *ServerConfig) SetDefaultProjectImage(v string) { - o.DefaultProjectImage = &v + o.DefaultProjectImage = v } -// GetDefaultProjectUser returns the DefaultProjectUser field value if set, zero value otherwise. +// GetDefaultProjectUser returns the DefaultProjectUser field value func (o *ServerConfig) GetDefaultProjectUser() string { - if o == nil || IsNil(o.DefaultProjectUser) { + if o == nil { var ret string return ret } - return *o.DefaultProjectUser + + return o.DefaultProjectUser } -// GetDefaultProjectUserOk returns a tuple with the DefaultProjectUser field value if set, nil otherwise +// GetDefaultProjectUserOk returns a tuple with the DefaultProjectUser field value // and a boolean to check if the value has been set. func (o *ServerConfig) GetDefaultProjectUserOk() (*string, bool) { - if o == nil || IsNil(o.DefaultProjectUser) { + if o == nil { return nil, false } - return o.DefaultProjectUser, true -} - -// HasDefaultProjectUser returns a boolean if a field has been set. -func (o *ServerConfig) HasDefaultProjectUser() bool { - if o != nil && !IsNil(o.DefaultProjectUser) { - return true - } - - return false + return &o.DefaultProjectUser, true } -// SetDefaultProjectUser gets a reference to the given string and assigns it to the DefaultProjectUser field. +// SetDefaultProjectUser sets field value func (o *ServerConfig) SetDefaultProjectUser(v string) { - o.DefaultProjectUser = &v + o.DefaultProjectUser = v } // GetFrps returns the Frps field value if set, zero value otherwise. @@ -310,260 +280,196 @@ func (o *ServerConfig) SetFrps(v FRPSConfig) { o.Frps = &v } -// GetHeadscalePort returns the HeadscalePort field value if set, zero value otherwise. +// GetHeadscalePort returns the HeadscalePort field value func (o *ServerConfig) GetHeadscalePort() int32 { - if o == nil || IsNil(o.HeadscalePort) { + if o == nil { var ret int32 return ret } - return *o.HeadscalePort + + return o.HeadscalePort } -// GetHeadscalePortOk returns a tuple with the HeadscalePort field value if set, nil otherwise +// GetHeadscalePortOk returns a tuple with the HeadscalePort field value // and a boolean to check if the value has been set. func (o *ServerConfig) GetHeadscalePortOk() (*int32, bool) { - if o == nil || IsNil(o.HeadscalePort) { + if o == nil { return nil, false } - return o.HeadscalePort, true + return &o.HeadscalePort, true } -// HasHeadscalePort returns a boolean if a field has been set. -func (o *ServerConfig) HasHeadscalePort() bool { - if o != nil && !IsNil(o.HeadscalePort) { - return true - } - - return false -} - -// SetHeadscalePort gets a reference to the given int32 and assigns it to the HeadscalePort field. +// SetHeadscalePort sets field value func (o *ServerConfig) SetHeadscalePort(v int32) { - o.HeadscalePort = &v + o.HeadscalePort = v } -// GetId returns the Id field value if set, zero value otherwise. +// GetId returns the Id field value func (o *ServerConfig) GetId() string { - if o == nil || IsNil(o.Id) { + if o == nil { var ret string return ret } - return *o.Id + + return o.Id } -// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// GetIdOk returns a tuple with the Id field value // and a boolean to check if the value has been set. func (o *ServerConfig) GetIdOk() (*string, bool) { - if o == nil || IsNil(o.Id) { + if o == nil { return nil, false } - return o.Id, true + return &o.Id, true } -// HasId returns a boolean if a field has been set. -func (o *ServerConfig) HasId() bool { - if o != nil && !IsNil(o.Id) { - return true - } - - return false -} - -// SetId gets a reference to the given string and assigns it to the Id field. +// SetId sets field value func (o *ServerConfig) SetId(v string) { - o.Id = &v + o.Id = v } -// GetLocalBuilderRegistryImage returns the LocalBuilderRegistryImage field value if set, zero value otherwise. +// GetLocalBuilderRegistryImage returns the LocalBuilderRegistryImage field value func (o *ServerConfig) GetLocalBuilderRegistryImage() string { - if o == nil || IsNil(o.LocalBuilderRegistryImage) { + if o == nil { var ret string return ret } - return *o.LocalBuilderRegistryImage + + return o.LocalBuilderRegistryImage } -// GetLocalBuilderRegistryImageOk returns a tuple with the LocalBuilderRegistryImage field value if set, nil otherwise +// GetLocalBuilderRegistryImageOk returns a tuple with the LocalBuilderRegistryImage field value // and a boolean to check if the value has been set. func (o *ServerConfig) GetLocalBuilderRegistryImageOk() (*string, bool) { - if o == nil || IsNil(o.LocalBuilderRegistryImage) { + if o == nil { return nil, false } - return o.LocalBuilderRegistryImage, true -} - -// HasLocalBuilderRegistryImage returns a boolean if a field has been set. -func (o *ServerConfig) HasLocalBuilderRegistryImage() bool { - if o != nil && !IsNil(o.LocalBuilderRegistryImage) { - return true - } - - return false + return &o.LocalBuilderRegistryImage, true } -// SetLocalBuilderRegistryImage gets a reference to the given string and assigns it to the LocalBuilderRegistryImage field. +// SetLocalBuilderRegistryImage sets field value func (o *ServerConfig) SetLocalBuilderRegistryImage(v string) { - o.LocalBuilderRegistryImage = &v + o.LocalBuilderRegistryImage = v } -// GetLocalBuilderRegistryPort returns the LocalBuilderRegistryPort field value if set, zero value otherwise. +// GetLocalBuilderRegistryPort returns the LocalBuilderRegistryPort field value func (o *ServerConfig) GetLocalBuilderRegistryPort() int32 { - if o == nil || IsNil(o.LocalBuilderRegistryPort) { + if o == nil { var ret int32 return ret } - return *o.LocalBuilderRegistryPort + + return o.LocalBuilderRegistryPort } -// GetLocalBuilderRegistryPortOk returns a tuple with the LocalBuilderRegistryPort field value if set, nil otherwise +// GetLocalBuilderRegistryPortOk returns a tuple with the LocalBuilderRegistryPort field value // and a boolean to check if the value has been set. func (o *ServerConfig) GetLocalBuilderRegistryPortOk() (*int32, bool) { - if o == nil || IsNil(o.LocalBuilderRegistryPort) { + if o == nil { return nil, false } - return o.LocalBuilderRegistryPort, true -} - -// HasLocalBuilderRegistryPort returns a boolean if a field has been set. -func (o *ServerConfig) HasLocalBuilderRegistryPort() bool { - if o != nil && !IsNil(o.LocalBuilderRegistryPort) { - return true - } - - return false + return &o.LocalBuilderRegistryPort, true } -// SetLocalBuilderRegistryPort gets a reference to the given int32 and assigns it to the LocalBuilderRegistryPort field. +// SetLocalBuilderRegistryPort sets field value func (o *ServerConfig) SetLocalBuilderRegistryPort(v int32) { - o.LocalBuilderRegistryPort = &v + o.LocalBuilderRegistryPort = v } -// GetLogFilePath returns the LogFilePath field value if set, zero value otherwise. +// GetLogFilePath returns the LogFilePath field value func (o *ServerConfig) GetLogFilePath() string { - if o == nil || IsNil(o.LogFilePath) { + if o == nil { var ret string return ret } - return *o.LogFilePath + + return o.LogFilePath } -// GetLogFilePathOk returns a tuple with the LogFilePath field value if set, nil otherwise +// GetLogFilePathOk returns a tuple with the LogFilePath field value // and a boolean to check if the value has been set. func (o *ServerConfig) GetLogFilePathOk() (*string, bool) { - if o == nil || IsNil(o.LogFilePath) { + if o == nil { return nil, false } - return o.LogFilePath, true -} - -// HasLogFilePath returns a boolean if a field has been set. -func (o *ServerConfig) HasLogFilePath() bool { - if o != nil && !IsNil(o.LogFilePath) { - return true - } - - return false + return &o.LogFilePath, true } -// SetLogFilePath gets a reference to the given string and assigns it to the LogFilePath field. +// SetLogFilePath sets field value func (o *ServerConfig) SetLogFilePath(v string) { - o.LogFilePath = &v + o.LogFilePath = v } -// GetProvidersDir returns the ProvidersDir field value if set, zero value otherwise. +// GetProvidersDir returns the ProvidersDir field value func (o *ServerConfig) GetProvidersDir() string { - if o == nil || IsNil(o.ProvidersDir) { + if o == nil { var ret string return ret } - return *o.ProvidersDir + + return o.ProvidersDir } -// GetProvidersDirOk returns a tuple with the ProvidersDir field value if set, nil otherwise +// GetProvidersDirOk returns a tuple with the ProvidersDir field value // and a boolean to check if the value has been set. func (o *ServerConfig) GetProvidersDirOk() (*string, bool) { - if o == nil || IsNil(o.ProvidersDir) { + if o == nil { return nil, false } - return o.ProvidersDir, true -} - -// HasProvidersDir returns a boolean if a field has been set. -func (o *ServerConfig) HasProvidersDir() bool { - if o != nil && !IsNil(o.ProvidersDir) { - return true - } - - return false + return &o.ProvidersDir, true } -// SetProvidersDir gets a reference to the given string and assigns it to the ProvidersDir field. +// SetProvidersDir sets field value func (o *ServerConfig) SetProvidersDir(v string) { - o.ProvidersDir = &v + o.ProvidersDir = v } -// GetRegistryUrl returns the RegistryUrl field value if set, zero value otherwise. +// GetRegistryUrl returns the RegistryUrl field value func (o *ServerConfig) GetRegistryUrl() string { - if o == nil || IsNil(o.RegistryUrl) { + if o == nil { var ret string return ret } - return *o.RegistryUrl + + return o.RegistryUrl } -// GetRegistryUrlOk returns a tuple with the RegistryUrl field value if set, nil otherwise +// GetRegistryUrlOk returns a tuple with the RegistryUrl field value // and a boolean to check if the value has been set. func (o *ServerConfig) GetRegistryUrlOk() (*string, bool) { - if o == nil || IsNil(o.RegistryUrl) { + if o == nil { return nil, false } - return o.RegistryUrl, true + return &o.RegistryUrl, true } -// HasRegistryUrl returns a boolean if a field has been set. -func (o *ServerConfig) HasRegistryUrl() bool { - if o != nil && !IsNil(o.RegistryUrl) { - return true - } - - return false -} - -// SetRegistryUrl gets a reference to the given string and assigns it to the RegistryUrl field. +// SetRegistryUrl sets field value func (o *ServerConfig) SetRegistryUrl(v string) { - o.RegistryUrl = &v + o.RegistryUrl = v } -// GetServerDownloadUrl returns the ServerDownloadUrl field value if set, zero value otherwise. +// GetServerDownloadUrl returns the ServerDownloadUrl field value func (o *ServerConfig) GetServerDownloadUrl() string { - if o == nil || IsNil(o.ServerDownloadUrl) { + if o == nil { var ret string return ret } - return *o.ServerDownloadUrl + + return o.ServerDownloadUrl } -// GetServerDownloadUrlOk returns a tuple with the ServerDownloadUrl field value if set, nil otherwise +// GetServerDownloadUrlOk returns a tuple with the ServerDownloadUrl field value // and a boolean to check if the value has been set. func (o *ServerConfig) GetServerDownloadUrlOk() (*string, bool) { - if o == nil || IsNil(o.ServerDownloadUrl) { + if o == nil { return nil, false } - return o.ServerDownloadUrl, true + return &o.ServerDownloadUrl, true } -// HasServerDownloadUrl returns a boolean if a field has been set. -func (o *ServerConfig) HasServerDownloadUrl() bool { - if o != nil && !IsNil(o.ServerDownloadUrl) { - return true - } - - return false -} - -// SetServerDownloadUrl gets a reference to the given string and assigns it to the ServerDownloadUrl field. +// SetServerDownloadUrl sets field value func (o *ServerConfig) SetServerDownloadUrl(v string) { - o.ServerDownloadUrl = &v + o.ServerDownloadUrl = v } func (o ServerConfig) MarshalJSON() ([]byte, error) { @@ -576,55 +482,77 @@ func (o ServerConfig) MarshalJSON() ([]byte, error) { func (o ServerConfig) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.ApiPort) { - toSerialize["apiPort"] = o.ApiPort - } - if !IsNil(o.BinariesPath) { - toSerialize["binariesPath"] = o.BinariesPath - } + toSerialize["apiPort"] = o.ApiPort + toSerialize["binariesPath"] = o.BinariesPath if !IsNil(o.BuildImageNamespace) { toSerialize["buildImageNamespace"] = o.BuildImageNamespace } - if !IsNil(o.BuilderImage) { - toSerialize["builderImage"] = o.BuilderImage - } - if !IsNil(o.BuilderRegistryServer) { - toSerialize["builderRegistryServer"] = o.BuilderRegistryServer - } - if !IsNil(o.DefaultProjectImage) { - toSerialize["defaultProjectImage"] = o.DefaultProjectImage - } - if !IsNil(o.DefaultProjectUser) { - toSerialize["defaultProjectUser"] = o.DefaultProjectUser - } + toSerialize["builderImage"] = o.BuilderImage + toSerialize["builderRegistryServer"] = o.BuilderRegistryServer + toSerialize["defaultProjectImage"] = o.DefaultProjectImage + toSerialize["defaultProjectUser"] = o.DefaultProjectUser if !IsNil(o.Frps) { toSerialize["frps"] = o.Frps } - if !IsNil(o.HeadscalePort) { - toSerialize["headscalePort"] = o.HeadscalePort - } - if !IsNil(o.Id) { - toSerialize["id"] = o.Id - } - if !IsNil(o.LocalBuilderRegistryImage) { - toSerialize["localBuilderRegistryImage"] = o.LocalBuilderRegistryImage - } - if !IsNil(o.LocalBuilderRegistryPort) { - toSerialize["localBuilderRegistryPort"] = o.LocalBuilderRegistryPort - } - if !IsNil(o.LogFilePath) { - toSerialize["logFilePath"] = o.LogFilePath + toSerialize["headscalePort"] = o.HeadscalePort + toSerialize["id"] = o.Id + toSerialize["localBuilderRegistryImage"] = o.LocalBuilderRegistryImage + toSerialize["localBuilderRegistryPort"] = o.LocalBuilderRegistryPort + toSerialize["logFilePath"] = o.LogFilePath + toSerialize["providersDir"] = o.ProvidersDir + toSerialize["registryUrl"] = o.RegistryUrl + toSerialize["serverDownloadUrl"] = o.ServerDownloadUrl + return toSerialize, nil +} + +func (o *ServerConfig) 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{ + "apiPort", + "binariesPath", + "builderImage", + "builderRegistryServer", + "defaultProjectImage", + "defaultProjectUser", + "headscalePort", + "id", + "localBuilderRegistryImage", + "localBuilderRegistryPort", + "logFilePath", + "providersDir", + "registryUrl", + "serverDownloadUrl", } - if !IsNil(o.ProvidersDir) { - toSerialize["providersDir"] = o.ProvidersDir + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - if !IsNil(o.RegistryUrl) { - toSerialize["registryUrl"] = o.RegistryUrl + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } } - if !IsNil(o.ServerDownloadUrl) { - toSerialize["serverDownloadUrl"] = o.ServerDownloadUrl + + varServerConfig := _ServerConfig{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varServerConfig) + + if err != nil { + return err } - return toSerialize, nil + + *o = ServerConfig(varServerConfig) + + return err } type NullableServerConfig struct { diff --git a/pkg/apiclient/model_set_git_provider_config.go b/pkg/apiclient/model_set_git_provider_config.go new file mode 100644 index 0000000000..5fff1bb051 --- /dev/null +++ b/pkg/apiclient/model_set_git_provider_config.go @@ -0,0 +1,256 @@ +/* +Daytona Server API + +Daytona Server API + +API version: v0.0.0-dev +*/ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package apiclient + +import ( + "bytes" + "encoding/json" + "fmt" +) + +// checks if the SetGitProviderConfig type satisfies the MappedNullable interface at compile time +var _ MappedNullable = &SetGitProviderConfig{} + +// SetGitProviderConfig struct for SetGitProviderConfig +type SetGitProviderConfig struct { + BaseApiUrl *string `json:"baseApiUrl,omitempty"` + Id string `json:"id"` + Token string `json:"token"` + Username *string `json:"username,omitempty"` +} + +type _SetGitProviderConfig SetGitProviderConfig + +// NewSetGitProviderConfig instantiates a new SetGitProviderConfig 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 NewSetGitProviderConfig(id string, token string) *SetGitProviderConfig { + this := SetGitProviderConfig{} + this.Id = id + this.Token = token + return &this +} + +// NewSetGitProviderConfigWithDefaults instantiates a new SetGitProviderConfig 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 NewSetGitProviderConfigWithDefaults() *SetGitProviderConfig { + this := SetGitProviderConfig{} + return &this +} + +// GetBaseApiUrl returns the BaseApiUrl field value if set, zero value otherwise. +func (o *SetGitProviderConfig) GetBaseApiUrl() string { + if o == nil || IsNil(o.BaseApiUrl) { + var ret string + return ret + } + return *o.BaseApiUrl +} + +// GetBaseApiUrlOk returns a tuple with the BaseApiUrl field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SetGitProviderConfig) GetBaseApiUrlOk() (*string, bool) { + if o == nil || IsNil(o.BaseApiUrl) { + return nil, false + } + return o.BaseApiUrl, true +} + +// HasBaseApiUrl returns a boolean if a field has been set. +func (o *SetGitProviderConfig) HasBaseApiUrl() bool { + if o != nil && !IsNil(o.BaseApiUrl) { + return true + } + + return false +} + +// SetBaseApiUrl gets a reference to the given string and assigns it to the BaseApiUrl field. +func (o *SetGitProviderConfig) SetBaseApiUrl(v string) { + o.BaseApiUrl = &v +} + +// GetId returns the Id field value +func (o *SetGitProviderConfig) 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 *SetGitProviderConfig) GetIdOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Id, true +} + +// SetId sets field value +func (o *SetGitProviderConfig) SetId(v string) { + o.Id = v +} + +// GetToken returns the Token field value +func (o *SetGitProviderConfig) GetToken() string { + if o == nil { + var ret string + return ret + } + + return o.Token +} + +// GetTokenOk returns a tuple with the Token field value +// and a boolean to check if the value has been set. +func (o *SetGitProviderConfig) GetTokenOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Token, true +} + +// SetToken sets field value +func (o *SetGitProviderConfig) SetToken(v string) { + o.Token = v +} + +// GetUsername returns the Username field value if set, zero value otherwise. +func (o *SetGitProviderConfig) GetUsername() string { + if o == nil || IsNil(o.Username) { + var ret string + return ret + } + return *o.Username +} + +// GetUsernameOk returns a tuple with the Username field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *SetGitProviderConfig) GetUsernameOk() (*string, bool) { + if o == nil || IsNil(o.Username) { + return nil, false + } + return o.Username, true +} + +// HasUsername returns a boolean if a field has been set. +func (o *SetGitProviderConfig) HasUsername() bool { + if o != nil && !IsNil(o.Username) { + return true + } + + return false +} + +// SetUsername gets a reference to the given string and assigns it to the Username field. +func (o *SetGitProviderConfig) SetUsername(v string) { + o.Username = &v +} + +func (o SetGitProviderConfig) MarshalJSON() ([]byte, error) { + toSerialize, err := o.ToMap() + if err != nil { + return []byte{}, err + } + return json.Marshal(toSerialize) +} + +func (o SetGitProviderConfig) ToMap() (map[string]interface{}, error) { + toSerialize := map[string]interface{}{} + if !IsNil(o.BaseApiUrl) { + toSerialize["baseApiUrl"] = o.BaseApiUrl + } + toSerialize["id"] = o.Id + toSerialize["token"] = o.Token + if !IsNil(o.Username) { + toSerialize["username"] = o.Username + } + return toSerialize, nil +} + +func (o *SetGitProviderConfig) 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", + "token", + } + + 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) + } + } + + varSetGitProviderConfig := _SetGitProviderConfig{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varSetGitProviderConfig) + + if err != nil { + return err + } + + *o = SetGitProviderConfig(varSetGitProviderConfig) + + return err +} + +type NullableSetGitProviderConfig struct { + value *SetGitProviderConfig + isSet bool +} + +func (v NullableSetGitProviderConfig) Get() *SetGitProviderConfig { + return v.value +} + +func (v *NullableSetGitProviderConfig) Set(val *SetGitProviderConfig) { + v.value = val + v.isSet = true +} + +func (v NullableSetGitProviderConfig) IsSet() bool { + return v.isSet +} + +func (v *NullableSetGitProviderConfig) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableSetGitProviderConfig(val *SetGitProviderConfig) *NullableSetGitProviderConfig { + return &NullableSetGitProviderConfig{value: val, isSet: true} +} + +func (v NullableSetGitProviderConfig) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableSetGitProviderConfig) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/pkg/apiclient/model_set_project_state.go b/pkg/apiclient/model_set_project_state.go index d6cdb3ada4..eebfd1d605 100644 --- a/pkg/apiclient/model_set_project_state.go +++ b/pkg/apiclient/model_set_project_state.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the SetProjectState type satisfies the MappedNullable interface at compile time @@ -20,15 +22,18 @@ var _ MappedNullable = &SetProjectState{} // SetProjectState struct for SetProjectState type SetProjectState struct { GitStatus *GitStatus `json:"gitStatus,omitempty"` - Uptime *int32 `json:"uptime,omitempty"` + Uptime int32 `json:"uptime"` } +type _SetProjectState SetProjectState + // NewSetProjectState instantiates a new SetProjectState 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 NewSetProjectState() *SetProjectState { +func NewSetProjectState(uptime int32) *SetProjectState { this := SetProjectState{} + this.Uptime = uptime return &this } @@ -72,36 +77,28 @@ func (o *SetProjectState) SetGitStatus(v GitStatus) { o.GitStatus = &v } -// GetUptime returns the Uptime field value if set, zero value otherwise. +// GetUptime returns the Uptime field value func (o *SetProjectState) GetUptime() int32 { - if o == nil || IsNil(o.Uptime) { + if o == nil { var ret int32 return ret } - return *o.Uptime + + return o.Uptime } -// GetUptimeOk returns a tuple with the Uptime field value if set, nil otherwise +// GetUptimeOk returns a tuple with the Uptime field value // and a boolean to check if the value has been set. func (o *SetProjectState) GetUptimeOk() (*int32, bool) { - if o == nil || IsNil(o.Uptime) { + if o == nil { return nil, false } - return o.Uptime, true + return &o.Uptime, true } -// HasUptime returns a boolean if a field has been set. -func (o *SetProjectState) HasUptime() bool { - if o != nil && !IsNil(o.Uptime) { - return true - } - - return false -} - -// SetUptime gets a reference to the given int32 and assigns it to the Uptime field. +// SetUptime sets field value func (o *SetProjectState) SetUptime(v int32) { - o.Uptime = &v + o.Uptime = v } func (o SetProjectState) MarshalJSON() ([]byte, error) { @@ -117,12 +114,47 @@ func (o SetProjectState) ToMap() (map[string]interface{}, error) { if !IsNil(o.GitStatus) { toSerialize["gitStatus"] = o.GitStatus } - if !IsNil(o.Uptime) { - toSerialize["uptime"] = o.Uptime - } + toSerialize["uptime"] = o.Uptime return toSerialize, nil } +func (o *SetProjectState) 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{ + "uptime", + } + + 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) + } + } + + varSetProjectState := _SetProjectState{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varSetProjectState) + + if err != nil { + return err + } + + *o = SetProjectState(varSetProjectState) + + return err +} + type NullableSetProjectState struct { value *SetProjectState isSet bool diff --git a/pkg/apiclient/model_workspace.go b/pkg/apiclient/model_workspace.go index c73386aea5..be046fceb2 100644 --- a/pkg/apiclient/model_workspace.go +++ b/pkg/apiclient/model_workspace.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the Workspace type satisfies the MappedNullable interface at compile time @@ -19,18 +21,24 @@ var _ MappedNullable = &Workspace{} // Workspace struct for Workspace type Workspace struct { - Id *string `json:"id,omitempty"` - Name *string `json:"name,omitempty"` - Projects []Project `json:"projects,omitempty"` - Target *string `json:"target,omitempty"` + Id string `json:"id"` + Name string `json:"name"` + Projects []Project `json:"projects"` + Target string `json:"target"` } +type _Workspace Workspace + // NewWorkspace instantiates a new Workspace 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 NewWorkspace() *Workspace { +func NewWorkspace(id string, name string, projects []Project, target string) *Workspace { this := Workspace{} + this.Id = id + this.Name = name + this.Projects = projects + this.Target = target return &this } @@ -42,132 +50,100 @@ func NewWorkspaceWithDefaults() *Workspace { return &this } -// GetId returns the Id field value if set, zero value otherwise. +// GetId returns the Id field value func (o *Workspace) GetId() string { - if o == nil || IsNil(o.Id) { + if o == nil { var ret string return ret } - return *o.Id + + return o.Id } -// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// GetIdOk returns a tuple with the Id field value // and a boolean to check if the value has been set. func (o *Workspace) GetIdOk() (*string, bool) { - if o == nil || IsNil(o.Id) { + if o == nil { return nil, false } - return o.Id, true + return &o.Id, true } -// HasId returns a boolean if a field has been set. -func (o *Workspace) HasId() bool { - if o != nil && !IsNil(o.Id) { - return true - } - - return false -} - -// SetId gets a reference to the given string and assigns it to the Id field. +// SetId sets field value func (o *Workspace) SetId(v string) { - o.Id = &v + o.Id = v } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *Workspace) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *Workspace) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true -} - -// HasName returns a boolean if a field has been set. -func (o *Workspace) HasName() bool { - if o != nil && !IsNil(o.Name) { - return true - } - - return false + return &o.Name, true } -// SetName gets a reference to the given string and assigns it to the Name field. +// SetName sets field value func (o *Workspace) SetName(v string) { - o.Name = &v + o.Name = v } -// GetProjects returns the Projects field value if set, zero value otherwise. +// GetProjects returns the Projects field value func (o *Workspace) GetProjects() []Project { - if o == nil || IsNil(o.Projects) { + if o == nil { var ret []Project return ret } + return o.Projects } -// GetProjectsOk returns a tuple with the Projects field value if set, nil otherwise +// GetProjectsOk returns a tuple with the Projects field value // and a boolean to check if the value has been set. func (o *Workspace) GetProjectsOk() ([]Project, bool) { - if o == nil || IsNil(o.Projects) { + if o == nil { return nil, false } return o.Projects, true } -// HasProjects returns a boolean if a field has been set. -func (o *Workspace) HasProjects() bool { - if o != nil && !IsNil(o.Projects) { - return true - } - - return false -} - -// SetProjects gets a reference to the given []Project and assigns it to the Projects field. +// SetProjects sets field value func (o *Workspace) SetProjects(v []Project) { o.Projects = v } -// GetTarget returns the Target field value if set, zero value otherwise. +// GetTarget returns the Target field value func (o *Workspace) GetTarget() string { - if o == nil || IsNil(o.Target) { + if o == nil { var ret string return ret } - return *o.Target + + return o.Target } -// GetTargetOk returns a tuple with the Target field value if set, nil otherwise +// GetTargetOk returns a tuple with the Target field value // and a boolean to check if the value has been set. func (o *Workspace) GetTargetOk() (*string, bool) { - if o == nil || IsNil(o.Target) { + if o == nil { return nil, false } - return o.Target, true -} - -// HasTarget returns a boolean if a field has been set. -func (o *Workspace) HasTarget() bool { - if o != nil && !IsNil(o.Target) { - return true - } - - return false + return &o.Target, true } -// SetTarget gets a reference to the given string and assigns it to the Target field. +// SetTarget sets field value func (o *Workspace) SetTarget(v string) { - o.Target = &v + o.Target = v } func (o Workspace) MarshalJSON() ([]byte, error) { @@ -180,19 +156,51 @@ func (o Workspace) MarshalJSON() ([]byte, error) { func (o Workspace) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Id) { - toSerialize["id"] = o.Id + toSerialize["id"] = o.Id + toSerialize["name"] = o.Name + toSerialize["projects"] = o.Projects + toSerialize["target"] = o.Target + return toSerialize, nil +} + +func (o *Workspace) 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", + "name", + "projects", + "target", } - if !IsNil(o.Name) { - toSerialize["name"] = o.Name + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - if !IsNil(o.Projects) { - toSerialize["projects"] = o.Projects + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } } - if !IsNil(o.Target) { - toSerialize["target"] = o.Target + + varWorkspace := _Workspace{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varWorkspace) + + if err != nil { + return err } - return toSerialize, nil + + *o = Workspace(varWorkspace) + + return err } type NullableWorkspace struct { diff --git a/pkg/apiclient/model_workspace_dto.go b/pkg/apiclient/model_workspace_dto.go index 39270342c4..c1c33251f9 100644 --- a/pkg/apiclient/model_workspace_dto.go +++ b/pkg/apiclient/model_workspace_dto.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the WorkspaceDTO type satisfies the MappedNullable interface at compile time @@ -19,19 +21,25 @@ var _ MappedNullable = &WorkspaceDTO{} // WorkspaceDTO struct for WorkspaceDTO type WorkspaceDTO struct { - Id *string `json:"id,omitempty"` + Id string `json:"id"` Info *WorkspaceInfo `json:"info,omitempty"` - Name *string `json:"name,omitempty"` - Projects []Project `json:"projects,omitempty"` - Target *string `json:"target,omitempty"` + Name string `json:"name"` + Projects []Project `json:"projects"` + Target string `json:"target"` } +type _WorkspaceDTO WorkspaceDTO + // NewWorkspaceDTO instantiates a new WorkspaceDTO 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 NewWorkspaceDTO() *WorkspaceDTO { +func NewWorkspaceDTO(id string, name string, projects []Project, target string) *WorkspaceDTO { this := WorkspaceDTO{} + this.Id = id + this.Name = name + this.Projects = projects + this.Target = target return &this } @@ -43,36 +51,28 @@ func NewWorkspaceDTOWithDefaults() *WorkspaceDTO { return &this } -// GetId returns the Id field value if set, zero value otherwise. +// GetId returns the Id field value func (o *WorkspaceDTO) GetId() string { - if o == nil || IsNil(o.Id) { + if o == nil { var ret string return ret } - return *o.Id + + return o.Id } -// GetIdOk returns a tuple with the Id field value if set, nil otherwise +// GetIdOk returns a tuple with the Id field value // and a boolean to check if the value has been set. func (o *WorkspaceDTO) GetIdOk() (*string, bool) { - if o == nil || IsNil(o.Id) { + if o == nil { return nil, false } - return o.Id, true -} - -// HasId returns a boolean if a field has been set. -func (o *WorkspaceDTO) HasId() bool { - if o != nil && !IsNil(o.Id) { - return true - } - - return false + return &o.Id, true } -// SetId gets a reference to the given string and assigns it to the Id field. +// SetId sets field value func (o *WorkspaceDTO) SetId(v string) { - o.Id = &v + o.Id = v } // GetInfo returns the Info field value if set, zero value otherwise. @@ -107,100 +107,76 @@ func (o *WorkspaceDTO) SetInfo(v WorkspaceInfo) { o.Info = &v } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *WorkspaceDTO) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *WorkspaceDTO) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true + return &o.Name, true } -// HasName returns a boolean if a field has been set. -func (o *WorkspaceDTO) 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. +// SetName sets field value func (o *WorkspaceDTO) SetName(v string) { - o.Name = &v + o.Name = v } -// GetProjects returns the Projects field value if set, zero value otherwise. +// GetProjects returns the Projects field value func (o *WorkspaceDTO) GetProjects() []Project { - if o == nil || IsNil(o.Projects) { + if o == nil { var ret []Project return ret } + return o.Projects } -// GetProjectsOk returns a tuple with the Projects field value if set, nil otherwise +// GetProjectsOk returns a tuple with the Projects field value // and a boolean to check if the value has been set. func (o *WorkspaceDTO) GetProjectsOk() ([]Project, bool) { - if o == nil || IsNil(o.Projects) { + if o == nil { return nil, false } return o.Projects, true } -// HasProjects returns a boolean if a field has been set. -func (o *WorkspaceDTO) HasProjects() bool { - if o != nil && !IsNil(o.Projects) { - return true - } - - return false -} - -// SetProjects gets a reference to the given []Project and assigns it to the Projects field. +// SetProjects sets field value func (o *WorkspaceDTO) SetProjects(v []Project) { o.Projects = v } -// GetTarget returns the Target field value if set, zero value otherwise. +// GetTarget returns the Target field value func (o *WorkspaceDTO) GetTarget() string { - if o == nil || IsNil(o.Target) { + if o == nil { var ret string return ret } - return *o.Target + + return o.Target } -// GetTargetOk returns a tuple with the Target field value if set, nil otherwise +// GetTargetOk returns a tuple with the Target field value // and a boolean to check if the value has been set. func (o *WorkspaceDTO) GetTargetOk() (*string, bool) { - if o == nil || IsNil(o.Target) { + if o == nil { return nil, false } - return o.Target, true + return &o.Target, true } -// HasTarget returns a boolean if a field has been set. -func (o *WorkspaceDTO) HasTarget() bool { - if o != nil && !IsNil(o.Target) { - return true - } - - return false -} - -// SetTarget gets a reference to the given string and assigns it to the Target field. +// SetTarget sets field value func (o *WorkspaceDTO) SetTarget(v string) { - o.Target = &v + o.Target = v } func (o WorkspaceDTO) MarshalJSON() ([]byte, error) { @@ -213,22 +189,54 @@ func (o WorkspaceDTO) MarshalJSON() ([]byte, error) { func (o WorkspaceDTO) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Id) { - toSerialize["id"] = o.Id - } + toSerialize["id"] = o.Id if !IsNil(o.Info) { toSerialize["info"] = o.Info } - if !IsNil(o.Name) { - toSerialize["name"] = o.Name + toSerialize["name"] = o.Name + toSerialize["projects"] = o.Projects + toSerialize["target"] = o.Target + return toSerialize, nil +} + +func (o *WorkspaceDTO) 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", + "name", + "projects", + "target", } - if !IsNil(o.Projects) { - toSerialize["projects"] = o.Projects + + allProperties := make(map[string]interface{}) + + err = json.Unmarshal(data, &allProperties) + + if err != nil { + return err } - if !IsNil(o.Target) { - toSerialize["target"] = o.Target + + for _, requiredProperty := range requiredProperties { + if _, exists := allProperties[requiredProperty]; !exists { + return fmt.Errorf("no value given for required property %v", requiredProperty) + } } - return toSerialize, nil + + varWorkspaceDTO := _WorkspaceDTO{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varWorkspaceDTO) + + if err != nil { + return err + } + + *o = WorkspaceDTO(varWorkspaceDTO) + + return err } type NullableWorkspaceDTO struct { diff --git a/pkg/apiclient/model_workspace_info.go b/pkg/apiclient/model_workspace_info.go index 0a45d422cb..7c7b22a6a3 100644 --- a/pkg/apiclient/model_workspace_info.go +++ b/pkg/apiclient/model_workspace_info.go @@ -11,7 +11,9 @@ API version: v0.0.0-dev package apiclient import ( + "bytes" "encoding/json" + "fmt" ) // checks if the WorkspaceInfo type satisfies the MappedNullable interface at compile time @@ -19,17 +21,21 @@ var _ MappedNullable = &WorkspaceInfo{} // WorkspaceInfo struct for WorkspaceInfo type WorkspaceInfo struct { - Name *string `json:"name,omitempty"` - Projects []ProjectInfo `json:"projects,omitempty"` + Name string `json:"name"` + Projects []ProjectInfo `json:"projects"` ProviderMetadata *string `json:"providerMetadata,omitempty"` } +type _WorkspaceInfo WorkspaceInfo + // NewWorkspaceInfo instantiates a new WorkspaceInfo 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 NewWorkspaceInfo() *WorkspaceInfo { +func NewWorkspaceInfo(name string, projects []ProjectInfo) *WorkspaceInfo { this := WorkspaceInfo{} + this.Name = name + this.Projects = projects return &this } @@ -41,66 +47,50 @@ func NewWorkspaceInfoWithDefaults() *WorkspaceInfo { return &this } -// GetName returns the Name field value if set, zero value otherwise. +// GetName returns the Name field value func (o *WorkspaceInfo) GetName() string { - if o == nil || IsNil(o.Name) { + if o == nil { var ret string return ret } - return *o.Name + + return o.Name } -// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// GetNameOk returns a tuple with the Name field value // and a boolean to check if the value has been set. func (o *WorkspaceInfo) GetNameOk() (*string, bool) { - if o == nil || IsNil(o.Name) { + if o == nil { return nil, false } - return o.Name, true + return &o.Name, true } -// HasName returns a boolean if a field has been set. -func (o *WorkspaceInfo) 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. +// SetName sets field value func (o *WorkspaceInfo) SetName(v string) { - o.Name = &v + o.Name = v } -// GetProjects returns the Projects field value if set, zero value otherwise. +// GetProjects returns the Projects field value func (o *WorkspaceInfo) GetProjects() []ProjectInfo { - if o == nil || IsNil(o.Projects) { + if o == nil { var ret []ProjectInfo return ret } + return o.Projects } -// GetProjectsOk returns a tuple with the Projects field value if set, nil otherwise +// GetProjectsOk returns a tuple with the Projects field value // and a boolean to check if the value has been set. func (o *WorkspaceInfo) GetProjectsOk() ([]ProjectInfo, bool) { - if o == nil || IsNil(o.Projects) { + if o == nil { return nil, false } return o.Projects, true } -// HasProjects returns a boolean if a field has been set. -func (o *WorkspaceInfo) HasProjects() bool { - if o != nil && !IsNil(o.Projects) { - return true - } - - return false -} - -// SetProjects gets a reference to the given []ProjectInfo and assigns it to the Projects field. +// SetProjects sets field value func (o *WorkspaceInfo) SetProjects(v []ProjectInfo) { o.Projects = v } @@ -147,18 +137,52 @@ func (o WorkspaceInfo) MarshalJSON() ([]byte, error) { func (o WorkspaceInfo) ToMap() (map[string]interface{}, error) { toSerialize := map[string]interface{}{} - if !IsNil(o.Name) { - toSerialize["name"] = o.Name - } - if !IsNil(o.Projects) { - toSerialize["projects"] = o.Projects - } + toSerialize["name"] = o.Name + toSerialize["projects"] = o.Projects if !IsNil(o.ProviderMetadata) { toSerialize["providerMetadata"] = o.ProviderMetadata } return toSerialize, nil } +func (o *WorkspaceInfo) 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", + "projects", + } + + 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) + } + } + + varWorkspaceInfo := _WorkspaceInfo{} + + decoder := json.NewDecoder(bytes.NewReader(data)) + decoder.DisallowUnknownFields() + err = decoder.Decode(&varWorkspaceInfo) + + if err != nil { + return err + } + + *o = WorkspaceInfo(varWorkspaceInfo) + + return err +} + type NullableWorkspaceInfo struct { value *WorkspaceInfo isSet bool diff --git a/pkg/apikey/apikey.go b/pkg/apikey/apikey.go index a24370c1d6..2900bca156 100644 --- a/pkg/apikey/apikey.go +++ b/pkg/apikey/apikey.go @@ -12,8 +12,8 @@ const ( ) type ApiKey struct { - KeyHash string `json:"keyHash"` - Type ApiKeyType `json:"type"` + KeyHash string `json:"keyHash" validate:"required"` + Type ApiKeyType `json:"type" validate:"required"` // Project or client name - Name string `json:"name"` + Name string `json:"name" validate:"required"` } // @name ApiKey diff --git a/pkg/build/build.go b/pkg/build/build.go index 47e9965a88..fc8e92a71b 100644 --- a/pkg/build/build.go +++ b/pkg/build/build.go @@ -16,10 +16,10 @@ const ( ) type Build struct { - Id string `json:"id"` - Hash string `json:"hash"` - State BuildState `json:"state"` - Project project.Project `json:"project"` - User string `json:"user"` - Image string `json:"image"` + Id string `json:"id" validate:"required"` + Hash string `json:"hash" validate:"required"` + State BuildState `json:"state" validate:"required"` + Project project.Project `json:"project" validate:"required"` + User string `json:"user" validate:"required"` + Image string `json:"image" validate:"required"` } // @name Build diff --git a/pkg/build/runner_config.go b/pkg/build/runner_config.go index e6b006e64c..752afc9130 100644 --- a/pkg/build/runner_config.go +++ b/pkg/build/runner_config.go @@ -15,9 +15,9 @@ import ( const DEFAULT_POLLER_INTERVAL = "0 */5 * * * *" type Config struct { - Id string `json:"id"` - Interval string `json:"interval"` - TelemetryEnabled bool `json:"telemetryEnabled"` + Id string `json:"id" validate:"required"` + Interval string `json:"interval" validate:"required"` + TelemetryEnabled bool `json:"telemetryEnabled" validate:"required"` } // @name BuildRunnerConfig func GetConfig() (*Config, error) { diff --git a/pkg/cmd/apikey/generate.go b/pkg/cmd/apikey/generate.go index 4eb4204da3..69feb25ba8 100644 --- a/pkg/cmd/apikey/generate.go +++ b/pkg/cmd/apikey/generate.go @@ -42,7 +42,7 @@ var GenerateCmd = &cobra.Command{ } for _, key := range apiKeyList { - if *key.Name == keyName { + if key.Name == keyName { log.Fatal("key name already exists, please choose a different one") } } @@ -57,7 +57,11 @@ var GenerateCmd = &cobra.Command{ log.Fatal(err) } - apiUrl := util.GetFrpcApiUrl(*serverConfig.Frps.Protocol, *serverConfig.Id, *serverConfig.Frps.Domain) + if serverConfig.Frps == nil { + log.Fatal("frps config is missing") + } + + apiUrl := util.GetFrpcApiUrl(serverConfig.Frps.Protocol, serverConfig.Id, serverConfig.Frps.Domain) view.Render(key, apiUrl) }, diff --git a/pkg/cmd/apikey/revoke.go b/pkg/cmd/apikey/revoke.go index 60e1d4925d..616970bc57 100644 --- a/pkg/cmd/apikey/revoke.go +++ b/pkg/cmd/apikey/revoke.go @@ -54,7 +54,7 @@ var revokeCmd = &cobra.Command{ if len(args) == 1 { for _, apiKey := range apiKeyList { - if *apiKey.Name == args[0] { + if apiKey.Name == args[0] { selectedApiKey = &apiKey break } @@ -75,11 +75,11 @@ var revokeCmd = &cobra.Command{ } if !yesFlag { - title := fmt.Sprintf("Revoke API Key '%s'?", *selectedApiKey.Name) - description := fmt.Sprintf("Are you sure you want to revoke '%s'?", *selectedApiKey.Name) - if apikeys.EqualsKeyHashFromApi(activeProfile.Api.Key, *selectedApiKey.KeyHash) { - title = fmt.Sprintf("Warning! API Key '%s' is attached to your active profile", *selectedApiKey.Name) - description = fmt.Sprintf("Revoking '%s' will lock out your active profile from accessing the server.", *selectedApiKey.Name) + title := fmt.Sprintf("Revoke API Key '%s'?", selectedApiKey.Name) + description := fmt.Sprintf("Are you sure you want to revoke '%s'?", selectedApiKey.Name) + if apikeys.EqualsKeyHashFromApi(activeProfile.Api.Key, selectedApiKey.KeyHash) { + title = fmt.Sprintf("Warning! API Key '%s' is attached to your active profile", selectedApiKey.Name) + description = fmt.Sprintf("Revoking '%s' will lock out your active profile from accessing the server.", selectedApiKey.Name) } form := huh.NewForm( @@ -98,7 +98,7 @@ var revokeCmd = &cobra.Command{ } if yesFlag { - _, err = apiClient.ApiKeyAPI.RevokeApiKey(ctx, *selectedApiKey.Name).Execute() + _, err = apiClient.ApiKeyAPI.RevokeApiKey(ctx, selectedApiKey.Name).Execute() if err != nil { log.Fatal(apiclient_util.HandleErrorResponse(nil, err)) } diff --git a/pkg/cmd/containerregistry/delete.go b/pkg/cmd/containerregistry/delete.go index 603ea6e254..d937c0cf7d 100644 --- a/pkg/cmd/containerregistry/delete.go +++ b/pkg/cmd/containerregistry/delete.go @@ -61,7 +61,7 @@ var containerRegistryDeleteCmd = &cobra.Command{ } } - selectedServer = *registryDto.Server + selectedServer = registryDto.Server } else { selectedServer = args[0] } diff --git a/pkg/cmd/containerregistry/set.go b/pkg/cmd/containerregistry/set.go index 1ded922669..a7aced1526 100644 --- a/pkg/cmd/containerregistry/set.go +++ b/pkg/cmd/containerregistry/set.go @@ -68,15 +68,15 @@ var containerRegistrySetCmd = &cobra.Command{ } editing := true - selectedServer = *registryDto.Server + selectedServer = registryDto.Server - if *registryDto.Server == containerregistry_view.NewRegistryServerIdentifier { + if registryDto.Server == containerregistry_view.NewRegistryServerIdentifier { editing = false registryView.Server, registryView.Username, registryView.Password = "", "", "" } else { - registryView.Server = *registryDto.Server - registryView.Username = *registryDto.Username - registryView.Password = *registryDto.Password + registryView.Server = registryDto.Server + registryView.Username = registryDto.Username + registryView.Password = registryDto.Password } containerregistry_view.RegistryCreationView(®istryView, containerRegistries, editing) @@ -84,9 +84,9 @@ var containerRegistrySetCmd = &cobra.Command{ } registryDto = &apiclient.ContainerRegistry{ - Server: ®istryView.Server, - Username: ®istryView.Username, - Password: ®istryView.Password, + Server: registryView.Server, + Username: registryView.Username, + Password: registryView.Password, } res, err = apiClient.ContainerRegistryAPI.SetContainerRegistry(context.Background(), url.QueryEscape(selectedServer)).ContainerRegistry(*registryDto).Execute() diff --git a/pkg/cmd/gitprovider/add.go b/pkg/cmd/gitprovider/add.go index 1b79fa76d7..ad986ffcc7 100644 --- a/pkg/cmd/gitprovider/add.go +++ b/pkg/cmd/gitprovider/add.go @@ -26,19 +26,17 @@ var GitProviderAddCmd = &cobra.Command{ log.Fatal(err) } - gitProviderData := apiclient.GitProvider{} - gitProviderData.Id = new(string) - gitProviderData.Username = new(string) - gitProviderData.Token = new(string) - gitProviderData.BaseApiUrl = new(string) + setGitProviderConfig := apiclient.SetGitProviderConfig{} + setGitProviderConfig.BaseApiUrl = new(string) + setGitProviderConfig.Username = new(string) - gitprovider_view.GitProviderSelectionView(&gitProviderData, nil, false) + gitprovider_view.GitProviderSelectionView(&setGitProviderConfig, nil, false) - if *gitProviderData.Id == "" { + if setGitProviderConfig.Id == "" { return } - res, err := apiClient.GitProviderAPI.SetGitProvider(ctx).GitProviderConfig(gitProviderData).Execute() + res, err := apiClient.GitProviderAPI.SetGitProvider(ctx).GitProviderConfig(setGitProviderConfig).Execute() if err != nil { log.Fatal(apiclient_util.HandleErrorResponse(res, err)) } diff --git a/pkg/cmd/gitprovider/delete.go b/pkg/cmd/gitprovider/delete.go index 09677ac699..3a3ef75c0c 100644 --- a/pkg/cmd/gitprovider/delete.go +++ b/pkg/cmd/gitprovider/delete.go @@ -31,11 +31,9 @@ var gitProviderDeleteCmd = &cobra.Command{ log.Fatal(apiclient_util.HandleErrorResponse(res, err)) } - var gitProviderData apiclient.GitProvider - gitProviderData.Id = new(string) - gitProviderData.Username = new(string) - gitProviderData.Token = new(string) + var gitProviderData apiclient.SetGitProviderConfig gitProviderData.BaseApiUrl = new(string) + gitProviderData.Username = new(string) if len(gitProviders) == 0 { views.RenderInfoMessage("No git providers registered") @@ -44,12 +42,12 @@ var gitProviderDeleteCmd = &cobra.Command{ gitprovider_view.GitProviderSelectionView(&gitProviderData, gitProviders, true) - if *gitProviderData.Id == "" { + if gitProviderData.Id == "" { log.Fatal("Git provider id can not be blank") return } - _, err = apiClient.GitProviderAPI.RemoveGitProvider(ctx, *gitProviderData.Id).Execute() + _, err = apiClient.GitProviderAPI.RemoveGitProvider(ctx, gitProviderData.Id).Execute() if err != nil { log.Fatal(err) } diff --git a/pkg/cmd/gitprovider/list.go b/pkg/cmd/gitprovider/list.go index 63c8ebf2b5..50b6ada807 100644 --- a/pkg/cmd/gitprovider/list.go +++ b/pkg/cmd/gitprovider/list.go @@ -43,12 +43,12 @@ var gitProviderListCmd = &cobra.Command{ for _, gitProvider := range gitProviders { for _, supportedProvider := range supportedProviders { - if *gitProvider.Id == supportedProvider.Id { + if gitProvider.Id == supportedProvider.Id { gitProviderViewList = append(gitProviderViewList, gitprovider_view.GitProviderView{ - Id: *gitProvider.Id, + Id: gitProvider.Id, Name: supportedProvider.Name, - Username: *gitProvider.Username, + Username: gitProvider.Username, }, ) } diff --git a/pkg/cmd/ports/forward.go b/pkg/cmd/ports/forward.go index 4af3a35b33..af5e1f2cb3 100644 --- a/pkg/cmd/ports/forward.go +++ b/pkg/cmd/ports/forward.go @@ -49,7 +49,7 @@ var PortForwardCmd = &cobra.Command{ if err != nil { log.Fatal(err) } - workspaceId = *workspace.Id + workspaceId = workspace.Id if len(args) == 3 { projectName = args[2] @@ -106,20 +106,24 @@ func ForwardPublicPort(workspaceId, projectName string, hostPort, targetPort uin } h := fnv.New64() - h.Write([]byte(fmt.Sprintf("%s-%s-%s", workspaceId, projectName, *serverConfig.Id))) + h.Write([]byte(fmt.Sprintf("%s-%s-%s", workspaceId, projectName, serverConfig.Id))) subDomain := fmt.Sprintf("%d-%s", targetPort, base64.RawURLEncoding.EncodeToString([]byte(fmt.Sprint(h.Sum64())))) + if serverConfig.Frps == nil { + return fmt.Errorf("frps config is missing") + } + go func() { time.Sleep(1 * time.Second) - var url = fmt.Sprintf("%s://%s.%s", *serverConfig.Frps.Protocol, subDomain, *serverConfig.Frps.Domain) + var url = fmt.Sprintf("%s://%s.%s", serverConfig.Frps.Protocol, subDomain, serverConfig.Frps.Domain) views.RenderInfoMessage(fmt.Sprintf("Port available at %s", url)) renderQr(url) }() _, service, err := frpc.GetService(frpc.FrpcConnectParams{ - ServerDomain: *serverConfig.Frps.Domain, - ServerPort: int(*serverConfig.Frps.Port), + ServerDomain: serverConfig.Frps.Domain, + ServerPort: int(serverConfig.Frps.Port), Name: subDomain, SubDomain: subDomain, Port: int(hostPort), diff --git a/pkg/cmd/profiledata/env/list.go b/pkg/cmd/profiledata/env/list.go index 94079bfed7..b767f9d672 100644 --- a/pkg/cmd/profiledata/env/list.go +++ b/pkg/cmd/profiledata/env/list.go @@ -33,17 +33,17 @@ var listCmd = &cobra.Command{ if output.FormatFlag != "" { if profileData.EnvVars == nil { - profileData.EnvVars = &map[string]string{} + profileData.EnvVars = map[string]string{} } - output.Output = *profileData.EnvVars + output.Output = profileData.EnvVars return } - if profileData.EnvVars == nil || len(*profileData.EnvVars) == 0 { + if profileData.EnvVars == nil || len(profileData.EnvVars) == 0 { views.RenderInfoMessageBold("No environment variables set") return } - env.List(*profileData.EnvVars) + env.List(profileData.EnvVars) }, } diff --git a/pkg/cmd/profiledata/env/set.go b/pkg/cmd/profiledata/env/set.go index 6624f40d5a..73b64cc6dc 100644 --- a/pkg/cmd/profiledata/env/set.go +++ b/pkg/cmd/profiledata/env/set.go @@ -32,7 +32,7 @@ var setCmd = &cobra.Command{ } if profileData.EnvVars == nil { - profileData.EnvVars = &map[string]string{} + profileData.EnvVars = map[string]string{} } if len(args) > 0 { @@ -41,12 +41,12 @@ var setCmd = &cobra.Command{ if len(kv) != 2 { log.Fatalf("Invalid key-value pair: %s", arg) } - (*profileData.EnvVars)[kv[0]] = kv[1] + (profileData.EnvVars)[kv[0]] = kv[1] } } else { form := huh.NewForm( huh.NewGroup( - views.GetEnvVarsInput(profileData.EnvVars), + views.GetEnvVarsInput(&profileData.EnvVars), ), ).WithTheme(views.GetCustomTheme()) diff --git a/pkg/cmd/projectconfig/add.go b/pkg/cmd/projectconfig/add.go index 4bc4a959e1..d343d33d44 100644 --- a/pkg/cmd/projectconfig/add.go +++ b/pkg/cmd/projectconfig/add.go @@ -46,13 +46,13 @@ var projectConfigAddCmd = &cobra.Command{ log.Fatal(apiclient_util.HandleErrorResponse(res, err)) } for _, pc := range existingProjectConfigs { - existingProjectConfigNames = append(existingProjectConfigNames, *pc.Name) + existingProjectConfigNames = append(existingProjectConfigNames, pc.Name) } projectDefaults := &create.ProjectConfigDefaults{ BuildChoice: create.AUTOMATIC, - Image: apiServerConfig.DefaultProjectImage, - ImageUser: apiServerConfig.DefaultProjectUser, + Image: &apiServerConfig.DefaultProjectImage, + ImageUser: &apiServerConfig.DefaultProjectUser, DevcontainerFilePath: create.DEVCONTAINER_FILEPATH, } @@ -82,11 +82,11 @@ var projectConfigAddCmd = &cobra.Command{ log.Fatal("no projects found") } - if projects[0].Name == nil { + if projects[0].Name == "" { log.Fatal("project config name is required") } - initialSuggestion := *projects[0].Name + initialSuggestion := projects[0].Name chosenName := workspace_util.GetSuggestedName(initialSuggestion, existingProjectConfigNames) @@ -105,16 +105,16 @@ var projectConfigAddCmd = &cobra.Command{ } newProjectConfig := apiclient.CreateProjectConfigDTO{ - Name: &chosenName, + Name: chosenName, BuildConfig: projects[0].BuildConfig, Image: projects[0].Image, User: projects[0].User, - Source: &apiclient.CreateProjectConfigSourceDTO{ + Source: apiclient.CreateProjectConfigSourceDTO{ Repository: projects[0].Source.Repository, }, } - newProjectConfig.EnvVars = workspace_util.GetEnvVariables(&projects[0], nil) + newProjectConfig.EnvVars = *workspace_util.GetEnvVariables(&projects[0], nil) res, err = apiClient.ProjectConfigAPI.SetProjectConfig(ctx).ProjectConfig(newProjectConfig).Execute() if err != nil { diff --git a/pkg/cmd/projectconfig/delete.go b/pkg/cmd/projectconfig/delete.go index 30df4cbe5c..7cbbf3f5e6 100644 --- a/pkg/cmd/projectconfig/delete.go +++ b/pkg/cmd/projectconfig/delete.go @@ -43,7 +43,7 @@ var projectConfigDeleteCmd = &cobra.Command{ if selectedProjectConfig == nil { return } - selectedProjectConfigName = *selectedProjectConfig.Name + selectedProjectConfigName = selectedProjectConfig.Name } else { selectedProjectConfigName = args[0] } diff --git a/pkg/cmd/projectconfig/setdefault.go b/pkg/cmd/projectconfig/setdefault.go index f171823513..5053cad341 100644 --- a/pkg/cmd/projectconfig/setdefault.go +++ b/pkg/cmd/projectconfig/setdefault.go @@ -37,7 +37,7 @@ var projectConfigSetDefaultCmd = &cobra.Command{ if projectConfig == nil { return } - projectConfigName = *projectConfig.Name + projectConfigName = projectConfig.Name } else { projectConfigName = args[0] } diff --git a/pkg/cmd/projectconfig/update.go b/pkg/cmd/projectconfig/update.go index b83e15d297..53228a6ba9 100644 --- a/pkg/cmd/projectconfig/update.go +++ b/pkg/cmd/projectconfig/update.go @@ -49,13 +49,13 @@ var projectConfigUpdateCmd = &cobra.Command{ } } - if projectConfig == nil || projectConfig.Name == nil { - log.Fatal("project config not found") + if projectConfig == nil { + return } projectConfigs = append(projectConfigs, apiclient.CreateProjectConfigDTO{ Name: projectConfig.Name, - Source: &apiclient.CreateProjectConfigSourceDTO{ + Source: apiclient.CreateProjectConfigSourceDTO{ Repository: projectConfig.Repository, }, BuildConfig: projectConfig.BuildConfig, @@ -64,18 +64,12 @@ var projectConfigUpdateCmd = &cobra.Command{ projectDefaults := &create.ProjectConfigDefaults{ BuildChoice: create.AUTOMATIC, + Image: &projectConfig.Image, + ImageUser: &projectConfig.User, } - if projectConfig.Image != nil { - projectDefaults.Image = projectConfig.Image - } - - if projectConfig.User != nil { - projectDefaults.ImageUser = projectConfig.User - } - - if projectConfig.BuildConfig != nil && projectConfig.BuildConfig.Devcontainer != nil && projectConfig.BuildConfig.Devcontainer.FilePath != nil { - projectDefaults.DevcontainerFilePath = *projectConfig.BuildConfig.Devcontainer.FilePath + if projectConfig.BuildConfig != nil && projectConfig.BuildConfig.Devcontainer != nil { + projectDefaults.DevcontainerFilePath = projectConfig.BuildConfig.Devcontainer.FilePath } create.ProjectsConfigurationChanged, err = create.RunProjectConfiguration(&projectConfigs, *projectDefaults) @@ -88,12 +82,12 @@ var projectConfigUpdateCmd = &cobra.Command{ BuildConfig: projectConfigs[0].BuildConfig, Image: projectConfigs[0].Image, User: projectConfigs[0].User, - Source: &apiclient.CreateProjectConfigSourceDTO{ + Source: apiclient.CreateProjectConfigSourceDTO{ Repository: projectConfigs[0].Source.Repository, }, } - newProjectConfig.EnvVars = workspace_util.GetEnvVariables(&projectConfigs[0], nil) + newProjectConfig.EnvVars = *workspace_util.GetEnvVariables(&projectConfigs[0], nil) res, err = apiClient.ProjectConfigAPI.SetProjectConfig(ctx).ProjectConfig(newProjectConfig).Execute() if err != nil { diff --git a/pkg/cmd/provider/install.go b/pkg/cmd/provider/install.go index 486edf83df..0aa4dced9d 100644 --- a/pkg/cmd/provider/install.go +++ b/pkg/cmd/provider/install.go @@ -35,7 +35,7 @@ var providerInstallCmd = &cobra.Command{ log.Fatal(apiclient_util.HandleErrorResponse(res, err)) } - providerManager := manager.NewProviderManager(manager.ProviderManagerConfig{RegistryUrl: *serverConfig.RegistryUrl}) + providerManager := manager.NewProviderManager(manager.ProviderManagerConfig{RegistryUrl: serverConfig.RegistryUrl}) providersManifest, err := providerManager.GetProvidersManifest() if err != nil { @@ -54,7 +54,7 @@ var providerInstallCmd = &cobra.Command{ providerList := convertToDTO(providersManifestLatest) specificProviderName := "Select a specific version" specificProviderVersion := "" - providerList = append(providerList, apiclient.Provider{Name: &specificProviderName, Version: &specificProviderVersion}) + providerList = append(providerList, apiclient.Provider{Name: specificProviderName, Version: specificProviderVersion}) providerToInstall, err := provider.GetProviderFromPrompt(providerList, "Choose a provider to install", false) if err != nil { @@ -69,7 +69,7 @@ var providerInstallCmd = &cobra.Command{ return } - if *providerToInstall.Name == specificProviderName { + if providerToInstall.Name == specificProviderName { providerList = convertToDTO(providersManifest) providerToInstall, err = provider.GetProviderFromPrompt(providerList, "Choose a specific provider to install", false) @@ -86,11 +86,11 @@ var providerInstallCmd = &cobra.Command{ } } - downloadUrls := convertToStringMap((*providersManifest)[*providerToInstall.Name].Versions[*providerToInstall.Version].DownloadUrls) + downloadUrls := convertToStringMap((*providersManifest)[providerToInstall.Name].Versions[providerToInstall.Version].DownloadUrls) err = view_utils.WithSpinner("Installing", func() error { res, err = apiClient.ProviderAPI.InstallProviderExecute(apiclient.ApiInstallProviderRequest{}.Provider(apiclient.InstallProviderRequest{ Name: providerToInstall.Name, - DownloadUrls: &downloadUrls, + DownloadUrls: downloadUrls, })) if err != nil { @@ -108,7 +108,7 @@ var providerInstallCmd = &cobra.Command{ log.Fatalf("Failed to execute download with spinner: %v", err) } - views.RenderInfoMessageBold(fmt.Sprintf("Provider %s has been successfully installed", *providerToInstall.Name)) + views.RenderInfoMessageBold(fmt.Sprintf("Provider %s has been successfully installed", providerToInstall.Name)) }, } @@ -117,8 +117,8 @@ func convertToDTO(manifest *manager.ProvidersManifest) []apiclient.Provider { for pluginName, pluginManifest := range *manifest { for version := range pluginManifest.Versions { pluginList = append(pluginList, apiclient.Provider{ - Name: &pluginName, - Version: &version, + Name: pluginName, + Version: version, }) } } diff --git a/pkg/cmd/provider/uninstall.go b/pkg/cmd/provider/uninstall.go index 811a3c1366..4d300bb900 100644 --- a/pkg/cmd/provider/uninstall.go +++ b/pkg/cmd/provider/uninstall.go @@ -46,12 +46,12 @@ var providerUninstallCmd = &cobra.Command{ } ctx := context.Background() - res, err := apiClient.ProviderAPI.UninstallProvider(ctx, *providerToUninstall.Name).Execute() + res, err := apiClient.ProviderAPI.UninstallProvider(ctx, providerToUninstall.Name).Execute() if err != nil { log.Fatal(apiclient.HandleErrorResponse(res, err)) } - views.RenderInfoMessageBold(fmt.Sprintf("Provider %s has been successfully uninstalled", *providerToUninstall.Name)) + views.RenderInfoMessageBold(fmt.Sprintf("Provider %s has been successfully uninstalled", providerToUninstall.Name)) }, } diff --git a/pkg/cmd/provider/update.go b/pkg/cmd/provider/update.go index d308b8cdc5..78482c745b 100644 --- a/pkg/cmd/provider/update.go +++ b/pkg/cmd/provider/update.go @@ -39,7 +39,7 @@ var providerUpdateCmd = &cobra.Command{ log.Fatal(apiclient_util.HandleErrorResponse(res, err)) } - providerManager := manager.NewProviderManager(manager.ProviderManagerConfig{RegistryUrl: *serverConfig.RegistryUrl}) + providerManager := manager.NewProviderManager(manager.ProviderManagerConfig{RegistryUrl: serverConfig.RegistryUrl}) providersManifest, err := providerManager.GetProvidersManifest() if err != nil { @@ -48,12 +48,12 @@ var providerUpdateCmd = &cobra.Command{ if allFlag { for _, provider := range providerList { - fmt.Printf("Updating provider %s\n", *provider.Name) + fmt.Printf("Updating provider %s\n", provider.Name) err := updateProvider(&provider, providersManifest, apiClient) if err != nil { - log.Error(fmt.Sprintf("Failed to update provider %s: %s", *provider.Name, err)) + log.Error(fmt.Sprintf("Failed to update provider %s: %s", provider.Name, err)) } else { - fmt.Printf("Provider %s has been successfully updated\n", *provider.Name) + fmt.Printf("Provider %s has been successfully updated\n", provider.Name) } } @@ -77,14 +77,14 @@ var providerUpdateCmd = &cobra.Command{ log.Fatal(err) } - fmt.Printf("Provider %s has been successfully updated\n", *providerToUpdate.Name) + fmt.Printf("Provider %s has been successfully updated\n", providerToUpdate.Name) }, } func updateProvider(providerToUpdate *apiclient.Provider, providersManifest *manager.ProvidersManifest, apiClient *apiclient.APIClient) error { - providerManifest, ok := (*providersManifest)[*providerToUpdate.Name] + providerManifest, ok := (*providersManifest)[providerToUpdate.Name] if !ok { - return fmt.Errorf("Provider %s not found in manifest", *providerToUpdate.Name) + return fmt.Errorf("Provider %s not found in manifest", providerToUpdate.Name) } version, ok := providerManifest.Versions["latest"] @@ -97,7 +97,7 @@ func updateProvider(providerToUpdate *apiclient.Provider, providersManifest *man res, err := apiClient.ProviderAPI.InstallProviderExecute(apiclient.ApiInstallProviderRequest{}.Provider(apiclient.InstallProviderRequest{ Name: providerToUpdate.Name, - DownloadUrls: &downloadUrls, + DownloadUrls: downloadUrls, })) if err != nil { return apiclient_util.HandleErrorResponse(res, err) diff --git a/pkg/cmd/target/remove.go b/pkg/cmd/target/remove.go index bb15b3308f..1c80abd3b2 100644 --- a/pkg/cmd/target/remove.go +++ b/pkg/cmd/target/remove.go @@ -54,7 +54,7 @@ var targetRemoveCmd = &cobra.Command{ } } - selectedTargetName = *selectedTarget.Name + selectedTargetName = selectedTarget.Name } else { selectedTargetName = args[0] } @@ -117,17 +117,17 @@ func RemoveTargetWorkspaces(ctx context.Context, client *apiclient.APIClient, ta } for _, workspace := range workspaceList { - if *workspace.Target != target { + if workspace.Target != target { continue } - res, err := client.WorkspaceAPI.RemoveWorkspace(ctx, *workspace.Id).Execute() + res, err := client.WorkspaceAPI.RemoveWorkspace(ctx, workspace.Id).Execute() if err != nil { - log.Errorf("Failed to delete workspace %s: %v", *workspace.Name, apiclient_util.HandleErrorResponse(res, err)) + log.Errorf("Failed to delete workspace %s: %v", workspace.Name, apiclient_util.HandleErrorResponse(res, err)) continue } - views.RenderLine(fmt.Sprintf("- Workspace %s successfully deleted\n", *workspace.Name)) + views.RenderLine(fmt.Sprintf("- Workspace %s successfully deleted\n", workspace.Name)) } return nil diff --git a/pkg/cmd/target/set.go b/pkg/cmd/target/set.go index 998146ed0c..38bf581423 100644 --- a/pkg/cmd/target/set.go +++ b/pkg/cmd/target/set.go @@ -60,7 +60,7 @@ var TargetSetCmd = &cobra.Command{ filteredTargets := []apiclient.ProviderTarget{} for _, t := range targets { - if *t.ProviderInfo.Name == *selectedProvider.Name { + if t.ProviderInfo.Name == selectedProvider.Name { filteredTargets = append(filteredTargets, t) } } @@ -79,15 +79,15 @@ var TargetSetCmd = &cobra.Command{ log.Fatal(err) } - targetManifest, res, err := client.ProviderAPI.GetTargetManifest(context.Background(), *selectedProvider.Name).Execute() + targetManifest, res, err := client.ProviderAPI.GetTargetManifest(context.Background(), selectedProvider.Name).Execute() if err != nil { log.Fatal(apiclient_util.HandleErrorResponse(res, err)) } - if *selectedTarget.Name == target.NewTargetName { - *selectedTarget.Name = "" - err = target.NewTargetNameInput(selectedTarget.Name, internal_util.ArrayMap(targets, func(t apiclient.ProviderTarget) string { - return *t.Name + if selectedTarget.Name == target.NewTargetName { + selectedTarget.Name = "" + err = target.NewTargetNameInput(&selectedTarget.Name, internal_util.ArrayMap(targets, func(t apiclient.ProviderTarget) string { + return t.Name })) if err != nil { log.Fatal(err) @@ -99,7 +99,7 @@ var TargetSetCmd = &cobra.Command{ log.Fatal(err) } - selectedTarget.ProviderInfo = &apiclient.ProviderProviderInfo{ + selectedTarget.ProviderInfo = apiclient.ProviderProviderInfo{ Name: selectedProvider.Name, Version: selectedProvider.Version, } diff --git a/pkg/cmd/workspace/code.go b/pkg/cmd/workspace/code.go index de35bb3bfb..b1586e47b3 100644 --- a/pkg/cmd/workspace/code.go +++ b/pkg/cmd/workspace/code.go @@ -62,13 +62,13 @@ var CodeCmd = &cobra.Command{ if workspace == nil { return } - workspaceId = *workspace.Id + workspaceId = workspace.Id } else { workspace, err = apiclient_util.GetWorkspace(args[0]) if err != nil { log.Fatal(err) } - workspaceId = *workspace.Id + workspaceId = workspace.Id } if len(args) == 0 || len(args) == 1 { @@ -79,7 +79,7 @@ var CodeCmd = &cobra.Command{ if selectedProject == nil { return } - projectName = *selectedProject.Name + projectName = selectedProject.Name } if len(args) == 2 { @@ -102,9 +102,9 @@ var CodeCmd = &cobra.Command{ providerMetadata := "" if workspace.Info != nil { for _, project := range workspace.Info.Projects { - if *project.Name == projectName { + if project.Name == projectName { if !project.GetIsRunning() { - views.RenderInfoMessage(fmt.Sprintf("Project '%s' from workspace '%s' is not in running state", projectName, *workspace.Name)) + views.RenderInfoMessage(fmt.Sprintf("Project '%s' from workspace '%s' is not in running state", projectName, workspace.Name)) return } if project.ProviderMetadata == nil { @@ -117,11 +117,11 @@ var CodeCmd = &cobra.Command{ } if !workspace_util.IsProjectRunning(workspace, projectName) { - views.RenderInfoMessage(fmt.Sprintf("Project '%s' from workspace '%s' is not in running state", projectName, *workspace.Name)) + views.RenderInfoMessage(fmt.Sprintf("Project '%s' from workspace '%s' is not in running state", projectName, workspace.Name)) return } - views.RenderInfoMessage(fmt.Sprintf("Opening the project '%s' from workspace '%s' in %s", projectName, *workspace.Name, ideName)) + views.RenderInfoMessage(fmt.Sprintf("Opening the project '%s' from workspace '%s' in %s", projectName, workspace.Name, ideName)) err = openIDE(ideId, activeProfile, workspaceId, projectName, providerMetadata) if err != nil { diff --git a/pkg/cmd/workspace/create.go b/pkg/cmd/workspace/create.go index 378ad8590c..0ecfc4cbab 100644 --- a/pkg/cmd/workspace/create.go +++ b/pkg/cmd/workspace/create.go @@ -75,7 +75,7 @@ var CreateCmd = &cobra.Command{ log.Fatal(apiclient_util.HandleErrorResponse(res, err)) } for _, workspaceInfo := range workspaceList { - existingWorkspaceNames = append(existingWorkspaceNames, *workspaceInfo.Name) + existingWorkspaceNames = append(existingWorkspaceNames, workspaceInfo.Name) } if len(args) == 0 { @@ -93,7 +93,7 @@ var CreateCmd = &cobra.Command{ log.Fatal(err) } - initialSuggestion := *projects[0].Name + initialSuggestion := projects[0].Name if workspaceName == "" { workspaceName = workspace_util.GetSuggestedName(initialSuggestion, existingWorkspaceNames) @@ -107,8 +107,8 @@ var CreateCmd = &cobra.Command{ projectNames := []string{} for i := range projects { - projects[i].EnvVars = workspace_util.GetEnvVariables(&projects[i], profileData) - projectNames = append(projectNames, *projects[i].Name) + projects[i].EnvVars = *workspace_util.GetEnvVariables(&projects[i], profileData) + projectNames = append(projectNames, projects[i].Name) } logs_view.CalculateLongestPrefixLength(projectNames) @@ -146,8 +146,8 @@ var CreateCmd = &cobra.Command{ go apiclient_util.ReadWorkspaceLogs(activeProfile, id, projectNames, &stopLogs) createdWorkspace, res, err := apiClient.WorkspaceAPI.CreateWorkspace(ctx).Workspace(apiclient.CreateWorkspaceDTO{ - Id: &id, - Name: &workspaceName, + Id: id, + Name: workspaceName, Target: target.Name, Projects: projects, }).Execute() @@ -155,7 +155,7 @@ var CreateCmd = &cobra.Command{ log.Fatal(apiclient_util.HandleErrorResponse(res, err)) } - err = waitForDial(tsConn, *createdWorkspace.Id, *createdWorkspace.Projects[0].Name) + err = waitForDial(tsConn, createdWorkspace.Id, createdWorkspace.Projects[0].Name) if err != nil { log.Fatal(err) } @@ -196,7 +196,7 @@ var CreateCmd = &cobra.Command{ providerMetadata := "" for _, project := range wsInfo.Info.Projects { - if *project.Name == *wsInfo.Projects[0].Name { + if project.Name == wsInfo.Projects[0].Name { if project.ProviderMetadata == nil { log.Fatal(errors.New("project provider metadata is missing")) } @@ -205,7 +205,7 @@ var CreateCmd = &cobra.Command{ } } - err = openIDE(chosenIdeId, activeProfile, *createdWorkspace.Id, *wsInfo.Projects[0].Name, providerMetadata) + err = openIDE(chosenIdeId, activeProfile, createdWorkspace.Id, wsInfo.Projects[0].Name, providerMetadata) if err != nil { log.Fatal(err) } @@ -264,7 +264,7 @@ func getTarget(activeProfileName string) (*apiclient.ProviderTarget, error) { if targetNameFlag != "" { for _, t := range targets { - if *t.Name == targetNameFlag { + if t.Name == targetNameFlag { return &t, nil } } @@ -300,8 +300,8 @@ func processPrompting(apiClient *apiclient.APIClient, workspaceName *string, pro projectDefaults := &create.ProjectConfigDefaults{ BuildChoice: create.AUTOMATIC, - Image: apiServerConfig.DefaultProjectImage, - ImageUser: apiServerConfig.DefaultProjectUser, + Image: &apiServerConfig.DefaultProjectImage, + ImageUser: &apiServerConfig.DefaultProjectUser, DevcontainerFilePath: create.DEVCONTAINER_FILEPATH, } @@ -319,7 +319,7 @@ func processPrompting(apiClient *apiclient.APIClient, workspaceName *string, pro return err } - initialSuggestion := *(*projects)[0].Name + initialSuggestion := (*projects)[0].Name suggestedName := workspace_util.GetSuggestedName(initialSuggestion, workspaceNames) @@ -385,15 +385,15 @@ func processGitURL(repoUrl string, apiClient *apiclient.APIClient, projects *[]a repoResponse.Branch = &branchFlag } - projectName, err := workspace_util.GetSanitizedProjectName(*repoResponse.Name) + projectName, err := workspace_util.GetSanitizedProjectName(repoResponse.Name) if err != nil { return nil, err } project := &apiclient.CreateProjectConfigDTO{ - Name: &projectName, - Source: &apiclient.CreateProjectConfigSourceDTO{ - Repository: repoResponse, + Name: projectName, + Source: apiclient.CreateProjectConfigSourceDTO{ + Repository: *repoResponse, }, BuildConfig: &apiclient.ProjectBuildConfig{}, } @@ -404,7 +404,7 @@ func processGitURL(repoUrl string, apiClient *apiclient.APIClient, projects *[]a devcontainerFilePath = devcontainerPathFlag } project.BuildConfig.Devcontainer = &apiclient.DevcontainerConfig{ - FilePath: &devcontainerFilePath, + FilePath: devcontainerFilePath, } } diff --git a/pkg/cmd/workspace/delete.go b/pkg/cmd/workspace/delete.go index 50732b2425..0ec6aae7d5 100644 --- a/pkg/cmd/workspace/delete.go +++ b/pkg/cmd/workspace/delete.go @@ -79,7 +79,7 @@ var DeleteCmd = &cobra.Command{ } workspaceDeleteList = selection.GetWorkspacesFromPrompt(workspaceList, "Delete") for _, workspace := range workspaceDeleteList { - workspaceDeleteListNames = append(workspaceDeleteListNames, *workspace.Name) + workspaceDeleteListNames = append(workspaceDeleteListNames, workspace.Name) } } else { for _, arg := range args { @@ -89,7 +89,7 @@ var DeleteCmd = &cobra.Command{ continue } workspaceDeleteList = append(workspaceDeleteList, workspace) - workspaceDeleteListNames = append(workspaceDeleteListNames, *workspace.Name) + workspaceDeleteListNames = append(workspaceDeleteListNames, workspace.Name) } } @@ -119,7 +119,7 @@ var DeleteCmd = &cobra.Command{ for _, workspace := range workspaceDeleteList { err := removeWorkspace(ctx, apiClient, workspace, forceFlag) if err != nil { - log.Error(fmt.Sprintf("[ %s ] : %v", *workspace.Name, err)) + log.Error(fmt.Sprintf("[ %s ] : %v", workspace.Name, err)) } } } @@ -152,18 +152,18 @@ func DeleteAllWorkspaces(force bool) error { } for _, workspace := range workspaceList { - res, err := apiClient.WorkspaceAPI.RemoveWorkspace(ctx, *workspace.Id).Force(force).Execute() + res, err := apiClient.WorkspaceAPI.RemoveWorkspace(ctx, workspace.Id).Force(force).Execute() if err != nil { - log.Errorf("Failed to delete workspace %s: %v", *workspace.Name, apiclient_util.HandleErrorResponse(res, err)) + log.Errorf("Failed to delete workspace %s: %v", workspace.Name, apiclient_util.HandleErrorResponse(res, err)) continue } - views.RenderLine(fmt.Sprintf("- Workspace %s successfully deleted\n", *workspace.Name)) + views.RenderLine(fmt.Sprintf("- Workspace %s successfully deleted\n", workspace.Name)) } return nil } func removeWorkspace(ctx context.Context, apiClient *apiclient.APIClient, workspace *apiclient.WorkspaceDTO, force bool) error { - res, err := apiClient.WorkspaceAPI.RemoveWorkspace(ctx, *workspace.Id).Force(force).Execute() + res, err := apiClient.WorkspaceAPI.RemoveWorkspace(ctx, workspace.Id).Force(force).Execute() if err != nil { return apiclient_util.HandleErrorResponse(res, err) @@ -179,11 +179,11 @@ func removeWorkspace(ctx context.Context, apiClient *apiclient.APIClient, worksp return err } - err = config.RemoveWorkspaceSshEntries(activeProfile.Id, *workspace.Id) + err = config.RemoveWorkspaceSshEntries(activeProfile.Id, workspace.Id) if err != nil { return err } - views.RenderInfoMessage(fmt.Sprintf("Workspace %s successfully deleted", *workspace.Name)) + views.RenderInfoMessage(fmt.Sprintf("Workspace %s successfully deleted", workspace.Name)) return nil } diff --git a/pkg/cmd/workspace/ssh.go b/pkg/cmd/workspace/ssh.go index 50e3f2eac5..348371a348 100644 --- a/pkg/cmd/workspace/ssh.go +++ b/pkg/cmd/workspace/ssh.go @@ -63,14 +63,14 @@ var SshCmd = &cobra.Command{ } if len(args) == 0 || len(args) == 1 { - selectedProject, err := selectWorkspaceProject(*workspace.Id, &activeProfile) + selectedProject, err := selectWorkspaceProject(workspace.Id, &activeProfile) if err != nil { log.Fatal(err) } if selectedProject == nil { return } - projectName = *selectedProject.Name + projectName = selectedProject.Name } if len(args) == 2 { @@ -78,11 +78,11 @@ var SshCmd = &cobra.Command{ } if !workspace_util.IsProjectRunning(workspace, projectName) { - views.RenderInfoMessage(fmt.Sprintf("Project '%s' from workspace '%s' is not in running state", projectName, *workspace.Name)) + views.RenderInfoMessage(fmt.Sprintf("Project '%s' from workspace '%s' is not in running state", projectName, workspace.Name)) return } - err = ide.OpenTerminalSsh(activeProfile, *workspace.Id, projectName) + err = ide.OpenTerminalSsh(activeProfile, workspace.Id, projectName) if err != nil { log.Fatal(err) } diff --git a/pkg/cmd/workspace/start.go b/pkg/cmd/workspace/start.go index 39f372a188..80b7244ed7 100644 --- a/pkg/cmd/workspace/start.go +++ b/pkg/cmd/workspace/start.go @@ -66,7 +66,7 @@ var StartCmd = &cobra.Command{ if workspace == nil { return } - workspaceId = *workspace.Name + workspaceId = workspace.Name } else { workspaceId = args[0] } @@ -119,12 +119,12 @@ func startAllWorkspaces() error { } for _, workspace := range workspaceList { - res, err := apiClient.WorkspaceAPI.StartWorkspace(ctx, *workspace.Id).Execute() + res, err := apiClient.WorkspaceAPI.StartWorkspace(ctx, workspace.Id).Execute() if err != nil { - log.Errorf("Failed to start workspace %s: %v", *workspace.Name, apiclient.HandleErrorResponse(res, err)) + log.Errorf("Failed to start workspace %s: %v", workspace.Name, apiclient.HandleErrorResponse(res, err)) continue } - fmt.Printf("Workspace '%s' is starting\n", *workspace.Name) + fmt.Printf("Workspace '%s' is starting\n", workspace.Name) } return nil } @@ -144,7 +144,7 @@ func getProjectNameCompletions(cmd *cobra.Command, args []string, toComplete str var choices []string for _, project := range workspace.Projects { - choices = append(choices, *project.Name) + choices = append(choices, project.Name) } return choices, cobra.ShellCompDirectiveDefault } @@ -163,7 +163,7 @@ func getWorkspaceNameCompletions() ([]string, cobra.ShellCompDirective) { var choices []string for _, v := range workspaceList { - choices = append(choices, *v.Name) + choices = append(choices, v.Name) } return choices, cobra.ShellCompDirectiveNoFileComp @@ -184,12 +184,12 @@ func getAllWorkspacesByState(state WorkspaceState) ([]string, cobra.ShellCompDir var choices []string for _, workspace := range workspaceList { for _, project := range workspace.Info.Projects { - if state == WORKSPACE_STATUS_RUNNING && *project.IsRunning { - choices = append(choices, *workspace.Name) + if state == WORKSPACE_STATUS_RUNNING && project.IsRunning { + choices = append(choices, workspace.Name) break } - if state == WORKSPACE_STATUS_STOPPED && !*project.IsRunning { - choices = append(choices, *workspace.Name) + if state == WORKSPACE_STATUS_STOPPED && !project.IsRunning { + choices = append(choices, workspace.Name) break } } diff --git a/pkg/cmd/workspace/stop.go b/pkg/cmd/workspace/stop.go index c46241f207..e9cc46c080 100644 --- a/pkg/cmd/workspace/stop.go +++ b/pkg/cmd/workspace/stop.go @@ -58,7 +58,7 @@ var StopCmd = &cobra.Command{ if workspace == nil { return } - workspaceId = *workspace.Name + workspaceId = workspace.Name } else { workspaceId = args[0] } @@ -106,12 +106,12 @@ func stopAllWorkspaces() error { } for _, workspace := range workspaceList { - res, err := apiClient.WorkspaceAPI.StopWorkspace(ctx, *workspace.Id).Execute() + res, err := apiClient.WorkspaceAPI.StopWorkspace(ctx, workspace.Id).Execute() if err != nil { - log.Errorf("Failed to stop workspace %s: %v", *workspace.Name, apiclient.HandleErrorResponse(res, err)) + log.Errorf("Failed to stop workspace %s: %v", workspace.Name, apiclient.HandleErrorResponse(res, err)) continue } - fmt.Printf("Workspace '%s' is stopping\n", *workspace.Name) + fmt.Printf("Workspace '%s' is stopping\n", workspace.Name) } return nil } diff --git a/pkg/cmd/workspace/util/add_from_config.go b/pkg/cmd/workspace/util/add_from_config.go index 2bf9f205bf..ddce9d9237 100644 --- a/pkg/cmd/workspace/util/add_from_config.go +++ b/pkg/cmd/workspace/util/add_from_config.go @@ -23,15 +23,15 @@ func AddProjectFromConfig(projectConfig *apiclient.ProjectConfig, apiClient *api project := &apiclient.CreateProjectConfigDTO{ Name: projectConfig.Name, - Source: &apiclient.CreateProjectConfigSourceDTO{ + Source: apiclient.CreateProjectConfigSourceDTO{ Repository: configRepo, }, BuildConfig: projectConfig.BuildConfig, - Image: projectConfig.Image, - User: projectConfig.User, + Image: &projectConfig.Image, + User: &projectConfig.User, EnvVars: projectConfig.EnvVars, } *projects = append(*projects, *project) - return projectConfig.Name, nil + return &projectConfig.Name, nil } diff --git a/pkg/cmd/workspace/util/branch_wizard.go b/pkg/cmd/workspace/util/branch_wizard.go index ac9f9c29e8..9c32619b31 100644 --- a/pkg/cmd/workspace/util/branch_wizard.go +++ b/pkg/cmd/workspace/util/branch_wizard.go @@ -37,7 +37,7 @@ func GetBranchFromWizard(config BranchWizardConfig) (*apiclient.GitRepository, e ctx := context.Background() err = views_util.WithSpinner("Loading", func() error { - branchList, _, err = config.ApiClient.GitProviderAPI.GetRepoBranches(ctx, config.ProviderId, config.NamespaceId, url.QueryEscape(*config.ChosenRepo.Id)).Execute() + branchList, _, err = config.ApiClient.GitProviderAPI.GetRepoBranches(ctx, config.ProviderId, config.NamespaceId, url.QueryEscape(config.ChosenRepo.Id)).Execute() return err }) @@ -50,14 +50,14 @@ func GetBranchFromWizard(config BranchWizardConfig) (*apiclient.GitRepository, e } if len(branchList) == 1 { - config.ChosenRepo.Branch = branchList[0].Name + config.ChosenRepo.Branch = &branchList[0].Name config.ChosenRepo.Sha = branchList[0].Sha return config.ChosenRepo, nil } var prList []apiclient.GitPullRequest err = views_util.WithSpinner("Loading", func() error { - prList, _, err = config.ApiClient.GitProviderAPI.GetRepoPRs(ctx, config.ProviderId, config.NamespaceId, url.QueryEscape(*config.ChosenRepo.Id)).Execute() + prList, _, err = config.ApiClient.GitProviderAPI.GetRepoPRs(ctx, config.ProviderId, config.NamespaceId, url.QueryEscape(config.ChosenRepo.Id)).Execute() return err }) @@ -72,7 +72,7 @@ func GetBranchFromWizard(config BranchWizardConfig) (*apiclient.GitRepository, e return nil, errors.New("must select a branch") } - config.ChosenRepo.Branch = branch.Name + config.ChosenRepo.Branch = &branch.Name config.ChosenRepo.Sha = branch.Sha return config.ChosenRepo, nil @@ -92,7 +92,7 @@ func GetBranchFromWizard(config BranchWizardConfig) (*apiclient.GitRepository, e if branch == nil { return nil, errors.New("must select a branch") } - config.ChosenRepo.Branch = branch.Name + config.ChosenRepo.Branch = &branch.Name config.ChosenRepo.Sha = branch.Sha } else if chosenCheckoutOption == selection.CheckoutPR { chosenPullRequest := selection.GetPullRequestFromPrompt(prList, config.ProjectOrder) @@ -100,7 +100,7 @@ func GetBranchFromWizard(config BranchWizardConfig) (*apiclient.GitRepository, e return nil, errors.New("must select a pull request") } - config.ChosenRepo.Branch = chosenPullRequest.Branch + config.ChosenRepo.Branch = &chosenPullRequest.Branch config.ChosenRepo.Sha = chosenPullRequest.Sha config.ChosenRepo.Id = chosenPullRequest.SourceRepoId config.ChosenRepo.Name = chosenPullRequest.SourceRepoName diff --git a/pkg/cmd/workspace/util/creation_data.go b/pkg/cmd/workspace/util/creation_data.go index c97b0f1bdf..9a51f81697 100644 --- a/pkg/cmd/workspace/util/creation_data.go +++ b/pkg/cmd/workspace/util/creation_data.go @@ -6,6 +6,7 @@ package util import ( "context" "fmt" + "net/http" "net/url" "os" "path/filepath" @@ -60,21 +61,17 @@ func GetProjectsCreationDataFromPrompt(config ProjectsDataPromptConfig) ([]apicl projectNames := []string{} for _, p := range projectList { - var currentName string - if p.Name != nil { - currentName = *p.Name - } - projectNames = append(projectNames, currentName) + projectNames = append(projectNames, p.Name) } // Append occurence number to keep duplicate entries unique - repoUrl := *projectConfig.Repository.Url + repoUrl := projectConfig.Repository.Url if len(selectedRepos) > 0 && selectedRepos[repoUrl] > 1 { - *projectConfig.Name += strconv.Itoa(selectedRepos[repoUrl]) + projectConfig.Name += strconv.Itoa(selectedRepos[repoUrl]) } - if *projectConfig.Name != selection.BlankProjectIdentifier { - projectName := GetSuggestedName(*projectConfig.Name, projectNames) + if projectConfig.Name != selection.BlankProjectIdentifier { + projectName := GetSuggestedName(projectConfig.Name, projectNames) branch, err := GetBranchFromProjectConfig(projectConfig, config.ApiClient, i) if err != nil { @@ -85,8 +82,8 @@ func GetProjectsCreationDataFromPrompt(config ProjectsDataPromptConfig) ([]apicl configRepo.Branch = &branch projectList = append(projectList, apiclient.CreateProjectConfigDTO{ - Name: &projectName, - Source: &apiclient.CreateProjectConfigSourceDTO{ + Name: projectName, + Source: apiclient.CreateProjectConfigSourceDTO{ Repository: configRepo, }, BuildConfig: projectConfig.BuildConfig, @@ -111,7 +108,13 @@ func GetProjectsCreationDataFromPrompt(config ProjectsDataPromptConfig) ([]apicl return nil, err } - providerRepoName, err := GetSanitizedProjectName(*providerRepo.Name) + var res *http.Response + providerRepo, res, err = config.ApiClient.GitProviderAPI.GetGitContext(context.Background(), url.QueryEscape(providerRepo.Url)).Execute() + if err != nil { + return nil, apiclient_util.HandleErrorResponse(res, err) + } + + providerRepoName, err := GetSanitizedProjectName(providerRepo.Name) if err != nil { return nil, err } @@ -158,7 +161,7 @@ func GetEnvVariables(projectConfigDto *apiclient.CreateProjectConfigDTO, profile envVars := map[string]string{} if profileData != nil && profileData.EnvVars != nil { - for k, v := range *profileData.EnvVars { + for k, v := range profileData.EnvVars { if strings.HasPrefix(v, "$") { env, ok := os.LookupEnv(v[1:]) if ok { @@ -173,7 +176,7 @@ func GetEnvVariables(projectConfigDto *apiclient.CreateProjectConfigDTO, profile } if projectConfigDto.EnvVars != nil { - for k, v := range *projectConfigDto.EnvVars { + for k, v := range projectConfigDto.EnvVars { if strings.HasPrefix(v, "$") { env, ok := os.LookupEnv(v[1:]) if ok { @@ -193,7 +196,7 @@ func GetEnvVariables(projectConfigDto *apiclient.CreateProjectConfigDTO, profile func GetBranchFromProjectConfig(projectConfig *apiclient.ProjectConfig, apiClient *apiclient.APIClient, projectOrder int) (string, error) { ctx := context.Background() - encodedURLParam := url.QueryEscape(*projectConfig.Repository.Url) + encodedURLParam := url.QueryEscape(projectConfig.Repository.Url) repoResponse, res, err := apiClient.GitProviderAPI.GetGitContext(ctx, encodedURLParam).Execute() if err != nil { @@ -208,7 +211,7 @@ func GetBranchFromProjectConfig(projectConfig *apiclient.ProjectConfig, apiClien branchWizardConfig := BranchWizardConfig{ ApiClient: apiClient, ProviderId: providerId, - NamespaceId: *repoResponse.Owner, + NamespaceId: repoResponse.Owner, ChosenRepo: repoResponse, ProjectOrder: projectOrder, } @@ -229,14 +232,14 @@ func GetBranchFromProjectConfig(projectConfig *apiclient.ProjectConfig, apiClien func newCreateProjectConfigDTO(config ProjectsDataPromptConfig, providerRepo *apiclient.GitRepository, providerRepoName string) apiclient.CreateProjectConfigDTO { project := apiclient.CreateProjectConfigDTO{ - Name: &providerRepoName, - Source: &apiclient.CreateProjectConfigSourceDTO{ - Repository: providerRepo, + Name: providerRepoName, + Source: apiclient.CreateProjectConfigSourceDTO{ + Repository: *providerRepo, }, BuildConfig: &apiclient.ProjectBuildConfig{}, Image: config.Defaults.Image, User: config.Defaults.ImageUser, - EnvVars: &map[string]string{}, + EnvVars: map[string]string{}, } return project diff --git a/pkg/cmd/workspace/util/repository_wizard.go b/pkg/cmd/workspace/util/repository_wizard.go index 4059700175..2a49b4da69 100644 --- a/pkg/cmd/workspace/util/repository_wizard.go +++ b/pkg/cmd/workspace/util/repository_wizard.go @@ -41,12 +41,12 @@ func getRepositoryFromWizard(config RepositoryWizardConfig) (*apiclient.GitRepos for _, gitProvider := range config.UserGitProviders { for _, supportedProvider := range supportedProviders { - if *gitProvider.Id == supportedProvider.Id { + if gitProvider.Id == supportedProvider.Id { gitProviderViewList = append(gitProviderViewList, gitprovider_view.GitProviderView{ - Id: *gitProvider.Id, + Id: gitProvider.Id, Name: supportedProvider.Name, - Username: *gitProvider.Username, + Username: gitProvider.Username, }, ) } @@ -72,7 +72,7 @@ func getRepositoryFromWizard(config RepositoryWizardConfig) (*apiclient.GitRepos } if len(namespaceList) == 1 { - namespaceId = *namespaceList[0].Id + namespaceId = namespaceList[0].Id } else { namespaceId = selection.GetNamespaceIdFromPrompt(namespaceList, config.ProjectOrder) if namespaceId == "" { diff --git a/pkg/cmd/workspace/util/workspace.go b/pkg/cmd/workspace/util/workspace.go index 2eb0323f01..f925b10b3f 100644 --- a/pkg/cmd/workspace/util/workspace.go +++ b/pkg/cmd/workspace/util/workspace.go @@ -8,8 +8,7 @@ import "github.com/daytonaio/daytona/pkg/apiclient" func IsProjectRunning(workspace *apiclient.WorkspaceDTO, projectName string) bool { for _, project := range workspace.GetProjects() { if project.GetName() == projectName { - uptime := project.GetState().Uptime - return uptime != nil && *uptime != 0 + return project.GetState().Uptime != 0 } } return false diff --git a/pkg/cmd/workspacemode/git_cred.go b/pkg/cmd/workspacemode/git_cred.go index dd11cc8d13..2a8a7f7b31 100644 --- a/pkg/cmd/workspacemode/git_cred.go +++ b/pkg/cmd/workspacemode/git_cred.go @@ -46,8 +46,8 @@ var gitCredCmd = &cobra.Command{ return } - fmt.Println("username=" + *gitProvider.Username) - fmt.Println("password=" + *gitProvider.Token) + fmt.Println("username=" + gitProvider.Username) + fmt.Println("password=" + gitProvider.Token) }, } diff --git a/pkg/containerregistry/container_registry.go b/pkg/containerregistry/container_registry.go index ed523652a8..3d1227c77c 100644 --- a/pkg/containerregistry/container_registry.go +++ b/pkg/containerregistry/container_registry.go @@ -10,9 +10,9 @@ import ( // ContainerRegistry represents a container registry credentials type ContainerRegistry struct { - Server string `json:"server"` - Username string `json:"username"` - Password string `json:"password"` + Server string `json:"server" validate:"required"` + Username string `json:"username" validate:"required"` + Password string `json:"password" validate:"required"` } // @name ContainerRegistry func GetServerHostname(server string) (string, error) { diff --git a/pkg/gitprovider/git_provider.go b/pkg/gitprovider/git_provider.go index 58ce454d55..e904a9989c 100644 --- a/pkg/gitprovider/git_provider.go +++ b/pkg/gitprovider/git_provider.go @@ -14,15 +14,15 @@ import ( const personalNamespaceId = "" type StaticGitContext struct { - Id string `json:"id"` - Url string `json:"url"` - Name string `json:"name"` - Branch *string `json:"branch,omitempty"` - Sha *string `json:"sha,omitempty"` - Owner string `json:"owner"` - PrNumber *uint32 `json:"prNumber,omitempty"` - Source string `json:"source"` - Path *string `json:"path,omitempty"` + Id string `json:"id" validate:"required"` + Url string `json:"url" validate:"required"` + Name string `json:"name" validate:"required"` + Branch *string `json:"branch,omitempty" validate:"optional"` + Sha *string `json:"sha,omitempty" validate:"optional"` + Owner string `json:"owner" validate:"required"` + PrNumber *uint32 `json:"prNumber,omitempty" validate:"optional"` + Source string `json:"source" validate:"required"` + Path *string `json:"path,omitempty" validate:"optional"` } // @name StaticGitContext type GitProvider interface { diff --git a/pkg/gitprovider/types.go b/pkg/gitprovider/types.go index 22235138b6..aee2cd011f 100644 --- a/pkg/gitprovider/types.go +++ b/pkg/gitprovider/types.go @@ -4,47 +4,47 @@ package gitprovider type GitProviderConfig struct { - Id string `json:"id"` - Username string `json:"username"` - Token string `json:"token"` - BaseApiUrl *string `json:"baseApiUrl,omitempty"` + Id string `json:"id" validate:"required"` + Username string `json:"username" validate:"required"` + Token string `json:"token" validate:"required"` + BaseApiUrl *string `json:"baseApiUrl,omitempty" validate:"optional"` } // @name GitProvider type GitUser struct { - Id string `json:"id"` - Username string `json:"username"` - Name string `json:"name"` - Email string `json:"email"` + Id string `json:"id" validate:"required"` + Username string `json:"username" validate:"required"` + Name string `json:"name" validate:"required"` + Email string `json:"email" validate:"required"` } // @name GitUser type GitRepository struct { - Id string `json:"id"` - Url string `json:"url"` - Name string `json:"name"` - Branch *string `json:"branch,omitempty"` - Sha string `json:"sha"` - Owner string `json:"owner"` - PrNumber *uint32 `json:"prNumber,omitempty"` - Source string `json:"source"` - Path *string `json:"path,omitempty"` + Id string `json:"id" validate:"required"` + Url string `json:"url" validate:"required"` + Name string `json:"name" validate:"required"` + Branch *string `json:"branch,omitempty" validate:"optional"` + Sha string `json:"sha" validate:"required"` + Owner string `json:"owner" validate:"required"` + PrNumber *uint32 `json:"prNumber,omitempty" validate:"optional"` + Source string `json:"source" validate:"required"` + Path *string `json:"path,omitempty" validate:"optional"` } // @name GitRepository type GitNamespace struct { - Id string `json:"id"` - Name string `json:"name"` + Id string `json:"id" validate:"required"` + Name string `json:"name" validate:"required"` } // @name GitNamespace type GitBranch struct { - Name string `json:"name"` - Sha string `json:"sha"` + Name string `json:"name" validate:"required"` + Sha string `json:"sha" validate:"required"` } // @name GitBranch type GitPullRequest struct { - Name string `json:"name"` - Branch string `json:"branch"` - Sha string `json:"sha"` - SourceRepoId string `json:"sourceRepoId"` - SourceRepoUrl string `json:"sourceRepoUrl"` - SourceRepoOwner string `json:"sourceRepoOwner"` - SourceRepoName string `json:"sourceRepoName"` + Name string `json:"name" validate:"required"` + Branch string `json:"branch" validate:"required"` + Sha string `json:"sha" validate:"required"` + SourceRepoId string `json:"sourceRepoId" validate:"required"` + SourceRepoUrl string `json:"sourceRepoUrl" validate:"required"` + SourceRepoOwner string `json:"sourceRepoOwner" validate:"required"` + SourceRepoName string `json:"sourceRepoName" validate:"required"` } // @name GitPullRequest diff --git a/pkg/profiledata/profile_data.go b/pkg/profiledata/profile_data.go index 29e99745ab..29217a8758 100644 --- a/pkg/profiledata/profile_data.go +++ b/pkg/profiledata/profile_data.go @@ -4,5 +4,5 @@ package profiledata type ProfileData struct { - EnvVars map[string]string `json:"envVars"` + EnvVars map[string]string `json:"envVars" validate:"required"` } // @name ProfileData diff --git a/pkg/provider/types.go b/pkg/provider/types.go index 105176d509..6ecd41bb8f 100644 --- a/pkg/provider/types.go +++ b/pkg/provider/types.go @@ -11,8 +11,8 @@ import ( ) type ProviderInfo struct { - Name string `json:"name"` - Version string `json:"version"` + Name string `json:"name" validate:"required"` + Version string `json:"version" validate:"required"` } type InitializeProviderRequest struct { @@ -43,10 +43,10 @@ type ProjectRequest struct { } type ProviderTarget struct { - Name string `json:"name"` - ProviderInfo ProviderInfo `json:"providerInfo"` + Name string `json:"name" validate:"required"` + ProviderInfo ProviderInfo `json:"providerInfo" validate:"required"` // JSON encoded map of options - Options string `json:"options"` + Options string `json:"options" validate:"required"` } // @name ProviderTarget type ProviderTargetManifest map[string]ProviderTargetProperty // @name ProviderTargetManifest diff --git a/pkg/server/projectconfig/dto/projectconfig.go b/pkg/server/projectconfig/dto/projectconfig.go index 7036db630f..740a12edd9 100644 --- a/pkg/server/projectconfig/dto/projectconfig.go +++ b/pkg/server/projectconfig/dto/projectconfig.go @@ -9,14 +9,14 @@ import ( ) type CreateProjectConfigDTO struct { - Name string `json:"name"` - Image *string `json:"image,omitempty"` - User *string `json:"user,omitempty"` - BuildConfig *buildconfig.ProjectBuildConfig `json:"buildConfig,omitempty"` - Source CreateProjectConfigSourceDTO `json:"source"` - EnvVars map[string]string `json:"envVars"` + Name string `json:"name" validate:"required"` + Image *string `json:"image,omitempty" validate:"optional"` + User *string `json:"user,omitempty" validate:"optional"` + BuildConfig *buildconfig.ProjectBuildConfig `json:"buildConfig,omitempty" validate:"optional"` + Source CreateProjectConfigSourceDTO `json:"source" validate:"required"` + EnvVars map[string]string `json:"envVars" validate:"required"` } // @name CreateProjectConfigDTO type CreateProjectConfigSourceDTO struct { - Repository *gitprovider.GitRepository `json:"repository"` + Repository *gitprovider.GitRepository `json:"repository" validate:"required"` } // @name CreateProjectConfigSourceDTO diff --git a/pkg/server/types.go b/pkg/server/types.go index b96ed7302a..5f64a32ab0 100644 --- a/pkg/server/types.go +++ b/pkg/server/types.go @@ -24,30 +24,30 @@ type ILocalContainerRegistry interface { } type FRPSConfig struct { - Domain string `json:"domain"` - Port uint32 `json:"port"` - Protocol string `json:"protocol"` + Domain string `json:"domain" validate:"required"` + Port uint32 `json:"port" validate:"required"` + Protocol string `json:"protocol" validate:"required"` } // @name FRPSConfig type NetworkKey struct { - Key string `json:"key"` + Key string `json:"key" validate:"required"` } // @name NetworkKey type Config struct { - ProvidersDir string `json:"providersDir"` - RegistryUrl string `json:"registryUrl"` - Id string `json:"id"` - ServerDownloadUrl string `json:"serverDownloadUrl"` - Frps *FRPSConfig `json:"frps,omitempty"` - ApiPort uint32 `json:"apiPort"` - HeadscalePort uint32 `json:"headscalePort"` - BinariesPath string `json:"binariesPath"` - LogFilePath string `json:"logFilePath"` - DefaultProjectImage string `json:"defaultProjectImage"` - DefaultProjectUser string `json:"defaultProjectUser"` - BuilderImage string `json:"builderImage"` - LocalBuilderRegistryPort uint32 `json:"localBuilderRegistryPort"` - LocalBuilderRegistryImage string `json:"localBuilderRegistryImage"` - BuilderRegistryServer string `json:"builderRegistryServer"` - BuildImageNamespace string `json:"buildImageNamespace"` + ProvidersDir string `json:"providersDir" validate:"required"` + RegistryUrl string `json:"registryUrl" validate:"required"` + Id string `json:"id" validate:"required"` + ServerDownloadUrl string `json:"serverDownloadUrl" validate:"required"` + Frps *FRPSConfig `json:"frps,omitempty" validate:"optional"` + ApiPort uint32 `json:"apiPort" validate:"required"` + HeadscalePort uint32 `json:"headscalePort" validate:"required"` + BinariesPath string `json:"binariesPath" validate:"required"` + LogFilePath string `json:"logFilePath" validate:"required"` + DefaultProjectImage string `json:"defaultProjectImage" validate:"required"` + DefaultProjectUser string `json:"defaultProjectUser" validate:"required"` + BuilderImage string `json:"builderImage" validate:"required"` + LocalBuilderRegistryPort uint32 `json:"localBuilderRegistryPort" validate:"required"` + LocalBuilderRegistryImage string `json:"localBuilderRegistryImage" validate:"required"` + BuilderRegistryServer string `json:"builderRegistryServer" validate:"required"` + BuildImageNamespace string `json:"buildImageNamespace" validate:"optional"` } // @name ServerConfig diff --git a/pkg/server/workspaces/create.go b/pkg/server/workspaces/create.go index 61bf9d686e..c5e09234a7 100644 --- a/pkg/server/workspaces/create.go +++ b/pkg/server/workspaces/create.go @@ -76,7 +76,7 @@ func (s *WorkspaceService) CreateWorkspace(ctx context.Context, req dto.CreateWo if projectConfig.Repository != nil { projectConfig.Repository.Url = util.CleanUpRepositoryUrl(projectConfig.Repository.Url) - if projectConfig.Repository.Sha != "" { + if projectConfig.Repository.Sha == "" { sha, err := s.gitProviderService.GetLastCommitSha(projectConfig.Repository) if err != nil { return nil, err diff --git a/pkg/server/workspaces/dto/workspace.go b/pkg/server/workspaces/dto/workspace.go index bd07a9f1f2..57377efe0c 100644 --- a/pkg/server/workspaces/dto/workspace.go +++ b/pkg/server/workspaces/dto/workspace.go @@ -11,17 +11,17 @@ import ( type WorkspaceDTO struct { workspace.Workspace - Info *workspace.WorkspaceInfo + Info *workspace.WorkspaceInfo `json:"info" validate:"optional"` } // @name WorkspaceDTO type ProjectDTO struct { project.Project - Info *project.ProjectInfo + Info *project.ProjectInfo `json:"info" validate:"optional"` } // @name ProjectDTO type CreateWorkspaceDTO struct { - Id string `json:"id"` - Name string `json:"name"` - Target string `json:"target"` + Id string `json:"id" validate:"required"` + Name string `json:"name" validate:"required"` + Target string `json:"target" validate:"required"` Projects []projectconfig_dto.CreateProjectConfigDTO `json:"projects" validate:"required,gt=0,dive"` } // @name CreateWorkspaceDTO diff --git a/pkg/views/containerregistry/list/view.go b/pkg/views/containerregistry/list/view.go index fe57e1f7ac..42e47db622 100644 --- a/pkg/views/containerregistry/list/view.go +++ b/pkg/views/containerregistry/list/view.go @@ -26,9 +26,9 @@ type rowData struct { func getRowData(registry *apiclient.ContainerRegistry) *rowData { rowData := rowData{"", "", ""} - rowData.Server = *registry.Server - rowData.Username = *registry.Username - rowData.Password = *registry.Password + rowData.Server = registry.Server + rowData.Username = registry.Username + rowData.Password = registry.Password return &rowData } @@ -91,11 +91,11 @@ func renderUnstyledList(registryList []apiclient.ContainerRegistry) { output := "\n" for _, registry := range registryList { - output += fmt.Sprintf("%s %s", views.GetPropertyKey("Server: "), *registry.Server) + "\n\n" + output += fmt.Sprintf("%s %s", views.GetPropertyKey("Server: "), registry.Server) + "\n\n" - output += fmt.Sprintf("%s %s", views.GetPropertyKey("Username: "), *registry.Username) + "\n\n" + output += fmt.Sprintf("%s %s", views.GetPropertyKey("Username: "), registry.Username) + "\n\n" - output += fmt.Sprintf("%s %s", views.GetPropertyKey("Password: "), *registry.Password) + "\n\n" + output += fmt.Sprintf("%s %s", views.GetPropertyKey("Password: "), registry.Password) + "\n\n" if registry.Server != registryList[len(registryList)-1].Server { output += views.SeparatorString + "\n\n" diff --git a/pkg/views/containerregistry/select.go b/pkg/views/containerregistry/select.go index 330d68e2df..914c27087c 100644 --- a/pkg/views/containerregistry/select.go +++ b/pkg/views/containerregistry/select.go @@ -26,9 +26,9 @@ func GetRegistryFromPrompt(registries []apiclient.ContainerRegistry, activeProfi emptyString := "" items = append(items, item{ registry: apiclient.ContainerRegistry{ - Password: &emptyString, - Username: &emptyString, - Server: &name, + Password: emptyString, + Username: emptyString, + Server: name, }, }) } diff --git a/pkg/views/containerregistry/view.go b/pkg/views/containerregistry/view.go index 80c6cc0f8c..24392c00f7 100644 --- a/pkg/views/containerregistry/view.go +++ b/pkg/views/containerregistry/view.go @@ -14,14 +14,14 @@ type item struct { registry apiclient.ContainerRegistry } -func (i item) Title() string { return *i.registry.Server } +func (i item) Title() string { return i.registry.Server } func (i item) Description() string { - if *i.registry.Server == NewRegistryServerIdentifier { + if i.registry.Server == NewRegistryServerIdentifier { return "Add a new container registry" } - return *i.registry.Username + return i.registry.Username } -func (i item) FilterValue() string { return *i.registry.Server } +func (i item) FilterValue() string { return i.registry.Server } type model struct { list list.Model diff --git a/pkg/views/gitprovider/select.go b/pkg/views/gitprovider/select.go index be5a9f59b3..faabc184e5 100644 --- a/pkg/views/gitprovider/select.go +++ b/pkg/views/gitprovider/select.go @@ -26,7 +26,7 @@ type GitProviderView struct { var commonGitProviderIds = []string{"github", "gitlab", "bitbucket"} -func GitProviderSelectionView(gitProviderAddView *apiclient.GitProvider, userGitProviders []apiclient.GitProvider, isDeleting bool) { +func GitProviderSelectionView(gitProviderAddView *apiclient.SetGitProviderConfig, userGitProviders []apiclient.GitProvider, isDeleting bool) { supportedProviders := config.GetSupportedGitProviders() var gitProviderOptions []huh.Option[string] @@ -34,7 +34,7 @@ func GitProviderSelectionView(gitProviderAddView *apiclient.GitProvider, userGit for _, supportedProvider := range supportedProviders { if isDeleting { for _, userProvider := range userGitProviders { - if *userProvider.Id == supportedProvider.Id { + if userProvider.Id == supportedProvider.Id { gitProviderOptions = append(gitProviderOptions, huh.Option[string]{Key: supportedProvider.Name, Value: supportedProvider.Id}) } } @@ -58,15 +58,15 @@ func GitProviderSelectionView(gitProviderAddView *apiclient.GitProvider, userGit Options( gitProviderOptions..., ). - Value(gitProviderAddView.Id)), + Value(&gitProviderAddView.Id)), huh.NewGroup( huh.NewSelect[string](). Title("Choose a Git provider"). Options( otherGitProviderOptions..., ). - Value(gitProviderAddView.Id)).WithHideFunc(func() bool { - return *gitProviderAddView.Id != "other" + Value(&gitProviderAddView.Id)).WithHideFunc(func() bool { + return gitProviderAddView.Id != "other" }), ).WithTheme(views.GetCustomTheme()) @@ -87,13 +87,13 @@ func GitProviderSelectionView(gitProviderAddView *apiclient.GitProvider, userGit return nil }), ).WithHideFunc(func() bool { - return isDeleting || !providerRequiresUsername(*gitProviderAddView.Id) + return isDeleting || !providerRequiresUsername(gitProviderAddView.Id) }), huh.NewGroup( huh.NewInput(). Title("Self-managed API URL"). Value(gitProviderAddView.BaseApiUrl). - Description(getApiUrlDescription(*gitProviderAddView.Id)). + Description(getApiUrlDescription(gitProviderAddView.Id)). Validate(func(str string) error { if str == "" { return errors.New("URL can not be blank") @@ -101,12 +101,12 @@ func GitProviderSelectionView(gitProviderAddView *apiclient.GitProvider, userGit return nil }), ).WithHideFunc(func() bool { - return isDeleting || !providerRequiresApiUrl(*gitProviderAddView.Id) + return isDeleting || !providerRequiresApiUrl(gitProviderAddView.Id) }), huh.NewGroup( huh.NewInput(). Title("Personal access token"). - Value(gitProviderAddView.Token). + Value(&gitProviderAddView.Token). Password(true). Validate(func(str string) error { if str == "" { @@ -118,7 +118,7 @@ func GitProviderSelectionView(gitProviderAddView *apiclient.GitProvider, userGit ).WithTheme(views.GetCustomTheme()) if !isDeleting { - views.RenderInfoMessage(getGitProviderHelpMessage(*gitProviderAddView.Id)) + views.RenderInfoMessage(getGitProviderHelpMessage(gitProviderAddView.Id)) } err = userDataForm.Run() diff --git a/pkg/views/projectconfig/info/view.go b/pkg/views/projectconfig/info/view.go index 65ed4e25bf..6c9c381dfb 100644 --- a/pkg/views/projectconfig/info/view.go +++ b/pkg/views/projectconfig/info/view.go @@ -29,16 +29,14 @@ func Render(projectConfig *apiclient.ProjectConfig, apiServerConfig *apiclient.S output += views.GetStyledMainTitle("Project Config Info") + "\n\n" - output += getInfoLine("Name", *projectConfig.Name) + "\n" + output += getInfoLine("Name", projectConfig.Name) + "\n" - if projectConfig.Repository != nil { - output += getInfoLine("Repository", *projectConfig.Repository.Url) + "\n" - } + output += getInfoLine("Repository", projectConfig.Repository.Url) + "\n" if GetLabelFromBuild(projectConfig.BuildConfig) != "" { projectDefaults := &create.ProjectConfigDefaults{ - Image: apiServerConfig.DefaultProjectImage, - ImageUser: apiServerConfig.DefaultProjectUser, + Image: &apiServerConfig.DefaultProjectImage, + ImageUser: &apiServerConfig.DefaultProjectUser, } createCreateProjectConfigDTO := apiclient.CreateProjectConfigDTO{ @@ -48,16 +46,16 @@ func Render(projectConfig *apiclient.ProjectConfig, apiServerConfig *apiclient.S output += getInfoLine("Build", buildChoice) + "\n" } - if projectConfig.Image != nil && *projectConfig.Image != "" { - output += getInfoLine("Image", *projectConfig.Image) + "\n" + if projectConfig.Image != "" { + output += getInfoLine("Image", projectConfig.Image) + "\n" } - if projectConfig.User != nil && *projectConfig.User != "" { - output += getInfoLine("User", *projectConfig.User) + "\n" + if projectConfig.User != "" { + output += getInfoLine("User", projectConfig.User) + "\n" } - if projectConfig.BuildConfig != nil && projectConfig.BuildConfig.Devcontainer != nil && projectConfig.BuildConfig.Devcontainer.FilePath != nil { - output += getInfoLine("Devcontainer path", *projectConfig.BuildConfig.Devcontainer.FilePath) + "\n" + if projectConfig.BuildConfig != nil && projectConfig.BuildConfig.Devcontainer != nil { + output += getInfoLine("Devcontainer path", projectConfig.BuildConfig.Devcontainer.FilePath) + "\n" } terminalWidth, _, err := term.GetSize(int(os.Stdout.Fd())) @@ -96,8 +94,8 @@ func GetLabelFromBuild(build *apiclient.ProjectBuildConfig) string { return "Automatic" } - if build.Devcontainer != nil && build.Devcontainer.FilePath != nil { - return fmt.Sprintf("Devcontainer (%s)", *build.Devcontainer.FilePath) + if build.Devcontainer != nil { + return fmt.Sprintf("Devcontainer (%s)", build.Devcontainer.FilePath) } return "" diff --git a/pkg/views/projectconfig/list/view.go b/pkg/views/projectconfig/list/view.go index 18fff1183a..7503e86d25 100644 --- a/pkg/views/projectconfig/list/view.go +++ b/pkg/views/projectconfig/list/view.go @@ -103,13 +103,13 @@ func getRowFromRowData(rowData RowData) []string { func getTableRowData(projectConfig apiclient.ProjectConfig, apiServerConfig *apiclient.ServerConfig, specifyGitProviders bool) *RowData { rowData := RowData{"", "", "", ""} - rowData.Name = *projectConfig.Name + views_util.AdditionalPropertyPadding - rowData.Repository = util.GetRepositorySlugFromUrl(*projectConfig.Repository.Url, specifyGitProviders) + rowData.Name = projectConfig.Name + views_util.AdditionalPropertyPadding + rowData.Repository = util.GetRepositorySlugFromUrl(projectConfig.Repository.Url, specifyGitProviders) rowData.IsDefault = "" projectDefaults := &create.ProjectConfigDefaults{ - Image: apiServerConfig.DefaultProjectImage, - ImageUser: apiServerConfig.DefaultProjectUser, + Image: &apiServerConfig.DefaultProjectImage, + ImageUser: &apiServerConfig.DefaultProjectUser, } createCreateProjectConfigDTO := apiclient.CreateProjectConfigDTO{ @@ -118,7 +118,7 @@ func getTableRowData(projectConfig apiclient.ProjectConfig, apiServerConfig *api _, rowData.Build = create.GetProjectBuildChoice(createCreateProjectConfigDTO, projectDefaults) - if *projectConfig.Default { + if projectConfig.Default { rowData.IsDefault = "1" } diff --git a/pkg/views/provider/list.go b/pkg/views/provider/list.go index dc0aa03b25..6f62a51efd 100644 --- a/pkg/views/provider/list.go +++ b/pkg/views/provider/list.go @@ -32,8 +32,8 @@ func getRowFromRowData(rowData RowData) []string { func getRowData(provider *apiclient.Provider) *RowData { rowData := RowData{"", ""} - rowData.Name = *provider.Name - rowData.Version = *provider.Version + rowData.Name = provider.Name + rowData.Version = provider.Version return &rowData } @@ -90,9 +90,9 @@ func renderUnstyledList(providerList []apiclient.Provider) { output := "\n" for _, provider := range providerList { - output += fmt.Sprintf("%s %s", views.GetPropertyKey("Provider Name: "), *provider.Name) + "\n\n" + output += fmt.Sprintf("%s %s", views.GetPropertyKey("Provider Name: "), provider.Name) + "\n\n" - output += fmt.Sprintf("%s %s", views.GetPropertyKey("Provider Version: "), *provider.Version) + "\n" + output += fmt.Sprintf("%s %s", views.GetPropertyKey("Provider Version: "), provider.Version) + "\n" if provider.Name != providerList[len(providerList)-1].Name { output += views.SeparatorString + "\n\n" diff --git a/pkg/views/provider/select.go b/pkg/views/provider/select.go index 5378951255..9e4e67de99 100644 --- a/pkg/views/provider/select.go +++ b/pkg/views/provider/select.go @@ -26,7 +26,7 @@ func GetProviderFromPrompt(providers []apiclient.Provider, title string, withNew name := NewProviderId items = append(items, item{ provider: apiclient.Provider{ - Name: &name, + Name: name, }, }) } diff --git a/pkg/views/provider/view.go b/pkg/views/provider/view.go index 6bc6fb3ebd..1ec88c4e41 100644 --- a/pkg/views/provider/view.go +++ b/pkg/views/provider/view.go @@ -17,11 +17,11 @@ type item struct { provider apiclient.Provider } -func (i item) Title() string { return *i.provider.Name } +func (i item) Title() string { return i.provider.Name } func (i item) Description() string { - return *i.provider.Version + return i.provider.Version } -func (i item) FilterValue() string { return *i.provider.Name } +func (i item) FilterValue() string { return i.provider.Name } type model struct { list list.Model diff --git a/pkg/views/server/apikey/create.go b/pkg/views/server/apikey/create.go index a8db6d281f..cf09462658 100644 --- a/pkg/views/server/apikey/create.go +++ b/pkg/views/server/apikey/create.go @@ -24,7 +24,7 @@ func ApiKeyCreationView(name *string, clientKeys []apiclient.ApiKey) { return errors.New("name can not be blank") } for _, key := range clientKeys { - if *key.Name == str { + if key.Name == str { return errors.New("key name already exists") } } diff --git a/pkg/views/server/apikey/list.go b/pkg/views/server/apikey/list.go index 61740d5525..2636d2a6f4 100644 --- a/pkg/views/server/apikey/list.go +++ b/pkg/views/server/apikey/list.go @@ -32,8 +32,8 @@ func getRowFromRowData(rowData RowData) []string { func getRowData(apiKey *apiclient.ApiKey) *RowData { rowData := RowData{"", ""} - rowData.Name = *apiKey.Name - rowData.Type = string(*apiKey.Type) + rowData.Name = apiKey.Name + rowData.Type = string(apiKey.Type) return &rowData } @@ -90,9 +90,9 @@ func renderUnstyledList(apiKeyList []apiclient.ApiKey) { output := "\n" for _, apiKey := range apiKeyList { - output += fmt.Sprintf("%s %s", views.GetPropertyKey("API Key Name: "), *apiKey.Name) + "\n\n" + output += fmt.Sprintf("%s %s", views.GetPropertyKey("API Key Name: "), apiKey.Name) + "\n\n" - output += fmt.Sprintf("%s %s", views.GetPropertyKey("API Key Type: "), *apiKey.Type) + "\n\n" + output += fmt.Sprintf("%s %s", views.GetPropertyKey("API Key Type: "), apiKey.Type) + "\n\n" if apiKey.Name != apiKeyList[len(apiKeyList)-1].Name { output += views.SeparatorString + "\n\n" diff --git a/pkg/views/server/apikey/select.go b/pkg/views/server/apikey/select.go index 2bacaf990d..393a01afe9 100644 --- a/pkg/views/server/apikey/select.go +++ b/pkg/views/server/apikey/select.go @@ -26,7 +26,7 @@ func GetApiKeyFromPrompt(apiKeys []apiclient.ApiKey, title string, withNewApiKey name := NewApiKeyName items = append(items, item{ apiKey: apiclient.ApiKey{ - Name: &name, + Name: name, }, }) } diff --git a/pkg/views/server/apikey/view.go b/pkg/views/server/apikey/view.go index fca13b83ef..229c57441b 100644 --- a/pkg/views/server/apikey/view.go +++ b/pkg/views/server/apikey/view.go @@ -17,11 +17,11 @@ type item struct { apiKey apiclient.ApiKey } -func (i item) Title() string { return *i.apiKey.Name } +func (i item) Title() string { return i.apiKey.Name } func (i item) Description() string { - return string(*i.apiKey.Type) + return string(i.apiKey.Type) } -func (i item) FilterValue() string { return *i.apiKey.Name } +func (i item) FilterValue() string { return i.apiKey.Name } type model struct { list list.Model diff --git a/pkg/views/server/configure.go b/pkg/views/server/configure.go index 5f5e877730..f88a0f19d6 100644 --- a/pkg/views/server/configure.go +++ b/pkg/views/server/configure.go @@ -51,7 +51,7 @@ func (m *Model) createForm(containerRegistries []apiclient.ContainerRegistry) *h Value: "local", }} for _, cr := range containerRegistries { - builderContainerRegistryOptions = append(builderContainerRegistryOptions, huh.Option[string]{Key: *cr.Server, Value: *cr.Server}) + builderContainerRegistryOptions = append(builderContainerRegistryOptions, huh.Option[string]{Key: cr.Server, Value: cr.Server}) } return huh.NewForm( @@ -59,34 +59,34 @@ func (m *Model) createForm(containerRegistries []apiclient.ContainerRegistry) *h huh.NewInput(). Title("Providers Directory"). Description("Directory will be created if it does not exist"). - Value(m.config.ProvidersDir), + Value(&m.config.ProvidersDir), huh.NewInput(). Title("Registry URL"). - Value(m.config.RegistryUrl), + Value(&m.config.RegistryUrl), huh.NewInput(). Title("Server Download URL"). - Value(m.config.ServerDownloadUrl), + Value(&m.config.ServerDownloadUrl), ), huh.NewGroup( huh.NewInput(). Title("Default Project Image"). - Value(m.config.DefaultProjectImage), + Value(&m.config.DefaultProjectImage), huh.NewInput(). Title("Default Project User"). - Value(m.config.DefaultProjectUser), + Value(&m.config.DefaultProjectUser), ), huh.NewGroup( huh.NewInput(). Title("Builder Image"). Description("Image dependencies: docker, @devcontainers/cli (node package)"). - Value(m.config.BuilderImage), + Value(&m.config.BuilderImage), huh.NewSelect[string](). Title("Builder Registry"). Description("To add options, add a container registry with 'daytona cr set'"). Options( builderContainerRegistryOptions..., ). - Value(m.config.BuilderRegistryServer), + Value(&m.config.BuilderRegistryServer), huh.NewInput(). Title("Build Image Namespace"). Description("Namespace to be used when tagging and pushing build images"). @@ -96,30 +96,30 @@ func (m *Model) createForm(containerRegistries []apiclient.ContainerRegistry) *h huh.NewInput(). Title("Local Builder Registry Port"). Value(&localBuilderRegistryPort). - Validate(createPortValidator(m.config, &localBuilderRegistryPort, m.config.LocalBuilderRegistryPort)), + Validate(createPortValidator(m.config, &localBuilderRegistryPort, &m.config.LocalBuilderRegistryPort)), huh.NewInput(). Title("Local Builder Registry Image"). - Value(m.config.LocalBuilderRegistryImage), + Value(&m.config.LocalBuilderRegistryImage), ).WithHideFunc(func() bool { - return m.config.BuilderRegistryServer == nil || *m.config.BuilderRegistryServer != "local" + return m.config.BuilderRegistryServer != "local" }), huh.NewGroup( huh.NewInput(). Title("API Port"). Value(&apiPortView). - Validate(createPortValidator(m.config, &apiPortView, m.config.ApiPort)), + Validate(createPortValidator(m.config, &apiPortView, &m.config.ApiPort)), huh.NewInput(). Title("Headscale Port"). Value(&headscalePortView). - Validate(createPortValidator(m.config, &headscalePortView, m.config.HeadscalePort)), + Validate(createPortValidator(m.config, &headscalePortView, &m.config.HeadscalePort)), huh.NewInput(). Title("Binaries Path"). Description("Directory will be created if it does not exist"). - Value(m.config.BinariesPath), + Value(&m.config.BinariesPath), huh.NewInput(). Title("Log File Path"). Description("File will be created if it does not exist"). - Value(m.config.LogFilePath). + Value(&m.config.LogFilePath). Validate(func(s string) error { _, err := os.Stat(s) if os.IsNotExist(err) { @@ -132,14 +132,14 @@ func (m *Model) createForm(containerRegistries []apiclient.ContainerRegistry) *h huh.NewGroup( huh.NewInput(). Title("Frps Domain"). - Value(m.config.Frps.Domain), + Value(&m.config.Frps.Domain), huh.NewInput(). Title("Frps Port"). Value(&frpsPortView). - Validate(createPortValidator(m.config, &frpsPortView, m.config.Frps.Port)), + Validate(createPortValidator(m.config, &frpsPortView, &m.config.Frps.Port)), huh.NewInput(). Title("Frps Protocol"). - Value(m.config.Frps.Protocol), + Value(&m.config.Frps.Protocol), ), ).WithTheme(views.GetCustomTheme()) } @@ -226,7 +226,7 @@ func createPortValidator(config *apiclient.ServerConfig, portView *string, port } *port = int32(validatePort) - if *config.ApiPort == *config.HeadscalePort { + if config.ApiPort == config.HeadscalePort { return errors.New("port conflict") } diff --git a/pkg/views/target/list/view.go b/pkg/views/target/list/view.go index 823b2600ef..55a06a4f61 100644 --- a/pkg/views/target/list/view.go +++ b/pkg/views/target/list/view.go @@ -35,9 +35,9 @@ func getRowFromRowData(rowData RowData) []string { func getRowData(target *apiclient.ProviderTarget) *RowData { rowData := RowData{"", "", ""} - rowData.Target = *target.Name - rowData.Provider = *target.ProviderInfo.Name - rowData.Options = *target.Options + rowData.Target = target.Name + rowData.Provider = target.ProviderInfo.Name + rowData.Options = target.Options return &rowData } @@ -96,7 +96,7 @@ func sortTargets(targets *[]apiclient.ProviderTarget) { sort.Slice(*targets, func(i, j int) bool { t1 := (*targets)[i] t2 := (*targets)[j] - return *t1.ProviderInfo.Name < *t2.ProviderInfo.Name + return t1.ProviderInfo.Name < t2.ProviderInfo.Name }) } @@ -104,11 +104,11 @@ func renderUnstyledList(targetList []apiclient.ProviderTarget) { output := "\n" for _, target := range targetList { - output += fmt.Sprintf("%s %s", views.GetPropertyKey("Target Name: "), *target.Name) + "\n\n" + output += fmt.Sprintf("%s %s", views.GetPropertyKey("Target Name: "), target.Name) + "\n\n" - output += fmt.Sprintf("%s %s", views.GetPropertyKey("Target Provider: "), *target.ProviderInfo.Name) + "\n\n" + output += fmt.Sprintf("%s %s", views.GetPropertyKey("Target Provider: "), target.ProviderInfo.Name) + "\n\n" - output += fmt.Sprintf("%s %s", views.GetPropertyKey("Target Options: "), *target.Options) + "\n" + output += fmt.Sprintf("%s %s", views.GetPropertyKey("Target Options: "), target.Options) + "\n" if target.Name != targetList[len(targetList)-1].Name { output += views.SeparatorString + "\n\n" diff --git a/pkg/views/target/select.go b/pkg/views/target/select.go index 990c8e26f1..f128ad8eac 100644 --- a/pkg/views/target/select.go +++ b/pkg/views/target/select.go @@ -26,8 +26,8 @@ func GetTargetFromPrompt(targets []apiclient.ProviderTarget, activeProfileName s options := "{}" items = append(items, item{ target: apiclient.ProviderTarget{ - Name: &name, - Options: &options, + Name: name, + Options: options, }, }) } diff --git a/pkg/views/target/set.go b/pkg/views/target/set.go index 7b3579bd64..92c5b2da09 100644 --- a/pkg/views/target/set.go +++ b/pkg/views/target/set.go @@ -47,7 +47,7 @@ func SetTargetForm(target *apiclient.ProviderTarget, targetManifest map[string]a groups := []*huh.Group{} options := make(map[string]interface{}) - err := json.Unmarshal([]byte(*target.Options), &options) + err := json.Unmarshal([]byte(target.Options), &options) if err != nil { return err } @@ -61,7 +61,7 @@ func SetTargetForm(target *apiclient.ProviderTarget, targetManifest map[string]a for _, name := range sortedKeys { property := targetManifest[name] if property.DisabledPredicate != nil && *property.DisabledPredicate != "" { - if matched, err := regexp.Match(*property.DisabledPredicate, []byte(*target.Name)); err == nil && matched { + if matched, err := regexp.Match(*property.DisabledPredicate, []byte(target.Name)); err == nil && matched { continue } } @@ -123,7 +123,7 @@ func SetTargetForm(target *apiclient.ProviderTarget, targetManifest map[string]a for name, property := range targetManifest { if property.DisabledPredicate != nil && *property.DisabledPredicate != "" { - if matched, err := regexp.Match(*property.DisabledPredicate, []byte(*target.Name)); err == nil && matched { + if matched, err := regexp.Match(*property.DisabledPredicate, []byte(target.Name)); err == nil && matched { continue } } @@ -151,7 +151,7 @@ func SetTargetForm(target *apiclient.ProviderTarget, targetManifest map[string]a } content := string(jsonContent) - target.Options = &content + target.Options = content return nil } diff --git a/pkg/views/target/view.go b/pkg/views/target/view.go index cfc06c9761..ef8e909c3b 100644 --- a/pkg/views/target/view.go +++ b/pkg/views/target/view.go @@ -17,14 +17,11 @@ type item struct { target apiclient.ProviderTarget } -func (i item) Title() string { return *i.target.Name } +func (i item) Title() string { return i.target.Name } func (i item) Description() string { - if i.target.ProviderInfo != nil { - return *i.target.ProviderInfo.Name - } - return "" + return i.target.ProviderInfo.Name } -func (i item) FilterValue() string { return *i.target.Name } +func (i item) FilterValue() string { return i.target.Name } type model struct { list list.Model diff --git a/pkg/views/workspace/create/configuration.go b/pkg/views/workspace/create/configuration.go index 9c5cdf6ca1..57d527164d 100644 --- a/pkg/views/workspace/create/configuration.go +++ b/pkg/views/workspace/create/configuration.go @@ -49,7 +49,7 @@ func NewConfigurationData(buildChoice BuildChoice, devContainerFilePath string, } if currentProject.EnvVars != nil { - projectConfigurationData.EnvVars = *currentProject.EnvVars + projectConfigurationData.EnvVars = currentProject.EnvVars } return projectConfigurationData @@ -77,7 +77,7 @@ func RunProjectConfiguration(projectList *[]apiclient.CreateProjectConfigDTO, de if currentProject.BuildConfig != nil { if currentProject.BuildConfig.Devcontainer != nil { builderChoice = DEVCONTAINER - devContainerFilePath = *currentProject.BuildConfig.Devcontainer.FilePath + devContainerFilePath = currentProject.BuildConfig.Devcontainer.FilePath } } else { if currentProject.Image == nil && currentProject.User == nil || @@ -119,14 +119,14 @@ func RunProjectConfiguration(projectList *[]apiclient.CreateProjectConfigDTO, de if projectConfigurationData.BuildChoice == string(DEVCONTAINER) { (*projectList)[i].BuildConfig = &apiclient.ProjectBuildConfig{ Devcontainer: &apiclient.DevcontainerConfig{ - FilePath: &projectConfigurationData.DevcontainerFilePath, + FilePath: projectConfigurationData.DevcontainerFilePath, }, } (*projectList)[i].Image = nil (*projectList)[i].User = nil } - (*projectList)[i].EnvVars = &projectConfigurationData.EnvVars + (*projectList)[i].EnvVars = projectConfigurationData.EnvVars } } diff --git a/pkg/views/workspace/create/summary.go b/pkg/views/workspace/create/summary.go index ac7d6be25e..6bdb4c2fde 100644 --- a/pkg/views/workspace/create/summary.go +++ b/pkg/views/workspace/create/summary.go @@ -99,19 +99,13 @@ func RenderSummary(name string, projectList []apiclient.CreateProjectConfigDTO, output = views.GetStyledMainTitle(fmt.Sprintf("SUMMARY - %s %s", nameLabel, name)) } - for _, project := range projectList { - if project.Source == nil || project.Source.Repository == nil || project.Source.Repository.Url == nil { - return "", fmt.Errorf("repository is required") - } - } - output += "\n\n" for i := range projectList { if len(projectList) == 1 { - output += fmt.Sprintf("%s - %s\n", lipgloss.NewStyle().Foreground(views.Green).Render("Project"), (*projectList[i].Source.Repository.Url)) + output += fmt.Sprintf("%s - %s\n", lipgloss.NewStyle().Foreground(views.Green).Render("Project"), (projectList[i].Source.Repository.Url)) } else { - output += fmt.Sprintf("%s - %s\n", lipgloss.NewStyle().Foreground(views.Green).Render(fmt.Sprintf("%s #%d", "Project", i+1)), (*projectList[i].Source.Repository.Url)) + output += fmt.Sprintf("%s - %s\n", lipgloss.NewStyle().Foreground(views.Green).Render(fmt.Sprintf("%s #%d", "Project", i+1)), (projectList[i].Source.Repository.Url)) } projectBuildChoice, choiceName := GetProjectBuildChoice(projectList[i], defaults) @@ -130,10 +124,8 @@ func renderProjectDetails(project apiclient.CreateProjectConfigDTO, buildChoice if buildChoice == DEVCONTAINER { if project.BuildConfig != nil { if project.BuildConfig.Devcontainer != nil { - if project.BuildConfig.Devcontainer.FilePath != nil { - output += "\n" - output += projectDetailOutput(DevcontainerConfig, *project.BuildConfig.Devcontainer.FilePath) - } + output += "\n" + output += projectDetailOutput(DevcontainerConfig, project.BuildConfig.Devcontainer.FilePath) } } } else { @@ -152,13 +144,13 @@ func renderProjectDetails(project apiclient.CreateProjectConfigDTO, buildChoice } } - if project.EnvVars != nil && len(*project.EnvVars) > 0 { + if project.EnvVars != nil && len(project.EnvVars) > 0 { if output != "" { output += "\n" } var envVars string - for key, val := range *project.EnvVars { + for key, val := range project.EnvVars { envVars += fmt.Sprintf("%s=%s; ", key, val) } output += projectDetailOutput(EnvVars, strings.TrimSuffix(envVars, "; ")) diff --git a/pkg/views/workspace/create/view.go b/pkg/views/workspace/create/view.go index dddc248c15..f083865426 100644 --- a/pkg/views/workspace/create/view.go +++ b/pkg/views/workspace/create/view.go @@ -101,7 +101,7 @@ func GetRepositoryFromUrlInput(multiProject bool, projectOrder int, apiClient *a return nil, err } - selectedRepos[*repo.Url]++ + selectedRepos[repo.Url]++ return repo, nil } diff --git a/pkg/views/workspace/info/view.go b/pkg/views/workspace/info/view.go index e624bd2812..7364d3c018 100644 --- a/pkg/views/workspace/info/view.go +++ b/pkg/views/workspace/info/view.go @@ -37,9 +37,9 @@ func Render(workspace *apiclient.WorkspaceDTO, ide string, forceUnstyled bool) { } output += "\n" - output += getInfoLine(nameLabel, *workspace.Name) + "\n" + output += getInfoLine(nameLabel, workspace.Name) + "\n" - output += getInfoLine("ID", *workspace.Id) + "\n" + output += getInfoLine("ID", workspace.Id) + "\n" if isCreationView { output += getInfoLine("Editor", ide) + "\n" @@ -90,27 +90,23 @@ func getSingleProjectOutput(project *apiclient.Project, isCreationView bool) str var output string var repositoryUrl string - if project.Repository != nil { - repositoryUrl = *project.Repository.Url - repositoryUrl = strings.TrimPrefix(repositoryUrl, "https://") - repositoryUrl = strings.TrimPrefix(repositoryUrl, "http://") - } + repositoryUrl = project.Repository.Url + repositoryUrl = strings.TrimPrefix(repositoryUrl, "https://") + repositoryUrl = strings.TrimPrefix(repositoryUrl, "http://") if project.State != nil { output += getInfoLineState("State", project.State) + "\n" - if project.State.GitStatus != nil { - output += getInfoLineGitStatus("Branch", project.State.GitStatus) + "\n" - } + output += getInfoLineGitStatus("Branch", &project.State.GitStatus) + "\n" } - if project.Target != nil && !isCreationView { - output += getInfoLine("Target", *project.Target) + "\n" + if !isCreationView { + output += getInfoLine("Target", project.Target) + "\n" } output += getInfoLine("Repository", repositoryUrl) - if project.Name != nil && !isCreationView { + if !isCreationView { output += "\n" - output += getInfoLine("Project", *project.Name) + output += getInfoLine("Project", project.Name) } return output @@ -119,17 +115,15 @@ func getSingleProjectOutput(project *apiclient.Project, isCreationView bool) str func getProjectsOutputs(projects []apiclient.Project, isCreationView bool) string { var output string for i, project := range projects { - output += getInfoLine(fmt.Sprintf("Project #%d", i+1), *project.Name) + output += getInfoLine(fmt.Sprintf("Project #%d", i+1), project.Name) output += getInfoLineState("State", project.State) - if project.State != nil && project.State.GitStatus != nil { - output += getInfoLineGitStatus("Branch", project.State.GitStatus) - } - if project.Target != nil && !isCreationView { - output += getInfoLine("Target", *project.Target) + if project.State != nil { + output += getInfoLineGitStatus("Branch", &project.State.GitStatus) } - if project.Repository != nil { - output += getInfoLine("Repository", *project.Repository.Url) + if !isCreationView { + output += getInfoLine("Target", project.Target) } + output += getInfoLine("Repository", project.Repository.Url) if project.Name != projects[len(projects)-1].Name { output += "\n" } @@ -145,10 +139,10 @@ func getInfoLineState(key string, state *apiclient.ProjectState) string { var uptime int var stateProperty string - if state == nil || state.Uptime == nil { + if state == nil { uptime = 0 } else { - uptime = int(*state.Uptime) + uptime = int(state.Uptime) } if uptime == 0 { @@ -162,10 +156,7 @@ func getInfoLineState(key string, state *apiclient.ProjectState) string { func getInfoLineGitStatus(key string, status *apiclient.GitStatus) string { output := propertyNameStyle.Render(fmt.Sprintf("%-*s", propertyNameWidth, key)) - if status.CurrentBranch == nil { - return output + propertyValueStyle.Foreground(views.Gray).Render("No branch") + "\n" - } - output += propertyNameStyle.Foreground(views.Gray).Render(fmt.Sprintf("%-*s", propertyNameWidth, *status.CurrentBranch)) + output += propertyNameStyle.Foreground(views.Gray).Render(fmt.Sprintf("%-*s", propertyNameWidth, status.CurrentBranch)) changesOutput := "" if status.FileStatus == nil { diff --git a/pkg/views/workspace/list/view.go b/pkg/views/workspace/list/view.go index 0c2fb450fd..9ead403ac5 100644 --- a/pkg/views/workspace/list/view.go +++ b/pkg/views/workspace/list/view.go @@ -45,7 +45,7 @@ func ListWorkspaces(workspaceList []apiclient.WorkspaceDTO, specifyGitProviders row = getRowFromRowData(*rowData, false) data = append(data, row) } else { - row = getRowFromRowData(RowData{Name: *workspace.Name}, true) + row = getRowFromRowData(RowData{Name: workspace.Name}, true) data = append(data, row) for _, project := range workspace.Projects { rowData = getProjectTableRowData(workspace, project, specifyGitProviders) @@ -150,10 +150,10 @@ func sortWorkspaces(workspaceList *[]apiclient.WorkspaceDTO, verbose bool) { if ws1.Info == nil || ws2.Info == nil || ws1.Info.Projects == nil || ws2.Info.Projects == nil { return false } - if len(ws1.Info.Projects) == 0 || len(ws2.Info.Projects) == 0 || ws1.Info.Projects[0].Created == nil || ws2.Info.Projects[0].Created == nil { + if len(ws1.Info.Projects) == 0 || len(ws2.Info.Projects) == 0 { return false } - return *ws1.Info.Projects[0].Created > *ws2.Info.Projects[0].Created + return ws1.Info.Projects[0].Created > ws2.Info.Projects[0].Created }) return } @@ -161,53 +161,48 @@ func sortWorkspaces(workspaceList *[]apiclient.WorkspaceDTO, verbose bool) { sort.Slice(*workspaceList, func(i, j int) bool { ws1 := (*workspaceList)[i] ws2 := (*workspaceList)[j] - if len(ws1.Projects) == 0 || len(ws2.Projects) == 0 || ws1.Projects[0].State == nil || ws2.Projects[0].State == nil || ws1.Projects[0].State.Uptime == nil || ws2.Projects[0].State.Uptime == nil { + if len(ws1.Projects) == 0 || len(ws2.Projects) == 0 || ws1.Projects[0].State == nil || ws2.Projects[0].State == nil { return true } - return *ws1.Projects[0].State.Uptime < *ws2.Projects[0].State.Uptime + return ws1.Projects[0].State.Uptime < ws2.Projects[0].State.Uptime }) } func getWorkspaceTableRowData(workspace apiclient.WorkspaceDTO, specifyGitProviders bool) *RowData { rowData := RowData{"", "", "", "", "", ""} - if workspace.Name != nil { - rowData.Name = *workspace.Name + views_util.AdditionalPropertyPadding - } - if workspace.Projects != nil && len(workspace.Projects) > 0 && workspace.Projects[0].Repository != nil { - rowData.Repository = util.GetRepositorySlugFromUrl(*workspace.Projects[0].Repository.Url, specifyGitProviders) + rowData.Name = workspace.Name + views_util.AdditionalPropertyPadding + if workspace.Projects != nil && len(workspace.Projects) > 0 { + rowData.Repository = util.GetRepositorySlugFromUrl(workspace.Projects[0].Repository.Url, specifyGitProviders) if workspace.Projects[0].Repository.Branch != nil { rowData.Branch = *workspace.Projects[0].Repository.Branch } } - if workspace.Target != nil { - rowData.Target = *workspace.Target + views_util.AdditionalPropertyPadding - } - if workspace.Info != nil && workspace.Info.Projects != nil && len(workspace.Info.Projects) > 0 && workspace.Info.Projects[0].Created != nil { - rowData.Created = util.FormatCreatedTime(*workspace.Info.Projects[0].Created) + + rowData.Target = workspace.Target + views_util.AdditionalPropertyPadding + + if workspace.Info != nil && workspace.Info.Projects != nil && len(workspace.Info.Projects) > 0 { + rowData.Created = util.FormatCreatedTime(workspace.Info.Projects[0].Created) } - if len(workspace.Projects) > 0 && workspace.Projects[0].State != nil && workspace.Projects[0].State.Uptime != nil && *workspace.Projects[0].State.Uptime > 0 { - rowData.Status = util.FormatUptime(*workspace.Projects[0].State.Uptime) + if len(workspace.Projects) > 0 && workspace.Projects[0].State != nil && workspace.Projects[0].State.Uptime > 0 { + rowData.Status = util.FormatUptime(workspace.Projects[0].State.Uptime) } return &rowData } func getProjectTableRowData(workspaceDTO apiclient.WorkspaceDTO, project apiclient.Project, specifyGitProviders bool) *RowData { rowData := RowData{"", "", "", "", "", ""} - if project.Name != nil { - rowData.Name = " └ " + *project.Name - } - if project.Repository != nil && project.Repository.Url != nil { - rowData.Repository = util.GetRepositorySlugFromUrl(*project.Repository.Url, specifyGitProviders) - if project.Repository.Branch != nil { - rowData.Branch = *project.Repository.Branch - } - } - if project.Target != nil { - rowData.Target = *project.Target + views_util.AdditionalPropertyPadding + rowData.Name = " └ " + project.Name + + rowData.Repository = util.GetRepositorySlugFromUrl(project.Repository.Url, specifyGitProviders) + if project.Repository.Branch != nil { + rowData.Branch = *project.Repository.Branch } - if project.State != nil && project.State.Uptime != nil && *project.State.Uptime > 0 { - rowData.Status = util.FormatUptime(*project.State.Uptime) + + rowData.Target = project.Target + views_util.AdditionalPropertyPadding + + if project.State != nil && project.State.Uptime > 0 { + rowData.Status = util.FormatUptime(project.State.Uptime) } if workspaceDTO.Info == nil || workspaceDTO.Info.Projects == nil { @@ -215,8 +210,8 @@ func getProjectTableRowData(workspaceDTO apiclient.WorkspaceDTO, project apiclie } for _, projectInfo := range workspaceDTO.Info.Projects { - if *projectInfo.Name == *project.Name { - rowData.Created = util.FormatCreatedTime(*projectInfo.Created) + if projectInfo.Name == project.Name { + rowData.Created = util.FormatCreatedTime(projectInfo.Created) break } } diff --git a/pkg/views/workspace/selection/branch.go b/pkg/views/workspace/selection/branch.go index e3b4fea4af..3fa7f2b367 100644 --- a/pkg/views/workspace/selection/branch.go +++ b/pkg/views/workspace/selection/branch.go @@ -19,9 +19,9 @@ func selectBranchPrompt(branches []apiclient.GitBranch, projectOrder int, choice // Populate items with titles and descriptions from workspaces. for _, branch := range branches { - newItem := item[string]{id: *branch.Name, title: *branch.Name, choiceProperty: *branch.Name} - if *branch.Sha != "" { - newItem.desc = fmt.Sprintf("SHA: %s", *branch.Sha) + newItem := item[string]{id: branch.Name, title: branch.Name, choiceProperty: branch.Name} + if branch.Sha != "" { + newItem.desc = fmt.Sprintf("SHA: %s", branch.Sha) } items = append(items, newItem) } @@ -57,7 +57,7 @@ func GetBranchFromPrompt(branches []apiclient.GitBranch, projectOrder int) *apic branchName := <-choiceChan for _, b := range branches { - if *b.Name == branchName { + if b.Name == branchName { return &b } } diff --git a/pkg/views/workspace/selection/namespace.go b/pkg/views/workspace/selection/namespace.go index 2a730dc6f2..a951567236 100644 --- a/pkg/views/workspace/selection/namespace.go +++ b/pkg/views/workspace/selection/namespace.go @@ -19,12 +19,12 @@ func selectNamespacePrompt(namespaces []apiclient.GitNamespace, projectOrder int // Populate items with titles and descriptions from workspaces. for _, namespace := range namespaces { - if *namespace.Id == "" { + if namespace.Id == "" { desc = "personal" } else { desc = "organization" } - newItem := item[string]{id: *namespace.Id, title: *namespace.Name, desc: desc, choiceProperty: *namespace.Id} + newItem := item[string]{id: namespace.Id, title: namespace.Name, desc: desc, choiceProperty: namespace.Id} items = append(items, newItem) } diff --git a/pkg/views/workspace/selection/project.go b/pkg/views/workspace/selection/project.go index d760d07f73..8f771855ce 100644 --- a/pkg/views/workspace/selection/project.go +++ b/pkg/views/workspace/selection/project.go @@ -25,12 +25,11 @@ func selectProjectPrompt(projects []apiclient.Project, actionVerb string, choice items := []list.Item{} for _, project := range projects { - var projectName string - if project.Name != nil { - projectName = *project.Name - } else { + projectName := project.Name + if project.Name == "" { projectName = "Unnamed Project" } + newItem := item[apiclient.Project]{title: projectName, desc: "", choiceProperty: project} items = append(items, newItem) } diff --git a/pkg/views/workspace/selection/projectconfig.go b/pkg/views/workspace/selection/projectconfig.go index 07c8271857..6766bd5715 100644 --- a/pkg/views/workspace/selection/projectconfig.go +++ b/pkg/views/workspace/selection/projectconfig.go @@ -28,23 +28,18 @@ func selectProjectConfigPrompt(projectConfigs []apiclient.ProjectConfig, project if showBlankOption { newItem := item[apiclient.ProjectConfig]{title: "Make a blank project", desc: "(default project configuration)", choiceProperty: apiclient.ProjectConfig{ - Name: &BlankProjectIdentifier, + Name: BlankProjectIdentifier, }} items = append(items, newItem) } for _, pc := range projectConfigs { - var projectConfigName string - if pc.Name != nil { - projectConfigName = *pc.Name - } else { + projectConfigName := pc.Name + if pc.Name == "" { projectConfigName = "Unnamed Project Config" } - desc := "" - if pc.Repository != nil && pc.Repository.Url != nil { - desc = *pc.Repository.Url - } - newItem := item[apiclient.ProjectConfig]{title: projectConfigName, desc: desc, choiceProperty: pc} + + newItem := item[apiclient.ProjectConfig]{title: projectConfigName, desc: pc.Repository.Url, choiceProperty: pc} items = append(items, newItem) } diff --git a/pkg/views/workspace/selection/projectrequest.go b/pkg/views/workspace/selection/projectrequest.go index 635f191011..da76e81d87 100644 --- a/pkg/views/workspace/selection/projectrequest.go +++ b/pkg/views/workspace/selection/projectrequest.go @@ -20,7 +20,7 @@ import ( var doneConfiguringName = "DoneConfiguringName" var DoneConfiguring = apiclient.CreateProjectConfigDTO{ - Name: &doneConfiguringName, + Name: doneConfiguringName, } type projectRequestItem struct { @@ -45,17 +45,15 @@ func selectProjectRequestPrompt(projects *[]apiclient.CreateProjectConfigDTO, ch var user string var devcontainerConfig string - if project.Name != nil { - name = fmt.Sprintf("%s %s", "Project:", *project.Name) - } + name = fmt.Sprintf("%s %s", "Project:", project.Name) if project.Image != nil { image = fmt.Sprintf("%s %s", "Image:", *project.Image) } if project.User != nil { user = fmt.Sprintf("%s %s", "User:", *project.User) } - if project.BuildConfig != nil && project.BuildConfig.Devcontainer != nil && project.BuildConfig.Devcontainer.FilePath != nil { - devcontainerConfig = fmt.Sprintf("%s %s", "Devcontainer Config:", *project.BuildConfig.Devcontainer.FilePath) + if project.BuildConfig != nil && project.BuildConfig.Devcontainer != nil { + devcontainerConfig = fmt.Sprintf("%s %s", "Devcontainer Config:", project.BuildConfig.Devcontainer.FilePath) } newItem := projectRequestItem{name: name, image: image, user: user, project: project, devcontainerConfig: devcontainerConfig} diff --git a/pkg/views/workspace/selection/pullrequest.go b/pkg/views/workspace/selection/pullrequest.go index 9849bd9367..e95b43e870 100644 --- a/pkg/views/workspace/selection/pullrequest.go +++ b/pkg/views/workspace/selection/pullrequest.go @@ -19,9 +19,11 @@ func selectPullRequestPrompt(pullRequests []apiclient.GitPullRequest, projectOrd // Populate items with titles and descriptions from workspaces. for _, pr := range pullRequests { - newItem := item[string]{id: *pr.Name, title: *pr.Name, choiceProperty: *pr.Name} - if *pr.Branch != "" { - newItem.desc = fmt.Sprintf("Branch: %s", *pr.Branch) + newItem := item[string]{ + id: pr.Name, + title: pr.Name, + choiceProperty: pr.Name, + desc: fmt.Sprintf("Branch: %s", pr.Branch), } items = append(items, newItem) } @@ -57,7 +59,7 @@ func GetPullRequestFromPrompt(pullRequests []apiclient.GitPullRequest, projectOr pullRequestName := <-choiceChan for _, pr := range pullRequests { - if *pr.Name == pullRequestName { + if pr.Name == pullRequestName { return &pr } } diff --git a/pkg/views/workspace/selection/repository.go b/pkg/views/workspace/selection/repository.go index 5523110d8d..d0737fb162 100644 --- a/pkg/views/workspace/selection/repository.go +++ b/pkg/views/workspace/selection/repository.go @@ -19,7 +19,12 @@ func selectRepositoryPrompt(repositories []apiclient.GitRepository, projectOrder // Populate items with titles and descriptions from workspaces. for _, repository := range repositories { - newItem := item[string]{id: *repository.Url, title: *repository.Name, choiceProperty: *repository.Url, desc: *repository.Url} + newItem := item[string]{ + id: repository.Url, + title: repository.Name, + choiceProperty: repository.Url, + desc: repository.Url, + } items = append(items, newItem) } @@ -57,7 +62,7 @@ func GetRepositoryFromPrompt(repositories []apiclient.GitRepository, projectOrde choice := <-choiceChan for _, repository := range repositories { - if *repository.Url == choice { + if repository.Url == choice { return &repository } } diff --git a/pkg/views/workspace/selection/workspace.go b/pkg/views/workspace/selection/workspace.go index 7a14a10292..da03a6c8a2 100644 --- a/pkg/views/workspace/selection/workspace.go +++ b/pkg/views/workspace/selection/workspace.go @@ -30,36 +30,34 @@ func generateWorkspaceList(workspaces []apiclient.WorkspaceDTO) []list.Item { } if len(workspace.Projects) == 1 { - if workspace.Projects[0].Repository != nil && workspace.Projects[0].Repository.Url != nil { - projectsInfo = append(projectsInfo, util.GetRepositorySlugFromUrl(*workspace.Projects[0].Repository.Url, true)) - } + projectsInfo = append(projectsInfo, util.GetRepositorySlugFromUrl(workspace.Projects[0].Repository.Url, true)) } else { for _, project := range workspace.Projects { - projectsInfo = append(projectsInfo, *project.Name) + projectsInfo = append(projectsInfo, project.Name) } } // Get the time if available uptime := "" createdTime := "" - if workspace.Info != nil && workspace.Info.Projects != nil && len(workspace.Info.Projects) > 0 && workspace.Info.Projects[0].Created != nil { - createdTime = util.FormatCreatedTime(*workspace.Info.Projects[0].Created) + if workspace.Info != nil && workspace.Info.Projects != nil && len(workspace.Info.Projects) > 0 { + createdTime = util.FormatCreatedTime(workspace.Info.Projects[0].Created) } - if len(workspace.Projects) > 0 && workspace.Projects[0].State != nil && workspace.Projects[0].State.Uptime != nil { - if *workspace.Projects[0].State.Uptime == 0 { + if len(workspace.Projects) > 0 && workspace.Projects[0].State != nil { + if workspace.Projects[0].State.Uptime == 0 { uptime = "STOPPED" } else { - uptime = fmt.Sprintf("up %s", util.FormatUptime(*workspace.Projects[0].State.Uptime)) + uptime = fmt.Sprintf("up %s", util.FormatUptime(workspace.Projects[0].State.Uptime)) } } newItem := item[apiclient.WorkspaceDTO]{ - title: *workspace.Name, - id: *workspace.Id, + title: workspace.Name, + id: workspace.Id, desc: strings.Join(projectsInfo, ", "), createdTime: createdTime, uptime: uptime, - target: *workspace.Target, + target: workspace.Target, choiceProperty: workspace, } diff --git a/pkg/workspace/project/buildconfig/buildconfig.go b/pkg/workspace/project/buildconfig/buildconfig.go index f72d841967..3e9de7d31a 100644 --- a/pkg/workspace/project/buildconfig/buildconfig.go +++ b/pkg/workspace/project/buildconfig/buildconfig.go @@ -4,7 +4,7 @@ package buildconfig type DevcontainerConfig struct { - FilePath string `json:"filePath"` + FilePath string `json:"filePath" validate:"required"` } // @name DevcontainerConfig /* @@ -16,7 +16,7 @@ type DockerfileConfig struct { */ type ProjectBuildConfig struct { - Devcontainer *DevcontainerConfig `json:"devcontainer"` + Devcontainer *DevcontainerConfig `json:"devcontainer,omitempty" validate:"optional"` /* Dockerfile *ProjectBuildDockerfile `json:"dockerfile"` */ diff --git a/pkg/workspace/project/config/config.go b/pkg/workspace/project/config/config.go index 6489caa6a8..8343ee6e76 100644 --- a/pkg/workspace/project/config/config.go +++ b/pkg/workspace/project/config/config.go @@ -9,11 +9,11 @@ import ( ) type ProjectConfig struct { - Name string `json:"name"` - Image string `json:"image"` - User string `json:"user"` - BuildConfig *buildconfig.ProjectBuildConfig `json:"buildConfig"` - Repository *gitprovider.GitRepository `json:"repository"` - EnvVars map[string]string `json:"envVars"` - IsDefault bool `json:"default"` + Name string `json:"name" validate:"required"` + Image string `json:"image" validate:"required"` + User string `json:"user" validate:"required"` + BuildConfig *buildconfig.ProjectBuildConfig `json:"buildConfig,omitempty" validate:"optional"` + Repository *gitprovider.GitRepository `json:"repository" validate:"required"` + EnvVars map[string]string `json:"envVars" validate:"required"` + IsDefault bool `json:"default" validate:"required"` } // @name ProjectConfig diff --git a/pkg/workspace/project/project.go b/pkg/workspace/project/project.go index f2b6f767e2..ec58575546 100644 --- a/pkg/workspace/project/project.go +++ b/pkg/workspace/project/project.go @@ -16,36 +16,36 @@ import ( type Project struct { config.ProjectConfig - WorkspaceId string `json:"workspaceId"` + WorkspaceId string `json:"workspaceId" validate:"required"` ApiKey string `json:"-"` - Target string `json:"target"` - State *ProjectState `json:"state,omitempty"` + Target string `json:"target" validate:"required"` + State *ProjectState `json:"state,omitempty" validate:"optional"` } // @name Project type ProjectInfo struct { - Name string `json:"name"` - Created string `json:"created"` - IsRunning bool `json:"isRunning"` - ProviderMetadata string `json:"providerMetadata,omitempty"` - WorkspaceId string `json:"workspaceId"` + Name string `json:"name" validate:"required"` + Created string `json:"created" validate:"required"` + IsRunning bool `json:"isRunning" validate:"required"` + ProviderMetadata string `json:"providerMetadata,omitempty" validate:"optional"` + WorkspaceId string `json:"workspaceId" validate:"required"` } // @name ProjectInfo type ProjectState struct { - UpdatedAt string `json:"updatedAt"` - Uptime uint64 `json:"uptime"` - GitStatus *GitStatus `json:"gitStatus"` + UpdatedAt string `json:"updatedAt" validate:"required"` + Uptime uint64 `json:"uptime" validate:"required"` + GitStatus *GitStatus `json:"gitStatus" validate:"required"` } // @name ProjectState type GitStatus struct { - CurrentBranch string `json:"currentBranch"` - Files []*FileStatus `json:"fileStatus"` + CurrentBranch string `json:"currentBranch" validate:"required"` + Files []*FileStatus `json:"fileStatus" validate:"required"` } // @name GitStatus type FileStatus struct { - Name string `json:"name"` - Extra string `json:"extra"` - Staging Status `json:"staging"` - Worktree Status `json:"worktree"` + Name string `json:"name" validate:"required"` + Extra string `json:"extra" validate:"required"` + Staging Status `json:"staging" validate:"required"` + Worktree Status `json:"worktree" validate:"required"` } // @name FileStatus // Status status code of a file in the Worktree diff --git a/pkg/workspace/workspace.go b/pkg/workspace/workspace.go index 7eb404b414..44cbe6d0d5 100644 --- a/pkg/workspace/workspace.go +++ b/pkg/workspace/workspace.go @@ -11,18 +11,18 @@ import ( ) type Workspace struct { - Id string `json:"id"` - Name string `json:"name"` - Projects []*project.Project `json:"projects"` - Target string `json:"target"` + Id string `json:"id" validate:"required"` + Name string `json:"name" validate:"required"` + Projects []*project.Project `json:"projects" validate:"required"` + Target string `json:"target" validate:"required"` ApiKey string `json:"-"` EnvVars map[string]string `json:"-"` } // @name Workspace type WorkspaceInfo struct { - Name string `json:"name"` - Projects []*project.ProjectInfo `json:"projects"` - ProviderMetadata string `json:"providerMetadata,omitempty"` + Name string `json:"name" validate:"required"` + Projects []*project.ProjectInfo `json:"projects" validate:"required"` + ProviderMetadata string `json:"providerMetadata,omitempty" validate:"optional"` } // @name WorkspaceInfo func (w *Workspace) GetProject(projectName string) (*project.Project, error) {