diff --git a/sdk/keyvault/azkeys/CHANGELOG.md b/sdk/keyvault/azkeys/CHANGELOG.md index f466da6f6d91..b9b69eb04448 100644 --- a/sdk/keyvault/azkeys/CHANGELOG.md +++ b/sdk/keyvault/azkeys/CHANGELOG.md @@ -1,15 +1,12 @@ # Release History -## 0.1.1 (Unreleased) - -### Features Added - -### Breaking Changes +## 0.2.0 (2022-01-12) ### Bugs Fixed * Fixes a bug in `crypto.NewClient` where the key version was required in the path, it is no longer required but is recommended. ### Other Changes +* Updates `azcore` dependency from `v0.20.0` to `v0.21.0` ## 0.1.0 (2021-11-09) * This is the initial release of the `azkeys` library diff --git a/sdk/keyvault/azkeys/autorest.md b/sdk/keyvault/azkeys/autorest.md index 574f3caae415..e530df9fc0ae 100644 --- a/sdk/keyvault/azkeys/autorest.md +++ b/sdk/keyvault/azkeys/autorest.md @@ -17,7 +17,7 @@ module: azkeys openapi-type: "data-plane" security: "AADToken" security-scopes: "https://vault.azure.net/.default" -use: "@autorest/go@4.0.0-preview.30" +use: "@autorest/go@4.0.0-preview.35" module-version: 0.1.0 export-clients: true ``` diff --git a/sdk/keyvault/azkeys/client.go b/sdk/keyvault/azkeys/client.go index e3fe61820646..bd1e6819af14 100644 --- a/sdk/keyvault/azkeys/client.go +++ b/sdk/keyvault/azkeys/client.go @@ -14,7 +14,8 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - generated "github.com/Azure/azure-sdk-for-go/sdk/keyvault/azkeys/internal/generated" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/keyvault/azkeys/internal/generated" shared "github.com/Azure/azure-sdk-for-go/sdk/keyvault/internal" ) @@ -58,9 +59,9 @@ func NewClient(vaultUrl string, credential azcore.TokenCredential, options *Clie shared.NewKeyVaultChallengePolicy(credential), ) - conn := generated.NewConnection(genOptions) + pl := runtime.NewPipeline(generated.ModuleName, generated.ModuleVersion, runtime.PipelineOptions{}, genOptions) return &Client{ - kvClient: generated.NewKeyVaultClient(conn), + kvClient: generated.NewKeyVaultClient(pl), vaultUrl: vaultUrl, }, nil } @@ -603,9 +604,9 @@ func (s *startDeleteKeyPoller) Poll(ctx context.Context) (*http.Response, error) return resp.RawResponse, nil } - var httpResponseErr azcore.HTTPResponse + var httpResponseErr *azcore.ResponseError if errors.As(err, &httpResponseErr) { - if httpResponseErr.RawResponse().StatusCode == http.StatusNotFound { + if httpResponseErr.StatusCode == http.StatusNotFound { // This is the expected result return s.deleteResponse.RawResponse, nil } @@ -660,9 +661,9 @@ func (c *Client) BeginDeleteKey(ctx context.Context, keyName string, options *Be } getResp, err := c.kvClient.GetDeletedKey(ctx, c.vaultUrl, keyName, nil) - var httpErr azcore.HTTPResponse + var httpErr *azcore.ResponseError if errors.As(err, &httpErr) { - if httpErr.RawResponse().StatusCode != http.StatusNotFound { + if httpErr.StatusCode != http.StatusNotFound { return DeleteKeyPollerResponse{}, err } } @@ -765,9 +766,9 @@ func (b *beginRecoverPoller) Done() bool { func (b *beginRecoverPoller) Poll(ctx context.Context) (*http.Response, error) { resp, err := b.client.GetKey(ctx, b.vaultUrl, b.keyName, "", nil) b.lastResponse = resp - var httpErr azcore.HTTPResponse + var httpErr *azcore.ResponseError if errors.As(err, &httpErr) { - return httpErr.RawResponse(), err + return httpErr.RawResponse, err } return resp.RawResponse, nil } @@ -845,9 +846,9 @@ func (c *Client) BeginRecoverDeletedKey(ctx context.Context, keyName string, opt } getResp, err := c.kvClient.GetKey(ctx, c.vaultUrl, keyName, "", nil) - var httpErr azcore.HTTPResponse + var httpErr *azcore.ResponseError if errors.As(err, &httpErr) { - if httpErr.RawResponse().StatusCode != http.StatusNotFound { + if httpErr.StatusCode != http.StatusNotFound { return RecoverDeletedKeyPollerResponse{}, err } } diff --git a/sdk/keyvault/azkeys/client_test.go b/sdk/keyvault/azkeys/client_test.go index 9ed0275ee9fa..5c24096a1355 100644 --- a/sdk/keyvault/azkeys/client_test.go +++ b/sdk/keyvault/azkeys/client_test.go @@ -263,13 +263,13 @@ func TestBackupKey(t *testing.T) { require.NoError(t, err) _, err = client.GetKey(ctx, key, nil) - var httpErr azcore.HTTPResponse + var httpErr *azcore.ResponseError require.True(t, errors.As(err, &httpErr)) - require.Equal(t, httpErr.RawResponse().StatusCode, http.StatusNotFound) + require.Equal(t, httpErr.RawResponse.StatusCode, http.StatusNotFound) _, err = client.GetDeletedKey(ctx, key, nil) require.True(t, errors.As(err, &httpErr)) - require.Equal(t, httpErr.RawResponse().StatusCode, http.StatusNotFound) + require.Equal(t, httpErr.RawResponse.StatusCode, http.StatusNotFound) time.Sleep(30 * delay()) // Poll this operation manually @@ -643,7 +643,7 @@ func TestReleaseKey(t *testing.T) { t.Skip("Skipping test in playback") } _, err = http.DefaultClient.Do(req) - require.NoError(t, err) + require.Error(t, err) // This URL doesn't exist so this should fail, will pass after 7.4-preview release // require.Equal(t, resp.StatusCode, http.StatusOK) // defer resp.Body.Close() diff --git a/sdk/keyvault/azkeys/constants.go b/sdk/keyvault/azkeys/constants.go index 43d515ecda16..fbd73635f5bc 100644 --- a/sdk/keyvault/azkeys/constants.go +++ b/sdk/keyvault/azkeys/constants.go @@ -6,7 +6,7 @@ package azkeys -import generated "github.com/Azure/azure-sdk-for-go/sdk/keyvault/azkeys/internal/generated" +import "github.com/Azure/azure-sdk-for-go/sdk/keyvault/azkeys/internal/generated" // DeletionRecoveryLevel - Reflects the deletion recovery level currently in effect for certificates in the current vault. If it contains 'Purgeable', the // certificate can be permanently deleted by a privileged user; otherwise, diff --git a/sdk/keyvault/azkeys/constants_test.go b/sdk/keyvault/azkeys/constants_test.go index 1dbff8a86cb7..e65db25a5f02 100644 --- a/sdk/keyvault/azkeys/constants_test.go +++ b/sdk/keyvault/azkeys/constants_test.go @@ -29,7 +29,6 @@ func TestToPtrMethods(t *testing.T) { //nolint func TestToGeneratedMethods(t *testing.T) { // If done incorrectly, this will have a nil pointer reference - var l *ListKeyVersionsOptions - l = nil + var l *ListKeyVersionsOptions = nil _ = l.toGenerated() } diff --git a/sdk/keyvault/azkeys/crypto/crypto_client.go b/sdk/keyvault/azkeys/crypto/crypto_client.go index 7a41f23e29ee..1fad6b2ea461 100644 --- a/sdk/keyvault/azkeys/crypto/crypto_client.go +++ b/sdk/keyvault/azkeys/crypto/crypto_client.go @@ -15,6 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" generated "github.com/Azure/azure-sdk-for-go/sdk/keyvault/azkeys/internal/generated" shared "github.com/Azure/azure-sdk-for-go/sdk/keyvault/internal" ) @@ -97,7 +98,7 @@ func NewClient(keyURL string, credential azcore.TokenCredential, options *Client genOptions.PerRetryPolicies, shared.NewKeyVaultChallengePolicy(credential), ) - conn := generated.NewConnection(genOptions) + pl := runtime.NewPipeline(generated.ModuleName, generated.ModuleVersion, runtime.PipelineOptions{}, genOptions) vaultURL, err := parseVaultURL(keyURL) if err != nil { @@ -110,7 +111,7 @@ func NewClient(keyURL string, credential azcore.TokenCredential, options *Client } return &Client{ - kvClient: generated.NewKeyVaultClient(conn), + kvClient: generated.NewKeyVaultClient(pl), vaultURL: vaultURL, keyID: keyID, keyVersion: keyVersion, diff --git a/sdk/keyvault/azkeys/go.mod b/sdk/keyvault/azkeys/go.mod index fef837cbac0e..1354980c6092 100644 --- a/sdk/keyvault/azkeys/go.mod +++ b/sdk/keyvault/azkeys/go.mod @@ -5,8 +5,8 @@ go 1.16 replace github.com/Azure/azure-sdk-for-go/sdk/keyvault/internal => ../internal require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.0 github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3 github.com/Azure/azure-sdk-for-go/sdk/keyvault/internal v0.1.0 github.com/stretchr/testify v1.7.0 diff --git a/sdk/keyvault/azkeys/go.sum b/sdk/keyvault/azkeys/go.sum index dd600c7a5375..ff950c29186f 100644 --- a/sdk/keyvault/azkeys/go.sum +++ b/sdk/keyvault/azkeys/go.sum @@ -1,18 +1,28 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0 h1:KQgdWmEOmaJKxaUUZwHAYh12t+b+ZJf8q3friycK1kA= github.com/Azure/azure-sdk-for-go/sdk/azcore v0.20.0/go.mod h1:ZPW/Z0kLCTdDZaDbYTetxc9Cxl/2lNqxYHYNOF2bti0= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0 h1:VBvHGLJbaY0+c66NZHdS9cgjHVYSH6DDa0XJMyrblsI= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.12.0/go.mod h1:GJzjM4SR9T0KyX5gKCVyz1ytD8FeWeUPCwtFCt1AyfE= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0 h1:8wVJL0HUP5yDFXvotdewORTw7Yu88JbreWN/mobSvsQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.0 h1:bLRntPH25SkY1uZ/YZW+dmxNky9r1fAHvDFrzluo+4Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.0/go.mod h1:TmXReXZ9yPp5D5TBRMTAtyz+UyOl15Py4hL5E5p6igQ= github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3 h1:E+m3SkZCN0Bf5q7YdTs5lSm2CYY3CK4spn5OmUIiQtk= github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= +github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= +github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= +github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= +github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= +github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= -github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4 h1:49lOXmGaUpV9Fz3gd7TFZY106KVlPVa5jcYD1gaQf98= -github.com/pkg/browser v0.0.0-20180916011732-0a3d74bf9ce4/go.mod h1:4OwLy04Bl9Ef3GJJCoec+30X3LQs/0/m4HFRt/2LUSA= +github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= +github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= +github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -24,18 +34,23 @@ golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNm golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/sdk/keyvault/azkeys/internal/generated/connection.go b/sdk/keyvault/azkeys/internal/generated/connection.go deleted file mode 100644 index c7fa89a3946d..000000000000 --- a/sdk/keyvault/azkeys/internal/generated/connection.go +++ /dev/null @@ -1,37 +0,0 @@ -//go:build go1.16 -// +build go1.16 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package internal - -import ( - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" -) - -// Connection - The key vault client performs cryptographic key operations and vault operations against the Key Vault service. -type Connection struct { - p runtime.Pipeline -} - -// NewConnection creates an instance of the Connection type with the specified endpoint. -// Pass nil to accept the default options; this is the same as passing a zero-value options. -func NewConnection(options *azcore.ClientOptions) *Connection { - cp := azcore.ClientOptions{} - if options != nil { - cp = *options - } - client := &Connection{ - p: runtime.NewPipeline(module, version, nil, nil, &cp), - } - return client -} - -// Pipeline returns the connection's pipeline. -func (c *Connection) Pipeline() runtime.Pipeline { - return c.p -} diff --git a/sdk/keyvault/azkeys/internal/generated/constants.go b/sdk/keyvault/azkeys/internal/generated/constants.go index 4f715fe6b0f2..ea281999817f 100644 --- a/sdk/keyvault/azkeys/internal/generated/constants.go +++ b/sdk/keyvault/azkeys/internal/generated/constants.go @@ -6,11 +6,11 @@ // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -package internal +package generated const ( - module = "internal" - version = "v0.1.1" + ModuleName = "generated" + ModuleVersion = "v0.2.0" ) // ActionType - The type of the action. @@ -19,7 +19,8 @@ type ActionType string const ( // ActionTypeRotate - Rotate the key based on the key policy. ActionTypeRotate ActionType = "rotate" - // ActionTypeNotify - Trigger event grid events. For preview, the notification time is not configurable and it is default to 30 days before expiry. + // ActionTypeNotify - Trigger event grid events. For preview, the notification time is not configurable and it is default + // to 30 days before expiry. ActionTypeNotify ActionType = "notify" ) @@ -155,40 +156,43 @@ func (c DataAction) ToPtr() *DataAction { return &c } -// DeletionRecoveryLevel - Reflects the deletion recovery level currently in effect for keys in the current vault. If it contains 'Purgeable' the key can -// be permanently deleted by a privileged user; otherwise, only the system +// DeletionRecoveryLevel - Reflects the deletion recovery level currently in effect for keys in the current vault. If it contains +// 'Purgeable' the key can be permanently deleted by a privileged user; otherwise, only the system // can purge the key, at the end of the retention interval. type DeletionRecoveryLevel string const ( - // DeletionRecoveryLevelCustomizedRecoverable - Denotes a vault state in which deletion is recoverable without the possibility for immediate and permanent - // deletion (i.e. purge when 7<= SoftDeleteRetentionInDays < 90).This level guarantees the recoverability of the deleted entity during the retention interval - // and while the subscription is still available. + // DeletionRecoveryLevelCustomizedRecoverable - Denotes a vault state in which deletion is recoverable without the possibility + // for immediate and permanent deletion (i.e. purge when 7<= SoftDeleteRetentionInDays < 90).This level guarantees the recoverability + // of the deleted entity during the retention interval and while the subscription is still available. DeletionRecoveryLevelCustomizedRecoverable DeletionRecoveryLevel = "CustomizedRecoverable" - // DeletionRecoveryLevelCustomizedRecoverableProtectedSubscription - Denotes a vault and subscription state in which deletion is recoverable, immediate - // and permanent deletion (i.e. purge) is not permitted, and in which the subscription itself cannot be permanently canceled when 7<= SoftDeleteRetentionInDays - // < 90. This level guarantees the recoverability of the deleted entity during the retention interval, and also reflects the fact that the subscription - // itself cannot be cancelled. + // DeletionRecoveryLevelCustomizedRecoverableProtectedSubscription - Denotes a vault and subscription state in which deletion + // is recoverable, immediate and permanent deletion (i.e. purge) is not permitted, and in which the subscription itself cannot + // be permanently canceled when 7<= SoftDeleteRetentionInDays < 90. This level guarantees the recoverability of the deleted + // entity during the retention interval, and also reflects the fact that the subscription itself cannot be cancelled. DeletionRecoveryLevelCustomizedRecoverableProtectedSubscription DeletionRecoveryLevel = "CustomizedRecoverable+ProtectedSubscription" - // DeletionRecoveryLevelCustomizedRecoverablePurgeable - Denotes a vault state in which deletion is recoverable, and which also permits immediate and permanent - // deletion (i.e. purge when 7<= SoftDeleteRetentionInDays < 90). This level guarantees the recoverability of the deleted entity during the retention interval, - // unless a Purge operation is requested, or the subscription is cancelled. + // DeletionRecoveryLevelCustomizedRecoverablePurgeable - Denotes a vault state in which deletion is recoverable, and which + // also permits immediate and permanent deletion (i.e. purge when 7<= SoftDeleteRetentionInDays < 90). This level guarantees + // the recoverability of the deleted entity during the retention interval, unless a Purge operation is requested, or the subscription + // is cancelled. DeletionRecoveryLevelCustomizedRecoverablePurgeable DeletionRecoveryLevel = "CustomizedRecoverable+Purgeable" - // DeletionRecoveryLevelPurgeable - Denotes a vault state in which deletion is an irreversible operation, without the possibility for recovery. This level - // corresponds to no protection being available against a Delete operation; the data is irretrievably lost upon accepting a Delete operation at the entity - // level or higher (vault, resource group, subscription etc.) + // DeletionRecoveryLevelPurgeable - Denotes a vault state in which deletion is an irreversible operation, without the possibility + // for recovery. This level corresponds to no protection being available against a Delete operation; the data is irretrievably + // lost upon accepting a Delete operation at the entity level or higher (vault, resource group, subscription etc.) DeletionRecoveryLevelPurgeable DeletionRecoveryLevel = "Purgeable" - // DeletionRecoveryLevelRecoverable - Denotes a vault state in which deletion is recoverable without the possibility for immediate and permanent deletion - // (i.e. purge). This level guarantees the recoverability of the deleted entity during the retention interval(90 days) and while the subscription is still - // available. System wil permanently delete it after 90 days, if not recovered + // DeletionRecoveryLevelRecoverable - Denotes a vault state in which deletion is recoverable without the possibility for immediate + // and permanent deletion (i.e. purge). This level guarantees the recoverability of the deleted entity during the retention + // interval(90 days) and while the subscription is still available. System wil permanently delete it after 90 days, if not + // recovered DeletionRecoveryLevelRecoverable DeletionRecoveryLevel = "Recoverable" - // DeletionRecoveryLevelRecoverableProtectedSubscription - Denotes a vault and subscription state in which deletion is recoverable within retention interval - // (90 days), immediate and permanent deletion (i.e. purge) is not permitted, and in which the subscription itself cannot be permanently canceled. System - // wil permanently delete it after 90 days, if not recovered + // DeletionRecoveryLevelRecoverableProtectedSubscription - Denotes a vault and subscription state in which deletion is recoverable + // within retention interval (90 days), immediate and permanent deletion (i.e. purge) is not permitted, and in which the subscription + // itself cannot be permanently canceled. System wil permanently delete it after 90 days, if not recovered DeletionRecoveryLevelRecoverableProtectedSubscription DeletionRecoveryLevel = "Recoverable+ProtectedSubscription" - // DeletionRecoveryLevelRecoverablePurgeable - Denotes a vault state in which deletion is recoverable, and which also permits immediate and permanent deletion - // (i.e. purge). This level guarantees the recoverability of the deleted entity during the retention interval (90 days), unless a Purge operation is requested, - // or the subscription is cancelled. System wil permanently delete it after 90 days, if not recovered + // DeletionRecoveryLevelRecoverablePurgeable - Denotes a vault state in which deletion is recoverable, and which also permits + // immediate and permanent deletion (i.e. purge). This level guarantees the recoverability of the deleted entity during the + // retention interval (90 days), unless a Purge operation is requested, or the subscription is cancelled. System wil permanently + // delete it after 90 days, if not recovered DeletionRecoveryLevelRecoverablePurgeable DeletionRecoveryLevel = "Recoverable+Purgeable" ) @@ -319,7 +323,8 @@ func (c JSONWebKeyOperation) ToPtr() *JSONWebKeyOperation { return &c } -// JSONWebKeySignatureAlgorithm - The signing/verification algorithm identifier. For more information on possible algorithm types, see JsonWebKeySignatureAlgorithm. +// JSONWebKeySignatureAlgorithm - The signing/verification algorithm identifier. For more information on possible algorithm +// types, see JsonWebKeySignatureAlgorithm. type JSONWebKeySignatureAlgorithm string const ( diff --git a/sdk/keyvault/azkeys/internal/generated/hsmsecuritydomain_client.go b/sdk/keyvault/azkeys/internal/generated/hsmsecuritydomain_client.go index e59e6d0c5247..a352892e2d55 100644 --- a/sdk/keyvault/azkeys/internal/generated/hsmsecuritydomain_client.go +++ b/sdk/keyvault/azkeys/internal/generated/hsmsecuritydomain_client.go @@ -6,11 +6,10 @@ // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -package internal +package generated import ( "context" - "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -20,53 +19,64 @@ import ( // HSMSecurityDomainClient contains the methods for the HSMSecurityDomain group. // Don't use this type directly, use NewHSMSecurityDomainClient() instead. type HSMSecurityDomainClient struct { - con *Connection + pl runtime.Pipeline } // NewHSMSecurityDomainClient creates a new instance of HSMSecurityDomainClient with the specified values. -func NewHSMSecurityDomainClient(con *Connection) *HSMSecurityDomainClient { - return &HSMSecurityDomainClient{con: con} +// pl - the pipeline used for sending requests and handling responses. +func NewHSMSecurityDomainClient(pl runtime.Pipeline) *HSMSecurityDomainClient { + client := &HSMSecurityDomainClient{ + pl: pl, + } + return client } -// BeginDownload - Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. -// If the operation fails it returns the *KeyVaultError error type. -func (client *HSMSecurityDomainClient) BeginDownload(ctx context.Context, vaultBaseURL string, certificateInfoObject CertificateInfoObject, options *HSMSecurityDomainBeginDownloadOptions) (HSMSecurityDomainDownloadPollerResponse, error) { +// BeginDownload - Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned +// managed HSM resource. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// certificateInfoObject - The Security Domain download operation requires customer to provide N certificates (minimum 3 and +// maximum 10) containing a public key in JWK format. +// options - HSMSecurityDomainClientBeginDownloadOptions contains the optional parameters for the HSMSecurityDomainClient.BeginDownload +// method. +func (client *HSMSecurityDomainClient) BeginDownload(ctx context.Context, vaultBaseURL string, certificateInfoObject CertificateInfoObject, options *HSMSecurityDomainClientBeginDownloadOptions) (HSMSecurityDomainClientDownloadPollerResponse, error) { resp, err := client.download(ctx, vaultBaseURL, certificateInfoObject, options) if err != nil { - return HSMSecurityDomainDownloadPollerResponse{}, err + return HSMSecurityDomainClientDownloadPollerResponse{}, err } - result := HSMSecurityDomainDownloadPollerResponse{ + result := HSMSecurityDomainClientDownloadPollerResponse{ RawResponse: resp, } - pt, err := runtime.NewPoller("HSMSecurityDomainClient.Download", resp, client.con.Pipeline(), client.downloadHandleError) + pt, err := runtime.NewPoller("HSMSecurityDomainClient.Download", resp, client.pl) if err != nil { - return HSMSecurityDomainDownloadPollerResponse{}, err + return HSMSecurityDomainClientDownloadPollerResponse{}, err } - result.Poller = &HSMSecurityDomainDownloadPoller{ + result.Poller = &HSMSecurityDomainClientDownloadPoller{ pt: pt, } return result, nil } -// Download - Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. -// If the operation fails it returns the *KeyVaultError error type. -func (client *HSMSecurityDomainClient) download(ctx context.Context, vaultBaseURL string, certificateInfoObject CertificateInfoObject, options *HSMSecurityDomainBeginDownloadOptions) (*http.Response, error) { +// Download - Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned +// managed HSM resource. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *HSMSecurityDomainClient) download(ctx context.Context, vaultBaseURL string, certificateInfoObject CertificateInfoObject, options *HSMSecurityDomainClientBeginDownloadOptions) (*http.Response, error) { req, err := client.downloadCreateRequest(ctx, vaultBaseURL, certificateInfoObject, options) if err != nil { return nil, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return nil, err } if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return nil, client.downloadHandleError(resp) + return nil, runtime.NewResponseError(resp) } return resp, nil } // downloadCreateRequest creates the Download request. -func (client *HSMSecurityDomainClient) downloadCreateRequest(ctx context.Context, vaultBaseURL string, certificateInfoObject CertificateInfoObject, options *HSMSecurityDomainBeginDownloadOptions) (*policy.Request, error) { +func (client *HSMSecurityDomainClient) downloadCreateRequest(ctx context.Context, vaultBaseURL string, certificateInfoObject CertificateInfoObject, options *HSMSecurityDomainClientBeginDownloadOptions) (*policy.Request, error) { host := "{vaultBaseUrl}" host = strings.ReplaceAll(host, "{vaultBaseUrl}", vaultBaseURL) urlPath := "/securitydomain/download" @@ -81,38 +91,28 @@ func (client *HSMSecurityDomainClient) downloadCreateRequest(ctx context.Context return req, runtime.MarshalAsJSON(req, certificateInfoObject) } -// downloadHandleError handles the Download error response. -func (client *HSMSecurityDomainClient) downloadHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // DownloadPending - Retrieves the Security Domain download operation status -// If the operation fails it returns the *KeyVaultError error type. -func (client *HSMSecurityDomainClient) DownloadPending(ctx context.Context, vaultBaseURL string, options *HSMSecurityDomainDownloadPendingOptions) (HSMSecurityDomainDownloadPendingResponse, error) { +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// options - HSMSecurityDomainClientDownloadPendingOptions contains the optional parameters for the HSMSecurityDomainClient.DownloadPending +// method. +func (client *HSMSecurityDomainClient) DownloadPending(ctx context.Context, vaultBaseURL string, options *HSMSecurityDomainClientDownloadPendingOptions) (HSMSecurityDomainClientDownloadPendingResponse, error) { req, err := client.downloadPendingCreateRequest(ctx, vaultBaseURL, options) if err != nil { - return HSMSecurityDomainDownloadPendingResponse{}, err + return HSMSecurityDomainClientDownloadPendingResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return HSMSecurityDomainDownloadPendingResponse{}, err + return HSMSecurityDomainClientDownloadPendingResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return HSMSecurityDomainDownloadPendingResponse{}, client.downloadPendingHandleError(resp) + return HSMSecurityDomainClientDownloadPendingResponse{}, runtime.NewResponseError(resp) } return client.downloadPendingHandleResponse(resp) } // downloadPendingCreateRequest creates the DownloadPending request. -func (client *HSMSecurityDomainClient) downloadPendingCreateRequest(ctx context.Context, vaultBaseURL string, options *HSMSecurityDomainDownloadPendingOptions) (*policy.Request, error) { +func (client *HSMSecurityDomainClient) downloadPendingCreateRequest(ctx context.Context, vaultBaseURL string, options *HSMSecurityDomainClientDownloadPendingOptions) (*policy.Request, error) { host := "{vaultBaseUrl}" host = strings.ReplaceAll(host, "{vaultBaseUrl}", vaultBaseURL) urlPath := "/securitydomain/download/pending" @@ -125,46 +125,36 @@ func (client *HSMSecurityDomainClient) downloadPendingCreateRequest(ctx context. } // downloadPendingHandleResponse handles the DownloadPending response. -func (client *HSMSecurityDomainClient) downloadPendingHandleResponse(resp *http.Response) (HSMSecurityDomainDownloadPendingResponse, error) { - result := HSMSecurityDomainDownloadPendingResponse{RawResponse: resp} +func (client *HSMSecurityDomainClient) downloadPendingHandleResponse(resp *http.Response) (HSMSecurityDomainClientDownloadPendingResponse, error) { + result := HSMSecurityDomainClientDownloadPendingResponse{RawResponse: resp} if err := runtime.UnmarshalAsJSON(resp, &result.SecurityDomainOperationStatus); err != nil { - return HSMSecurityDomainDownloadPendingResponse{}, err + return HSMSecurityDomainClientDownloadPendingResponse{}, err } return result, nil } -// downloadPendingHandleError handles the DownloadPending error response. -func (client *HSMSecurityDomainClient) downloadPendingHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // TransferKey - Retrieve Security Domain transfer key -// If the operation fails it returns the *KeyVaultError error type. -func (client *HSMSecurityDomainClient) TransferKey(ctx context.Context, vaultBaseURL string, options *HSMSecurityDomainTransferKeyOptions) (HSMSecurityDomainTransferKeyResponse, error) { +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// options - HSMSecurityDomainClientTransferKeyOptions contains the optional parameters for the HSMSecurityDomainClient.TransferKey +// method. +func (client *HSMSecurityDomainClient) TransferKey(ctx context.Context, vaultBaseURL string, options *HSMSecurityDomainClientTransferKeyOptions) (HSMSecurityDomainClientTransferKeyResponse, error) { req, err := client.transferKeyCreateRequest(ctx, vaultBaseURL, options) if err != nil { - return HSMSecurityDomainTransferKeyResponse{}, err + return HSMSecurityDomainClientTransferKeyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return HSMSecurityDomainTransferKeyResponse{}, err + return HSMSecurityDomainClientTransferKeyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return HSMSecurityDomainTransferKeyResponse{}, client.transferKeyHandleError(resp) + return HSMSecurityDomainClientTransferKeyResponse{}, runtime.NewResponseError(resp) } return client.transferKeyHandleResponse(resp) } // transferKeyCreateRequest creates the TransferKey request. -func (client *HSMSecurityDomainClient) transferKeyCreateRequest(ctx context.Context, vaultBaseURL string, options *HSMSecurityDomainTransferKeyOptions) (*policy.Request, error) { +func (client *HSMSecurityDomainClient) transferKeyCreateRequest(ctx context.Context, vaultBaseURL string, options *HSMSecurityDomainClientTransferKeyOptions) (*policy.Request, error) { host := "{vaultBaseUrl}" host = strings.ReplaceAll(host, "{vaultBaseUrl}", vaultBaseURL) urlPath := "/securitydomain/upload" @@ -180,66 +170,57 @@ func (client *HSMSecurityDomainClient) transferKeyCreateRequest(ctx context.Cont } // transferKeyHandleResponse handles the TransferKey response. -func (client *HSMSecurityDomainClient) transferKeyHandleResponse(resp *http.Response) (HSMSecurityDomainTransferKeyResponse, error) { - result := HSMSecurityDomainTransferKeyResponse{RawResponse: resp} +func (client *HSMSecurityDomainClient) transferKeyHandleResponse(resp *http.Response) (HSMSecurityDomainClientTransferKeyResponse, error) { + result := HSMSecurityDomainClientTransferKeyResponse{RawResponse: resp} if err := runtime.UnmarshalAsJSON(resp, &result.TransferKey); err != nil { - return HSMSecurityDomainTransferKeyResponse{}, err + return HSMSecurityDomainClientTransferKeyResponse{}, err } return result, nil } -// transferKeyHandleError handles the TransferKey error response. -func (client *HSMSecurityDomainClient) transferKeyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // BeginUpload - Restore the provided Security Domain. -// If the operation fails it returns the *KeyVaultError error type. -func (client *HSMSecurityDomainClient) BeginUpload(ctx context.Context, vaultBaseURL string, securityDomain SecurityDomainObject, options *HSMSecurityDomainBeginUploadOptions) (HSMSecurityDomainUploadPollerResponse, error) { +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// securityDomain - The Security Domain to be restored. +// options - HSMSecurityDomainClientBeginUploadOptions contains the optional parameters for the HSMSecurityDomainClient.BeginUpload +// method. +func (client *HSMSecurityDomainClient) BeginUpload(ctx context.Context, vaultBaseURL string, securityDomain SecurityDomainObject, options *HSMSecurityDomainClientBeginUploadOptions) (HSMSecurityDomainClientUploadPollerResponse, error) { resp, err := client.upload(ctx, vaultBaseURL, securityDomain, options) if err != nil { - return HSMSecurityDomainUploadPollerResponse{}, err + return HSMSecurityDomainClientUploadPollerResponse{}, err } - result := HSMSecurityDomainUploadPollerResponse{ + result := HSMSecurityDomainClientUploadPollerResponse{ RawResponse: resp, } - pt, err := runtime.NewPoller("HSMSecurityDomainClient.Upload", resp, client.con.Pipeline(), client.uploadHandleError) + pt, err := runtime.NewPoller("HSMSecurityDomainClient.Upload", resp, client.pl) if err != nil { - return HSMSecurityDomainUploadPollerResponse{}, err + return HSMSecurityDomainClientUploadPollerResponse{}, err } - result.Poller = &HSMSecurityDomainUploadPoller{ + result.Poller = &HSMSecurityDomainClientUploadPoller{ pt: pt, } return result, nil } // Upload - Restore the provided Security Domain. -// If the operation fails it returns the *KeyVaultError error type. -func (client *HSMSecurityDomainClient) upload(ctx context.Context, vaultBaseURL string, securityDomain SecurityDomainObject, options *HSMSecurityDomainBeginUploadOptions) (*http.Response, error) { +// If the operation fails it returns an *azcore.ResponseError type. +func (client *HSMSecurityDomainClient) upload(ctx context.Context, vaultBaseURL string, securityDomain SecurityDomainObject, options *HSMSecurityDomainClientBeginUploadOptions) (*http.Response, error) { req, err := client.uploadCreateRequest(ctx, vaultBaseURL, securityDomain, options) if err != nil { return nil, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return nil, err } if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNoContent) { - return nil, client.uploadHandleError(resp) + return nil, runtime.NewResponseError(resp) } return resp, nil } // uploadCreateRequest creates the Upload request. -func (client *HSMSecurityDomainClient) uploadCreateRequest(ctx context.Context, vaultBaseURL string, securityDomain SecurityDomainObject, options *HSMSecurityDomainBeginUploadOptions) (*policy.Request, error) { +func (client *HSMSecurityDomainClient) uploadCreateRequest(ctx context.Context, vaultBaseURL string, securityDomain SecurityDomainObject, options *HSMSecurityDomainClientBeginUploadOptions) (*policy.Request, error) { host := "{vaultBaseUrl}" host = strings.ReplaceAll(host, "{vaultBaseUrl}", vaultBaseURL) urlPath := "/securitydomain/upload" @@ -251,38 +232,28 @@ func (client *HSMSecurityDomainClient) uploadCreateRequest(ctx context.Context, return req, runtime.MarshalAsJSON(req, securityDomain) } -// uploadHandleError handles the Upload error response. -func (client *HSMSecurityDomainClient) uploadHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // UploadPending - Get Security Domain upload operation status -// If the operation fails it returns the *KeyVaultError error type. -func (client *HSMSecurityDomainClient) UploadPending(ctx context.Context, vaultBaseURL string, options *HSMSecurityDomainUploadPendingOptions) (HSMSecurityDomainUploadPendingResponse, error) { +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// options - HSMSecurityDomainClientUploadPendingOptions contains the optional parameters for the HSMSecurityDomainClient.UploadPending +// method. +func (client *HSMSecurityDomainClient) UploadPending(ctx context.Context, vaultBaseURL string, options *HSMSecurityDomainClientUploadPendingOptions) (HSMSecurityDomainClientUploadPendingResponse, error) { req, err := client.uploadPendingCreateRequest(ctx, vaultBaseURL, options) if err != nil { - return HSMSecurityDomainUploadPendingResponse{}, err + return HSMSecurityDomainClientUploadPendingResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return HSMSecurityDomainUploadPendingResponse{}, err + return HSMSecurityDomainClientUploadPendingResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return HSMSecurityDomainUploadPendingResponse{}, client.uploadPendingHandleError(resp) + return HSMSecurityDomainClientUploadPendingResponse{}, runtime.NewResponseError(resp) } return client.uploadPendingHandleResponse(resp) } // uploadPendingCreateRequest creates the UploadPending request. -func (client *HSMSecurityDomainClient) uploadPendingCreateRequest(ctx context.Context, vaultBaseURL string, options *HSMSecurityDomainUploadPendingOptions) (*policy.Request, error) { +func (client *HSMSecurityDomainClient) uploadPendingCreateRequest(ctx context.Context, vaultBaseURL string, options *HSMSecurityDomainClientUploadPendingOptions) (*policy.Request, error) { host := "{vaultBaseUrl}" host = strings.ReplaceAll(host, "{vaultBaseUrl}", vaultBaseURL) urlPath := "/securitydomain/upload/pending" @@ -295,23 +266,10 @@ func (client *HSMSecurityDomainClient) uploadPendingCreateRequest(ctx context.Co } // uploadPendingHandleResponse handles the UploadPending response. -func (client *HSMSecurityDomainClient) uploadPendingHandleResponse(resp *http.Response) (HSMSecurityDomainUploadPendingResponse, error) { - result := HSMSecurityDomainUploadPendingResponse{RawResponse: resp} +func (client *HSMSecurityDomainClient) uploadPendingHandleResponse(resp *http.Response) (HSMSecurityDomainClientUploadPendingResponse, error) { + result := HSMSecurityDomainClientUploadPendingResponse{RawResponse: resp} if err := runtime.UnmarshalAsJSON(resp, &result.SecurityDomainOperationStatus); err != nil { - return HSMSecurityDomainUploadPendingResponse{}, err + return HSMSecurityDomainClientUploadPendingResponse{}, err } return result, nil } - -// uploadPendingHandleError handles the UploadPending error response. -func (client *HSMSecurityDomainClient) uploadPendingHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} diff --git a/sdk/keyvault/azkeys/internal/generated/keyvaultclient_client.go b/sdk/keyvault/azkeys/internal/generated/keyvault_client.go similarity index 70% rename from sdk/keyvault/azkeys/internal/generated/keyvaultclient_client.go rename to sdk/keyvault/azkeys/internal/generated/keyvault_client.go index 5475a4b3e693..90ee07b40551 100644 --- a/sdk/keyvault/azkeys/internal/generated/keyvaultclient_client.go +++ b/sdk/keyvault/azkeys/internal/generated/keyvault_client.go @@ -6,12 +6,11 @@ // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -package internal +package generated import ( "context" "errors" - "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -23,36 +22,43 @@ import ( // KeyVaultClient contains the methods for the KeyVaultClient group. // Don't use this type directly, use NewKeyVaultClient() instead. type KeyVaultClient struct { - con *Connection + pl runtime.Pipeline } // NewKeyVaultClient creates a new instance of KeyVaultClient with the specified values. -func NewKeyVaultClient(con *Connection) *KeyVaultClient { - return &KeyVaultClient{con: con} -} - -// BackupKey - The Key Backup operation exports a key from Azure Key Vault in a protected form. Note that this operation does NOT return key material in -// a form that can be used outside the Azure Key Vault system, -// the returned key material is either protected to a Azure Key Vault HSM or to Azure Key Vault itself. The intent of this operation is to allow a client -// to GENERATE a key in one Azure Key Vault -// instance, BACKUP the key, and then RESTORE it into another Azure Key Vault instance. The BACKUP operation may be used to export, in protected form, any -// key type from Azure Key Vault. Individual -// versions of a key cannot be backed up. BACKUP / RESTORE can be performed within geographical boundaries only; meaning that a BACKUP from one geographical -// area cannot be restored to another -// geographical area. For example, a backup from the US geographical area cannot be restored in an EU geographical area. This operation requires the key/backup -// permission. -// If the operation fails it returns the *KeyVaultError error type. +// pl - the pipeline used for sending requests and handling responses. +func NewKeyVaultClient(pl runtime.Pipeline) *KeyVaultClient { + client := &KeyVaultClient{ + pl: pl, + } + return client +} + +// BackupKey - The Key Backup operation exports a key from Azure Key Vault in a protected form. Note that this operation does +// NOT return key material in a form that can be used outside the Azure Key Vault system, +// the returned key material is either protected to a Azure Key Vault HSM or to Azure Key Vault itself. The intent of this +// operation is to allow a client to GENERATE a key in one Azure Key Vault +// instance, BACKUP the key, and then RESTORE it into another Azure Key Vault instance. The BACKUP operation may be used to +// export, in protected form, any key type from Azure Key Vault. Individual +// versions of a key cannot be backed up. BACKUP / RESTORE can be performed within geographical boundaries only; meaning that +// a BACKUP from one geographical area cannot be restored to another +// geographical area. For example, a backup from the US geographical area cannot be restored in an EU geographical area. This +// operation requires the key/backup permission. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of the key. +// options - KeyVaultClientBackupKeyOptions contains the optional parameters for the KeyVaultClient.BackupKey method. func (client *KeyVaultClient) BackupKey(ctx context.Context, vaultBaseURL string, keyName string, options *KeyVaultClientBackupKeyOptions) (KeyVaultClientBackupKeyResponse, error) { req, err := client.backupKeyCreateRequest(ctx, vaultBaseURL, keyName, options) if err != nil { return KeyVaultClientBackupKeyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientBackupKeyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientBackupKeyResponse{}, client.backupKeyHandleError(resp) + return KeyVaultClientBackupKeyResponse{}, runtime.NewResponseError(resp) } return client.backupKeyHandleResponse(resp) } @@ -86,34 +92,25 @@ func (client *KeyVaultClient) backupKeyHandleResponse(resp *http.Response) (KeyV return result, nil } -// backupKeyHandleError handles the BackupKey error response. -func (client *KeyVaultClient) backupKeyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// CreateKey - The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, Azure Key Vault creates -// a new version of the key. It requires the keys/create +// CreateKey - The create key operation can be used to create any key type in Azure Key Vault. If the named key already exists, +// Azure Key Vault creates a new version of the key. It requires the keys/create // permission. -// If the operation fails it returns the *KeyVaultError error type. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name for the new key. The system will generate the version name for the new key. +// parameters - The parameters to create a key. +// options - KeyVaultClientCreateKeyOptions contains the optional parameters for the KeyVaultClient.CreateKey method. func (client *KeyVaultClient) CreateKey(ctx context.Context, vaultBaseURL string, keyName string, parameters KeyCreateParameters, options *KeyVaultClientCreateKeyOptions) (KeyVaultClientCreateKeyResponse, error) { req, err := client.createKeyCreateRequest(ctx, vaultBaseURL, keyName, parameters, options) if err != nil { return KeyVaultClientCreateKeyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientCreateKeyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientCreateKeyResponse{}, client.createKeyHandleError(resp) + return KeyVaultClientCreateKeyResponse{}, runtime.NewResponseError(resp) } return client.createKeyHandleResponse(resp) } @@ -147,36 +144,28 @@ func (client *KeyVaultClient) createKeyHandleResponse(resp *http.Response) (KeyV return result, nil } -// createKeyHandleError handles the CreateKey error response. -func (client *KeyVaultClient) createKeyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// Decrypt - The DECRYPT operation decrypts a well-formed block of ciphertext using the target encryption key and specified algorithm. This operation is -// the reverse of the ENCRYPT operation; only a single block of -// data may be decrypted, the size of this block is dependent on the target key and the algorithm to be used. The DECRYPT operation applies to asymmetric -// and symmetric keys stored in Azure Key Vault +// Decrypt - The DECRYPT operation decrypts a well-formed block of ciphertext using the target encryption key and specified +// algorithm. This operation is the reverse of the ENCRYPT operation; only a single block of +// data may be decrypted, the size of this block is dependent on the target key and the algorithm to be used. The DECRYPT +// operation applies to asymmetric and symmetric keys stored in Azure Key Vault // since it uses the private portion of the key. This operation requires the keys/decrypt permission. -// If the operation fails it returns the *KeyVaultError error type. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of the key. +// keyVersion - The version of the key. +// parameters - The parameters for the decryption operation. +// options - KeyVaultClientDecryptOptions contains the optional parameters for the KeyVaultClient.Decrypt method. func (client *KeyVaultClient) Decrypt(ctx context.Context, vaultBaseURL string, keyName string, keyVersion string, parameters KeyOperationsParameters, options *KeyVaultClientDecryptOptions) (KeyVaultClientDecryptResponse, error) { req, err := client.decryptCreateRequest(ctx, vaultBaseURL, keyName, keyVersion, parameters, options) if err != nil { return KeyVaultClientDecryptResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientDecryptResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientDecryptResponse{}, client.decryptHandleError(resp) + return KeyVaultClientDecryptResponse{}, runtime.NewResponseError(resp) } return client.decryptHandleResponse(resp) } @@ -214,34 +203,24 @@ func (client *KeyVaultClient) decryptHandleResponse(resp *http.Response) (KeyVau return result, nil } -// decryptHandleError handles the Decrypt error response. -func (client *KeyVaultClient) decryptHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// DeleteKey - The delete key operation cannot be used to remove individual versions of a key. This operation removes the cryptographic material associated -// with the key, which means the key is not usable for +// DeleteKey - The delete key operation cannot be used to remove individual versions of a key. This operation removes the +// cryptographic material associated with the key, which means the key is not usable for // Sign/Verify, Wrap/Unwrap or Encrypt/Decrypt operations. This operation requires the keys/delete permission. -// If the operation fails it returns the *KeyVaultError error type. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of the key to delete. +// options - KeyVaultClientDeleteKeyOptions contains the optional parameters for the KeyVaultClient.DeleteKey method. func (client *KeyVaultClient) DeleteKey(ctx context.Context, vaultBaseURL string, keyName string, options *KeyVaultClientDeleteKeyOptions) (KeyVaultClientDeleteKeyResponse, error) { req, err := client.deleteKeyCreateRequest(ctx, vaultBaseURL, keyName, options) if err != nil { return KeyVaultClientDeleteKeyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientDeleteKeyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientDeleteKeyResponse{}, client.deleteKeyHandleError(resp) + return KeyVaultClientDeleteKeyResponse{}, runtime.NewResponseError(resp) } return client.deleteKeyHandleResponse(resp) } @@ -275,38 +254,30 @@ func (client *KeyVaultClient) deleteKeyHandleResponse(resp *http.Response) (KeyV return result, nil } -// deleteKeyHandleError handles the DeleteKey error response. -func (client *KeyVaultClient) deleteKeyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// Encrypt - The ENCRYPT operation encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure Key Vault. Note that the ENCRYPT -// operation only supports a single block of data, the size -// of which is dependent on the target key and the encryption algorithm to be used. The ENCRYPT operation is only strictly necessary for symmetric keys -// stored in Azure Key Vault since protection with an -// asymmetric key can be performed using public portion of the key. This operation is supported for asymmetric keys as a convenience for callers that have -// a key-reference but do not have access to the +// Encrypt - The ENCRYPT operation encrypts an arbitrary sequence of bytes using an encryption key that is stored in Azure +// Key Vault. Note that the ENCRYPT operation only supports a single block of data, the size +// of which is dependent on the target key and the encryption algorithm to be used. The ENCRYPT operation is only strictly +// necessary for symmetric keys stored in Azure Key Vault since protection with an +// asymmetric key can be performed using public portion of the key. This operation is supported for asymmetric keys as a convenience +// for callers that have a key-reference but do not have access to the // public key material. This operation requires the keys/encrypt permission. -// If the operation fails it returns the *KeyVaultError error type. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of the key. +// keyVersion - The version of the key. +// parameters - The parameters for the encryption operation. +// options - KeyVaultClientEncryptOptions contains the optional parameters for the KeyVaultClient.Encrypt method. func (client *KeyVaultClient) Encrypt(ctx context.Context, vaultBaseURL string, keyName string, keyVersion string, parameters KeyOperationsParameters, options *KeyVaultClientEncryptOptions) (KeyVaultClientEncryptResponse, error) { req, err := client.encryptCreateRequest(ctx, vaultBaseURL, keyName, keyVersion, parameters, options) if err != nil { return KeyVaultClientEncryptResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientEncryptResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientEncryptResponse{}, client.encryptHandleError(resp) + return KeyVaultClientEncryptResponse{}, runtime.NewResponseError(resp) } return client.encryptHandleResponse(resp) } @@ -344,32 +315,25 @@ func (client *KeyVaultClient) encryptHandleResponse(resp *http.Response) (KeyVau return result, nil } -// encryptHandleError handles the Encrypt error response. -func (client *KeyVaultClient) encryptHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// Export - The export key operation is applicable to all key types. The target key must be marked exportable. This operation requires the keys/export permission. -// If the operation fails it returns the *KeyVaultError error type. +// Export - The export key operation is applicable to all key types. The target key must be marked exportable. This operation +// requires the keys/export permission. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of the key to get. +// keyVersion - Adding the version parameter retrieves a specific version of a key. +// parameters - The parameters for the key export operation. +// options - KeyVaultClientExportOptions contains the optional parameters for the KeyVaultClient.Export method. func (client *KeyVaultClient) Export(ctx context.Context, vaultBaseURL string, keyName string, keyVersion string, parameters KeyExportParameters, options *KeyVaultClientExportOptions) (KeyVaultClientExportResponse, error) { req, err := client.exportCreateRequest(ctx, vaultBaseURL, keyName, keyVersion, parameters, options) if err != nil { return KeyVaultClientExportResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientExportResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientExportResponse{}, client.exportHandleError(resp) + return KeyVaultClientExportResponse{}, runtime.NewResponseError(resp) } return client.exportHandleResponse(resp) } @@ -407,34 +371,24 @@ func (client *KeyVaultClient) exportHandleResponse(resp *http.Response) (KeyVaul return result, nil } -// exportHandleError handles the Export error response. -func (client *KeyVaultClient) exportHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// GetDeletedKey - The Get Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked on any vault, it will -// return an error if invoked on a non soft-delete enabled vault. This +// GetDeletedKey - The Get Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be +// invoked on any vault, it will return an error if invoked on a non soft-delete enabled vault. This // operation requires the keys/get permission. -// If the operation fails it returns the *KeyVaultError error type. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of the key. +// options - KeyVaultClientGetDeletedKeyOptions contains the optional parameters for the KeyVaultClient.GetDeletedKey method. func (client *KeyVaultClient) GetDeletedKey(ctx context.Context, vaultBaseURL string, keyName string, options *KeyVaultClientGetDeletedKeyOptions) (KeyVaultClientGetDeletedKeyResponse, error) { req, err := client.getDeletedKeyCreateRequest(ctx, vaultBaseURL, keyName, options) if err != nil { return KeyVaultClientGetDeletedKeyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientGetDeletedKeyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientGetDeletedKeyResponse{}, client.getDeletedKeyHandleError(resp) + return KeyVaultClientGetDeletedKeyResponse{}, runtime.NewResponseError(resp) } return client.getDeletedKeyHandleResponse(resp) } @@ -468,25 +422,14 @@ func (client *KeyVaultClient) getDeletedKeyHandleResponse(resp *http.Response) ( return result, nil } -// getDeletedKeyHandleError handles the GetDeletedKey error response. -func (client *KeyVaultClient) getDeletedKeyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// GetDeletedKeys - Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a deleted key. This operation -// includes deletion-specific information. The Get Deleted Keys -// operation is applicable for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return an error if invoked on a -// non soft-delete enabled vault. This operation +// GetDeletedKeys - Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part +// of a deleted key. This operation includes deletion-specific information. The Get Deleted Keys +// operation is applicable for vaults enabled for soft-delete. While the operation can be invoked on any vault, it will return +// an error if invoked on a non soft-delete enabled vault. This operation // requires the keys/list permission. -// If the operation fails it returns the *KeyVaultError error type. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// options - KeyVaultClientGetDeletedKeysOptions contains the optional parameters for the KeyVaultClient.GetDeletedKeys method. func (client *KeyVaultClient) GetDeletedKeys(vaultBaseURL string, options *KeyVaultClientGetDeletedKeysOptions) *KeyVaultClientGetDeletedKeysPager { return &KeyVaultClientGetDeletedKeysPager{ client: client, @@ -527,33 +470,25 @@ func (client *KeyVaultClient) getDeletedKeysHandleResponse(resp *http.Response) return result, nil } -// getDeletedKeysHandleError handles the GetDeletedKeys error response. -func (client *KeyVaultClient) getDeletedKeysHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// GetKey - The get key operation is applicable to all key types. If the requested key is symmetric, then no key material is released in the response. This -// operation requires the keys/get permission. -// If the operation fails it returns the *KeyVaultError error type. +// GetKey - The get key operation is applicable to all key types. If the requested key is symmetric, then no key material +// is released in the response. This operation requires the keys/get permission. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of the key to get. +// keyVersion - Adding the version parameter retrieves a specific version of a key. This URI fragment is optional. If not +// specified, the latest version of the key is returned. +// options - KeyVaultClientGetKeyOptions contains the optional parameters for the KeyVaultClient.GetKey method. func (client *KeyVaultClient) GetKey(ctx context.Context, vaultBaseURL string, keyName string, keyVersion string, options *KeyVaultClientGetKeyOptions) (KeyVaultClientGetKeyResponse, error) { req, err := client.getKeyCreateRequest(ctx, vaultBaseURL, keyName, keyVersion, options) if err != nil { return KeyVaultClientGetKeyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientGetKeyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientGetKeyResponse{}, client.getKeyHandleError(resp) + return KeyVaultClientGetKeyResponse{}, runtime.NewResponseError(resp) } return client.getKeyHandleResponse(resp) } @@ -591,33 +526,24 @@ func (client *KeyVaultClient) getKeyHandleResponse(resp *http.Response) (KeyVaul return result, nil } -// getKeyHandleError handles the GetKey error response. -func (client *KeyVaultClient) getKeyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// GetKeyRotationPolicy - The GetKeyRotationPolicy operation returns the specified key policy resources in the specified key vault. This operation requires -// the keys/get permission. -// If the operation fails it returns the *KeyVaultError error type. +// GetKeyRotationPolicy - The GetKeyRotationPolicy operation returns the specified key policy resources in the specified key +// vault. This operation requires the keys/get permission. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of the key in a given key vault. +// options - KeyVaultClientGetKeyRotationPolicyOptions contains the optional parameters for the KeyVaultClient.GetKeyRotationPolicy +// method. func (client *KeyVaultClient) GetKeyRotationPolicy(ctx context.Context, vaultBaseURL string, keyName string, options *KeyVaultClientGetKeyRotationPolicyOptions) (KeyVaultClientGetKeyRotationPolicyResponse, error) { req, err := client.getKeyRotationPolicyCreateRequest(ctx, vaultBaseURL, keyName, options) if err != nil { return KeyVaultClientGetKeyRotationPolicyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientGetKeyRotationPolicyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientGetKeyRotationPolicyResponse{}, client.getKeyRotationPolicyHandleError(resp) + return KeyVaultClientGetKeyRotationPolicyResponse{}, runtime.NewResponseError(resp) } return client.getKeyRotationPolicyHandleResponse(resp) } @@ -651,21 +577,12 @@ func (client *KeyVaultClient) getKeyRotationPolicyHandleResponse(resp *http.Resp return result, nil } -// getKeyRotationPolicyHandleError handles the GetKeyRotationPolicy error response. -func (client *KeyVaultClient) getKeyRotationPolicyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// GetKeyVersions - The full key identifier, attributes, and tags are provided in the response. This operation requires the keys/list permission. -// If the operation fails it returns the *KeyVaultError error type. +// GetKeyVersions - The full key identifier, attributes, and tags are provided in the response. This operation requires the +// keys/list permission. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of the key. +// options - KeyVaultClientGetKeyVersionsOptions contains the optional parameters for the KeyVaultClient.GetKeyVersions method. func (client *KeyVaultClient) GetKeyVersions(vaultBaseURL string, keyName string, options *KeyVaultClientGetKeyVersionsOptions) *KeyVaultClientGetKeyVersionsPager { return &KeyVaultClientGetKeyVersionsPager{ client: client, @@ -710,24 +627,13 @@ func (client *KeyVaultClient) getKeyVersionsHandleResponse(resp *http.Response) return result, nil } -// getKeyVersionsHandleError handles the GetKeyVersions error response. -func (client *KeyVaultClient) getKeyVersionsHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// GetKeys - Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a stored key. The LIST operation is -// applicable to all key types, however only the base key -// identifier, attributes, and tags are provided in the response. Individual versions of a key are not listed in the response. This operation requires the -// keys/list permission. -// If the operation fails it returns the *KeyVaultError error type. +// GetKeys - Retrieves a list of the keys in the Key Vault as JSON Web Key structures that contain the public part of a stored +// key. The LIST operation is applicable to all key types, however only the base key +// identifier, attributes, and tags are provided in the response. Individual versions of a key are not listed in the response. +// This operation requires the keys/list permission. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// options - KeyVaultClientGetKeysOptions contains the optional parameters for the KeyVaultClient.GetKeys method. func (client *KeyVaultClient) GetKeys(vaultBaseURL string, options *KeyVaultClientGetKeysOptions) *KeyVaultClientGetKeysPager { return &KeyVaultClientGetKeysPager{ client: client, @@ -768,32 +674,22 @@ func (client *KeyVaultClient) getKeysHandleResponse(resp *http.Response) (KeyVau return result, nil } -// getKeysHandleError handles the GetKeys error response. -func (client *KeyVaultClient) getKeysHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // GetRandomBytes - Get the requested number of bytes containing random values from a managed HSM. -// If the operation fails it returns the *KeyVaultError error type. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// parameters - The request object to get random bytes. +// options - KeyVaultClientGetRandomBytesOptions contains the optional parameters for the KeyVaultClient.GetRandomBytes method. func (client *KeyVaultClient) GetRandomBytes(ctx context.Context, vaultBaseURL string, parameters GetRandomBytesRequest, options *KeyVaultClientGetRandomBytesOptions) (KeyVaultClientGetRandomBytesResponse, error) { req, err := client.getRandomBytesCreateRequest(ctx, vaultBaseURL, parameters, options) if err != nil { return KeyVaultClientGetRandomBytesResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientGetRandomBytesResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientGetRandomBytesResponse{}, client.getRandomBytesHandleError(resp) + return KeyVaultClientGetRandomBytesResponse{}, runtime.NewResponseError(resp) } return client.getRandomBytesHandleResponse(resp) } @@ -823,34 +719,25 @@ func (client *KeyVaultClient) getRandomBytesHandleResponse(resp *http.Response) return result, nil } -// getRandomBytesHandleError handles the GetRandomBytes error response. -func (client *KeyVaultClient) getRandomBytesHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// ImportKey - The import key operation may be used to import any key type into an Azure Key Vault. If the named key already exists, Azure Key Vault creates -// a new version of the key. This operation requires the +// ImportKey - The import key operation may be used to import any key type into an Azure Key Vault. If the named key already +// exists, Azure Key Vault creates a new version of the key. This operation requires the // keys/import permission. -// If the operation fails it returns the *KeyVaultError error type. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - Name for the imported key. +// parameters - The parameters to import a key. +// options - KeyVaultClientImportKeyOptions contains the optional parameters for the KeyVaultClient.ImportKey method. func (client *KeyVaultClient) ImportKey(ctx context.Context, vaultBaseURL string, keyName string, parameters KeyImportParameters, options *KeyVaultClientImportKeyOptions) (KeyVaultClientImportKeyResponse, error) { req, err := client.importKeyCreateRequest(ctx, vaultBaseURL, keyName, parameters, options) if err != nil { return KeyVaultClientImportKeyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientImportKeyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientImportKeyResponse{}, client.importKeyHandleError(resp) + return KeyVaultClientImportKeyResponse{}, runtime.NewResponseError(resp) } return client.importKeyHandleResponse(resp) } @@ -884,34 +771,25 @@ func (client *KeyVaultClient) importKeyHandleResponse(resp *http.Response) (KeyV return result, nil } -// importKeyHandleError handles the ImportKey error response. -func (client *KeyVaultClient) importKeyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// PurgeDeletedKey - The Purge Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can be invoked on any vault, it will -// return an error if invoked on a non soft-delete enabled vault. +// PurgeDeletedKey - The Purge Deleted Key operation is applicable for soft-delete enabled vaults. While the operation can +// be invoked on any vault, it will return an error if invoked on a non soft-delete enabled vault. // This operation requires the keys/purge permission. -// If the operation fails it returns the *KeyVaultError error type. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of the key +// options - KeyVaultClientPurgeDeletedKeyOptions contains the optional parameters for the KeyVaultClient.PurgeDeletedKey +// method. func (client *KeyVaultClient) PurgeDeletedKey(ctx context.Context, vaultBaseURL string, keyName string, options *KeyVaultClientPurgeDeletedKeyOptions) (KeyVaultClientPurgeDeletedKeyResponse, error) { req, err := client.purgeDeletedKeyCreateRequest(ctx, vaultBaseURL, keyName, options) if err != nil { return KeyVaultClientPurgeDeletedKeyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientPurgeDeletedKeyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusNoContent) { - return KeyVaultClientPurgeDeletedKeyResponse{}, client.purgeDeletedKeyHandleError(resp) + return KeyVaultClientPurgeDeletedKeyResponse{}, runtime.NewResponseError(resp) } return KeyVaultClientPurgeDeletedKeyResponse{RawResponse: resp}, nil } @@ -936,34 +814,26 @@ func (client *KeyVaultClient) purgeDeletedKeyCreateRequest(ctx context.Context, return req, nil } -// purgeDeletedKeyHandleError handles the PurgeDeletedKey error response. -func (client *KeyVaultClient) purgeDeletedKeyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// RecoverDeletedKey - The Recover Deleted Key operation is applicable for deleted keys in soft-delete enabled vaults. It recovers the deleted key back -// to its latest version under /keys. An attempt to recover an non-deleted -// key will return an error. Consider this the inverse of the delete operation on soft-delete enabled vaults. This operation requires the keys/recover permission. -// If the operation fails it returns the *KeyVaultError error type. +// RecoverDeletedKey - The Recover Deleted Key operation is applicable for deleted keys in soft-delete enabled vaults. It +// recovers the deleted key back to its latest version under /keys. An attempt to recover an non-deleted +// key will return an error. Consider this the inverse of the delete operation on soft-delete enabled vaults. This operation +// requires the keys/recover permission. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of the deleted key. +// options - KeyVaultClientRecoverDeletedKeyOptions contains the optional parameters for the KeyVaultClient.RecoverDeletedKey +// method. func (client *KeyVaultClient) RecoverDeletedKey(ctx context.Context, vaultBaseURL string, keyName string, options *KeyVaultClientRecoverDeletedKeyOptions) (KeyVaultClientRecoverDeletedKeyResponse, error) { req, err := client.recoverDeletedKeyCreateRequest(ctx, vaultBaseURL, keyName, options) if err != nil { return KeyVaultClientRecoverDeletedKeyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientRecoverDeletedKeyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientRecoverDeletedKeyResponse{}, client.recoverDeletedKeyHandleError(resp) + return KeyVaultClientRecoverDeletedKeyResponse{}, runtime.NewResponseError(resp) } return client.recoverDeletedKeyHandleResponse(resp) } @@ -997,33 +867,25 @@ func (client *KeyVaultClient) recoverDeletedKeyHandleResponse(resp *http.Respons return result, nil } -// recoverDeletedKeyHandleError handles the RecoverDeletedKey error response. -func (client *KeyVaultClient) recoverDeletedKeyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// Release - The release key operation is applicable to all key types. The target key must be marked exportable. This operation requires the keys/release -// permission. -// If the operation fails it returns the *KeyVaultError error type. +// Release - The release key operation is applicable to all key types. The target key must be marked exportable. This operation +// requires the keys/release permission. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of the key to get. +// keyVersion - Adding the version parameter retrieves a specific version of a key. +// parameters - The parameters for the key release operation. +// options - KeyVaultClientReleaseOptions contains the optional parameters for the KeyVaultClient.Release method. func (client *KeyVaultClient) Release(ctx context.Context, vaultBaseURL string, keyName string, keyVersion string, parameters KeyReleaseParameters, options *KeyVaultClientReleaseOptions) (KeyVaultClientReleaseResponse, error) { req, err := client.releaseCreateRequest(ctx, vaultBaseURL, keyName, keyVersion, parameters, options) if err != nil { return KeyVaultClientReleaseResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientReleaseResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientReleaseResponse{}, client.releaseHandleError(resp) + return KeyVaultClientReleaseResponse{}, runtime.NewResponseError(resp) } return client.releaseHandleResponse(resp) } @@ -1061,40 +923,30 @@ func (client *KeyVaultClient) releaseHandleResponse(resp *http.Response) (KeyVau return result, nil } -// releaseHandleError handles the Release error response. -func (client *KeyVaultClient) releaseHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// RestoreKey - Imports a previously backed up key into Azure Key Vault, restoring the key, its key identifier, attributes and access control policies. -// The RESTORE operation may be used to import a previously backed -// up key. Individual versions of a key cannot be restored. The key is restored in its entirety with the same key name as it had when it was backed up. -// If the key name is not available in the target Key -// Vault, the RESTORE operation will be rejected. While the key name is retained during restore, the final key identifier will change if the key is restored -// to a different vault. Restore will restore all -// versions and preserve version identifiers. The RESTORE operation is subject to security constraints: The target Key Vault must be owned by the same Microsoft -// Azure Subscription as the source Key Vault +// RestoreKey - Imports a previously backed up key into Azure Key Vault, restoring the key, its key identifier, attributes +// and access control policies. The RESTORE operation may be used to import a previously backed +// up key. Individual versions of a key cannot be restored. The key is restored in its entirety with the same key name as +// it had when it was backed up. If the key name is not available in the target Key +// Vault, the RESTORE operation will be rejected. While the key name is retained during restore, the final key identifier +// will change if the key is restored to a different vault. Restore will restore all +// versions and preserve version identifiers. The RESTORE operation is subject to security constraints: The target Key Vault +// must be owned by the same Microsoft Azure Subscription as the source Key Vault // The user must have RESTORE permission in the target Key Vault. This operation requires the keys/restore permission. -// If the operation fails it returns the *KeyVaultError error type. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// parameters - The parameters to restore the key. +// options - KeyVaultClientRestoreKeyOptions contains the optional parameters for the KeyVaultClient.RestoreKey method. func (client *KeyVaultClient) RestoreKey(ctx context.Context, vaultBaseURL string, parameters KeyRestoreParameters, options *KeyVaultClientRestoreKeyOptions) (KeyVaultClientRestoreKeyResponse, error) { req, err := client.restoreKeyCreateRequest(ctx, vaultBaseURL, parameters, options) if err != nil { return KeyVaultClientRestoreKeyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientRestoreKeyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientRestoreKeyResponse{}, client.restoreKeyHandleError(resp) + return KeyVaultClientRestoreKeyResponse{}, runtime.NewResponseError(resp) } return client.restoreKeyHandleResponse(resp) } @@ -1124,32 +976,22 @@ func (client *KeyVaultClient) restoreKeyHandleResponse(resp *http.Response) (Key return result, nil } -// restoreKeyHandleError handles the RestoreKey error response. -func (client *KeyVaultClient) restoreKeyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // RotateKey - The operation will rotate the key based on the key policy. It requires the keys/rotate permission. -// If the operation fails it returns the *KeyVaultError error type. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of key to be rotated. The system will generate a new version in the specified key. +// options - KeyVaultClientRotateKeyOptions contains the optional parameters for the KeyVaultClient.RotateKey method. func (client *KeyVaultClient) RotateKey(ctx context.Context, vaultBaseURL string, keyName string, options *KeyVaultClientRotateKeyOptions) (KeyVaultClientRotateKeyResponse, error) { req, err := client.rotateKeyCreateRequest(ctx, vaultBaseURL, keyName, options) if err != nil { return KeyVaultClientRotateKeyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientRotateKeyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientRotateKeyResponse{}, client.rotateKeyHandleError(resp) + return KeyVaultClientRotateKeyResponse{}, runtime.NewResponseError(resp) } return client.rotateKeyHandleResponse(resp) } @@ -1183,33 +1025,25 @@ func (client *KeyVaultClient) rotateKeyHandleResponse(resp *http.Response) (KeyV return result, nil } -// rotateKeyHandleError handles the RotateKey error response. -func (client *KeyVaultClient) rotateKeyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// Sign - The SIGN operation is applicable to asymmetric and symmetric keys stored in Azure Key Vault since this operation uses the private portion of the -// key. This operation requires the keys/sign permission. -// If the operation fails it returns the *KeyVaultError error type. +// Sign - The SIGN operation is applicable to asymmetric and symmetric keys stored in Azure Key Vault since this operation +// uses the private portion of the key. This operation requires the keys/sign permission. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of the key. +// keyVersion - The version of the key. +// parameters - The parameters for the signing operation. +// options - KeyVaultClientSignOptions contains the optional parameters for the KeyVaultClient.Sign method. func (client *KeyVaultClient) Sign(ctx context.Context, vaultBaseURL string, keyName string, keyVersion string, parameters KeySignParameters, options *KeyVaultClientSignOptions) (KeyVaultClientSignResponse, error) { req, err := client.signCreateRequest(ctx, vaultBaseURL, keyName, keyVersion, parameters, options) if err != nil { return KeyVaultClientSignResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientSignResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientSignResponse{}, client.signHandleError(resp) + return KeyVaultClientSignResponse{}, runtime.NewResponseError(resp) } return client.signHandleResponse(resp) } @@ -1247,34 +1081,27 @@ func (client *KeyVaultClient) signHandleResponse(resp *http.Response) (KeyVaultC return result, nil } -// signHandleError handles the Sign error response. -func (client *KeyVaultClient) signHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// UnwrapKey - The UNWRAP operation supports decryption of a symmetric key using the target key encryption key. This operation is the reverse of the WRAP -// operation. The UNWRAP operation applies to asymmetric and -// symmetric keys stored in Azure Key Vault since it uses the private portion of the key. This operation requires the keys/unwrapKey permission. -// If the operation fails it returns the *KeyVaultError error type. +// UnwrapKey - The UNWRAP operation supports decryption of a symmetric key using the target key encryption key. This operation +// is the reverse of the WRAP operation. The UNWRAP operation applies to asymmetric and +// symmetric keys stored in Azure Key Vault since it uses the private portion of the key. This operation requires the keys/unwrapKey +// permission. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of the key. +// keyVersion - The version of the key. +// parameters - The parameters for the key operation. +// options - KeyVaultClientUnwrapKeyOptions contains the optional parameters for the KeyVaultClient.UnwrapKey method. func (client *KeyVaultClient) UnwrapKey(ctx context.Context, vaultBaseURL string, keyName string, keyVersion string, parameters KeyOperationsParameters, options *KeyVaultClientUnwrapKeyOptions) (KeyVaultClientUnwrapKeyResponse, error) { req, err := client.unwrapKeyCreateRequest(ctx, vaultBaseURL, keyName, keyVersion, parameters, options) if err != nil { return KeyVaultClientUnwrapKeyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientUnwrapKeyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientUnwrapKeyResponse{}, client.unwrapKeyHandleError(resp) + return KeyVaultClientUnwrapKeyResponse{}, runtime.NewResponseError(resp) } return client.unwrapKeyHandleResponse(resp) } @@ -1312,33 +1139,25 @@ func (client *KeyVaultClient) unwrapKeyHandleResponse(resp *http.Response) (KeyV return result, nil } -// unwrapKeyHandleError handles the UnwrapKey error response. -func (client *KeyVaultClient) unwrapKeyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// UpdateKey - In order to perform this operation, the key must already exist in the Key Vault. Note: The cryptographic material of a key itself cannot -// be changed. This operation requires the keys/update permission. -// If the operation fails it returns the *KeyVaultError error type. +// UpdateKey - In order to perform this operation, the key must already exist in the Key Vault. Note: The cryptographic material +// of a key itself cannot be changed. This operation requires the keys/update permission. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of key to update. +// keyVersion - The version of the key to update. +// parameters - The parameters of the key to update. +// options - KeyVaultClientUpdateKeyOptions contains the optional parameters for the KeyVaultClient.UpdateKey method. func (client *KeyVaultClient) UpdateKey(ctx context.Context, vaultBaseURL string, keyName string, keyVersion string, parameters KeyUpdateParameters, options *KeyVaultClientUpdateKeyOptions) (KeyVaultClientUpdateKeyResponse, error) { req, err := client.updateKeyCreateRequest(ctx, vaultBaseURL, keyName, keyVersion, parameters, options) if err != nil { return KeyVaultClientUpdateKeyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientUpdateKeyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientUpdateKeyResponse{}, client.updateKeyHandleError(resp) + return KeyVaultClientUpdateKeyResponse{}, runtime.NewResponseError(resp) } return client.updateKeyHandleResponse(resp) } @@ -1376,32 +1195,25 @@ func (client *KeyVaultClient) updateKeyHandleResponse(resp *http.Response) (KeyV return result, nil } -// updateKeyHandleError handles the UpdateKey error response. -func (client *KeyVaultClient) updateKeyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// UpdateKeyRotationPolicy - Set specified members in the key policy. Leave others as undefined. This operation requires the keys/update permission. -// If the operation fails it returns the *KeyVaultError error type. +// UpdateKeyRotationPolicy - Set specified members in the key policy. Leave others as undefined. This operation requires the +// keys/update permission. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of the key in the given vault. +// keyRotationPolicy - The policy for the key. +// options - KeyVaultClientUpdateKeyRotationPolicyOptions contains the optional parameters for the KeyVaultClient.UpdateKeyRotationPolicy +// method. func (client *KeyVaultClient) UpdateKeyRotationPolicy(ctx context.Context, vaultBaseURL string, keyName string, keyRotationPolicy KeyRotationPolicy, options *KeyVaultClientUpdateKeyRotationPolicyOptions) (KeyVaultClientUpdateKeyRotationPolicyResponse, error) { req, err := client.updateKeyRotationPolicyCreateRequest(ctx, vaultBaseURL, keyName, keyRotationPolicy, options) if err != nil { return KeyVaultClientUpdateKeyRotationPolicyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientUpdateKeyRotationPolicyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientUpdateKeyRotationPolicyResponse{}, client.updateKeyRotationPolicyHandleError(resp) + return KeyVaultClientUpdateKeyRotationPolicyResponse{}, runtime.NewResponseError(resp) } return client.updateKeyRotationPolicyHandleResponse(resp) } @@ -1435,36 +1247,28 @@ func (client *KeyVaultClient) updateKeyRotationPolicyHandleResponse(resp *http.R return result, nil } -// updateKeyRotationPolicyHandleError handles the UpdateKeyRotationPolicy error response. -func (client *KeyVaultClient) updateKeyRotationPolicyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// Verify - The VERIFY operation is applicable to symmetric keys stored in Azure Key Vault. VERIFY is not strictly necessary for asymmetric keys stored -// in Azure Key Vault since signature verification can be -// performed using the public portion of the key but this operation is supported as a convenience for callers that only have a key-reference and not the -// public portion of the key. This operation requires +// Verify - The VERIFY operation is applicable to symmetric keys stored in Azure Key Vault. VERIFY is not strictly necessary +// for asymmetric keys stored in Azure Key Vault since signature verification can be +// performed using the public portion of the key but this operation is supported as a convenience for callers that only have +// a key-reference and not the public portion of the key. This operation requires // the keys/verify permission. -// If the operation fails it returns the *KeyVaultError error type. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of the key. +// keyVersion - The version of the key. +// parameters - The parameters for verify operations. +// options - KeyVaultClientVerifyOptions contains the optional parameters for the KeyVaultClient.Verify method. func (client *KeyVaultClient) Verify(ctx context.Context, vaultBaseURL string, keyName string, keyVersion string, parameters KeyVerifyParameters, options *KeyVaultClientVerifyOptions) (KeyVaultClientVerifyResponse, error) { req, err := client.verifyCreateRequest(ctx, vaultBaseURL, keyName, keyVersion, parameters, options) if err != nil { return KeyVaultClientVerifyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientVerifyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientVerifyResponse{}, client.verifyHandleError(resp) + return KeyVaultClientVerifyResponse{}, runtime.NewResponseError(resp) } return client.verifyHandleResponse(resp) } @@ -1502,36 +1306,29 @@ func (client *KeyVaultClient) verifyHandleResponse(resp *http.Response) (KeyVaul return result, nil } -// verifyHandleError handles the Verify error response. -func (client *KeyVaultClient) verifyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - -// WrapKey - The WRAP operation supports encryption of a symmetric key using a key encryption key that has previously been stored in an Azure Key Vault. -// The WRAP operation is only strictly necessary for symmetric -// keys stored in Azure Key Vault since protection with an asymmetric key can be performed using the public portion of the key. This operation is supported -// for asymmetric keys as a convenience for -// callers that have a key-reference but do not have access to the public key material. This operation requires the keys/wrapKey permission. -// If the operation fails it returns the *KeyVaultError error type. +// WrapKey - The WRAP operation supports encryption of a symmetric key using a key encryption key that has previously been +// stored in an Azure Key Vault. The WRAP operation is only strictly necessary for symmetric +// keys stored in Azure Key Vault since protection with an asymmetric key can be performed using the public portion of the +// key. This operation is supported for asymmetric keys as a convenience for +// callers that have a key-reference but do not have access to the public key material. This operation requires the keys/wrapKey +// permission. +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// keyName - The name of the key. +// keyVersion - The version of the key. +// parameters - The parameters for wrap operation. +// options - KeyVaultClientWrapKeyOptions contains the optional parameters for the KeyVaultClient.WrapKey method. func (client *KeyVaultClient) WrapKey(ctx context.Context, vaultBaseURL string, keyName string, keyVersion string, parameters KeyOperationsParameters, options *KeyVaultClientWrapKeyOptions) (KeyVaultClientWrapKeyResponse, error) { req, err := client.wrapKeyCreateRequest(ctx, vaultBaseURL, keyName, keyVersion, parameters, options) if err != nil { return KeyVaultClientWrapKeyResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { return KeyVaultClientWrapKeyResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeyVaultClientWrapKeyResponse{}, client.wrapKeyHandleError(resp) + return KeyVaultClientWrapKeyResponse{}, runtime.NewResponseError(resp) } return client.wrapKeyHandleResponse(resp) } @@ -1568,16 +1365,3 @@ func (client *KeyVaultClient) wrapKeyHandleResponse(resp *http.Response) (KeyVau } return result, nil } - -// wrapKeyHandleError handles the WrapKey error response. -func (client *KeyVaultClient) wrapKeyHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} diff --git a/sdk/keyvault/azkeys/internal/generated/models.go b/sdk/keyvault/azkeys/internal/generated/models.go index 21bbeafaef84..a9952e614c11 100644 --- a/sdk/keyvault/azkeys/internal/generated/models.go +++ b/sdk/keyvault/azkeys/internal/generated/models.go @@ -6,7 +6,7 @@ // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -package internal +package generated import ( "encoding/json" @@ -37,7 +37,11 @@ type Attributes struct { // MarshalJSON implements the json.Marshaller interface for type Attributes. func (a Attributes) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - a.marshalInternal(objectMap) + populateTimeUnix(objectMap, "created", a.Created) + populate(objectMap, "enabled", a.Enabled) + populateTimeUnix(objectMap, "exp", a.Expires) + populateTimeUnix(objectMap, "nbf", a.NotBefore) + populateTimeUnix(objectMap, "updated", a.Updated) return json.Marshal(objectMap) } @@ -47,18 +51,6 @@ func (a *Attributes) UnmarshalJSON(data []byte) error { if err := json.Unmarshal(data, &rawMsg); err != nil { return err } - return a.unmarshalInternal(rawMsg) -} - -func (a Attributes) marshalInternal(objectMap map[string]interface{}) { - populateTimeUnix(objectMap, "created", a.Created) - populate(objectMap, "enabled", a.Enabled) - populateTimeUnix(objectMap, "exp", a.Expires) - populateTimeUnix(objectMap, "nbf", a.NotBefore) - populateTimeUnix(objectMap, "updated", a.Updated) -} - -func (a *Attributes) unmarshalInternal(rawMsg map[string]json.RawMessage) error { for key, val := range rawMsg { var err error switch key { @@ -136,13 +128,28 @@ func (c CertificateInfoObject) MarshalJSON() ([]byte, error) { // DeletedKeyBundle - A DeletedKeyBundle consisting of a WebKey plus its Attributes and deletion info type DeletedKeyBundle struct { - KeyBundle + // The key management attributes. + Attributes *KeyAttributes `json:"attributes,omitempty"` + + // The Json web key. + Key *JSONWebKey `json:"key,omitempty"` + // The url of the recovery object, used to identify and recover the deleted key. RecoveryID *string `json:"recoveryId,omitempty"` + // The policy rules under which the key can be exported. + ReleasePolicy *KeyReleasePolicy `json:"release_policy,omitempty"` + + // Application specific metadata in the form of key-value pairs. + Tags map[string]*string `json:"tags,omitempty"` + // READ-ONLY; The time when the key was deleted, in UTC DeletedDate *time.Time `json:"deletedDate,omitempty" azure:"ro"` + // READ-ONLY; True if the key's lifetime is managed by key vault. If this is a key backing a certificate, then managed will + // be true. + Managed *bool `json:"managed,omitempty" azure:"ro"` + // READ-ONLY; The time when the key is scheduled to be purged, in UTC ScheduledPurgeDate *time.Time `json:"scheduledPurgeDate,omitempty" azure:"ro"` } @@ -150,10 +157,14 @@ type DeletedKeyBundle struct { // MarshalJSON implements the json.Marshaller interface for type DeletedKeyBundle. func (d DeletedKeyBundle) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - d.KeyBundle.marshalInternal(objectMap) + populate(objectMap, "attributes", d.Attributes) populateTimeUnix(objectMap, "deletedDate", d.DeletedDate) + populate(objectMap, "key", d.Key) + populate(objectMap, "managed", d.Managed) populate(objectMap, "recoveryId", d.RecoveryID) + populate(objectMap, "release_policy", d.ReleasePolicy) populateTimeUnix(objectMap, "scheduledPurgeDate", d.ScheduledPurgeDate) + populate(objectMap, "tags", d.Tags) return json.Marshal(objectMap) } @@ -166,35 +177,59 @@ func (d *DeletedKeyBundle) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "attributes": + err = unpopulate(val, &d.Attributes) + delete(rawMsg, key) case "deletedDate": err = unpopulateTimeUnix(val, &d.DeletedDate) delete(rawMsg, key) + case "key": + err = unpopulate(val, &d.Key) + delete(rawMsg, key) + case "managed": + err = unpopulate(val, &d.Managed) + delete(rawMsg, key) case "recoveryId": err = unpopulate(val, &d.RecoveryID) delete(rawMsg, key) + case "release_policy": + err = unpopulate(val, &d.ReleasePolicy) + delete(rawMsg, key) case "scheduledPurgeDate": err = unpopulateTimeUnix(val, &d.ScheduledPurgeDate) delete(rawMsg, key) + case "tags": + err = unpopulate(val, &d.Tags) + delete(rawMsg, key) } if err != nil { return err } } - if err := d.KeyBundle.unmarshalInternal(rawMsg); err != nil { - return err - } return nil } // DeletedKeyItem - The deleted key item containing the deleted key metadata and information about deletion. type DeletedKeyItem struct { - KeyItem + // The key management attributes. + Attributes *KeyAttributes `json:"attributes,omitempty"` + + // Key identifier. + Kid *string `json:"kid,omitempty"` + // The url of the recovery object, used to identify and recover the deleted key. RecoveryID *string `json:"recoveryId,omitempty"` + // Application specific metadata in the form of key-value pairs. + Tags map[string]*string `json:"tags,omitempty"` + // READ-ONLY; The time when the key was deleted, in UTC DeletedDate *time.Time `json:"deletedDate,omitempty" azure:"ro"` + // READ-ONLY; True if the key's lifetime is managed by key vault. If this is a key backing a certificate, then managed will + // be true. + Managed *bool `json:"managed,omitempty" azure:"ro"` + // READ-ONLY; The time when the key is scheduled to be purged, in UTC ScheduledPurgeDate *time.Time `json:"scheduledPurgeDate,omitempty" azure:"ro"` } @@ -202,10 +237,13 @@ type DeletedKeyItem struct { // MarshalJSON implements the json.Marshaller interface for type DeletedKeyItem. func (d DeletedKeyItem) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - d.KeyItem.marshalInternal(objectMap) + populate(objectMap, "attributes", d.Attributes) populateTimeUnix(objectMap, "deletedDate", d.DeletedDate) + populate(objectMap, "kid", d.Kid) + populate(objectMap, "managed", d.Managed) populate(objectMap, "recoveryId", d.RecoveryID) populateTimeUnix(objectMap, "scheduledPurgeDate", d.ScheduledPurgeDate) + populate(objectMap, "tags", d.Tags) return json.Marshal(objectMap) } @@ -218,23 +256,32 @@ func (d *DeletedKeyItem) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "attributes": + err = unpopulate(val, &d.Attributes) + delete(rawMsg, key) case "deletedDate": err = unpopulateTimeUnix(val, &d.DeletedDate) delete(rawMsg, key) + case "kid": + err = unpopulate(val, &d.Kid) + delete(rawMsg, key) + case "managed": + err = unpopulate(val, &d.Managed) + delete(rawMsg, key) case "recoveryId": err = unpopulate(val, &d.RecoveryID) delete(rawMsg, key) case "scheduledPurgeDate": err = unpopulateTimeUnix(val, &d.ScheduledPurgeDate) delete(rawMsg, key) + case "tags": + err = unpopulate(val, &d.Tags) + delete(rawMsg, key) } if err != nil { return err } } - if err := d.KeyItem.unmarshalInternal(rawMsg); err != nil { - return err - } return nil } @@ -243,7 +290,8 @@ type DeletedKeyListResult struct { // READ-ONLY; The URL to get the next set of deleted keys. NextLink *string `json:"nextLink,omitempty" azure:"ro"` - // READ-ONLY; A response message containing a list of deleted keys in the vault along with a link to the next page of deleted keys + // READ-ONLY; A response message containing a list of deleted keys in the vault along with a link to the next page of deleted + // keys Value []*DeletedKeyItem `json:"value,omitempty" azure:"ro"` } @@ -273,28 +321,33 @@ type GetRandomBytesRequest struct { Count *int32 `json:"count,omitempty"` } -// HSMSecurityDomainBeginDownloadOptions contains the optional parameters for the HSMSecurityDomain.BeginDownload method. -type HSMSecurityDomainBeginDownloadOptions struct { +// HSMSecurityDomainClientBeginDownloadOptions contains the optional parameters for the HSMSecurityDomainClient.BeginDownload +// method. +type HSMSecurityDomainClientBeginDownloadOptions struct { // placeholder for future optional parameters } -// HSMSecurityDomainBeginUploadOptions contains the optional parameters for the HSMSecurityDomain.BeginUpload method. -type HSMSecurityDomainBeginUploadOptions struct { +// HSMSecurityDomainClientBeginUploadOptions contains the optional parameters for the HSMSecurityDomainClient.BeginUpload +// method. +type HSMSecurityDomainClientBeginUploadOptions struct { // placeholder for future optional parameters } -// HSMSecurityDomainDownloadPendingOptions contains the optional parameters for the HSMSecurityDomain.DownloadPending method. -type HSMSecurityDomainDownloadPendingOptions struct { +// HSMSecurityDomainClientDownloadPendingOptions contains the optional parameters for the HSMSecurityDomainClient.DownloadPending +// method. +type HSMSecurityDomainClientDownloadPendingOptions struct { // placeholder for future optional parameters } -// HSMSecurityDomainTransferKeyOptions contains the optional parameters for the HSMSecurityDomain.TransferKey method. -type HSMSecurityDomainTransferKeyOptions struct { +// HSMSecurityDomainClientTransferKeyOptions contains the optional parameters for the HSMSecurityDomainClient.TransferKey +// method. +type HSMSecurityDomainClientTransferKeyOptions struct { // placeholder for future optional parameters } -// HSMSecurityDomainUploadPendingOptions contains the optional parameters for the HSMSecurityDomain.UploadPending method. -type HSMSecurityDomainUploadPendingOptions struct { +// HSMSecurityDomainClientUploadPendingOptions contains the optional parameters for the HSMSecurityDomainClient.UploadPending +// method. +type HSMSecurityDomainClientUploadPendingOptions struct { // placeholder for future optional parameters } @@ -436,26 +489,44 @@ func (j *JSONWebKey) UnmarshalJSON(data []byte) error { // KeyAttributes - The attributes of a key managed by the key vault service. type KeyAttributes struct { - Attributes + // Determines whether the object is enabled. + Enabled *bool `json:"enabled,omitempty"` + + // Expiry date in UTC. + Expires *time.Time `json:"exp,omitempty"` + // Indicates if the private key can be exported. Exportable *bool `json:"exportable,omitempty"` + // Not before date in UTC. + NotBefore *time.Time `json:"nbf,omitempty"` + + // READ-ONLY; Creation time in UTC. + Created *time.Time `json:"created,omitempty" azure:"ro"` + // READ-ONLY; softDelete data retention days. Value should be >=7 and <=90 when softDelete enabled, otherwise 0. RecoverableDays *int32 `json:"recoverableDays,omitempty" azure:"ro"` - // READ-ONLY; Reflects the deletion recovery level currently in effect for keys in the current vault. If it contains 'Purgeable' the key can be permanently - // deleted by a privileged user; otherwise, only the system + // READ-ONLY; Reflects the deletion recovery level currently in effect for keys in the current vault. If it contains 'Purgeable' + // the key can be permanently deleted by a privileged user; otherwise, only the system // can purge the key, at the end of the retention interval. RecoveryLevel *DeletionRecoveryLevel `json:"recoveryLevel,omitempty" azure:"ro"` + + // READ-ONLY; Last updated time in UTC. + Updated *time.Time `json:"updated,omitempty" azure:"ro"` } // MarshalJSON implements the json.Marshaller interface for type KeyAttributes. func (k KeyAttributes) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - k.Attributes.marshalInternal(objectMap) + populateTimeUnix(objectMap, "created", k.Created) + populate(objectMap, "enabled", k.Enabled) + populateTimeUnix(objectMap, "exp", k.Expires) populate(objectMap, "exportable", k.Exportable) + populateTimeUnix(objectMap, "nbf", k.NotBefore) populate(objectMap, "recoverableDays", k.RecoverableDays) populate(objectMap, "recoveryLevel", k.RecoveryLevel) + populateTimeUnix(objectMap, "updated", k.Updated) return json.Marshal(objectMap) } @@ -468,23 +539,35 @@ func (k *KeyAttributes) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { + case "created": + err = unpopulateTimeUnix(val, &k.Created) + delete(rawMsg, key) + case "enabled": + err = unpopulate(val, &k.Enabled) + delete(rawMsg, key) + case "exp": + err = unpopulateTimeUnix(val, &k.Expires) + delete(rawMsg, key) case "exportable": err = unpopulate(val, &k.Exportable) delete(rawMsg, key) + case "nbf": + err = unpopulateTimeUnix(val, &k.NotBefore) + delete(rawMsg, key) case "recoverableDays": err = unpopulate(val, &k.RecoverableDays) delete(rawMsg, key) case "recoveryLevel": err = unpopulate(val, &k.RecoveryLevel) delete(rawMsg, key) + case "updated": + err = unpopulateTimeUnix(val, &k.Updated) + delete(rawMsg, key) } if err != nil { return err } } - if err := k.Attributes.unmarshalInternal(rawMsg); err != nil { - return err - } return nil } @@ -502,59 +585,20 @@ type KeyBundle struct { // Application specific metadata in the form of key-value pairs. Tags map[string]*string `json:"tags,omitempty"` - // READ-ONLY; True if the key's lifetime is managed by key vault. If this is a key backing a certificate, then managed will be true. + // READ-ONLY; True if the key's lifetime is managed by key vault. If this is a key backing a certificate, then managed will + // be true. Managed *bool `json:"managed,omitempty" azure:"ro"` } // MarshalJSON implements the json.Marshaller interface for type KeyBundle. func (k KeyBundle) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - k.marshalInternal(objectMap) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type KeyBundle. -func (k *KeyBundle) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return err - } - return k.unmarshalInternal(rawMsg) -} - -func (k KeyBundle) marshalInternal(objectMap map[string]interface{}) { populate(objectMap, "attributes", k.Attributes) populate(objectMap, "key", k.Key) populate(objectMap, "managed", k.Managed) populate(objectMap, "release_policy", k.ReleasePolicy) populate(objectMap, "tags", k.Tags) -} - -func (k *KeyBundle) unmarshalInternal(rawMsg map[string]json.RawMessage) error { - for key, val := range rawMsg { - var err error - switch key { - case "attributes": - err = unpopulate(val, &k.Attributes) - delete(rawMsg, key) - case "key": - err = unpopulate(val, &k.Key) - delete(rawMsg, key) - case "managed": - err = unpopulate(val, &k.Managed) - delete(rawMsg, key) - case "release_policy": - err = unpopulate(val, &k.ReleasePolicy) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, &k.Tags) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil + return json.Marshal(objectMap) } // KeyCreateParameters - The key create parameters. @@ -648,55 +692,19 @@ type KeyItem struct { // Application specific metadata in the form of key-value pairs. Tags map[string]*string `json:"tags,omitempty"` - // READ-ONLY; True if the key's lifetime is managed by key vault. If this is a key backing a certificate, then managed will be true. + // READ-ONLY; True if the key's lifetime is managed by key vault. If this is a key backing a certificate, then managed will + // be true. Managed *bool `json:"managed,omitempty" azure:"ro"` } // MarshalJSON implements the json.Marshaller interface for type KeyItem. func (k KeyItem) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - k.marshalInternal(objectMap) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type KeyItem. -func (k *KeyItem) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return err - } - return k.unmarshalInternal(rawMsg) -} - -func (k KeyItem) marshalInternal(objectMap map[string]interface{}) { populate(objectMap, "attributes", k.Attributes) populate(objectMap, "kid", k.Kid) populate(objectMap, "managed", k.Managed) populate(objectMap, "tags", k.Tags) -} - -func (k *KeyItem) unmarshalInternal(rawMsg map[string]json.RawMessage) error { - for key, val := range rawMsg { - var err error - switch key { - case "attributes": - err = unpopulate(val, &k.Attributes) - delete(rawMsg, key) - case "kid": - err = unpopulate(val, &k.Kid) - delete(rawMsg, key) - case "managed": - err = unpopulate(val, &k.Managed) - delete(rawMsg, key) - case "tags": - err = unpopulate(val, &k.Tags) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil + return json.Marshal(objectMap) } // KeyListResult - The key list result. @@ -951,8 +959,8 @@ type KeyRotationPolicy struct { // The key rotation policy attributes. Attributes *KeyRotationPolicyAttributes `json:"attributes,omitempty"` - // Actions that will be performed by Key Vault over the lifetime of a key. For preview, lifetimeActions can only have two items at maximum: one for rotate, - // one for notify. Notification time would be + // Actions that will be performed by Key Vault over the lifetime of a key. For preview, lifetimeActions can only have two + // items at maximum: one for rotate, one for notify. Notification time would be // default to 30 days before expiry and it is not configurable. LifetimeActions []*LifetimeActions `json:"lifetimeActions,omitempty"` @@ -971,8 +979,8 @@ func (k KeyRotationPolicy) MarshalJSON() ([]byte, error) { // KeyRotationPolicyAttributes - The key rotation policy attributes. type KeyRotationPolicyAttributes struct { - // The expiryTime will be applied on the new key version. It should be at least 28 days. It will be in ISO 8601 Format. Examples: 90 days: P90D, 3 months: - // P3M, 48 hours: PT48H, 1 year and 10 days: P1Y10D + // The expiryTime will be applied on the new key version. It should be at least 28 days. It will be in ISO 8601 Format. Examples: + // 90 days: P90D, 3 months: P3M, 48 hours: PT48H, 1 year and 10 days: P1Y10D ExpiryTime *string `json:"expiryTime,omitempty"` // READ-ONLY; The key rotation policy created time in UTC. @@ -1128,7 +1136,8 @@ type KeyVaultClientGetKeyOptions struct { // placeholder for future optional parameters } -// KeyVaultClientGetKeyRotationPolicyOptions contains the optional parameters for the KeyVaultClient.GetKeyRotationPolicy method. +// KeyVaultClientGetKeyRotationPolicyOptions contains the optional parameters for the KeyVaultClient.GetKeyRotationPolicy +// method. type KeyVaultClientGetKeyRotationPolicyOptions struct { // placeholder for future optional parameters } @@ -1195,7 +1204,8 @@ type KeyVaultClientUpdateKeyOptions struct { // placeholder for future optional parameters } -// KeyVaultClientUpdateKeyRotationPolicyOptions contains the optional parameters for the KeyVaultClient.UpdateKeyRotationPolicy method. +// KeyVaultClientUpdateKeyRotationPolicyOptions contains the optional parameters for the KeyVaultClient.UpdateKeyRotationPolicy +// method. type KeyVaultClientUpdateKeyRotationPolicyOptions struct { // placeholder for future optional parameters } @@ -1211,17 +1221,9 @@ type KeyVaultClientWrapKeyOptions struct { } // KeyVaultError - The key vault error exception. -// Implements the error and azcore.HTTPResponse interfaces. type KeyVaultError struct { - raw string // READ-ONLY; The key vault server error. - InnerError *Error `json:"error,omitempty" azure:"ro"` -} - -// Error implements the error interface for type KeyVaultError. -// The contents of the error text are not contractual and subject to change. -func (e KeyVaultError) Error() string { - return e.raw + Error *Error `json:"error,omitempty" azure:"ro"` } // KeyVerifyParameters - The key verify parameters. @@ -1288,7 +1290,8 @@ type LifetimeActions struct { // LifetimeActionsTrigger - A condition to be satisfied for an action to be executed. type LifetimeActionsTrigger struct { - // Time after creation to attempt to rotate. It only applies to rotate. It will be in ISO 8601 duration format. Example: 90 days : "P90D" + // Time after creation to attempt to rotate. It only applies to rotate. It will be in ISO 8601 duration format. Example: 90 + // days : "P90D" TimeAfterCreate *string `json:"timeAfterCreate,omitempty"` // Time before expiry to attempt to rotate or notify. It will be in ISO 8601 duration format. Example: 90 days : "P90D" @@ -1405,8 +1408,8 @@ func (r RoleAssignmentListResult) MarshalJSON() ([]byte, error) { // RoleAssignmentProperties - Role assignment properties. type RoleAssignmentProperties struct { - // REQUIRED; The principal ID assigned to the role. This maps to the ID inside the Active Directory. It can point to a user, service principal, or security - // group. + // REQUIRED; The principal ID assigned to the role. This maps to the ID inside the Active Directory. It can point to a user, + // service principal, or security group. PrincipalID *string `json:"principalId,omitempty"` // REQUIRED; The role definition ID used in the role assignment. @@ -1425,25 +1428,26 @@ type RoleAssignmentPropertiesWithScope struct { Scope *RoleScope `json:"scope,omitempty"` } -// RoleAssignmentsCreateOptions contains the optional parameters for the RoleAssignments.Create method. -type RoleAssignmentsCreateOptions struct { +// RoleAssignmentsClientCreateOptions contains the optional parameters for the RoleAssignmentsClient.Create method. +type RoleAssignmentsClientCreateOptions struct { // placeholder for future optional parameters } -// RoleAssignmentsDeleteOptions contains the optional parameters for the RoleAssignments.Delete method. -type RoleAssignmentsDeleteOptions struct { +// RoleAssignmentsClientDeleteOptions contains the optional parameters for the RoleAssignmentsClient.Delete method. +type RoleAssignmentsClientDeleteOptions struct { // placeholder for future optional parameters } -// RoleAssignmentsGetOptions contains the optional parameters for the RoleAssignments.Get method. -type RoleAssignmentsGetOptions struct { +// RoleAssignmentsClientGetOptions contains the optional parameters for the RoleAssignmentsClient.Get method. +type RoleAssignmentsClientGetOptions struct { // placeholder for future optional parameters } -// RoleAssignmentsListForScopeOptions contains the optional parameters for the RoleAssignments.ListForScope method. -type RoleAssignmentsListForScopeOptions struct { - // The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId eq {id} to - // return all role assignments at, above or below the scope for the specified principal. +// RoleAssignmentsClientListForScopeOptions contains the optional parameters for the RoleAssignmentsClient.ListForScope method. +type RoleAssignmentsClientListForScopeOptions struct { + // The filter to apply on the operation. Use $filter=atScope() to return all role assignments at or above the scope. Use $filter=principalId + // eq {id} to return all role assignments at, above or below the + // scope for the specified principal. Filter *string } @@ -1520,23 +1524,24 @@ func (r RoleDefinitionProperties) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// RoleDefinitionsCreateOrUpdateOptions contains the optional parameters for the RoleDefinitions.CreateOrUpdate method. -type RoleDefinitionsCreateOrUpdateOptions struct { +// RoleDefinitionsClientCreateOrUpdateOptions contains the optional parameters for the RoleDefinitionsClient.CreateOrUpdate +// method. +type RoleDefinitionsClientCreateOrUpdateOptions struct { // placeholder for future optional parameters } -// RoleDefinitionsDeleteOptions contains the optional parameters for the RoleDefinitions.Delete method. -type RoleDefinitionsDeleteOptions struct { +// RoleDefinitionsClientDeleteOptions contains the optional parameters for the RoleDefinitionsClient.Delete method. +type RoleDefinitionsClientDeleteOptions struct { // placeholder for future optional parameters } -// RoleDefinitionsGetOptions contains the optional parameters for the RoleDefinitions.Get method. -type RoleDefinitionsGetOptions struct { +// RoleDefinitionsClientGetOptions contains the optional parameters for the RoleDefinitionsClient.Get method. +type RoleDefinitionsClientGetOptions struct { // placeholder for future optional parameters } -// RoleDefinitionsListOptions contains the optional parameters for the RoleDefinitions.List method. -type RoleDefinitionsListOptions struct { +// RoleDefinitionsClientListOptions contains the optional parameters for the RoleDefinitionsClient.List method. +type RoleDefinitionsClientListOptions struct { // The filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as well. Filter *string } @@ -1554,8 +1559,8 @@ type SecurityDomainJSONWebKey struct { // REQUIRED; Key identifier. Kid *string `json:"kid,omitempty"` - // REQUIRED; JsonWebKey Key Type (kty), as defined in https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. For Security Domain this value - // must be RSA. + // REQUIRED; JsonWebKey Key Type (kty), as defined in https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40. + // For Security Domain this value must be RSA. Kty *string `json:"kty,omitempty"` // REQUIRED; RSA modulus. diff --git a/sdk/keyvault/azkeys/internal/generated/pagers.go b/sdk/keyvault/azkeys/internal/generated/pagers.go index 8654ece6860e..a7675562c748 100644 --- a/sdk/keyvault/azkeys/internal/generated/pagers.go +++ b/sdk/keyvault/azkeys/internal/generated/pagers.go @@ -6,7 +6,7 @@ // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -package internal +package generated import ( "context" @@ -47,13 +47,13 @@ func (p *KeyVaultClientGetDeletedKeysPager) NextPage(ctx context.Context) bool { p.err = err return false } - resp, err := p.client.con.Pipeline().Do(req) + resp, err := p.client.pl.Do(req) if err != nil { p.err = err return false } if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = p.client.getDeletedKeysHandleError(resp) + p.err = runtime.NewResponseError(resp) return false } result, err := p.client.getDeletedKeysHandleResponse(resp) @@ -101,13 +101,13 @@ func (p *KeyVaultClientGetKeyVersionsPager) NextPage(ctx context.Context) bool { p.err = err return false } - resp, err := p.client.con.Pipeline().Do(req) + resp, err := p.client.pl.Do(req) if err != nil { p.err = err return false } if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = p.client.getKeyVersionsHandleError(resp) + p.err = runtime.NewResponseError(resp) return false } result, err := p.client.getKeyVersionsHandleResponse(resp) @@ -155,13 +155,13 @@ func (p *KeyVaultClientGetKeysPager) NextPage(ctx context.Context) bool { p.err = err return false } - resp, err := p.client.con.Pipeline().Do(req) + resp, err := p.client.pl.Do(req) if err != nil { p.err = err return false } if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = p.client.getKeysHandleError(resp) + p.err = runtime.NewResponseError(resp) return false } result, err := p.client.getKeysHandleResponse(resp) @@ -178,23 +178,23 @@ func (p *KeyVaultClientGetKeysPager) PageResponse() KeyVaultClientGetKeysRespons return p.current } -// RoleAssignmentsListForScopePager provides operations for iterating over paged responses. -type RoleAssignmentsListForScopePager struct { +// RoleAssignmentsClientListForScopePager provides operations for iterating over paged responses. +type RoleAssignmentsClientListForScopePager struct { client *RoleAssignmentsClient - current RoleAssignmentsListForScopeResponse + current RoleAssignmentsClientListForScopeResponse err error requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, RoleAssignmentsListForScopeResponse) (*policy.Request, error) + advancer func(context.Context, RoleAssignmentsClientListForScopeResponse) (*policy.Request, error) } // Err returns the last error encountered while paging. -func (p *RoleAssignmentsListForScopePager) Err() error { +func (p *RoleAssignmentsClientListForScopePager) Err() error { return p.err } // NextPage returns true if the pager advanced to the next page. // Returns false if there are no more pages or an error occurred. -func (p *RoleAssignmentsListForScopePager) NextPage(ctx context.Context) bool { +func (p *RoleAssignmentsClientListForScopePager) NextPage(ctx context.Context) bool { var req *policy.Request var err error if !reflect.ValueOf(p.current).IsZero() { @@ -209,13 +209,13 @@ func (p *RoleAssignmentsListForScopePager) NextPage(ctx context.Context) bool { p.err = err return false } - resp, err := p.client.con.Pipeline().Do(req) + resp, err := p.client.pl.Do(req) if err != nil { p.err = err return false } if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = p.client.listForScopeHandleError(resp) + p.err = runtime.NewResponseError(resp) return false } result, err := p.client.listForScopeHandleResponse(resp) @@ -227,28 +227,28 @@ func (p *RoleAssignmentsListForScopePager) NextPage(ctx context.Context) bool { return true } -// PageResponse returns the current RoleAssignmentsListForScopeResponse page. -func (p *RoleAssignmentsListForScopePager) PageResponse() RoleAssignmentsListForScopeResponse { +// PageResponse returns the current RoleAssignmentsClientListForScopeResponse page. +func (p *RoleAssignmentsClientListForScopePager) PageResponse() RoleAssignmentsClientListForScopeResponse { return p.current } -// RoleDefinitionsListPager provides operations for iterating over paged responses. -type RoleDefinitionsListPager struct { +// RoleDefinitionsClientListPager provides operations for iterating over paged responses. +type RoleDefinitionsClientListPager struct { client *RoleDefinitionsClient - current RoleDefinitionsListResponse + current RoleDefinitionsClientListResponse err error requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, RoleDefinitionsListResponse) (*policy.Request, error) + advancer func(context.Context, RoleDefinitionsClientListResponse) (*policy.Request, error) } // Err returns the last error encountered while paging. -func (p *RoleDefinitionsListPager) Err() error { +func (p *RoleDefinitionsClientListPager) Err() error { return p.err } // NextPage returns true if the pager advanced to the next page. // Returns false if there are no more pages or an error occurred. -func (p *RoleDefinitionsListPager) NextPage(ctx context.Context) bool { +func (p *RoleDefinitionsClientListPager) NextPage(ctx context.Context) bool { var req *policy.Request var err error if !reflect.ValueOf(p.current).IsZero() { @@ -263,13 +263,13 @@ func (p *RoleDefinitionsListPager) NextPage(ctx context.Context) bool { p.err = err return false } - resp, err := p.client.con.Pipeline().Do(req) + resp, err := p.client.pl.Do(req) if err != nil { p.err = err return false } if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = p.client.listHandleError(resp) + p.err = runtime.NewResponseError(resp) return false } result, err := p.client.listHandleResponse(resp) @@ -281,7 +281,7 @@ func (p *RoleDefinitionsListPager) NextPage(ctx context.Context) bool { return true } -// PageResponse returns the current RoleDefinitionsListResponse page. -func (p *RoleDefinitionsListPager) PageResponse() RoleDefinitionsListResponse { +// PageResponse returns the current RoleDefinitionsClientListResponse page. +func (p *RoleDefinitionsClientListPager) PageResponse() RoleDefinitionsClientListResponse { return p.current } diff --git a/sdk/keyvault/azkeys/internal/generated/pollers.go b/sdk/keyvault/azkeys/internal/generated/pollers.go index 2b5e07174fe8..4f96c2593ab9 100644 --- a/sdk/keyvault/azkeys/internal/generated/pollers.go +++ b/sdk/keyvault/azkeys/internal/generated/pollers.go @@ -6,7 +6,7 @@ // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -package internal +package generated import ( "context" @@ -14,13 +14,13 @@ import ( "net/http" ) -// HSMSecurityDomainDownloadPoller provides polling facilities until the operation reaches a terminal state. -type HSMSecurityDomainDownloadPoller struct { +// HSMSecurityDomainClientDownloadPoller provides polling facilities until the operation reaches a terminal state. +type HSMSecurityDomainClientDownloadPoller struct { pt *azcore.Poller } // Done returns true if the LRO has reached a terminal state. -func (p *HSMSecurityDomainDownloadPoller) Done() bool { +func (p *HSMSecurityDomainClientDownloadPoller) Done() bool { return p.pt.Done() } @@ -34,18 +34,18 @@ func (p *HSMSecurityDomainDownloadPoller) Done() bool { // If Poll fails, the poller's state is unmodified and the error is returned. // Calling Poll on an LRO that has reached a terminal state will return the final // HTTP response or error. -func (p *HSMSecurityDomainDownloadPoller) Poll(ctx context.Context) (*http.Response, error) { +func (p *HSMSecurityDomainClientDownloadPoller) Poll(ctx context.Context) (*http.Response, error) { return p.pt.Poll(ctx) } // FinalResponse performs a final GET to the service and returns the final response // for the polling operation. If there is an error performing the final GET then an error is returned. -// If the final GET succeeded then the final HSMSecurityDomainDownloadResponse will be returned. -func (p *HSMSecurityDomainDownloadPoller) FinalResponse(ctx context.Context) (HSMSecurityDomainDownloadResponse, error) { - respType := HSMSecurityDomainDownloadResponse{} +// If the final GET succeeded then the final HSMSecurityDomainClientDownloadResponse will be returned. +func (p *HSMSecurityDomainClientDownloadPoller) FinalResponse(ctx context.Context) (HSMSecurityDomainClientDownloadResponse, error) { + respType := HSMSecurityDomainClientDownloadResponse{} resp, err := p.pt.FinalResponse(ctx, &respType.SecurityDomainObject) if err != nil { - return HSMSecurityDomainDownloadResponse{}, err + return HSMSecurityDomainClientDownloadResponse{}, err } respType.RawResponse = resp return respType, nil @@ -53,17 +53,17 @@ func (p *HSMSecurityDomainDownloadPoller) FinalResponse(ctx context.Context) (HS // ResumeToken returns a value representing the poller that can be used to resume // the LRO at a later time. ResumeTokens are unique per service operation. -func (p *HSMSecurityDomainDownloadPoller) ResumeToken() (string, error) { +func (p *HSMSecurityDomainClientDownloadPoller) ResumeToken() (string, error) { return p.pt.ResumeToken() } -// HSMSecurityDomainUploadPoller provides polling facilities until the operation reaches a terminal state. -type HSMSecurityDomainUploadPoller struct { +// HSMSecurityDomainClientUploadPoller provides polling facilities until the operation reaches a terminal state. +type HSMSecurityDomainClientUploadPoller struct { pt *azcore.Poller } // Done returns true if the LRO has reached a terminal state. -func (p *HSMSecurityDomainUploadPoller) Done() bool { +func (p *HSMSecurityDomainClientUploadPoller) Done() bool { return p.pt.Done() } @@ -77,18 +77,18 @@ func (p *HSMSecurityDomainUploadPoller) Done() bool { // If Poll fails, the poller's state is unmodified and the error is returned. // Calling Poll on an LRO that has reached a terminal state will return the final // HTTP response or error. -func (p *HSMSecurityDomainUploadPoller) Poll(ctx context.Context) (*http.Response, error) { +func (p *HSMSecurityDomainClientUploadPoller) Poll(ctx context.Context) (*http.Response, error) { return p.pt.Poll(ctx) } // FinalResponse performs a final GET to the service and returns the final response // for the polling operation. If there is an error performing the final GET then an error is returned. -// If the final GET succeeded then the final HSMSecurityDomainUploadResponse will be returned. -func (p *HSMSecurityDomainUploadPoller) FinalResponse(ctx context.Context) (HSMSecurityDomainUploadResponse, error) { - respType := HSMSecurityDomainUploadResponse{} +// If the final GET succeeded then the final HSMSecurityDomainClientUploadResponse will be returned. +func (p *HSMSecurityDomainClientUploadPoller) FinalResponse(ctx context.Context) (HSMSecurityDomainClientUploadResponse, error) { + respType := HSMSecurityDomainClientUploadResponse{} resp, err := p.pt.FinalResponse(ctx, &respType.SecurityDomainOperationStatus) if err != nil { - return HSMSecurityDomainUploadResponse{}, err + return HSMSecurityDomainClientUploadResponse{}, err } respType.RawResponse = resp return respType, nil @@ -96,6 +96,6 @@ func (p *HSMSecurityDomainUploadPoller) FinalResponse(ctx context.Context) (HSMS // ResumeToken returns a value representing the poller that can be used to resume // the LRO at a later time. ResumeTokens are unique per service operation. -func (p *HSMSecurityDomainUploadPoller) ResumeToken() (string, error) { +func (p *HSMSecurityDomainClientUploadPoller) ResumeToken() (string, error) { return p.pt.ResumeToken() } diff --git a/sdk/keyvault/azkeys/internal/generated/response_types.go b/sdk/keyvault/azkeys/internal/generated/response_types.go index 3d17dd362d14..8a23005e2f25 100644 --- a/sdk/keyvault/azkeys/internal/generated/response_types.go +++ b/sdk/keyvault/azkeys/internal/generated/response_types.go @@ -6,7 +6,7 @@ // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -package internal +package generated import ( "context" @@ -15,22 +15,22 @@ import ( "time" ) -// HSMSecurityDomainDownloadPendingResponse contains the response from method HSMSecurityDomain.DownloadPending. -type HSMSecurityDomainDownloadPendingResponse struct { - HSMSecurityDomainDownloadPendingResult +// HSMSecurityDomainClientDownloadPendingResponse contains the response from method HSMSecurityDomainClient.DownloadPending. +type HSMSecurityDomainClientDownloadPendingResponse struct { + HSMSecurityDomainClientDownloadPendingResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// HSMSecurityDomainDownloadPendingResult contains the result from method HSMSecurityDomain.DownloadPending. -type HSMSecurityDomainDownloadPendingResult struct { +// HSMSecurityDomainClientDownloadPendingResult contains the result from method HSMSecurityDomainClient.DownloadPending. +type HSMSecurityDomainClientDownloadPendingResult struct { SecurityDomainOperationStatus } -// HSMSecurityDomainDownloadPollerResponse contains the response from method HSMSecurityDomain.Download. -type HSMSecurityDomainDownloadPollerResponse struct { +// HSMSecurityDomainClientDownloadPollerResponse contains the response from method HSMSecurityDomainClient.Download. +type HSMSecurityDomainClientDownloadPollerResponse struct { // Poller contains an initialized poller. - Poller *HSMSecurityDomainDownloadPoller + Poller *HSMSecurityDomainClientDownloadPoller // RawResponse contains the underlying HTTP response. RawResponse *http.Response @@ -38,8 +38,8 @@ type HSMSecurityDomainDownloadPollerResponse struct { // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. // freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. -func (l HSMSecurityDomainDownloadPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (HSMSecurityDomainDownloadResponse, error) { - respType := HSMSecurityDomainDownloadResponse{} +func (l HSMSecurityDomainClientDownloadPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (HSMSecurityDomainClientDownloadResponse, error) { + respType := HSMSecurityDomainClientDownloadResponse{} resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.SecurityDomainObject) if err != nil { return respType, err @@ -48,13 +48,13 @@ func (l HSMSecurityDomainDownloadPollerResponse) PollUntilDone(ctx context.Conte return respType, nil } -// Resume rehydrates a HSMSecurityDomainDownloadPollerResponse from the provided client and resume token. -func (l *HSMSecurityDomainDownloadPollerResponse) Resume(ctx context.Context, client *HSMSecurityDomainClient, token string) error { - pt, err := runtime.NewPollerFromResumeToken("HSMSecurityDomainClient.Download", token, client.con.Pipeline(), client.downloadHandleError) +// Resume rehydrates a HSMSecurityDomainClientDownloadPollerResponse from the provided client and resume token. +func (l *HSMSecurityDomainClientDownloadPollerResponse) Resume(ctx context.Context, client *HSMSecurityDomainClient, token string) error { + pt, err := runtime.NewPollerFromResumeToken("HSMSecurityDomainClient.Download", token, client.pl) if err != nil { return err } - poller := &HSMSecurityDomainDownloadPoller{ + poller := &HSMSecurityDomainClientDownloadPoller{ pt: pt, } resp, err := poller.Poll(ctx) @@ -66,46 +66,46 @@ func (l *HSMSecurityDomainDownloadPollerResponse) Resume(ctx context.Context, cl return nil } -// HSMSecurityDomainDownloadResponse contains the response from method HSMSecurityDomain.Download. -type HSMSecurityDomainDownloadResponse struct { - HSMSecurityDomainDownloadResult +// HSMSecurityDomainClientDownloadResponse contains the response from method HSMSecurityDomainClient.Download. +type HSMSecurityDomainClientDownloadResponse struct { + HSMSecurityDomainClientDownloadResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// HSMSecurityDomainDownloadResult contains the result from method HSMSecurityDomain.Download. -type HSMSecurityDomainDownloadResult struct { +// HSMSecurityDomainClientDownloadResult contains the result from method HSMSecurityDomainClient.Download. +type HSMSecurityDomainClientDownloadResult struct { SecurityDomainObject } -// HSMSecurityDomainTransferKeyResponse contains the response from method HSMSecurityDomain.TransferKey. -type HSMSecurityDomainTransferKeyResponse struct { - HSMSecurityDomainTransferKeyResult +// HSMSecurityDomainClientTransferKeyResponse contains the response from method HSMSecurityDomainClient.TransferKey. +type HSMSecurityDomainClientTransferKeyResponse struct { + HSMSecurityDomainClientTransferKeyResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// HSMSecurityDomainTransferKeyResult contains the result from method HSMSecurityDomain.TransferKey. -type HSMSecurityDomainTransferKeyResult struct { +// HSMSecurityDomainClientTransferKeyResult contains the result from method HSMSecurityDomainClient.TransferKey. +type HSMSecurityDomainClientTransferKeyResult struct { TransferKey } -// HSMSecurityDomainUploadPendingResponse contains the response from method HSMSecurityDomain.UploadPending. -type HSMSecurityDomainUploadPendingResponse struct { - HSMSecurityDomainUploadPendingResult +// HSMSecurityDomainClientUploadPendingResponse contains the response from method HSMSecurityDomainClient.UploadPending. +type HSMSecurityDomainClientUploadPendingResponse struct { + HSMSecurityDomainClientUploadPendingResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// HSMSecurityDomainUploadPendingResult contains the result from method HSMSecurityDomain.UploadPending. -type HSMSecurityDomainUploadPendingResult struct { +// HSMSecurityDomainClientUploadPendingResult contains the result from method HSMSecurityDomainClient.UploadPending. +type HSMSecurityDomainClientUploadPendingResult struct { SecurityDomainOperationStatus } -// HSMSecurityDomainUploadPollerResponse contains the response from method HSMSecurityDomain.Upload. -type HSMSecurityDomainUploadPollerResponse struct { +// HSMSecurityDomainClientUploadPollerResponse contains the response from method HSMSecurityDomainClient.Upload. +type HSMSecurityDomainClientUploadPollerResponse struct { // Poller contains an initialized poller. - Poller *HSMSecurityDomainUploadPoller + Poller *HSMSecurityDomainClientUploadPoller // RawResponse contains the underlying HTTP response. RawResponse *http.Response @@ -113,8 +113,8 @@ type HSMSecurityDomainUploadPollerResponse struct { // PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. // freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. -func (l HSMSecurityDomainUploadPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (HSMSecurityDomainUploadResponse, error) { - respType := HSMSecurityDomainUploadResponse{} +func (l HSMSecurityDomainClientUploadPollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (HSMSecurityDomainClientUploadResponse, error) { + respType := HSMSecurityDomainClientUploadResponse{} resp, err := l.Poller.pt.PollUntilDone(ctx, freq, &respType.SecurityDomainOperationStatus) if err != nil { return respType, err @@ -123,13 +123,13 @@ func (l HSMSecurityDomainUploadPollerResponse) PollUntilDone(ctx context.Context return respType, nil } -// Resume rehydrates a HSMSecurityDomainUploadPollerResponse from the provided client and resume token. -func (l *HSMSecurityDomainUploadPollerResponse) Resume(ctx context.Context, client *HSMSecurityDomainClient, token string) error { - pt, err := runtime.NewPollerFromResumeToken("HSMSecurityDomainClient.Upload", token, client.con.Pipeline(), client.uploadHandleError) +// Resume rehydrates a HSMSecurityDomainClientUploadPollerResponse from the provided client and resume token. +func (l *HSMSecurityDomainClientUploadPollerResponse) Resume(ctx context.Context, client *HSMSecurityDomainClient, token string) error { + pt, err := runtime.NewPollerFromResumeToken("HSMSecurityDomainClient.Upload", token, client.pl) if err != nil { return err } - poller := &HSMSecurityDomainUploadPoller{ + poller := &HSMSecurityDomainClientUploadPoller{ pt: pt, } resp, err := poller.Poll(ctx) @@ -141,15 +141,15 @@ func (l *HSMSecurityDomainUploadPollerResponse) Resume(ctx context.Context, clie return nil } -// HSMSecurityDomainUploadResponse contains the response from method HSMSecurityDomain.Upload. -type HSMSecurityDomainUploadResponse struct { - HSMSecurityDomainUploadResult +// HSMSecurityDomainClientUploadResponse contains the response from method HSMSecurityDomainClient.Upload. +type HSMSecurityDomainClientUploadResponse struct { + HSMSecurityDomainClientUploadResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// HSMSecurityDomainUploadResult contains the result from method HSMSecurityDomain.Upload. -type HSMSecurityDomainUploadResult struct { +// HSMSecurityDomainClientUploadResult contains the result from method HSMSecurityDomainClient.Upload. +type HSMSecurityDomainClientUploadResult struct { SecurityDomainOperationStatus } @@ -447,98 +447,98 @@ type KeyVaultClientWrapKeyResult struct { KeyOperationResult } -// RoleAssignmentsCreateResponse contains the response from method RoleAssignments.Create. -type RoleAssignmentsCreateResponse struct { - RoleAssignmentsCreateResult +// RoleAssignmentsClientCreateResponse contains the response from method RoleAssignmentsClient.Create. +type RoleAssignmentsClientCreateResponse struct { + RoleAssignmentsClientCreateResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// RoleAssignmentsCreateResult contains the result from method RoleAssignments.Create. -type RoleAssignmentsCreateResult struct { +// RoleAssignmentsClientCreateResult contains the result from method RoleAssignmentsClient.Create. +type RoleAssignmentsClientCreateResult struct { RoleAssignment } -// RoleAssignmentsDeleteResponse contains the response from method RoleAssignments.Delete. -type RoleAssignmentsDeleteResponse struct { - RoleAssignmentsDeleteResult +// RoleAssignmentsClientDeleteResponse contains the response from method RoleAssignmentsClient.Delete. +type RoleAssignmentsClientDeleteResponse struct { + RoleAssignmentsClientDeleteResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// RoleAssignmentsDeleteResult contains the result from method RoleAssignments.Delete. -type RoleAssignmentsDeleteResult struct { +// RoleAssignmentsClientDeleteResult contains the result from method RoleAssignmentsClient.Delete. +type RoleAssignmentsClientDeleteResult struct { RoleAssignment } -// RoleAssignmentsGetResponse contains the response from method RoleAssignments.Get. -type RoleAssignmentsGetResponse struct { - RoleAssignmentsGetResult +// RoleAssignmentsClientGetResponse contains the response from method RoleAssignmentsClient.Get. +type RoleAssignmentsClientGetResponse struct { + RoleAssignmentsClientGetResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// RoleAssignmentsGetResult contains the result from method RoleAssignments.Get. -type RoleAssignmentsGetResult struct { +// RoleAssignmentsClientGetResult contains the result from method RoleAssignmentsClient.Get. +type RoleAssignmentsClientGetResult struct { RoleAssignment } -// RoleAssignmentsListForScopeResponse contains the response from method RoleAssignments.ListForScope. -type RoleAssignmentsListForScopeResponse struct { - RoleAssignmentsListForScopeResult +// RoleAssignmentsClientListForScopeResponse contains the response from method RoleAssignmentsClient.ListForScope. +type RoleAssignmentsClientListForScopeResponse struct { + RoleAssignmentsClientListForScopeResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// RoleAssignmentsListForScopeResult contains the result from method RoleAssignments.ListForScope. -type RoleAssignmentsListForScopeResult struct { +// RoleAssignmentsClientListForScopeResult contains the result from method RoleAssignmentsClient.ListForScope. +type RoleAssignmentsClientListForScopeResult struct { RoleAssignmentListResult } -// RoleDefinitionsCreateOrUpdateResponse contains the response from method RoleDefinitions.CreateOrUpdate. -type RoleDefinitionsCreateOrUpdateResponse struct { - RoleDefinitionsCreateOrUpdateResult +// RoleDefinitionsClientCreateOrUpdateResponse contains the response from method RoleDefinitionsClient.CreateOrUpdate. +type RoleDefinitionsClientCreateOrUpdateResponse struct { + RoleDefinitionsClientCreateOrUpdateResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// RoleDefinitionsCreateOrUpdateResult contains the result from method RoleDefinitions.CreateOrUpdate. -type RoleDefinitionsCreateOrUpdateResult struct { +// RoleDefinitionsClientCreateOrUpdateResult contains the result from method RoleDefinitionsClient.CreateOrUpdate. +type RoleDefinitionsClientCreateOrUpdateResult struct { RoleDefinition } -// RoleDefinitionsDeleteResponse contains the response from method RoleDefinitions.Delete. -type RoleDefinitionsDeleteResponse struct { - RoleDefinitionsDeleteResult +// RoleDefinitionsClientDeleteResponse contains the response from method RoleDefinitionsClient.Delete. +type RoleDefinitionsClientDeleteResponse struct { + RoleDefinitionsClientDeleteResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// RoleDefinitionsDeleteResult contains the result from method RoleDefinitions.Delete. -type RoleDefinitionsDeleteResult struct { +// RoleDefinitionsClientDeleteResult contains the result from method RoleDefinitionsClient.Delete. +type RoleDefinitionsClientDeleteResult struct { RoleDefinition } -// RoleDefinitionsGetResponse contains the response from method RoleDefinitions.Get. -type RoleDefinitionsGetResponse struct { - RoleDefinitionsGetResult +// RoleDefinitionsClientGetResponse contains the response from method RoleDefinitionsClient.Get. +type RoleDefinitionsClientGetResponse struct { + RoleDefinitionsClientGetResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// RoleDefinitionsGetResult contains the result from method RoleDefinitions.Get. -type RoleDefinitionsGetResult struct { +// RoleDefinitionsClientGetResult contains the result from method RoleDefinitionsClient.Get. +type RoleDefinitionsClientGetResult struct { RoleDefinition } -// RoleDefinitionsListResponse contains the response from method RoleDefinitions.List. -type RoleDefinitionsListResponse struct { - RoleDefinitionsListResult +// RoleDefinitionsClientListResponse contains the response from method RoleDefinitionsClient.List. +type RoleDefinitionsClientListResponse struct { + RoleDefinitionsClientListResult // RawResponse contains the underlying HTTP response. RawResponse *http.Response } -// RoleDefinitionsListResult contains the result from method RoleDefinitions.List. -type RoleDefinitionsListResult struct { +// RoleDefinitionsClientListResult contains the result from method RoleDefinitionsClient.List. +type RoleDefinitionsClientListResult struct { RoleDefinitionListResult } diff --git a/sdk/keyvault/azkeys/internal/generated/roleassignments_client.go b/sdk/keyvault/azkeys/internal/generated/roleassignments_client.go index ed815e45f398..a11abecccd4d 100644 --- a/sdk/keyvault/azkeys/internal/generated/roleassignments_client.go +++ b/sdk/keyvault/azkeys/internal/generated/roleassignments_client.go @@ -6,12 +6,11 @@ // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -package internal +package generated import ( "context" "errors" - "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,39 +21,45 @@ import ( // RoleAssignmentsClient contains the methods for the RoleAssignments group. // Don't use this type directly, use NewRoleAssignmentsClient() instead. type RoleAssignmentsClient struct { - con *Connection + pl runtime.Pipeline } // NewRoleAssignmentsClient creates a new instance of RoleAssignmentsClient with the specified values. -func NewRoleAssignmentsClient(con *Connection) *RoleAssignmentsClient { - return &RoleAssignmentsClient{con: con} +// pl - the pipeline used for sending requests and handling responses. +func NewRoleAssignmentsClient(pl runtime.Pipeline) *RoleAssignmentsClient { + client := &RoleAssignmentsClient{ + pl: pl, + } + return client } // Create - Creates a role assignment. -// If the operation fails it returns the *KeyVaultError error type. -func (client *RoleAssignmentsClient) Create(ctx context.Context, vaultBaseURL string, scope string, roleAssignmentName string, parameters RoleAssignmentCreateParameters, options *RoleAssignmentsCreateOptions) (RoleAssignmentsCreateResponse, error) { +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// scope - The scope of the role assignment to create. +// roleAssignmentName - The name of the role assignment to create. It can be any valid GUID. +// parameters - Parameters for the role assignment. +// options - RoleAssignmentsClientCreateOptions contains the optional parameters for the RoleAssignmentsClient.Create method. +func (client *RoleAssignmentsClient) Create(ctx context.Context, vaultBaseURL string, scope string, roleAssignmentName string, parameters RoleAssignmentCreateParameters, options *RoleAssignmentsClientCreateOptions) (RoleAssignmentsClientCreateResponse, error) { req, err := client.createCreateRequest(ctx, vaultBaseURL, scope, roleAssignmentName, parameters, options) if err != nil { - return RoleAssignmentsCreateResponse{}, err + return RoleAssignmentsClientCreateResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return RoleAssignmentsCreateResponse{}, err + return RoleAssignmentsClientCreateResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return RoleAssignmentsCreateResponse{}, client.createHandleError(resp) + return RoleAssignmentsClientCreateResponse{}, runtime.NewResponseError(resp) } return client.createHandleResponse(resp) } // createCreateRequest creates the Create request. -func (client *RoleAssignmentsClient) createCreateRequest(ctx context.Context, vaultBaseURL string, scope string, roleAssignmentName string, parameters RoleAssignmentCreateParameters, options *RoleAssignmentsCreateOptions) (*policy.Request, error) { +func (client *RoleAssignmentsClient) createCreateRequest(ctx context.Context, vaultBaseURL string, scope string, roleAssignmentName string, parameters RoleAssignmentCreateParameters, options *RoleAssignmentsClientCreateOptions) (*policy.Request, error) { host := "{vaultBaseUrl}" host = strings.ReplaceAll(host, "{vaultBaseUrl}", vaultBaseURL) urlPath := "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}" - if scope == "" { - return nil, errors.New("parameter scope cannot be empty") - } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if roleAssignmentName == "" { return nil, errors.New("parameter roleAssignmentName cannot be empty") @@ -72,52 +77,40 @@ func (client *RoleAssignmentsClient) createCreateRequest(ctx context.Context, va } // createHandleResponse handles the Create response. -func (client *RoleAssignmentsClient) createHandleResponse(resp *http.Response) (RoleAssignmentsCreateResponse, error) { - result := RoleAssignmentsCreateResponse{RawResponse: resp} +func (client *RoleAssignmentsClient) createHandleResponse(resp *http.Response) (RoleAssignmentsClientCreateResponse, error) { + result := RoleAssignmentsClientCreateResponse{RawResponse: resp} if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignment); err != nil { - return RoleAssignmentsCreateResponse{}, err + return RoleAssignmentsClientCreateResponse{}, err } return result, nil } -// createHandleError handles the Create error response. -func (client *RoleAssignmentsClient) createHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Delete - Deletes a role assignment. -// If the operation fails it returns the *KeyVaultError error type. -func (client *RoleAssignmentsClient) Delete(ctx context.Context, vaultBaseURL string, scope string, roleAssignmentName string, options *RoleAssignmentsDeleteOptions) (RoleAssignmentsDeleteResponse, error) { +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// scope - The scope of the role assignment to delete. +// roleAssignmentName - The name of the role assignment to delete. +// options - RoleAssignmentsClientDeleteOptions contains the optional parameters for the RoleAssignmentsClient.Delete method. +func (client *RoleAssignmentsClient) Delete(ctx context.Context, vaultBaseURL string, scope string, roleAssignmentName string, options *RoleAssignmentsClientDeleteOptions) (RoleAssignmentsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, vaultBaseURL, scope, roleAssignmentName, options) if err != nil { - return RoleAssignmentsDeleteResponse{}, err + return RoleAssignmentsClientDeleteResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return RoleAssignmentsDeleteResponse{}, err + return RoleAssignmentsClientDeleteResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return RoleAssignmentsDeleteResponse{}, client.deleteHandleError(resp) + return RoleAssignmentsClientDeleteResponse{}, runtime.NewResponseError(resp) } return client.deleteHandleResponse(resp) } // deleteCreateRequest creates the Delete request. -func (client *RoleAssignmentsClient) deleteCreateRequest(ctx context.Context, vaultBaseURL string, scope string, roleAssignmentName string, options *RoleAssignmentsDeleteOptions) (*policy.Request, error) { +func (client *RoleAssignmentsClient) deleteCreateRequest(ctx context.Context, vaultBaseURL string, scope string, roleAssignmentName string, options *RoleAssignmentsClientDeleteOptions) (*policy.Request, error) { host := "{vaultBaseUrl}" host = strings.ReplaceAll(host, "{vaultBaseUrl}", vaultBaseURL) urlPath := "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}" - if scope == "" { - return nil, errors.New("parameter scope cannot be empty") - } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if roleAssignmentName == "" { return nil, errors.New("parameter roleAssignmentName cannot be empty") @@ -135,52 +128,40 @@ func (client *RoleAssignmentsClient) deleteCreateRequest(ctx context.Context, va } // deleteHandleResponse handles the Delete response. -func (client *RoleAssignmentsClient) deleteHandleResponse(resp *http.Response) (RoleAssignmentsDeleteResponse, error) { - result := RoleAssignmentsDeleteResponse{RawResponse: resp} +func (client *RoleAssignmentsClient) deleteHandleResponse(resp *http.Response) (RoleAssignmentsClientDeleteResponse, error) { + result := RoleAssignmentsClientDeleteResponse{RawResponse: resp} if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignment); err != nil { - return RoleAssignmentsDeleteResponse{}, err + return RoleAssignmentsClientDeleteResponse{}, err } return result, nil } -// deleteHandleError handles the Delete error response. -func (client *RoleAssignmentsClient) deleteHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Get - Get the specified role assignment. -// If the operation fails it returns the *KeyVaultError error type. -func (client *RoleAssignmentsClient) Get(ctx context.Context, vaultBaseURL string, scope string, roleAssignmentName string, options *RoleAssignmentsGetOptions) (RoleAssignmentsGetResponse, error) { +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// scope - The scope of the role assignment. +// roleAssignmentName - The name of the role assignment to get. +// options - RoleAssignmentsClientGetOptions contains the optional parameters for the RoleAssignmentsClient.Get method. +func (client *RoleAssignmentsClient) Get(ctx context.Context, vaultBaseURL string, scope string, roleAssignmentName string, options *RoleAssignmentsClientGetOptions) (RoleAssignmentsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, vaultBaseURL, scope, roleAssignmentName, options) if err != nil { - return RoleAssignmentsGetResponse{}, err + return RoleAssignmentsClientGetResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return RoleAssignmentsGetResponse{}, err + return RoleAssignmentsClientGetResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return RoleAssignmentsGetResponse{}, client.getHandleError(resp) + return RoleAssignmentsClientGetResponse{}, runtime.NewResponseError(resp) } return client.getHandleResponse(resp) } // getCreateRequest creates the Get request. -func (client *RoleAssignmentsClient) getCreateRequest(ctx context.Context, vaultBaseURL string, scope string, roleAssignmentName string, options *RoleAssignmentsGetOptions) (*policy.Request, error) { +func (client *RoleAssignmentsClient) getCreateRequest(ctx context.Context, vaultBaseURL string, scope string, roleAssignmentName string, options *RoleAssignmentsClientGetOptions) (*policy.Request, error) { host := "{vaultBaseUrl}" host = strings.ReplaceAll(host, "{vaultBaseUrl}", vaultBaseURL) urlPath := "/{scope}/providers/Microsoft.Authorization/roleAssignments/{roleAssignmentName}" - if scope == "" { - return nil, errors.New("parameter scope cannot be empty") - } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if roleAssignmentName == "" { return nil, errors.New("parameter roleAssignmentName cannot be empty") @@ -198,49 +179,37 @@ func (client *RoleAssignmentsClient) getCreateRequest(ctx context.Context, vault } // getHandleResponse handles the Get response. -func (client *RoleAssignmentsClient) getHandleResponse(resp *http.Response) (RoleAssignmentsGetResponse, error) { - result := RoleAssignmentsGetResponse{RawResponse: resp} +func (client *RoleAssignmentsClient) getHandleResponse(resp *http.Response) (RoleAssignmentsClientGetResponse, error) { + result := RoleAssignmentsClientGetResponse{RawResponse: resp} if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignment); err != nil { - return RoleAssignmentsGetResponse{}, err + return RoleAssignmentsClientGetResponse{}, err } return result, nil } -// getHandleError handles the Get error response. -func (client *RoleAssignmentsClient) getHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // ListForScope - Gets role assignments for a scope. -// If the operation fails it returns the *KeyVaultError error type. -func (client *RoleAssignmentsClient) ListForScope(vaultBaseURL string, scope string, options *RoleAssignmentsListForScopeOptions) *RoleAssignmentsListForScopePager { - return &RoleAssignmentsListForScopePager{ +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// scope - The scope of the role assignments. +// options - RoleAssignmentsClientListForScopeOptions contains the optional parameters for the RoleAssignmentsClient.ListForScope +// method. +func (client *RoleAssignmentsClient) ListForScope(vaultBaseURL string, scope string, options *RoleAssignmentsClientListForScopeOptions) *RoleAssignmentsClientListForScopePager { + return &RoleAssignmentsClientListForScopePager{ client: client, requester: func(ctx context.Context) (*policy.Request, error) { return client.listForScopeCreateRequest(ctx, vaultBaseURL, scope, options) }, - advancer: func(ctx context.Context, resp RoleAssignmentsListForScopeResponse) (*policy.Request, error) { + advancer: func(ctx context.Context, resp RoleAssignmentsClientListForScopeResponse) (*policy.Request, error) { return runtime.NewRequest(ctx, http.MethodGet, *resp.RoleAssignmentListResult.NextLink) }, } } // listForScopeCreateRequest creates the ListForScope request. -func (client *RoleAssignmentsClient) listForScopeCreateRequest(ctx context.Context, vaultBaseURL string, scope string, options *RoleAssignmentsListForScopeOptions) (*policy.Request, error) { +func (client *RoleAssignmentsClient) listForScopeCreateRequest(ctx context.Context, vaultBaseURL string, scope string, options *RoleAssignmentsClientListForScopeOptions) (*policy.Request, error) { host := "{vaultBaseUrl}" host = strings.ReplaceAll(host, "{vaultBaseUrl}", vaultBaseURL) urlPath := "/{scope}/providers/Microsoft.Authorization/roleAssignments" - if scope == "" { - return nil, errors.New("parameter scope cannot be empty") - } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(host, urlPath)) if err != nil { @@ -257,23 +226,10 @@ func (client *RoleAssignmentsClient) listForScopeCreateRequest(ctx context.Conte } // listForScopeHandleResponse handles the ListForScope response. -func (client *RoleAssignmentsClient) listForScopeHandleResponse(resp *http.Response) (RoleAssignmentsListForScopeResponse, error) { - result := RoleAssignmentsListForScopeResponse{RawResponse: resp} +func (client *RoleAssignmentsClient) listForScopeHandleResponse(resp *http.Response) (RoleAssignmentsClientListForScopeResponse, error) { + result := RoleAssignmentsClientListForScopeResponse{RawResponse: resp} if err := runtime.UnmarshalAsJSON(resp, &result.RoleAssignmentListResult); err != nil { - return RoleAssignmentsListForScopeResponse{}, err + return RoleAssignmentsClientListForScopeResponse{}, err } return result, nil } - -// listForScopeHandleError handles the ListForScope error response. -func (client *RoleAssignmentsClient) listForScopeHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} diff --git a/sdk/keyvault/azkeys/internal/generated/roledefinitions_client.go b/sdk/keyvault/azkeys/internal/generated/roledefinitions_client.go index 84b8d80a4ea4..244a6df95625 100644 --- a/sdk/keyvault/azkeys/internal/generated/roledefinitions_client.go +++ b/sdk/keyvault/azkeys/internal/generated/roledefinitions_client.go @@ -6,12 +6,11 @@ // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -package internal +package generated import ( "context" "errors" - "fmt" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -22,39 +21,46 @@ import ( // RoleDefinitionsClient contains the methods for the RoleDefinitions group. // Don't use this type directly, use NewRoleDefinitionsClient() instead. type RoleDefinitionsClient struct { - con *Connection + pl runtime.Pipeline } // NewRoleDefinitionsClient creates a new instance of RoleDefinitionsClient with the specified values. -func NewRoleDefinitionsClient(con *Connection) *RoleDefinitionsClient { - return &RoleDefinitionsClient{con: con} +// pl - the pipeline used for sending requests and handling responses. +func NewRoleDefinitionsClient(pl runtime.Pipeline) *RoleDefinitionsClient { + client := &RoleDefinitionsClient{ + pl: pl, + } + return client } // CreateOrUpdate - Creates or updates a custom role definition. -// If the operation fails it returns the *KeyVaultError error type. -func (client *RoleDefinitionsClient) CreateOrUpdate(ctx context.Context, vaultBaseURL string, scope string, roleDefinitionName string, parameters RoleDefinitionCreateParameters, options *RoleDefinitionsCreateOrUpdateOptions) (RoleDefinitionsCreateOrUpdateResponse, error) { +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// scope - The scope of the role definition to create or update. Managed HSM only supports '/'. +// roleDefinitionName - The name of the role definition to create or update. It can be any valid GUID. +// parameters - Parameters for the role definition. +// options - RoleDefinitionsClientCreateOrUpdateOptions contains the optional parameters for the RoleDefinitionsClient.CreateOrUpdate +// method. +func (client *RoleDefinitionsClient) CreateOrUpdate(ctx context.Context, vaultBaseURL string, scope string, roleDefinitionName string, parameters RoleDefinitionCreateParameters, options *RoleDefinitionsClientCreateOrUpdateOptions) (RoleDefinitionsClientCreateOrUpdateResponse, error) { req, err := client.createOrUpdateCreateRequest(ctx, vaultBaseURL, scope, roleDefinitionName, parameters, options) if err != nil { - return RoleDefinitionsCreateOrUpdateResponse{}, err + return RoleDefinitionsClientCreateOrUpdateResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return RoleDefinitionsCreateOrUpdateResponse{}, err + return RoleDefinitionsClientCreateOrUpdateResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusCreated) { - return RoleDefinitionsCreateOrUpdateResponse{}, client.createOrUpdateHandleError(resp) + return RoleDefinitionsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) } return client.createOrUpdateHandleResponse(resp) } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *RoleDefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, vaultBaseURL string, scope string, roleDefinitionName string, parameters RoleDefinitionCreateParameters, options *RoleDefinitionsCreateOrUpdateOptions) (*policy.Request, error) { +func (client *RoleDefinitionsClient) createOrUpdateCreateRequest(ctx context.Context, vaultBaseURL string, scope string, roleDefinitionName string, parameters RoleDefinitionCreateParameters, options *RoleDefinitionsClientCreateOrUpdateOptions) (*policy.Request, error) { host := "{vaultBaseUrl}" host = strings.ReplaceAll(host, "{vaultBaseUrl}", vaultBaseURL) urlPath := "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionName}" - if scope == "" { - return nil, errors.New("parameter scope cannot be empty") - } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if roleDefinitionName == "" { return nil, errors.New("parameter roleDefinitionName cannot be empty") @@ -72,52 +78,40 @@ func (client *RoleDefinitionsClient) createOrUpdateCreateRequest(ctx context.Con } // createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *RoleDefinitionsClient) createOrUpdateHandleResponse(resp *http.Response) (RoleDefinitionsCreateOrUpdateResponse, error) { - result := RoleDefinitionsCreateOrUpdateResponse{RawResponse: resp} +func (client *RoleDefinitionsClient) createOrUpdateHandleResponse(resp *http.Response) (RoleDefinitionsClientCreateOrUpdateResponse, error) { + result := RoleDefinitionsClientCreateOrUpdateResponse{RawResponse: resp} if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinition); err != nil { - return RoleDefinitionsCreateOrUpdateResponse{}, err + return RoleDefinitionsClientCreateOrUpdateResponse{}, err } return result, nil } -// createOrUpdateHandleError handles the CreateOrUpdate error response. -func (client *RoleDefinitionsClient) createOrUpdateHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Delete - Deletes a custom role definition. -// If the operation fails it returns the *KeyVaultError error type. -func (client *RoleDefinitionsClient) Delete(ctx context.Context, vaultBaseURL string, scope string, roleDefinitionName string, options *RoleDefinitionsDeleteOptions) (RoleDefinitionsDeleteResponse, error) { +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// scope - The scope of the role definition to delete. Managed HSM only supports '/'. +// roleDefinitionName - The name (GUID) of the role definition to delete. +// options - RoleDefinitionsClientDeleteOptions contains the optional parameters for the RoleDefinitionsClient.Delete method. +func (client *RoleDefinitionsClient) Delete(ctx context.Context, vaultBaseURL string, scope string, roleDefinitionName string, options *RoleDefinitionsClientDeleteOptions) (RoleDefinitionsClientDeleteResponse, error) { req, err := client.deleteCreateRequest(ctx, vaultBaseURL, scope, roleDefinitionName, options) if err != nil { - return RoleDefinitionsDeleteResponse{}, err + return RoleDefinitionsClientDeleteResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return RoleDefinitionsDeleteResponse{}, err + return RoleDefinitionsClientDeleteResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return RoleDefinitionsDeleteResponse{}, client.deleteHandleError(resp) + return RoleDefinitionsClientDeleteResponse{}, runtime.NewResponseError(resp) } return client.deleteHandleResponse(resp) } // deleteCreateRequest creates the Delete request. -func (client *RoleDefinitionsClient) deleteCreateRequest(ctx context.Context, vaultBaseURL string, scope string, roleDefinitionName string, options *RoleDefinitionsDeleteOptions) (*policy.Request, error) { +func (client *RoleDefinitionsClient) deleteCreateRequest(ctx context.Context, vaultBaseURL string, scope string, roleDefinitionName string, options *RoleDefinitionsClientDeleteOptions) (*policy.Request, error) { host := "{vaultBaseUrl}" host = strings.ReplaceAll(host, "{vaultBaseUrl}", vaultBaseURL) urlPath := "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionName}" - if scope == "" { - return nil, errors.New("parameter scope cannot be empty") - } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if roleDefinitionName == "" { return nil, errors.New("parameter roleDefinitionName cannot be empty") @@ -135,52 +129,40 @@ func (client *RoleDefinitionsClient) deleteCreateRequest(ctx context.Context, va } // deleteHandleResponse handles the Delete response. -func (client *RoleDefinitionsClient) deleteHandleResponse(resp *http.Response) (RoleDefinitionsDeleteResponse, error) { - result := RoleDefinitionsDeleteResponse{RawResponse: resp} +func (client *RoleDefinitionsClient) deleteHandleResponse(resp *http.Response) (RoleDefinitionsClientDeleteResponse, error) { + result := RoleDefinitionsClientDeleteResponse{RawResponse: resp} if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinition); err != nil { - return RoleDefinitionsDeleteResponse{}, err + return RoleDefinitionsClientDeleteResponse{}, err } return result, nil } -// deleteHandleError handles the Delete error response. -func (client *RoleDefinitionsClient) deleteHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // Get - Get the specified role definition. -// If the operation fails it returns the *KeyVaultError error type. -func (client *RoleDefinitionsClient) Get(ctx context.Context, vaultBaseURL string, scope string, roleDefinitionName string, options *RoleDefinitionsGetOptions) (RoleDefinitionsGetResponse, error) { +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// scope - The scope of the role definition to get. Managed HSM only supports '/'. +// roleDefinitionName - The name of the role definition to get. +// options - RoleDefinitionsClientGetOptions contains the optional parameters for the RoleDefinitionsClient.Get method. +func (client *RoleDefinitionsClient) Get(ctx context.Context, vaultBaseURL string, scope string, roleDefinitionName string, options *RoleDefinitionsClientGetOptions) (RoleDefinitionsClientGetResponse, error) { req, err := client.getCreateRequest(ctx, vaultBaseURL, scope, roleDefinitionName, options) if err != nil { - return RoleDefinitionsGetResponse{}, err + return RoleDefinitionsClientGetResponse{}, err } - resp, err := client.con.Pipeline().Do(req) + resp, err := client.pl.Do(req) if err != nil { - return RoleDefinitionsGetResponse{}, err + return RoleDefinitionsClientGetResponse{}, err } if !runtime.HasStatusCode(resp, http.StatusOK) { - return RoleDefinitionsGetResponse{}, client.getHandleError(resp) + return RoleDefinitionsClientGetResponse{}, runtime.NewResponseError(resp) } return client.getHandleResponse(resp) } // getCreateRequest creates the Get request. -func (client *RoleDefinitionsClient) getCreateRequest(ctx context.Context, vaultBaseURL string, scope string, roleDefinitionName string, options *RoleDefinitionsGetOptions) (*policy.Request, error) { +func (client *RoleDefinitionsClient) getCreateRequest(ctx context.Context, vaultBaseURL string, scope string, roleDefinitionName string, options *RoleDefinitionsClientGetOptions) (*policy.Request, error) { host := "{vaultBaseUrl}" host = strings.ReplaceAll(host, "{vaultBaseUrl}", vaultBaseURL) urlPath := "/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionName}" - if scope == "" { - return nil, errors.New("parameter scope cannot be empty") - } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) if roleDefinitionName == "" { return nil, errors.New("parameter roleDefinitionName cannot be empty") @@ -198,49 +180,36 @@ func (client *RoleDefinitionsClient) getCreateRequest(ctx context.Context, vault } // getHandleResponse handles the Get response. -func (client *RoleDefinitionsClient) getHandleResponse(resp *http.Response) (RoleDefinitionsGetResponse, error) { - result := RoleDefinitionsGetResponse{RawResponse: resp} +func (client *RoleDefinitionsClient) getHandleResponse(resp *http.Response) (RoleDefinitionsClientGetResponse, error) { + result := RoleDefinitionsClientGetResponse{RawResponse: resp} if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinition); err != nil { - return RoleDefinitionsGetResponse{}, err + return RoleDefinitionsClientGetResponse{}, err } return result, nil } -// getHandleError handles the Get error response. -func (client *RoleDefinitionsClient) getHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} - // List - Get all role definitions that are applicable at scope and above. -// If the operation fails it returns the *KeyVaultError error type. -func (client *RoleDefinitionsClient) List(vaultBaseURL string, scope string, options *RoleDefinitionsListOptions) *RoleDefinitionsListPager { - return &RoleDefinitionsListPager{ +// If the operation fails it returns an *azcore.ResponseError type. +// vaultBaseURL - The vault name, for example https://myvault.vault.azure.net. +// scope - The scope of the role definition. +// options - RoleDefinitionsClientListOptions contains the optional parameters for the RoleDefinitionsClient.List method. +func (client *RoleDefinitionsClient) List(vaultBaseURL string, scope string, options *RoleDefinitionsClientListOptions) *RoleDefinitionsClientListPager { + return &RoleDefinitionsClientListPager{ client: client, requester: func(ctx context.Context) (*policy.Request, error) { return client.listCreateRequest(ctx, vaultBaseURL, scope, options) }, - advancer: func(ctx context.Context, resp RoleDefinitionsListResponse) (*policy.Request, error) { + advancer: func(ctx context.Context, resp RoleDefinitionsClientListResponse) (*policy.Request, error) { return runtime.NewRequest(ctx, http.MethodGet, *resp.RoleDefinitionListResult.NextLink) }, } } // listCreateRequest creates the List request. -func (client *RoleDefinitionsClient) listCreateRequest(ctx context.Context, vaultBaseURL string, scope string, options *RoleDefinitionsListOptions) (*policy.Request, error) { +func (client *RoleDefinitionsClient) listCreateRequest(ctx context.Context, vaultBaseURL string, scope string, options *RoleDefinitionsClientListOptions) (*policy.Request, error) { host := "{vaultBaseUrl}" host = strings.ReplaceAll(host, "{vaultBaseUrl}", vaultBaseURL) urlPath := "/{scope}/providers/Microsoft.Authorization/roleDefinitions" - if scope == "" { - return nil, errors.New("parameter scope cannot be empty") - } urlPath = strings.ReplaceAll(urlPath, "{scope}", scope) req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(host, urlPath)) if err != nil { @@ -257,23 +226,10 @@ func (client *RoleDefinitionsClient) listCreateRequest(ctx context.Context, vaul } // listHandleResponse handles the List response. -func (client *RoleDefinitionsClient) listHandleResponse(resp *http.Response) (RoleDefinitionsListResponse, error) { - result := RoleDefinitionsListResponse{RawResponse: resp} +func (client *RoleDefinitionsClient) listHandleResponse(resp *http.Response) (RoleDefinitionsClientListResponse, error) { + result := RoleDefinitionsClientListResponse{RawResponse: resp} if err := runtime.UnmarshalAsJSON(resp, &result.RoleDefinitionListResult); err != nil { - return RoleDefinitionsListResponse{}, err + return RoleDefinitionsClientListResponse{}, err } return result, nil } - -// listHandleError handles the List error response. -func (client *RoleDefinitionsClient) listHandleError(resp *http.Response) error { - body, err := runtime.Payload(resp) - if err != nil { - return runtime.NewResponseError(err, resp) - } - errType := KeyVaultError{raw: string(body)} - if err := runtime.UnmarshalAsJSON(resp, &errType); err != nil { - return runtime.NewResponseError(fmt.Errorf("%s\n%s", string(body), err), resp) - } - return runtime.NewResponseError(&errType, resp) -} diff --git a/sdk/keyvault/azkeys/internal/generated/time_unix.go b/sdk/keyvault/azkeys/internal/generated/time_unix.go index 1259dd37d4d9..ef296335710b 100644 --- a/sdk/keyvault/azkeys/internal/generated/time_unix.go +++ b/sdk/keyvault/azkeys/internal/generated/time_unix.go @@ -6,7 +6,7 @@ // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -package internal +package generated import ( "encoding/json" diff --git a/sdk/keyvault/azkeys/models.go b/sdk/keyvault/azkeys/models.go index 3511e45cedbc..745be488cf7e 100644 --- a/sdk/keyvault/azkeys/models.go +++ b/sdk/keyvault/azkeys/models.go @@ -9,7 +9,7 @@ package azkeys import ( "time" - generated "github.com/Azure/azure-sdk-for-go/sdk/keyvault/azkeys/internal/generated" + "github.com/Azure/azure-sdk-for-go/sdk/keyvault/azkeys/internal/generated" ) // Attributes - The object attributes managed by the KeyVault service. @@ -47,13 +47,11 @@ func (k KeyAttributes) toGenerated() *generated.KeyAttributes { return &generated.KeyAttributes{ RecoverableDays: k.RecoverableDays, RecoveryLevel: recoveryLevelToGenerated(k.RecoveryLevel), - Attributes: generated.Attributes{ - Enabled: k.Enabled, - Expires: k.Expires, - NotBefore: k.NotBefore, - Created: k.Created, - Updated: k.Updated, - }, + Enabled: k.Enabled, + Expires: k.Expires, + NotBefore: k.NotBefore, + Created: k.Created, + Updated: k.Updated, } } @@ -284,7 +282,22 @@ func deletedKeyItemFromGenerated(i *generated.DeletedKeyItem) *DeletedKeyItem { RecoveryID: i.RecoveryID, DeletedDate: i.DeletedDate, ScheduledPurgeDate: i.ScheduledPurgeDate, - KeyItem: *keyItemFromGenerated(&i.KeyItem), + KeyItem: KeyItem{ + Attributes: &KeyAttributes{ + Attributes: Attributes{ + Enabled: i.Attributes.Enabled, + Expires: i.Attributes.Expires, + NotBefore: i.Attributes.NotBefore, + Created: i.Attributes.Created, + Updated: i.Attributes.Updated, + }, + RecoverableDays: i.Attributes.RecoverableDays, + RecoveryLevel: (*DeletionRecoveryLevel)(i.Attributes.RecoveryLevel), + }, + KID: i.Kid, + Tags: i.Tags, + Managed: i.Managed, + }, } }