-
Notifications
You must be signed in to change notification settings - Fork 40
/
model_asrtask.go
94 lines (80 loc) · 2.98 KB
/
model_asrtask.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
package replicationjobs
import (
"encoding/json"
"fmt"
"time"
"github.com/hashicorp/go-azure-helpers/lang/dates"
)
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See NOTICE.txt in the project root for license information.
type ASRTask struct {
AllowedActions *[]string `json:"allowedActions,omitempty"`
CustomDetails TaskTypeDetails `json:"customDetails"`
EndTime *string `json:"endTime,omitempty"`
Errors *[]JobErrorDetails `json:"errors,omitempty"`
FriendlyName *string `json:"friendlyName,omitempty"`
GroupTaskCustomDetails GroupTaskDetails `json:"groupTaskCustomDetails"`
Name *string `json:"name,omitempty"`
StartTime *string `json:"startTime,omitempty"`
State *string `json:"state,omitempty"`
StateDescription *string `json:"stateDescription,omitempty"`
TaskId *string `json:"taskId,omitempty"`
TaskType *string `json:"taskType,omitempty"`
}
func (o *ASRTask) GetEndTimeAsTime() (*time.Time, error) {
if o.EndTime == nil {
return nil, nil
}
return dates.ParseAsFormat(o.EndTime, "2006-01-02T15:04:05Z07:00")
}
func (o *ASRTask) SetEndTimeAsTime(input time.Time) {
formatted := input.Format("2006-01-02T15:04:05Z07:00")
o.EndTime = &formatted
}
func (o *ASRTask) GetStartTimeAsTime() (*time.Time, error) {
if o.StartTime == nil {
return nil, nil
}
return dates.ParseAsFormat(o.StartTime, "2006-01-02T15:04:05Z07:00")
}
func (o *ASRTask) SetStartTimeAsTime(input time.Time) {
formatted := input.Format("2006-01-02T15:04:05Z07:00")
o.StartTime = &formatted
}
var _ json.Unmarshaler = &ASRTask{}
func (s *ASRTask) UnmarshalJSON(bytes []byte) error {
type alias ASRTask
var decoded alias
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling into ASRTask: %+v", err)
}
s.AllowedActions = decoded.AllowedActions
s.EndTime = decoded.EndTime
s.Errors = decoded.Errors
s.FriendlyName = decoded.FriendlyName
s.Name = decoded.Name
s.StartTime = decoded.StartTime
s.State = decoded.State
s.StateDescription = decoded.StateDescription
s.TaskId = decoded.TaskId
s.TaskType = decoded.TaskType
var temp map[string]json.RawMessage
if err := json.Unmarshal(bytes, &temp); err != nil {
return fmt.Errorf("unmarshaling ASRTask into map[string]json.RawMessage: %+v", err)
}
if v, ok := temp["customDetails"]; ok {
impl, err := unmarshalTaskTypeDetailsImplementation(v)
if err != nil {
return fmt.Errorf("unmarshaling field 'CustomDetails' for 'ASRTask': %+v", err)
}
s.CustomDetails = impl
}
if v, ok := temp["groupTaskCustomDetails"]; ok {
impl, err := unmarshalGroupTaskDetailsImplementation(v)
if err != nil {
return fmt.Errorf("unmarshaling field 'GroupTaskCustomDetails' for 'ASRTask': %+v", err)
}
s.GroupTaskCustomDetails = impl
}
return nil
}