forked from stmcginnis/gofish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataprotectionlineofservice.go
115 lines (102 loc) · 3.87 KB
/
dataprotectionlineofservice.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
//
// SPDX-License-Identifier: BSD-3-Clause
//
package swordfish
import (
"encoding/json"
"github.com/stmcginnis/gofish/common"
)
// DataProtectionLineOfService describes a replica that protects data from loss.
// The requirements must be met collectively by the communication path and the
// replica.
type DataProtectionLineOfService struct {
common.Entity
// ODataContext is the odata context.
ODataContext string `json:"@odata.context"`
// ODataEtag is the odata etag.
ODataEtag string `json:"@odata.etag"`
// ODataID is the odata identifier.
ODataID string `json:"@odata.id"`
// ODataType is the odata type.
ODataType string `json:"@odata.type"`
// Description provides a description of this resource.
Description string
// IsIsolated is True shall indicate that the replica is in a separate
// fault domain from its source. The default value of this property is
// false.
IsIsolated bool
// MinLifetime shall be an ISO 8601 duration that specifies
// the minimum required lifetime of the replica. Note: The maximum number
// of replicas can be determined using this value together with the
// replicaSchedule.
MinLifetime string
// RecoveryGeographicObjective specifies the geographic scope of the failure
// domain.
RecoveryGeographicObjective FailureDomainScope
// RecoveryPointObjectiveTime shall be an ISO 8601 duration that specifies
// the maximum time over which source data may be lost on failure. In the
// case that IsIsolated = false, failure of the domain is not a
// consideration.
RecoveryPointObjectiveTime string
// RecoveryTimeObjective shall be an enumeration that
// indicates the maximum time required to access an alternate replica. In
// the case that IsIsolated = false, failure of the domain is not a
// consideration.
RecoveryTimeObjective RecoveryAccessScope
// ReplicaAccessLocation is used if the data access location of the
// replica is required to be at a specific location. Note 1: The
// location value may be granular. Note 2: A value may be required for
// some regulatory compliance.
ReplicaAccessLocation common.Location
// ReplicaClassOfService shall reference the class of
// service that defines the required service levels of the replica.
ReplicaClassOfService ClassOfService
// ReplicaType is the type of replica.
ReplicaType ReplicaType
// Schedule if a replica is made periodically, the value shall define
// the schedule.
Schedule common.Schedule
}
// GetDataProtectionLineOfService will get a DataProtectionLineOfService instance from the service.
func GetDataProtectionLineOfService(c common.Client, uri string) (*DataProtectionLineOfService, error) {
resp, err := c.Get(uri)
if err != nil {
return nil, err
}
defer resp.Body.Close()
var dataprotectionlineofservice DataProtectionLineOfService
err = json.NewDecoder(resp.Body).Decode(&dataprotectionlineofservice)
if err != nil {
return nil, err
}
dataprotectionlineofservice.SetClient(c)
return &dataprotectionlineofservice, nil
}
// ListReferencedDataProtectionLineOfServices gets the collection of DataProtectionLineOfService from
// a provided reference.
func ListReferencedDataProtectionLineOfServices(c common.Client, link string) ([]*DataProtectionLineOfService, error) {
var result []*DataProtectionLineOfService
if link == "" {
return result, nil
}
links, err := common.GetCollection(c, link)
if err != nil {
return result, err
}
for _, dataprotectionlineofserviceLink := range links.ItemLinks {
dataprotectionlineofservice, err := GetDataProtectionLineOfService(c, dataprotectionlineofserviceLink)
if err != nil {
return result, err
}
result = append(result, dataprotectionlineofservice)
}
return result, nil
}
// ReplicaRequest is a request for a replica.
type ReplicaRequest struct {
// ReplicaName shall be the names of the replica.
ReplicaName string
// ReplicaSource shall reference a resource to be
// replicated.
ReplicaSource common.Link
}