Skip to content

Commit

Permalink
add update function for account client (#7705)
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinForReal authored Dec 2, 2024
1 parent 9ed29c2 commit 272b958
Show file tree
Hide file tree
Showing 4 changed files with 171 additions and 16 deletions.
11 changes: 11 additions & 0 deletions pkg/azclient/accountclient/custom.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,17 @@ func (client *Client) Create(ctx context.Context, resourceGroupName string, reso
return nil, nil
}

func (client *Client) Update(ctx context.Context, resourceGroupName string, resourceName string, parameters *armstorage.AccountUpdateParameters) (*armstorage.Account, error) {
if parameters == nil {
parameters = &armstorage.AccountUpdateParameters{}
}
resp, err := client.AccountsClient.Update(ctx, resourceGroupName, resourceName, *parameters, nil)
if err != nil {
return nil, err
}
return &resp.Account, nil
}

func (client *Client) GetProperties(ctx context.Context, resourceGroupName string, accountName string, options *armstorage.AccountsClientGetPropertiesOptions) (*armstorage.Account, error) {
resp, err := client.AccountsClient.GetProperties(ctx, resourceGroupName, accountName, options)
if err != nil {
Expand Down
17 changes: 17 additions & 0 deletions pkg/azclient/accountclient/custom_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pkg/azclient/accountclient/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
type Interface interface {
utils.ListFunc[armstorage.Account]
Create(ctx context.Context, resourceGroupName string, accountName string, resource *armstorage.AccountCreateParameters) (*armstorage.Account, error)
Update(ctx context.Context, resourceGroupName string, accountName string, parameters *armstorage.AccountUpdateParameters) (*armstorage.Account, error)
GetProperties(ctx context.Context, resourceGroupName string, accountName string, options *armstorage.AccountsClientGetPropertiesOptions) (*armstorage.Account, error)
Delete(ctx context.Context, resourceGroupName string, accountName string) error
ListKeys(ctx context.Context, resourceGroupName string, accountName string) ([]*armstorage.AccountKey, error)
Expand Down
158 changes: 142 additions & 16 deletions pkg/azclient/accountclient/testdata/Account.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interactions:
Content-Type:
- application/json
User-Agent:
- ccm-resource-group-clien azsdk-go-armresources/v1.2.0 (go1.23.1; linux)
- ccm-resource-group-clien azsdk-go-armresources/v1.2.0 (go1.23.2; linux)
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/aks-cit-Account?api-version=2021-04-01
method: PUT
response:
Expand Down Expand Up @@ -51,6 +51,8 @@ interactions:
- CONFIG_NOCACHE
X-Content-Type-Options:
- nosniff
X-Ms-Ratelimit-Remaining-Subscription-Global-Writes:
- "11999"
status: 201 Created
code: 201
duration: 200ms
Expand All @@ -75,7 +77,7 @@ interactions:
Content-Type:
- application/json
User-Agent:
- ccm-Account-client azsdk-go-armstorage/v1.6.0 (go1.23.1; linux)
- ccm-Account-client azsdk-go-armstorage/v1.6.0 (go1.23.2; linux)
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-Account/providers/Microsoft.Storage/storageAccounts/akscitaccountsdktest?api-version=2023-05-01
method: PUT
response:
Expand Down Expand Up @@ -106,6 +108,8 @@ interactions:
- CONFIG_NOCACHE
X-Content-Type-Options:
- nosniff
X-Ms-Ratelimit-Remaining-Subscription-Global-Writes:
- "12000"
status: 202 Accepted
code: 202
duration: 200ms
Expand All @@ -124,7 +128,7 @@ interactions:
form: {}
headers:
User-Agent:
- ccm-Account-client azsdk-go-armstorage/v1.6.0 (go1.23.1; linux)
- ccm-Account-client azsdk-go-armstorage/v1.6.0 (go1.23.2; linux)
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Storage/locations/eastus/asyncoperations/00000000-0000-0000-0000-000000000000?api-version=2023-05-01&c=c&h=h&monitor=true&s=s&t=t
method: GET
response:
Expand Down Expand Up @@ -153,6 +157,8 @@ interactions:
- CONFIG_NOCACHE
X-Content-Type-Options:
- nosniff
X-Ms-Ratelimit-Remaining-Subscription-Global-Reads:
- "16499"
status: 200 OK
code: 200
duration: 200ms
Expand All @@ -173,7 +179,7 @@ interactions:
Accept:
- application/json
User-Agent:
- ccm-Account-client azsdk-go-armstorage/v1.6.0 (go1.23.1; linux)
- ccm-Account-client azsdk-go-armstorage/v1.6.0 (go1.23.2; linux)
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-Account/providers/Microsoft.Storage/storageAccounts/akscitaccountsdktest?api-version=2023-05-01
method: GET
response:
Expand Down Expand Up @@ -202,6 +208,8 @@ interactions:
- CONFIG_NOCACHE
X-Content-Type-Options:
- nosniff
X-Ms-Ratelimit-Remaining-Subscription-Global-Reads:
- "16499"
status: 200 OK
code: 200
duration: 200ms
Expand All @@ -222,7 +230,7 @@ interactions:
Accept:
- application/json
User-Agent:
- ccm-Account-client azsdk-go-armstorage/v1.6.0 (go1.23.1; linux)
- ccm-Account-client azsdk-go-armstorage/v1.6.0 (go1.23.2; linux)
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-Account/providers/Microsoft.Storage/storageAccounts/akscitaccountsdktestnotfound?api-version=2023-05-01
method: GET
response:
Expand Down Expand Up @@ -257,6 +265,116 @@ interactions:
code: 404
duration: 200ms
- id: 5
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 75
transfer_encoding: []
trailer: {}
host: management.azure.com
remote_addr: ""
request_uri: ""
body: '{"properties":{"allowBlobPublicAccess":false,"allowSharedKeyAccess":false}}'
form: {}
headers:
Accept:
- application/json
Content-Length:
- "75"
Content-Type:
- application/json
User-Agent:
- ccm-Account-client azsdk-go-armstorage/v1.6.0 (go1.23.2; linux)
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-Account/providers/Microsoft.Storage/storageAccounts/akscitaccountsdktest?api-version=2023-05-01
method: PATCH
response:
proto: HTTP/2.0
proto_major: 2
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: 1617
uncompressed: false
body: '{"sku":{"name":"Standard_GRS","tier":"Standard"},"kind":"Storage","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-Account/providers/Microsoft.Storage/storageAccounts/akscitaccountsdktest","name":"akscitaccountsdktest","type":"Microsoft.Storage/storageAccounts","location":"eastus","tags":{},"properties":{"defaultToOAuthAuthentication":false,"keyPolicy":{"keyExpirationPeriodInDays":20},"keyCreationTime":{"key1":"2001-02-03T04:05:06Z","key2":"2001-02-03T04:05:06Z"},"allowCrossTenantReplication":false,"privateEndpointConnections":[],"isSftpEnabled":false,"minimumTlsVersion":"TLS1_2","allowBlobPublicAccess":false,"allowSharedKeyAccess":false,"isHnsEnabled":false,"networkAcls":{"ipv6Rules":[],"bypass":"AzureServices","virtualNetworkRules":[],"ipRules":[],"defaultAction":"Allow"},"supportsHttpsTrafficOnly":true,"encryption":{"requireInfrastructureEncryption":false,"services":{"file":{"keyType":"Account","enabled":true,"lastEnabledTime":"2001-02-03T04:05:06Z"},"blob":{"keyType":"Account","enabled":true,"lastEnabledTime":"2001-02-03T04:05:06Z"}},"keySource":"Microsoft.Storage"},"provisioningState":"Succeeded","creationTime":"2001-02-03T04:05:06Z","primaryEndpoints":{"blob":"https://akscitaccountsdktest.blob.core.windows.net/","queue":"https://akscitaccountsdktest.queue.core.windows.net/","table":"https://akscitaccountsdktest.table.core.windows.net/","file":"https://akscitaccountsdktest.file.core.windows.net/"},"primaryLocation":"eastus","statusOfPrimary":"available","secondaryLocation":"westus","statusOfSecondary":"available"}}'
headers:
Cache-Control:
- no-cache
Content-Length:
- "1617"
Content-Type:
- application/json
Expires:
- "-1"
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Cache:
- CONFIG_NOCACHE
X-Content-Type-Options:
- nosniff
X-Ms-Ratelimit-Remaining-Subscription-Global-Writes:
- "11999"
status: 200 OK
code: 200
duration: 200ms
- id: 6
request:
proto: HTTP/1.1
proto_major: 1
proto_minor: 1
content_length: 2
transfer_encoding: []
trailer: {}
host: management.azure.com
remote_addr: ""
request_uri: ""
body: '{}'
form: {}
headers:
Accept:
- application/json
Content-Length:
- "2"
Content-Type:
- application/json
User-Agent:
- ccm-Account-client azsdk-go-armstorage/v1.6.0 (go1.23.2; linux)
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-Account/providers/Microsoft.Storage/storageAccounts/akscitaccountsdktest?api-version=2023-05-01
method: PATCH
response:
proto: HTTP/2.0
proto_major: 2
proto_minor: 0
transfer_encoding: []
trailer: {}
content_length: 1617
uncompressed: false
body: '{"sku":{"name":"Standard_GRS","tier":"Standard"},"kind":"Storage","id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-Account/providers/Microsoft.Storage/storageAccounts/akscitaccountsdktest","name":"akscitaccountsdktest","type":"Microsoft.Storage/storageAccounts","location":"eastus","tags":{},"properties":{"defaultToOAuthAuthentication":false,"keyPolicy":{"keyExpirationPeriodInDays":20},"keyCreationTime":{"key1":"2001-02-03T04:05:06Z","key2":"2001-02-03T04:05:06Z"},"allowCrossTenantReplication":false,"privateEndpointConnections":[],"isSftpEnabled":false,"minimumTlsVersion":"TLS1_2","allowBlobPublicAccess":false,"allowSharedKeyAccess":false,"isHnsEnabled":false,"networkAcls":{"ipv6Rules":[],"bypass":"AzureServices","virtualNetworkRules":[],"ipRules":[],"defaultAction":"Allow"},"supportsHttpsTrafficOnly":true,"encryption":{"requireInfrastructureEncryption":false,"services":{"file":{"keyType":"Account","enabled":true,"lastEnabledTime":"2001-02-03T04:05:06Z"},"blob":{"keyType":"Account","enabled":true,"lastEnabledTime":"2001-02-03T04:05:06Z"}},"keySource":"Microsoft.Storage"},"provisioningState":"Succeeded","creationTime":"2001-02-03T04:05:06Z","primaryEndpoints":{"blob":"https://akscitaccountsdktest.blob.core.windows.net/","queue":"https://akscitaccountsdktest.queue.core.windows.net/","table":"https://akscitaccountsdktest.table.core.windows.net/","file":"https://akscitaccountsdktest.file.core.windows.net/"},"primaryLocation":"eastus","statusOfPrimary":"available","secondaryLocation":"westus","statusOfSecondary":"available"}}'
headers:
Cache-Control:
- no-cache
Content-Length:
- "1617"
Content-Type:
- application/json
Expires:
- "-1"
Pragma:
- no-cache
Strict-Transport-Security:
- max-age=31536000; includeSubDomains
X-Cache:
- CONFIG_NOCACHE
X-Content-Type-Options:
- nosniff
X-Ms-Ratelimit-Remaining-Subscription-Global-Writes:
- "11999"
status: 200 OK
code: 200
duration: 200ms
- id: 7
request:
proto: HTTP/1.1
proto_major: 1
Expand All @@ -273,7 +391,7 @@ interactions:
Accept:
- application/json
User-Agent:
- ccm-Account-client azsdk-go-armstorage/v1.6.0 (go1.23.1; linux)
- ccm-Account-client azsdk-go-armstorage/v1.6.0 (go1.23.2; linux)
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-Account/providers/Microsoft.Storage/storageAccounts/akscitaccountsdktest/listKeys?api-version=2023-05-01
method: POST
response:
Expand Down Expand Up @@ -305,7 +423,7 @@ interactions:
status: 200 OK
code: 200
duration: 200ms
- id: 6
- id: 8
request:
proto: HTTP/1.1
proto_major: 1
Expand All @@ -322,7 +440,7 @@ interactions:
Accept:
- application/json
User-Agent:
- ccm-Account-client azsdk-go-armstorage/v1.6.0 (go1.23.1; linux)
- ccm-Account-client azsdk-go-armstorage/v1.6.0 (go1.23.2; linux)
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-Account/providers/Microsoft.Storage/storageAccounts?api-version=2023-05-01
method: GET
response:
Expand Down Expand Up @@ -351,10 +469,12 @@ interactions:
- CONFIG_NOCACHE
X-Content-Type-Options:
- nosniff
X-Ms-Ratelimit-Remaining-Subscription-Global-Reads:
- "16499"
status: 200 OK
code: 200
duration: 200ms
- id: 7
- id: 9
request:
proto: HTTP/1.1
proto_major: 1
Expand All @@ -371,7 +491,7 @@ interactions:
Accept:
- application/json
User-Agent:
- ccm-Account-client azsdk-go-armstorage/v1.6.0 (go1.23.1; linux)
- ccm-Account-client azsdk-go-armstorage/v1.6.0 (go1.23.2; linux)
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-Accountnotfound/providers/Microsoft.Storage/storageAccounts?api-version=2023-05-01
method: GET
response:
Expand Down Expand Up @@ -405,7 +525,7 @@ interactions:
status: 404 Not Found
code: 404
duration: 200ms
- id: 8
- id: 10
request:
proto: HTTP/1.1
proto_major: 1
Expand All @@ -420,7 +540,7 @@ interactions:
form: {}
headers:
User-Agent:
- ccm-Account-client azsdk-go-armstorage/v1.6.0 (go1.23.1; linux)
- ccm-Account-client azsdk-go-armstorage/v1.6.0 (go1.23.2; linux)
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/aks-cit-Account/providers/Microsoft.Storage/storageAccounts/akscitaccountsdktest?api-version=2023-05-01
method: DELETE
response:
Expand Down Expand Up @@ -449,10 +569,12 @@ interactions:
- CONFIG_NOCACHE
X-Content-Type-Options:
- nosniff
X-Ms-Ratelimit-Remaining-Subscription-Global-Deletes:
- "12000"
status: 200 OK
code: 200
duration: 200ms
- id: 9
- id: 11
request:
proto: HTTP/1.1
proto_major: 1
Expand All @@ -469,7 +591,7 @@ interactions:
Accept:
- application/json
User-Agent:
- ccm-resource-group-clien azsdk-go-armresources/v1.2.0 (go1.23.1; linux)
- ccm-resource-group-clien azsdk-go-armresources/v1.2.0 (go1.23.2; linux)
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/aks-cit-Account?api-version=2021-04-01
method: DELETE
response:
Expand Down Expand Up @@ -498,10 +620,12 @@ interactions:
- CONFIG_NOCACHE
X-Content-Type-Options:
- nosniff
X-Ms-Ratelimit-Remaining-Subscription-Global-Deletes:
- "12000"
status: 202 Accepted
code: 202
duration: 200ms
- id: 10
- id: 12
request:
proto: HTTP/1.1
proto_major: 1
Expand All @@ -516,7 +640,7 @@ interactions:
form: {}
headers:
User-Agent:
- ccm-resource-group-clien azsdk-go-armresources/v1.2.0 (go1.23.1; linux)
- ccm-resource-group-clien azsdk-go-armresources/v1.2.0 (go1.23.2; linux)
url: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/operationresults/eyJqb2JJZCI6IlJFU09VUkNFR1JPVVBERUxFVElPTkpPQi1BS1M6MkRDSVQ6MkRBQ0NPVU5ULUVBU1RVUyIsImpvYkxvY2F0aW9uIjoiZWFzdHVzIn0?api-version=2021-04-01&c=c&h=h&s=s&t=t
method: GET
response:
Expand All @@ -543,6 +667,8 @@ interactions:
- CONFIG_NOCACHE
X-Content-Type-Options:
- nosniff
X-Ms-Ratelimit-Remaining-Subscription-Global-Reads:
- "16499"
status: 200 OK
code: 200
duration: 200ms

0 comments on commit 272b958

Please sign in to comment.