-
Notifications
You must be signed in to change notification settings - Fork 627
/
Copy pathazurerepositorysettings.go
262 lines (235 loc) · 8.36 KB
/
azurerepositorysettings.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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
// Licensed to Elasticsearch B.V. under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Elasticsearch B.V. licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// Code generated from the elasticsearch-specification DO NOT EDIT.
// https://github.com/elastic/elasticsearch-specification/tree/ea991724f4dd4f90c496eff547d3cc2e6529f509
package types
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"strconv"
)
// AzureRepositorySettings type.
//
// https://github.com/elastic/elasticsearch-specification/blob/ea991724f4dd4f90c496eff547d3cc2e6529f509/specification/snapshot/_types/SnapshotRepository.ts#L145-L196
type AzureRepositorySettings struct {
// BasePath The path to the repository data within the container.
// It defaults to the root directory.
//
// NOTE: Don't set `base_path` when configuring a snapshot repository for
// Elastic Cloud Enterprise.
// Elastic Cloud Enterprise automatically generates the `base_path` for each
// deployment so that multiple deployments can share the same bucket.
BasePath *string `json:"base_path,omitempty"`
// ChunkSize Big files can be broken down into multiple smaller blobs in the blob store
// during snapshotting.
// It is not recommended to change this value from its default unless there is
// an explicit reason for limiting the size of blobs in the repository.
// Setting a value lower than the default can result in an increased number of
// API calls to the blob store during snapshot create and restore operations
// compared to using the default value and thus make both operations slower and
// more costly.
// Specify the chunk size as a byte unit, for example: `10MB`, `5KB`, 500B.
// The default varies by repository type.
ChunkSize ByteSize `json:"chunk_size,omitempty"`
// Client The name of the Azure repository client to use.
Client *string `json:"client,omitempty"`
// Compress When set to `true`, metadata files are stored in compressed format.
// This setting doesn't affect index files that are already compressed by
// default.
Compress *bool `json:"compress,omitempty"`
// Container The Azure container.
Container *string `json:"container,omitempty"`
// DeleteObjectsMaxSize The maxmimum batch size, between 1 and 256, used for `BlobBatch` requests.
// Defaults to 256 which is the maximum number supported by the Azure blob batch
// API.
DeleteObjectsMaxSize *int `json:"delete_objects_max_size,omitempty"`
// LocationMode Either `primary_only` or `secondary_only`.
// Note that if you set it to `secondary_only`, it will force `readonly` to
// `true`.
LocationMode *string `json:"location_mode,omitempty"`
// MaxConcurrentBatchDeletes The maximum number of concurrent batch delete requests that will be submitted
// for any individual bulk delete with `BlobBatch`.
// Note that the effective number of concurrent deletes is further limited by
// the Azure client connection and event loop thread limits.
// Defaults to 10, minimum is 1, maximum is 100.
MaxConcurrentBatchDeletes *int `json:"max_concurrent_batch_deletes,omitempty"`
// MaxRestoreBytesPerSec The maximum snapshot restore rate per node.
// It defaults to unlimited.
// Note that restores are also throttled through recovery settings.
MaxRestoreBytesPerSec ByteSize `json:"max_restore_bytes_per_sec,omitempty"`
// MaxSnapshotBytesPerSec The maximum snapshot creation rate per node.
// It defaults to 40mb per second.
// Note that if the recovery settings for managed services are set, then it
// defaults to unlimited, and the rate is additionally throttled through
// recovery settings.
MaxSnapshotBytesPerSec ByteSize `json:"max_snapshot_bytes_per_sec,omitempty"`
// Readonly If `true`, the repository is read-only.
// The cluster can retrieve and restore snapshots from the repository but not
// write to the repository or create snapshots in it.
//
// Only a cluster with write access can create snapshots in the repository.
// All other clusters connected to the repository should have the `readonly`
// parameter set to `true`.
// If `false`, the cluster can write to the repository and create snapshots in
// it.
//
// IMPORTANT: If you register the same snapshot repository with multiple
// clusters, only one cluster should have write access to the repository.
// Having multiple clusters write to the repository at the same time risks
// corrupting the contents of the repository.
Readonly *bool `json:"readonly,omitempty"`
}
func (s *AzureRepositorySettings) UnmarshalJSON(data []byte) error {
dec := json.NewDecoder(bytes.NewReader(data))
for {
t, err := dec.Token()
if err != nil {
if errors.Is(err, io.EOF) {
break
}
return err
}
switch t {
case "base_path":
var tmp json.RawMessage
if err := dec.Decode(&tmp); err != nil {
return fmt.Errorf("%s | %w", "BasePath", err)
}
o := string(tmp[:])
o, err = strconv.Unquote(o)
if err != nil {
o = string(tmp[:])
}
s.BasePath = &o
case "chunk_size":
if err := dec.Decode(&s.ChunkSize); err != nil {
return fmt.Errorf("%s | %w", "ChunkSize", err)
}
case "client":
var tmp json.RawMessage
if err := dec.Decode(&tmp); err != nil {
return fmt.Errorf("%s | %w", "Client", err)
}
o := string(tmp[:])
o, err = strconv.Unquote(o)
if err != nil {
o = string(tmp[:])
}
s.Client = &o
case "compress":
var tmp any
dec.Decode(&tmp)
switch v := tmp.(type) {
case string:
value, err := strconv.ParseBool(v)
if err != nil {
return fmt.Errorf("%s | %w", "Compress", err)
}
s.Compress = &value
case bool:
s.Compress = &v
}
case "container":
var tmp json.RawMessage
if err := dec.Decode(&tmp); err != nil {
return fmt.Errorf("%s | %w", "Container", err)
}
o := string(tmp[:])
o, err = strconv.Unquote(o)
if err != nil {
o = string(tmp[:])
}
s.Container = &o
case "delete_objects_max_size":
var tmp any
dec.Decode(&tmp)
switch v := tmp.(type) {
case string:
value, err := strconv.Atoi(v)
if err != nil {
return fmt.Errorf("%s | %w", "DeleteObjectsMaxSize", err)
}
s.DeleteObjectsMaxSize = &value
case float64:
f := int(v)
s.DeleteObjectsMaxSize = &f
}
case "location_mode":
var tmp json.RawMessage
if err := dec.Decode(&tmp); err != nil {
return fmt.Errorf("%s | %w", "LocationMode", err)
}
o := string(tmp[:])
o, err = strconv.Unquote(o)
if err != nil {
o = string(tmp[:])
}
s.LocationMode = &o
case "max_concurrent_batch_deletes":
var tmp any
dec.Decode(&tmp)
switch v := tmp.(type) {
case string:
value, err := strconv.Atoi(v)
if err != nil {
return fmt.Errorf("%s | %w", "MaxConcurrentBatchDeletes", err)
}
s.MaxConcurrentBatchDeletes = &value
case float64:
f := int(v)
s.MaxConcurrentBatchDeletes = &f
}
case "max_restore_bytes_per_sec":
if err := dec.Decode(&s.MaxRestoreBytesPerSec); err != nil {
return fmt.Errorf("%s | %w", "MaxRestoreBytesPerSec", err)
}
case "max_snapshot_bytes_per_sec":
if err := dec.Decode(&s.MaxSnapshotBytesPerSec); err != nil {
return fmt.Errorf("%s | %w", "MaxSnapshotBytesPerSec", err)
}
case "readonly":
var tmp any
dec.Decode(&tmp)
switch v := tmp.(type) {
case string:
value, err := strconv.ParseBool(v)
if err != nil {
return fmt.Errorf("%s | %w", "Readonly", err)
}
s.Readonly = &value
case bool:
s.Readonly = &v
}
}
}
return nil
}
// NewAzureRepositorySettings returns a AzureRepositorySettings.
func NewAzureRepositorySettings() *AzureRepositorySettings {
r := &AzureRepositorySettings{}
return r
}
// true
type AzureRepositorySettingsVariant interface {
AzureRepositorySettingsCaster() *AzureRepositorySettings
}
func (s *AzureRepositorySettings) AzureRepositorySettingsCaster() *AzureRepositorySettings {
return s
}