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