Skip to content

Commit

Permalink
Tidy up Beetle APIs
Browse files Browse the repository at this point in the history
* Expose the concept of namespace (ns) and multi-cloud infrastructure (mci)
* Update handlers and functions for Beetle APIs
* Add externalDocs to show Tumblebug API docs
  • Loading branch information
yunkon-kim committed Aug 22, 2024
1 parent e85492c commit ec0dc0a
Show file tree
Hide file tree
Showing 12 changed files with 284 additions and 315 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ ENV BEETLE_TUMBLEBUG_REST_URL=http://localhost:1323/tumblebug
# Set log file path (default logfile path: ./beetle.log)
# Set log level, such as trace, debug info, warn, error, fatal, and panic
ENV BEETLE_LOGFILE_PATH=/app/log/beetle.log \
BEETLE_LOGFILE_MAXSIZE=10 \
BEETLE_LOGFILE_MAXSIZE=1000 \
BEETLE_LOGFILE_MAXBACKUPS=3 \
BEETLE_LOGFILE_MAXAGE=30 \
BEETLE_LOGFILE_COMPRESS=false \
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ compose-up: ## Up services by docker compose
@echo "Starting services by docker compose..."
@cd deployments/docker-compose && docker compose up

compose-build-up: ## Build and up services by docker compose
compose-build-up: swag ## Build and up services by docker compose
@echo "Building and starting services by docker compose..."
@cd deployments/docker-compose && DOCKER_BUILDKIT=1 docker compose up --build

Expand Down
76 changes: 53 additions & 23 deletions api/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ const docTemplate = `{
}
}
},
"/migration/infra": {
"/migration/ns/{nsId}/mci": {
"post": {
"description": "It migrates an infrastructure on a cloud platform.",
"description": "Migrate an infrastructure to the multi-cloud infrastructure (MCI)",
"consumes": [
"application/json"
],
Expand All @@ -70,11 +70,19 @@ const docTemplate = `{
"tags": [
"[Migration] Infrastructure"
],
"summary": "Migrate an infrastructure on a cloud platform",
"summary": "Migrate an infrastructure to the multi-cloud infrastructure (MCI)",
"parameters": [
{
"description": "Specify network, disk, compute, security group, virtual machine, etc.",
"name": "InfrastructureInfo",
"type": "string",
"default": "mig01",
"description": "Namespace ID",
"name": "nsId",
"in": "path",
"required": true
},
{
"description": "Specify the information for the targeted mulci-cloud infrastructure (MCI)",
"name": "mciInfo",
"in": "body",
"required": true,
"schema": {
Expand All @@ -84,7 +92,7 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "Successfully migrated infrastructure on a cloud platform",
"description": "Successfully migrated to the multi-cloud infrastructure",
"schema": {
"$ref": "#/definitions/controller.MigrateInfraResponse"
}
Expand All @@ -104,9 +112,9 @@ const docTemplate = `{
}
}
},
"/migration/infra/{infraId}": {
"/migration/ns/{nsId}/mci/{mciId}": {
"get": {
"description": "It gets the migrated infrastructure on a cloud platform.",
"description": "Get the migrated multi-cloud infrastructure (MCI)",
"consumes": [
"application/json"
],
Expand All @@ -116,19 +124,28 @@ const docTemplate = `{
"tags": [
"[Migration] Infrastructure"
],
"summary": "Get the migrated infrastructure on a cloud platform",
"summary": "Get the migrated multi-cloud infrastructure (MCI)",
"parameters": [
{
"type": "string",
"description": "a infrastructure ID created for migration",
"name": "infraId",
"default": "mig01",
"description": "Namespace ID",
"name": "nsId",
"in": "path",
"required": true
},
{
"type": "string",
"default": "mmci01",
"description": "Migrated Multi-Cloud Infrastructure (MCI) ID",
"name": "mciId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Successfully got the migrated infrastructure on a cloud platform",
"description": "The migrated multi-cloud infrastructure (MCI) information",
"schema": {
"$ref": "#/definitions/controller.MigrateInfraResponse"
}
Expand All @@ -148,7 +165,7 @@ const docTemplate = `{
}
},
"delete": {
"description": "It deletes the migrated infrastructure on a cloud platform.",
"description": "Delete the migrated mult-cloud infrastructure (MCI)",
"consumes": [
"application/json"
],
Expand All @@ -158,19 +175,28 @@ const docTemplate = `{
"tags": [
"[Migration] Infrastructure"
],
"summary": "Delete the migrated infrastructure on a cloud platform",
"summary": "Delete the migrated mult-cloud infrastructure (MCI)",
"parameters": [
{
"type": "string",
"description": "a infrastructure ID created for migration",
"name": "infraId",
"default": "mig01",
"description": "Namespace ID",
"name": "nsId",
"in": "path",
"required": true
},
{
"type": "string",
"default": "mmci01",
"description": "Migrated Multi-Cloud Infrastructure (MCI) ID",
"name": "mciId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Successfully deleted the migrated infrastructure on a cloud platform",
"description": "The result of deleting the migrated multi-cloud infrastructure (MCI)",
"schema": {
"$ref": "#/definitions/model.Response"
}
Expand Down Expand Up @@ -219,9 +245,9 @@ const docTemplate = `{
}
}
},
"/recommendation/infra": {
"/recommendation/mci": {
"post": {
"description": "It recommends a cloud infrastructure most similar to the input. Infrastructure includes network, storage, compute, and so on.",
"description": "Recommend an appropriate multi-cloud infrastructure (MCI) for cloud migration",
"consumes": [
"application/json"
],
Expand All @@ -231,11 +257,11 @@ const docTemplate = `{
"tags": [
"[Recommendation] Infrastructure"
],
"summary": "Recommend an appropriate infrastructure for cloud migration",
"summary": "Recommend an appropriate multi-cloud infrastructure (MCI) for cloud migration",
"parameters": [
{
"description": "Specify network, disk, compute, security group, virtual machine, etc.",
"name": "UserInfrastructure",
"description": "Specify the your infrastructure to be migrated",
"name": "UserInfra",
"in": "body",
"required": true,
"schema": {
Expand All @@ -245,7 +271,7 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": "Successfully recommended an appropriate infrastructure for cloud migration",
"description": "The result of recommended infrastructure",
"schema": {
"$ref": "#/definitions/controller.RecommendInfraResponse"
}
Expand Down Expand Up @@ -1470,6 +1496,10 @@ const docTemplate = `{
"BasicAuth": {
"type": "basic"
}
},
"externalDocs": {
"description": "▶▶▶ CB-Tumblebug REST API",
"url": "http://localhost:8056/tumblebug/api/index.html"
}
}`

Expand Down
76 changes: 53 additions & 23 deletions api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
}
}
},
"/migration/infra": {
"/migration/ns/{nsId}/mci": {
"post": {
"description": "It migrates an infrastructure on a cloud platform.",
"description": "Migrate an infrastructure to the multi-cloud infrastructure (MCI)",
"consumes": [
"application/json"
],
Expand All @@ -63,11 +63,19 @@
"tags": [
"[Migration] Infrastructure"
],
"summary": "Migrate an infrastructure on a cloud platform",
"summary": "Migrate an infrastructure to the multi-cloud infrastructure (MCI)",
"parameters": [
{
"description": "Specify network, disk, compute, security group, virtual machine, etc.",
"name": "InfrastructureInfo",
"type": "string",
"default": "mig01",
"description": "Namespace ID",
"name": "nsId",
"in": "path",
"required": true
},
{
"description": "Specify the information for the targeted mulci-cloud infrastructure (MCI)",
"name": "mciInfo",
"in": "body",
"required": true,
"schema": {
Expand All @@ -77,7 +85,7 @@
],
"responses": {
"200": {
"description": "Successfully migrated infrastructure on a cloud platform",
"description": "Successfully migrated to the multi-cloud infrastructure",
"schema": {
"$ref": "#/definitions/controller.MigrateInfraResponse"
}
Expand All @@ -97,9 +105,9 @@
}
}
},
"/migration/infra/{infraId}": {
"/migration/ns/{nsId}/mci/{mciId}": {
"get": {
"description": "It gets the migrated infrastructure on a cloud platform.",
"description": "Get the migrated multi-cloud infrastructure (MCI)",
"consumes": [
"application/json"
],
Expand All @@ -109,19 +117,28 @@
"tags": [
"[Migration] Infrastructure"
],
"summary": "Get the migrated infrastructure on a cloud platform",
"summary": "Get the migrated multi-cloud infrastructure (MCI)",
"parameters": [
{
"type": "string",
"description": "a infrastructure ID created for migration",
"name": "infraId",
"default": "mig01",
"description": "Namespace ID",
"name": "nsId",
"in": "path",
"required": true
},
{
"type": "string",
"default": "mmci01",
"description": "Migrated Multi-Cloud Infrastructure (MCI) ID",
"name": "mciId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Successfully got the migrated infrastructure on a cloud platform",
"description": "The migrated multi-cloud infrastructure (MCI) information",
"schema": {
"$ref": "#/definitions/controller.MigrateInfraResponse"
}
Expand All @@ -141,7 +158,7 @@
}
},
"delete": {
"description": "It deletes the migrated infrastructure on a cloud platform.",
"description": "Delete the migrated mult-cloud infrastructure (MCI)",
"consumes": [
"application/json"
],
Expand All @@ -151,19 +168,28 @@
"tags": [
"[Migration] Infrastructure"
],
"summary": "Delete the migrated infrastructure on a cloud platform",
"summary": "Delete the migrated mult-cloud infrastructure (MCI)",
"parameters": [
{
"type": "string",
"description": "a infrastructure ID created for migration",
"name": "infraId",
"default": "mig01",
"description": "Namespace ID",
"name": "nsId",
"in": "path",
"required": true
},
{
"type": "string",
"default": "mmci01",
"description": "Migrated Multi-Cloud Infrastructure (MCI) ID",
"name": "mciId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "Successfully deleted the migrated infrastructure on a cloud platform",
"description": "The result of deleting the migrated multi-cloud infrastructure (MCI)",
"schema": {
"$ref": "#/definitions/model.Response"
}
Expand Down Expand Up @@ -212,9 +238,9 @@
}
}
},
"/recommendation/infra": {
"/recommendation/mci": {
"post": {
"description": "It recommends a cloud infrastructure most similar to the input. Infrastructure includes network, storage, compute, and so on.",
"description": "Recommend an appropriate multi-cloud infrastructure (MCI) for cloud migration",
"consumes": [
"application/json"
],
Expand All @@ -224,11 +250,11 @@
"tags": [
"[Recommendation] Infrastructure"
],
"summary": "Recommend an appropriate infrastructure for cloud migration",
"summary": "Recommend an appropriate multi-cloud infrastructure (MCI) for cloud migration",
"parameters": [
{
"description": "Specify network, disk, compute, security group, virtual machine, etc.",
"name": "UserInfrastructure",
"description": "Specify the your infrastructure to be migrated",
"name": "UserInfra",
"in": "body",
"required": true,
"schema": {
Expand All @@ -238,7 +264,7 @@
],
"responses": {
"200": {
"description": "Successfully recommended an appropriate infrastructure for cloud migration",
"description": "The result of recommended infrastructure",
"schema": {
"$ref": "#/definitions/controller.RecommendInfraResponse"
}
Expand Down Expand Up @@ -1463,5 +1489,9 @@
"BasicAuth": {
"type": "basic"
}
},
"externalDocs": {
"description": "▶▶▶ CB-Tumblebug REST API",
"url": "http://localhost:8056/tumblebug/api/index.html"
}
}
Loading

0 comments on commit ec0dc0a

Please sign in to comment.