diff --git a/.erda/migrations/license-agent/20230927-license-base.sql b/.erda/migrations/license-agent/20230927-license-base.sql new file mode 100644 index 00000000000..76f0987e974 --- /dev/null +++ b/.erda/migrations/license-agent/20230927-license-base.sql @@ -0,0 +1,11 @@ +CREATE TABLE erda_license +( + `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '许可证ID', + `entity_type` ENUM('PLATFORM', 'ORG') NOT NULL COMMENT '实体类型', + `entity_id` BIGINT NOT NULL DEFAULT 0 COMMENT '实体ID', + `enc_license` TEXT COMMENT '加密许可证信息', + `created_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', + `updated_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', + PRIMARY KEY (`id`), + UNIQUE KEY entity_entity_id (entity_type, entity_id) +) COMMENT '许可证信息表'; diff --git a/apistructs/license_agent.go b/apistructs/license_agent.go new file mode 100644 index 00000000000..55883dd604e --- /dev/null +++ b/apistructs/license_agent.go @@ -0,0 +1,10 @@ +package apistructs + +type RegisterLicenseRequest struct { + Scope int64 `json:"scope"` + License string `json:"license"` +} + +type RegisterLicenseResponse struct { + Id int64 `json:"id"` +} diff --git a/internal/core/openapi/legacy/api/apis/license_agent/agent_license_feature_get.go b/internal/core/openapi/legacy/api/apis/license_agent/agent_license_feature_get.go new file mode 100644 index 00000000000..9229ef2e1cc --- /dev/null +++ b/internal/core/openapi/legacy/api/apis/license_agent/agent_license_feature_get.go @@ -0,0 +1,32 @@ +// Copyright (c) 2021 Terminus, Inc. +// +// 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 license_agent + +import ( + "net/http" + + "github.com/erda-project/erda/internal/core/openapi/legacy/api/apis" +) + +var AGENT_LICENSE_FEATURE_GET = apis.ApiSpec{ + Path: "/api/licenses/features", + BackendPath: "/api/licenses/features", + Host: "license-agent.marathon.l4lb.thisdcos.directory:8080", + Scheme: "http", + Method: http.MethodGet, + IsOpenAPI: true, + CheckLogin: true, + CheckToken: true, +} diff --git a/internal/core/openapi/legacy/api/apis/license_agent/agent_license_get.go b/internal/core/openapi/legacy/api/apis/license_agent/agent_license_get.go new file mode 100644 index 00000000000..c4ff41495e7 --- /dev/null +++ b/internal/core/openapi/legacy/api/apis/license_agent/agent_license_get.go @@ -0,0 +1,32 @@ +// Copyright (c) 2021 Terminus, Inc. +// +// 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 license_agent + +import ( + "net/http" + + "github.com/erda-project/erda/internal/core/openapi/legacy/api/apis" +) + +var AGENT_LICENSE_GET = apis.ApiSpec{ + Path: "/api/licenses", + BackendPath: "/api/licenses", + Host: "license-agent.marathon.l4lb.thisdcos.directory:8080", + Scheme: "http", + Method: http.MethodGet, + IsOpenAPI: true, + CheckLogin: true, + CheckToken: true, +} diff --git a/internal/core/openapi/legacy/api/apis/license_agent/agent_register_license_post.go b/internal/core/openapi/legacy/api/apis/license_agent/agent_register_license_post.go new file mode 100644 index 00000000000..4a9d8eaa34b --- /dev/null +++ b/internal/core/openapi/legacy/api/apis/license_agent/agent_register_license_post.go @@ -0,0 +1,35 @@ +// Copyright (c) 2021 Terminus, Inc. +// +// 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 license_agent + +import ( + "net/http" + + "github.com/erda-project/erda/apistructs" + "github.com/erda-project/erda/internal/core/openapi/legacy/api/apis" +) + +var AGENT_REGISTER_LICENSE_POST = apis.ApiSpec{ + Path: "/api/licenses/actions/register", + BackendPath: "/api/licenses/actions/register", + Host: "license-agent.marathon.l4lb.thisdcos.directory:8080", + Scheme: "http", + Method: http.MethodPost, + IsOpenAPI: true, + CheckLogin: true, + CheckToken: true, + RequestType: apistructs.RegisterLicenseRequest{}, + ResponseType: apistructs.RegisterLicenseResponse{}, +}