forked from Azure/azure-sdk-for-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
548 lines (492 loc) · 18 KB
/
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
package job
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"encoding/json"
"errors"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/date"
"github.com/Azure/go-autorest/autorest/to"
"github.com/satori/go.uuid"
"net/http"
)
// CompileMode enumerates the values for compile mode.
type CompileMode string
const (
// Full specifies the full state for compile mode.
Full CompileMode = "Full"
// Semantic specifies the semantic state for compile mode.
Semantic CompileMode = "Semantic"
// SingleBox specifies the single box state for compile mode.
SingleBox CompileMode = "SingleBox"
)
// ResourceType enumerates the values for resource type.
type ResourceType string
const (
// JobManagerResource specifies the job manager resource state for resource type.
JobManagerResource ResourceType = "JobManagerResource"
// JobManagerResourceInUserFolder specifies the job manager resource in user folder state for resource type.
JobManagerResourceInUserFolder ResourceType = "JobManagerResourceInUserFolder"
// StatisticsResource specifies the statistics resource state for resource type.
StatisticsResource ResourceType = "StatisticsResource"
// StatisticsResourceInUserFolder specifies the statistics resource in user folder state for resource type.
StatisticsResourceInUserFolder ResourceType = "StatisticsResourceInUserFolder"
// VertexResource specifies the vertex resource state for resource type.
VertexResource ResourceType = "VertexResource"
// VertexResourceInUserFolder specifies the vertex resource in user folder state for resource type.
VertexResourceInUserFolder ResourceType = "VertexResourceInUserFolder"
)
// Result enumerates the values for result.
type Result string
const (
// Cancelled specifies the cancelled state for result.
Cancelled Result = "Cancelled"
// Failed specifies the failed state for result.
Failed Result = "Failed"
// None specifies the none state for result.
None Result = "None"
// Succeeded specifies the succeeded state for result.
Succeeded Result = "Succeeded"
)
// SeverityTypes enumerates the values for severity types.
type SeverityTypes string
const (
// Error specifies the error state for severity types.
Error SeverityTypes = "Error"
// Info specifies the info state for severity types.
Info SeverityTypes = "Info"
// Warning specifies the warning state for severity types.
Warning SeverityTypes = "Warning"
)
// State enumerates the values for state.
type State string
const (
// StateAccepted specifies the state accepted state for state.
StateAccepted State = "Accepted"
// StateCompiling specifies the state compiling state for state.
StateCompiling State = "Compiling"
// StateEnded specifies the state ended state for state.
StateEnded State = "Ended"
// StateNew specifies the state new state for state.
StateNew State = "New"
// StatePaused specifies the state paused state for state.
StatePaused State = "Paused"
// StateQueued specifies the state queued state for state.
StateQueued State = "Queued"
// StateRunning specifies the state running state for state.
StateRunning State = "Running"
// StateScheduling specifies the state scheduling state for state.
StateScheduling State = "Scheduling"
// StateStarting specifies the state starting state for state.
StateStarting State = "Starting"
// StateWaitingForCapacity specifies the state waiting for capacity state for state.
StateWaitingForCapacity State = "WaitingForCapacity"
)
// Type enumerates the values for type.
type Type string
const (
// Hive specifies the hive state for type.
Hive Type = "Hive"
// USQL specifies the usql state for type.
USQL Type = "USql"
)
// DataPath is a Data Lake Analytics job data path item.
type DataPath struct {
autorest.Response `json:"-"`
JobID *uuid.UUID `json:"jobId,omitempty"`
Command *string `json:"command,omitempty"`
Paths *[]string `json:"paths,omitempty"`
}
// Diagnostics is
type Diagnostics struct {
ColumnNumber *int32 `json:"columnNumber,omitempty"`
End *int32 `json:"end,omitempty"`
LineNumber *int32 `json:"lineNumber,omitempty"`
Message *string `json:"message,omitempty"`
Severity SeverityTypes `json:"severity,omitempty"`
Start *int32 `json:"start,omitempty"`
}
// ErrorDetails is the Data Lake Analytics job error details.
type ErrorDetails struct {
Description *string `json:"description,omitempty"`
Details *string `json:"details,omitempty"`
EndOffset *int32 `json:"endOffset,omitempty"`
ErrorID *string `json:"errorId,omitempty"`
FilePath *string `json:"filePath,omitempty"`
HelpLink *string `json:"helpLink,omitempty"`
InternalDiagnostics *string `json:"internalDiagnostics,omitempty"`
LineNumber *int32 `json:"lineNumber,omitempty"`
Message *string `json:"message,omitempty"`
Resolution *string `json:"resolution,omitempty"`
InnerError *InnerError `json:"innerError,omitempty"`
Severity SeverityTypes `json:"severity,omitempty"`
Source *string `json:"source,omitempty"`
StartOffset *int32 `json:"startOffset,omitempty"`
}
// HiveJobProperties is
type HiveJobProperties struct {
RuntimeVersion *string `json:"runtimeVersion,omitempty"`
Script *string `json:"script,omitempty"`
Type Type `json:"type,omitempty"`
LogsLocation *string `json:"logsLocation,omitempty"`
OutputLocation *string `json:"outputLocation,omitempty"`
StatementCount *int32 `json:"statementCount,omitempty"`
ExecutedStatementCount *int32 `json:"executedStatementCount,omitempty"`
}
// MarshalJSON is the custom marshaler for HiveJobProperties.
func (hjp HiveJobProperties) MarshalJSON() ([]byte, error) {
hjp.Type = Hive
type Alias HiveJobProperties
return json.Marshal(&struct {
Alias
}{
Alias: (Alias)(hjp),
})
}
// AsUSQLJobProperties is the Properties implementation for HiveJobProperties.
func (hjp HiveJobProperties) AsUSQLJobProperties() (*USQLJobProperties, bool) {
return nil, false
}
// AsHiveJobProperties is the Properties implementation for HiveJobProperties.
func (hjp HiveJobProperties) AsHiveJobProperties() (*HiveJobProperties, bool) {
return &hjp, true
}
// InfoListResult is list of jobInfo items.
type InfoListResult struct {
autorest.Response `json:"-"`
Value *[]Information `json:"value,omitempty"`
NextLink *string `json:"nextLink,omitempty"`
Count *int64 `json:"count,omitempty"`
}
// InfoListResultPreparer prepares a request to retrieve the next set of results. It returns
// nil if no more results exist.
func (client InfoListResult) InfoListResultPreparer() (*http.Request, error) {
if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
return nil, nil
}
return autorest.Prepare(&http.Request{},
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(client.NextLink)))
}
// Information is the common Data Lake Analytics job information properties.
type Information struct {
autorest.Response `json:"-"`
JobID *uuid.UUID `json:"jobId,omitempty"`
Name *string `json:"name,omitempty"`
Type Type `json:"type,omitempty"`
Submitter *string `json:"submitter,omitempty"`
ErrorMessage *[]ErrorDetails `json:"errorMessage,omitempty"`
DegreeOfParallelism *int32 `json:"degreeOfParallelism,omitempty"`
Priority *int32 `json:"priority,omitempty"`
SubmitTime *date.Time `json:"submitTime,omitempty"`
StartTime *date.Time `json:"startTime,omitempty"`
EndTime *date.Time `json:"endTime,omitempty"`
State State `json:"state,omitempty"`
Result Result `json:"result,omitempty"`
LogFolder *string `json:"logFolder,omitempty"`
LogFilePatterns *[]string `json:"logFilePatterns,omitempty"`
StateAuditRecords *[]StateAuditRecord `json:"stateAuditRecords,omitempty"`
Properties Properties `json:"properties,omitempty"`
}
// UnmarshalJSON is the custom unmarshaler for Information struct.
func (i *Information) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
var v *json.RawMessage
v = m["jobId"]
if v != nil {
var jobID uuid.UUID
err = json.Unmarshal(*m["jobId"], &jobID)
if err != nil {
return err
}
i.JobID = &jobID
}
v = m["name"]
if v != nil {
var name string
err = json.Unmarshal(*m["name"], &name)
if err != nil {
return err
}
i.Name = &name
}
v = m["type"]
if v != nil {
var typeVar Type
err = json.Unmarshal(*m["type"], &typeVar)
if err != nil {
return err
}
i.Type = typeVar
}
v = m["submitter"]
if v != nil {
var submitter string
err = json.Unmarshal(*m["submitter"], &submitter)
if err != nil {
return err
}
i.Submitter = &submitter
}
v = m["errorMessage"]
if v != nil {
var errorMessage []ErrorDetails
err = json.Unmarshal(*m["errorMessage"], &errorMessage)
if err != nil {
return err
}
i.ErrorMessage = &errorMessage
}
v = m["degreeOfParallelism"]
if v != nil {
var degreeOfParallelism int32
err = json.Unmarshal(*m["degreeOfParallelism"], °reeOfParallelism)
if err != nil {
return err
}
i.DegreeOfParallelism = °reeOfParallelism
}
v = m["priority"]
if v != nil {
var priority int32
err = json.Unmarshal(*m["priority"], &priority)
if err != nil {
return err
}
i.Priority = &priority
}
v = m["submitTime"]
if v != nil {
var submitTime date.Time
err = json.Unmarshal(*m["submitTime"], &submitTime)
if err != nil {
return err
}
i.SubmitTime = &submitTime
}
v = m["startTime"]
if v != nil {
var startTime date.Time
err = json.Unmarshal(*m["startTime"], &startTime)
if err != nil {
return err
}
i.StartTime = &startTime
}
v = m["endTime"]
if v != nil {
var endTime date.Time
err = json.Unmarshal(*m["endTime"], &endTime)
if err != nil {
return err
}
i.EndTime = &endTime
}
v = m["state"]
if v != nil {
var state State
err = json.Unmarshal(*m["state"], &state)
if err != nil {
return err
}
i.State = state
}
v = m["result"]
if v != nil {
var resultVar Result
err = json.Unmarshal(*m["result"], &resultVar)
if err != nil {
return err
}
i.Result = resultVar
}
v = m["logFolder"]
if v != nil {
var logFolder string
err = json.Unmarshal(*m["logFolder"], &logFolder)
if err != nil {
return err
}
i.LogFolder = &logFolder
}
v = m["logFilePatterns"]
if v != nil {
var logFilePatterns []string
err = json.Unmarshal(*m["logFilePatterns"], &logFilePatterns)
if err != nil {
return err
}
i.LogFilePatterns = &logFilePatterns
}
v = m["stateAuditRecords"]
if v != nil {
var stateAuditRecords []StateAuditRecord
err = json.Unmarshal(*m["stateAuditRecords"], &stateAuditRecords)
if err != nil {
return err
}
i.StateAuditRecords = &stateAuditRecords
}
v = m["properties"]
if v != nil {
properties, err := unmarshalProperties(*m["properties"])
if err != nil {
return err
}
i.Properties = properties
}
return nil
}
// InnerError is the Data Lake Analytics job error details.
type InnerError struct {
DiagnosticCode *int32 `json:"diagnosticCode,omitempty"`
Severity SeverityTypes `json:"severity,omitempty"`
Details *string `json:"details,omitempty"`
Component *string `json:"component,omitempty"`
ErrorID *string `json:"errorId,omitempty"`
HelpLink *string `json:"helpLink,omitempty"`
InternalDiagnostics *string `json:"internalDiagnostics,omitempty"`
Message *string `json:"message,omitempty"`
Resolution *string `json:"resolution,omitempty"`
Source *string `json:"source,omitempty"`
Description *string `json:"description,omitempty"`
}
// Properties is the common Data Lake Analytics job properties.
type Properties interface {
AsUSQLJobProperties() (*USQLJobProperties, bool)
AsHiveJobProperties() (*HiveJobProperties, bool)
}
func unmarshalProperties(body []byte) (Properties, error) {
var m map[string]interface{}
err := json.Unmarshal(body, &m)
if err != nil {
return nil, err
}
switch m["type"] {
case string(USQL):
var usjp USQLJobProperties
err := json.Unmarshal(body, &usjp)
return usjp, err
case string(Hive):
var hjp HiveJobProperties
err := json.Unmarshal(body, &hjp)
return hjp, err
default:
return nil, errors.New("Unsupported type")
}
}
func unmarshalPropertiesArray(body []byte) ([]Properties, error) {
var rawMessages []*json.RawMessage
err := json.Unmarshal(body, &rawMessages)
if err != nil {
return nil, err
}
pArray := make([]Properties, len(rawMessages))
for index, rawMessage := range rawMessages {
p, err := unmarshalProperties(*rawMessage)
if err != nil {
return nil, err
}
pArray[index] = p
}
return pArray, nil
}
// Resource is the Data Lake Analytics job resources.
type Resource struct {
Name *string `json:"name,omitempty"`
ResourcePath *string `json:"resourcePath,omitempty"`
Type ResourceType `json:"type,omitempty"`
}
// StateAuditRecord is the Data Lake Analytics job state audit records for tracking the lifecycle of a job.
type StateAuditRecord struct {
NewState *string `json:"newState,omitempty"`
TimeStamp *date.Time `json:"timeStamp,omitempty"`
RequestedByUser *string `json:"requestedByUser,omitempty"`
Details *string `json:"details,omitempty"`
}
// Statistics is the Data Lake Analytics job execution statistics.
type Statistics struct {
autorest.Response `json:"-"`
LastUpdateTimeUtc *date.Time `json:"lastUpdateTimeUtc,omitempty"`
FinalizingTimeUtc *date.Time `json:"finalizingTimeUtc,omitempty"`
Stages *[]StatisticsVertexStage `json:"stages,omitempty"`
}
// StatisticsVertexStage is the Data Lake Analytics job statistics vertex stage information.
type StatisticsVertexStage struct {
DataRead *int64 `json:"dataRead,omitempty"`
DataReadCrossPod *int64 `json:"dataReadCrossPod,omitempty"`
DataReadIntraPod *int64 `json:"dataReadIntraPod,omitempty"`
DataToRead *int64 `json:"dataToRead,omitempty"`
DataWritten *int64 `json:"dataWritten,omitempty"`
DuplicateDiscardCount *int32 `json:"duplicateDiscardCount,omitempty"`
FailedCount *int32 `json:"failedCount,omitempty"`
MaxVertexDataRead *int64 `json:"maxVertexDataRead,omitempty"`
MinVertexDataRead *int64 `json:"minVertexDataRead,omitempty"`
ReadFailureCount *int32 `json:"readFailureCount,omitempty"`
RevocationCount *int32 `json:"revocationCount,omitempty"`
RunningCount *int32 `json:"runningCount,omitempty"`
ScheduledCount *int32 `json:"scheduledCount,omitempty"`
StageName *string `json:"stageName,omitempty"`
SucceededCount *int32 `json:"succeededCount,omitempty"`
TempDataWritten *int64 `json:"tempDataWritten,omitempty"`
TotalCount *int32 `json:"totalCount,omitempty"`
TotalFailedTime *string `json:"totalFailedTime,omitempty"`
TotalProgress *int32 `json:"totalProgress,omitempty"`
TotalSucceededTime *string `json:"totalSucceededTime,omitempty"`
}
// USQLJobProperties is
type USQLJobProperties struct {
RuntimeVersion *string `json:"runtimeVersion,omitempty"`
Script *string `json:"script,omitempty"`
Type Type `json:"type,omitempty"`
Resources *[]Resource `json:"resources,omitempty"`
Statistics *Statistics `json:"statistics,omitempty"`
DebugData *DataPath `json:"debugData,omitempty"`
Diagnostics *[]Diagnostics `json:"diagnostics,omitempty"`
AlgebraFilePath *string `json:"algebraFilePath,omitempty"`
TotalCompilationTime *string `json:"totalCompilationTime,omitempty"`
TotalPauseTime *string `json:"totalPauseTime,omitempty"`
TotalQueuedTime *string `json:"totalQueuedTime,omitempty"`
TotalRunningTime *string `json:"totalRunningTime,omitempty"`
RootProcessNodeID *string `json:"rootProcessNodeId,omitempty"`
YarnApplicationID *string `json:"yarnApplicationId,omitempty"`
YarnApplicationTimeStamp *int64 `json:"yarnApplicationTimeStamp,omitempty"`
CompileMode CompileMode `json:"compileMode,omitempty"`
}
// MarshalJSON is the custom marshaler for USQLJobProperties.
func (usjp USQLJobProperties) MarshalJSON() ([]byte, error) {
usjp.Type = USQL
type Alias USQLJobProperties
return json.Marshal(&struct {
Alias
}{
Alias: (Alias)(usjp),
})
}
// AsUSQLJobProperties is the Properties implementation for USQLJobProperties.
func (usjp USQLJobProperties) AsUSQLJobProperties() (*USQLJobProperties, bool) {
return &usjp, true
}
// AsHiveJobProperties is the Properties implementation for USQLJobProperties.
func (usjp USQLJobProperties) AsHiveJobProperties() (*HiveJobProperties, bool) {
return nil, false
}