-
Notifications
You must be signed in to change notification settings - Fork 46
/
model_migrationitemproperties.go
103 lines (90 loc) · 4.77 KB
/
model_migrationitemproperties.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
package replicationmigrationitems
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 MigrationItemProperties struct {
AllowedOperations *[]MigrationItemOperation `json:"allowedOperations,omitempty"`
CriticalJobHistory *[]CriticalJobHistoryDetails `json:"criticalJobHistory,omitempty"`
CurrentJob *CurrentJobDetails `json:"currentJob,omitempty"`
EventCorrelationId *string `json:"eventCorrelationId,omitempty"`
Health *ProtectionHealth `json:"health,omitempty"`
HealthErrors *[]HealthError `json:"healthErrors,omitempty"`
LastMigrationStatus *string `json:"lastMigrationStatus,omitempty"`
LastMigrationTime *string `json:"lastMigrationTime,omitempty"`
LastTestMigrationStatus *string `json:"lastTestMigrationStatus,omitempty"`
LastTestMigrationTime *string `json:"lastTestMigrationTime,omitempty"`
MachineName *string `json:"machineName,omitempty"`
MigrationState *MigrationState `json:"migrationState,omitempty"`
MigrationStateDescription *string `json:"migrationStateDescription,omitempty"`
PolicyFriendlyName *string `json:"policyFriendlyName,omitempty"`
PolicyId *string `json:"policyId,omitempty"`
ProviderSpecificDetails MigrationProviderSpecificSettings `json:"providerSpecificDetails"`
RecoveryServicesProviderId *string `json:"recoveryServicesProviderId,omitempty"`
ReplicationStatus *string `json:"replicationStatus,omitempty"`
TestMigrateState *TestMigrationState `json:"testMigrateState,omitempty"`
TestMigrateStateDescription *string `json:"testMigrateStateDescription,omitempty"`
}
func (o *MigrationItemProperties) GetLastMigrationTimeAsTime() (*time.Time, error) {
if o.LastMigrationTime == nil {
return nil, nil
}
return dates.ParseAsFormat(o.LastMigrationTime, "2006-01-02T15:04:05Z07:00")
}
func (o *MigrationItemProperties) SetLastMigrationTimeAsTime(input time.Time) {
formatted := input.Format("2006-01-02T15:04:05Z07:00")
o.LastMigrationTime = &formatted
}
func (o *MigrationItemProperties) GetLastTestMigrationTimeAsTime() (*time.Time, error) {
if o.LastTestMigrationTime == nil {
return nil, nil
}
return dates.ParseAsFormat(o.LastTestMigrationTime, "2006-01-02T15:04:05Z07:00")
}
func (o *MigrationItemProperties) SetLastTestMigrationTimeAsTime(input time.Time) {
formatted := input.Format("2006-01-02T15:04:05Z07:00")
o.LastTestMigrationTime = &formatted
}
var _ json.Unmarshaler = &MigrationItemProperties{}
func (s *MigrationItemProperties) UnmarshalJSON(bytes []byte) error {
type alias MigrationItemProperties
var decoded alias
if err := json.Unmarshal(bytes, &decoded); err != nil {
return fmt.Errorf("unmarshaling into MigrationItemProperties: %+v", err)
}
s.AllowedOperations = decoded.AllowedOperations
s.CriticalJobHistory = decoded.CriticalJobHistory
s.CurrentJob = decoded.CurrentJob
s.EventCorrelationId = decoded.EventCorrelationId
s.Health = decoded.Health
s.HealthErrors = decoded.HealthErrors
s.LastMigrationStatus = decoded.LastMigrationStatus
s.LastMigrationTime = decoded.LastMigrationTime
s.LastTestMigrationStatus = decoded.LastTestMigrationStatus
s.LastTestMigrationTime = decoded.LastTestMigrationTime
s.MachineName = decoded.MachineName
s.MigrationState = decoded.MigrationState
s.MigrationStateDescription = decoded.MigrationStateDescription
s.PolicyFriendlyName = decoded.PolicyFriendlyName
s.PolicyId = decoded.PolicyId
s.RecoveryServicesProviderId = decoded.RecoveryServicesProviderId
s.ReplicationStatus = decoded.ReplicationStatus
s.TestMigrateState = decoded.TestMigrateState
s.TestMigrateStateDescription = decoded.TestMigrateStateDescription
var temp map[string]json.RawMessage
if err := json.Unmarshal(bytes, &temp); err != nil {
return fmt.Errorf("unmarshaling MigrationItemProperties into map[string]json.RawMessage: %+v", err)
}
if v, ok := temp["providerSpecificDetails"]; ok {
impl, err := unmarshalMigrationProviderSpecificSettingsImplementation(v)
if err != nil {
return fmt.Errorf("unmarshaling field 'ProviderSpecificDetails' for 'MigrationItemProperties': %+v", err)
}
s.ProviderSpecificDetails = impl
}
return nil
}