forked from Azure/azure-sdk-for-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
478 lines (429 loc) · 16.5 KB
/
models.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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
package keyvault
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"context"
"encoding/json"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/to"
"github.com/Azure/go-autorest/tracing"
"github.com/gofrs/uuid"
"net/http"
)
// The package's fully qualified name.
const fqdn = "github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2015-06-01/keyvault"
// AccessPolicyEntry an identity that have access to the key vault. All identities in the array must use
// the same tenant ID as the key vault's tenant ID.
type AccessPolicyEntry struct {
// TenantID - The Azure Active Directory tenant ID that should be used for authenticating requests to the key vault.
TenantID *uuid.UUID `json:"tenantId,omitempty"`
// ObjectID - The object ID of a user, service principal or security group in the Azure Active Directory tenant for the vault. The object ID must be unique for the list of access policies.
ObjectID *string `json:"objectId,omitempty"`
// ApplicationID - Application ID of the client making request on behalf of a principal
ApplicationID *uuid.UUID `json:"applicationId,omitempty"`
// Permissions - Permissions the identity has for keys, secrets and certificates.
Permissions *Permissions `json:"permissions,omitempty"`
}
// Permissions permissions the identity has for keys, secrets and certificates.
type Permissions struct {
// Keys - Permissions to keys
Keys *[]KeyPermissions `json:"keys,omitempty"`
// Secrets - Permissions to secrets
Secrets *[]SecretPermissions `json:"secrets,omitempty"`
// Certificates - Permissions to certificates
Certificates *[]CertificatePermissions `json:"certificates,omitempty"`
}
// Resource key Vault resource
type Resource struct {
// ID - READ-ONLY; The Azure Resource Manager resource ID for the key vault.
ID *string `json:"id,omitempty"`
// Name - The name of the key vault.
Name *string `json:"name,omitempty"`
// Type - READ-ONLY; The resource type of the key vault.
Type *string `json:"type,omitempty"`
// Location - The supported Azure location where the key vault should be created.
Location *string `json:"location,omitempty"`
// Tags - The tags that will be assigned to the key vault.
Tags map[string]*string `json:"tags"`
}
// MarshalJSON is the custom marshaler for Resource.
func (r Resource) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if r.Name != nil {
objectMap["name"] = r.Name
}
if r.Location != nil {
objectMap["location"] = r.Location
}
if r.Tags != nil {
objectMap["tags"] = r.Tags
}
return json.Marshal(objectMap)
}
// ResourceListResult list of vault resources.
type ResourceListResult struct {
autorest.Response `json:"-"`
// Value - Gets the list of vault resources.
Value *[]Resource `json:"value,omitempty"`
// NextLink - Gets the URL to get the next set of vault resources.
NextLink *string `json:"nextLink,omitempty"`
}
// ResourceListResultIterator provides access to a complete listing of Resource values.
type ResourceListResultIterator struct {
i int
page ResourceListResultPage
}
// NextWithContext advances to the next value. If there was an error making
// the request the iterator does not advance and the error is returned.
func (iter *ResourceListResultIterator) NextWithContext(ctx context.Context) (err error) {
if tracing.IsEnabled() {
ctx = tracing.StartSpan(ctx, fqdn+"/ResourceListResultIterator.NextWithContext")
defer func() {
sc := -1
if iter.Response().Response.Response != nil {
sc = iter.Response().Response.Response.StatusCode
}
tracing.EndSpan(ctx, sc, err)
}()
}
iter.i++
if iter.i < len(iter.page.Values()) {
return nil
}
err = iter.page.NextWithContext(ctx)
if err != nil {
iter.i--
return err
}
iter.i = 0
return nil
}
// Next advances to the next value. If there was an error making
// the request the iterator does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (iter *ResourceListResultIterator) Next() error {
return iter.NextWithContext(context.Background())
}
// NotDone returns true if the enumeration should be started or is not yet complete.
func (iter ResourceListResultIterator) NotDone() bool {
return iter.page.NotDone() && iter.i < len(iter.page.Values())
}
// Response returns the raw server response from the last page request.
func (iter ResourceListResultIterator) Response() ResourceListResult {
return iter.page.Response()
}
// Value returns the current value or a zero-initialized value if the
// iterator has advanced beyond the end of the collection.
func (iter ResourceListResultIterator) Value() Resource {
if !iter.page.NotDone() {
return Resource{}
}
return iter.page.Values()[iter.i]
}
// Creates a new instance of the ResourceListResultIterator type.
func NewResourceListResultIterator(page ResourceListResultPage) ResourceListResultIterator {
return ResourceListResultIterator{page: page}
}
// IsEmpty returns true if the ListResult contains no values.
func (rlr ResourceListResult) IsEmpty() bool {
return rlr.Value == nil || len(*rlr.Value) == 0
}
// hasNextLink returns true if the NextLink is not empty.
func (rlr ResourceListResult) hasNextLink() bool {
return rlr.NextLink != nil && len(*rlr.NextLink) != 0
}
// resourceListResultPreparer prepares a request to retrieve the next set of results.
// It returns nil if no more results exist.
func (rlr ResourceListResult) resourceListResultPreparer(ctx context.Context) (*http.Request, error) {
if !rlr.hasNextLink() {
return nil, nil
}
return autorest.Prepare((&http.Request{}).WithContext(ctx),
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(rlr.NextLink)))
}
// ResourceListResultPage contains a page of Resource values.
type ResourceListResultPage struct {
fn func(context.Context, ResourceListResult) (ResourceListResult, error)
rlr ResourceListResult
}
// NextWithContext advances to the next page of values. If there was an error making
// the request the page does not advance and the error is returned.
func (page *ResourceListResultPage) NextWithContext(ctx context.Context) (err error) {
if tracing.IsEnabled() {
ctx = tracing.StartSpan(ctx, fqdn+"/ResourceListResultPage.NextWithContext")
defer func() {
sc := -1
if page.Response().Response.Response != nil {
sc = page.Response().Response.Response.StatusCode
}
tracing.EndSpan(ctx, sc, err)
}()
}
for {
next, err := page.fn(ctx, page.rlr)
if err != nil {
return err
}
page.rlr = next
if !next.hasNextLink() || !next.IsEmpty() {
break
}
}
return nil
}
// Next advances to the next page of values. If there was an error making
// the request the page does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (page *ResourceListResultPage) Next() error {
return page.NextWithContext(context.Background())
}
// NotDone returns true if the page enumeration should be started or is not yet complete.
func (page ResourceListResultPage) NotDone() bool {
return !page.rlr.IsEmpty()
}
// Response returns the raw server response from the last page request.
func (page ResourceListResultPage) Response() ResourceListResult {
return page.rlr
}
// Values returns the slice of values for the current page or nil if there are no values.
func (page ResourceListResultPage) Values() []Resource {
if page.rlr.IsEmpty() {
return nil
}
return *page.rlr.Value
}
// Creates a new instance of the ResourceListResultPage type.
func NewResourceListResultPage(cur ResourceListResult, getNextPage func(context.Context, ResourceListResult) (ResourceListResult, error)) ResourceListResultPage {
return ResourceListResultPage{
fn: getNextPage,
rlr: cur,
}
}
// Sku SKU details
type Sku struct {
// Family - SKU family name
Family *string `json:"family,omitempty"`
// Name - SKU name to specify whether the key vault is a standard vault or a premium vault. Possible values include: 'Standard', 'Premium'
Name SkuName `json:"name,omitempty"`
}
// Vault resource information with extended details.
type Vault struct {
autorest.Response `json:"-"`
// Properties - Properties of the vault
Properties *VaultProperties `json:"properties,omitempty"`
// ID - READ-ONLY; The Azure Resource Manager resource ID for the key vault.
ID *string `json:"id,omitempty"`
// Name - The name of the key vault.
Name *string `json:"name,omitempty"`
// Type - READ-ONLY; The resource type of the key vault.
Type *string `json:"type,omitempty"`
// Location - The supported Azure location where the key vault should be created.
Location *string `json:"location,omitempty"`
// Tags - The tags that will be assigned to the key vault.
Tags map[string]*string `json:"tags"`
}
// MarshalJSON is the custom marshaler for Vault.
func (vVar Vault) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if vVar.Properties != nil {
objectMap["properties"] = vVar.Properties
}
if vVar.Name != nil {
objectMap["name"] = vVar.Name
}
if vVar.Location != nil {
objectMap["location"] = vVar.Location
}
if vVar.Tags != nil {
objectMap["tags"] = vVar.Tags
}
return json.Marshal(objectMap)
}
// VaultCreateOrUpdateParameters parameters for creating or updating a vault
type VaultCreateOrUpdateParameters struct {
// Location - The supported Azure location where the key vault should be created.
Location *string `json:"location,omitempty"`
// Tags - The tags that will be assigned to the key vault.
Tags map[string]*string `json:"tags"`
// Properties - Properties of the vault
Properties *VaultProperties `json:"properties,omitempty"`
}
// MarshalJSON is the custom marshaler for VaultCreateOrUpdateParameters.
func (vcoup VaultCreateOrUpdateParameters) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if vcoup.Location != nil {
objectMap["location"] = vcoup.Location
}
if vcoup.Tags != nil {
objectMap["tags"] = vcoup.Tags
}
if vcoup.Properties != nil {
objectMap["properties"] = vcoup.Properties
}
return json.Marshal(objectMap)
}
// VaultListResult list of vaults
type VaultListResult struct {
autorest.Response `json:"-"`
// Value - Gets or sets the list of vaults.
Value *[]Vault `json:"value,omitempty"`
// NextLink - Gets or sets the URL to get the next set of vaults.
NextLink *string `json:"nextLink,omitempty"`
}
// VaultListResultIterator provides access to a complete listing of Vault values.
type VaultListResultIterator struct {
i int
page VaultListResultPage
}
// NextWithContext advances to the next value. If there was an error making
// the request the iterator does not advance and the error is returned.
func (iter *VaultListResultIterator) NextWithContext(ctx context.Context) (err error) {
if tracing.IsEnabled() {
ctx = tracing.StartSpan(ctx, fqdn+"/VaultListResultIterator.NextWithContext")
defer func() {
sc := -1
if iter.Response().Response.Response != nil {
sc = iter.Response().Response.Response.StatusCode
}
tracing.EndSpan(ctx, sc, err)
}()
}
iter.i++
if iter.i < len(iter.page.Values()) {
return nil
}
err = iter.page.NextWithContext(ctx)
if err != nil {
iter.i--
return err
}
iter.i = 0
return nil
}
// Next advances to the next value. If there was an error making
// the request the iterator does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (iter *VaultListResultIterator) Next() error {
return iter.NextWithContext(context.Background())
}
// NotDone returns true if the enumeration should be started or is not yet complete.
func (iter VaultListResultIterator) NotDone() bool {
return iter.page.NotDone() && iter.i < len(iter.page.Values())
}
// Response returns the raw server response from the last page request.
func (iter VaultListResultIterator) Response() VaultListResult {
return iter.page.Response()
}
// Value returns the current value or a zero-initialized value if the
// iterator has advanced beyond the end of the collection.
func (iter VaultListResultIterator) Value() Vault {
if !iter.page.NotDone() {
return Vault{}
}
return iter.page.Values()[iter.i]
}
// Creates a new instance of the VaultListResultIterator type.
func NewVaultListResultIterator(page VaultListResultPage) VaultListResultIterator {
return VaultListResultIterator{page: page}
}
// IsEmpty returns true if the ListResult contains no values.
func (vlr VaultListResult) IsEmpty() bool {
return vlr.Value == nil || len(*vlr.Value) == 0
}
// hasNextLink returns true if the NextLink is not empty.
func (vlr VaultListResult) hasNextLink() bool {
return vlr.NextLink != nil && len(*vlr.NextLink) != 0
}
// vaultListResultPreparer prepares a request to retrieve the next set of results.
// It returns nil if no more results exist.
func (vlr VaultListResult) vaultListResultPreparer(ctx context.Context) (*http.Request, error) {
if !vlr.hasNextLink() {
return nil, nil
}
return autorest.Prepare((&http.Request{}).WithContext(ctx),
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(vlr.NextLink)))
}
// VaultListResultPage contains a page of Vault values.
type VaultListResultPage struct {
fn func(context.Context, VaultListResult) (VaultListResult, error)
vlr VaultListResult
}
// NextWithContext advances to the next page of values. If there was an error making
// the request the page does not advance and the error is returned.
func (page *VaultListResultPage) NextWithContext(ctx context.Context) (err error) {
if tracing.IsEnabled() {
ctx = tracing.StartSpan(ctx, fqdn+"/VaultListResultPage.NextWithContext")
defer func() {
sc := -1
if page.Response().Response.Response != nil {
sc = page.Response().Response.Response.StatusCode
}
tracing.EndSpan(ctx, sc, err)
}()
}
for {
next, err := page.fn(ctx, page.vlr)
if err != nil {
return err
}
page.vlr = next
if !next.hasNextLink() || !next.IsEmpty() {
break
}
}
return nil
}
// Next advances to the next page of values. If there was an error making
// the request the page does not advance and the error is returned.
// Deprecated: Use NextWithContext() instead.
func (page *VaultListResultPage) Next() error {
return page.NextWithContext(context.Background())
}
// NotDone returns true if the page enumeration should be started or is not yet complete.
func (page VaultListResultPage) NotDone() bool {
return !page.vlr.IsEmpty()
}
// Response returns the raw server response from the last page request.
func (page VaultListResultPage) Response() VaultListResult {
return page.vlr
}
// Values returns the slice of values for the current page or nil if there are no values.
func (page VaultListResultPage) Values() []Vault {
if page.vlr.IsEmpty() {
return nil
}
return *page.vlr.Value
}
// Creates a new instance of the VaultListResultPage type.
func NewVaultListResultPage(cur VaultListResult, getNextPage func(context.Context, VaultListResult) (VaultListResult, error)) VaultListResultPage {
return VaultListResultPage{
fn: getNextPage,
vlr: cur,
}
}
// VaultProperties properties of the vault
type VaultProperties struct {
// VaultURI - The URI of the vault for performing operations on keys and secrets.
VaultURI *string `json:"vaultUri,omitempty"`
// TenantID - The Azure Active Directory tenant ID that should be used for authenticating requests to the key vault.
TenantID *uuid.UUID `json:"tenantId,omitempty"`
// Sku - SKU details
Sku *Sku `json:"sku,omitempty"`
// AccessPolicies - An array of 0 to 16 identities that have access to the key vault. All identities in the array must use the same tenant ID as the key vault's tenant ID.
AccessPolicies *[]AccessPolicyEntry `json:"accessPolicies,omitempty"`
// EnabledForDeployment - Property to specify whether Azure Virtual Machines are permitted to retrieve certificates stored as secrets from the key vault.
EnabledForDeployment *bool `json:"enabledForDeployment,omitempty"`
// EnabledForDiskEncryption - Property to specify whether Azure Disk Encryption is permitted to retrieve secrets from the vault and unwrap keys.
EnabledForDiskEncryption *bool `json:"enabledForDiskEncryption,omitempty"`
// EnabledForTemplateDeployment - Property to specify whether Azure Resource Manager is permitted to retrieve secrets from the key vault.
EnabledForTemplateDeployment *bool `json:"enabledForTemplateDeployment,omitempty"`
// EnableSoftDelete - Property to specify whether the 'soft delete' functionality is enabled for this key vault.
EnableSoftDelete *bool `json:"enableSoftDelete,omitempty"`
}