58 lines
2.0 KiB
Go
58 lines
2.0 KiB
Go
package dto
|
|
|
|
import "browser.local/platform/domain"
|
|
|
|
type ServerLifecycleCreateRequest struct {
|
|
ID string `json:"id"`
|
|
PluginID string `json:"pluginId"`
|
|
RunEndpointID string `json:"runEndpointId"`
|
|
Name string `json:"name"`
|
|
OwnerUserID string `json:"ownerUserId,omitempty"`
|
|
IdempotencyKey string `json:"idempotencyKey"`
|
|
ProfileKey string `json:"profileKey"`
|
|
Bindings map[string]string `json:"bindings,omitempty"`
|
|
}
|
|
|
|
type ServerLifecycleCommandRequest struct {
|
|
ExpectedConfigVersion int `json:"expectedConfigVersion"`
|
|
IdempotencyKey string `json:"idempotencyKey"`
|
|
}
|
|
|
|
type ServerLifecycleResponse struct {
|
|
Accepted bool `json:"accepted"`
|
|
Action domain.ServerLifecycleAction `json:"action"`
|
|
Instance ServerInstanceResponse `json:"instance"`
|
|
Job JobResponse `json:"job"`
|
|
}
|
|
|
|
func (request ServerLifecycleCreateRequest) ToDomain() domain.ServerLifecycleCreate {
|
|
return domain.ServerLifecycleCreate{
|
|
ID: request.ID,
|
|
PluginID: request.PluginID,
|
|
RunEndpointID: request.RunEndpointID,
|
|
Name: request.Name,
|
|
OwnerUserID: request.OwnerUserID,
|
|
IdempotencyKey: request.IdempotencyKey,
|
|
ProfileKey: request.ProfileKey,
|
|
Bindings: domain.CopyStringMap(request.Bindings),
|
|
}
|
|
}
|
|
|
|
func (request ServerLifecycleCommandRequest) ToDomain(serverInstanceID string) domain.ServerLifecycleCommand {
|
|
return domain.ServerLifecycleCommand{
|
|
ServerInstanceID: serverInstanceID,
|
|
ExpectedConfigVersion: request.ExpectedConfigVersion,
|
|
IdempotencyKey: request.IdempotencyKey,
|
|
}
|
|
}
|
|
|
|
func ServerLifecycleFromDomain(result domain.ServerLifecycleResult) ServerLifecycleResponse {
|
|
result = domain.CopyServerLifecycleResult(result)
|
|
return ServerLifecycleResponse{
|
|
Accepted: result.Accepted,
|
|
Action: result.Action,
|
|
Instance: ServerInstanceFromDomain(result.Instance),
|
|
Job: JobFromDomain(result.Job),
|
|
}
|
|
}
|