vendor: update all dependencies to latest versions

This commit is contained in:
Nick Craig-Wood
2018-01-16 13:20:59 +00:00
parent 8e83fb6fb9
commit 7d3a17725d
4878 changed files with 1974213 additions and 201199 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,28 @@
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.
// UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string {
return "Azure-SDK-For-Go/v12.2.0-beta services"
}
// Version returns the semantic version (see http://semver.org) of the client.
func Version() string {
return "v12.2.0-beta"
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,28 @@
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.
// UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string {
return "Azure-SDK-For-Go/v12.2.0-beta services"
}
// Version returns the semantic version (see http://semver.org) of the client.
func Version() string {
return "v12.2.0-beta"
}
@@ -0,0 +1,51 @@
// Package keyvault implements the Azure ARM Keyvault service API version 2015-06-01.
//
// The Azure management API provides a RESTful set of web services that interact with Azure Key Vault.
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 (
"github.com/Azure/go-autorest/autorest"
)
const (
// DefaultBaseURI is the default URI used for the service Keyvault
DefaultBaseURI = "https://management.azure.com"
)
// BaseClient is the base client for Keyvault.
type BaseClient struct {
autorest.Client
BaseURI string
SubscriptionID string
}
// New creates an instance of the BaseClient client.
func New(subscriptionID string) BaseClient {
return NewWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewWithBaseURI creates an instance of the BaseClient client.
func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient {
return BaseClient{
Client: autorest.NewClientWithUserAgent(UserAgent()),
BaseURI: baseURI,
SubscriptionID: subscriptionID,
}
}
@@ -0,0 +1,431 @@
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 (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/to"
"github.com/satori/go.uuid"
"net/http"
)
// 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"
)
// 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"
)
// 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"
)
// SkuName enumerates the values for sku name.
type SkuName string
const (
// Premium ...
Premium SkuName = "premium"
// Standard ...
Standard SkuName = "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 {
// TenantID - The Azure Active Directory tenant ID that should be used for authenticating requests to the key vault.
TenantID *uuid.UUID `json:"tenantId,omitempty"`
// ObjectID - The object ID of a user, service principal or security group in the Azure Active Directory tenant for the vault. The object ID must be unique for the list of access policies.
ObjectID *string `json:"objectId,omitempty"`
// ApplicationID - Application ID of the client making request on behalf of a principal
ApplicationID *uuid.UUID `json:"applicationId,omitempty"`
// Permissions - Permissions the identity has for keys, secrets and certificates.
Permissions *Permissions `json:"permissions,omitempty"`
}
// Permissions permissions the identity has for keys, secrets and certificates.
type Permissions struct {
// Keys - Permissions to keys
Keys *[]KeyPermissions `json:"keys,omitempty"`
// Secrets - Permissions to secrets
Secrets *[]SecretPermissions `json:"secrets,omitempty"`
// Certificates - Permissions to certificates
Certificates *[]CertificatePermissions `json:"certificates,omitempty"`
}
// Resource key Vault resource
type Resource struct {
// ID - The Azure Resource Manager resource ID for the key vault.
ID *string `json:"id,omitempty"`
// Name - The name of the key vault.
Name *string `json:"name,omitempty"`
// Type - The resource type of the key vault.
Type *string `json:"type,omitempty"`
// Location - The supported Azure location where the key vault should be created.
Location *string `json:"location,omitempty"`
// Tags - The tags that will be assigned to the key vault.
Tags *map[string]*string `json:"tags,omitempty"`
}
// ResourceListResult list of vault resources.
type ResourceListResult struct {
autorest.Response `json:"-"`
// Value - Gets the list of vault resources.
Value *[]Resource `json:"value,omitempty"`
// NextLink - Gets the URL to get the next set of vault resources.
NextLink *string `json:"nextLink,omitempty"`
}
// ResourceListResultIterator provides access to a complete listing of Resource values.
type ResourceListResultIterator struct {
i int
page ResourceListResultPage
}
// Next advances to the next value. If there was an error making
// the request the iterator does not advance and the error is returned.
func (iter *ResourceListResultIterator) Next() error {
iter.i++
if iter.i < len(iter.page.Values()) {
return nil
}
err := iter.page.Next()
if err != nil {
iter.i--
return err
}
iter.i = 0
return nil
}
// NotDone returns true if the enumeration should be started or is not yet complete.
func (iter ResourceListResultIterator) NotDone() bool {
return iter.page.NotDone() && iter.i < len(iter.page.Values())
}
// Response returns the raw server response from the last page request.
func (iter ResourceListResultIterator) Response() ResourceListResult {
return iter.page.Response()
}
// Value returns the current value or a zero-initialized value if the
// iterator has advanced beyond the end of the collection.
func (iter ResourceListResultIterator) Value() Resource {
if !iter.page.NotDone() {
return Resource{}
}
return iter.page.Values()[iter.i]
}
// IsEmpty returns true if the ListResult contains no values.
func (rlr ResourceListResult) IsEmpty() bool {
return rlr.Value == nil || len(*rlr.Value) == 0
}
// resourceListResultPreparer prepares a request to retrieve the next set of results.
// It returns nil if no more results exist.
func (rlr ResourceListResult) resourceListResultPreparer() (*http.Request, error) {
if rlr.NextLink == nil || len(to.String(rlr.NextLink)) < 1 {
return nil, nil
}
return autorest.Prepare(&http.Request{},
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(rlr.NextLink)))
}
// ResourceListResultPage contains a page of Resource values.
type ResourceListResultPage struct {
fn func(ResourceListResult) (ResourceListResult, error)
rlr ResourceListResult
}
// 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.
func (page *ResourceListResultPage) Next() error {
next, err := page.fn(page.rlr)
if err != nil {
return err
}
page.rlr = next
return nil
}
// NotDone returns true if the page enumeration should be started or is not yet complete.
func (page ResourceListResultPage) NotDone() bool {
return !page.rlr.IsEmpty()
}
// Response returns the raw server response from the last page request.
func (page ResourceListResultPage) Response() ResourceListResult {
return page.rlr
}
// Values returns the slice of values for the current page or nil if there are no values.
func (page ResourceListResultPage) Values() []Resource {
if page.rlr.IsEmpty() {
return nil
}
return *page.rlr.Value
}
// Sku SKU details
type Sku struct {
// Family - SKU family name
Family *string `json:"family,omitempty"`
// Name - SKU name to specify whether the key vault is a standard vault or a premium vault. Possible values include: 'Standard', 'Premium'
Name SkuName `json:"name,omitempty"`
}
// Vault resource information with extended details.
type Vault struct {
autorest.Response `json:"-"`
// ID - The Azure Resource Manager resource ID for the key vault.
ID *string `json:"id,omitempty"`
// Name - The name of the key vault.
Name *string `json:"name,omitempty"`
// Type - The resource type of the key vault.
Type *string `json:"type,omitempty"`
// Location - The supported Azure location where the key vault should be created.
Location *string `json:"location,omitempty"`
// Tags - The tags that will be assigned to the key vault.
Tags *map[string]*string `json:"tags,omitempty"`
// Properties - Properties of the vault
Properties *VaultProperties `json:"properties,omitempty"`
}
// VaultCreateOrUpdateParameters parameters for creating or updating a vault
type VaultCreateOrUpdateParameters struct {
// Location - The supported Azure location where the key vault should be created.
Location *string `json:"location,omitempty"`
// Tags - The tags that will be assigned to the key vault.
Tags *map[string]*string `json:"tags,omitempty"`
// Properties - Properties of the vault
Properties *VaultProperties `json:"properties,omitempty"`
}
// VaultListResult list of vaults
type VaultListResult struct {
autorest.Response `json:"-"`
// Value - Gets or sets the list of vaults.
Value *[]Vault `json:"value,omitempty"`
// NextLink - Gets or sets the URL to get the next set of vaults.
NextLink *string `json:"nextLink,omitempty"`
}
// VaultListResultIterator provides access to a complete listing of Vault values.
type VaultListResultIterator struct {
i int
page VaultListResultPage
}
// Next advances to the next value. If there was an error making
// the request the iterator does not advance and the error is returned.
func (iter *VaultListResultIterator) Next() error {
iter.i++
if iter.i < len(iter.page.Values()) {
return nil
}
err := iter.page.Next()
if err != nil {
iter.i--
return err
}
iter.i = 0
return nil
}
// NotDone returns true if the enumeration should be started or is not yet complete.
func (iter VaultListResultIterator) NotDone() bool {
return iter.page.NotDone() && iter.i < len(iter.page.Values())
}
// Response returns the raw server response from the last page request.
func (iter VaultListResultIterator) Response() VaultListResult {
return iter.page.Response()
}
// Value returns the current value or a zero-initialized value if the
// iterator has advanced beyond the end of the collection.
func (iter VaultListResultIterator) Value() Vault {
if !iter.page.NotDone() {
return Vault{}
}
return iter.page.Values()[iter.i]
}
// IsEmpty returns true if the ListResult contains no values.
func (vlr VaultListResult) IsEmpty() bool {
return vlr.Value == nil || len(*vlr.Value) == 0
}
// vaultListResultPreparer prepares a request to retrieve the next set of results.
// It returns nil if no more results exist.
func (vlr VaultListResult) vaultListResultPreparer() (*http.Request, error) {
if vlr.NextLink == nil || len(to.String(vlr.NextLink)) < 1 {
return nil, nil
}
return autorest.Prepare(&http.Request{},
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(vlr.NextLink)))
}
// VaultListResultPage contains a page of Vault values.
type VaultListResultPage struct {
fn func(VaultListResult) (VaultListResult, error)
vlr VaultListResult
}
// 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.
func (page *VaultListResultPage) Next() error {
next, err := page.fn(page.vlr)
if err != nil {
return err
}
page.vlr = next
return nil
}
// NotDone returns true if the page enumeration should be started or is not yet complete.
func (page VaultListResultPage) NotDone() bool {
return !page.vlr.IsEmpty()
}
// Response returns the raw server response from the last page request.
func (page VaultListResultPage) Response() VaultListResult {
return page.vlr
}
// Values returns the slice of values for the current page or nil if there are no values.
func (page VaultListResultPage) Values() []Vault {
if page.vlr.IsEmpty() {
return nil
}
return *page.vlr.Value
}
// VaultProperties properties of the vault
type VaultProperties struct {
// VaultURI - The URI of the vault for performing operations on keys and secrets.
VaultURI *string `json:"vaultUri,omitempty"`
// TenantID - The Azure Active Directory tenant ID that should be used for authenticating requests to the key vault.
TenantID *uuid.UUID `json:"tenantId,omitempty"`
// Sku - SKU details
Sku *Sku `json:"sku,omitempty"`
// AccessPolicies - An array of 0 to 16 identities that have access to the key vault. All identities in the array must use the same tenant ID as the key vault's tenant ID.
AccessPolicies *[]AccessPolicyEntry `json:"accessPolicies,omitempty"`
// EnabledForDeployment - Property to specify whether Azure Virtual Machines are permitted to retrieve certificates stored as secrets from the key vault.
EnabledForDeployment *bool `json:"enabledForDeployment,omitempty"`
// EnabledForDiskEncryption - Property to specify whether Azure Disk Encryption is permitted to retrieve secrets from the vault and unwrap keys.
EnabledForDiskEncryption *bool `json:"enabledForDiskEncryption,omitempty"`
// EnabledForTemplateDeployment - Property to specify whether Azure Resource Manager is permitted to retrieve secrets from the key vault.
EnabledForTemplateDeployment *bool `json:"enabledForTemplateDeployment,omitempty"`
// EnableSoftDelete - Property to specify whether the 'soft delete' functionality is enabled for this key vault.
EnableSoftDelete *bool `json:"enableSoftDelete,omitempty"`
}
@@ -0,0 +1,452 @@
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"
"net/http"
)
// VaultsClient is the the Azure management API provides a RESTful set of web services that interact with Azure Key
// Vault.
type VaultsClient struct {
BaseClient
}
// NewVaultsClient creates an instance of the VaultsClient client.
func NewVaultsClient(subscriptionID string) VaultsClient {
return NewVaultsClientWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewVaultsClientWithBaseURI creates an instance of the VaultsClient client.
func NewVaultsClientWithBaseURI(baseURI string, subscriptionID string) VaultsClient {
return VaultsClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateOrUpdate create or update a key vault in the specified subscription.
//
// resourceGroupName is the name of the Resource Group to which the server belongs. vaultName is name of the vault
// parameters is parameters to create or update the vault
func (client VaultsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, vaultName string, parameters VaultCreateOrUpdateParameters) (result Vault, err error) {
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: parameters,
Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.Properties", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.Properties.TenantID", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.Properties.Sku", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.Properties.Sku.Family", Name: validation.Null, Rule: true, Chain: nil}}},
{Target: "parameters.Properties.AccessPolicies", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.Properties.AccessPolicies", Name: validation.MaxItems, Rule: 16, Chain: nil}}},
}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "keyvault.VaultsClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, vaultName, parameters)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "CreateOrUpdate", nil, "Failure preparing request")
return
}
resp, err := client.CreateOrUpdateSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "CreateOrUpdate", resp, "Failure sending request")
return
}
result, err = client.CreateOrUpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "CreateOrUpdate", resp, "Failure responding to request")
}
return
}
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
func (client VaultsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, vaultName string, parameters VaultCreateOrUpdateParameters) (*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 = "2015-06-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
// http.Response Body if it receives an error.
func (client VaultsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
azure.DoRetryWithRegistration(client.Client))
}
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body.
func (client VaultsClient) CreateOrUpdateResponder(resp *http.Response) (result Vault, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Delete deletes the specified Azure key vault.
//
// resourceGroupName is the name of the Resource Group to which the vault belongs. vaultName is the name of the vault
// to delete
func (client VaultsClient) Delete(ctx context.Context, resourceGroupName string, vaultName string) (result autorest.Response, err error) {
req, err := client.DeletePreparer(ctx, resourceGroupName, vaultName)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Delete", nil, "Failure preparing request")
return
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Delete", resp, "Failure sending request")
return
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client VaultsClient) DeletePreparer(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 = "2015-06-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// DeleteSender sends the Delete request. The method will close the
// http.Response Body if it receives an error.
func (client VaultsClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
azure.DoRetryWithRegistration(client.Client))
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client VaultsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// Get gets the specified Azure key vault.
//
// resourceGroupName is the name of the Resource Group to which the vault belongs. vaultName is the name of the vault.
func (client VaultsClient) Get(ctx context.Context, resourceGroupName string, vaultName string) (result Vault, err error) {
req, err := client.GetPreparer(ctx, resourceGroupName, vaultName)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "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.VaultsClient", "Get", resp, "Failure sending request")
return
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client VaultsClient) GetPreparer(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 = "2015-06-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}", 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 VaultsClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
azure.DoRetryWithRegistration(client.Client))
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client VaultsClient) GetResponder(resp *http.Response) (result Vault, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// List the List operation gets information about the vaults associated with the subscription.
//
// filter is the filter to apply on the operation. top is maximum number of results to return.
func (client VaultsClient) List(ctx context.Context, filter string, top *int32) (result ResourceListResultPage, err error) {
result.fn = client.listNextResults
req, err := client.ListPreparer(ctx, filter, top)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "List", nil, "Failure preparing request")
return
}
resp, err := client.ListSender(req)
if err != nil {
result.rlr.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "List", resp, "Failure sending request")
return
}
result.rlr, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client VaultsClient) ListPreparer(ctx context.Context, filter string, top *int32) (*http.Request, error) {
pathParameters := map[string]interface{}{
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2015-11-01"
queryParameters := map[string]interface{}{
"$filter": autorest.Encode("query", filter),
"api-version": APIVersion,
}
if top != nil {
queryParameters["$top"] = autorest.Encode("query", *top)
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resources", 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 VaultsClient) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
azure.DoRetryWithRegistration(client.Client))
}
// ListResponder handles the response to the List request. The method always
// closes the http.Response Body.
func (client VaultsClient) ListResponder(resp *http.Response) (result ResourceListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
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 VaultsClient) listNextResults(lastResults ResourceListResult) (result ResourceListResult, err error) {
req, err := lastResults.resourceListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "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.VaultsClient", "listNextResults", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "listNextResults", resp, "Failure responding to next results request")
}
return
}
// ListComplete enumerates all values, automatically crossing page boundaries as required.
func (client VaultsClient) ListComplete(ctx context.Context, filter string, top *int32) (result ResourceListResultIterator, err error) {
result.page, err = client.List(ctx, filter, top)
return
}
// ListByResourceGroup the List operation gets information about the vaults associated with the subscription and within
// the specified resource group.
//
// resourceGroupName is the name of the Resource Group to which the vault belongs. top is maximum number of results to
// return.
func (client VaultsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, top *int32) (result VaultListResultPage, err error) {
result.fn = client.listByResourceGroupNextResults
req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, top)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListByResourceGroup", nil, "Failure preparing request")
return
}
resp, err := client.ListByResourceGroupSender(req)
if err != nil {
result.vlr.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListByResourceGroup", resp, "Failure sending request")
return
}
result.vlr, err = client.ListByResourceGroupResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListByResourceGroup", resp, "Failure responding to request")
}
return
}
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
func (client VaultsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, top *int32) (*http.Request, error) {
pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2015-06-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if top != nil {
queryParameters["$top"] = autorest.Encode("query", *top)
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
// http.Response Body if it receives an error.
func (client VaultsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
azure.DoRetryWithRegistration(client.Client))
}
// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
// closes the http.Response Body.
func (client VaultsClient) ListByResourceGroupResponder(resp *http.Response) (result VaultListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// listByResourceGroupNextResults retrieves the next set of results, if any.
func (client VaultsClient) listByResourceGroupNextResults(lastResults VaultListResult) (result VaultListResult, err error) {
req, err := lastResults.vaultListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListByResourceGroupSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
}
result, err = client.ListByResourceGroupResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
}
return
}
// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
func (client VaultsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, top *int32) (result VaultListResultIterator, err error) {
result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, top)
return
}
@@ -0,0 +1,28 @@
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.
// UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string {
return "Azure-SDK-For-Go/v12.2.0-beta services"
}
// Version returns the semantic version (see http://semver.org) of the client.
func Version() string {
return "v12.2.0-beta"
}
@@ -0,0 +1,51 @@
// Package keyvault implements the Azure ARM Keyvault service API version 2016-10-01.
//
// The Azure management API provides a RESTful set of web services that interact with Azure Key Vault.
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 (
"github.com/Azure/go-autorest/autorest"
)
const (
// DefaultBaseURI is the default URI used for the service Keyvault
DefaultBaseURI = "https://management.azure.com"
)
// BaseClient is the base client for Keyvault.
type BaseClient struct {
autorest.Client
BaseURI string
SubscriptionID string
}
// New creates an instance of the BaseClient client.
func New(subscriptionID string) BaseClient {
return NewWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewWithBaseURI creates an instance of the BaseClient client.
func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient {
return BaseClient{
Client: autorest.NewClientWithUserAgent(UserAgent()),
BaseURI: baseURI,
SubscriptionID: subscriptionID,
}
}
@@ -0,0 +1,627 @@
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 (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/date"
"github.com/Azure/go-autorest/autorest/to"
"github.com/satori/go.uuid"
"net/http"
)
// CertificatePermissions enumerates the values for certificate permissions.
type CertificatePermissions string
const (
// 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"
)
// CreateMode enumerates the values for create mode.
type CreateMode string
const (
// CreateModeDefault ...
CreateModeDefault CreateMode = "default"
// CreateModeRecover ...
CreateModeRecover CreateMode = "recover"
)
// 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"
)
// 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"
)
// SkuName enumerates the values for sku name.
type SkuName string
const (
// Premium ...
Premium SkuName = "premium"
// Standard ...
Standard SkuName = "standard"
)
// StoragePermissions enumerates the values for storage permissions.
type StoragePermissions string
const (
// StoragePermissionsDelete ...
StoragePermissionsDelete StoragePermissions = "delete"
// StoragePermissionsDeletesas ...
StoragePermissionsDeletesas StoragePermissions = "deletesas"
// StoragePermissionsGet ...
StoragePermissionsGet StoragePermissions = "get"
// StoragePermissionsGetsas ...
StoragePermissionsGetsas StoragePermissions = "getsas"
// StoragePermissionsList ...
StoragePermissionsList StoragePermissions = "list"
// StoragePermissionsListsas ...
StoragePermissionsListsas StoragePermissions = "listsas"
// StoragePermissionsRegeneratekey ...
StoragePermissionsRegeneratekey StoragePermissions = "regeneratekey"
// StoragePermissionsSet ...
StoragePermissionsSet StoragePermissions = "set"
// StoragePermissionsSetsas ...
StoragePermissionsSetsas StoragePermissions = "setsas"
// StoragePermissionsUpdate ...
StoragePermissionsUpdate StoragePermissions = "update"
)
// AccessPolicyEntry an identity that have access to the key vault. All identities in the array must use the same
// tenant ID as the key vault's tenant ID.
type AccessPolicyEntry struct {
// TenantID - The Azure Active Directory tenant ID that should be used for authenticating requests to the key vault.
TenantID *uuid.UUID `json:"tenantId,omitempty"`
// ObjectID - The object ID of a user, service principal or security group in the Azure Active Directory tenant for the vault. The object ID must be unique for the list of access policies.
ObjectID *string `json:"objectId,omitempty"`
// ApplicationID - Application ID of the client making request on behalf of a principal
ApplicationID *uuid.UUID `json:"applicationId,omitempty"`
// Permissions - Permissions the identity has for keys, secrets and certificates.
Permissions *Permissions `json:"permissions,omitempty"`
}
// DeletedVault deleted vault information with extended details.
type DeletedVault struct {
autorest.Response `json:"-"`
// ID - The resource ID for the deleted key vault.
ID *string `json:"id,omitempty"`
// Name - The name of the key vault.
Name *string `json:"name,omitempty"`
// Type - The resource type of the key vault.
Type *string `json:"type,omitempty"`
// Properties - Properties of the vault
Properties *DeletedVaultProperties `json:"properties,omitempty"`
}
// DeletedVaultListResult list of vaults
type DeletedVaultListResult struct {
autorest.Response `json:"-"`
// Value - The list of deleted vaults.
Value *[]DeletedVault `json:"value,omitempty"`
// NextLink - The URL to get the next set of deleted vaults.
NextLink *string `json:"nextLink,omitempty"`
}
// DeletedVaultListResultIterator provides access to a complete listing of DeletedVault values.
type DeletedVaultListResultIterator struct {
i int
page DeletedVaultListResultPage
}
// Next 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 *DeletedVaultListResultIterator) Next() error {
iter.i++
if iter.i < len(iter.page.Values()) {
return nil
}
err := iter.page.Next()
if err != nil {
iter.i--
return err
}
iter.i = 0
return nil
}
// NotDone returns true if the enumeration should be started or is not yet complete.
func (iter DeletedVaultListResultIterator) 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 DeletedVaultListResultIterator) Response() DeletedVaultListResult {
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 DeletedVaultListResultIterator) Value() DeletedVault {
if !iter.page.NotDone() {
return DeletedVault{}
}
return iter.page.Values()[iter.i]
}
// IsEmpty returns true if the ListResult contains no values.
func (dvlr DeletedVaultListResult) IsEmpty() bool {
return dvlr.Value == nil || len(*dvlr.Value) == 0
}
// deletedVaultListResultPreparer prepares a request to retrieve the next set of results.
// It returns nil if no more results exist.
func (dvlr DeletedVaultListResult) deletedVaultListResultPreparer() (*http.Request, error) {
if dvlr.NextLink == nil || len(to.String(dvlr.NextLink)) < 1 {
return nil, nil
}
return autorest.Prepare(&http.Request{},
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(dvlr.NextLink)))
}
// DeletedVaultListResultPage contains a page of DeletedVault values.
type DeletedVaultListResultPage struct {
fn func(DeletedVaultListResult) (DeletedVaultListResult, error)
dvlr DeletedVaultListResult
}
// 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.
func (page *DeletedVaultListResultPage) Next() error {
next, err := page.fn(page.dvlr)
if err != nil {
return err
}
page.dvlr = next
return nil
}
// NotDone returns true if the page enumeration should be started or is not yet complete.
func (page DeletedVaultListResultPage) NotDone() bool {
return !page.dvlr.IsEmpty()
}
// Response returns the raw server response from the last page request.
func (page DeletedVaultListResultPage) Response() DeletedVaultListResult {
return page.dvlr
}
// Values returns the slice of values for the current page or nil if there are no values.
func (page DeletedVaultListResultPage) Values() []DeletedVault {
if page.dvlr.IsEmpty() {
return nil
}
return *page.dvlr.Value
}
// DeletedVaultProperties properties of the deleted vault.
type DeletedVaultProperties struct {
// VaultID - The resource id of the original vault.
VaultID *string `json:"vaultId,omitempty"`
// Location - The location of the original vault.
Location *string `json:"location,omitempty"`
// DeletionDate - The deleted date.
DeletionDate *date.Time `json:"deletionDate,omitempty"`
// ScheduledPurgeDate - The scheduled purged date.
ScheduledPurgeDate *date.Time `json:"scheduledPurgeDate,omitempty"`
// Tags - Tags of the original vault.
Tags *map[string]*string `json:"tags,omitempty"`
}
// Permissions permissions the identity has for keys, secrets, certificates and storage.
type Permissions struct {
// Keys - Permissions to keys
Keys *[]KeyPermissions `json:"keys,omitempty"`
// Secrets - Permissions to secrets
Secrets *[]SecretPermissions `json:"secrets,omitempty"`
// Certificates - Permissions to certificates
Certificates *[]CertificatePermissions `json:"certificates,omitempty"`
// Storage - Permissions to storage accounts
Storage *[]StoragePermissions `json:"storage,omitempty"`
}
// Resource key Vault resource
type Resource struct {
// ID - The Azure Resource Manager resource ID for the key vault.
ID *string `json:"id,omitempty"`
// Name - The name of the key vault.
Name *string `json:"name,omitempty"`
// Type - The resource type of the key vault.
Type *string `json:"type,omitempty"`
// Location - The supported Azure location where the key vault should be created.
Location *string `json:"location,omitempty"`
// Tags - The tags that will be assigned to the key vault.
Tags *map[string]*string `json:"tags,omitempty"`
}
// ResourceListResult list of vault resources.
type ResourceListResult struct {
autorest.Response `json:"-"`
// Value - Gets the list of vault resources.
Value *[]Resource `json:"value,omitempty"`
// NextLink - Gets the URL to get the next set of vault resources.
NextLink *string `json:"nextLink,omitempty"`
}
// ResourceListResultIterator provides access to a complete listing of Resource values.
type ResourceListResultIterator struct {
i int
page ResourceListResultPage
}
// Next advances to the next value. If there was an error making
// the request the iterator does not advance and the error is returned.
func (iter *ResourceListResultIterator) Next() error {
iter.i++
if iter.i < len(iter.page.Values()) {
return nil
}
err := iter.page.Next()
if err != nil {
iter.i--
return err
}
iter.i = 0
return nil
}
// NotDone returns true if the enumeration should be started or is not yet complete.
func (iter ResourceListResultIterator) NotDone() bool {
return iter.page.NotDone() && iter.i < len(iter.page.Values())
}
// Response returns the raw server response from the last page request.
func (iter ResourceListResultIterator) Response() ResourceListResult {
return iter.page.Response()
}
// Value returns the current value or a zero-initialized value if the
// iterator has advanced beyond the end of the collection.
func (iter ResourceListResultIterator) Value() Resource {
if !iter.page.NotDone() {
return Resource{}
}
return iter.page.Values()[iter.i]
}
// IsEmpty returns true if the ListResult contains no values.
func (rlr ResourceListResult) IsEmpty() bool {
return rlr.Value == nil || len(*rlr.Value) == 0
}
// resourceListResultPreparer prepares a request to retrieve the next set of results.
// It returns nil if no more results exist.
func (rlr ResourceListResult) resourceListResultPreparer() (*http.Request, error) {
if rlr.NextLink == nil || len(to.String(rlr.NextLink)) < 1 {
return nil, nil
}
return autorest.Prepare(&http.Request{},
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(rlr.NextLink)))
}
// ResourceListResultPage contains a page of Resource values.
type ResourceListResultPage struct {
fn func(ResourceListResult) (ResourceListResult, error)
rlr ResourceListResult
}
// 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.
func (page *ResourceListResultPage) Next() error {
next, err := page.fn(page.rlr)
if err != nil {
return err
}
page.rlr = next
return nil
}
// NotDone returns true if the page enumeration should be started or is not yet complete.
func (page ResourceListResultPage) NotDone() bool {
return !page.rlr.IsEmpty()
}
// Response returns the raw server response from the last page request.
func (page ResourceListResultPage) Response() ResourceListResult {
return page.rlr
}
// Values returns the slice of values for the current page or nil if there are no values.
func (page ResourceListResultPage) Values() []Resource {
if page.rlr.IsEmpty() {
return nil
}
return *page.rlr.Value
}
// Sku SKU details
type Sku struct {
// Family - SKU family name
Family *string `json:"family,omitempty"`
// Name - SKU name to specify whether the key vault is a standard vault or a premium vault. Possible values include: 'Standard', 'Premium'
Name SkuName `json:"name,omitempty"`
}
// Vault resource information with extended details.
type Vault struct {
autorest.Response `json:"-"`
// ID - The Azure Resource Manager resource ID for the key vault.
ID *string `json:"id,omitempty"`
// Name - The name of the key vault.
Name *string `json:"name,omitempty"`
// Type - The resource type of the key vault.
Type *string `json:"type,omitempty"`
// Location - The supported Azure location where the key vault should be created.
Location *string `json:"location,omitempty"`
// Tags - The tags that will be assigned to the key vault.
Tags *map[string]*string `json:"tags,omitempty"`
// Properties - Properties of the vault
Properties *VaultProperties `json:"properties,omitempty"`
}
// VaultCreateOrUpdateParameters parameters for creating or updating a vault
type VaultCreateOrUpdateParameters struct {
// Location - The supported Azure location where the key vault should be created.
Location *string `json:"location,omitempty"`
// Tags - The tags that will be assigned to the key vault.
Tags *map[string]*string `json:"tags,omitempty"`
// Properties - Properties of the vault
Properties *VaultProperties `json:"properties,omitempty"`
}
// VaultListResult list of vaults
type VaultListResult struct {
autorest.Response `json:"-"`
// Value - Gets or sets the list of vaults.
Value *[]Vault `json:"value,omitempty"`
// NextLink - Gets or sets the URL to get the next set of vaults.
NextLink *string `json:"nextLink,omitempty"`
}
// VaultListResultIterator provides access to a complete listing of Vault values.
type VaultListResultIterator struct {
i int
page VaultListResultPage
}
// Next advances to the next value. If there was an error making
// the request the iterator does not advance and the error is returned.
func (iter *VaultListResultIterator) Next() error {
iter.i++
if iter.i < len(iter.page.Values()) {
return nil
}
err := iter.page.Next()
if err != nil {
iter.i--
return err
}
iter.i = 0
return nil
}
// NotDone returns true if the enumeration should be started or is not yet complete.
func (iter VaultListResultIterator) NotDone() bool {
return iter.page.NotDone() && iter.i < len(iter.page.Values())
}
// Response returns the raw server response from the last page request.
func (iter VaultListResultIterator) Response() VaultListResult {
return iter.page.Response()
}
// Value returns the current value or a zero-initialized value if the
// iterator has advanced beyond the end of the collection.
func (iter VaultListResultIterator) Value() Vault {
if !iter.page.NotDone() {
return Vault{}
}
return iter.page.Values()[iter.i]
}
// IsEmpty returns true if the ListResult contains no values.
func (vlr VaultListResult) IsEmpty() bool {
return vlr.Value == nil || len(*vlr.Value) == 0
}
// vaultListResultPreparer prepares a request to retrieve the next set of results.
// It returns nil if no more results exist.
func (vlr VaultListResult) vaultListResultPreparer() (*http.Request, error) {
if vlr.NextLink == nil || len(to.String(vlr.NextLink)) < 1 {
return nil, nil
}
return autorest.Prepare(&http.Request{},
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(vlr.NextLink)))
}
// VaultListResultPage contains a page of Vault values.
type VaultListResultPage struct {
fn func(VaultListResult) (VaultListResult, error)
vlr VaultListResult
}
// 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.
func (page *VaultListResultPage) Next() error {
next, err := page.fn(page.vlr)
if err != nil {
return err
}
page.vlr = next
return nil
}
// NotDone returns true if the page enumeration should be started or is not yet complete.
func (page VaultListResultPage) NotDone() bool {
return !page.vlr.IsEmpty()
}
// Response returns the raw server response from the last page request.
func (page VaultListResultPage) Response() VaultListResult {
return page.vlr
}
// Values returns the slice of values for the current page or nil if there are no values.
func (page VaultListResultPage) Values() []Vault {
if page.vlr.IsEmpty() {
return nil
}
return *page.vlr.Value
}
// VaultProperties properties of the vault
type VaultProperties struct {
// TenantID - The Azure Active Directory tenant ID that should be used for authenticating requests to the key vault.
TenantID *uuid.UUID `json:"tenantId,omitempty"`
// Sku - SKU details
Sku *Sku `json:"sku,omitempty"`
// AccessPolicies - An array of 0 to 16 identities that have access to the key vault. All identities in the array must use the same tenant ID as the key vault's tenant ID.
AccessPolicies *[]AccessPolicyEntry `json:"accessPolicies,omitempty"`
// VaultURI - The URI of the vault for performing operations on keys and secrets.
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"`
// EnabledForDiskEncryption - Property to specify whether Azure Disk Encryption is permitted to retrieve secrets from the vault and unwrap keys.
EnabledForDiskEncryption *bool `json:"enabledForDiskEncryption,omitempty"`
// EnabledForTemplateDeployment - Property to specify whether Azure Resource Manager is permitted to retrieve secrets from the key vault.
EnabledForTemplateDeployment *bool `json:"enabledForTemplateDeployment,omitempty"`
// EnableSoftDelete - Property to specify whether the 'soft delete' functionality is enabled for this key vault. It does not accept false value.
EnableSoftDelete *bool `json:"enableSoftDelete,omitempty"`
// CreateMode - The vault's create mode to indicate whether the vault need to be recovered or not. Possible values include: 'CreateModeRecover', 'CreateModeDefault'
CreateMode CreateMode `json:"createMode,omitempty"`
}
// VaultsPurgeDeletedFuture an abstraction for monitoring and retrieving the results of a long-running operation.
type VaultsPurgeDeletedFuture struct {
azure.Future
req *http.Request
}
// Result returns the result of the asynchronous operation.
// If the operation has not completed it will return an error.
func (future VaultsPurgeDeletedFuture) Result(client VaultsClient) (ar autorest.Response, err error) {
var done bool
done, err = future.Done(client)
if err != nil {
return
}
if !done {
return ar, autorest.NewError("keyvault.VaultsPurgeDeletedFuture", "Result", "asynchronous operation has not completed")
}
if future.PollingMethod() == azure.PollingLocation {
ar, err = client.PurgeDeletedResponder(future.Response())
return
}
var resp *http.Response
resp, err = autorest.SendWithSender(client, autorest.ChangeToGet(future.req),
autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...))
if err != nil {
return
}
ar, err = client.PurgeDeletedResponder(resp)
return
}
@@ -0,0 +1,675 @@
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"
"net/http"
)
// VaultsClient is the the Azure management API provides a RESTful set of web services that interact with Azure Key
// Vault.
type VaultsClient struct {
BaseClient
}
// NewVaultsClient creates an instance of the VaultsClient client.
func NewVaultsClient(subscriptionID string) VaultsClient {
return NewVaultsClientWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewVaultsClientWithBaseURI creates an instance of the VaultsClient client.
func NewVaultsClientWithBaseURI(baseURI string, subscriptionID string) VaultsClient {
return VaultsClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateOrUpdate create or update a key vault in the specified subscription.
//
// resourceGroupName is the name of the Resource Group to which the server belongs. vaultName is name of the vault
// parameters is parameters to create or update the vault
func (client VaultsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, vaultName string, parameters VaultCreateOrUpdateParameters) (result Vault, err error) {
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: parameters,
Constraints: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.Properties", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.Properties.TenantID", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.Properties.Sku", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.Properties.Sku.Family", Name: validation.Null, Rule: true, Chain: nil}}},
{Target: "parameters.Properties.AccessPolicies", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.Properties.AccessPolicies", Name: validation.MaxItems, Rule: 16, Chain: nil}}},
}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "keyvault.VaultsClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, vaultName, parameters)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "CreateOrUpdate", nil, "Failure preparing request")
return
}
resp, err := client.CreateOrUpdateSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "CreateOrUpdate", resp, "Failure sending request")
return
}
result, err = client.CreateOrUpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "CreateOrUpdate", resp, "Failure responding to request")
}
return
}
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
func (client VaultsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, vaultName string, parameters VaultCreateOrUpdateParameters) (*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 = "2016-10-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
// http.Response Body if it receives an error.
func (client VaultsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
azure.DoRetryWithRegistration(client.Client))
}
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body.
func (client VaultsClient) CreateOrUpdateResponder(resp *http.Response) (result Vault, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Delete deletes the specified Azure key vault.
//
// resourceGroupName is the name of the Resource Group to which the vault belongs. vaultName is the name of the vault
// to delete
func (client VaultsClient) Delete(ctx context.Context, resourceGroupName string, vaultName string) (result autorest.Response, err error) {
req, err := client.DeletePreparer(ctx, resourceGroupName, vaultName)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Delete", nil, "Failure preparing request")
return
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Delete", resp, "Failure sending request")
return
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client VaultsClient) DeletePreparer(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 = "2016-10-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults/{vaultName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// DeleteSender sends the Delete request. The method will close the
// http.Response Body if it receives an error.
func (client VaultsClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
azure.DoRetryWithRegistration(client.Client))
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client VaultsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByClosing())
result.Response = resp
return
}
// Get gets the specified Azure key vault.
//
// resourceGroupName is the name of the Resource Group to which the vault belongs. vaultName is the name of the vault.
func (client VaultsClient) Get(ctx context.Context, resourceGroupName string, vaultName string) (result Vault, err error) {
req, err := client.GetPreparer(ctx, resourceGroupName, vaultName)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "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.VaultsClient", "Get", resp, "Failure sending request")
return
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client VaultsClient) GetPreparer(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 = "2016-10-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}", 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 VaultsClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
azure.DoRetryWithRegistration(client.Client))
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client VaultsClient) GetResponder(resp *http.Response) (result Vault, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// GetDeleted gets the deleted Azure key vault.
//
// vaultName is the name of the vault. location is the location of the deleted vault.
func (client VaultsClient) GetDeleted(ctx context.Context, vaultName string, location string) (result DeletedVault, err error) {
req, err := client.GetDeletedPreparer(ctx, vaultName, location)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "GetDeleted", nil, "Failure preparing request")
return
}
resp, err := client.GetDeletedSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "GetDeleted", resp, "Failure sending request")
return
}
result, err = client.GetDeletedResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "GetDeleted", resp, "Failure responding to request")
}
return
}
// GetDeletedPreparer prepares the GetDeleted request.
func (client VaultsClient) GetDeletedPreparer(ctx context.Context, vaultName string, location string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"location": autorest.Encode("path", location),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
"vaultName": autorest.Encode("path", vaultName),
}
const APIVersion = "2016-10-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedVaults/{vaultName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// GetDeletedSender sends the GetDeleted request. The method will close the
// http.Response Body if it receives an error.
func (client VaultsClient) GetDeletedSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
azure.DoRetryWithRegistration(client.Client))
}
// GetDeletedResponder handles the response to the GetDeleted request. The method always
// closes the http.Response Body.
func (client VaultsClient) GetDeletedResponder(resp *http.Response) (result DeletedVault, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// List the List operation gets information about the vaults associated with the subscription.
//
// filter is the filter to apply on the operation. top is maximum number of results to return.
func (client VaultsClient) List(ctx context.Context, filter string, top *int32) (result ResourceListResultPage, err error) {
result.fn = client.listNextResults
req, err := client.ListPreparer(ctx, filter, top)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "List", nil, "Failure preparing request")
return
}
resp, err := client.ListSender(req)
if err != nil {
result.rlr.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "List", resp, "Failure sending request")
return
}
result.rlr, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client VaultsClient) ListPreparer(ctx context.Context, filter string, top *int32) (*http.Request, error) {
pathParameters := map[string]interface{}{
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2015-11-01"
queryParameters := map[string]interface{}{
"$filter": autorest.Encode("query", filter),
"api-version": APIVersion,
}
if top != nil {
queryParameters["$top"] = autorest.Encode("query", *top)
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resources", 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 VaultsClient) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
azure.DoRetryWithRegistration(client.Client))
}
// ListResponder handles the response to the List request. The method always
// closes the http.Response Body.
func (client VaultsClient) ListResponder(resp *http.Response) (result ResourceListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
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 VaultsClient) listNextResults(lastResults ResourceListResult) (result ResourceListResult, err error) {
req, err := lastResults.resourceListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "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.VaultsClient", "listNextResults", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "listNextResults", resp, "Failure responding to next results request")
}
return
}
// ListComplete enumerates all values, automatically crossing page boundaries as required.
func (client VaultsClient) ListComplete(ctx context.Context, filter string, top *int32) (result ResourceListResultIterator, err error) {
result.page, err = client.List(ctx, filter, top)
return
}
// ListByResourceGroup the List operation gets information about the vaults associated with the subscription and within
// the specified resource group.
//
// resourceGroupName is the name of the Resource Group to which the vault belongs. top is maximum number of results to
// return.
func (client VaultsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, top *int32) (result VaultListResultPage, err error) {
result.fn = client.listByResourceGroupNextResults
req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName, top)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListByResourceGroup", nil, "Failure preparing request")
return
}
resp, err := client.ListByResourceGroupSender(req)
if err != nil {
result.vlr.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListByResourceGroup", resp, "Failure sending request")
return
}
result.vlr, err = client.ListByResourceGroupResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListByResourceGroup", resp, "Failure responding to request")
}
return
}
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
func (client VaultsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string, top *int32) (*http.Request, error) {
pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-10-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if top != nil {
queryParameters["$top"] = autorest.Encode("query", *top)
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.KeyVault/vaults", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
// http.Response Body if it receives an error.
func (client VaultsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
azure.DoRetryWithRegistration(client.Client))
}
// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
// closes the http.Response Body.
func (client VaultsClient) ListByResourceGroupResponder(resp *http.Response) (result VaultListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// listByResourceGroupNextResults retrieves the next set of results, if any.
func (client VaultsClient) listByResourceGroupNextResults(lastResults VaultListResult) (result VaultListResult, err error) {
req, err := lastResults.vaultListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListByResourceGroupSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
}
result, err = client.ListByResourceGroupResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
}
return
}
// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
func (client VaultsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string, top *int32) (result VaultListResultIterator, err error) {
result.page, err = client.ListByResourceGroup(ctx, resourceGroupName, top)
return
}
// ListDeleted gets information about the deleted vaults in a subscription.
func (client VaultsClient) ListDeleted(ctx context.Context) (result DeletedVaultListResultPage, err error) {
result.fn = client.listDeletedNextResults
req, err := client.ListDeletedPreparer(ctx)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListDeleted", nil, "Failure preparing request")
return
}
resp, err := client.ListDeletedSender(req)
if err != nil {
result.dvlr.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListDeleted", resp, "Failure sending request")
return
}
result.dvlr, err = client.ListDeletedResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "ListDeleted", resp, "Failure responding to request")
}
return
}
// ListDeletedPreparer prepares the ListDeleted request.
func (client VaultsClient) ListDeletedPreparer(ctx context.Context) (*http.Request, error) {
pathParameters := map[string]interface{}{
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-10-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/deletedVaults", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// ListDeletedSender sends the ListDeleted request. The method will close the
// http.Response Body if it receives an error.
func (client VaultsClient) ListDeletedSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req,
azure.DoRetryWithRegistration(client.Client))
}
// ListDeletedResponder handles the response to the ListDeleted request. The method always
// closes the http.Response Body.
func (client VaultsClient) ListDeletedResponder(resp *http.Response) (result DeletedVaultListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// listDeletedNextResults retrieves the next set of results, if any.
func (client VaultsClient) listDeletedNextResults(lastResults DeletedVaultListResult) (result DeletedVaultListResult, err error) {
req, err := lastResults.deletedVaultListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "listDeletedNextResults", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListDeletedSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "keyvault.VaultsClient", "listDeletedNextResults", resp, "Failure sending next results request")
}
result, err = client.ListDeletedResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "listDeletedNextResults", resp, "Failure responding to next results request")
}
return
}
// ListDeletedComplete enumerates all values, automatically crossing page boundaries as required.
func (client VaultsClient) ListDeletedComplete(ctx context.Context) (result DeletedVaultListResultIterator, err error) {
result.page, err = client.ListDeleted(ctx)
return
}
// PurgeDeleted permanently deletes the specified vault. aka Purges the deleted Azure key vault.
//
// vaultName is the name of the soft-deleted vault. location is the location of the soft-deleted vault.
func (client VaultsClient) PurgeDeleted(ctx context.Context, vaultName string, location string) (result VaultsPurgeDeletedFuture, err error) {
req, err := client.PurgeDeletedPreparer(ctx, vaultName, location)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "PurgeDeleted", nil, "Failure preparing request")
return
}
result, err = client.PurgeDeletedSender(req)
if err != nil {
err = autorest.NewErrorWithError(err, "keyvault.VaultsClient", "PurgeDeleted", result.Response(), "Failure sending request")
return
}
return
}
// PurgeDeletedPreparer prepares the PurgeDeleted request.
func (client VaultsClient) PurgeDeletedPreparer(ctx context.Context, vaultName string, location string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"location": autorest.Encode("path", location),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
"vaultName": autorest.Encode("path", vaultName),
}
const APIVersion = "2016-10-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.KeyVault/locations/{location}/deletedVaults/{vaultName}/purge", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare((&http.Request{}).WithContext(ctx))
}
// PurgeDeletedSender sends the PurgeDeleted request. The method will close the
// http.Response Body if it receives an error.
func (client VaultsClient) PurgeDeletedSender(req *http.Request) (future VaultsPurgeDeletedFuture, err error) {
sender := autorest.DecorateSender(client, azure.DoRetryWithRegistration(client.Client))
future.Future = azure.NewFuture(req)
future.req = req
_, err = future.Done(sender)
if err != nil {
return
}
err = autorest.Respond(future.Response(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted))
return
}
// PurgeDeletedResponder handles the response to the PurgeDeleted request. The method always
// closes the http.Response Body.
func (client VaultsClient) PurgeDeletedResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByClosing())
result.Response = resp
return
}
@@ -0,0 +1,28 @@
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.
// UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string {
return "Azure-SDK-For-Go/v12.2.0-beta services"
}
// Version returns the semantic version (see http://semver.org) of the client.
func Version() string {
return "v12.2.0-beta"
}