89 lines
3.3 KiB
Go
89 lines
3.3 KiB
Go
package dto
|
|
|
|
import (
|
|
"time"
|
|
|
|
"browser.local/platform/domain"
|
|
)
|
|
|
|
type ArtifactDownloadReferenceRequest struct {
|
|
ArtifactID string `json:"artifactId"`
|
|
}
|
|
|
|
type ArtifactDownloadReferenceResponse struct {
|
|
ArtifactID string `json:"artifactId"`
|
|
OwnerKind domain.ArtifactOwnerKind `json:"ownerKind"`
|
|
OwnerID string `json:"ownerId"`
|
|
Filename string `json:"filename"`
|
|
ContentType string `json:"contentType"`
|
|
SizeBytes int64 `json:"sizeBytes"`
|
|
Checksum string `json:"checksum"`
|
|
State domain.ArtifactState `json:"state"`
|
|
DownloadURL string `json:"downloadUrl"`
|
|
ExpiresAt time.Time `json:"expiresAt"`
|
|
RangeSupported bool `json:"rangeSupported"`
|
|
ChunkSizeBytes int `json:"chunkSizeBytes"`
|
|
StorageBehavior string `json:"storageBehavior"`
|
|
}
|
|
|
|
type ArtifactContentRequest struct {
|
|
ArtifactID string `json:"artifactId"`
|
|
Offset int64 `json:"offset"`
|
|
Limit int `json:"limit"`
|
|
}
|
|
|
|
type ArtifactTransferProgressResponse struct {
|
|
ArtifactID string `json:"artifactId"`
|
|
BytesRead int64 `json:"bytesRead"`
|
|
TotalSizeBytes int64 `json:"totalSizeBytes"`
|
|
Complete bool `json:"complete"`
|
|
}
|
|
|
|
type ArtifactDownloadSafeErrorResponse struct {
|
|
Code string `json:"code"`
|
|
Message string `json:"message"`
|
|
Details []string `json:"details,omitempty"`
|
|
}
|
|
|
|
func (request ArtifactDownloadReferenceRequest) ToDomain() domain.ArtifactDownloadReferenceRequest {
|
|
return domain.ArtifactDownloadReferenceRequest{ArtifactID: request.ArtifactID}
|
|
}
|
|
|
|
func (request ArtifactContentRequest) ToDomain() domain.ArtifactContentRequest {
|
|
return domain.ArtifactContentRequest{ArtifactID: request.ArtifactID, Offset: request.Offset, Limit: request.Limit}
|
|
}
|
|
|
|
func ArtifactDownloadReferenceFromDomain(reference domain.ArtifactDownloadReference) ArtifactDownloadReferenceResponse {
|
|
reference = domain.CopyArtifactDownloadReference(reference)
|
|
return ArtifactDownloadReferenceResponse{
|
|
ArtifactID: reference.ArtifactID,
|
|
OwnerKind: reference.OwnerKind,
|
|
OwnerID: reference.OwnerID,
|
|
Filename: reference.Filename,
|
|
ContentType: reference.ContentType,
|
|
SizeBytes: reference.SizeBytes,
|
|
Checksum: reference.Checksum,
|
|
State: reference.State,
|
|
DownloadURL: reference.DownloadURL,
|
|
ExpiresAt: reference.ExpiresAt,
|
|
RangeSupported: reference.RangeSupported,
|
|
ChunkSizeBytes: reference.ChunkSizeBytes,
|
|
StorageBehavior: reference.StorageBehavior,
|
|
}
|
|
}
|
|
|
|
func ArtifactTransferProgressFromDomain(progress domain.ArtifactTransferProgress) ArtifactTransferProgressResponse {
|
|
progress = domain.CopyArtifactTransferProgress(progress)
|
|
return ArtifactTransferProgressResponse{
|
|
ArtifactID: progress.ArtifactID,
|
|
BytesRead: progress.BytesRead,
|
|
TotalSizeBytes: progress.TotalSizeBytes,
|
|
Complete: progress.Complete,
|
|
}
|
|
}
|
|
|
|
func ArtifactDownloadSafeErrorFromDomain(safeError domain.ArtifactDownloadSafeError) ArtifactDownloadSafeErrorResponse {
|
|
safeError = domain.CopyArtifactDownloadSafeError(safeError)
|
|
return ArtifactDownloadSafeErrorResponse{Code: safeError.Code, Message: safeError.Message, Details: safeError.Details}
|
|
}
|