diff --git a/internal/api/openapi/repo.go b/internal/api/openapi/repo.go index 8fb613eb9..32b2159e5 100644 --- a/internal/api/openapi/repo.go +++ b/internal/api/openapi/repo.go @@ -384,6 +384,18 @@ func repoOperations(reflector *openapi3.Reflector) { _ = reflector.SetJSONResponse(&createRepository, new(usererror.Error), http.StatusForbidden) _ = reflector.Spec.AddOperation(http.MethodPost, "/repos", createRepository) + importRepository := openapi3.Operation{} + importRepository.WithTags("repository") + importRepository.WithMapOfAnything(map[string]interface{}{"operationId": "importRepository"}) + importRepository.WithParameters(queryParameterSpacePath) + _ = reflector.SetRequest(&importRepository, &struct{ repo.ImportInput }{}, http.MethodPost) + _ = reflector.SetJSONResponse(&importRepository, new(types.Repository), http.StatusCreated) + _ = reflector.SetJSONResponse(&importRepository, new(usererror.Error), http.StatusBadRequest) + _ = reflector.SetJSONResponse(&importRepository, new(usererror.Error), http.StatusInternalServerError) + _ = reflector.SetJSONResponse(&importRepository, new(usererror.Error), http.StatusUnauthorized) + _ = reflector.SetJSONResponse(&importRepository, new(usererror.Error), http.StatusForbidden) + _ = reflector.Spec.AddOperation(http.MethodPost, "/repos/import", importRepository) + opFind := openapi3.Operation{} opFind.WithTags("repository") opFind.WithMapOfAnything(map[string]interface{}{"operationId": "findRepository"}) diff --git a/internal/api/openapi/space.go b/internal/api/openapi/space.go index 1a2117938..b77841508 100644 --- a/internal/api/openapi/space.go +++ b/internal/api/openapi/space.go @@ -158,6 +158,17 @@ func spaceOperations(reflector *openapi3.Reflector) { _ = reflector.SetJSONResponse(&opCreate, new(usererror.Error), http.StatusForbidden) _ = reflector.Spec.AddOperation(http.MethodPost, "/spaces", opCreate) + opImport := openapi3.Operation{} + opImport.WithTags("space") + opImport.WithMapOfAnything(map[string]interface{}{"operationId": "importSpace"}) + _ = reflector.SetRequest(&opImport, &struct{ space.ImportInput }{}, http.MethodPost) + _ = reflector.SetJSONResponse(&opImport, new(types.Space), http.StatusCreated) + _ = reflector.SetJSONResponse(&opImport, new(usererror.Error), http.StatusBadRequest) + _ = reflector.SetJSONResponse(&opImport, new(usererror.Error), http.StatusInternalServerError) + _ = reflector.SetJSONResponse(&opImport, new(usererror.Error), http.StatusUnauthorized) + _ = reflector.SetJSONResponse(&opImport, new(usererror.Error), http.StatusForbidden) + _ = reflector.Spec.AddOperation(http.MethodPost, "/spaces/import", opImport) + opGet := openapi3.Operation{} opGet.WithTags("space") opGet.WithMapOfAnything(map[string]interface{}{"operationId": "getSpace"}) diff --git a/internal/services/importer/provider.go b/internal/services/importer/provider.go index 0665e1be2..0e759675a 100644 --- a/internal/services/importer/provider.go +++ b/internal/services/importer/provider.go @@ -29,14 +29,7 @@ const ( ProviderTypeGitLabEnterprise ProviderType = "gitlab-enterprise" ) -type Provider struct { - Type ProviderType `json:"type"` - Host string `json:"host"` - Username string `json:"username"` - Password string `json:"password"` -} - -func (p Provider) Enum() []any { +func (p ProviderType) Enum() []any { return []any{ ProviderTypeGitHub, ProviderTypeGitHubEnterprise, @@ -45,6 +38,13 @@ func (p Provider) Enum() []any { } } +type Provider struct { + Type ProviderType `json:"type"` + Host string `json:"host"` + Username string `json:"username"` + Password string `json:"password"` +} + type RepositoryInfo struct { Space string UID string