-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathcollections.go
162 lines (136 loc) · 4.01 KB
/
collections.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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package gocbcore
import (
"encoding/json"
"strconv"
"time"
)
const (
unknownCid = uint32(0xFFFFFFFF)
pendingCid = uint32(0xFFFFFFFE)
)
// ManifestCollection is the representation of a collection within a manifest.
type ManifestCollection struct {
UID uint32
Name string
MaxTTL int32
History *bool
}
// UnmarshalJSON is a custom implementation of json unmarshaling.
func (item *ManifestCollection) UnmarshalJSON(data []byte) error {
decData := struct {
UID string `json:"uid"`
Name string `json:"name"`
MaxTTL int32 `json:"maxTTL"`
History *bool `json:"history"`
}{}
if err := json.Unmarshal(data, &decData); err != nil {
return err
}
decUID, err := strconv.ParseUint(decData.UID, 16, 32)
if err != nil {
return err
}
item.UID = uint32(decUID)
item.Name = decData.Name
item.MaxTTL = decData.MaxTTL
item.History = decData.History
return nil
}
// ManifestScope is the representation of a scope within a manifest.
type ManifestScope struct {
UID uint32
Name string
Collections []ManifestCollection
}
// UnmarshalJSON is a custom implementation of json unmarshaling.
func (item *ManifestScope) UnmarshalJSON(data []byte) error {
decData := struct {
UID string `json:"uid"`
Name string `json:"name"`
Collections []ManifestCollection `json:"collections"`
}{}
if err := json.Unmarshal(data, &decData); err != nil {
return err
}
decUID, err := strconv.ParseUint(decData.UID, 16, 32)
if err != nil {
return err
}
item.UID = uint32(decUID)
item.Name = decData.Name
item.Collections = decData.Collections
return nil
}
// Manifest is the representation of a collections manifest.
type Manifest struct {
UID uint64
Scopes []ManifestScope
}
// UnmarshalJSON is a custom implementation of json unmarshaling.
func (item *Manifest) UnmarshalJSON(data []byte) error {
decData := struct {
UID string `json:"uid"`
Scopes []ManifestScope `json:"scopes"`
}{}
if err := json.Unmarshal(data, &decData); err != nil {
return err
}
decUID, err := strconv.ParseUint(decData.UID, 16, 64)
if err != nil {
return err
}
item.UID = decUID
item.Scopes = decData.Scopes
return nil
}
// GetCollectionManifestOptions are the options available to the GetCollectionManifest command.
type GetCollectionManifestOptions struct {
TraceContext RequestSpanContext
RetryStrategy RetryStrategy
Deadline time.Time
// Internal: This should never be used and is not supported.
User string
}
// GetAllCollectionManifestsOptions are the options available to the GetAllCollectionManifests command.
type GetAllCollectionManifestsOptions struct {
TraceContext RequestSpanContext
RetryStrategy RetryStrategy
Deadline time.Time
// Internal: This should never be used and is not supported.
User string
}
// GetCollectionIDOptions are the options available to the GetCollectionID command.
type GetCollectionIDOptions struct {
RetryStrategy RetryStrategy
TraceContext RequestSpanContext
Deadline time.Time
// Internal: This should never be used and is not supported.
User string
}
// GetCollectionIDResult encapsulates the result of a GetCollectionID operation.
type GetCollectionIDResult struct {
ManifestID uint64
CollectionID uint32
// Internal: This should never be used and is not supported.
Internal struct {
ResourceUnits *ResourceUnitResult
}
}
// GetCollectionManifestResult encapsulates the result of a GetCollectionManifest operation.
type GetCollectionManifestResult struct {
Manifest []byte
// Internal: This should never be used and is not supported.
Internal struct {
ResourceUnits *ResourceUnitResult
}
}
// SingleServerManifestResult encapsulates the result from a single server when using the GetAllCollectionManifests
// operation.
type SingleServerManifestResult struct {
Manifest []byte
Error error
}
// GetAllCollectionManifestsResult encapsulates the result of a GetAllCollectionManifests operation.
type GetAllCollectionManifestsResult struct {
Manifests map[string]SingleServerManifestResult
}