/
rpc-models.go
228 lines (193 loc) · 7.93 KB
/
rpc-models.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
package common
import (
"reflect"
"time"
"github.com/Azure/azure-storage-blob-go/azblob"
"github.com/JeffreyRichter/enum/enum"
)
var ERpcCmd = RpcCmd("")
// JobStatus indicates the status of a Job; the default is InProgress.
type RpcCmd string
func (RpcCmd) None() RpcCmd { return RpcCmd("--none--") }
func (RpcCmd) CopyJobPartOrder() RpcCmd { return RpcCmd("CopyJobPartOrder") }
func (RpcCmd) ListJobs() RpcCmd { return RpcCmd("ListJobs") }
func (RpcCmd) ListJobSummary() RpcCmd { return RpcCmd("ListJobSummary") }
func (RpcCmd) ListSyncJobSummary() RpcCmd { return RpcCmd("ListSyncJobSummary") }
func (RpcCmd) ListJobTransfers() RpcCmd { return RpcCmd("ListJobTransfers") }
func (RpcCmd) CancelJob() RpcCmd { return RpcCmd("Cancel") }
func (RpcCmd) PauseJob() RpcCmd { return RpcCmd("PauseJob") }
func (RpcCmd) ResumeJob() RpcCmd { return RpcCmd("ResumeJob") }
func (RpcCmd) GetJobFromTo() RpcCmd { return RpcCmd("GetJobFromTo") }
func (c RpcCmd) String() string {
return enum.String(c, reflect.TypeOf(c))
}
func (c RpcCmd) Pattern() string { return "/" + c.String() }
func (c *RpcCmd) Parse(s string) error {
val, err := enum.Parse(reflect.TypeOf(c), s, false)
if err == nil {
*c = val.(RpcCmd)
}
return err
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// This struct represents the job info (a single part) to be sent to the storage engine
type CopyJobPartOrderRequest struct {
Version Version // version of the azcopy
JobID JobID // Guid - job identifier
PartNum PartNumber // part number of the job
IsFinalPart bool // to determine the final part for a specific job
ForceWrite OverwriteOption // to determine if the existing needs to be overwritten or not. If set to true, existing blobs are overwritten
Priority JobPriority // priority of the task
FromTo FromTo
Include map[string]int
Exclude map[string]int
// list of blobTypes to exclude.
ExcludeBlobType []azblob.BlobType
SourceRoot string
DestinationRoot string
Transfers []CopyTransfer
LogLevel LogLevel
BlobAttributes BlobTransferAttributes
SourceSAS string
DestinationSAS string
// commandString hold the user given command which is logged to the Job log file
CommandString string
CredentialInfo CredentialInfo
S2SGetPropertiesInBackend bool
S2SSourceChangeValidation bool
S2SDestLengthValidation bool
S2SInvalidMetadataHandleOption InvalidMetadataHandleOption
}
// CredentialInfo contains essential credential info which need be transited between modules,
// and used during creating Azure storage client Credential.
type CredentialInfo struct {
CredentialType CredentialType
OAuthTokenInfo OAuthTokenInfo
S3CredentialInfo S3CredentialInfo
}
// S3CredentialInfo contains essential credential info which need to build up S3 client.
type S3CredentialInfo struct {
Endpoint string
Region string
}
type CopyJobPartOrderErrorType string
var ECopyJobPartOrderErrorType CopyJobPartOrderErrorType
func (CopyJobPartOrderErrorType) NoTransfersScheduledErr() CopyJobPartOrderErrorType {
return CopyJobPartOrderErrorType("NoTransfersScheduledErr")
}
type CopyJobPartOrderResponse struct {
ErrorMsg CopyJobPartOrderErrorType
JobStarted bool
}
// represents the raw list command input from the user when requested the list of transfer with given status for given JobId
type ListRequest struct {
JobID JobID
OfStatus string // TODO: OfStatus with string type sounds not good, change it to enum
Output OutputFormat
}
// This struct represents the optional attribute for blob request header
type BlobTransferAttributes struct {
BlobType BlobType // The type of a blob - BlockBlob, PageBlob, AppendBlob
ContentType string // The content type specified for the blob.
ContentEncoding string // Specifies which content encodings have been applied to the blob.
ContentLanguage string // Specifies the language of the content
ContentDisposition string // Specifies the content disposition
CacheControl string // Specifies the cache control header
BlockBlobTier BlockBlobTier // Specifies the tier to set on the block blobs.
PageBlobTier PageBlobTier // Specifies the tier to set on the page blobs.
Metadata string // User-defined Name-value pairs associated with the blob
NoGuessMimeType bool // represents user decision to interpret the content-encoding from source file
PreserveLastModifiedTime bool // when downloading, tell engine to set file's timestamp to timestamp of blob
PutMd5 bool // when uploading, should we create and PUT Content-MD5 hashes
MD5ValidationOption HashValidationOption // when downloading, how strictly should we validate MD5 hashes?
BlockSizeInBytes uint32
}
type JobIDDetails struct {
JobId JobID
CommandString string
StartTime int64
JobStatus JobStatus
}
// ListJobsResponse represent the Job with JobId and
type ListJobsResponse struct {
ErrorMessage string
JobIDDetails []JobIDDetails
}
// ListContainerResponse represents the list of blobs within the container.
type ListContainerResponse struct {
Blobs []string
}
// represents the JobProgressPercentage Summary response for list command when requested the Job Progress Summary for given JobId
type ListJobSummaryResponse struct {
ErrorMsg string
Timestamp time.Time `json:"-"`
JobID JobID `json:"-"`
// TODO: added for debugging purpose. remove later
ActiveConnections int64
// CompleteJobOrdered determines whether the Job has been completely ordered or not
CompleteJobOrdered bool
JobStatus JobStatus
TotalTransfers uint32
TransfersCompleted uint32
TransfersFailed uint32
TransfersSkipped uint32
// includes bytes sent in retries (i.e. has double counting, if there are retries) and in failed transfers
BytesOverWire uint64
// does not include failed transfers or bytes sent in retries (i.e. no double counting). Includes successful transfers and transfers in progress
TotalBytesTransferred uint64
// sum of the total transfer enumerated so far.
TotalBytesEnumerated uint64
// sum of total bytes expected in the job (i.e. based on our current expectation of which files will be successful)
TotalBytesExpected uint64
PercentComplete float32
FailedTransfers []TransferDetail
SkippedTransfers []TransferDetail
PerfConstraint PerfConstraint
PerfStrings []string `json:"-"`
}
// wraps the standard ListJobSummaryResponse with sync-specific stats
type ListSyncJobSummaryResponse struct {
ListJobSummaryResponse
DeleteTotalTransfers uint32
DeleteTransfersCompleted uint32
}
type ListJobTransfersRequest struct {
JobID JobID
OfStatus TransferStatus
}
type ResumeJobRequest struct {
JobID JobID
SourceSAS string
DestinationSAS string
IncludeTransfer map[string]int
ExcludeTransfer map[string]int
CredentialInfo CredentialInfo
}
// represents the Details and details of a single transfer
type TransferDetail struct {
Src string
Dst string
TransferStatus TransferStatus
ErrorCode int32
}
type CancelPauseResumeResponse struct {
ErrorMsg string
CancelledPauseResumed bool
}
// represents the list of Details and details of number of transfers
type ListJobTransfersResponse struct {
ErrorMsg string
JobID JobID
Details []TransferDetail
}
// GetJobFromToRequest indicates request to get job's FromTo info from job part plan header
type GetJobFromToRequest struct {
JobID JobID
}
// GetJobFromToResponse indicates response to get job's FromTo info.
type GetJobFromToResponse struct {
ErrorMsg string
FromTo FromTo
Source string
Destination string
}