CloudMigrations: Implement migrations API (#85348)

* Implement run migration endpoint

* Refactor RunMigration method into separate methods

* Save migration runs fix lint

* Minor changes

* Refactor how to use cms endpoint

* fix interface

* complete merge

* add individual items

* adds tracing to getMigration

* linter

* updated swagger definition with the latest changes

* CloudMigrations: Implement core API handlers for cloud migrations and migration runs (#85407)

* implement delete

* add auth token encryption

* implement token validation

* call token validation during migration creation

* implement get migration status

* implement list migration runs

* fix bug

* finish parse domain func

* fix urls

* fix typo

* fix encoding and decoding

* remove double decryption

* add missing slash

* fix id returned by create function

* inject missing services

* finish implementing (as far as I can tell right now) data migration and response handling

* comment out broken test, needs a rewrite

* add a few final touches

* get dashboard migration to work properly

* changed runMigration to a POST

* swagger

* swagger

* swagger

---------

Co-authored-by: Michael Mandrus <michael.mandrus@grafana.com>
Co-authored-by: Leonard Gram <leo@xlson.com>
Co-authored-by: Michael Mandrus <41969079+mmandrus@users.noreply.github.com>
This commit is contained in:
idafurjes
2024-04-03 13:36:13 +02:00
committed by GitHub
parent 89638238e5
commit b885da09da
17 changed files with 966 additions and 333 deletions

View File

@@ -2796,46 +2796,13 @@
}
}
},
"CloudMigrationRun": {
"type": "object",
"properties": {
"created": {
"type": "string",
"format": "date-time"
},
"finished": {
"type": "string",
"format": "date-time"
},
"id": {
"type": "integer",
"format": "int64"
},
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/MigratedResource"
}
},
"result": {
"$ref": "#/definitions/MigrationResult"
},
"uid": {
"type": "string"
},
"updated": {
"type": "string",
"format": "date-time"
}
}
},
"CloudMigrationRunList": {
"type": "object",
"properties": {
"runs": {
"type": "array",
"items": {
"$ref": "#/definitions/CloudMigrationRun"
"$ref": "#/definitions/MigrateDataResponseDTO"
}
}
}
@@ -4572,6 +4539,9 @@
}
}
},
"ItemStatus": {
"type": "string"
},
"JSONWebKey": {
"description": "JSONWebKey represents a public or private key in JWK format. It can be\nmarshaled into JSON and unmarshaled from JSON.",
"type": "object",
@@ -4909,45 +4879,32 @@
}
}
},
"MigratedResource": {
"MigrateDataResponseDTO": {
"type": "object",
"properties": {
"id": {
"type": "string"
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"refID": {
"type": "string"
},
"result": {
"$ref": "#/definitions/MigratedResourceResult"
},
"type": {
"type": "string"
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/MigrateDataResponseItemDTO"
}
}
}
},
"MigratedResourceResult": {
"MigrateDataResponseItemDTO": {
"type": "object",
"properties": {
"message": {
"error": {
"type": "string"
},
"refId": {
"type": "string"
},
"status": {
"type": "string"
}
}
},
"MigrationResult": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"status": {
"type": "string"
"$ref": "#/definitions/ItemStatus"
}
}
},
@@ -7941,7 +7898,7 @@
"cloudMigrationRunResponse": {
"description": "",
"schema": {
"$ref": "#/definitions/CloudMigrationRun"
"$ref": "#/definitions/MigrateDataResponseDTO"
}
},
"conflictError": {

View File

@@ -2433,6 +2433,38 @@
"$ref": "#/responses/internalServerError"
}
}
},
"post": {
"description": "It returns migrations that has been created.",
"tags": [
"migrations"
],
"summary": "Trigger the run of a migration to the Grafana Cloud.",
"operationId": "runCloudMigration",
"parameters": [
{
"type": "integer",
"format": "int64",
"description": "ID of an migration",
"name": "id",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"$ref": "#/responses/cloudMigrationRunResponse"
},
"401": {
"$ref": "#/responses/unauthorisedError"
},
"403": {
"$ref": "#/responses/forbiddenError"
},
"500": {
"$ref": "#/responses/internalServerError"
}
}
}
},
"/cloudmigration/migration/{id}/run/{runID}": {
@@ -12739,46 +12771,13 @@
}
}
},
"CloudMigrationRun": {
"type": "object",
"properties": {
"created": {
"type": "string",
"format": "date-time"
},
"finished": {
"type": "string",
"format": "date-time"
},
"id": {
"type": "integer",
"format": "int64"
},
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/MigratedResource"
}
},
"result": {
"$ref": "#/definitions/MigrationResult"
},
"uid": {
"type": "string"
},
"updated": {
"type": "string",
"format": "date-time"
}
}
},
"CloudMigrationRunList": {
"type": "object",
"properties": {
"runs": {
"type": "array",
"items": {
"$ref": "#/definitions/CloudMigrationRun"
"$ref": "#/definitions/MigrateDataResponseDTO"
}
}
}
@@ -15489,6 +15488,9 @@
}
}
},
"ItemStatus": {
"type": "string"
},
"JSONWebKey": {
"description": "JSONWebKey represents a public or private key in JWK format. It can be\nmarshaled into JSON and unmarshaled from JSON.",
"type": "object",
@@ -15924,45 +15926,32 @@
}
}
},
"MigratedResource": {
"MigrateDataResponseDTO": {
"type": "object",
"properties": {
"id": {
"type": "string"
"type": "integer",
"format": "int64"
},
"name": {
"type": "string"
},
"refID": {
"type": "string"
},
"result": {
"$ref": "#/definitions/MigratedResourceResult"
},
"type": {
"type": "string"
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/MigrateDataResponseItemDTO"
}
}
}
},
"MigratedResourceResult": {
"MigrateDataResponseItemDTO": {
"type": "object",
"properties": {
"message": {
"error": {
"type": "string"
},
"refId": {
"type": "string"
},
"status": {
"type": "string"
}
}
},
"MigrationResult": {
"type": "object",
"properties": {
"message": {
"type": "string"
},
"status": {
"type": "string"
"$ref": "#/definitions/ItemStatus"
}
}
},
@@ -21673,7 +21662,7 @@
"cloudMigrationRunResponse": {
"description": "(empty)",
"schema": {
"$ref": "#/definitions/CloudMigrationRun"
"$ref": "#/definitions/MigrateDataResponseDTO"
}
},
"conflictError": {

View File

@@ -217,7 +217,7 @@
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CloudMigrationRun"
"$ref": "#/components/schemas/MigrateDataResponseDTO"
}
}
},
@@ -3552,44 +3552,11 @@
},
"type": "object"
},
"CloudMigrationRun": {
"properties": {
"created": {
"format": "date-time",
"type": "string"
},
"finished": {
"format": "date-time",
"type": "string"
},
"id": {
"format": "int64",
"type": "integer"
},
"items": {
"items": {
"$ref": "#/components/schemas/MigratedResource"
},
"type": "array"
},
"result": {
"$ref": "#/components/schemas/MigrationResult"
},
"uid": {
"type": "string"
},
"updated": {
"format": "date-time",
"type": "string"
}
},
"type": "object"
},
"CloudMigrationRunList": {
"properties": {
"runs": {
"items": {
"$ref": "#/components/schemas/CloudMigrationRun"
"$ref": "#/components/schemas/MigrateDataResponseDTO"
},
"type": "array"
}
@@ -6302,6 +6269,9 @@
},
"type": "object"
},
"ItemStatus": {
"type": "string"
},
"JSONWebKey": {
"description": "JSONWebKey represents a public or private key in JWK format. It can be\nmarshaled into JSON and unmarshaled from JSON.",
"properties": {
@@ -6737,44 +6707,31 @@
],
"type": "object"
},
"MigratedResource": {
"MigrateDataResponseDTO": {
"properties": {
"id": {
"type": "string"
"format": "int64",
"type": "integer"
},
"name": {
"type": "string"
},
"refID": {
"type": "string"
},
"result": {
"$ref": "#/components/schemas/MigratedResourceResult"
},
"type": {
"type": "string"
"items": {
"items": {
"$ref": "#/components/schemas/MigrateDataResponseItemDTO"
},
"type": "array"
}
},
"type": "object"
},
"MigratedResourceResult": {
"MigrateDataResponseItemDTO": {
"properties": {
"message": {
"error": {
"type": "string"
},
"refId": {
"type": "string"
},
"status": {
"type": "string"
}
},
"type": "object"
},
"MigrationResult": {
"properties": {
"message": {
"type": "string"
},
"status": {
"type": "string"
"$ref": "#/components/schemas/ItemStatus"
}
},
"type": "object"
@@ -14970,6 +14927,40 @@
"tags": [
"migrations"
]
},
"post": {
"description": "It returns migrations that has been created.",
"operationId": "runCloudMigration",
"parameters": [
{
"description": "ID of an migration",
"in": "path",
"name": "id",
"required": true,
"schema": {
"format": "int64",
"type": "integer"
}
}
],
"responses": {
"200": {
"$ref": "#/components/responses/cloudMigrationRunResponse"
},
"401": {
"$ref": "#/components/responses/unauthorisedError"
},
"403": {
"$ref": "#/components/responses/forbiddenError"
},
"500": {
"$ref": "#/components/responses/internalServerError"
}
},
"summary": "Trigger the run of a migration to the Grafana Cloud.",
"tags": [
"migrations"
]
}
},
"/cloudmigration/migration/{id}/run/{runID}": {