From a893af519a7ce6221968b8b0bfeb69a1f9c621a8 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Sat, 5 Dec 2020 01:00:59 +0000 Subject: [PATCH] CodeGen from PR 11040 in Azure/azure-rest-api-specs Update keyvault.json (#11040) * Update keyvault.json * Update keyvault.json * Update keyvault.json --- .../mgmt/2019-09-01/keyvault/CHANGELOG.md | 96 ++ .../mgmt/2019-09-01/keyvault/enums.go | 395 ++++++++ .../keyvault/mgmt/2019-09-01/keyvault/keys.go | 558 ++++++++++++ .../keyvault/keyvaultapi/interfaces.go | 13 + .../mgmt/2019-09-01/keyvault/models.go | 843 +++++++++++------- .../mgmt/2019-09-01/keyvault/operations.go | 3 + .../mgmt/2019-09-01/keyvault/vaults.go | 12 + 7 files changed, 1604 insertions(+), 316 deletions(-) create mode 100644 services/keyvault/mgmt/2019-09-01/keyvault/CHANGELOG.md create mode 100644 services/keyvault/mgmt/2019-09-01/keyvault/enums.go create mode 100644 services/keyvault/mgmt/2019-09-01/keyvault/keys.go diff --git a/services/keyvault/mgmt/2019-09-01/keyvault/CHANGELOG.md b/services/keyvault/mgmt/2019-09-01/keyvault/CHANGELOG.md new file mode 100644 index 000000000000..647217755d5b --- /dev/null +++ b/services/keyvault/mgmt/2019-09-01/keyvault/CHANGELOG.md @@ -0,0 +1,96 @@ +Generated from https://github.com/Azure/azure-rest-api-specs/tree/3c764635e7d442b3e74caf593029fcd440b3ef82 + +Code generator @microsoft.azure/autorest.go@~2.1.161 + +## Breaking Changes + +- Function `NewResourceListResultPage` parameter(s) have been changed from `(func(context.Context, ResourceListResult) (ResourceListResult, error))` to `(ResourceListResult, func(context.Context, ResourceListResult) (ResourceListResult, error))` +- Function `NewOperationListResultPage` parameter(s) have been changed from `(func(context.Context, OperationListResult) (OperationListResult, error))` to `(OperationListResult, func(context.Context, OperationListResult) (OperationListResult, error))` +- Function `NewDeletedVaultListResultPage` parameter(s) have been changed from `(func(context.Context, DeletedVaultListResult) (DeletedVaultListResult, error))` to `(DeletedVaultListResult, func(context.Context, DeletedVaultListResult) (DeletedVaultListResult, error))` +- Function `NewVaultListResultPage` parameter(s) have been changed from `(func(context.Context, VaultListResult) (VaultListResult, error))` to `(VaultListResult, func(context.Context, VaultListResult) (VaultListResult, error))` + +## New Content + +- New const `KeyPermissionsAll` +- New const `JSONWebKeyOperationSign` +- New const `RSA` +- New const `StoragePermissionsAll` +- New const `JSONWebKeyOperationEncrypt` +- New const `RSAHSM` +- New const `Purgeable` +- New const `All` +- New const `ECHSM` +- New const `P521` +- New const `JSONWebKeyOperationDecrypt` +- New const `JSONWebKeyOperationImport` +- New const `JSONWebKeyOperationVerify` +- New const `Recoverable` +- New const `P256` +- New const `RecoverableProtectedSubscription` +- New const `P384` +- New const `JSONWebKeyOperationUnwrapKey` +- New const `SecretPermissionsAll` +- New const `JSONWebKeyOperationWrapKey` +- New const `EC` +- New const `RecoverablePurgeable` +- New const `P256K` +- New function `*KeyListResultIterator.Next() error` +- New function `NewKeysClientWithBaseURI(string, string) KeysClient` +- New function `KeysClient.List(context.Context, string, string) (KeyListResultPage, error)` +- New function `KeysClient.GetVersionPreparer(context.Context, string, string, string, string) (*http.Request, error)` +- New function `PossibleJSONWebKeyTypeValues() []JSONWebKeyType` +- New function `KeysClient.CreateIfNotExistSender(*http.Request) (*http.Response, error)` +- New function `KeysClient.ListVersionsPreparer(context.Context, string, string, string) (*http.Request, error)` +- New function `KeyListResultIterator.Response() KeyListResult` +- New function `KeysClient.GetVersion(context.Context, string, string, string, string) (Key, error)` +- New function `KeysClient.GetSender(*http.Request) (*http.Response, error)` +- New function `KeysClient.GetVersionSender(*http.Request) (*http.Response, error)` +- New function `PossibleJSONWebKeyOperationValues() []JSONWebKeyOperation` +- New function `KeyListResult.IsEmpty() bool` +- New function `KeyAttributes.MarshalJSON() ([]byte, error)` +- New function `KeyListResultIterator.Value() Key` +- New function `*Key.UnmarshalJSON([]byte) error` +- New function `PrivateLinkResourceProperties.MarshalJSON() ([]byte, error)` +- New function `NewKeyListResultIterator(KeyListResultPage) KeyListResultIterator` +- New function `KeysClient.ListVersionsSender(*http.Request) (*http.Response, error)` +- New function `KeysClient.ListVersionsResponder(*http.Response) (KeyListResult, error)` +- New function `KeyCreateParameters.MarshalJSON() ([]byte, error)` +- New function `KeysClient.GetResponder(*http.Response) (Key, error)` +- New function `NewKeysClient(string) KeysClient` +- New function `*KeyListResultPage.Next() error` +- New function `KeysClient.ListResponder(*http.Response) (KeyListResult, error)` +- New function `KeysClient.Get(context.Context, string, string, string) (Key, error)` +- New function `VaultProperties.MarshalJSON() ([]byte, error)` +- New function `KeyListResultPage.Values() []Key` +- New function `KeyProperties.MarshalJSON() ([]byte, error)` +- New function `KeysClient.CreateIfNotExistResponder(*http.Response) (Key, error)` +- New function `KeysClient.ListVersions(context.Context, string, string, string) (KeyListResultPage, error)` +- New function `VaultAccessPolicyParameters.MarshalJSON() ([]byte, error)` +- New function `KeysClient.ListComplete(context.Context, string, string) (KeyListResultIterator, error)` +- New function `KeysClient.ListVersionsComplete(context.Context, string, string, string) (KeyListResultIterator, error)` +- New function `PossibleDeletionRecoveryLevelValues() []DeletionRecoveryLevel` +- New function `KeyListResultPage.Response() KeyListResult` +- New function `DeletedVault.MarshalJSON() ([]byte, error)` +- New function `KeysClient.GetPreparer(context.Context, string, string, string) (*http.Request, error)` +- New function `PossibleJSONWebKeyCurveNameValues() []JSONWebKeyCurveName` +- New function `*KeyListResultIterator.NextWithContext(context.Context) error` +- New function `Key.MarshalJSON() ([]byte, error)` +- New function `KeysClient.CreateIfNotExist(context.Context, string, string, string, KeyCreateParameters) (Key, error)` +- New function `Attributes.MarshalJSON() ([]byte, error)` +- New function `KeysClient.ListPreparer(context.Context, string, string) (*http.Request, error)` +- New function `KeysClient.CreateIfNotExistPreparer(context.Context, string, string, string, KeyCreateParameters) (*http.Request, error)` +- New function `KeyListResultIterator.NotDone() bool` +- New function `KeysClient.GetVersionResponder(*http.Response) (Key, error)` +- New function `*KeyListResultPage.NextWithContext(context.Context) error` +- New function `KeysClient.ListSender(*http.Request) (*http.Response, error)` +- New function `KeyListResultPage.NotDone() bool` +- New function `NewKeyListResultPage(KeyListResult, func(context.Context, KeyListResult) (KeyListResult, error)) KeyListResultPage` +- New struct `Attributes` +- New struct `Key` +- New struct `KeyAttributes` +- New struct `KeyCreateParameters` +- New struct `KeyListResult` +- New struct `KeyListResultIterator` +- New struct `KeyListResultPage` +- New struct `KeyProperties` +- New struct `KeysClient` diff --git a/services/keyvault/mgmt/2019-09-01/keyvault/enums.go b/services/keyvault/mgmt/2019-09-01/keyvault/enums.go new file mode 100644 index 000000000000..250c41518d85 --- /dev/null +++ b/services/keyvault/mgmt/2019-09-01/keyvault/enums.go @@ -0,0 +1,395 @@ +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. + +// AccessPolicyUpdateKind enumerates the values for access policy update kind. +type AccessPolicyUpdateKind string + +const ( + // Add ... + Add AccessPolicyUpdateKind = "add" + // Remove ... + Remove AccessPolicyUpdateKind = "remove" + // Replace ... + Replace AccessPolicyUpdateKind = "replace" +) + +// PossibleAccessPolicyUpdateKindValues returns an array of possible values for the AccessPolicyUpdateKind const type. +func PossibleAccessPolicyUpdateKindValues() []AccessPolicyUpdateKind { + return []AccessPolicyUpdateKind{Add, Remove, Replace} +} + +// CertificatePermissions enumerates the values for certificate permissions. +type CertificatePermissions string + +const ( + // All ... + All CertificatePermissions = "all" + // Backup ... + Backup CertificatePermissions = "backup" + // 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" + // Restore ... + Restore CertificatePermissions = "restore" + // 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, Backup, Create, Delete, Deleteissuers, Get, Getissuers, Import, List, Listissuers, Managecontacts, Manageissuers, Purge, Recover, Restore, Setissuers, Update} +} + +// CreateMode enumerates the values for create mode. +type CreateMode string + +const ( + // CreateModeDefault ... + CreateModeDefault CreateMode = "default" + // CreateModeRecover ... + CreateModeRecover CreateMode = "recover" +) + +// PossibleCreateModeValues returns an array of possible values for the CreateMode const type. +func PossibleCreateModeValues() []CreateMode { + return []CreateMode{CreateModeDefault, CreateModeRecover} +} + +// DeletionRecoveryLevel enumerates the values for deletion recovery level. +type DeletionRecoveryLevel string + +const ( + // Purgeable ... + Purgeable DeletionRecoveryLevel = "Purgeable" + // Recoverable ... + Recoverable DeletionRecoveryLevel = "Recoverable" + // RecoverableProtectedSubscription ... + RecoverableProtectedSubscription DeletionRecoveryLevel = "Recoverable+ProtectedSubscription" + // RecoverablePurgeable ... + RecoverablePurgeable DeletionRecoveryLevel = "Recoverable+Purgeable" +) + +// PossibleDeletionRecoveryLevelValues returns an array of possible values for the DeletionRecoveryLevel const type. +func PossibleDeletionRecoveryLevelValues() []DeletionRecoveryLevel { + return []DeletionRecoveryLevel{Purgeable, Recoverable, RecoverableProtectedSubscription, RecoverablePurgeable} +} + +// JSONWebKeyCurveName enumerates the values for json web key curve name. +type JSONWebKeyCurveName string + +const ( + // P256 ... + P256 JSONWebKeyCurveName = "P-256" + // P256K ... + P256K JSONWebKeyCurveName = "P-256K" + // P384 ... + P384 JSONWebKeyCurveName = "P-384" + // P521 ... + P521 JSONWebKeyCurveName = "P-521" +) + +// PossibleJSONWebKeyCurveNameValues returns an array of possible values for the JSONWebKeyCurveName const type. +func PossibleJSONWebKeyCurveNameValues() []JSONWebKeyCurveName { + return []JSONWebKeyCurveName{P256, P256K, P384, P521} +} + +// JSONWebKeyOperation enumerates the values for json web key operation. +type JSONWebKeyOperation string + +const ( + // JSONWebKeyOperationDecrypt ... + JSONWebKeyOperationDecrypt JSONWebKeyOperation = "decrypt" + // JSONWebKeyOperationEncrypt ... + JSONWebKeyOperationEncrypt JSONWebKeyOperation = "encrypt" + // JSONWebKeyOperationImport ... + JSONWebKeyOperationImport JSONWebKeyOperation = "import" + // JSONWebKeyOperationSign ... + JSONWebKeyOperationSign JSONWebKeyOperation = "sign" + // JSONWebKeyOperationUnwrapKey ... + JSONWebKeyOperationUnwrapKey JSONWebKeyOperation = "unwrapKey" + // JSONWebKeyOperationVerify ... + JSONWebKeyOperationVerify JSONWebKeyOperation = "verify" + // JSONWebKeyOperationWrapKey ... + JSONWebKeyOperationWrapKey JSONWebKeyOperation = "wrapKey" +) + +// PossibleJSONWebKeyOperationValues returns an array of possible values for the JSONWebKeyOperation const type. +func PossibleJSONWebKeyOperationValues() []JSONWebKeyOperation { + return []JSONWebKeyOperation{JSONWebKeyOperationDecrypt, JSONWebKeyOperationEncrypt, JSONWebKeyOperationImport, JSONWebKeyOperationSign, JSONWebKeyOperationUnwrapKey, JSONWebKeyOperationVerify, JSONWebKeyOperationWrapKey} +} + +// JSONWebKeyType enumerates the values for json web key type. +type JSONWebKeyType string + +const ( + // EC ... + EC JSONWebKeyType = "EC" + // ECHSM ... + ECHSM JSONWebKeyType = "EC-HSM" + // RSA ... + RSA JSONWebKeyType = "RSA" + // RSAHSM ... + RSAHSM JSONWebKeyType = "RSA-HSM" +) + +// PossibleJSONWebKeyTypeValues returns an array of possible values for the JSONWebKeyType const type. +func PossibleJSONWebKeyTypeValues() []JSONWebKeyType { + return []JSONWebKeyType{EC, ECHSM, RSA, RSAHSM} +} + +// 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} +} + +// NetworkRuleAction enumerates the values for network rule action. +type NetworkRuleAction string + +const ( + // Allow ... + Allow NetworkRuleAction = "Allow" + // Deny ... + Deny NetworkRuleAction = "Deny" +) + +// PossibleNetworkRuleActionValues returns an array of possible values for the NetworkRuleAction const type. +func PossibleNetworkRuleActionValues() []NetworkRuleAction { + return []NetworkRuleAction{Allow, Deny} +} + +// NetworkRuleBypassOptions enumerates the values for network rule bypass options. +type NetworkRuleBypassOptions string + +const ( + // AzureServices ... + AzureServices NetworkRuleBypassOptions = "AzureServices" + // None ... + None NetworkRuleBypassOptions = "None" +) + +// PossibleNetworkRuleBypassOptionsValues returns an array of possible values for the NetworkRuleBypassOptions const type. +func PossibleNetworkRuleBypassOptionsValues() []NetworkRuleBypassOptions { + return []NetworkRuleBypassOptions{AzureServices, None} +} + +// PrivateEndpointConnectionProvisioningState enumerates the values for private endpoint connection +// provisioning state. +type PrivateEndpointConnectionProvisioningState string + +const ( + // Creating ... + Creating PrivateEndpointConnectionProvisioningState = "Creating" + // Deleting ... + Deleting PrivateEndpointConnectionProvisioningState = "Deleting" + // Disconnected ... + Disconnected PrivateEndpointConnectionProvisioningState = "Disconnected" + // Failed ... + Failed PrivateEndpointConnectionProvisioningState = "Failed" + // Succeeded ... + Succeeded PrivateEndpointConnectionProvisioningState = "Succeeded" + // Updating ... + Updating PrivateEndpointConnectionProvisioningState = "Updating" +) + +// PossiblePrivateEndpointConnectionProvisioningStateValues returns an array of possible values for the PrivateEndpointConnectionProvisioningState const type. +func PossiblePrivateEndpointConnectionProvisioningStateValues() []PrivateEndpointConnectionProvisioningState { + return []PrivateEndpointConnectionProvisioningState{Creating, Deleting, Disconnected, Failed, Succeeded, Updating} +} + +// PrivateEndpointServiceConnectionStatus enumerates the values for private endpoint service connection status. +type PrivateEndpointServiceConnectionStatus string + +const ( + // PrivateEndpointServiceConnectionStatusApproved ... + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + // PrivateEndpointServiceConnectionStatusDisconnected ... + PrivateEndpointServiceConnectionStatusDisconnected PrivateEndpointServiceConnectionStatus = "Disconnected" + // PrivateEndpointServiceConnectionStatusPending ... + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + // PrivateEndpointServiceConnectionStatusRejected ... + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" +) + +// PossiblePrivateEndpointServiceConnectionStatusValues returns an array of possible values for the PrivateEndpointServiceConnectionStatus const type. +func PossiblePrivateEndpointServiceConnectionStatusValues() []PrivateEndpointServiceConnectionStatus { + return []PrivateEndpointServiceConnectionStatus{PrivateEndpointServiceConnectionStatusApproved, PrivateEndpointServiceConnectionStatusDisconnected, PrivateEndpointServiceConnectionStatusPending, PrivateEndpointServiceConnectionStatusRejected} +} + +// Reason enumerates the values for reason. +type Reason string + +const ( + // AccountNameInvalid ... + AccountNameInvalid Reason = "AccountNameInvalid" + // AlreadyExists ... + AlreadyExists Reason = "AlreadyExists" +) + +// PossibleReasonValues returns an array of possible values for the Reason const type. +func PossibleReasonValues() []Reason { + return []Reason{AccountNameInvalid, AlreadyExists} +} + +// 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} +} + +// StoragePermissions enumerates the values for storage permissions. +type StoragePermissions string + +const ( + // StoragePermissionsAll ... + StoragePermissionsAll StoragePermissions = "all" + // StoragePermissionsBackup ... + StoragePermissionsBackup StoragePermissions = "backup" + // StoragePermissionsDelete ... + StoragePermissionsDelete StoragePermissions = "delete" + // StoragePermissionsDeletesas ... + StoragePermissionsDeletesas StoragePermissions = "deletesas" + // StoragePermissionsGet ... + StoragePermissionsGet StoragePermissions = "get" + // StoragePermissionsGetsas ... + StoragePermissionsGetsas StoragePermissions = "getsas" + // StoragePermissionsList ... + StoragePermissionsList StoragePermissions = "list" + // StoragePermissionsListsas ... + StoragePermissionsListsas StoragePermissions = "listsas" + // StoragePermissionsPurge ... + StoragePermissionsPurge StoragePermissions = "purge" + // StoragePermissionsRecover ... + StoragePermissionsRecover StoragePermissions = "recover" + // StoragePermissionsRegeneratekey ... + StoragePermissionsRegeneratekey StoragePermissions = "regeneratekey" + // StoragePermissionsRestore ... + StoragePermissionsRestore StoragePermissions = "restore" + // StoragePermissionsSet ... + StoragePermissionsSet StoragePermissions = "set" + // StoragePermissionsSetsas ... + StoragePermissionsSetsas StoragePermissions = "setsas" + // StoragePermissionsUpdate ... + StoragePermissionsUpdate StoragePermissions = "update" +) + +// PossibleStoragePermissionsValues returns an array of possible values for the StoragePermissions const type. +func PossibleStoragePermissionsValues() []StoragePermissions { + return []StoragePermissions{StoragePermissionsAll, StoragePermissionsBackup, StoragePermissionsDelete, StoragePermissionsDeletesas, StoragePermissionsGet, StoragePermissionsGetsas, StoragePermissionsList, StoragePermissionsListsas, StoragePermissionsPurge, StoragePermissionsRecover, StoragePermissionsRegeneratekey, StoragePermissionsRestore, StoragePermissionsSet, StoragePermissionsSetsas, StoragePermissionsUpdate} +} diff --git a/services/keyvault/mgmt/2019-09-01/keyvault/keys.go b/services/keyvault/mgmt/2019-09-01/keyvault/keys.go new file mode 100644 index 000000000000..c4dd095577ef --- /dev/null +++ b/services/keyvault/mgmt/2019-09-01/keyvault/keys.go @@ -0,0 +1,558 @@ +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. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// KeysClient is the the Azure management API provides a RESTful set of web services that interact with Azure Key +// Vault. +type KeysClient struct { + BaseClient +} + +// NewKeysClient creates an instance of the KeysClient client. +func NewKeysClient(subscriptionID string) KeysClient { + return NewKeysClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewKeysClientWithBaseURI creates an instance of the KeysClient client using a custom endpoint. Use this when +// interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure stack). +func NewKeysClientWithBaseURI(baseURI string, subscriptionID string) KeysClient { + return KeysClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateIfNotExist creates the first version of a new key if it does not exist. If it already exists, then the +// existing key is returned without any write operations being performed. This API does not create subsequent versions, +// and does not update existing keys. +// Parameters: +// resourceGroupName - the name of the resource group which contains the specified key vault. +// vaultName - the name of the key vault which contains the key to be created. +// keyName - the name of the key to be created. +// parameters - the parameters used to create the specified key. +func (client KeysClient) CreateIfNotExist(ctx context.Context, resourceGroupName string, vaultName string, keyName string, parameters KeyCreateParameters) (result Key, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/KeysClient.CreateIfNotExist") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: vaultName, + Constraints: []validation.Constraint{{Target: "vaultName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9-]{3,24}$`, Chain: nil}}}, + {TargetValue: keyName, + Constraints: []validation.Constraint{{Target: "keyName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9-]{1,127}$`, Chain: nil}}}, + {TargetValue: parameters, + Constraints: []validation.Constraint{{Target: "parameters.Properties", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { + return result, validation.NewError("keyvault.KeysClient", "CreateIfNotExist", err.Error()) + } + + req, err := client.CreateIfNotExistPreparer(ctx, resourceGroupName, vaultName, keyName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "keyvault.KeysClient", "CreateIfNotExist", nil, "Failure preparing request") + return + } + + resp, err := client.CreateIfNotExistSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "keyvault.KeysClient", "CreateIfNotExist", resp, "Failure sending request") + return + } + + result, err = client.CreateIfNotExistResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "keyvault.KeysClient", "CreateIfNotExist", resp, "Failure responding to request") + } + + return +} + +// CreateIfNotExistPreparer prepares the CreateIfNotExist request. +func (client KeysClient) CreateIfNotExistPreparer(ctx context.Context, resourceGroupName string, vaultName string, keyName string, parameters KeyCreateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vaultName": autorest.Encode("path", vaultName), + } + + const APIVersion = "2019-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateIfNotExistSender sends the CreateIfNotExist request. The method will close the +// http.Response Body if it receives an error. +func (client KeysClient) CreateIfNotExistSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateIfNotExistResponder handles the response to the CreateIfNotExist request. The method always +// closes the http.Response Body. +func (client KeysClient) CreateIfNotExistResponder(resp *http.Response) (result Key, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get gets the current version of the specified key from the specified key vault. +// Parameters: +// resourceGroupName - the name of the resource group which contains the specified key vault. +// vaultName - the name of the vault which contains the key to be retrieved. +// keyName - the name of the key to be retrieved. +func (client KeysClient) Get(ctx context.Context, resourceGroupName string, vaultName string, keyName string) (result Key, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/KeysClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: vaultName, + Constraints: []validation.Constraint{{Target: "vaultName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9-]{3,24}$`, Chain: nil}}}, + {TargetValue: keyName, + Constraints: []validation.Constraint{{Target: "keyName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9-]{1,127}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("keyvault.KeysClient", "Get", err.Error()) + } + + req, err := client.GetPreparer(ctx, resourceGroupName, vaultName, keyName) + if err != nil { + err = autorest.NewErrorWithError(err, "keyvault.KeysClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "keyvault.KeysClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "keyvault.KeysClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client KeysClient) GetPreparer(ctx context.Context, resourceGroupName string, vaultName string, keyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vaultName": autorest.Encode("path", vaultName), + } + + const APIVersion = "2019-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client KeysClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client KeysClient) GetResponder(resp *http.Response) (result Key, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetVersion gets the specified version of the specified key in the specified key vault. +// Parameters: +// resourceGroupName - the name of the resource group which contains the specified key vault. +// vaultName - the name of the vault which contains the key version to be retrieved. +// keyName - the name of the key version to be retrieved. +// keyVersion - the version of the key to be retrieved. +func (client KeysClient) GetVersion(ctx context.Context, resourceGroupName string, vaultName string, keyName string, keyVersion string) (result Key, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/KeysClient.GetVersion") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: vaultName, + Constraints: []validation.Constraint{{Target: "vaultName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9-]{3,24}$`, Chain: nil}}}, + {TargetValue: keyName, + Constraints: []validation.Constraint{{Target: "keyName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9-]{1,127}$`, Chain: nil}}}, + {TargetValue: keyVersion, + Constraints: []validation.Constraint{{Target: "keyVersion", Name: validation.Pattern, Rule: `^[a-fA-F0-9]{32}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("keyvault.KeysClient", "GetVersion", err.Error()) + } + + req, err := client.GetVersionPreparer(ctx, resourceGroupName, vaultName, keyName, keyVersion) + if err != nil { + err = autorest.NewErrorWithError(err, "keyvault.KeysClient", "GetVersion", nil, "Failure preparing request") + return + } + + resp, err := client.GetVersionSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "keyvault.KeysClient", "GetVersion", resp, "Failure sending request") + return + } + + result, err = client.GetVersionResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "keyvault.KeysClient", "GetVersion", resp, "Failure responding to request") + } + + return +} + +// GetVersionPreparer prepares the GetVersion request. +func (client KeysClient) GetVersionPreparer(ctx context.Context, resourceGroupName string, vaultName string, keyName string, keyVersion string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "keyVersion": autorest.Encode("path", keyVersion), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vaultName": autorest.Encode("path", vaultName), + } + + const APIVersion = "2019-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions/{keyVersion}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetVersionSender sends the GetVersion request. The method will close the +// http.Response Body if it receives an error. +func (client KeysClient) GetVersionSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetVersionResponder handles the response to the GetVersion request. The method always +// closes the http.Response Body. +func (client KeysClient) GetVersionResponder(resp *http.Response) (result Key, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists the keys in the specified key vault. +// Parameters: +// resourceGroupName - the name of the resource group which contains the specified key vault. +// vaultName - the name of the vault which contains the keys to be retrieved. +func (client KeysClient) List(ctx context.Context, resourceGroupName string, vaultName string) (result KeyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/KeysClient.List") + defer func() { + sc := -1 + if result.klr.Response.Response != nil { + sc = result.klr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: vaultName, + Constraints: []validation.Constraint{{Target: "vaultName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9-]{3,24}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("keyvault.KeysClient", "List", err.Error()) + } + + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, vaultName) + if err != nil { + err = autorest.NewErrorWithError(err, "keyvault.KeysClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.klr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "keyvault.KeysClient", "List", resp, "Failure sending request") + return + } + + result.klr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "keyvault.KeysClient", "List", resp, "Failure responding to request") + } + if result.klr.hasNextLink() && result.klr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client KeysClient) ListPreparer(ctx context.Context, resourceGroupName string, vaultName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vaultName": autorest.Encode("path", vaultName), + } + + const APIVersion = "2019-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client KeysClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client KeysClient) ListResponder(resp *http.Response) (result KeyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client KeysClient) listNextResults(ctx context.Context, lastResults KeyListResult) (result KeyListResult, err error) { + req, err := lastResults.keyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "keyvault.KeysClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "keyvault.KeysClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "keyvault.KeysClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client KeysClient) ListComplete(ctx context.Context, resourceGroupName string, vaultName string) (result KeyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/KeysClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, vaultName) + return +} + +// ListVersions lists the versions of the specified key in the specified key vault. +// Parameters: +// resourceGroupName - the name of the resource group which contains the specified key vault. +// vaultName - the name of the vault which contains the key versions to be retrieved. +// keyName - the name of the key versions to be retrieved. +func (client KeysClient) ListVersions(ctx context.Context, resourceGroupName string, vaultName string, keyName string) (result KeyListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/KeysClient.ListVersions") + defer func() { + sc := -1 + if result.klr.Response.Response != nil { + sc = result.klr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: vaultName, + Constraints: []validation.Constraint{{Target: "vaultName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9-]{3,24}$`, Chain: nil}}}, + {TargetValue: keyName, + Constraints: []validation.Constraint{{Target: "keyName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9-]{1,127}$`, Chain: nil}}}}); err != nil { + return result, validation.NewError("keyvault.KeysClient", "ListVersions", err.Error()) + } + + result.fn = client.listVersionsNextResults + req, err := client.ListVersionsPreparer(ctx, resourceGroupName, vaultName, keyName) + if err != nil { + err = autorest.NewErrorWithError(err, "keyvault.KeysClient", "ListVersions", nil, "Failure preparing request") + return + } + + resp, err := client.ListVersionsSender(req) + if err != nil { + result.klr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "keyvault.KeysClient", "ListVersions", resp, "Failure sending request") + return + } + + result.klr, err = client.ListVersionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "keyvault.KeysClient", "ListVersions", resp, "Failure responding to request") + } + if result.klr.hasNextLink() && result.klr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListVersionsPreparer prepares the ListVersions request. +func (client KeysClient) ListVersionsPreparer(ctx context.Context, resourceGroupName string, vaultName string, keyName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "keyName": autorest.Encode("path", keyName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + "vaultName": autorest.Encode("path", vaultName), + } + + const APIVersion = "2019-09-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}/keys/{keyName}/versions", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListVersionsSender sends the ListVersions request. The method will close the +// http.Response Body if it receives an error. +func (client KeysClient) ListVersionsSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListVersionsResponder handles the response to the ListVersions request. The method always +// closes the http.Response Body. +func (client KeysClient) ListVersionsResponder(resp *http.Response) (result KeyListResult, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listVersionsNextResults retrieves the next set of results, if any. +func (client KeysClient) listVersionsNextResults(ctx context.Context, lastResults KeyListResult) (result KeyListResult, err error) { + req, err := lastResults.keyListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "keyvault.KeysClient", "listVersionsNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListVersionsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "keyvault.KeysClient", "listVersionsNextResults", resp, "Failure sending next results request") + } + result, err = client.ListVersionsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "keyvault.KeysClient", "listVersionsNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListVersionsComplete enumerates all values, automatically crossing page boundaries as required. +func (client KeysClient) ListVersionsComplete(ctx context.Context, resourceGroupName string, vaultName string, keyName string) (result KeyListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/KeysClient.ListVersions") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.ListVersions(ctx, resourceGroupName, vaultName, keyName) + return +} diff --git a/services/keyvault/mgmt/2019-09-01/keyvault/keyvaultapi/interfaces.go b/services/keyvault/mgmt/2019-09-01/keyvault/keyvaultapi/interfaces.go index 34f0530deaae..e41988921c01 100644 --- a/services/keyvault/mgmt/2019-09-01/keyvault/keyvaultapi/interfaces.go +++ b/services/keyvault/mgmt/2019-09-01/keyvault/keyvaultapi/interfaces.go @@ -68,3 +68,16 @@ type OperationsClientAPI interface { } var _ OperationsClientAPI = (*keyvault.OperationsClient)(nil) + +// KeysClientAPI contains the set of methods on the KeysClient type. +type KeysClientAPI interface { + CreateIfNotExist(ctx context.Context, resourceGroupName string, vaultName string, keyName string, parameters keyvault.KeyCreateParameters) (result keyvault.Key, err error) + Get(ctx context.Context, resourceGroupName string, vaultName string, keyName string) (result keyvault.Key, err error) + GetVersion(ctx context.Context, resourceGroupName string, vaultName string, keyName string, keyVersion string) (result keyvault.Key, err error) + List(ctx context.Context, resourceGroupName string, vaultName string) (result keyvault.KeyListResultPage, err error) + ListComplete(ctx context.Context, resourceGroupName string, vaultName string) (result keyvault.KeyListResultIterator, err error) + ListVersions(ctx context.Context, resourceGroupName string, vaultName string, keyName string) (result keyvault.KeyListResultPage, err error) + ListVersionsComplete(ctx context.Context, resourceGroupName string, vaultName string, keyName string) (result keyvault.KeyListResultIterator, err error) +} + +var _ KeysClientAPI = (*keyvault.KeysClient)(nil) diff --git a/services/keyvault/mgmt/2019-09-01/keyvault/models.go b/services/keyvault/mgmt/2019-09-01/keyvault/models.go index c210803ae785..3f1a9c17187c 100644 --- a/services/keyvault/mgmt/2019-09-01/keyvault/models.go +++ b/services/keyvault/mgmt/2019-09-01/keyvault/models.go @@ -32,293 +32,6 @@ import ( // The package's fully qualified name. const fqdn = "github.com/Azure/azure-sdk-for-go/services/keyvault/mgmt/2019-09-01/keyvault" -// AccessPolicyUpdateKind enumerates the values for access policy update kind. -type AccessPolicyUpdateKind string - -const ( - // Add ... - Add AccessPolicyUpdateKind = "add" - // Remove ... - Remove AccessPolicyUpdateKind = "remove" - // Replace ... - Replace AccessPolicyUpdateKind = "replace" -) - -// PossibleAccessPolicyUpdateKindValues returns an array of possible values for the AccessPolicyUpdateKind const type. -func PossibleAccessPolicyUpdateKindValues() []AccessPolicyUpdateKind { - return []AccessPolicyUpdateKind{Add, Remove, Replace} -} - -// CertificatePermissions enumerates the values for certificate permissions. -type CertificatePermissions string - -const ( - // Backup ... - Backup CertificatePermissions = "backup" - // 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" - // Restore ... - Restore CertificatePermissions = "restore" - // 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{Backup, Create, Delete, Deleteissuers, Get, Getissuers, Import, List, Listissuers, Managecontacts, Manageissuers, Purge, Recover, Restore, Setissuers, Update} -} - -// CreateMode enumerates the values for create mode. -type CreateMode string - -const ( - // CreateModeDefault ... - CreateModeDefault CreateMode = "default" - // CreateModeRecover ... - CreateModeRecover CreateMode = "recover" -) - -// PossibleCreateModeValues returns an array of possible values for the CreateMode const type. -func PossibleCreateModeValues() []CreateMode { - return []CreateMode{CreateModeDefault, CreateModeRecover} -} - -// KeyPermissions enumerates the values for key permissions. -type KeyPermissions string - -const ( - // 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{KeyPermissionsBackup, KeyPermissionsCreate, KeyPermissionsDecrypt, KeyPermissionsDelete, KeyPermissionsEncrypt, KeyPermissionsGet, KeyPermissionsImport, KeyPermissionsList, KeyPermissionsPurge, KeyPermissionsRecover, KeyPermissionsRestore, KeyPermissionsSign, KeyPermissionsUnwrapKey, KeyPermissionsUpdate, KeyPermissionsVerify, KeyPermissionsWrapKey} -} - -// NetworkRuleAction enumerates the values for network rule action. -type NetworkRuleAction string - -const ( - // Allow ... - Allow NetworkRuleAction = "Allow" - // Deny ... - Deny NetworkRuleAction = "Deny" -) - -// PossibleNetworkRuleActionValues returns an array of possible values for the NetworkRuleAction const type. -func PossibleNetworkRuleActionValues() []NetworkRuleAction { - return []NetworkRuleAction{Allow, Deny} -} - -// NetworkRuleBypassOptions enumerates the values for network rule bypass options. -type NetworkRuleBypassOptions string - -const ( - // AzureServices ... - AzureServices NetworkRuleBypassOptions = "AzureServices" - // None ... - None NetworkRuleBypassOptions = "None" -) - -// PossibleNetworkRuleBypassOptionsValues returns an array of possible values for the NetworkRuleBypassOptions const type. -func PossibleNetworkRuleBypassOptionsValues() []NetworkRuleBypassOptions { - return []NetworkRuleBypassOptions{AzureServices, None} -} - -// PrivateEndpointConnectionProvisioningState enumerates the values for private endpoint connection -// provisioning state. -type PrivateEndpointConnectionProvisioningState string - -const ( - // Creating ... - Creating PrivateEndpointConnectionProvisioningState = "Creating" - // Deleting ... - Deleting PrivateEndpointConnectionProvisioningState = "Deleting" - // Disconnected ... - Disconnected PrivateEndpointConnectionProvisioningState = "Disconnected" - // Failed ... - Failed PrivateEndpointConnectionProvisioningState = "Failed" - // Succeeded ... - Succeeded PrivateEndpointConnectionProvisioningState = "Succeeded" - // Updating ... - Updating PrivateEndpointConnectionProvisioningState = "Updating" -) - -// PossiblePrivateEndpointConnectionProvisioningStateValues returns an array of possible values for the PrivateEndpointConnectionProvisioningState const type. -func PossiblePrivateEndpointConnectionProvisioningStateValues() []PrivateEndpointConnectionProvisioningState { - return []PrivateEndpointConnectionProvisioningState{Creating, Deleting, Disconnected, Failed, Succeeded, Updating} -} - -// PrivateEndpointServiceConnectionStatus enumerates the values for private endpoint service connection status. -type PrivateEndpointServiceConnectionStatus string - -const ( - // PrivateEndpointServiceConnectionStatusApproved ... - PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" - // PrivateEndpointServiceConnectionStatusDisconnected ... - PrivateEndpointServiceConnectionStatusDisconnected PrivateEndpointServiceConnectionStatus = "Disconnected" - // PrivateEndpointServiceConnectionStatusPending ... - PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" - // PrivateEndpointServiceConnectionStatusRejected ... - PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" -) - -// PossiblePrivateEndpointServiceConnectionStatusValues returns an array of possible values for the PrivateEndpointServiceConnectionStatus const type. -func PossiblePrivateEndpointServiceConnectionStatusValues() []PrivateEndpointServiceConnectionStatus { - return []PrivateEndpointServiceConnectionStatus{PrivateEndpointServiceConnectionStatusApproved, PrivateEndpointServiceConnectionStatusDisconnected, PrivateEndpointServiceConnectionStatusPending, PrivateEndpointServiceConnectionStatusRejected} -} - -// Reason enumerates the values for reason. -type Reason string - -const ( - // AccountNameInvalid ... - AccountNameInvalid Reason = "AccountNameInvalid" - // AlreadyExists ... - AlreadyExists Reason = "AlreadyExists" -) - -// PossibleReasonValues returns an array of possible values for the Reason const type. -func PossibleReasonValues() []Reason { - return []Reason{AccountNameInvalid, AlreadyExists} -} - -// SecretPermissions enumerates the values for secret permissions. -type SecretPermissions string - -const ( - // 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{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} -} - -// StoragePermissions enumerates the values for storage permissions. -type StoragePermissions string - -const ( - // StoragePermissionsBackup ... - StoragePermissionsBackup StoragePermissions = "backup" - // StoragePermissionsDelete ... - StoragePermissionsDelete StoragePermissions = "delete" - // StoragePermissionsDeletesas ... - StoragePermissionsDeletesas StoragePermissions = "deletesas" - // StoragePermissionsGet ... - StoragePermissionsGet StoragePermissions = "get" - // StoragePermissionsGetsas ... - StoragePermissionsGetsas StoragePermissions = "getsas" - // StoragePermissionsList ... - StoragePermissionsList StoragePermissions = "list" - // StoragePermissionsListsas ... - StoragePermissionsListsas StoragePermissions = "listsas" - // StoragePermissionsPurge ... - StoragePermissionsPurge StoragePermissions = "purge" - // StoragePermissionsRecover ... - StoragePermissionsRecover StoragePermissions = "recover" - // StoragePermissionsRegeneratekey ... - StoragePermissionsRegeneratekey StoragePermissions = "regeneratekey" - // StoragePermissionsRestore ... - StoragePermissionsRestore StoragePermissions = "restore" - // StoragePermissionsSet ... - StoragePermissionsSet StoragePermissions = "set" - // StoragePermissionsSetsas ... - StoragePermissionsSetsas StoragePermissions = "setsas" - // StoragePermissionsUpdate ... - StoragePermissionsUpdate StoragePermissions = "update" -) - -// PossibleStoragePermissionsValues returns an array of possible values for the StoragePermissions const type. -func PossibleStoragePermissionsValues() []StoragePermissions { - return []StoragePermissions{StoragePermissionsBackup, StoragePermissionsDelete, StoragePermissionsDeletesas, StoragePermissionsGet, StoragePermissionsGetsas, StoragePermissionsList, StoragePermissionsListsas, StoragePermissionsPurge, StoragePermissionsRecover, StoragePermissionsRegeneratekey, StoragePermissionsRestore, StoragePermissionsSet, StoragePermissionsSetsas, StoragePermissionsUpdate} -} - // 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 { @@ -332,6 +45,37 @@ type AccessPolicyEntry struct { Permissions *Permissions `json:"permissions,omitempty"` } +// Attributes the object attributes managed by the Azure Key Vault service. +type Attributes struct { + // Enabled - Determines whether or not the object is enabled. + Enabled *bool `json:"enabled,omitempty"` + // NotBefore - Not before date in seconds since 1970-01-01T00:00:00Z. + NotBefore *int64 `json:"nbf,omitempty"` + // Expires - Expiry date in seconds since 1970-01-01T00:00:00Z. + Expires *int64 `json:"exp,omitempty"` + // Created - READ-ONLY; Creation time in seconds since 1970-01-01T00:00:00Z. + Created *int64 `json:"created,omitempty"` + // Updated - READ-ONLY; Last updated time in seconds since 1970-01-01T00:00:00Z. + Updated *int64 `json:"updated,omitempty"` + // RecoveryLevel - READ-ONLY; The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. Possible values include: 'Purgeable', 'RecoverablePurgeable', 'Recoverable', 'RecoverableProtectedSubscription' + RecoveryLevel DeletionRecoveryLevel `json:"recoveryLevel,omitempty"` +} + +// MarshalJSON is the custom marshaler for Attributes. +func (a Attributes) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if a.Enabled != nil { + objectMap["enabled"] = a.Enabled + } + if a.NotBefore != nil { + objectMap["nbf"] = a.NotBefore + } + if a.Expires != nil { + objectMap["exp"] = a.Expires + } + return json.Marshal(objectMap) +} + // CheckNameAvailabilityResult the CheckNameAvailability operation response. type CheckNameAvailabilityResult struct { autorest.Response `json:"-"` @@ -369,6 +113,15 @@ type DeletedVault struct { Properties *DeletedVaultProperties `json:"properties,omitempty"` } +// MarshalJSON is the custom marshaler for DeletedVault. +func (dv DeletedVault) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if dv.Properties != nil { + objectMap["properties"] = dv.Properties + } + return json.Marshal(objectMap) +} + // DeletedVaultListResult list of vaults type DeletedVaultListResult struct { autorest.Response `json:"-"` @@ -446,10 +199,15 @@ func (dvlr DeletedVaultListResult) IsEmpty() bool { return dvlr.Value == nil || len(*dvlr.Value) == 0 } +// hasNextLink returns true if the NextLink is not empty. +func (dvlr DeletedVaultListResult) hasNextLink() bool { + return dvlr.NextLink != nil && len(*dvlr.NextLink) != 0 +} + // deletedVaultListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. func (dvlr DeletedVaultListResult) deletedVaultListResultPreparer(ctx context.Context) (*http.Request, error) { - if dvlr.NextLink == nil || len(to.String(dvlr.NextLink)) < 1 { + if !dvlr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), @@ -477,11 +235,16 @@ func (page *DeletedVaultListResultPage) NextWithContext(ctx context.Context) (er tracing.EndSpan(ctx, sc, err) }() } - next, err := page.fn(ctx, page.dvlr) - if err != nil { - return err + for { + next, err := page.fn(ctx, page.dvlr) + if err != nil { + return err + } + page.dvlr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } } - page.dvlr = next return nil } @@ -511,8 +274,11 @@ func (page DeletedVaultListResultPage) Values() []DeletedVault { } // Creates a new instance of the DeletedVaultListResultPage type. -func NewDeletedVaultListResultPage(getNextPage func(context.Context, DeletedVaultListResult) (DeletedVaultListResult, error)) DeletedVaultListResultPage { - return DeletedVaultListResultPage{fn: getNextPage} +func NewDeletedVaultListResultPage(cur DeletedVaultListResult, getNextPage func(context.Context, DeletedVaultListResult) (DeletedVaultListResult, error)) DeletedVaultListResultPage { + return DeletedVaultListResultPage{ + fn: getNextPage, + dvlr: cur, + } } // DeletedVaultProperties properties of the deleted vault. @@ -541,6 +307,349 @@ type IPRule struct { Value *string `json:"value,omitempty"` } +// Key the key resource. +type Key struct { + autorest.Response `json:"-"` + // KeyProperties - The properties of the key. + *KeyProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified identifier of the key vault resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Name of the key vault resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type of the key vault resource. + Type *string `json:"type,omitempty"` + // Location - READ-ONLY; Azure location of the key vault resource. + Location *string `json:"location,omitempty"` + // Tags - READ-ONLY; Tags assigned to the key vault resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for Key. +func (kVar Key) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if kVar.KeyProperties != nil { + objectMap["properties"] = kVar.KeyProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for Key struct. +func (kVar *Key) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var keyProperties KeyProperties + err = json.Unmarshal(*v, &keyProperties) + if err != nil { + return err + } + kVar.KeyProperties = &keyProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + kVar.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + kVar.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + kVar.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + kVar.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + kVar.Tags = tags + } + } + } + + return nil +} + +// KeyAttributes the attributes of the key. +type KeyAttributes struct { + // Enabled - Determines whether or not the object is enabled. + Enabled *bool `json:"enabled,omitempty"` + // NotBefore - Not before date in seconds since 1970-01-01T00:00:00Z. + NotBefore *int64 `json:"nbf,omitempty"` + // Expires - Expiry date in seconds since 1970-01-01T00:00:00Z. + Expires *int64 `json:"exp,omitempty"` + // Created - READ-ONLY; Creation time in seconds since 1970-01-01T00:00:00Z. + Created *int64 `json:"created,omitempty"` + // Updated - READ-ONLY; Last updated time in seconds since 1970-01-01T00:00:00Z. + Updated *int64 `json:"updated,omitempty"` + // RecoveryLevel - READ-ONLY; The deletion recovery level currently in effect for the object. If it contains 'Purgeable', then the object can be permanently deleted by a privileged user; otherwise, only the system can purge the object at the end of the retention interval. Possible values include: 'Purgeable', 'RecoverablePurgeable', 'Recoverable', 'RecoverableProtectedSubscription' + RecoveryLevel DeletionRecoveryLevel `json:"recoveryLevel,omitempty"` +} + +// MarshalJSON is the custom marshaler for KeyAttributes. +func (ka KeyAttributes) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ka.Enabled != nil { + objectMap["enabled"] = ka.Enabled + } + if ka.NotBefore != nil { + objectMap["nbf"] = ka.NotBefore + } + if ka.Expires != nil { + objectMap["exp"] = ka.Expires + } + return json.Marshal(objectMap) +} + +// KeyCreateParameters the parameters used to create a key. +type KeyCreateParameters struct { + // Tags - The tags that will be assigned to the key. + Tags map[string]*string `json:"tags"` + // Properties - The properties of the key to be created. + Properties *KeyProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for KeyCreateParameters. +func (kcp KeyCreateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if kcp.Tags != nil { + objectMap["tags"] = kcp.Tags + } + if kcp.Properties != nil { + objectMap["properties"] = kcp.Properties + } + return json.Marshal(objectMap) +} + +// KeyListResult the page of keys. +type KeyListResult struct { + autorest.Response `json:"-"` + // Value - The key resources. + Value *[]Key `json:"value,omitempty"` + // NextLink - The URL to get the next page of keys. + NextLink *string `json:"nextLink,omitempty"` +} + +// KeyListResultIterator provides access to a complete listing of Key values. +type KeyListResultIterator struct { + i int + page KeyListResultPage +} + +// 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 *KeyListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/KeyListResultIterator.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 *KeyListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter KeyListResultIterator) 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 KeyListResultIterator) Response() KeyListResult { + 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 KeyListResultIterator) Value() Key { + if !iter.page.NotDone() { + return Key{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the KeyListResultIterator type. +func NewKeyListResultIterator(page KeyListResultPage) KeyListResultIterator { + return KeyListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (klr KeyListResult) IsEmpty() bool { + return klr.Value == nil || len(*klr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (klr KeyListResult) hasNextLink() bool { + return klr.NextLink != nil && len(*klr.NextLink) != 0 +} + +// keyListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (klr KeyListResult) keyListResultPreparer(ctx context.Context) (*http.Request, error) { + if !klr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(klr.NextLink))) +} + +// KeyListResultPage contains a page of Key values. +type KeyListResultPage struct { + fn func(context.Context, KeyListResult) (KeyListResult, error) + klr KeyListResult +} + +// 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 *KeyListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/KeyListResultPage.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.klr) + if err != nil { + return err + } + page.klr = 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 *KeyListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page KeyListResultPage) NotDone() bool { + return !page.klr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page KeyListResultPage) Response() KeyListResult { + return page.klr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page KeyListResultPage) Values() []Key { + if page.klr.IsEmpty() { + return nil + } + return *page.klr.Value +} + +// Creates a new instance of the KeyListResultPage type. +func NewKeyListResultPage(cur KeyListResult, getNextPage func(context.Context, KeyListResult) (KeyListResult, error)) KeyListResultPage { + return KeyListResultPage{ + fn: getNextPage, + klr: cur, + } +} + +// KeyProperties the properties of the key. +type KeyProperties struct { + // Attributes - The attributes of the key. + Attributes *KeyAttributes `json:"attributes,omitempty"` + // Kty - The type of the key. For valid values, see JsonWebKeyType. Possible values include: 'EC', 'ECHSM', 'RSA', 'RSAHSM' + Kty JSONWebKeyType `json:"kty,omitempty"` + KeyOps *[]JSONWebKeyOperation `json:"keyOps,omitempty"` + // KeySize - The key size in bits. For example: 2048, 3072, or 4096 for RSA. + KeySize *int32 `json:"keySize,omitempty"` + // CurveName - The elliptic curve name. For valid values, see JsonWebKeyCurveName. Possible values include: 'P256', 'P384', 'P521', 'P256K' + CurveName JSONWebKeyCurveName `json:"curveName,omitempty"` + // KeyURI - READ-ONLY; The URI to retrieve the current version of the key. + KeyURI *string `json:"keyUri,omitempty"` + // KeyURIWithVersion - READ-ONLY; The URI to retrieve the specific version of the key. + KeyURIWithVersion *string `json:"keyUriWithVersion,omitempty"` +} + +// MarshalJSON is the custom marshaler for KeyProperties. +func (kp KeyProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if kp.Attributes != nil { + objectMap["attributes"] = kp.Attributes + } + if kp.Kty != "" { + objectMap["kty"] = kp.Kty + } + if kp.KeyOps != nil { + objectMap["keyOps"] = kp.KeyOps + } + if kp.KeySize != nil { + objectMap["keySize"] = kp.KeySize + } + if kp.CurveName != "" { + objectMap["curveName"] = kp.CurveName + } + return json.Marshal(objectMap) +} + // LogSpecification log specification of operation. type LogSpecification struct { // Name - Name of log specification. @@ -734,10 +843,15 @@ func (olr OperationListResult) IsEmpty() bool { return olr.Value == nil || len(*olr.Value) == 0 } +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + // operationListResultPreparer prepares a request to retrieve the next set of results. // It returns nil if no more results exist. func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { - if olr.NextLink == nil || len(to.String(olr.NextLink)) < 1 { + if !olr.hasNextLink() { return nil, nil } return autorest.Prepare((&http.Request{}).WithContext(ctx), @@ -765,11 +879,16 @@ func (page *OperationListResultPage) NextWithContext(ctx context.Context) (err e tracing.EndSpan(ctx, sc, err) }() } - next, err := page.fn(ctx, page.olr) - if err != nil { - return err + for { + next, err := page.fn(ctx, page.olr) + if err != nil { + return err + } + page.olr = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } } - page.olr = next return nil } @@ -799,8 +918,11 @@ func (page OperationListResultPage) Values() []Operation { } // Creates a new instance of the OperationListResultPage type. -func NewOperationListResultPage(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { - return OperationListResultPage{fn: getNextPage} +func NewOperationListResultPage(cur OperationListResult, getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{ + fn: getNextPage, + olr: cur, + } } // OperationProperties properties of operation, include metric specifications. @@ -1111,6 +1233,15 @@ type PrivateLinkResourceProperties struct { RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` } +// MarshalJSON is the custom marshaler for PrivateLinkResourceProperties. +func (plrp PrivateLinkResourceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plrp.RequiredZoneNames != nil { + objectMap["requiredZoneNames"] = plrp.RequiredZoneNames + } + return json.Marshal(objectMap) +} + // PrivateLinkServiceConnectionState an object that represents the approval state of the private link // connection. type PrivateLinkServiceConnectionState struct { @@ -1219,10 +1350,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), @@ -1250,11 +1386,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 } @@ -1284,8 +1425,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, + } } // ServiceSpecification one property of operation, include log specifications. @@ -1349,6 +1493,15 @@ type VaultAccessPolicyParameters struct { Properties *VaultAccessPolicyProperties `json:"properties,omitempty"` } +// MarshalJSON is the custom marshaler for VaultAccessPolicyParameters. +func (vapp VaultAccessPolicyParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vapp.Properties != nil { + objectMap["properties"] = vapp.Properties + } + return json.Marshal(objectMap) +} + // VaultAccessPolicyProperties properties of the vault access policy type VaultAccessPolicyProperties struct { // 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. @@ -1465,10 +1618,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), @@ -1496,11 +1654,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 } @@ -1530,8 +1693,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, + } } // VaultPatchParameters parameters for creating or updating a vault @@ -1590,7 +1756,7 @@ type VaultProperties struct { Sku *Sku `json:"sku,omitempty"` // AccessPolicies - An array of 0 to 1024 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. When `createMode` is set to `recover`, access policies are not required. Otherwise, access policies are required. AccessPolicies *[]AccessPolicyEntry `json:"accessPolicies,omitempty"` - // VaultURI - The URI of the vault for performing operations on keys and secrets. + // VaultURI - The URI of the vault for performing operations on keys and secrets. This property is readonly VaultURI *string `json:"vaultUri,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"` @@ -1614,6 +1780,51 @@ type VaultProperties struct { PrivateEndpointConnections *[]PrivateEndpointConnectionItem `json:"privateEndpointConnections,omitempty"` } +// MarshalJSON is the custom marshaler for VaultProperties. +func (vp VaultProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if vp.TenantID != nil { + objectMap["tenantId"] = vp.TenantID + } + if vp.Sku != nil { + objectMap["sku"] = vp.Sku + } + if vp.AccessPolicies != nil { + objectMap["accessPolicies"] = vp.AccessPolicies + } + if vp.VaultURI != nil { + objectMap["vaultUri"] = vp.VaultURI + } + if vp.EnabledForDeployment != nil { + objectMap["enabledForDeployment"] = vp.EnabledForDeployment + } + if vp.EnabledForDiskEncryption != nil { + objectMap["enabledForDiskEncryption"] = vp.EnabledForDiskEncryption + } + if vp.EnabledForTemplateDeployment != nil { + objectMap["enabledForTemplateDeployment"] = vp.EnabledForTemplateDeployment + } + if vp.EnableSoftDelete != nil { + objectMap["enableSoftDelete"] = vp.EnableSoftDelete + } + if vp.SoftDeleteRetentionInDays != nil { + objectMap["softDeleteRetentionInDays"] = vp.SoftDeleteRetentionInDays + } + if vp.EnableRbacAuthorization != nil { + objectMap["enableRbacAuthorization"] = vp.EnableRbacAuthorization + } + if vp.CreateMode != "" { + objectMap["createMode"] = vp.CreateMode + } + if vp.EnablePurgeProtection != nil { + objectMap["enablePurgeProtection"] = vp.EnablePurgeProtection + } + if vp.NetworkAcls != nil { + objectMap["networkAcls"] = vp.NetworkAcls + } + return json.Marshal(objectMap) +} + // VaultsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a long-running // operation. type VaultsCreateOrUpdateFuture struct { diff --git a/services/keyvault/mgmt/2019-09-01/keyvault/operations.go b/services/keyvault/mgmt/2019-09-01/keyvault/operations.go index 54b846374862..1fdc72cba446 100644 --- a/services/keyvault/mgmt/2019-09-01/keyvault/operations.go +++ b/services/keyvault/mgmt/2019-09-01/keyvault/operations.go @@ -72,6 +72,9 @@ func (client OperationsClient) List(ctx context.Context) (result OperationListRe if err != nil { err = autorest.NewErrorWithError(err, "keyvault.OperationsClient", "List", resp, "Failure responding to request") } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } diff --git a/services/keyvault/mgmt/2019-09-01/keyvault/vaults.go b/services/keyvault/mgmt/2019-09-01/keyvault/vaults.go index de21073c2194..efdf9dd0ae27 100644 --- a/services/keyvault/mgmt/2019-09-01/keyvault/vaults.go +++ b/services/keyvault/mgmt/2019-09-01/keyvault/vaults.go @@ -471,6 +471,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 } @@ -587,6 +590,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 } @@ -701,6 +707,9 @@ func (client VaultsClient) ListBySubscription(ctx context.Context, top *int32) ( if err != nil { err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListBySubscription", resp, "Failure responding to request") } + if result.vlr.hasNextLink() && result.vlr.IsEmpty() { + err = result.NextWithContext(ctx) + } return } @@ -812,6 +821,9 @@ func (client VaultsClient) ListDeleted(ctx context.Context) (result DeletedVault if err != nil { err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListDeleted", resp, "Failure responding to request") } + if result.dvlr.hasNextLink() && result.dvlr.IsEmpty() { + err = result.NextWithContext(ctx) + } return }