diff --git a/services/keyvault/mgmt/2015-06-01/keyvault/CHANGELOG.md b/services/keyvault/mgmt/2015-06-01/keyvault/CHANGELOG.md new file mode 100644 index 000000000000..562801caf1ac --- /dev/null +++ b/services/keyvault/mgmt/2015-06-01/keyvault/CHANGELOG.md @@ -0,0 +1,8 @@ +Generated from https://github.com/Azure/azure-rest-api-specs/tree/3c764635e7d442b3e74caf593029fcd440b3ef82 + +Code generator @microsoft.azure/autorest.go@~2.1.161 + +## Breaking Changes + +- Function `NewVaultListResultPage` parameter(s) have been changed from `(func(context.Context, VaultListResult) (VaultListResult, error))` to `(VaultListResult, func(context.Context, VaultListResult) (VaultListResult, error))` +- Function `NewResourceListResultPage` parameter(s) have been changed from `(func(context.Context, ResourceListResult) (ResourceListResult, error))` to `(ResourceListResult, func(context.Context, ResourceListResult) (ResourceListResult, error))` diff --git a/services/keyvault/mgmt/2015-06-01/keyvault/enums.go b/services/keyvault/mgmt/2015-06-01/keyvault/enums.go new file mode 100644 index 000000000000..b08f06c808db --- /dev/null +++ b/services/keyvault/mgmt/2015-06-01/keyvault/enums.go @@ -0,0 +1,148 @@ +package keyvault + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed 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 by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// CertificatePermissions enumerates the values for certificate permissions. +type CertificatePermissions string + +const ( + // All ... + All CertificatePermissions = "all" + // Create ... + Create CertificatePermissions = "create" + // Delete ... + Delete CertificatePermissions = "delete" + // Deleteissuers ... + Deleteissuers CertificatePermissions = "deleteissuers" + // Get ... + Get CertificatePermissions = "get" + // Getissuers ... + Getissuers CertificatePermissions = "getissuers" + // Import ... + Import CertificatePermissions = "import" + // List ... + List CertificatePermissions = "list" + // Listissuers ... + Listissuers CertificatePermissions = "listissuers" + // Managecontacts ... + Managecontacts CertificatePermissions = "managecontacts" + // Manageissuers ... + Manageissuers CertificatePermissions = "manageissuers" + // Purge ... + Purge CertificatePermissions = "purge" + // Recover ... + Recover CertificatePermissions = "recover" + // Setissuers ... + Setissuers CertificatePermissions = "setissuers" + // Update ... + Update CertificatePermissions = "update" +) + +// PossibleCertificatePermissionsValues returns an array of possible values for the CertificatePermissions const type. +func PossibleCertificatePermissionsValues() []CertificatePermissions { + return []CertificatePermissions{All, Create, Delete, Deleteissuers, Get, Getissuers, Import, List, Listissuers, Managecontacts, Manageissuers, Purge, Recover, Setissuers, Update} +} + +// KeyPermissions enumerates the values for key permissions. +type KeyPermissions string + +const ( + // KeyPermissionsAll ... + KeyPermissionsAll KeyPermissions = "all" + // KeyPermissionsBackup ... + KeyPermissionsBackup KeyPermissions = "backup" + // KeyPermissionsCreate ... + KeyPermissionsCreate KeyPermissions = "create" + // KeyPermissionsDecrypt ... + KeyPermissionsDecrypt KeyPermissions = "decrypt" + // KeyPermissionsDelete ... + KeyPermissionsDelete KeyPermissions = "delete" + // KeyPermissionsEncrypt ... + KeyPermissionsEncrypt KeyPermissions = "encrypt" + // KeyPermissionsGet ... + KeyPermissionsGet KeyPermissions = "get" + // KeyPermissionsImport ... + KeyPermissionsImport KeyPermissions = "import" + // KeyPermissionsList ... + KeyPermissionsList KeyPermissions = "list" + // KeyPermissionsPurge ... + KeyPermissionsPurge KeyPermissions = "purge" + // KeyPermissionsRecover ... + KeyPermissionsRecover KeyPermissions = "recover" + // KeyPermissionsRestore ... + KeyPermissionsRestore KeyPermissions = "restore" + // KeyPermissionsSign ... + KeyPermissionsSign KeyPermissions = "sign" + // KeyPermissionsUnwrapKey ... + KeyPermissionsUnwrapKey KeyPermissions = "unwrapKey" + // KeyPermissionsUpdate ... + KeyPermissionsUpdate KeyPermissions = "update" + // KeyPermissionsVerify ... + KeyPermissionsVerify KeyPermissions = "verify" + // KeyPermissionsWrapKey ... + KeyPermissionsWrapKey KeyPermissions = "wrapKey" +) + +// PossibleKeyPermissionsValues returns an array of possible values for the KeyPermissions const type. +func PossibleKeyPermissionsValues() []KeyPermissions { + return []KeyPermissions{KeyPermissionsAll, KeyPermissionsBackup, KeyPermissionsCreate, KeyPermissionsDecrypt, KeyPermissionsDelete, KeyPermissionsEncrypt, KeyPermissionsGet, KeyPermissionsImport, KeyPermissionsList, KeyPermissionsPurge, KeyPermissionsRecover, KeyPermissionsRestore, KeyPermissionsSign, KeyPermissionsUnwrapKey, KeyPermissionsUpdate, KeyPermissionsVerify, KeyPermissionsWrapKey} +} + +// SecretPermissions enumerates the values for secret permissions. +type SecretPermissions string + +const ( + // SecretPermissionsAll ... + SecretPermissionsAll SecretPermissions = "all" + // SecretPermissionsBackup ... + SecretPermissionsBackup SecretPermissions = "backup" + // SecretPermissionsDelete ... + SecretPermissionsDelete SecretPermissions = "delete" + // SecretPermissionsGet ... + SecretPermissionsGet SecretPermissions = "get" + // SecretPermissionsList ... + SecretPermissionsList SecretPermissions = "list" + // SecretPermissionsPurge ... + SecretPermissionsPurge SecretPermissions = "purge" + // SecretPermissionsRecover ... + SecretPermissionsRecover SecretPermissions = "recover" + // SecretPermissionsRestore ... + SecretPermissionsRestore SecretPermissions = "restore" + // SecretPermissionsSet ... + SecretPermissionsSet SecretPermissions = "set" +) + +// PossibleSecretPermissionsValues returns an array of possible values for the SecretPermissions const type. +func PossibleSecretPermissionsValues() []SecretPermissions { + return []SecretPermissions{SecretPermissionsAll, SecretPermissionsBackup, SecretPermissionsDelete, SecretPermissionsGet, SecretPermissionsList, SecretPermissionsPurge, SecretPermissionsRecover, SecretPermissionsRestore, SecretPermissionsSet} +} + +// SkuName enumerates the values for sku name. +type SkuName string + +const ( + // Premium ... + Premium SkuName = "premium" + // Standard ... + Standard SkuName = "standard" +) + +// PossibleSkuNameValues returns an array of possible values for the SkuName const type. +func PossibleSkuNameValues() []SkuName { + return []SkuName{Premium, Standard} +} diff --git a/services/keyvault/mgmt/2015-06-01/keyvault/models.go b/services/keyvault/mgmt/2015-06-01/keyvault/models.go index faed14ecaa77..14881d745b2a 100644 --- a/services/keyvault/mgmt/2015-06-01/keyvault/models.go +++ b/services/keyvault/mgmt/2015-06-01/keyvault/models.go @@ -30,136 +30,6 @@ import ( // The package's fully qualified name. const fqdn = "github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2015-06-01/keyvault" -// CertificatePermissions enumerates the values for certificate permissions. -type CertificatePermissions string - -const ( - // All ... - All CertificatePermissions = "all" - // Create ... - Create CertificatePermissions = "create" - // Delete ... - Delete CertificatePermissions = "delete" - // Deleteissuers ... - Deleteissuers CertificatePermissions = "deleteissuers" - // Get ... - Get CertificatePermissions = "get" - // Getissuers ... - Getissuers CertificatePermissions = "getissuers" - // Import ... - Import CertificatePermissions = "import" - // List ... - List CertificatePermissions = "list" - // Listissuers ... - Listissuers CertificatePermissions = "listissuers" - // Managecontacts ... - Managecontacts CertificatePermissions = "managecontacts" - // Manageissuers ... - Manageissuers CertificatePermissions = "manageissuers" - // Purge ... - Purge CertificatePermissions = "purge" - // Recover ... - Recover CertificatePermissions = "recover" - // Setissuers ... - Setissuers CertificatePermissions = "setissuers" - // Update ... - Update CertificatePermissions = "update" -) - -// PossibleCertificatePermissionsValues returns an array of possible values for the CertificatePermissions const type. -func PossibleCertificatePermissionsValues() []CertificatePermissions { - return []CertificatePermissions{All, Create, Delete, Deleteissuers, Get, Getissuers, Import, List, Listissuers, Managecontacts, Manageissuers, Purge, Recover, Setissuers, Update} -} - -// KeyPermissions enumerates the values for key permissions. -type KeyPermissions string - -const ( - // KeyPermissionsAll ... - KeyPermissionsAll KeyPermissions = "all" - // KeyPermissionsBackup ... - KeyPermissionsBackup KeyPermissions = "backup" - // KeyPermissionsCreate ... - KeyPermissionsCreate KeyPermissions = "create" - // KeyPermissionsDecrypt ... - KeyPermissionsDecrypt KeyPermissions = "decrypt" - // KeyPermissionsDelete ... - KeyPermissionsDelete KeyPermissions = "delete" - // KeyPermissionsEncrypt ... - KeyPermissionsEncrypt KeyPermissions = "encrypt" - // KeyPermissionsGet ... - KeyPermissionsGet KeyPermissions = "get" - // KeyPermissionsImport ... - KeyPermissionsImport KeyPermissions = "import" - // KeyPermissionsList ... - KeyPermissionsList KeyPermissions = "list" - // KeyPermissionsPurge ... - KeyPermissionsPurge KeyPermissions = "purge" - // KeyPermissionsRecover ... - KeyPermissionsRecover KeyPermissions = "recover" - // KeyPermissionsRestore ... - KeyPermissionsRestore KeyPermissions = "restore" - // KeyPermissionsSign ... - KeyPermissionsSign KeyPermissions = "sign" - // KeyPermissionsUnwrapKey ... - KeyPermissionsUnwrapKey KeyPermissions = "unwrapKey" - // KeyPermissionsUpdate ... - KeyPermissionsUpdate KeyPermissions = "update" - // KeyPermissionsVerify ... - KeyPermissionsVerify KeyPermissions = "verify" - // KeyPermissionsWrapKey ... - KeyPermissionsWrapKey KeyPermissions = "wrapKey" -) - -// PossibleKeyPermissionsValues returns an array of possible values for the KeyPermissions const type. -func PossibleKeyPermissionsValues() []KeyPermissions { - return []KeyPermissions{KeyPermissionsAll, KeyPermissionsBackup, KeyPermissionsCreate, KeyPermissionsDecrypt, KeyPermissionsDelete, KeyPermissionsEncrypt, KeyPermissionsGet, KeyPermissionsImport, KeyPermissionsList, KeyPermissionsPurge, KeyPermissionsRecover, KeyPermissionsRestore, KeyPermissionsSign, KeyPermissionsUnwrapKey, KeyPermissionsUpdate, KeyPermissionsVerify, KeyPermissionsWrapKey} -} - -// SecretPermissions enumerates the values for secret permissions. -type SecretPermissions string - -const ( - // SecretPermissionsAll ... - SecretPermissionsAll SecretPermissions = "all" - // SecretPermissionsBackup ... - SecretPermissionsBackup SecretPermissions = "backup" - // SecretPermissionsDelete ... - SecretPermissionsDelete SecretPermissions = "delete" - // SecretPermissionsGet ... - SecretPermissionsGet SecretPermissions = "get" - // SecretPermissionsList ... - SecretPermissionsList SecretPermissions = "list" - // SecretPermissionsPurge ... - SecretPermissionsPurge SecretPermissions = "purge" - // SecretPermissionsRecover ... - SecretPermissionsRecover SecretPermissions = "recover" - // SecretPermissionsRestore ... - SecretPermissionsRestore SecretPermissions = "restore" - // SecretPermissionsSet ... - SecretPermissionsSet SecretPermissions = "set" -) - -// PossibleSecretPermissionsValues returns an array of possible values for the SecretPermissions const type. -func PossibleSecretPermissionsValues() []SecretPermissions { - return []SecretPermissions{SecretPermissionsAll, SecretPermissionsBackup, SecretPermissionsDelete, SecretPermissionsGet, SecretPermissionsList, SecretPermissionsPurge, SecretPermissionsRecover, SecretPermissionsRestore, SecretPermissionsSet} -} - -// SkuName enumerates the values for sku name. -type SkuName string - -const ( - // Premium ... - Premium SkuName = "premium" - // Standard ... - Standard SkuName = "standard" -) - -// PossibleSkuNameValues returns an array of possible values for the SkuName const type. -func PossibleSkuNameValues() []SkuName { - return []SkuName{Premium, Standard} -} - // 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 { @@ -289,10 +159,15 @@ 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.NextLink == nil || len(to.String(rlr.NextLink)) < 1 { + if !rlr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), @@ -320,11 +195,16 @@ func (page *ResourceListResultPage) NextWithContext(ctx context.Context) (err er tracing.EndSpan(ctx, sc, err) }() } - next, err := page.fn(ctx, page.rlr) - if err != nil { - return err + for { + next, err := page.fn(ctx, page.rlr) + if err != nil { + return err + } + page.rlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } } - page.rlr = next return nil } @@ -354,8 +234,11 @@ func (page ResourceListResultPage) Values() []Resource { } // Creates a new instance of the ResourceListResultPage type. -func NewResourceListResultPage(getNextPage func(context.Context, ResourceListResult) (ResourceListResult, error)) ResourceListResultPage { - return ResourceListResultPage{fn: getNextPage} +func NewResourceListResultPage(cur ResourceListResult, getNextPage func(context.Context, ResourceListResult) (ResourceListResult, error)) ResourceListResultPage { + return ResourceListResultPage{ + fn: getNextPage, + rlr: cur, + } } // Sku SKU details @@ -503,10 +386,15 @@ 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.NextLink == nil || len(to.String(vlr.NextLink)) < 1 { + if !vlr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), @@ -534,11 +422,16 @@ func (page *VaultListResultPage) NextWithContext(ctx context.Context) (err error tracing.EndSpan(ctx, sc, err) }() } - next, err := page.fn(ctx, page.vlr) - if err != nil { - return err + for { + next, err := page.fn(ctx, page.vlr) + if err != nil { + return err + } + page.vlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } } - page.vlr = next return nil } @@ -568,8 +461,11 @@ func (page VaultListResultPage) Values() []Vault { } // Creates a new instance of the VaultListResultPage type. -func NewVaultListResultPage(getNextPage func(context.Context, VaultListResult) (VaultListResult, error)) VaultListResultPage { - return VaultListResultPage{fn: getNextPage} +func NewVaultListResultPage(cur VaultListResult, getNextPage func(context.Context, VaultListResult) (VaultListResult, error)) VaultListResultPage { + return VaultListResultPage{ + fn: getNextPage, + vlr: cur, + } } // VaultProperties properties of the vault diff --git a/services/keyvault/mgmt/2015-06-01/keyvault/vaults.go b/services/keyvault/mgmt/2015-06-01/keyvault/vaults.go index 51633311e328..0823bd0216d2 100644 --- a/services/keyvault/mgmt/2015-06-01/keyvault/vaults.go +++ b/services/keyvault/mgmt/2015-06-01/keyvault/vaults.go @@ -317,6 +317,9 @@ func (client VaultsClient) List(ctx context.Context, top *int32) (result Resourc if err != nil { err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "List", resp, "Failure responding to request") } + if result.rlr.hasNextLink() && result.rlr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -433,6 +436,9 @@ func (client VaultsClient) ListByResourceGroup(ctx context.Context, resourceGrou if err != nil { err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListByResourceGroup", resp, "Failure responding to request") } + if result.vlr.hasNextLink() && result.vlr.IsEmpty() { + err = result.NextWithContext(ctx) + } return }