98e5048370
* start on tokens * more error messages * more handling * rephrased with suggestions from Daniel * separate gms parse method * use translation * refactor initial idea to use error obj * use error dto result * handle gms client * clean logs and comments * fix tests * tests for gms * test and lint * lint * one more handling from gms * typing in fe * use error interface * use validation error * remove unused gms error * use errorlib and helper function in fe * regen api * use same error util * one more error to handle
76 lines
2.0 KiB
Go
76 lines
2.0 KiB
Go
package gmsclient
|
|
|
|
import "time"
|
|
|
|
type MigrateDataType string
|
|
|
|
type MigrateDataRequestDTO struct {
|
|
Items []MigrateDataRequestItemDTO `json:"items"`
|
|
}
|
|
|
|
type MigrateDataRequestItemDTO struct {
|
|
Type MigrateDataType `json:"type"`
|
|
RefID string `json:"refId"`
|
|
Name string `json:"name"`
|
|
Data interface{} `json:"data"`
|
|
}
|
|
|
|
type ItemStatus string
|
|
|
|
const (
|
|
ItemStatusOK ItemStatus = "OK"
|
|
ItemStatusError ItemStatus = "ERROR"
|
|
)
|
|
|
|
type MigrateDataResponseDTO struct {
|
|
RunUID string `json:"uid"`
|
|
Items []MigrateDataResponseItemDTO `json:"items"`
|
|
}
|
|
|
|
type MigrateDataResponseListDTO struct {
|
|
RunUID string `json:"uid"`
|
|
}
|
|
|
|
type MigrateDataResponseItemDTO struct {
|
|
// required:true
|
|
Type MigrateDataType `json:"type"`
|
|
// required:true
|
|
RefID string `json:"refId"`
|
|
// required:true
|
|
Status ItemStatus `json:"status"`
|
|
Error string `json:"error,omitempty"`
|
|
}
|
|
|
|
type CreateSnapshotUploadUrlResponseDTO struct {
|
|
UploadUrl string `json:"uploadUrl"`
|
|
}
|
|
|
|
type EventRequestDTO struct {
|
|
LocalID string `json:"migrationClientId"`
|
|
Event LocalEventType `json:"event"`
|
|
Error string `json:"error"`
|
|
DurationIfFinished time.Duration `json:"duration"`
|
|
}
|
|
|
|
type LocalEventType string
|
|
|
|
const (
|
|
EventConnect LocalEventType = "connect"
|
|
EventDisconnect LocalEventType = "disconnect"
|
|
EventStartBuildingSnapshot LocalEventType = "start_building_snapshot"
|
|
EventDoneBuildingSnapshot LocalEventType = "done_building_snapshot"
|
|
EventStartUploadingSnapshot LocalEventType = "start_uploading_snapshot"
|
|
EventDoneUploadingSnapshot LocalEventType = "done_uploading_snapshot"
|
|
)
|
|
|
|
type GMSAPIError struct {
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
// Error messages returned from GMS
|
|
var (
|
|
GMSErrorMessageInstanceUnreachable = "instance is unreachable"
|
|
GMSErrorMessageInstanceCheckingError = "checking if instance is reachable"
|
|
GMSErrorMessageInstanceFetching = "fetching instance by stack id"
|
|
)
|