202 lines
8.1 KiB
Go
202 lines
8.1 KiB
Go
package dto
|
|
|
|
import (
|
|
"time"
|
|
|
|
"browser.local/platform/domain"
|
|
)
|
|
|
|
type ArtifactTransferOpenRequest struct {
|
|
RunEndpointID string `json:"runEndpointId"`
|
|
SessionToken string `json:"sessionToken"`
|
|
ArtifactID string `json:"artifactId"`
|
|
Direction domain.ArtifactTransferDirection `json:"direction"`
|
|
OwnerKind domain.ArtifactOwnerKind `json:"ownerKind"`
|
|
OwnerID string `json:"ownerId"`
|
|
SizeBytes int64 `json:"sizeBytes"`
|
|
ChunkSizeBytes int `json:"chunkSizeBytes"`
|
|
Checksum string `json:"checksum"`
|
|
IdempotencyKey string `json:"idempotencyKey"`
|
|
}
|
|
|
|
type ArtifactTransferOpenResponse struct {
|
|
Accepted bool `json:"accepted"`
|
|
TransferID string `json:"transferId"`
|
|
Direction domain.ArtifactTransferDirection `json:"direction"`
|
|
Artifact ArtifactResponse `json:"artifact"`
|
|
TotalChunks int `json:"totalChunks"`
|
|
ChunkSizeBytes int `json:"chunkSizeBytes"`
|
|
ReceivedChunkIndexes []int `json:"receivedChunkIndexes"`
|
|
NextMissingChunkIndex int `json:"nextMissingChunkIndex"`
|
|
Completed bool `json:"completed"`
|
|
Duplicate bool `json:"duplicate"`
|
|
ServerTime time.Time `json:"serverTime"`
|
|
}
|
|
|
|
type ArtifactChunkUploadRequest struct {
|
|
RunEndpointID string `json:"runEndpointId"`
|
|
SessionToken string `json:"sessionToken"`
|
|
TransferID string `json:"transferId"`
|
|
ArtifactID string `json:"artifactId"`
|
|
ChunkIndex int `json:"chunkIndex"`
|
|
Offset int64 `json:"offset"`
|
|
SizeBytes int `json:"sizeBytes"`
|
|
Checksum string `json:"checksum"`
|
|
Payload []byte `json:"-"`
|
|
}
|
|
|
|
type ArtifactChunkUploadResponse struct {
|
|
Accepted bool `json:"accepted"`
|
|
TransferID string `json:"transferId"`
|
|
ArtifactID string `json:"artifactId"`
|
|
ChunkIndex int `json:"chunkIndex"`
|
|
ReceivedChunkIndexes []int `json:"receivedChunkIndexes"`
|
|
NextMissingChunkIndex int `json:"nextMissingChunkIndex"`
|
|
Duplicate bool `json:"duplicate"`
|
|
ServerTime time.Time `json:"serverTime"`
|
|
}
|
|
|
|
type ArtifactTransferStatusRequest struct {
|
|
RunEndpointID string `json:"runEndpointId"`
|
|
SessionToken string `json:"sessionToken"`
|
|
TransferID string `json:"transferId"`
|
|
ArtifactID string `json:"artifactId"`
|
|
}
|
|
|
|
type ArtifactTransferStatusResponse struct {
|
|
Accepted bool `json:"accepted"`
|
|
TransferID string `json:"transferId"`
|
|
ArtifactID string `json:"artifactId"`
|
|
Direction domain.ArtifactTransferDirection `json:"direction"`
|
|
TotalChunks int `json:"totalChunks"`
|
|
ChunkSizeBytes int `json:"chunkSizeBytes"`
|
|
ReceivedChunkIndexes []int `json:"receivedChunkIndexes"`
|
|
NextMissingChunkIndex int `json:"nextMissingChunkIndex"`
|
|
Completed bool `json:"completed"`
|
|
ServerTime time.Time `json:"serverTime"`
|
|
}
|
|
|
|
type ArtifactTransferCompleteRequest struct {
|
|
RunEndpointID string `json:"runEndpointId"`
|
|
SessionToken string `json:"sessionToken"`
|
|
TransferID string `json:"transferId"`
|
|
ArtifactID string `json:"artifactId"`
|
|
Checksum string `json:"checksum"`
|
|
SizeBytes int64 `json:"sizeBytes"`
|
|
}
|
|
|
|
type ArtifactTransferCompleteResponse struct {
|
|
Accepted bool `json:"accepted"`
|
|
TransferID string `json:"transferId"`
|
|
Artifact ArtifactResponse `json:"artifact"`
|
|
Completed bool `json:"completed"`
|
|
ServerTime time.Time `json:"serverTime"`
|
|
}
|
|
|
|
func (request ArtifactTransferOpenRequest) ToDomain() domain.ArtifactTransferOpen {
|
|
return domain.ArtifactTransferOpen{
|
|
RunEndpointID: request.RunEndpointID,
|
|
SessionToken: request.SessionToken,
|
|
ArtifactID: request.ArtifactID,
|
|
Direction: request.Direction,
|
|
OwnerKind: request.OwnerKind,
|
|
OwnerID: request.OwnerID,
|
|
SizeBytes: request.SizeBytes,
|
|
ChunkSizeBytes: request.ChunkSizeBytes,
|
|
Checksum: request.Checksum,
|
|
IdempotencyKey: request.IdempotencyKey,
|
|
}
|
|
}
|
|
|
|
func (request ArtifactChunkUploadRequest) ToDomain() domain.ArtifactChunkUpload {
|
|
return domain.ArtifactChunkUpload{
|
|
RunEndpointID: request.RunEndpointID,
|
|
SessionToken: request.SessionToken,
|
|
TransferID: request.TransferID,
|
|
ArtifactID: request.ArtifactID,
|
|
ChunkIndex: request.ChunkIndex,
|
|
Offset: request.Offset,
|
|
SizeBytes: request.SizeBytes,
|
|
Checksum: request.Checksum,
|
|
Payload: domain.CopyBytes(request.Payload),
|
|
}
|
|
}
|
|
|
|
func (request ArtifactTransferStatusRequest) ToDomain() domain.ArtifactTransferStatusQuery {
|
|
return domain.ArtifactTransferStatusQuery{
|
|
RunEndpointID: request.RunEndpointID,
|
|
SessionToken: request.SessionToken,
|
|
TransferID: request.TransferID,
|
|
ArtifactID: request.ArtifactID,
|
|
}
|
|
}
|
|
|
|
func (request ArtifactTransferCompleteRequest) ToDomain() domain.ArtifactTransferComplete {
|
|
return domain.ArtifactTransferComplete{
|
|
RunEndpointID: request.RunEndpointID,
|
|
SessionToken: request.SessionToken,
|
|
TransferID: request.TransferID,
|
|
ArtifactID: request.ArtifactID,
|
|
Checksum: request.Checksum,
|
|
SizeBytes: request.SizeBytes,
|
|
}
|
|
}
|
|
|
|
func ArtifactTransferOpenFromDomain(result domain.ArtifactTransferOpenResult) ArtifactTransferOpenResponse {
|
|
result = domain.CopyArtifactTransferOpenResult(result)
|
|
return ArtifactTransferOpenResponse{
|
|
Accepted: result.Accepted,
|
|
TransferID: result.TransferID,
|
|
Direction: result.Direction,
|
|
Artifact: ArtifactFromDomain(result.Artifact),
|
|
TotalChunks: result.TotalChunks,
|
|
ChunkSizeBytes: result.ChunkSizeBytes,
|
|
ReceivedChunkIndexes: result.ReceivedChunkIndexes,
|
|
NextMissingChunkIndex: result.NextMissingChunkIndex,
|
|
Completed: result.Completed,
|
|
Duplicate: result.Duplicate,
|
|
ServerTime: result.ServerTime,
|
|
}
|
|
}
|
|
|
|
func ArtifactChunkUploadFromDomain(result domain.ArtifactChunkUploadResult) ArtifactChunkUploadResponse {
|
|
result = domain.CopyArtifactChunkUploadResult(result)
|
|
return ArtifactChunkUploadResponse{
|
|
Accepted: result.Accepted,
|
|
TransferID: result.TransferID,
|
|
ArtifactID: result.ArtifactID,
|
|
ChunkIndex: result.ChunkIndex,
|
|
ReceivedChunkIndexes: result.ReceivedChunkIndexes,
|
|
NextMissingChunkIndex: result.NextMissingChunkIndex,
|
|
Duplicate: result.Duplicate,
|
|
ServerTime: result.ServerTime,
|
|
}
|
|
}
|
|
|
|
func ArtifactTransferStatusFromDomain(result domain.ArtifactTransferStatusResult) ArtifactTransferStatusResponse {
|
|
result = domain.CopyArtifactTransferStatusResult(result)
|
|
return ArtifactTransferStatusResponse{
|
|
Accepted: result.Accepted,
|
|
TransferID: result.TransferID,
|
|
ArtifactID: result.ArtifactID,
|
|
Direction: result.Direction,
|
|
TotalChunks: result.TotalChunks,
|
|
ChunkSizeBytes: result.ChunkSizeBytes,
|
|
ReceivedChunkIndexes: result.ReceivedChunkIndexes,
|
|
NextMissingChunkIndex: result.NextMissingChunkIndex,
|
|
Completed: result.Completed,
|
|
ServerTime: result.ServerTime,
|
|
}
|
|
}
|
|
|
|
func ArtifactTransferCompleteFromDomain(result domain.ArtifactTransferCompleteResult) ArtifactTransferCompleteResponse {
|
|
result = domain.CopyArtifactTransferCompleteResult(result)
|
|
return ArtifactTransferCompleteResponse{
|
|
Accepted: result.Accepted,
|
|
TransferID: result.TransferID,
|
|
Artifact: ArtifactFromDomain(result.Artifact),
|
|
Completed: result.Completed,
|
|
ServerTime: result.ServerTime,
|
|
}
|
|
}
|