"...include/git@developer.sourcefind.cn:yangql/googletest.git" did not exist on "7a0680dc223088211807f1b19598dfe01b3bab8b"
Commit 5ddc7f7d authored by Maksim Khadkevich's avatar Maksim Khadkevich Committed by GitHub
Browse files

feat: moved compoundAI operator, APIserver, and examples (#10)

parent 14ce7e03
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package models
import (
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
type IBaseModel interface {
GetId() uint
GetUid() string
GetCreatedAt() time.Time
GetUpdatedAt() time.Time
GetDeletedAt() gorm.DeletedAt
}
type BaseModel struct {
gorm.Model
Uid uuid.UUID `json:"uid" gorm:"type:uuid;default:gen_random_uuid()"`
}
func (b *BaseModel) GetId() uint {
return b.ID
}
func (b *BaseModel) GetUid() string {
return b.Uid.String()
}
func (b *BaseModel) GetCreatedAt() time.Time {
return b.CreatedAt
}
func (b *BaseModel) GetUpdatedAt() time.Time {
return b.UpdatedAt
}
func (b *BaseModel) GetDeletedAt() gorm.DeletedAt {
return b.DeletedAt
}
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package models
type Cluster struct {
Resource
CreatorAssociate
OrganizationAssociate
Description string `json:"description"`
KubeConfig string `json:"kube_config"`
}
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package models
import (
"time"
"github.com/dynemo-ai/dynemo/deploy/compoundai/api-server/api/schemas"
)
type CompoundComponent struct {
Resource
ClusterAssociate
Version string `json:"version"`
KubeNamespace string `json:"kube_namespace"`
Description string `json:"description"`
Manifest *schemas.CompoundComponentManifestSchema `json:"manifest" type:"jsonb"`
LatestInstalledAt *time.Time `json:"latest_installed_at"`
LatestHeartbeatAt *time.Time `json:"latest_heartbeat_at"`
}
func (d *CompoundComponent) GetResourceType() schemas.ResourceType {
return schemas.ResourceTypeCompoundAIComponent
}
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package models
import (
"time"
"github.com/dynemo-ai/dynemo/deploy/compoundai/api-server/api/schemas"
)
type Deployment struct {
Resource
ClusterAssociate
CreatorAssociate
VisibilityLevel
Description string `json:"description"`
Status schemas.DeploymentStatus `json:"status"`
StatusSyncingAt *time.Time `json:"status_syncing_at"`
StatusUpdatedAt *time.Time `json:"status_updated_at"`
KubeDeployToken string `json:"kube_deploy_token"`
KubeNamespace string `json:"kube_namespace"`
}
func (d *Deployment) GetResourceType() schemas.ResourceType {
return schemas.ResourceTypeDeployment
}
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package models
type DeployOption struct {
Force bool
}
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package models
import (
"github.com/dynemo-ai/dynemo/deploy/compoundai/api-server/api/schemas"
)
type DeploymentRevision struct {
BaseModel
CreatorAssociate
DeploymentAssociate
Status schemas.DeploymentRevisionStatus `json:"status"`
}
func (s *DeploymentRevision) GetName() string {
return s.Uid.String()
}
func (s *DeploymentRevision) GetResourceType() schemas.ResourceType {
return schemas.ResourceTypeDeploymentRevision
}
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package models
import "github.com/dynemo-ai/dynemo/deploy/compoundai/api-server/api/schemas"
type DeploymentTarget struct {
BaseModel
CreatorAssociate
DeploymentAssociate
DeploymentRevisionAssociate
CompoundNimVersionAssociate
DmsAssociate
Config *schemas.DeploymentTargetConfig `json:"config"`
}
func (s *DeploymentTarget) GetName() string {
return s.Uid.String()
}
func (s *DeploymentTarget) GetResourceType() schemas.ResourceType {
return schemas.ResourceTypeDeploymentRevision
}
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package models
type Resource struct {
BaseModel
Name string `json:"name"`
}
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package models
type VisibilityLevel string
const (
UserLevel VisibilityLevel = "user"
OrgLevel VisibilityLevel = "organization"
)
type Visibility struct {
Visibility VisibilityLevel `json:"visibility"`
}
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package routes
import (
"strings"
"github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
"github.com/dynemo-ai/dynemo/deploy/compoundai/api-server/api/common/consts"
"github.com/dynemo-ai/dynemo/deploy/compoundai/api-server/api/controllers"
"github.com/dynemo-ai/dynemo/deploy/compoundai/api-server/api/mocks"
"github.com/dynemo-ai/dynemo/deploy/compoundai/api-server/api/schemas"
)
func SetupRouter() *gin.Engine {
router := gin.Default()
router.Use(injectCurrentOrganization)
baseGroup := router.Group("")
createK8sRoutes(baseGroup)
api := router.Group("/api")
api.Use(getAuthInfo)
v1 := api.Group("/v1")
v2 := api.Group("/v2")
/* Start V1 APIs */
createClusterRoutes(v1)
// These routes are proxied to NDS
createCompoundNimRoutes(v1)
createBentoRepositoriesRoutes(v1)
createMiscellaneousRoutes(v1)
createMockedRoutes(v1)
createOrganizationRoutes(v1)
createPublicRoutes(v1)
/* End V1 APIs */
/* Start V2 APIs */
deploymentRoutesV2(v2)
/* End V2 APIs */
return router
}
func createK8sRoutes(grp *gin.RouterGroup) {
healthGroup := grp.Group("/healthz")
healthGroup.GET("", controllers.HealthController.Get)
readyGroup := grp.Group("/readyz")
readyGroup.GET("", controllers.HealthController.Get)
}
func createClusterRoutes(grp *gin.RouterGroup) {
grp = grp.Group("/clusters")
resourceGrp := grp.Group("/:clusterName")
resourceGrp.GET("", controllers.ClusterController.Get)
resourceGrp.PATCH("", controllers.ClusterController.Update)
grp.GET("", controllers.ClusterController.List)
grp.POST("", controllers.ClusterController.Create)
compoundComponentRoutes(resourceGrp)
deploymentRoutes(resourceGrp)
}
func deploymentRoutes(grp *gin.RouterGroup) {
namespacedGrp := grp.Group("/namespaces/:kubeNamespace/deployments")
grp = grp.Group("/deployments")
resourceGrp := namespacedGrp.Group("/:deploymentName")
resourceGrp.GET("", controllers.DeploymentController.Get)
resourceGrp.PATCH("", controllers.DeploymentController.Update)
resourceGrp.POST("/sync_status", controllers.DeploymentController.SyncStatus)
resourceGrp.POST("/terminate", controllers.DeploymentController.Terminate)
resourceGrp.DELETE("", controllers.DeploymentController.Delete)
// resourceGrp.GET("/terminal_records", controllers.DeploymentController.ListTerminalRecords)
grp.GET("", controllers.DeploymentController.ListClusterDeployments)
grp.POST("", controllers.DeploymentController.Create)
deploymentRevisionRoutes(resourceGrp)
}
func deploymentRevisionRoutes(grp *gin.RouterGroup) {
grp = grp.Group("/revisions")
resourceGrp := grp.Group("/:revisionUid")
resourceGrp.GET("", controllers.DeploymentRevisionController.Get)
grp.GET("", controllers.DeploymentRevisionController.List)
}
func deploymentRoutesV2(grp *gin.RouterGroup) {
grp = grp.Group("/deployments")
grp.POST("", controllers.DeploymentController.CreateV2)
resourceGrp := grp.Group("/:deploymentName")
resourceGrp.GET("", controllers.DeploymentController.GetV2)
resourceGrp.PUT("", controllers.DeploymentController.UpdateV2)
resourceGrp.POST("/terminate", controllers.DeploymentController.TerminateV2)
resourceGrp.DELETE("", controllers.DeploymentController.DeleteV2)
}
func createBentoRepositoriesRoutes(grp *gin.RouterGroup) {
grp = grp.Group("/bento_repositories")
resourceGrp := grp.Group("/:bentoRepositoryName")
resourceGrp.GET("", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("", controllers.ProxyController.ReverseProxy)
resourceGrp.GET("/deployments", controllers.ProxyController.ReverseProxy)
grp.GET("", controllers.ProxyController.ReverseProxy)
grp.POST("", controllers.ProxyController.ReverseProxy)
bentoRoutes(resourceGrp)
}
func bentoRoutes(grp *gin.RouterGroup) {
grp = grp.Group("/bentos")
resourceGrp := grp.Group("/:version")
resourceGrp.GET("", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("/update_image_build_status_syncing_at", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("/update_image_build_status", controllers.ProxyController.ReverseProxy)
resourceGrp.GET("/models", controllers.ProxyController.ReverseProxy)
resourceGrp.GET("/deployments", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("/start_multipart_upload", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("/presign_multipart_upload_url", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("/complete_multipart_upload", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("/presign_upload_url", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("/presign_download_url", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("/start_upload", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("/finish_upload", controllers.ProxyController.ReverseProxy)
resourceGrp.PUT("/upload", controllers.ProxyController.ReverseProxy)
resourceGrp.GET("/download", controllers.ProxyController.ReverseProxy)
grp.GET("", controllers.ProxyController.ReverseProxy)
grp.POST("", controllers.ProxyController.ReverseProxy)
}
func createCompoundNimRoutes(grp *gin.RouterGroup) {
grp = grp.Group("/compound_nims")
resourceGrp := grp.Group("/:compoundNimName")
resourceGrp.GET("", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("", controllers.ProxyController.ReverseProxy)
resourceGrp.GET("/deployments", controllers.DeploymentController.ListCompoundNimDeployments)
grp.GET("", controllers.ProxyController.ReverseProxy)
grp.POST("", controllers.ProxyController.ReverseProxy)
compoundNimVersionRoutes(resourceGrp)
}
func compoundNimVersionRoutes(grp *gin.RouterGroup) {
grp = grp.Group("/versions")
resourceGrp := grp.Group("/:version")
resourceGrp.GET("", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("/update_image_build_status_syncing_at", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("/update_image_build_status", controllers.ProxyController.ReverseProxy)
resourceGrp.GET("/models", controllers.ProxyController.ReverseProxy)
resourceGrp.GET("/deployments", controllers.DeploymentController.ListCompoundNimVersionDeployments)
resourceGrp.PATCH("/start_multipart_upload", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("/presign_multipart_upload_url", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("/complete_multipart_upload", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("/presign_upload_url", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("/presign_download_url", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("/start_upload", controllers.ProxyController.ReverseProxy)
resourceGrp.PATCH("/finish_upload", controllers.ProxyController.ReverseProxy)
resourceGrp.PUT("/upload", controllers.ProxyController.ReverseProxy)
resourceGrp.GET("/download", controllers.ProxyController.ReverseProxy)
grp.GET("", controllers.ProxyController.ReverseProxy)
grp.POST("", controllers.ProxyController.ReverseProxy)
}
func createMiscellaneousRoutes(grp *gin.RouterGroup) {
versionGrp := grp.Group("/version")
versionGrp.GET("", controllers.VersionController.Get)
}
// Legacy APIs used by the CLI
func createMockedRoutes(grp *gin.RouterGroup) {
grp.GET("auth/current", controllers.UserController.GetDefaultUser)
}
func createOrganizationRoutes(grp *gin.RouterGroup) {
resourceGrp := grp.Group("/current_org")
resourceGrp.GET("", controllers.OrganizationController.Get)
resourceGrp.GET("/major_cluster", controllers.OrganizationController.GetMajorCluster)
resourceGrp.PATCH("", controllers.OrganizationController.Update)
resourceGrp.GET("/events", controllers.OrganizationController.ListEvents)
resourceGrp.GET("/event_operation_names", controllers.OrganizationController.ListEventOperationNames)
grp.GET("/members", controllers.OrganizationMemberController.List)
grp.POST("/members", controllers.OrganizationMemberController.Create)
grp.DELETE("/members", controllers.OrganizationMemberController.Delete)
grp.GET("/deployments", controllers.DeploymentController.ListDeployments)
grp.GET("/deployment_creation_json_schema", controllers.DeploymentController.CreationJSONSchema)
grp.GET("/yatai_components", controllers.CompoundComponentController.ListAll)
grp.GET("/orgs", controllers.OrganizationController.List)
grp.POST("/orgs", controllers.OrganizationController.Create)
}
func createPublicRoutes(grp *gin.RouterGroup) {
grp.GET("/info", controllers.InfoController.GetInfo)
}
func compoundComponentRoutes(grp *gin.RouterGroup) {
grp = grp.Group("/yatai_components")
grp.GET("", controllers.CompoundComponentController.List)
grp.POST("", controllers.CompoundComponentController.Register)
}
func injectCurrentOrganization(c *gin.Context) {
orgName := strings.TrimSpace(c.GetHeader(consts.YataiOrganizationHeaderName))
if orgName == "" {
orgName = strings.TrimSpace(c.Query("organization_name"))
}
org := mocks.DefaultOrg()
if orgName != "" {
org.Name = orgName
}
orgId := c.GetHeader(consts.NgcOrganizationHeaderName)
if orgId == "" {
orgId = "default"
}
org.Uid = orgId
c.Set(controllers.CurrentOrganizationKey, org)
c.Next()
}
func getAuthInfo(c *gin.Context) {
orgId := c.GetHeader(consts.NgcOrganizationHeaderName)
if orgId == "" {
orgId = "default"
}
userId := c.GetHeader(consts.NgcUserHeaderName)
if userId == "" {
userId = "default"
}
ownership := &schemas.OwnershipSchema{
UserId: userId,
OrganizationId: orgId,
}
log.Info().Msgf("Setting ownership info %+v", ownership)
c.Set(controllers.OwnershipInfoKey, ownership)
c.Next()
}
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package runtime
import (
"fmt"
"github.com/dynemo-ai/dynemo/deploy/compoundai/api-server/api/common/env"
"github.com/dynemo-ai/dynemo/deploy/compoundai/api-server/api/database"
"github.com/dynemo-ai/dynemo/deploy/compoundai/api-server/api/routes"
"github.com/rs/zerolog/log"
)
type runtime struct{}
var Runtime = runtime{}
func (r *runtime) StartServer(port int) {
env.SetupEnv()
database.SetupDB()
router := routes.SetupRouter()
log.Info().Msgf("Starting CompoundAI API server on port %d", port)
router.Run(fmt.Sprintf("0.0.0.0:%d", port))
}
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package schemas
import "time"
type BaseSchema struct {
Uid string `json:"uid"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt *time.Time `json:"deleted_at"`
}
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package schemas
type ClusterSchema struct {
ResourceSchema
Creator *UserSchema `json:"creator"`
Description string `json:"description"`
}
type ClusterListSchema struct {
BaseListSchema
Items []*ClusterSchema `json:"items"`
}
type ClusterFullSchema struct {
ClusterSchema
Organization *OrganizationSchema `json:"organization"`
KubeConfig *string `json:"kube_config"`
}
type UpdateClusterSchema struct {
Description *string `json:"description"`
KubeConfig *string `json:"kube_config"`
}
type CreateClusterSchema struct {
Description string `json:"description"`
KubeConfig string `json:"kube_config"`
Name string `json:"name"`
}
type GetClusterSchema struct {
ClusterName string `uri:"clusterName" binding:"required"`
}
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package schemas
type CompoundNimApiSchema struct {
Route string `json:"route"`
Doc string `json:"doc"`
Input string `json:"input"`
Output string `json:"output"`
}
type CompoundNimManifestSchema struct {
Service string `json:"service"`
CompoundAiVersion string `json:"bentoml_version"`
Apis map[string]CompoundNimApiSchema `json:"apis"`
SizeBytes uint `json:"size_bytes"`
}
type TransmissionStrategy string
const (
TransmissionStrategyPresignedURL TransmissionStrategy = "presigned_url"
TransmissionStrategyProxy TransmissionStrategy = "proxy"
)
type CompoundNimVersionUploadStatus string
const (
CompoundNimVersionUploadStatusPending CompoundNimVersionUploadStatus = "pending"
CompoundNimVersionUploadStatusUploading CompoundNimVersionUploadStatus = "uploading"
CompoundNimVersionUploadStatusSuccess CompoundNimVersionUploadStatus = "success"
CompoundNimVersionUploadStatusFailed CompoundNimVersionUploadStatus = "failed"
)
type ImageBuildStatus string
const (
ImageBuildStatusPending ImageBuildStatus = "pending"
ImageBuildStatusBuilding ImageBuildStatus = "building"
ImageBuildStatusSuccess ImageBuildStatus = "success"
ImageBuildStatusFailed ImageBuildStatus = "failed"
)
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package schemas
import (
"database/sql/driver"
"encoding/json"
"time"
)
type CompoundComponentName string
const (
CompoundComponentNameDeployment CompoundComponentName = "deployment"
CompoundComponentNameImageBuilder CompoundComponentName = "image-builder"
CompoundComponentNameFunction CompoundComponentName = "function"
CompoundComponentNameJob CompoundComponentName = "job"
)
type CompoundComponentManifestSchema struct {
SelectorLabels map[string]string `json:"selector_labels,omitempty"`
LatestCRDVersion string `json:"latest_crd_version,omitempty"`
}
func (c *CompoundComponentManifestSchema) Scan(value interface{}) error {
if value == nil {
return nil
}
return json.Unmarshal(value.([]byte), c)
}
func (c *CompoundComponentManifestSchema) Value() (driver.Value, error) {
if c == nil {
return nil, nil
}
return json.Marshal(c)
}
type RegisterCompoundComponentSchema struct {
Name CompoundComponentName `json:"name"`
Version string `json:"version"`
KubeNamespace string `json:"kube_namespace"`
SelectorLabels map[string]string `json:"selector_labels,omitempty"`
Manifest *CompoundComponentManifestSchema `json:"manifest"`
}
type CompoundComponentSchema struct {
ResourceSchema
Creator *UserSchema `json:"creator"`
Cluster *ClusterFullSchema `json:"cluster"`
Description string `json:"description"`
Version string `json:"version"`
KubeNamespace string `json:"kube_namespace"`
Manifest *CompoundComponentManifestSchema `json:"manifest"`
LatestInstalledAt *time.Time `json:"latest_installed_at"`
LatestHeartbeatAt *time.Time `json:"latest_heartbeat_at"`
}
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package schemas
type CompoundNimSchema struct {
ResourceSchema
Creator *UserSchema `json:"creator"`
Organization *OrganizationSchema `json:"organization"`
LatestCompoundNimVersion *CompoundNimVersionSchema `json:"latest_bento"`
NCompoundNimVersions uint `json:"n_bentos"`
NDeployments uint `json:"n_deployments"`
LatestCompoundNimVersions []*CompoundNimVersionSchema `json:"latest_bentos"`
Description string `json:"description"`
}
type GetCompoundNimSchema struct {
CompoundNimName string `uri:"compoundNimName" binding:"required"`
}
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package schemas
import "time"
type CompoundNimVersionSchema struct {
ResourceSchema
CompoundNimUid string `json:"bento_repository_uid"`
Creator *UserSchema `json:"creator"`
Version string `json:"version"`
Description string `json:"description"`
ImageBuildStatus ImageBuildStatus `json:"image_build_status"`
UploadStatus CompoundNimVersionUploadStatus `json:"upload_status"`
UploadStartedAt *time.Time `json:"upload_started_at"`
UploadFinishedAt *time.Time `json:"upload_finished_at"`
UploadFinishedReason string `json:"upload_finished_reason"`
PresignedUploadUrl string `json:"presigned_upload_url"`
PresignedDownloadUrl string `json:"presigned_download_url"`
PresignedUrlsDeprecated bool `json:"presigned_urls_deprecated"`
TransmissionStrategy TransmissionStrategy `json:"transmission_strategy"`
UploadId string `json:"upload_id"`
Manifest *CompoundNimManifestSchema `json:"manifest"`
BuildAt time.Time `json:"build_at"`
}
type CompoundNimVersionFullSchema struct {
CompoundNimVersionSchema
Repository *CompoundNimSchema `json:"repository"`
}
type GetCompoundNimVersionSchema struct {
GetCompoundNimSchema
CompoundNimVersion string `uri:"version" binding:"required"`
}
func (s *GetCompoundNimVersionSchema) Tag() *string {
tag := s.CompoundNimName + ":" + s.CompoundNimVersion
return &tag
}
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package schemas
type DeploymentSchema struct {
ResourceSchema
Creator *UserSchema `json:"creator"`
Cluster *ClusterFullSchema `json:"cluster"`
Status DeploymentStatus `json:"status" enum:"unknown,non-deployed,running,unhealthy,failed,deploying"`
URLs []string `json:"urls"`
LatestRevision *DeploymentRevisionSchema `json:"latest_revision"`
KubeNamespace string `json:"kube_namespace"`
}
type DeploymentListSchema struct {
BaseListSchema
Items []*DeploymentSchema `json:"items"`
}
type UpdateDeploymentSchema struct {
Targets []*CreateDeploymentTargetSchema `json:"targets"`
Description *string `json:"description,omitempty"`
DoNotDeploy bool `json:"do_not_deploy,omitempty"`
}
type CreateDeploymentSchema struct {
Name string `json:"name"`
KubeNamespace string `json:"kube_namespace"`
UpdateDeploymentSchema
}
type GetDeploymentSchema struct {
GetClusterSchema
DeploymentName string `uri:"deploymentName" binding:"required"`
KubeNamespace string `uri:"kubeNamespace" binding:"required"`
}
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package schemas
type DeploymentRevisionSchema struct {
ResourceSchema
Creator *UserSchema `json:"creator"`
Status DeploymentRevisionStatus `json:"status" enum:"active,inactive"`
Targets []*DeploymentTargetSchema `json:"targets"`
}
type DeploymentRevisionListSchema struct {
BaseListSchema
Items []*DeploymentRevisionSchema `json:"items"`
}
type GetDeploymentRevisionSchema struct {
GetDeploymentSchema
RevisionUid string `uri:"revisionUid" binding:"required"`
}
/*
* SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package schemas
type DeploymentRevisionStatus string
const (
DeploymentRevisionStatusActive DeploymentRevisionStatus = "active"
DeploymentRevisionStatusInactive DeploymentRevisionStatus = "inactive"
)
func (d DeploymentRevisionStatus) Ptr() *DeploymentRevisionStatus {
return &d
}
func DeploymentRevisionStatusPtr(status DeploymentRevisionStatus) *DeploymentRevisionStatus {
return status.Ptr()
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment