|
|
|
|
@ -9,7 +9,6 @@ import (
|
|
|
|
|
"net/url"
|
|
|
|
|
|
|
|
|
|
"github.com/Azure/go-autorest/autorest"
|
|
|
|
|
"github.com/Azure/go-autorest/autorest/azure"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
const (
|
|
|
|
|
@ -20,9 +19,6 @@ const (
|
|
|
|
|
type AZVaultClientIface interface {
|
|
|
|
|
GetSecret(string, string) (*Secret, error)
|
|
|
|
|
SetSecret(string, string, string) error
|
|
|
|
|
DeletePreparer(string, string) (*http.Request, error)
|
|
|
|
|
DeleteResponder(*http.Response) (autorest.Response, error)
|
|
|
|
|
DeleteSender(*http.Request) (*http.Response, error)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type VaultClient struct {
|
|
|
|
|
@ -137,72 +133,6 @@ func (client *VaultClient) SetSecret(vaultName, secretName string, secretValue s
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 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 *VaultClient) Delete(resourceGroupName string, vaultName string) (result autorest.Response, err error) {
|
|
|
|
|
req, err := client.DeletePreparer(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 *VaultClient) DeletePreparer(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),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
queryParameters := map[string]interface{}{
|
|
|
|
|
"api-version": AzureVaultApiVersion,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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{})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DeleteSender sends the Delete request. The method will close the
|
|
|
|
|
// http.Response Body if it receives an error.
|
|
|
|
|
func (client *VaultClient) 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 *VaultClient) 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
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (client *VaultClient) getVaultUrl(vaultName string) string {
|
|
|
|
|
return fmt.Sprintf("%s://%s.%s/", client.keyVaultEndpoint.Scheme, vaultName, client.keyVaultEndpoint.Host)
|
|
|
|
|
}
|
|
|
|
|
|