1package job
2
3// Copyright (c) Microsoft and contributors.  All rights reserved.
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13//
14// See the License for the specific language governing permissions and
15// limitations under the License.
16//
17// Code generated by Microsoft (R) AutoRest Code Generator.
18// Changes may cause incorrect behavior and will be lost if the code is regenerated.
19
20import (
21	"context"
22	"encoding/json"
23	"github.com/Azure/go-autorest/autorest"
24	"github.com/Azure/go-autorest/autorest/date"
25	"github.com/Azure/go-autorest/autorest/to"
26	"github.com/Azure/go-autorest/tracing"
27	"github.com/satori/go.uuid"
28	"net/http"
29)
30
31// The package's fully qualified name.
32const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/datalake/analytics/2016-03-20-preview/job"
33
34// CompileMode enumerates the values for compile mode.
35type CompileMode string
36
37const (
38	// Full ...
39	Full CompileMode = "Full"
40	// Semantic ...
41	Semantic CompileMode = "Semantic"
42	// SingleBox ...
43	SingleBox CompileMode = "SingleBox"
44)
45
46// PossibleCompileModeValues returns an array of possible values for the CompileMode const type.
47func PossibleCompileModeValues() []CompileMode {
48	return []CompileMode{Full, Semantic, SingleBox}
49}
50
51// ResourceType enumerates the values for resource type.
52type ResourceType string
53
54const (
55	// JobManagerResource ...
56	JobManagerResource ResourceType = "JobManagerResource"
57	// JobManagerResourceInUserFolder ...
58	JobManagerResourceInUserFolder ResourceType = "JobManagerResourceInUserFolder"
59	// StatisticsResource ...
60	StatisticsResource ResourceType = "StatisticsResource"
61	// StatisticsResourceInUserFolder ...
62	StatisticsResourceInUserFolder ResourceType = "StatisticsResourceInUserFolder"
63	// VertexResource ...
64	VertexResource ResourceType = "VertexResource"
65	// VertexResourceInUserFolder ...
66	VertexResourceInUserFolder ResourceType = "VertexResourceInUserFolder"
67)
68
69// PossibleResourceTypeValues returns an array of possible values for the ResourceType const type.
70func PossibleResourceTypeValues() []ResourceType {
71	return []ResourceType{JobManagerResource, JobManagerResourceInUserFolder, StatisticsResource, StatisticsResourceInUserFolder, VertexResource, VertexResourceInUserFolder}
72}
73
74// Result enumerates the values for result.
75type Result string
76
77const (
78	// Cancelled ...
79	Cancelled Result = "Cancelled"
80	// Failed ...
81	Failed Result = "Failed"
82	// None ...
83	None Result = "None"
84	// Succeeded ...
85	Succeeded Result = "Succeeded"
86)
87
88// PossibleResultValues returns an array of possible values for the Result const type.
89func PossibleResultValues() []Result {
90	return []Result{Cancelled, Failed, None, Succeeded}
91}
92
93// SeverityTypes enumerates the values for severity types.
94type SeverityTypes string
95
96const (
97	// Error ...
98	Error SeverityTypes = "Error"
99	// Info ...
100	Info SeverityTypes = "Info"
101	// Warning ...
102	Warning SeverityTypes = "Warning"
103)
104
105// PossibleSeverityTypesValues returns an array of possible values for the SeverityTypes const type.
106func PossibleSeverityTypesValues() []SeverityTypes {
107	return []SeverityTypes{Error, Info, Warning}
108}
109
110// State enumerates the values for state.
111type State string
112
113const (
114	// StateAccepted ...
115	StateAccepted State = "Accepted"
116	// StateCompiling ...
117	StateCompiling State = "Compiling"
118	// StateEnded ...
119	StateEnded State = "Ended"
120	// StateNew ...
121	StateNew State = "New"
122	// StatePaused ...
123	StatePaused State = "Paused"
124	// StateQueued ...
125	StateQueued State = "Queued"
126	// StateRunning ...
127	StateRunning State = "Running"
128	// StateScheduling ...
129	StateScheduling State = "Scheduling"
130	// StateStarting ...
131	StateStarting State = "Starting"
132	// StateWaitingForCapacity ...
133	StateWaitingForCapacity State = "WaitingForCapacity"
134)
135
136// PossibleStateValues returns an array of possible values for the State const type.
137func PossibleStateValues() []State {
138	return []State{StateAccepted, StateCompiling, StateEnded, StateNew, StatePaused, StateQueued, StateRunning, StateScheduling, StateStarting, StateWaitingForCapacity}
139}
140
141// Type enumerates the values for type.
142type Type string
143
144const (
145	// TypeHive ...
146	TypeHive Type = "Hive"
147	// TypeJobProperties ...
148	TypeJobProperties Type = "JobProperties"
149	// TypeUSQL ...
150	TypeUSQL Type = "USql"
151)
152
153// PossibleTypeValues returns an array of possible values for the Type const type.
154func PossibleTypeValues() []Type {
155	return []Type{TypeHive, TypeJobProperties, TypeUSQL}
156}
157
158// TypeEnum enumerates the values for type enum.
159type TypeEnum string
160
161const (
162	// Hive ...
163	Hive TypeEnum = "Hive"
164	// USQL ...
165	USQL TypeEnum = "USql"
166)
167
168// PossibleTypeEnumValues returns an array of possible values for the TypeEnum const type.
169func PossibleTypeEnumValues() []TypeEnum {
170	return []TypeEnum{Hive, USQL}
171}
172
173// DataPath a Data Lake Analytics job data path item.
174type DataPath struct {
175	autorest.Response `json:"-"`
176	// JobID - READ-ONLY; the id of the job this data is for.
177	JobID *uuid.UUID `json:"jobId,omitempty"`
178	// Command - READ-ONLY; the command that this job data relates to.
179	Command *string `json:"command,omitempty"`
180	// Paths - READ-ONLY; the list of paths to all of the job data.
181	Paths *[]string `json:"paths,omitempty"`
182}
183
184// Diagnostics ...
185type Diagnostics struct {
186	// ColumnNumber - READ-ONLY; the column where the error occurred.
187	ColumnNumber *int32 `json:"columnNumber,omitempty"`
188	// End - READ-ONLY; the ending index of the error.
189	End *int32 `json:"end,omitempty"`
190	// LineNumber - READ-ONLY; the line number the error occurred on.
191	LineNumber *int32 `json:"lineNumber,omitempty"`
192	// Message - READ-ONLY; the error message.
193	Message *string `json:"message,omitempty"`
194	// Severity - READ-ONLY; the severity of the error. Possible values include: 'Warning', 'Error', 'Info'
195	Severity SeverityTypes `json:"severity,omitempty"`
196	// Start - READ-ONLY; the starting index of the error.
197	Start *int32 `json:"start,omitempty"`
198}
199
200// ErrorDetails the Data Lake Analytics job error details.
201type ErrorDetails struct {
202	// Description - READ-ONLY; the error message description
203	Description *string `json:"description,omitempty"`
204	// Details - READ-ONLY; the details of the error message.
205	Details *string `json:"details,omitempty"`
206	// EndOffset - READ-ONLY; the end offset in the job where the error was found.
207	EndOffset *int32 `json:"endOffset,omitempty"`
208	// ErrorID - READ-ONLY; the specific identifier for the type of error encountered in the job.
209	ErrorID *string `json:"errorId,omitempty"`
210	// FilePath - READ-ONLY; the path to any supplemental error files, if any.
211	FilePath *string `json:"filePath,omitempty"`
212	// HelpLink - READ-ONLY; the link to MSDN or Azure help for this type of error, if any.
213	HelpLink *string `json:"helpLink,omitempty"`
214	// InternalDiagnostics - READ-ONLY; the internal diagnostic stack trace if the user requesting the job error details has sufficient permissions it will be retrieved, otherwise it will be empty.
215	InternalDiagnostics *string `json:"internalDiagnostics,omitempty"`
216	// LineNumber - READ-ONLY; the specific line number in the job where the error occurred.
217	LineNumber *int32 `json:"lineNumber,omitempty"`
218	// Message - READ-ONLY; the user friendly error message for the failure.
219	Message *string `json:"message,omitempty"`
220	// Resolution - READ-ONLY; the recommended resolution for the failure, if any.
221	Resolution *string `json:"resolution,omitempty"`
222	// InnerError - READ-ONLY; the inner error of this specific job error message, if any.
223	InnerError *InnerError `json:"innerError,omitempty"`
224	// Severity - READ-ONLY; the severity level of the failure. Possible values include: 'Warning', 'Error', 'Info'
225	Severity SeverityTypes `json:"severity,omitempty"`
226	// Source - READ-ONLY; the ultimate source of the failure (usually either SYSTEM or USER).
227	Source *string `json:"source,omitempty"`
228	// StartOffset - READ-ONLY; the start offset in the job where the error was found
229	StartOffset *int32 `json:"startOffset,omitempty"`
230}
231
232// HiveJobProperties ...
233type HiveJobProperties struct {
234	// LogsLocation - READ-ONLY; the Hive logs location
235	LogsLocation *string `json:"logsLocation,omitempty"`
236	// OutputLocation - READ-ONLY; the location of Hive job output files (both execution output and results)
237	OutputLocation *string `json:"outputLocation,omitempty"`
238	// StatementCount - READ-ONLY; the number of statements that will be run based on the script
239	StatementCount *int32 `json:"statementCount,omitempty"`
240	// ExecutedStatementCount - READ-ONLY; the number of statements that have been run based on the script
241	ExecutedStatementCount *int32 `json:"executedStatementCount,omitempty"`
242	// RuntimeVersion - the runtime version of the Data Lake Analytics engine to use for the specific type of job being run.
243	RuntimeVersion *string `json:"runtimeVersion,omitempty"`
244	// Script - the script to run
245	Script *string `json:"script,omitempty"`
246	// Type - Possible values include: 'TypeJobProperties', 'TypeUSQL', 'TypeHive'
247	Type Type `json:"type,omitempty"`
248}
249
250// MarshalJSON is the custom marshaler for HiveJobProperties.
251func (hjp HiveJobProperties) MarshalJSON() ([]byte, error) {
252	hjp.Type = TypeHive
253	objectMap := make(map[string]interface{})
254	if hjp.RuntimeVersion != nil {
255		objectMap["runtimeVersion"] = hjp.RuntimeVersion
256	}
257	if hjp.Script != nil {
258		objectMap["script"] = hjp.Script
259	}
260	if hjp.Type != "" {
261		objectMap["type"] = hjp.Type
262	}
263	return json.Marshal(objectMap)
264}
265
266// AsUSQLJobProperties is the BasicProperties implementation for HiveJobProperties.
267func (hjp HiveJobProperties) AsUSQLJobProperties() (*USQLJobProperties, bool) {
268	return nil, false
269}
270
271// AsHiveJobProperties is the BasicProperties implementation for HiveJobProperties.
272func (hjp HiveJobProperties) AsHiveJobProperties() (*HiveJobProperties, bool) {
273	return &hjp, true
274}
275
276// AsProperties is the BasicProperties implementation for HiveJobProperties.
277func (hjp HiveJobProperties) AsProperties() (*Properties, bool) {
278	return nil, false
279}
280
281// AsBasicProperties is the BasicProperties implementation for HiveJobProperties.
282func (hjp HiveJobProperties) AsBasicProperties() (BasicProperties, bool) {
283	return &hjp, true
284}
285
286// InfoListResult list of jobInfo items.
287type InfoListResult struct {
288	autorest.Response `json:"-"`
289	// Value - READ-ONLY; the list of jobInfo items.
290	Value *[]Information `json:"value,omitempty"`
291	// NextLink - READ-ONLY; the link (url) to the next page of results.
292	NextLink *string `json:"nextLink,omitempty"`
293	// Count - READ-ONLY; the total count of results that are available, but might not be returned in the current page.
294	Count *int64 `json:"count,omitempty"`
295}
296
297// InfoListResultIterator provides access to a complete listing of Information values.
298type InfoListResultIterator struct {
299	i    int
300	page InfoListResultPage
301}
302
303// NextWithContext advances to the next value.  If there was an error making
304// the request the iterator does not advance and the error is returned.
305func (iter *InfoListResultIterator) NextWithContext(ctx context.Context) (err error) {
306	if tracing.IsEnabled() {
307		ctx = tracing.StartSpan(ctx, fqdn+"/InfoListResultIterator.NextWithContext")
308		defer func() {
309			sc := -1
310			if iter.Response().Response.Response != nil {
311				sc = iter.Response().Response.Response.StatusCode
312			}
313			tracing.EndSpan(ctx, sc, err)
314		}()
315	}
316	iter.i++
317	if iter.i < len(iter.page.Values()) {
318		return nil
319	}
320	err = iter.page.NextWithContext(ctx)
321	if err != nil {
322		iter.i--
323		return err
324	}
325	iter.i = 0
326	return nil
327}
328
329// Next advances to the next value.  If there was an error making
330// the request the iterator does not advance and the error is returned.
331// Deprecated: Use NextWithContext() instead.
332func (iter *InfoListResultIterator) Next() error {
333	return iter.NextWithContext(context.Background())
334}
335
336// NotDone returns true if the enumeration should be started or is not yet complete.
337func (iter InfoListResultIterator) NotDone() bool {
338	return iter.page.NotDone() && iter.i < len(iter.page.Values())
339}
340
341// Response returns the raw server response from the last page request.
342func (iter InfoListResultIterator) Response() InfoListResult {
343	return iter.page.Response()
344}
345
346// Value returns the current value or a zero-initialized value if the
347// iterator has advanced beyond the end of the collection.
348func (iter InfoListResultIterator) Value() Information {
349	if !iter.page.NotDone() {
350		return Information{}
351	}
352	return iter.page.Values()[iter.i]
353}
354
355// Creates a new instance of the InfoListResultIterator type.
356func NewInfoListResultIterator(page InfoListResultPage) InfoListResultIterator {
357	return InfoListResultIterator{page: page}
358}
359
360// IsEmpty returns true if the ListResult contains no values.
361func (ilr InfoListResult) IsEmpty() bool {
362	return ilr.Value == nil || len(*ilr.Value) == 0
363}
364
365// infoListResultPreparer prepares a request to retrieve the next set of results.
366// It returns nil if no more results exist.
367func (ilr InfoListResult) infoListResultPreparer(ctx context.Context) (*http.Request, error) {
368	if ilr.NextLink == nil || len(to.String(ilr.NextLink)) < 1 {
369		return nil, nil
370	}
371	return autorest.Prepare((&http.Request{}).WithContext(ctx),
372		autorest.AsJSON(),
373		autorest.AsGet(),
374		autorest.WithBaseURL(to.String(ilr.NextLink)))
375}
376
377// InfoListResultPage contains a page of Information values.
378type InfoListResultPage struct {
379	fn  func(context.Context, InfoListResult) (InfoListResult, error)
380	ilr InfoListResult
381}
382
383// NextWithContext advances to the next page of values.  If there was an error making
384// the request the page does not advance and the error is returned.
385func (page *InfoListResultPage) NextWithContext(ctx context.Context) (err error) {
386	if tracing.IsEnabled() {
387		ctx = tracing.StartSpan(ctx, fqdn+"/InfoListResultPage.NextWithContext")
388		defer func() {
389			sc := -1
390			if page.Response().Response.Response != nil {
391				sc = page.Response().Response.Response.StatusCode
392			}
393			tracing.EndSpan(ctx, sc, err)
394		}()
395	}
396	next, err := page.fn(ctx, page.ilr)
397	if err != nil {
398		return err
399	}
400	page.ilr = next
401	return nil
402}
403
404// Next advances to the next page of values.  If there was an error making
405// the request the page does not advance and the error is returned.
406// Deprecated: Use NextWithContext() instead.
407func (page *InfoListResultPage) Next() error {
408	return page.NextWithContext(context.Background())
409}
410
411// NotDone returns true if the page enumeration should be started or is not yet complete.
412func (page InfoListResultPage) NotDone() bool {
413	return !page.ilr.IsEmpty()
414}
415
416// Response returns the raw server response from the last page request.
417func (page InfoListResultPage) Response() InfoListResult {
418	return page.ilr
419}
420
421// Values returns the slice of values for the current page or nil if there are no values.
422func (page InfoListResultPage) Values() []Information {
423	if page.ilr.IsEmpty() {
424		return nil
425	}
426	return *page.ilr.Value
427}
428
429// Creates a new instance of the InfoListResultPage type.
430func NewInfoListResultPage(getNextPage func(context.Context, InfoListResult) (InfoListResult, error)) InfoListResultPage {
431	return InfoListResultPage{fn: getNextPage}
432}
433
434// Information the common Data Lake Analytics job information properties.
435type Information struct {
436	autorest.Response `json:"-"`
437	// JobID - the job's unique identifier (a GUID).
438	JobID *uuid.UUID `json:"jobId,omitempty"`
439	// Name - the friendly name of the job.
440	Name *string `json:"name,omitempty"`
441	// Type - the job type of the current job (Hive or USql). Possible values include: 'USQL', 'Hive'
442	Type TypeEnum `json:"type,omitempty"`
443	// Submitter - the user or account that submitted the job.
444	Submitter *string `json:"submitter,omitempty"`
445	// ErrorMessage - READ-ONLY; the error message details for the job, if the job failed.
446	ErrorMessage *[]ErrorDetails `json:"errorMessage,omitempty"`
447	// DegreeOfParallelism - the degree of parallelism used for this job. This must be greater than 0.
448	DegreeOfParallelism *int32 `json:"degreeOfParallelism,omitempty"`
449	// DegreeOfParallelismPercent - the degree of parallelism in percentage used for this job.
450	DegreeOfParallelismPercent *float64 `json:"degreeOfParallelismPercent,omitempty"`
451	// Priority - the priority value for the current job. Lower numbers have a higher priority. By default, a job has a priority of 1000. This must be greater than 0.
452	Priority *int32 `json:"priority,omitempty"`
453	// SubmitTime - READ-ONLY; the time the job was submitted to the service.
454	SubmitTime *date.Time `json:"submitTime,omitempty"`
455	// StartTime - READ-ONLY; the start time of the job.
456	StartTime *date.Time `json:"startTime,omitempty"`
457	// EndTime - READ-ONLY; the completion time of the job.
458	EndTime *date.Time `json:"endTime,omitempty"`
459	// State - READ-ONLY; the job state. When the job is in the Ended state, refer to Result and ErrorMessage for details. Possible values include: 'StateAccepted', 'StateCompiling', 'StateEnded', 'StateNew', 'StateQueued', 'StateRunning', 'StateScheduling', 'StateStarting', 'StatePaused', 'StateWaitingForCapacity'
460	State State `json:"state,omitempty"`
461	// Result - READ-ONLY; the result of job execution or the current result of the running job. Possible values include: 'None', 'Succeeded', 'Cancelled', 'Failed'
462	Result Result `json:"result,omitempty"`
463	// LogFolder - READ-ONLY; the log folder path to use in the following format: adl://<accountName>.azuredatalakestore.net/system/jobservice/jobs/Usql/2016/03/13/17/18/5fe51957-93bc-4de0-8ddc-c5a4753b068b/logs/.
464	LogFolder *string `json:"logFolder,omitempty"`
465	// LogFilePatterns - the list of log file name patterns to find in the logFolder. '*' is the only matching character allowed. Example format: jobExecution*.log or *mylog*.txt
466	LogFilePatterns *[]string `json:"logFilePatterns,omitempty"`
467	// StateAuditRecords - READ-ONLY; the job state audit records, indicating when various operations have been performed on this job.
468	StateAuditRecords *[]StateAuditRecord `json:"stateAuditRecords,omitempty"`
469	// HierarchyQueueNode - READ-ONLY; the name of hierarchy queue node this job is assigned to, null if job has not been assigned yet or the account doesn't have hierarchy queue.
470	HierarchyQueueNode *string `json:"hierarchyQueueNode,omitempty"`
471	// Properties - the job specific properties.
472	Properties BasicProperties `json:"properties,omitempty"`
473}
474
475// UnmarshalJSON is the custom unmarshaler for Information struct.
476func (i *Information) UnmarshalJSON(body []byte) error {
477	var m map[string]*json.RawMessage
478	err := json.Unmarshal(body, &m)
479	if err != nil {
480		return err
481	}
482	for k, v := range m {
483		switch k {
484		case "jobId":
485			if v != nil {
486				var jobID uuid.UUID
487				err = json.Unmarshal(*v, &jobID)
488				if err != nil {
489					return err
490				}
491				i.JobID = &jobID
492			}
493		case "name":
494			if v != nil {
495				var name string
496				err = json.Unmarshal(*v, &name)
497				if err != nil {
498					return err
499				}
500				i.Name = &name
501			}
502		case "type":
503			if v != nil {
504				var typeVar TypeEnum
505				err = json.Unmarshal(*v, &typeVar)
506				if err != nil {
507					return err
508				}
509				i.Type = typeVar
510			}
511		case "submitter":
512			if v != nil {
513				var submitter string
514				err = json.Unmarshal(*v, &submitter)
515				if err != nil {
516					return err
517				}
518				i.Submitter = &submitter
519			}
520		case "errorMessage":
521			if v != nil {
522				var errorMessage []ErrorDetails
523				err = json.Unmarshal(*v, &errorMessage)
524				if err != nil {
525					return err
526				}
527				i.ErrorMessage = &errorMessage
528			}
529		case "degreeOfParallelism":
530			if v != nil {
531				var degreeOfParallelism int32
532				err = json.Unmarshal(*v, &degreeOfParallelism)
533				if err != nil {
534					return err
535				}
536				i.DegreeOfParallelism = &degreeOfParallelism
537			}
538		case "degreeOfParallelismPercent":
539			if v != nil {
540				var degreeOfParallelismPercent float64
541				err = json.Unmarshal(*v, &degreeOfParallelismPercent)
542				if err != nil {
543					return err
544				}
545				i.DegreeOfParallelismPercent = &degreeOfParallelismPercent
546			}
547		case "priority":
548			if v != nil {
549				var priority int32
550				err = json.Unmarshal(*v, &priority)
551				if err != nil {
552					return err
553				}
554				i.Priority = &priority
555			}
556		case "submitTime":
557			if v != nil {
558				var submitTime date.Time
559				err = json.Unmarshal(*v, &submitTime)
560				if err != nil {
561					return err
562				}
563				i.SubmitTime = &submitTime
564			}
565		case "startTime":
566			if v != nil {
567				var startTime date.Time
568				err = json.Unmarshal(*v, &startTime)
569				if err != nil {
570					return err
571				}
572				i.StartTime = &startTime
573			}
574		case "endTime":
575			if v != nil {
576				var endTime date.Time
577				err = json.Unmarshal(*v, &endTime)
578				if err != nil {
579					return err
580				}
581				i.EndTime = &endTime
582			}
583		case "state":
584			if v != nil {
585				var state State
586				err = json.Unmarshal(*v, &state)
587				if err != nil {
588					return err
589				}
590				i.State = state
591			}
592		case "result":
593			if v != nil {
594				var resultVar Result
595				err = json.Unmarshal(*v, &resultVar)
596				if err != nil {
597					return err
598				}
599				i.Result = resultVar
600			}
601		case "logFolder":
602			if v != nil {
603				var logFolder string
604				err = json.Unmarshal(*v, &logFolder)
605				if err != nil {
606					return err
607				}
608				i.LogFolder = &logFolder
609			}
610		case "logFilePatterns":
611			if v != nil {
612				var logFilePatterns []string
613				err = json.Unmarshal(*v, &logFilePatterns)
614				if err != nil {
615					return err
616				}
617				i.LogFilePatterns = &logFilePatterns
618			}
619		case "stateAuditRecords":
620			if v != nil {
621				var stateAuditRecords []StateAuditRecord
622				err = json.Unmarshal(*v, &stateAuditRecords)
623				if err != nil {
624					return err
625				}
626				i.StateAuditRecords = &stateAuditRecords
627			}
628		case "hierarchyQueueNode":
629			if v != nil {
630				var hierarchyQueueNode string
631				err = json.Unmarshal(*v, &hierarchyQueueNode)
632				if err != nil {
633					return err
634				}
635				i.HierarchyQueueNode = &hierarchyQueueNode
636			}
637		case "properties":
638			if v != nil {
639				properties, err := unmarshalBasicProperties(*v)
640				if err != nil {
641					return err
642				}
643				i.Properties = properties
644			}
645		}
646	}
647
648	return nil
649}
650
651// InnerError the Data Lake Analytics job error details.
652type InnerError struct {
653	// DiagnosticCode - READ-ONLY; the diagnostic error code.
654	DiagnosticCode *int32 `json:"diagnosticCode,omitempty"`
655	// Severity - READ-ONLY; the severity level of the failure. Possible values include: 'Warning', 'Error', 'Info'
656	Severity SeverityTypes `json:"severity,omitempty"`
657	// Details - READ-ONLY; the details of the error message.
658	Details *string `json:"details,omitempty"`
659	// Component - READ-ONLY; the component that failed.
660	Component *string `json:"component,omitempty"`
661	// ErrorID - READ-ONLY; the specific identifier for the type of error encountered in the job.
662	ErrorID *string `json:"errorId,omitempty"`
663	// HelpLink - READ-ONLY; the link to MSDN or Azure help for this type of error, if any.
664	HelpLink *string `json:"helpLink,omitempty"`
665	// InternalDiagnostics - READ-ONLY; the internal diagnostic stack trace if the user requesting the job error details has sufficient permissions it will be retrieved, otherwise it will be empty.
666	InternalDiagnostics *string `json:"internalDiagnostics,omitempty"`
667	// Message - READ-ONLY; the user friendly error message for the failure.
668	Message *string `json:"message,omitempty"`
669	// Resolution - READ-ONLY; the recommended resolution for the failure, if any.
670	Resolution *string `json:"resolution,omitempty"`
671	// Source - READ-ONLY; the ultimate source of the failure (usually either SYSTEM or USER).
672	Source *string `json:"source,omitempty"`
673	// Description - READ-ONLY; the error message description
674	Description *string `json:"description,omitempty"`
675}
676
677// BasicProperties the common Data Lake Analytics job properties.
678type BasicProperties interface {
679	AsUSQLJobProperties() (*USQLJobProperties, bool)
680	AsHiveJobProperties() (*HiveJobProperties, bool)
681	AsProperties() (*Properties, bool)
682}
683
684// Properties the common Data Lake Analytics job properties.
685type Properties struct {
686	// RuntimeVersion - the runtime version of the Data Lake Analytics engine to use for the specific type of job being run.
687	RuntimeVersion *string `json:"runtimeVersion,omitempty"`
688	// Script - the script to run
689	Script *string `json:"script,omitempty"`
690	// Type - Possible values include: 'TypeJobProperties', 'TypeUSQL', 'TypeHive'
691	Type Type `json:"type,omitempty"`
692}
693
694func unmarshalBasicProperties(body []byte) (BasicProperties, error) {
695	var m map[string]interface{}
696	err := json.Unmarshal(body, &m)
697	if err != nil {
698		return nil, err
699	}
700
701	switch m["type"] {
702	case string(TypeUSQL):
703		var usjp USQLJobProperties
704		err := json.Unmarshal(body, &usjp)
705		return usjp, err
706	case string(TypeHive):
707		var hjp HiveJobProperties
708		err := json.Unmarshal(body, &hjp)
709		return hjp, err
710	default:
711		var p Properties
712		err := json.Unmarshal(body, &p)
713		return p, err
714	}
715}
716func unmarshalBasicPropertiesArray(body []byte) ([]BasicProperties, error) {
717	var rawMessages []*json.RawMessage
718	err := json.Unmarshal(body, &rawMessages)
719	if err != nil {
720		return nil, err
721	}
722
723	pArray := make([]BasicProperties, len(rawMessages))
724
725	for index, rawMessage := range rawMessages {
726		p, err := unmarshalBasicProperties(*rawMessage)
727		if err != nil {
728			return nil, err
729		}
730		pArray[index] = p
731	}
732	return pArray, nil
733}
734
735// MarshalJSON is the custom marshaler for Properties.
736func (p Properties) MarshalJSON() ([]byte, error) {
737	p.Type = TypeJobProperties
738	objectMap := make(map[string]interface{})
739	if p.RuntimeVersion != nil {
740		objectMap["runtimeVersion"] = p.RuntimeVersion
741	}
742	if p.Script != nil {
743		objectMap["script"] = p.Script
744	}
745	if p.Type != "" {
746		objectMap["type"] = p.Type
747	}
748	return json.Marshal(objectMap)
749}
750
751// AsUSQLJobProperties is the BasicProperties implementation for Properties.
752func (p Properties) AsUSQLJobProperties() (*USQLJobProperties, bool) {
753	return nil, false
754}
755
756// AsHiveJobProperties is the BasicProperties implementation for Properties.
757func (p Properties) AsHiveJobProperties() (*HiveJobProperties, bool) {
758	return nil, false
759}
760
761// AsProperties is the BasicProperties implementation for Properties.
762func (p Properties) AsProperties() (*Properties, bool) {
763	return &p, true
764}
765
766// AsBasicProperties is the BasicProperties implementation for Properties.
767func (p Properties) AsBasicProperties() (BasicProperties, bool) {
768	return &p, true
769}
770
771// Resource the Data Lake Analytics job resources.
772type Resource struct {
773	// Name - the name of the resource.
774	Name *string `json:"name,omitempty"`
775	// ResourcePath - the path to the resource.
776	ResourcePath *string `json:"resourcePath,omitempty"`
777	// Type - the job resource type. Possible values include: 'VertexResource', 'JobManagerResource', 'StatisticsResource', 'VertexResourceInUserFolder', 'JobManagerResourceInUserFolder', 'StatisticsResourceInUserFolder'
778	Type ResourceType `json:"type,omitempty"`
779}
780
781// StateAuditRecord the Data Lake Analytics job state audit records for tracking the lifecycle of a job.
782type StateAuditRecord struct {
783	// NewState - READ-ONLY; the new state the job is in.
784	NewState *string `json:"newState,omitempty"`
785	// TimeStamp - READ-ONLY; the time stamp that the state change took place.
786	TimeStamp *date.Time `json:"timeStamp,omitempty"`
787	// RequestedByUser - READ-ONLY; the user who requests the change.
788	RequestedByUser *string `json:"requestedByUser,omitempty"`
789	// Details - READ-ONLY;  the details of the audit log.
790	Details *string `json:"details,omitempty"`
791}
792
793// Statistics the Data Lake Analytics job execution statistics.
794type Statistics struct {
795	autorest.Response `json:"-"`
796	// LastUpdateTimeUtc - READ-ONLY; the last update time for the statistics.
797	LastUpdateTimeUtc *date.Time `json:"lastUpdateTimeUtc,omitempty"`
798	// FinalizingTimeUtc - READ-ONLY; the job finalizing start time.
799	FinalizingTimeUtc *date.Time `json:"finalizingTimeUtc,omitempty"`
800	// Stages - READ-ONLY; the list of stages for the job.
801	Stages *[]StatisticsVertexStage `json:"stages,omitempty"`
802}
803
804// StatisticsVertexStage the Data Lake Analytics job statistics vertex stage information.
805type StatisticsVertexStage struct {
806	// DataRead - READ-ONLY; the amount of data read, in bytes.
807	DataRead *int64 `json:"dataRead,omitempty"`
808	// DataReadCrossPod - READ-ONLY; the amount of data read across multiple pods, in bytes.
809	DataReadCrossPod *int64 `json:"dataReadCrossPod,omitempty"`
810	// DataReadIntraPod - READ-ONLY; the amount of data read in one pod, in bytes.
811	DataReadIntraPod *int64 `json:"dataReadIntraPod,omitempty"`
812	// DataToRead - READ-ONLY; the amount of data remaining to be read, in bytes.
813	DataToRead *int64 `json:"dataToRead,omitempty"`
814	// DataWritten - READ-ONLY; the amount of data written, in bytes.
815	DataWritten *int64 `json:"dataWritten,omitempty"`
816	// DuplicateDiscardCount - READ-ONLY; the number of duplicates that were discarded.
817	DuplicateDiscardCount *int32 `json:"duplicateDiscardCount,omitempty"`
818	// FailedCount - READ-ONLY; the number of failures that occurred in this stage.
819	FailedCount *int32 `json:"failedCount,omitempty"`
820	// MaxVertexDataRead - READ-ONLY; the maximum amount of data read in a single vertex, in bytes.
821	MaxVertexDataRead *int64 `json:"maxVertexDataRead,omitempty"`
822	// MinVertexDataRead - READ-ONLY; the minimum amount of data read in a single vertex, in bytes.
823	MinVertexDataRead *int64 `json:"minVertexDataRead,omitempty"`
824	// ReadFailureCount - READ-ONLY; the number of read failures in this stage.
825	ReadFailureCount *int32 `json:"readFailureCount,omitempty"`
826	// RevocationCount - READ-ONLY; the number of vertices that were revoked during this stage.
827	RevocationCount *int32 `json:"revocationCount,omitempty"`
828	// RunningCount - READ-ONLY; the number of currently running vertices in this stage.
829	RunningCount *int32 `json:"runningCount,omitempty"`
830	// ScheduledCount - READ-ONLY; the number of currently scheduled vertices in this stage
831	ScheduledCount *int32 `json:"scheduledCount,omitempty"`
832	// StageName - READ-ONLY; the name of this stage in job execution.
833	StageName *string `json:"stageName,omitempty"`
834	// SucceededCount - READ-ONLY; the number of vertices that succeeded in this stage.
835	SucceededCount *int32 `json:"succeededCount,omitempty"`
836	// TempDataWritten - READ-ONLY; the amount of temporary data written, in bytes.
837	TempDataWritten *int64 `json:"tempDataWritten,omitempty"`
838	// TotalCount - READ-ONLY; the total vertex count for this stage.
839	TotalCount *int32 `json:"totalCount,omitempty"`
840	// TotalFailedTime - READ-ONLY; the amount of time that failed vertices took up in this stage.
841	TotalFailedTime *string `json:"totalFailedTime,omitempty"`
842	// TotalProgress - READ-ONLY; the current progress of this stage, as a percentage.
843	TotalProgress *int32 `json:"totalProgress,omitempty"`
844	// TotalSucceededTime - READ-ONLY; the amount of time all successful vertices took in this stage.
845	TotalSucceededTime *string `json:"totalSucceededTime,omitempty"`
846}
847
848// USQLJobProperties ...
849type USQLJobProperties struct {
850	// Resources - the list of resources that are required by the job
851	Resources *[]Resource `json:"resources,omitempty"`
852	// Statistics - the job specific statistics.
853	Statistics *Statistics `json:"statistics,omitempty"`
854	// DebugData - the job specific debug data locations.
855	DebugData *DataPath `json:"debugData,omitempty"`
856	// Diagnostics - the diagnostics for the job.
857	Diagnostics *[]Diagnostics `json:"diagnostics,omitempty"`
858	// AlgebraFilePath - READ-ONLY; the algebra file path after the job has completed
859	AlgebraFilePath *string `json:"algebraFilePath,omitempty"`
860	// TotalCompilationTime - READ-ONLY; the total time this job spent compiling. This value should not be set by the user and will be ignored if it is.
861	TotalCompilationTime *string `json:"totalCompilationTime,omitempty"`
862	// TotalPauseTime - READ-ONLY; the total time this job spent paused. This value should not be set by the user and will be ignored if it is.
863	TotalPauseTime *string `json:"totalPauseTime,omitempty"`
864	// TotalQueuedTime - READ-ONLY; the total time this job spent queued. This value should not be set by the user and will be ignored if it is.
865	TotalQueuedTime *string `json:"totalQueuedTime,omitempty"`
866	// TotalRunningTime - READ-ONLY; the total time this job spent executing. This value should not be set by the user and will be ignored if it is.
867	TotalRunningTime *string `json:"totalRunningTime,omitempty"`
868	// RootProcessNodeID - READ-ONLY; the ID used to identify the job manager coordinating job execution. This value should not be set by the user and will be ignored if it is.
869	RootProcessNodeID *string `json:"rootProcessNodeId,omitempty"`
870	// YarnApplicationID - READ-ONLY; the ID used to identify the yarn application executing the job. This value should not be set by the user and will be ignored if it is.
871	YarnApplicationID *string `json:"yarnApplicationId,omitempty"`
872	// YarnApplicationTimeStamp - READ-ONLY; the timestamp (in ticks) for the yarn application executing the job. This value should not be set by the user and will be ignored if it is.
873	YarnApplicationTimeStamp *int64 `json:"yarnApplicationTimeStamp,omitempty"`
874	// CompileMode - the compile mode for the job. Possible values include: 'Semantic', 'Full', 'SingleBox'
875	CompileMode CompileMode `json:"compileMode,omitempty"`
876	// RuntimeVersion - the runtime version of the Data Lake Analytics engine to use for the specific type of job being run.
877	RuntimeVersion *string `json:"runtimeVersion,omitempty"`
878	// Script - the script to run
879	Script *string `json:"script,omitempty"`
880	// Type - Possible values include: 'TypeJobProperties', 'TypeUSQL', 'TypeHive'
881	Type Type `json:"type,omitempty"`
882}
883
884// MarshalJSON is the custom marshaler for USQLJobProperties.
885func (usjp USQLJobProperties) MarshalJSON() ([]byte, error) {
886	usjp.Type = TypeUSQL
887	objectMap := make(map[string]interface{})
888	if usjp.Resources != nil {
889		objectMap["resources"] = usjp.Resources
890	}
891	if usjp.Statistics != nil {
892		objectMap["statistics"] = usjp.Statistics
893	}
894	if usjp.DebugData != nil {
895		objectMap["debugData"] = usjp.DebugData
896	}
897	if usjp.Diagnostics != nil {
898		objectMap["diagnostics"] = usjp.Diagnostics
899	}
900	if usjp.CompileMode != "" {
901		objectMap["compileMode"] = usjp.CompileMode
902	}
903	if usjp.RuntimeVersion != nil {
904		objectMap["runtimeVersion"] = usjp.RuntimeVersion
905	}
906	if usjp.Script != nil {
907		objectMap["script"] = usjp.Script
908	}
909	if usjp.Type != "" {
910		objectMap["type"] = usjp.Type
911	}
912	return json.Marshal(objectMap)
913}
914
915// AsUSQLJobProperties is the BasicProperties implementation for USQLJobProperties.
916func (usjp USQLJobProperties) AsUSQLJobProperties() (*USQLJobProperties, bool) {
917	return &usjp, true
918}
919
920// AsHiveJobProperties is the BasicProperties implementation for USQLJobProperties.
921func (usjp USQLJobProperties) AsHiveJobProperties() (*HiveJobProperties, bool) {
922	return nil, false
923}
924
925// AsProperties is the BasicProperties implementation for USQLJobProperties.
926func (usjp USQLJobProperties) AsProperties() (*Properties, bool) {
927	return nil, false
928}
929
930// AsBasicProperties is the BasicProperties implementation for USQLJobProperties.
931func (usjp USQLJobProperties) AsBasicProperties() (BasicProperties, bool) {
932	return &usjp, true
933}
934