From d59677ebd4098373d1732442f656969f4c02910c Mon Sep 17 00:00:00 2001 From: Rick Winter Date: Thu, 4 Jan 2024 09:46:39 -0800 Subject: [PATCH 01/32] Update package versions (#22201) * Update package versions * upgrade to MSAL v1.2.1 * add token_type to fake tokens * revert debugging --------- Co-authored-by: Charles Lowell <10964656+chlowell@users.noreply.github.com> --- sdk/azidentity/CHANGELOG.md | 1 + sdk/azidentity/azidentity_test.go | 2 +- sdk/azidentity/go.mod | 20 +++++++-------- sdk/azidentity/go.sum | 42 +++++++++++++++---------------- sdk/azidentity/go.work.sum | 5 ++++ sdk/azidentity/mock_test.go | 2 +- 6 files changed, 39 insertions(+), 33 deletions(-) diff --git a/sdk/azidentity/CHANGELOG.md b/sdk/azidentity/CHANGELOG.md index 06209c7bca8e..50352e6210b9 100644 --- a/sdk/azidentity/CHANGELOG.md +++ b/sdk/azidentity/CHANGELOG.md @@ -11,6 +11,7 @@ * `azidentity.doForClient` method no longer removes headers from the incoming request ### Other Changes +* Move to latest released versions of net, crypto, core, etc... ## 1.5.0-beta.2 (2023-11-07) diff --git a/sdk/azidentity/azidentity_test.go b/sdk/azidentity/azidentity_test.go index ea07cac60a80..5fa86a4605ff 100644 --- a/sdk/azidentity/azidentity_test.go +++ b/sdk/azidentity/azidentity_test.go @@ -46,7 +46,7 @@ const ( ) var ( - accessTokenRespSuccess = []byte(fmt.Sprintf(`{"access_token": "%s", "expires_in": %d}`, tokenValue, tokenExpiresIn)) + accessTokenRespSuccess = []byte(fmt.Sprintf(`{"access_token": "%s","expires_in": %d,"token_type":"Bearer"}`, tokenValue, tokenExpiresIn)) testTRO = policy.TokenRequestOptions{Scopes: []string{liveTestScope}} ) diff --git a/sdk/azidentity/go.mod b/sdk/azidentity/go.mod index 6230418edbb3..656d9c6f810a 100644 --- a/sdk/azidentity/go.mod +++ b/sdk/azidentity/go.mod @@ -3,14 +3,14 @@ module github.com/Azure/azure-sdk-for-go/sdk/azidentity go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.2.0 - github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 - github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 - github.com/golang-jwt/jwt/v5 v5.0.0 - github.com/google/uuid v1.3.1 + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 + github.com/golang-jwt/jwt/v5 v5.2.0 + github.com/google/uuid v1.5.0 github.com/stretchr/testify v1.8.4 - golang.org/x/crypto v0.14.0 + golang.org/x/crypto v0.17.0 ) require ( @@ -19,11 +19,11 @@ require ( github.com/dnaeon/go-vcr v1.2.0 // indirect github.com/keybase/go-keychain v0.0.0-20230523030712-b5615109f100 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/net v0.19.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/sdk/azidentity/go.sum b/sdk/azidentity/go.sum index 5160eeb04966..7d0a3bfbfcb9 100644 --- a/sdk/azidentity/go.sum +++ b/sdk/azidentity/go.sum @@ -1,21 +1,21 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 h1:lGlwhPtrX6EVml1hO0ivjkUxsSyl4dsiw9qcA1k/3IQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1/go.mod h1:RKUqNu35KJYcVG/fqTRqmuXJZYNhYkBrnC/hX7yGbTA= github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.2.0 h1:xZaKaIde2fNBQ6cvgvsdlMMeD4OTpLaOQ1UTVDXGicI= github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.2.0/go.mod h1:veBEHsnzafwWVNkJ71OdC2tqipKKauNabOxdoi05Mhk= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 h1:6oNBlSdi1QqM1PNW7FPA6xOGA5UNsXnkaYZz9vdPGhA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1/go.mod h1:tCcJZ0uHAmvjsVYzEFivsRTN00oz5BEsRgQHu5JZ9WE= -github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= -github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 h1:DzHpqpoJVaCgOUdVHxE8QB52S6NiVdDQvGlny1qvPqA= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= 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.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= -github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= -github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= -github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw= +github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= +github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/keybase/go-keychain v0.0.0-20230523030712-b5615109f100 h1:rG3VnJUnAWyiv7qYmmdOdSapzz6HM+zb9/uRFr0T5EM= github.com/keybase/go-keychain v0.0.0-20230523030712-b5615109f100/go.mod h1:qDHUvIjGZJUtdPtuP4WMu5/U4aVWbFw1MhlkJqCGmCQ= github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= @@ -23,21 +23,21 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 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-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= 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/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/sdk/azidentity/go.work.sum b/sdk/azidentity/go.work.sum index de25d73e270a..7cd86b0019e4 100644 --- a/sdk/azidentity/go.work.sum +++ b/sdk/azidentity/go.work.sum @@ -3,7 +3,10 @@ github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0-beta.1/go.mod h1:3Ug6Qzto9an github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 h1:DzHpqpoJVaCgOUdVHxE8QB52S6NiVdDQvGlny1qvPqA= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= @@ -15,6 +18,7 @@ github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc= +golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= @@ -28,6 +32,7 @@ golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/term v0.12.0/go.mod h1:owVbMEjm3cBLCHdkQu9b1opXd4ETQWc3BhuQGKgXgvU= golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.15.0/go.mod h1:BDl952bC7+uMoWR75FIrCDx79TPU9oHkTZ9yRbYOrX0= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/sdk/azidentity/mock_test.go b/sdk/azidentity/mock_test.go index cdc24761604c..2509f57778f1 100644 --- a/sdk/azidentity/mock_test.go +++ b/sdk/azidentity/mock_test.go @@ -53,7 +53,7 @@ func (m *mockSTS) Do(req *http.Request) (*http.Response, error) { if grant := req.FormValue("grant_type"); grant == "device_code" || grant == "password" { // include account info because we're authenticating a user res.Body = io.NopCloser(bytes.NewReader( - []byte(fmt.Sprintf(`{"access_token":"at","expires_in": 3600,"refresh_token":"rt","client_info":%q,"id_token":%q}`, mockClientInfo, mockIDT)), + []byte(fmt.Sprintf(`{"access_token":"at","expires_in": 3600,"refresh_token":"rt","client_info":%q,"id_token":%q,"token_type":"Bearer"}`, mockClientInfo, mockIDT)), )) } else { res.Body = io.NopCloser(bytes.NewReader(accessTokenRespSuccess)) From 4228971848df07dec47962cb3e925f4dea32d376 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Thu, 4 Jan 2024 09:50:51 -0800 Subject: [PATCH 02/32] Increment package version after release of messaging/azeventgrid (#22060) --- sdk/messaging/azeventgrid/CHANGELOG.md | 10 ++++++++++ sdk/messaging/azeventgrid/internal/version.go | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sdk/messaging/azeventgrid/CHANGELOG.md b/sdk/messaging/azeventgrid/CHANGELOG.md index ffe46ca5f747..782bf4498bcc 100644 --- a/sdk/messaging/azeventgrid/CHANGELOG.md +++ b/sdk/messaging/azeventgrid/CHANGELOG.md @@ -1,5 +1,15 @@ # Release History +## 0.4.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes + ## 0.4.0 (2023-11-27) ### Features Added diff --git a/sdk/messaging/azeventgrid/internal/version.go b/sdk/messaging/azeventgrid/internal/version.go index 08e8f005d2a9..1eb8e52fa0ff 100644 --- a/sdk/messaging/azeventgrid/internal/version.go +++ b/sdk/messaging/azeventgrid/internal/version.go @@ -14,5 +14,5 @@ const ( ModuleName = "azeventgrid" // ModuleVersion is the semantic version (see http://semver.org) of this module. - ModuleVersion = "v0.4.0" + ModuleVersion = "v0.4.1" ) From 8c72917dac6b3db687f870e8e15985325917dc79 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Thu, 4 Jan 2024 09:51:33 -0800 Subject: [PATCH 03/32] Increment package version after release of ai/azopenai (#22126) --- sdk/ai/azopenai/CHANGELOG.md | 10 ++++++++++ sdk/ai/azopenai/version.go | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sdk/ai/azopenai/CHANGELOG.md b/sdk/ai/azopenai/CHANGELOG.md index f8373965323e..8cba1e8685ed 100644 --- a/sdk/ai/azopenai/CHANGELOG.md +++ b/sdk/ai/azopenai/CHANGELOG.md @@ -1,5 +1,15 @@ # Release History +## 0.4.1 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes + ## 0.4.0 (2023-12-11) Support for many of the features mentioned in OpenAI's November Dev Day and Microsoft's 2023 Ignite conference diff --git a/sdk/ai/azopenai/version.go b/sdk/ai/azopenai/version.go index b3fc491abbb4..3f09eece9564 100644 --- a/sdk/ai/azopenai/version.go +++ b/sdk/ai/azopenai/version.go @@ -7,5 +7,5 @@ package azopenai const ( - version = "v0.4.0" + version = "v0.4.1" ) From 5798b0daaebe8eadfe23ac0c39a1573eff4cca10 Mon Sep 17 00:00:00 2001 From: Sourav Gupta <98318303+souravgupta-msft@users.noreply.github.com> Date: Fri, 5 Jan 2024 10:54:59 +0530 Subject: [PATCH 04/32] azblob: STG91 upgrade (#22194) --- sdk/storage/azblob/CHANGELOG.md | 3 + sdk/storage/azblob/README.md | 2 +- sdk/storage/azblob/appendblob/client.go | 3 +- sdk/storage/azblob/appendblob/client_test.go | 68 +++++++++++ sdk/storage/azblob/assets.json | 2 +- sdk/storage/azblob/blob/client.go | 17 ++- sdk/storage/azblob/blob/client_test.go | 64 +++++++++++ sdk/storage/azblob/blockblob/client.go | 3 +- sdk/storage/azblob/blockblob/client_test.go | 76 +++++++++++++ sdk/storage/azblob/client.go | 19 +--- sdk/storage/azblob/client_test.go | 106 ++++++++++++++++++ sdk/storage/azblob/container/client.go | 17 ++- sdk/storage/azblob/container/client_test.go | 52 +++++++++ sdk/storage/azblob/internal/base/clients.go | 29 ++++- .../azblob/internal/generated/autorest.md | 4 +- .../azblob/internal/generated/constants.go | 2 +- .../generated/zz_appendblob_client.go | 8 +- .../internal/generated/zz_blob_client.go | 48 ++++---- .../internal/generated/zz_blockblob_client.go | 12 +- .../internal/generated/zz_container_client.go | 36 +++--- .../internal/generated/zz_pageblob_client.go | 18 +-- .../internal/generated/zz_service_client.go | 16 +-- .../internal/shared/challenge_policy.go | 6 +- .../internal/shared/challenge_policy_test.go | 4 +- sdk/storage/azblob/pageblob/client.go | 3 +- sdk/storage/azblob/pageblob/client_test.go | 68 +++++++++++ sdk/storage/azblob/service/client.go | 17 ++- sdk/storage/azblob/service/client_test.go | 76 +++++++++++++ 28 files changed, 661 insertions(+), 118 deletions(-) diff --git a/sdk/storage/azblob/CHANGELOG.md b/sdk/storage/azblob/CHANGELOG.md index 77698e093e25..0d363352c48c 100644 --- a/sdk/storage/azblob/CHANGELOG.md +++ b/sdk/storage/azblob/CHANGELOG.md @@ -4,6 +4,9 @@ ### Features Added +* Updated service version to `2023-11-03`. +* Added support for Audience when OAuth is used. + ### Breaking Changes ### Bugs Fixed diff --git a/sdk/storage/azblob/README.md b/sdk/storage/azblob/README.md index 905fb2675c68..1f51959fa3d6 100644 --- a/sdk/storage/azblob/README.md +++ b/sdk/storage/azblob/README.md @@ -1,6 +1,6 @@ # Azure Blob Storage module for Go -> Service Version: 2023-08-03 +> Service Version: 2023-11-03 Azure Blob Storage is Microsoft's object storage solution for the cloud. Blob Storage is optimized for storing massive amounts of unstructured data - data that does not adhere to a particular data model or diff --git a/sdk/storage/azblob/appendblob/client.go b/sdk/storage/azblob/appendblob/client.go index 2229b7d85e7f..ef8e2e85a068 100644 --- a/sdk/storage/azblob/appendblob/client.go +++ b/sdk/storage/azblob/appendblob/client.go @@ -35,7 +35,8 @@ type Client base.CompositeClient[generated.BlobClient, generated.AppendBlobClien // - cred - an Azure AD credential, typically obtained via the azidentity module // - options - client options; pass nil to accept the default values func NewClient(blobURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { - authPolicy := shared.NewStorageChallengePolicy(cred) + audience := base.GetAudience((*base.ClientOptions)(options)) + authPolicy := shared.NewStorageChallengePolicy(cred, audience) conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}} diff --git a/sdk/storage/azblob/appendblob/client_test.go b/sdk/storage/azblob/appendblob/client_test.go index 865b57d0e743..ddcbb17e0280 100644 --- a/sdk/storage/azblob/appendblob/client_test.go +++ b/sdk/storage/azblob/appendblob/client_test.go @@ -3578,3 +3578,71 @@ func (s *AppendBlobRecordedTestsSuite) TestAppendBlockSetTier() { _, err = abClient.SetTier(context.Background(), blob.AccessTierHot, nil) _require.ErrorContains(err, "operation will not work on this blob type. SetTier only works for page blob in premium storage account and block blob in blob storage account") } + +func (s *AppendBlobRecordedTestsSuite) TestAppendBlobClientDefaultAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient) + defer testcommon.DeleteContainer(context.Background(), _require, containerClient) + + blobName := testcommon.GenerateBlobName(testName) + blobURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s/%s", accountName, containerName, blobName) + + options := &appendblob.ClientOptions{ + Audience: "https://storage.azure.com/", + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + abClientAudience, err := appendblob.NewClient(blobURL, cred, options) + _require.NoError(err) + + _, err = abClientAudience.Create(context.Background(), nil) + _require.NoError(err) + + _, err = abClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} + +func (s *AppendBlobRecordedTestsSuite) TestAppendBlobClientCustomAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient) + defer testcommon.DeleteContainer(context.Background(), _require, containerClient) + + blobName := testcommon.GenerateBlobName(testName) + blobURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s/%s", accountName, containerName, blobName) + + options := &appendblob.ClientOptions{ + Audience: "https://" + accountName + ".blob.core.windows.net", + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + abClientAudience, err := appendblob.NewClient(blobURL, cred, options) + _require.NoError(err) + + _, err = abClientAudience.Create(context.Background(), nil) + _require.NoError(err) + + _, err = abClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} diff --git a/sdk/storage/azblob/assets.json b/sdk/storage/azblob/assets.json index 80d6183c5b52..a2a2f83f8d49 100644 --- a/sdk/storage/azblob/assets.json +++ b/sdk/storage/azblob/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/storage/azblob", - "Tag": "go/storage/azblob_0040e8284c" + "Tag": "go/storage/azblob_ceb9b7d6b4" } diff --git a/sdk/storage/azblob/blob/client.go b/sdk/storage/azblob/blob/client.go index d2421ddd916a..23955a828f72 100644 --- a/sdk/storage/azblob/blob/client.go +++ b/sdk/storage/azblob/blob/client.go @@ -36,7 +36,8 @@ type Client base.Client[generated.BlobClient] // - cred - an Azure AD credential, typically obtained via the azidentity module // - options - client options; pass nil to accept the default values func NewClient(blobURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { - authPolicy := shared.NewStorageChallengePolicy(cred) + audience := base.GetAudience((*base.ClientOptions)(options)) + authPolicy := shared.NewStorageChallengePolicy(cred, audience) conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}} @@ -44,7 +45,7 @@ func NewClient(blobURL string, cred azcore.TokenCredential, options *ClientOptio if err != nil { return nil, err } - return (*Client)(base.NewBlobClient(blobURL, azClient, &cred)), nil + return (*Client)(base.NewBlobClient(blobURL, azClient, &cred, (*base.ClientOptions)(conOptions))), nil } // NewClientWithNoCredential creates an instance of Client with the specified values. @@ -58,7 +59,7 @@ func NewClientWithNoCredential(blobURL string, options *ClientOptions) (*Client, if err != nil { return nil, err } - return (*Client)(base.NewBlobClient(blobURL, azClient, nil)), nil + return (*Client)(base.NewBlobClient(blobURL, azClient, nil, (*base.ClientOptions)(conOptions))), nil } // NewClientWithSharedKeyCredential creates an instance of Client with the specified values. @@ -74,7 +75,7 @@ func NewClientWithSharedKeyCredential(blobURL string, cred *SharedKeyCredential, if err != nil { return nil, err } - return (*Client)(base.NewBlobClient(blobURL, azClient, cred)), nil + return (*Client)(base.NewBlobClient(blobURL, azClient, cred, (*base.ClientOptions)(conOptions))), nil } // NewClientFromConnectionString creates an instance of Client with the specified values. @@ -112,6 +113,10 @@ func (b *Client) credential() any { return base.Credential((*base.Client[generated.BlobClient])(b)) } +func (b *Client) getClientOptions() *base.ClientOptions { + return base.GetClientOptions((*base.Client[generated.BlobClient])(b)) +} + // URL returns the URL endpoint used by the Client object. func (b *Client) URL() string { return b.generated().Endpoint() @@ -126,7 +131,7 @@ func (b *Client) WithSnapshot(snapshot string) (*Client, error) { } p.Snapshot = snapshot - return (*Client)(base.NewBlobClient(p.String(), b.generated().InternalClient(), b.credential())), nil + return (*Client)(base.NewBlobClient(p.String(), b.generated().InternalClient(), b.credential(), b.getClientOptions())), nil } // WithVersionID creates a new AppendBlobURL object identical to the source but with the specified version id. @@ -138,7 +143,7 @@ func (b *Client) WithVersionID(versionID string) (*Client, error) { } p.VersionID = versionID - return (*Client)(base.NewBlobClient(p.String(), b.generated().InternalClient(), b.credential())), nil + return (*Client)(base.NewBlobClient(p.String(), b.generated().InternalClient(), b.credential(), b.getClientOptions())), nil } // Delete marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection. diff --git a/sdk/storage/azblob/blob/client_test.go b/sdk/storage/azblob/blob/client_test.go index d8d43666a303..61b90f213bd0 100644 --- a/sdk/storage/azblob/blob/client_test.go +++ b/sdk/storage/azblob/blob/client_test.go @@ -3681,3 +3681,67 @@ func (s *BlobRecordedTestsSuite) TestBlobGetAccountInfo() { _require.NoError(err) _require.NotZero(bAccInfo) } + +func (s *BlobRecordedTestsSuite) TestBlobClientDefaultAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient) + defer testcommon.DeleteContainer(context.Background(), _require, containerClient) + + blobName := testcommon.GenerateBlobName(testName) + blobURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s/%s", accountName, containerName, blobName) + testcommon.CreateNewBlockBlob(context.Background(), _require, blobName, containerClient) + + options := &blob.ClientOptions{ + Audience: "https://storage.azure.com/", + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + blobClientAudience, err := blob.NewClient(blobURL, cred, options) + _require.NoError(err) + + _, err = blobClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} + +func (s *BlobRecordedTestsSuite) TestBlobClientCustomAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient) + defer testcommon.DeleteContainer(context.Background(), _require, containerClient) + + blobName := testcommon.GenerateBlobName(testName) + blobURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s/%s", accountName, containerName, blobName) + testcommon.CreateNewBlockBlob(context.Background(), _require, blobName, containerClient) + + options := &blob.ClientOptions{ + Audience: "https://" + accountName + ".blob.core.windows.net", + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + blobClientAudience, err := blob.NewClient(blobURL, cred, options) + _require.NoError(err) + + _, err = blobClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} diff --git a/sdk/storage/azblob/blockblob/client.go b/sdk/storage/azblob/blockblob/client.go index e3167b7747d8..b69c4d490d6d 100644 --- a/sdk/storage/azblob/blockblob/client.go +++ b/sdk/storage/azblob/blockblob/client.go @@ -45,7 +45,8 @@ type Client base.CompositeClient[generated.BlobClient, generated.BlockBlobClient // - cred - an Azure AD credential, typically obtained via the azidentity module // - options - client options; pass nil to accept the default values func NewClient(blobURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { - authPolicy := shared.NewStorageChallengePolicy(cred) + audience := base.GetAudience((*base.ClientOptions)(options)) + authPolicy := shared.NewStorageChallengePolicy(cred, audience) conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}} diff --git a/sdk/storage/azblob/blockblob/client_test.go b/sdk/storage/azblob/blockblob/client_test.go index e7d3841ab3a0..4de1cf4e8d94 100644 --- a/sdk/storage/azblob/blockblob/client_test.go +++ b/sdk/storage/azblob/blockblob/client_test.go @@ -5869,3 +5869,79 @@ func TestServiceVersion(t *testing.T) { _, err = client.Upload(context.Background(), streaming.NopCloser(r), nil) require.NoError(t, err) } + +func (s *BlockBlobRecordedTestsSuite) TestBlockBlobClientDefaultAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient) + defer testcommon.DeleteContainer(context.Background(), _require, containerClient) + + blobName := testcommon.GenerateBlobName(testName) + blobURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s/%s", accountName, containerName, blobName) + + options := &blockblob.ClientOptions{ + Audience: "https://storage.azure.com/", + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + bbClientAudience, err := blockblob.NewClient(blobURL, cred, options) + _require.NoError(err) + + contentSize := 4 * 1024 // 4 KB + r, _ := testcommon.GetDataAndReader(testName, contentSize) + rsc := streaming.NopCloser(r) + + _, err = bbClientAudience.Upload(context.Background(), rsc, nil) + _require.NoError(err) + + _, err = bbClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} + +func (s *BlockBlobRecordedTestsSuite) TestBlockBlobClientCustomAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient) + defer testcommon.DeleteContainer(context.Background(), _require, containerClient) + + blobName := testcommon.GenerateBlobName(testName) + blobURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s/%s", accountName, containerName, blobName) + + options := &blockblob.ClientOptions{ + Audience: "https://" + accountName + ".blob.core.windows.net", + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + bbClientAudience, err := blockblob.NewClient(blobURL, cred, options) + _require.NoError(err) + + contentSize := 4 * 1024 // 4 KB + r, _ := testcommon.GetDataAndReader(testName, contentSize) + rsc := streaming.NopCloser(r) + + _, err = bbClientAudience.Upload(context.Background(), rsc, nil) + _require.NoError(err) + + _, err = bbClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} diff --git a/sdk/storage/azblob/client.go b/sdk/storage/azblob/client.go index 5c4b719c4ba6..c511d8a79f20 100644 --- a/sdk/storage/azblob/client.go +++ b/sdk/storage/azblob/client.go @@ -31,11 +31,7 @@ type Client struct { // - cred - an Azure AD credential, typically obtained via the azidentity module // - options - client options; pass nil to accept the default values func NewClient(serviceURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { - var clientOptions *service.ClientOptions - if options != nil { - clientOptions = &service.ClientOptions{ClientOptions: options.ClientOptions} - } - svcClient, err := service.NewClient(serviceURL, cred, clientOptions) + svcClient, err := service.NewClient(serviceURL, cred, (*service.ClientOptions)(options)) if err != nil { return nil, err } @@ -50,11 +46,7 @@ func NewClient(serviceURL string, cred azcore.TokenCredential, options *ClientOp // - serviceURL - the URL of the storage account e.g. https://.blob.core.windows.net/? // - options - client options; pass nil to accept the default values func NewClientWithNoCredential(serviceURL string, options *ClientOptions) (*Client, error) { - var clientOptions *service.ClientOptions - if options != nil { - clientOptions = &service.ClientOptions{ClientOptions: options.ClientOptions} - } - svcClient, err := service.NewClientWithNoCredential(serviceURL, clientOptions) + svcClient, err := service.NewClientWithNoCredential(serviceURL, (*service.ClientOptions)(options)) if err != nil { return nil, err } @@ -83,15 +75,12 @@ func NewClientWithSharedKeyCredential(serviceURL string, cred *SharedKeyCredenti // - connectionString - a connection string for the desired storage account // - options - client options; pass nil to accept the default values func NewClientFromConnectionString(connectionString string, options *ClientOptions) (*Client, error) { - if options == nil { - options = &ClientOptions{} - } - containerClient, err := service.NewClientFromConnectionString(connectionString, (*service.ClientOptions)(options)) + svcClient, err := service.NewClientFromConnectionString(connectionString, (*service.ClientOptions)(options)) if err != nil { return nil, err } return &Client{ - svc: containerClient, + svc: svcClient, }, nil } diff --git a/sdk/storage/azblob/client_test.go b/sdk/storage/azblob/client_test.go index 2bcf3400527d..5fd3563e1011 100644 --- a/sdk/storage/azblob/client_test.go +++ b/sdk/storage/azblob/client_test.go @@ -80,6 +80,36 @@ func (s *AZBlobUnrecordedTestsSuite) AfterTest(suite string, test string) { } +func (s *AZBlobRecordedTestsSuite) TestAzBlobClientSharedKey() { + _require := require.New(s.T()) + + cred, err := testcommon.GetGenericSharedKeyCredential(testcommon.TestAccountDefault) + _require.NoError(err) + + svcURL := "https://" + cred.AccountName() + ".blob.core.windows.net/" + azClient, err := azblob.NewClientWithSharedKeyCredential(svcURL, cred, nil) + _require.NoError(err) + _require.NotNil(azClient) + _require.Equal(azClient.URL(), svcURL) +} + +func (s *AZBlobRecordedTestsSuite) TestAzBlobClientConnectionString() { + _require := require.New(s.T()) + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + connString, err := testcommon.GetGenericConnectionString(testcommon.TestAccountDefault) + _require.NoError(err) + _require.NotNil(connString) + + svcURL := "https://" + accountName + ".blob.core.windows.net/" + azClient, err := azblob.NewClientFromConnectionString(*connString, nil) + _require.NoError(err) + _require.NotNil(azClient) + _require.Equal(azClient.URL(), svcURL) +} + // create a test file func generateFile(fileName string, fileSize int) []byte { // generate random data @@ -756,3 +786,79 @@ func (s *AZBlobUnrecordedTestsSuite) TestDoBatchTransferWithError() { mmf.isClosed = true time.Sleep(time.Second * 5) } + +func (s *AZBlobRecordedTestsSuite) TestAzBlobClientDefaultAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + options := &azblob.ClientOptions{ + Audience: "https://storage.azure.com/", + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + azClientAudience, err := azblob.NewClient("https://"+accountName+".blob.core.windows.net/", cred, options) + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + _, err = azClientAudience.CreateContainer(context.Background(), containerName, nil) + _require.NoError(err) + + defer func() { + _, err = azClientAudience.DeleteContainer(context.Background(), containerName, nil) + _require.NoError(err) + }() + + pager := azClientAudience.NewListContainersPager(&azblob.ListContainersOptions{ + Prefix: &containerName, + }) + for pager.More() { + resp, err := pager.NextPage(context.Background()) + _require.NoError(err) + _require.Equal(len(resp.ContainerItems), 1) + _require.NotNil(resp.ContainerItems[0].Name) + _require.Equal(*resp.ContainerItems[0].Name, containerName) + } +} + +func (s *AZBlobRecordedTestsSuite) TestAzBlobClientCustomAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + options := &azblob.ClientOptions{ + Audience: "https://" + accountName + ".blob.core.windows.net", + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + azClientAudience, err := azblob.NewClient("https://"+accountName+".blob.core.windows.net/", cred, options) + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + _, err = azClientAudience.CreateContainer(context.Background(), containerName, nil) + _require.NoError(err) + + defer func() { + _, err = azClientAudience.DeleteContainer(context.Background(), containerName, nil) + _require.NoError(err) + }() + + pager := azClientAudience.NewListContainersPager(&azblob.ListContainersOptions{ + Prefix: &containerName, + }) + for pager.More() { + resp, err := pager.NextPage(context.Background()) + _require.NoError(err) + _require.Equal(len(resp.ContainerItems), 1) + _require.NotNil(resp.ContainerItems[0].Name) + _require.Equal(*resp.ContainerItems[0].Name, containerName) + } +} diff --git a/sdk/storage/azblob/container/client.go b/sdk/storage/azblob/container/client.go index 3058b5d49c00..0086a81920dd 100644 --- a/sdk/storage/azblob/container/client.go +++ b/sdk/storage/azblob/container/client.go @@ -42,7 +42,8 @@ type Client base.Client[generated.ContainerClient] // - cred - an Azure AD credential, typically obtained via the azidentity module // - options - client options; pass nil to accept the default values func NewClient(containerURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { - authPolicy := shared.NewStorageChallengePolicy(cred) + audience := base.GetAudience((*base.ClientOptions)(options)) + authPolicy := shared.NewStorageChallengePolicy(cred, audience) conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}} @@ -50,7 +51,7 @@ func NewClient(containerURL string, cred azcore.TokenCredential, options *Client if err != nil { return nil, err } - return (*Client)(base.NewContainerClient(containerURL, azClient, &cred)), nil + return (*Client)(base.NewContainerClient(containerURL, azClient, &cred, (*base.ClientOptions)(conOptions))), nil } // NewClientWithNoCredential creates an instance of Client with the specified values. @@ -64,7 +65,7 @@ func NewClientWithNoCredential(containerURL string, options *ClientOptions) (*Cl if err != nil { return nil, err } - return (*Client)(base.NewContainerClient(containerURL, azClient, nil)), nil + return (*Client)(base.NewContainerClient(containerURL, azClient, nil, (*base.ClientOptions)(conOptions))), nil } // NewClientWithSharedKeyCredential creates an instance of Client with the specified values. @@ -80,7 +81,7 @@ func NewClientWithSharedKeyCredential(containerURL string, cred *SharedKeyCreden if err != nil { return nil, err } - return (*Client)(base.NewContainerClient(containerURL, azClient, cred)), nil + return (*Client)(base.NewContainerClient(containerURL, azClient, cred, (*base.ClientOptions)(conOptions))), nil } // NewClientFromConnectionString creates an instance of Client with the specified values. @@ -122,6 +123,10 @@ func getGeneratedBlobClient(b *blob.Client) *generated.BlobClient { return base.InnerClient((*base.Client[generated.BlobClient])(b)) } +func (c *Client) getClientOptions() *base.ClientOptions { + return base.GetClientOptions((*base.Client[generated.ContainerClient])(c)) +} + // URL returns the URL endpoint used by the Client object. func (c *Client) URL() string { return c.generated().Endpoint() @@ -133,7 +138,7 @@ func (c *Client) URL() string { func (c *Client) NewBlobClient(blobName string) *blob.Client { blobName = url.PathEscape(blobName) blobURL := runtime.JoinPaths(c.URL(), blobName) - return (*blob.Client)(base.NewBlobClient(blobURL, c.generated().InternalClient().WithClientName(shared.BlobClient), c.credential())) + return (*blob.Client)(base.NewBlobClient(blobURL, c.generated().InternalClient().WithClientName(shared.BlobClient), c.credential(), c.getClientOptions())) } // NewAppendBlobClient creates a new appendblob.Client object by concatenating blobName to the end of @@ -366,7 +371,7 @@ func (c *Client) NewBatchBuilder() (*BatchBuilder, error) { switch cred := c.credential().(type) { case *azcore.TokenCredential: - authPolicy = shared.NewStorageChallengePolicy(*cred) + authPolicy = shared.NewStorageChallengePolicy(*cred, base.GetAudience(c.getClientOptions())) case *SharedKeyCredential: authPolicy = exported.NewSharedKeyCredPolicy(cred) case nil: diff --git a/sdk/storage/azblob/container/client_test.go b/sdk/storage/azblob/container/client_test.go index a0e089d60ae0..26a4b98e1a31 100644 --- a/sdk/storage/azblob/container/client_test.go +++ b/sdk/storage/azblob/container/client_test.go @@ -3459,3 +3459,55 @@ func (s *ContainerUnrecordedTestsSuite) TestContainerSASUsingAccessPolicy() { _, err = bbClient.Delete(context.Background(), nil) _require.NoError(err) } + +func (s *ContainerRecordedTestsSuite) TestContainerClientDefaultAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + options := &container.ClientOptions{ + Audience: "https://storage.azure.com/", + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + containerClientAudience, err := container.NewClient("https://"+accountName+".blob.core.windows.net/"+containerName, cred, options) + _require.NoError(err) + + _, err = containerClientAudience.Create(context.Background(), nil) + _require.NoError(err) + defer testcommon.DeleteContainer(context.Background(), _require, containerClientAudience) + + _, err = containerClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} + +func (s *ContainerRecordedTestsSuite) TestContainerClientCustomAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + options := &container.ClientOptions{ + Audience: "https://" + accountName + ".blob.core.windows.net", + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + containerClientAudience, err := container.NewClient("https://"+accountName+".blob.core.windows.net/"+containerName, cred, options) + _require.NoError(err) + + _, err = containerClientAudience.Create(context.Background(), nil) + _require.NoError(err) + defer testcommon.DeleteContainer(context.Background(), _require, containerClientAudience) + + _, err = containerClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} diff --git a/sdk/storage/azblob/internal/base/clients.go b/sdk/storage/azblob/internal/base/clients.go index c95f19254a71..073de855b617 100644 --- a/sdk/storage/azblob/internal/base/clients.go +++ b/sdk/storage/azblob/internal/base/clients.go @@ -10,16 +10,24 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/internal/exported" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/internal/generated" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/internal/shared" + "strings" ) // ClientOptions contains the optional parameters when creating a Client. type ClientOptions struct { azcore.ClientOptions + + // Audience to use when requesting tokens for Azure Active Directory authentication. + // Only has an effect when credential is of type TokenCredential. The value could be + // https://storage.azure.com/ (default) or https://.blob.core.windows.net. + Audience string } type Client[T any] struct { inner *T credential any + options *ClientOptions } func InnerClient[T any](client *Client[T]) *T { @@ -39,28 +47,43 @@ func Credential[T any](client *Client[T]) any { return client.credential } +func GetClientOptions[T any](client *Client[T]) *ClientOptions { + return client.options +} + +func GetAudience(clOpts *ClientOptions) string { + if clOpts == nil || len(strings.TrimSpace(clOpts.Audience)) == 0 { + return shared.TokenScope + } else { + return strings.TrimRight(clOpts.Audience, "/") + "/.default" + } +} + func NewClient[T any](inner *T) *Client[T] { return &Client[T]{inner: inner} } -func NewServiceClient(containerURL string, azClient *azcore.Client, credential any) *Client[generated.ServiceClient] { +func NewServiceClient(containerURL string, azClient *azcore.Client, credential any, options *ClientOptions) *Client[generated.ServiceClient] { return &Client[generated.ServiceClient]{ inner: generated.NewServiceClient(containerURL, azClient), credential: credential, + options: options, } } -func NewContainerClient(containerURL string, azClient *azcore.Client, credential any) *Client[generated.ContainerClient] { +func NewContainerClient(containerURL string, azClient *azcore.Client, credential any, options *ClientOptions) *Client[generated.ContainerClient] { return &Client[generated.ContainerClient]{ inner: generated.NewContainerClient(containerURL, azClient), credential: credential, + options: options, } } -func NewBlobClient(blobURL string, azClient *azcore.Client, credential any) *Client[generated.BlobClient] { +func NewBlobClient(blobURL string, azClient *azcore.Client, credential any, options *ClientOptions) *Client[generated.BlobClient] { return &Client[generated.BlobClient]{ inner: generated.NewBlobClient(blobURL, azClient), credential: credential, + options: options, } } diff --git a/sdk/storage/azblob/internal/generated/autorest.md b/sdk/storage/azblob/internal/generated/autorest.md index 25deeec35872..92dc7e2d31e5 100644 --- a/sdk/storage/azblob/internal/generated/autorest.md +++ b/sdk/storage/azblob/internal/generated/autorest.md @@ -22,7 +22,7 @@ export-clients: true use: "@autorest/go@4.0.0-preview.61" ``` -### Updating service version to 2023-08-03 +### Updating service version to 2023-11-03 ```yaml directive: - from: @@ -36,7 +36,7 @@ directive: transform: >- return $. replaceAll(`[]string{"2021-12-02"}`, `[]string{ServiceVersion}`). - replaceAll(`2021-12-02`, `2023-08-03`); + replaceAll(`2021-12-02`, `2023-11-03`); ``` ### Undo breaking change with BlobName diff --git a/sdk/storage/azblob/internal/generated/constants.go b/sdk/storage/azblob/internal/generated/constants.go index 8c13c44116b6..8f2bbbb7cb81 100644 --- a/sdk/storage/azblob/internal/generated/constants.go +++ b/sdk/storage/azblob/internal/generated/constants.go @@ -6,4 +6,4 @@ package generated -const ServiceVersion = "2023-08-03" +const ServiceVersion = "2023-11-03" diff --git a/sdk/storage/azblob/internal/generated/zz_appendblob_client.go b/sdk/storage/azblob/internal/generated/zz_appendblob_client.go index dbfe069e6f1d..797318611c37 100644 --- a/sdk/storage/azblob/internal/generated/zz_appendblob_client.go +++ b/sdk/storage/azblob/internal/generated/zz_appendblob_client.go @@ -32,7 +32,7 @@ type AppendBlobClient struct { // AppendBlob. Append Block is supported only on version 2015-02-21 version or later. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - contentLength - The length of the request. // - body - Initial data // - options - AppendBlobClientAppendBlockOptions contains the optional parameters for the AppendBlobClient.AppendBlock method. @@ -201,7 +201,7 @@ func (client *AppendBlobClient) appendBlockHandleResponse(resp *http.Response) ( // created with x-ms-blob-type set to AppendBlob. Append Block is supported only on version 2015-02-21 version or later. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - sourceURL - Specify a URL to the copy source. // - contentLength - The length of the request. // - options - AppendBlobClientAppendBlockFromURLOptions contains the optional parameters for the AppendBlobClient.AppendBlockFromURL @@ -387,7 +387,7 @@ func (client *AppendBlobClient) appendBlockFromURLHandleResponse(resp *http.Resp // Create - The Create Append Blob operation creates a new append blob. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - contentLength - The length of the request. // - options - AppendBlobClientCreateOptions contains the optional parameters for the AppendBlobClient.Create method. // - BlobHTTPHeaders - BlobHTTPHeaders contains a group of parameters for the BlobClient.SetHTTPHeaders method. @@ -560,7 +560,7 @@ func (client *AppendBlobClient) createHandleResponse(resp *http.Response) (Appen // or later. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - AppendBlobClientSealOptions contains the optional parameters for the AppendBlobClient.Seal method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ContainerClient.GetProperties method. // - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the ContainerClient.Delete method. diff --git a/sdk/storage/azblob/internal/generated/zz_blob_client.go b/sdk/storage/azblob/internal/generated/zz_blob_client.go index caaa3dfed7c4..fe568a96c7ac 100644 --- a/sdk/storage/azblob/internal/generated/zz_blob_client.go +++ b/sdk/storage/azblob/internal/generated/zz_blob_client.go @@ -32,7 +32,7 @@ type BlobClient struct { // blob with zero length and full metadata. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - copyID - The copy identifier provided in the x-ms-copy-id header of the original Copy Blob operation. // - options - BlobClientAbortCopyFromURLOptions contains the optional parameters for the BlobClient.AbortCopyFromURL method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ContainerClient.GetProperties method. @@ -104,7 +104,7 @@ func (client *BlobClient) abortCopyFromURLHandleResponse(resp *http.Response) (B // AcquireLease - [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - duration - Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A non-infinite // lease can be between 15 and 60 seconds. A lease duration cannot be changed using // renew or change. @@ -206,7 +206,7 @@ func (client *BlobClient) acquireLeaseHandleResponse(resp *http.Response) (BlobC // BreakLease - [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - BlobClientBreakLeaseOptions contains the optional parameters for the BlobClient.BreakLease method. // - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the ContainerClient.Delete method. func (client *BlobClient) BreakLease(ctx context.Context, options *BlobClientBreakLeaseOptions, modifiedAccessConditions *ModifiedAccessConditions) (BlobClientBreakLeaseResponse, error) { @@ -309,7 +309,7 @@ func (client *BlobClient) breakLeaseHandleResponse(resp *http.Response) (BlobCli // ChangeLease - [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - leaseID - Specifies the current lease ID on the resource. // - proposedLeaseID - Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) if the proposed // lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID @@ -411,7 +411,7 @@ func (client *BlobClient) changeLeaseHandleResponse(resp *http.Response) (BlobCl // until the copy is complete. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - copySource - Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in length that specifies // a page blob snapshot. The value should be URL-encoded as it would appear in a request // URI. The source blob must either be public or must be authenticated via a shared access signature. @@ -585,7 +585,7 @@ func (client *BlobClient) copyFromURLHandleResponse(resp *http.Response) (BlobCl // CreateSnapshot - The Create Snapshot operation creates a read-only snapshot of a blob // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - BlobClientCreateSnapshotOptions contains the optional parameters for the BlobClient.CreateSnapshot method. // - CPKInfo - CPKInfo contains a group of parameters for the BlobClient.Download method. // - CPKScopeInfo - CPKScopeInfo contains a group of parameters for the BlobClient.SetMetadata method. @@ -724,7 +724,7 @@ func (client *BlobClient) createSnapshotHandleResponse(resp *http.Response) (Blo // return an HTTP status code of 404 (ResourceNotFound). // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - BlobClientDeleteOptions contains the optional parameters for the BlobClient.Delete method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ContainerClient.GetProperties method. // - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the ContainerClient.Delete method. @@ -820,7 +820,7 @@ func (client *BlobClient) deleteHandleResponse(resp *http.Response) (BlobClientD // DeleteImmutabilityPolicy - The Delete Immutability Policy operation deletes the immutability policy on the blob // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - BlobClientDeleteImmutabilityPolicyOptions contains the optional parameters for the BlobClient.DeleteImmutabilityPolicy // method. func (client *BlobClient) DeleteImmutabilityPolicy(ctx context.Context, options *BlobClientDeleteImmutabilityPolicyOptions) (BlobClientDeleteImmutabilityPolicyResponse, error) { @@ -887,7 +887,7 @@ func (client *BlobClient) deleteImmutabilityPolicyHandleResponse(resp *http.Resp // can also call Download to read a snapshot. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - BlobClientDownloadOptions contains the optional parameters for the BlobClient.Download method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ContainerClient.GetProperties method. // - CPKInfo - CPKInfo contains a group of parameters for the BlobClient.Download method. @@ -1195,7 +1195,7 @@ func (client *BlobClient) downloadHandleResponse(resp *http.Response) (BlobClien // GetAccountInfo - Returns the sku name and account kind // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - BlobClientGetAccountInfoOptions contains the optional parameters for the BlobClient.GetAccountInfo method. func (client *BlobClient) GetAccountInfo(ctx context.Context, options *BlobClientGetAccountInfoOptions) (BlobClientGetAccountInfoResponse, error) { var err error @@ -1262,7 +1262,7 @@ func (client *BlobClient) getAccountInfoHandleResponse(resp *http.Response) (Blo // for the blob. It does not return the content of the blob. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - BlobClientGetPropertiesOptions contains the optional parameters for the BlobClient.GetProperties method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ContainerClient.GetProperties method. // - CPKInfo - CPKInfo contains a group of parameters for the BlobClient.Download method. @@ -1580,7 +1580,7 @@ func (client *BlobClient) getPropertiesHandleResponse(resp *http.Response) (Blob // GetTags - The Get Tags operation enables users to get the tags associated with a blob. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - BlobClientGetTagsOptions contains the optional parameters for the BlobClient.GetTags method. // - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the ContainerClient.Delete method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ContainerClient.GetProperties method. @@ -1662,7 +1662,7 @@ func (client *BlobClient) getTagsHandleResponse(resp *http.Response) (BlobClient // Query - The Query operation enables users to select/project on blob data by providing simple query expressions. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - BlobClientQueryOptions contains the optional parameters for the BlobClient.Query method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ContainerClient.GetProperties method. // - CPKInfo - CPKInfo contains a group of parameters for the BlobClient.Download method. @@ -1896,7 +1896,7 @@ func (client *BlobClient) queryHandleResponse(resp *http.Response) (BlobClientQu // ReleaseLease - [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - leaseID - Specifies the current lease ID on the resource. // - options - BlobClientReleaseLeaseOptions contains the optional parameters for the BlobClient.ReleaseLease method. // - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the ContainerClient.Delete method. @@ -1990,7 +1990,7 @@ func (client *BlobClient) releaseLeaseHandleResponse(resp *http.Response) (BlobC // RenewLease - [Update] The Lease Blob operation establishes and manages a lock on a blob for write and delete operations // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - leaseID - Specifies the current lease ID on the resource. // - options - BlobClientRenewLeaseOptions contains the optional parameters for the BlobClient.RenewLease method. // - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the ContainerClient.Delete method. @@ -2087,7 +2087,7 @@ func (client *BlobClient) renewLeaseHandleResponse(resp *http.Response) (BlobCli // SetExpiry - Sets the time a blob will expire and be deleted. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - expiryOptions - Required. Indicates mode of the expiry time // - options - BlobClientSetExpiryOptions contains the optional parameters for the BlobClient.SetExpiry method. func (client *BlobClient) SetExpiry(ctx context.Context, expiryOptions ExpiryOptions, options *BlobClientSetExpiryOptions) (BlobClientSetExpiryResponse, error) { @@ -2167,7 +2167,7 @@ func (client *BlobClient) setExpiryHandleResponse(resp *http.Response) (BlobClie // SetHTTPHeaders - The Set HTTP Headers operation sets system properties on the blob // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - BlobClientSetHTTPHeadersOptions contains the optional parameters for the BlobClient.SetHTTPHeaders method. // - BlobHTTPHeaders - BlobHTTPHeaders contains a group of parameters for the BlobClient.SetHTTPHeaders method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ContainerClient.GetProperties method. @@ -2288,7 +2288,7 @@ func (client *BlobClient) setHTTPHeadersHandleResponse(resp *http.Response) (Blo // SetImmutabilityPolicy - The Set Immutability Policy operation sets the immutability policy on the blob // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - BlobClientSetImmutabilityPolicyOptions contains the optional parameters for the BlobClient.SetImmutabilityPolicy // method. // - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the ContainerClient.Delete method. @@ -2374,7 +2374,7 @@ func (client *BlobClient) setImmutabilityPolicyHandleResponse(resp *http.Respons // SetLegalHold - The Set Legal Hold operation sets a legal hold on the blob. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - legalHold - Specified if a legal hold should be set on the blob. // - options - BlobClientSetLegalHoldOptions contains the optional parameters for the BlobClient.SetLegalHold method. func (client *BlobClient) SetLegalHold(ctx context.Context, legalHold bool, options *BlobClientSetLegalHoldOptions) (BlobClientSetLegalHoldResponse, error) { @@ -2449,7 +2449,7 @@ func (client *BlobClient) setLegalHoldHandleResponse(resp *http.Response) (BlobC // pairs // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - BlobClientSetMetadataOptions contains the optional parameters for the BlobClient.SetMetadata method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ContainerClient.GetProperties method. // - CPKInfo - CPKInfo contains a group of parameters for the BlobClient.Download method. @@ -2581,7 +2581,7 @@ func (client *BlobClient) setMetadataHandleResponse(resp *http.Response) (BlobCl // SetTags - The Set Tags operation enables users to set tags on a blob. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - tags - Blob tags // - options - BlobClientSetTagsOptions contains the optional parameters for the BlobClient.SetTags method. // - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the ContainerClient.Delete method. @@ -2670,7 +2670,7 @@ func (client *BlobClient) setTagsHandleResponse(resp *http.Response) (BlobClient // storage type. This operation does not update the blob's ETag. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - tier - Indicates the tier to be set on the blob. // - options - BlobClientSetTierOptions contains the optional parameters for the BlobClient.SetTier method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ContainerClient.GetProperties method. @@ -2747,7 +2747,7 @@ func (client *BlobClient) setTierHandleResponse(resp *http.Response) (BlobClient // StartCopyFromURL - The Start Copy From URL operation copies a blob or an internet resource to a new blob. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - copySource - Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in length that specifies // a page blob snapshot. The value should be URL-encoded as it would appear in a request // URI. The source blob must either be public or must be authenticated via a shared access signature. @@ -2899,7 +2899,7 @@ func (client *BlobClient) startCopyFromURLHandleResponse(resp *http.Response) (B // Undelete - Undelete a blob that was previously soft deleted // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - BlobClientUndeleteOptions contains the optional parameters for the BlobClient.Undelete method. func (client *BlobClient) Undelete(ctx context.Context, options *BlobClientUndeleteOptions) (BlobClientUndeleteResponse, error) { var err error diff --git a/sdk/storage/azblob/internal/generated/zz_blockblob_client.go b/sdk/storage/azblob/internal/generated/zz_blockblob_client.go index bfd7f5eac7de..b6115b50a656 100644 --- a/sdk/storage/azblob/internal/generated/zz_blockblob_client.go +++ b/sdk/storage/azblob/internal/generated/zz_blockblob_client.go @@ -36,7 +36,7 @@ type BlockBlobClient struct { // belong to. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - blocks - Blob Blocks. // - options - BlockBlobClientCommitBlockListOptions contains the optional parameters for the BlockBlobClient.CommitBlockList // method. @@ -227,7 +227,7 @@ func (client *BlockBlobClient) commitBlockListHandleResponse(resp *http.Response // GetBlockList - The Get Block List operation retrieves the list of blocks that have been uploaded as part of a block blob // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - listType - Specifies whether to return the list of committed blocks, the list of uncommitted blocks, or both lists together. // - options - BlockBlobClientGetBlockListOptions contains the optional parameters for the BlockBlobClient.GetBlockList method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ContainerClient.GetProperties method. @@ -332,7 +332,7 @@ func (client *BlockBlobClient) getBlockListHandleResponse(resp *http.Response) ( // Block from URL API in conjunction with Put Block List. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - contentLength - The length of the request. // - copySource - Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in length that specifies // a page blob snapshot. The value should be URL-encoded as it would appear in a request @@ -535,7 +535,7 @@ func (client *BlockBlobClient) putBlobFromURLHandleResponse(resp *http.Response) // StageBlock - The Stage Block operation creates a new block to be committed as part of a blob // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - blockID - A valid Base64 string value that identifies the block. Prior to encoding, the string must be less than or equal // to 64 bytes in size. For a given blob, the length of the value specified for the blockid // parameter must be the same size for each block. @@ -662,7 +662,7 @@ func (client *BlockBlobClient) stageBlockHandleResponse(resp *http.Response) (Bl // are read from a URL. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - blockID - A valid Base64 string value that identifies the block. Prior to encoding, the string must be less than or equal // to 64 bytes in size. For a given blob, the length of the value specified for the blockid // parameter must be the same size for each block. @@ -810,7 +810,7 @@ func (client *BlockBlobClient) stageBlockFromURLHandleResponse(resp *http.Respon // the content of a block blob, use the Put Block List operation. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - contentLength - The length of the request. // - body - Initial data // - options - BlockBlobClientUploadOptions contains the optional parameters for the BlockBlobClient.Upload method. diff --git a/sdk/storage/azblob/internal/generated/zz_container_client.go b/sdk/storage/azblob/internal/generated/zz_container_client.go index ce1ff6fdd75e..dbc2a293ec67 100644 --- a/sdk/storage/azblob/internal/generated/zz_container_client.go +++ b/sdk/storage/azblob/internal/generated/zz_container_client.go @@ -34,7 +34,7 @@ type ContainerClient struct { // to 60 seconds, or can be infinite // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - duration - Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A non-infinite // lease can be between 15 and 60 seconds. A lease duration cannot be changed using // renew or change. @@ -129,7 +129,7 @@ func (client *ContainerClient) acquireLeaseHandleResponse(resp *http.Response) ( // to 60 seconds, or can be infinite // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - ContainerClientBreakLeaseOptions contains the optional parameters for the ContainerClient.BreakLease method. // - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the ContainerClient.Delete method. func (client *ContainerClient) BreakLease(ctx context.Context, options *ContainerClientBreakLeaseOptions, modifiedAccessConditions *ModifiedAccessConditions) (ContainerClientBreakLeaseResponse, error) { @@ -225,7 +225,7 @@ func (client *ContainerClient) breakLeaseHandleResponse(resp *http.Response) (Co // to 60 seconds, or can be infinite // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - leaseID - Specifies the current lease ID on the resource. // - proposedLeaseID - Proposed lease ID, in a GUID string format. The Blob service returns 400 (Invalid request) if the proposed // lease ID is not in the correct format. See Guid Constructor (String) for a list of valid GUID @@ -319,7 +319,7 @@ func (client *ContainerClient) changeLeaseHandleResponse(resp *http.Response) (C // fails // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - ContainerClientCreateOptions contains the optional parameters for the ContainerClient.Create method. // - ContainerCPKScopeInfo - ContainerCPKScopeInfo contains a group of parameters for the ContainerClient.Create method. func (client *ContainerClient) Create(ctx context.Context, options *ContainerClientCreateOptions, containerCPKScopeInfo *ContainerCPKScopeInfo) (ContainerClientCreateResponse, error) { @@ -412,7 +412,7 @@ func (client *ContainerClient) createHandleResponse(resp *http.Response) (Contai // deleted during garbage collection // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - ContainerClientDeleteOptions contains the optional parameters for the ContainerClient.Delete method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ContainerClient.GetProperties method. // - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the ContainerClient.Delete method. @@ -489,7 +489,7 @@ func (client *ContainerClient) deleteHandleResponse(resp *http.Response) (Contai // Filter blobs searches within the given container. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - where - Filters the results to return only to return only blobs whose tags match the specified expression. // - options - ContainerClientFilterBlobsOptions contains the optional parameters for the ContainerClient.FilterBlobs method. func (client *ContainerClient) FilterBlobs(ctx context.Context, where string, options *ContainerClientFilterBlobsOptions) (ContainerClientFilterBlobsResponse, error) { @@ -570,7 +570,7 @@ func (client *ContainerClient) filterBlobsHandleResponse(resp *http.Response) (C // be accessed publicly. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - ContainerClientGetAccessPolicyOptions contains the optional parameters for the ContainerClient.GetAccessPolicy // method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ContainerClient.GetProperties method. @@ -657,7 +657,7 @@ func (client *ContainerClient) getAccessPolicyHandleResponse(resp *http.Response // GetAccountInfo - Returns the sku name and account kind // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - ContainerClientGetAccountInfoOptions contains the optional parameters for the ContainerClient.GetAccountInfo // method. func (client *ContainerClient) GetAccountInfo(ctx context.Context, options *ContainerClientGetAccountInfoOptions) (ContainerClientGetAccountInfoResponse, error) { @@ -725,7 +725,7 @@ func (client *ContainerClient) getAccountInfoHandleResponse(resp *http.Response) // does not include the container's list of blobs // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - ContainerClientGetPropertiesOptions contains the optional parameters for the ContainerClient.GetProperties method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ContainerClient.GetProperties method. func (client *ContainerClient) GetProperties(ctx context.Context, options *ContainerClientGetPropertiesOptions, leaseAccessConditions *LeaseAccessConditions) (ContainerClientGetPropertiesResponse, error) { @@ -854,7 +854,7 @@ func (client *ContainerClient) getPropertiesHandleResponse(resp *http.Response) // NewListBlobFlatSegmentPager - [Update] The List Blobs operation returns a list of the blobs under the specified container // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - ContainerClientListBlobFlatSegmentOptions contains the optional parameters for the ContainerClient.NewListBlobFlatSegmentPager // method. // @@ -921,7 +921,7 @@ func (client *ContainerClient) ListBlobFlatSegmentHandleResponse(resp *http.Resp // NewListBlobHierarchySegmentPager - [Update] The List Blobs operation returns a list of the blobs under the specified container // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - delimiter - When the request includes this parameter, the operation returns a BlobPrefix element in the response body that // acts as a placeholder for all blobs whose names begin with the same substring up to the // appearance of the delimiter character. The delimiter may be a single character or a string. @@ -1014,7 +1014,7 @@ func (client *ContainerClient) ListBlobHierarchySegmentHandleResponse(resp *http // to 60 seconds, or can be infinite // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - leaseID - Specifies the current lease ID on the resource. // - options - ContainerClientReleaseLeaseOptions contains the optional parameters for the ContainerClient.ReleaseLease method. // - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the ContainerClient.Delete method. @@ -1100,7 +1100,7 @@ func (client *ContainerClient) releaseLeaseHandleResponse(resp *http.Response) ( // Rename - Renames an existing container. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - sourceContainerName - Required. Specifies the name of the container to rename. // - options - ContainerClientRenameOptions contains the optional parameters for the ContainerClient.Rename method. func (client *ContainerClient) Rename(ctx context.Context, sourceContainerName string, options *ContainerClientRenameOptions) (ContainerClientRenameResponse, error) { @@ -1172,7 +1172,7 @@ func (client *ContainerClient) renameHandleResponse(resp *http.Response) (Contai // to 60 seconds, or can be infinite // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - leaseID - Specifies the current lease ID on the resource. // - options - ContainerClientRenewLeaseOptions contains the optional parameters for the ContainerClient.RenewLease method. // - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the ContainerClient.Delete method. @@ -1261,7 +1261,7 @@ func (client *ContainerClient) renewLeaseHandleResponse(resp *http.Response) (Co // Restore - Restores a previously-deleted container. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - ContainerClientRestoreOptions contains the optional parameters for the ContainerClient.Restore method. func (client *ContainerClient) Restore(ctx context.Context, options *ContainerClientRestoreOptions) (ContainerClientRestoreResponse, error) { var err error @@ -1334,7 +1334,7 @@ func (client *ContainerClient) restoreHandleResponse(resp *http.Response) (Conta // may be accessed publicly. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - containerACL - the acls for the container // - options - ContainerClientSetAccessPolicyOptions contains the optional parameters for the ContainerClient.SetAccessPolicy // method. @@ -1433,7 +1433,7 @@ func (client *ContainerClient) setAccessPolicyHandleResponse(resp *http.Response // SetMetadata - operation sets one or more user-defined name-value pairs for the specified container. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - ContainerClientSetMetadataOptions contains the optional parameters for the ContainerClient.SetMetadata method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ContainerClient.GetProperties method. // - ModifiedAccessConditions - ModifiedAccessConditions contains a group of parameters for the ContainerClient.Delete method. @@ -1524,7 +1524,7 @@ func (client *ContainerClient) setMetadataHandleResponse(resp *http.Response) (C // SubmitBatch - The Batch operation allows multiple API calls to be embedded into a single HTTP request. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - contentLength - The length of the request. // - multipartContentType - Required. The value of this header must be multipart/mixed with a batch boundary. Example header // value: multipart/mixed; boundary=batch_ diff --git a/sdk/storage/azblob/internal/generated/zz_pageblob_client.go b/sdk/storage/azblob/internal/generated/zz_pageblob_client.go index bfa9883f5ce7..cb6a19f7a335 100644 --- a/sdk/storage/azblob/internal/generated/zz_pageblob_client.go +++ b/sdk/storage/azblob/internal/generated/zz_pageblob_client.go @@ -30,7 +30,7 @@ type PageBlobClient struct { // ClearPages - The Clear Pages operation clears a set of pages from a page blob // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - contentLength - The length of the request. // - options - PageBlobClientClearPagesOptions contains the optional parameters for the PageBlobClient.ClearPages method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ContainerClient.GetProperties method. @@ -181,7 +181,7 @@ func (client *PageBlobClient) clearPagesHandleResponse(resp *http.Response) (Pag // 2016-05-31. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - copySource - Specifies the name of the source page blob snapshot. This value is a URL of up to 2 KB in length that specifies // a page blob snapshot. The value should be URL-encoded as it would appear in a request // URI. The source blob must either be public or must be authenticated via a shared access signature. @@ -283,7 +283,7 @@ func (client *PageBlobClient) copyIncrementalHandleResponse(resp *http.Response) // Create - The Create operation creates a new page blob. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - contentLength - The length of the request. // - blobContentLength - This header specifies the maximum size for the page blob, up to 1 TB. The page blob size must be aligned // to a 512-byte boundary. @@ -464,7 +464,7 @@ func (client *PageBlobClient) createHandleResponse(resp *http.Response) (PageBlo // NewGetPageRangesPager - The Get Page Ranges operation returns the list of valid page ranges for a page blob or snapshot // of a page blob // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - PageBlobClientGetPageRangesOptions contains the optional parameters for the PageBlobClient.NewGetPageRangesPager // method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ContainerClient.GetProperties method. @@ -585,7 +585,7 @@ func (client *PageBlobClient) GetPageRangesHandleResponse(resp *http.Response) ( // NewGetPageRangesDiffPager - The Get Page Ranges Diff operation returns the list of valid page ranges for a page blob that // were changed between target blob and previous snapshot. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - PageBlobClientGetPageRangesDiffOptions contains the optional parameters for the PageBlobClient.NewGetPageRangesDiffPager // method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ContainerClient.GetProperties method. @@ -712,7 +712,7 @@ func (client *PageBlobClient) GetPageRangesDiffHandleResponse(resp *http.Respons // Resize - Resize the Blob // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - blobContentLength - This header specifies the maximum size for the page blob, up to 1 TB. The page blob size must be aligned // to a 512-byte boundary. // - options - PageBlobClientResizeOptions contains the optional parameters for the PageBlobClient.Resize method. @@ -831,7 +831,7 @@ func (client *PageBlobClient) resizeHandleResponse(resp *http.Response) (PageBlo // UpdateSequenceNumber - Update the sequence number of the blob // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - sequenceNumberAction - Required if the x-ms-blob-sequence-number header is set for the request. This property applies to // page blobs only. This property indicates how the service should modify the blob's sequence number // - options - PageBlobClientUpdateSequenceNumberOptions contains the optional parameters for the PageBlobClient.UpdateSequenceNumber @@ -940,7 +940,7 @@ func (client *PageBlobClient) updateSequenceNumberHandleResponse(resp *http.Resp // UploadPages - The Upload Pages operation writes a range of pages to a page blob // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - contentLength - The length of the request. // - body - Initial data // - options - PageBlobClientUploadPagesOptions contains the optional parameters for the PageBlobClient.UploadPages method. @@ -1111,7 +1111,7 @@ func (client *PageBlobClient) uploadPagesHandleResponse(resp *http.Response) (Pa // a URL // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - sourceURL - Specify a URL to the copy source. // - sourceRange - Bytes of source data in the specified range. The length of this range should match the ContentLength header // and x-ms-range/Range destination range header. diff --git a/sdk/storage/azblob/internal/generated/zz_service_client.go b/sdk/storage/azblob/internal/generated/zz_service_client.go index 9a73b7301b17..c792fbf094bf 100644 --- a/sdk/storage/azblob/internal/generated/zz_service_client.go +++ b/sdk/storage/azblob/internal/generated/zz_service_client.go @@ -33,7 +33,7 @@ type ServiceClient struct { // be scoped within the expression to a single container. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - where - Filters the results to return only to return only blobs whose tags match the specified expression. // - options - ServiceClientFilterBlobsOptions contains the optional parameters for the ServiceClient.FilterBlobs method. func (client *ServiceClient) FilterBlobs(ctx context.Context, where string, options *ServiceClientFilterBlobsOptions) (ServiceClientFilterBlobsResponse, error) { @@ -112,7 +112,7 @@ func (client *ServiceClient) filterBlobsHandleResponse(resp *http.Response) (Ser // GetAccountInfo - Returns the sku name and account kind // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - ServiceClientGetAccountInfoOptions contains the optional parameters for the ServiceClient.GetAccountInfo method. func (client *ServiceClient) GetAccountInfo(ctx context.Context, options *ServiceClientGetAccountInfoOptions) (ServiceClientGetAccountInfoResponse, error) { var err error @@ -186,7 +186,7 @@ func (client *ServiceClient) getAccountInfoHandleResponse(resp *http.Response) ( // CORS (Cross-Origin Resource Sharing) rules. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - ServiceClientGetPropertiesOptions contains the optional parameters for the ServiceClient.GetProperties method. func (client *ServiceClient) GetProperties(ctx context.Context, options *ServiceClientGetPropertiesOptions) (ServiceClientGetPropertiesResponse, error) { var err error @@ -249,7 +249,7 @@ func (client *ServiceClient) getPropertiesHandleResponse(resp *http.Response) (S // location endpoint when read-access geo-redundant replication is enabled for the storage account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - ServiceClientGetStatisticsOptions contains the optional parameters for the ServiceClient.GetStatistics method. func (client *ServiceClient) GetStatistics(ctx context.Context, options *ServiceClientGetStatisticsOptions) (ServiceClientGetStatisticsResponse, error) { var err error @@ -319,7 +319,7 @@ func (client *ServiceClient) getStatisticsHandleResponse(resp *http.Response) (S // bearer token authentication. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - keyInfo - Key information // - options - ServiceClientGetUserDelegationKeyOptions contains the optional parameters for the ServiceClient.GetUserDelegationKey // method. @@ -393,7 +393,7 @@ func (client *ServiceClient) getUserDelegationKeyHandleResponse(resp *http.Respo // NewListContainersSegmentPager - The List Containers Segment operation returns a list of the containers under the specified // account // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - options - ServiceClientListContainersSegmentOptions contains the optional parameters for the ServiceClient.NewListContainersSegmentPager // method. // @@ -451,7 +451,7 @@ func (client *ServiceClient) ListContainersSegmentHandleResponse(resp *http.Resp // and CORS (Cross-Origin Resource Sharing) rules // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - storageServiceProperties - The StorageService properties. // - options - ServiceClientSetPropertiesOptions contains the optional parameters for the ServiceClient.SetProperties method. func (client *ServiceClient) SetProperties(ctx context.Context, storageServiceProperties StorageServiceProperties, options *ServiceClientSetPropertiesOptions) (ServiceClientSetPropertiesResponse, error) { @@ -514,7 +514,7 @@ func (client *ServiceClient) setPropertiesHandleResponse(resp *http.Response) (S // SubmitBatch - The Batch operation allows multiple API calls to be embedded into a single HTTP request. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2023-08-03 +// Generated from API version 2023-11-03 // - contentLength - The length of the request. // - multipartContentType - Required. The value of this header must be multipart/mixed with a batch boundary. Example header // value: multipart/mixed; boundary=batch_ diff --git a/sdk/storage/azblob/internal/shared/challenge_policy.go b/sdk/storage/azblob/internal/shared/challenge_policy.go index e7c8e9213d80..1c81b9db9b86 100644 --- a/sdk/storage/azblob/internal/shared/challenge_policy.go +++ b/sdk/storage/azblob/internal/shared/challenge_policy.go @@ -20,9 +20,9 @@ type storageAuthorizer struct { tenantID string } -func NewStorageChallengePolicy(cred azcore.TokenCredential) policy.Policy { - s := storageAuthorizer{scopes: []string{TokenScope}} - return runtime.NewBearerTokenPolicy(cred, []string{TokenScope}, &policy.BearerTokenOptions{ +func NewStorageChallengePolicy(cred azcore.TokenCredential, audience string) policy.Policy { + s := storageAuthorizer{scopes: []string{audience}} + return runtime.NewBearerTokenPolicy(cred, []string{audience}, &policy.BearerTokenOptions{ AuthorizationHandler: policy.AuthorizationHandler{ OnRequest: s.onRequest, OnChallenge: s.onChallenge, diff --git a/sdk/storage/azblob/internal/shared/challenge_policy_test.go b/sdk/storage/azblob/internal/shared/challenge_policy_test.go index f666947ef9c7..b6d16853d3c8 100644 --- a/sdk/storage/azblob/internal/shared/challenge_policy_test.go +++ b/sdk/storage/azblob/internal/shared/challenge_policy_test.go @@ -39,7 +39,7 @@ func TestChallengePolicyStorage(t *testing.T) { require.Equal(t, []string{storageScope}, tro.Scopes) return azcore.AccessToken{Token: accessToken, ExpiresOn: time.Now().Add(time.Hour)}, nil }) - p := NewStorageChallengePolicy(cred) + p := NewStorageChallengePolicy(cred, storageScope) pl := runtime.NewPipeline("", "", runtime.PipelineOptions{PerRetry: []policy.Policy{p}}, &policy.ClientOptions{Transport: srv}, @@ -77,7 +77,7 @@ func TestChallengePolicyDisk(t *testing.T) { attemptedAuthentication = true return azcore.AccessToken{}, nil }) - p := NewStorageChallengePolicy(cred) + p := NewStorageChallengePolicy(cred, "https://storage.azure.com/.default") pl := runtime.NewPipeline("", "", runtime.PipelineOptions{PerRetry: []policy.Policy{p}}, &policy.ClientOptions{Transport: srv}, diff --git a/sdk/storage/azblob/pageblob/client.go b/sdk/storage/azblob/pageblob/client.go index 14e90a1fd66e..1d62487c9104 100644 --- a/sdk/storage/azblob/pageblob/client.go +++ b/sdk/storage/azblob/pageblob/client.go @@ -36,7 +36,8 @@ type Client base.CompositeClient[generated.BlobClient, generated.PageBlobClient] // - cred - an Azure AD credential, typically obtained via the azidentity module // - options - client options; pass nil to accept the default values func NewClient(blobURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { - authPolicy := shared.NewStorageChallengePolicy(cred) + audience := base.GetAudience((*base.ClientOptions)(options)) + authPolicy := shared.NewStorageChallengePolicy(cred, audience) conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}} diff --git a/sdk/storage/azblob/pageblob/client_test.go b/sdk/storage/azblob/pageblob/client_test.go index 3a0b250bcde0..6712f19be6dc 100644 --- a/sdk/storage/azblob/pageblob/client_test.go +++ b/sdk/storage/azblob/pageblob/client_test.go @@ -4929,3 +4929,71 @@ func (s *PageBlobRecordedTestsSuite) TestPageGetAccountInfo() { _require.NoError(err) _require.NotZero(bAccInfo) } + +func (s *PageBlobRecordedTestsSuite) TestPageBlobClientDefaultAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient) + defer testcommon.DeleteContainer(context.Background(), _require, containerClient) + + blobName := testcommon.GenerateBlobName(testName) + blobURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s/%s", accountName, containerName, blobName) + + options := &pageblob.ClientOptions{ + Audience: "https://storage.azure.com/", + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + pbClientAudience, err := pageblob.NewClient(blobURL, cred, options) + _require.NoError(err) + + _, err = pbClientAudience.Create(context.Background(), pageblob.PageBytes*10, nil) + _require.NoError(err) + + _, err = pbClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} + +func (s *PageBlobRecordedTestsSuite) TestPageBlobClientCustomAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + containerClient := testcommon.CreateNewContainer(context.Background(), _require, containerName, svcClient) + defer testcommon.DeleteContainer(context.Background(), _require, containerClient) + + blobName := testcommon.GenerateBlobName(testName) + blobURL := fmt.Sprintf("https://%s.blob.core.windows.net/%s/%s", accountName, containerName, blobName) + + options := &pageblob.ClientOptions{ + Audience: "https://" + accountName + ".blob.core.windows.net", + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + pbClientAudience, err := pageblob.NewClient(blobURL, cred, options) + _require.NoError(err) + + _, err = pbClientAudience.Create(context.Background(), pageblob.PageBytes*10, nil) + _require.NoError(err) + + _, err = pbClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} diff --git a/sdk/storage/azblob/service/client.go b/sdk/storage/azblob/service/client.go index 461775347eeb..bcd10a4be864 100644 --- a/sdk/storage/azblob/service/client.go +++ b/sdk/storage/azblob/service/client.go @@ -40,7 +40,8 @@ type Client base.Client[generated.ServiceClient] // - cred - an Azure AD credential, typically obtained via the azidentity module // - options - client options; pass nil to accept the default values func NewClient(serviceURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { - authPolicy := shared.NewStorageChallengePolicy(cred) + audience := base.GetAudience((*base.ClientOptions)(options)) + authPolicy := shared.NewStorageChallengePolicy(cred, audience) conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}} @@ -48,7 +49,7 @@ func NewClient(serviceURL string, cred azcore.TokenCredential, options *ClientOp if err != nil { return nil, err } - return (*Client)(base.NewServiceClient(serviceURL, azClient, &cred)), nil + return (*Client)(base.NewServiceClient(serviceURL, azClient, &cred, (*base.ClientOptions)(conOptions))), nil } // NewClientWithNoCredential creates an instance of Client with the specified values. @@ -62,7 +63,7 @@ func NewClientWithNoCredential(serviceURL string, options *ClientOptions) (*Clie if err != nil { return nil, err } - return (*Client)(base.NewServiceClient(serviceURL, azClient, nil)), nil + return (*Client)(base.NewServiceClient(serviceURL, azClient, nil, (*base.ClientOptions)(conOptions))), nil } // NewClientWithSharedKeyCredential creates an instance of Client with the specified values. @@ -79,7 +80,7 @@ func NewClientWithSharedKeyCredential(serviceURL string, cred *SharedKeyCredenti return nil, err } - return (*Client)(base.NewServiceClient(serviceURL, azClient, cred)), nil + return (*Client)(base.NewServiceClient(serviceURL, azClient, cred, (*base.ClientOptions)(conOptions))), nil } // NewClientFromConnectionString creates an instance of Client with the specified values. @@ -136,6 +137,10 @@ func getGeneratedBlobClient(b *blob.Client) *generated.BlobClient { return base.InnerClient((*base.Client[generated.BlobClient])(b)) } +func (s *Client) getClientOptions() *base.ClientOptions { + return base.GetClientOptions((*base.Client[generated.ServiceClient])(s)) +} + // URL returns the URL endpoint used by the Client object. func (s *Client) URL() string { return s.generated().Endpoint() @@ -145,7 +150,7 @@ func (s *Client) URL() string { // this Client's URL. The new container.Client uses the same request policy pipeline as the Client. func (s *Client) NewContainerClient(containerName string) *container.Client { containerURL := runtime.JoinPaths(s.generated().Endpoint(), containerName) - return (*container.Client)(base.NewContainerClient(containerURL, s.generated().InternalClient().WithClientName(shared.ContainerClient), s.credential())) + return (*container.Client)(base.NewContainerClient(containerURL, s.generated().InternalClient().WithClientName(shared.ContainerClient), s.credential(), s.getClientOptions())) } // CreateContainer is a lifecycle method to creates a new container under the specified account. @@ -315,7 +320,7 @@ func (s *Client) NewBatchBuilder() (*BatchBuilder, error) { switch cred := s.credential().(type) { case *azcore.TokenCredential: - authPolicy = shared.NewStorageChallengePolicy(*cred) + authPolicy = shared.NewStorageChallengePolicy(*cred, base.GetAudience(s.getClientOptions())) case *SharedKeyCredential: authPolicy = exported.NewSharedKeyCredPolicy(cred) case nil: diff --git a/sdk/storage/azblob/service/client_test.go b/sdk/storage/azblob/service/client_test.go index 78c7b6c0ff88..0449197a4013 100644 --- a/sdk/storage/azblob/service/client_test.go +++ b/sdk/storage/azblob/service/client_test.go @@ -1809,3 +1809,79 @@ func (s *ServiceUnrecordedTestsSuite) TestServiceBlobBatchErrors() { _, err = svcClient.SubmitBatch(context.Background(), nil, nil) _require.Error(err) } + +func (s *ServiceRecordedTestsSuite) TestServiceClientDefaultAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + options := &service.ClientOptions{ + Audience: "https://storage.azure.com/", + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + svcClientAudience, err := service.NewClient("https://"+accountName+".blob.core.windows.net/", cred, options) + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + _, err = svcClientAudience.CreateContainer(context.Background(), containerName, nil) + _require.NoError(err) + + defer func() { + _, err = svcClientAudience.DeleteContainer(context.Background(), containerName, nil) + _require.NoError(err) + }() + + pager := svcClientAudience.NewListContainersPager(&service.ListContainersOptions{ + Prefix: &containerName, + }) + for pager.More() { + resp, err := pager.NextPage(context.Background()) + _require.NoError(err) + _require.Equal(len(resp.ContainerItems), 1) + _require.NotNil(resp.ContainerItems[0].Name) + _require.Equal(*resp.ContainerItems[0].Name, containerName) + } +} + +func (s *ServiceRecordedTestsSuite) TestServiceClientCustomAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + options := &service.ClientOptions{ + Audience: "https://" + accountName + ".blob.core.windows.net", + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + svcClientAudience, err := service.NewClient("https://"+accountName+".blob.core.windows.net/", cred, options) + _require.NoError(err) + + containerName := testcommon.GenerateContainerName(testName) + _, err = svcClientAudience.CreateContainer(context.Background(), containerName, nil) + _require.NoError(err) + + defer func() { + _, err = svcClientAudience.DeleteContainer(context.Background(), containerName, nil) + _require.NoError(err) + }() + + pager := svcClientAudience.NewListContainersPager(&service.ListContainersOptions{ + Prefix: &containerName, + }) + for pager.More() { + resp, err := pager.NextPage(context.Background()) + _require.NoError(err) + _require.Equal(len(resp.ContainerItems), 1) + _require.NotNil(resp.ContainerItems[0].Name) + _require.Equal(*resp.ContainerItems[0].Name, containerName) + } +} From 7f7c19bd79f98dd706a6cef7dd4d2689419309f2 Mon Sep 17 00:00:00 2001 From: Sourav Gupta <98318303+souravgupta-msft@users.noreply.github.com> Date: Fri, 5 Jan 2024 10:56:35 +0530 Subject: [PATCH 05/32] azfile: STG91 upgrade (#22193) --- sdk/storage/azfile/CHANGELOG.md | 5 + sdk/storage/azfile/README.md | 2 +- sdk/storage/azfile/assets.json | 2 +- sdk/storage/azfile/directory/client.go | 3 +- sdk/storage/azfile/directory/client_test.go | 123 +- sdk/storage/azfile/file/client.go | 3 +- sdk/storage/azfile/file/client_test.go | 334 +++++- sdk/storage/azfile/file/examples_test.go | 3 +- sdk/storage/azfile/internal/base/clients.go | 29 +- .../azfile/internal/generated/autorest.md | 21 +- .../azfile/internal/generated/constants.go | 9 + .../azfile/internal/generated/models.go | 14 +- .../azfile/internal/generated/zz_constants.go | 21 +- .../internal/generated/zz_directory_client.go | 463 ++++---- .../internal/generated/zz_file_client.go | 1004 +++++++++-------- .../azfile/internal/generated/zz_models.go | 725 +----------- .../internal/generated/zz_models_serde.go | 69 +- .../azfile/internal/generated/zz_options.go | 852 ++++++++++++++ .../internal/generated/zz_response_types.go | 83 +- .../internal/generated/zz_service_client.go | 37 +- .../internal/generated/zz_share_client.go | 636 ++++++----- .../internal/generated/zz_time_rfc1123.go | 23 +- .../internal/generated/zz_time_rfc3339.go | 35 +- .../internal/generated/zz_xml_helper.go | 26 +- sdk/storage/azfile/service/client.go | 3 +- sdk/storage/azfile/service/client_test.go | 35 + sdk/storage/azfile/share/client.go | 3 +- sdk/storage/azfile/share/client_test.go | 105 ++ 28 files changed, 2780 insertions(+), 1888 deletions(-) create mode 100644 sdk/storage/azfile/internal/generated/constants.go create mode 100644 sdk/storage/azfile/internal/generated/zz_options.go diff --git a/sdk/storage/azfile/CHANGELOG.md b/sdk/storage/azfile/CHANGELOG.md index 390a176fd2a2..973dbcf87a93 100644 --- a/sdk/storage/azfile/CHANGELOG.md +++ b/sdk/storage/azfile/CHANGELOG.md @@ -5,10 +5,15 @@ ### Features Added +* Updated service version to `2023-11-03`. +* Added support for Audience when OAuth is used. + ### Breaking Changes ### Bugs Fixed +* Fixed a bug where `UploadRangeFromURL` using OAuth was returning error. + ### Other Changes diff --git a/sdk/storage/azfile/README.md b/sdk/storage/azfile/README.md index 9d543493bf30..67e9d5c360ec 100644 --- a/sdk/storage/azfile/README.md +++ b/sdk/storage/azfile/README.md @@ -1,6 +1,6 @@ # Azure File Storage SDK for Go -> Service Version: 2022-11-02 +> Service Version: 2023-11-03 Azure File Shares offers fully managed file shares in the cloud that are accessible via the industry standard [Server Message Block (SMB) protocol](https://docs.microsoft.com/windows/desktop/FileIO/microsoft-smb-protocol-and-cifs-protocol-overview). diff --git a/sdk/storage/azfile/assets.json b/sdk/storage/azfile/assets.json index 68320e470010..4c4caf344b81 100644 --- a/sdk/storage/azfile/assets.json +++ b/sdk/storage/azfile/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/storage/azfile", - "Tag": "go/storage/azfile_f1d39931a0" + "Tag": "go/storage/azfile_f80b868396" } diff --git a/sdk/storage/azfile/directory/client.go b/sdk/storage/azfile/directory/client.go index 34af659ddcc5..dc90bf7d8fd6 100644 --- a/sdk/storage/azfile/directory/client.go +++ b/sdk/storage/azfile/directory/client.go @@ -36,7 +36,8 @@ type Client base.Client[generated.DirectoryClient] // // Note that ClientOptions.FileRequestIntent is currently required for token authentication. func NewClient(directoryURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { - authPolicy := runtime.NewBearerTokenPolicy(cred, []string{shared.TokenScope}, nil) + audience := base.GetAudience((*base.ClientOptions)(options)) + authPolicy := runtime.NewBearerTokenPolicy(cred, []string{audience}, nil) conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{ PerRetry: []policy.Policy{authPolicy}, diff --git a/sdk/storage/azfile/directory/client_test.go b/sdk/storage/azfile/directory/client_test.go index fe4475d706be..c2b7dc12df25 100644 --- a/sdk/storage/azfile/directory/client_test.go +++ b/sdk/storage/azfile/directory/client_test.go @@ -39,27 +39,27 @@ func Test(t *testing.T) { } } -func (s *DirectoryRecordedTestsSuite) SetupSuite() { - s.proxy = testcommon.SetupSuite(&s.Suite) +func (d *DirectoryRecordedTestsSuite) SetupSuite() { + d.proxy = testcommon.SetupSuite(&d.Suite) } -func (s *DirectoryRecordedTestsSuite) TearDownSuite() { - testcommon.TearDownSuite(&s.Suite, s.proxy) +func (d *DirectoryRecordedTestsSuite) TearDownSuite() { + testcommon.TearDownSuite(&d.Suite, d.proxy) } -func (s *DirectoryRecordedTestsSuite) BeforeTest(suite string, test string) { - testcommon.BeforeTest(s.T(), suite, test) +func (d *DirectoryRecordedTestsSuite) BeforeTest(suite string, test string) { + testcommon.BeforeTest(d.T(), suite, test) } -func (s *DirectoryRecordedTestsSuite) AfterTest(suite string, test string) { - testcommon.AfterTest(s.T(), suite, test) +func (d *DirectoryRecordedTestsSuite) AfterTest(suite string, test string) { + testcommon.AfterTest(d.T(), suite, test) } -func (s *DirectoryUnrecordedTestsSuite) BeforeTest(suite string, test string) { +func (d *DirectoryUnrecordedTestsSuite) BeforeTest(suite string, test string) { } -func (s *DirectoryUnrecordedTestsSuite) AfterTest(suite string, test string) { +func (d *DirectoryUnrecordedTestsSuite) AfterTest(suite string, test string) { } @@ -2264,3 +2264,106 @@ func (d *DirectoryRecordedTestsSuite) TestListFileDirEncodedPrefix() { _require.Equal(*resp.Prefix, dirName) } } + +func (d *DirectoryRecordedTestsSuite) TestDirectoryClientDefaultAudience() { + _require := require.New(d.T()) + testName := d.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(d.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + dirName := testcommon.GenerateDirectoryName(testName) + dirURL := "https://" + accountName + ".file.core.windows.net/" + shareName + "/" + dirName + + options := &directory.ClientOptions{ + FileRequestIntent: to.Ptr(directory.ShareTokenIntentBackup), + Audience: "https://storage.azure.com/", + } + testcommon.SetClientOptions(d.T(), &options.ClientOptions) + dirClientAudience, err := directory.NewClient(dirURL, cred, options) + _require.NoError(err) + + _, err = dirClientAudience.Create(context.Background(), nil) + _require.NoError(err) + + _, err = dirClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} + +func (d *DirectoryRecordedTestsSuite) TestDirectoryClientCustomAudience() { + _require := require.New(d.T()) + testName := d.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(d.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + dirName := testcommon.GenerateDirectoryName(testName) + dirURL := "https://" + accountName + ".file.core.windows.net/" + shareName + "/" + dirName + + options := &directory.ClientOptions{ + FileRequestIntent: to.Ptr(directory.ShareTokenIntentBackup), + Audience: "https://" + accountName + ".file.core.windows.net", + } + testcommon.SetClientOptions(d.T(), &options.ClientOptions) + dirClientAudience, err := directory.NewClient(dirURL, cred, options) + _require.NoError(err) + + _, err = dirClientAudience.Create(context.Background(), nil) + _require.NoError(err) + + _, err = dirClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} + +func (d *DirectoryRecordedTestsSuite) TestDirectoryAudienceNegative() { + _require := require.New(d.T()) + testName := d.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(d.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + dirName := testcommon.GenerateDirectoryName(testName) + dirURL := "https://" + accountName + ".file.core.windows.net/" + shareName + "/" + dirName + + options := &directory.ClientOptions{ + FileRequestIntent: to.Ptr(directory.ShareTokenIntentBackup), + Audience: "https://badaudience.file.core.windows.net", + } + testcommon.SetClientOptions(d.T(), &options.ClientOptions) + dirClientAudience, err := directory.NewClient(dirURL, cred, options) + _require.NoError(err) + + _, err = dirClientAudience.Create(context.Background(), nil) + _require.Error(err) + testcommon.ValidateFileErrorCode(_require, err, fileerror.AuthenticationFailed) +} diff --git a/sdk/storage/azfile/file/client.go b/sdk/storage/azfile/file/client.go index f1d0d3232af8..fc712327fc73 100644 --- a/sdk/storage/azfile/file/client.go +++ b/sdk/storage/azfile/file/client.go @@ -41,7 +41,8 @@ type Client base.Client[generated.FileClient] // // Note that ClientOptions.FileRequestIntent is currently required for token authentication. func NewClient(fileURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { - authPolicy := runtime.NewBearerTokenPolicy(cred, []string{shared.TokenScope}, nil) + audience := base.GetAudience((*base.ClientOptions)(options)) + authPolicy := runtime.NewBearerTokenPolicy(cred, []string{audience}, nil) conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{ PerRetry: []policy.Policy{authPolicy}, diff --git a/sdk/storage/azfile/file/client_test.go b/sdk/storage/azfile/file/client_test.go index bab8724fa4ec..c98c4d04ef6b 100644 --- a/sdk/storage/azfile/file/client_test.go +++ b/sdk/storage/azfile/file/client_test.go @@ -20,6 +20,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/file" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/fileerror" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/shared" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/testcommon" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/lease" @@ -30,7 +31,6 @@ import ( "github.com/stretchr/testify/suite" "hash/crc64" "io" - "io/ioutil" "net/http" "os" "strings" @@ -51,27 +51,27 @@ func Test(t *testing.T) { } } -func (s *FileRecordedTestsSuite) SetupSuite() { - s.proxy = testcommon.SetupSuite(&s.Suite) +func (f *FileRecordedTestsSuite) SetupSuite() { + f.proxy = testcommon.SetupSuite(&f.Suite) } -func (s *FileRecordedTestsSuite) TearDownSuite() { - testcommon.TearDownSuite(&s.Suite, s.proxy) +func (f *FileRecordedTestsSuite) TearDownSuite() { + testcommon.TearDownSuite(&f.Suite, f.proxy) } -func (s *FileRecordedTestsSuite) BeforeTest(suite string, test string) { - testcommon.BeforeTest(s.T(), suite, test) +func (f *FileRecordedTestsSuite) BeforeTest(suite string, test string) { + testcommon.BeforeTest(f.T(), suite, test) } -func (s *FileRecordedTestsSuite) AfterTest(suite string, test string) { - testcommon.AfterTest(s.T(), suite, test) +func (f *FileRecordedTestsSuite) AfterTest(suite string, test string) { + testcommon.AfterTest(f.T(), suite, test) } -func (s *FileUnrecordedTestsSuite) BeforeTest(suite string, test string) { +func (f *FileUnrecordedTestsSuite) BeforeTest(suite string, test string) { } -func (s *FileUnrecordedTestsSuite) AfterTest(suite string, test string) { +func (f *FileUnrecordedTestsSuite) AfterTest(suite string, test string) { } @@ -890,7 +890,7 @@ func (f *FileRecordedTestsSuite) TestFileStartCopyDestEmpty() { _require.NoError(err) // Read the file data to verify the copy - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) defer func() { err = resp.Body.Close() _require.NoError(err) @@ -1490,7 +1490,7 @@ func (f *FileUnrecordedTestsSuite) TestFileStartCopyUsingSASSrc() { dResp, err := copyFileClient.DownloadStream(context.Background(), nil) _require.NoError(err) - data, err := ioutil.ReadAll(dResp.Body) + data, err := io.ReadAll(dResp.Body) defer func() { err = dResp.Body.Close() _require.NoError(err) @@ -1927,7 +1927,76 @@ func (f *FileUnrecordedTestsSuite) TestFileUploadRangeFromURLCopySourceAuthBlob( }) _require.NoError(err) - data, err := ioutil.ReadAll(dResp.Body) + data, err := io.ReadAll(dResp.Body) + defer func() { + err = dResp.Body.Close() + _require.NoError(err) + }() + + _require.EqualValues(data, content) +} + +func (f *FileUnrecordedTestsSuite) TestFileUploadRangeFromURLCopySourceAuthFile() { + _require := require.New(f.T()) + testName := f.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + // Getting token + accessToken, err := cred.GetToken(context.Background(), policy.TokenRequestOptions{Scopes: []string{"https://storage.azure.com/.default"}}) + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(f.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + var fileSize int64 = 1024 * 10 + contentSize := 1024 * 8 // 8KB + _, content := testcommon.GenerateData(contentSize) + body := bytes.NewReader(content) + rsc := streaming.NopCloser(body) + contentCRC64 := crc64.Checksum(content, shared.CRC64Table) + + srcFClient := shareClient.NewRootDirectoryClient().NewFileClient("src" + testcommon.GenerateFileName(testName)) + _, err = srcFClient.Create(context.Background(), fileSize, nil) + _require.NoError(err) + + gResp, err := srcFClient.GetProperties(context.Background(), nil) + _require.NoError(err) + _require.Equal(*gResp.ContentLength, fileSize) + + _, err = srcFClient.UploadRange(context.Background(), 0, rsc, nil) + _require.NoError(err) + + destFileURL := "https://" + accountName + ".file.core.windows.net/" + shareName + "/dest" + testcommon.GenerateFileName(testName) + destFClient, err := file.NewClient(destFileURL, cred, &file.ClientOptions{FileRequestIntent: to.Ptr(file.ShareTokenIntentBackup)}) + _require.NoError(err) + + _, err = destFClient.Create(context.Background(), fileSize, nil) + _require.NoError(err) + + uResp, err := destFClient.UploadRangeFromURL(context.Background(), srcFClient.URL(), 0, 0, int64(contentSize), &file.UploadRangeFromURLOptions{ + SourceContentValidation: file.SourceContentValidationTypeCRC64(contentCRC64), + CopySourceAuthorization: to.Ptr("Bearer " + accessToken.Token), + }) + _require.NoError(err) + _require.NotNil(uResp.XMSContentCRC64) + _require.EqualValues(binary.LittleEndian.Uint64(uResp.XMSContentCRC64), contentCRC64) + + // validate the content uploaded + dResp, err := destFClient.DownloadStream(context.Background(), &file.DownloadStreamOptions{ + Range: file.HTTPRange{Offset: 0, Count: int64(contentSize)}, + }) + _require.NoError(err) + + data, err := io.ReadAll(dResp.Body) defer func() { err = dResp.Body.Close() _require.NoError(err) @@ -2078,7 +2147,7 @@ func (f *FileUnrecordedTestsSuite) TestFileUploadFile() { content := make([]byte, fileSize) _, err = rand.Read(content) _require.NoError(err) - err = ioutil.WriteFile("testFile", content, 0644) + err = os.WriteFile("testFile", content, 0644) _require.NoError(err) defer func() { @@ -2339,7 +2408,7 @@ func (f *FileRecordedTestsSuite) TestUploadDownloadDefaultNonDefaultMD5() { _require.NotNil(resp.ContentMD5) _require.Equal(*resp.ContentType, "application/octet-stream") - downloadedData, err := ioutil.ReadAll(resp.Body) + downloadedData, err := io.ReadAll(resp.Body) _require.NoError(err) _require.EqualValues(downloadedData, contentD[:1024]) @@ -2362,7 +2431,7 @@ func (f *FileRecordedTestsSuite) TestUploadDownloadDefaultNonDefaultMD5() { _require.Equal(*resp.ContentLanguage, "test") // Note: when it's downloading range, range's MD5 is returned, when set rangeGetContentMD5=true, currently set it to false, so should be empty - downloadedData, err = ioutil.ReadAll(resp.Body) + downloadedData, err = io.ReadAll(resp.Body) _require.NoError(err) _require.EqualValues(downloadedData, contentD[1024:]) @@ -2392,7 +2461,7 @@ func (f *FileRecordedTestsSuite) TestUploadDownloadDefaultNonDefaultMD5() { _require.EqualValues(resp.ContentMD5, pResp.ContentMD5) // Note: This case is inted to get entire fClient, entire file's MD5 will be returned. _require.Nil(resp.FileContentMD5) // Note: FileContentMD5 is returned, only when range is specified explicitly. - downloadedData, err = ioutil.ReadAll(resp.Body) + downloadedData, err = io.ReadAll(resp.Body) _require.NoError(err) _require.EqualValues(downloadedData, contentD[:]) @@ -2470,7 +2539,7 @@ func (f *FileRecordedTestsSuite) TestFileDownloadDataEntireFile() { _require.NoError(err) // Specifying a count of 0 results in the value being ignored - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) _require.NoError(err) _require.EqualValues(string(data), testcommon.FileDefaultData) } @@ -2495,7 +2564,7 @@ func (f *FileRecordedTestsSuite) TestFileDownloadDataCountExact() { }) _require.NoError(err) - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) _require.NoError(err) _require.EqualValues(string(data), testcommon.FileDefaultData) } @@ -2520,7 +2589,7 @@ func (f *FileRecordedTestsSuite) TestFileDownloadDataCountOutOfRange() { }) _require.NoError(err) - data, err := ioutil.ReadAll(resp.Body) + data, err := io.ReadAll(resp.Body) _require.NoError(err) _require.EqualValues(string(data), testcommon.FileDefaultData) } @@ -2612,7 +2681,7 @@ func (f *FileRecordedTestsSuite) TestFileUploadRangeTransactionalMD5() { _require.NoError(err) _require.Equal(*resp.ContentLength, int64(2048)) - downloadedData, err := ioutil.ReadAll(resp.Body) + downloadedData, err := io.ReadAll(resp.Body) _require.NoError(err) _require.EqualValues(downloadedData, contentD[:]) } @@ -2853,7 +2922,7 @@ func (f *FileRecordedTestsSuite) TestClearRangeNonDefaultCount() { dResp, err := fClient.DownloadStream(context.Background(), nil) _require.NoError(err) - _bytes, err := ioutil.ReadAll(dResp.Body) + _bytes, err := io.ReadAll(dResp.Body) _require.NoError(err) _require.EqualValues(_bytes, []byte{0}) } @@ -3093,7 +3162,7 @@ func (f *FileRecordedTestsSuite) TestFileUploadDownloadSmallFile() { // create local file _, content := testcommon.GenerateData(int(fileSize)) srcFileName := "testFileUpload" - err = ioutil.WriteFile(srcFileName, content, 0644) + err = os.WriteFile(srcFileName, content, 0644) _require.NoError(err) defer func() { err = os.Remove(srcFileName) @@ -3612,6 +3681,82 @@ func (f *FileRecordedTestsSuite) TestFileRenameUsingOAuth() { testcommon.ValidateFileErrorCode(_require, err, fileerror.ResourceNotFound) } +func (f *FileUnrecordedTestsSuite) TestFileUploadRangeFromURLUsingOAuth() { + _require := require.New(f.T()) + testName := f.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + sharedKeyCred, err := testcommon.GetGenericSharedKeyCredential(testcommon.TestAccountDefault) + _require.NoError(err) + + tokenCred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(f.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + var fileSize int64 = 1024 * 10 + contentSize := 1024 * 8 // 8KB + _, content := testcommon.GenerateData(contentSize) + body := bytes.NewReader(content) + rsc := streaming.NopCloser(body) + contentCRC64 := crc64.Checksum(content, shared.CRC64Table) + + srcFileName := "src" + testcommon.GenerateFileName(testName) + srcFClient := shareClient.NewRootDirectoryClient().NewFileClient(srcFileName) + _, err = srcFClient.Create(context.Background(), fileSize, nil) + _require.NoError(err) + + _, err = srcFClient.UploadRange(context.Background(), 0, rsc, nil) + _require.NoError(err) + + perms := sas.FilePermissions{Read: true, Write: true} + sasQueryParams, err := sas.SignatureValues{ + Protocol: sas.ProtocolHTTPS, // Users MUST use HTTPS (not HTTP) + ExpiryTime: time.Now().UTC().Add(48 * time.Hour), // 48-hours before expiration + ShareName: shareName, + FilePath: srcFileName, + Permissions: perms.String(), + }.SignWithSharedKey(sharedKeyCred) + _require.NoError(err) + + srcFileSAS := srcFClient.URL() + "?" + sasQueryParams.Encode() + + destFileURL := "https://" + accountName + ".file.core.windows.net/" + shareName + "/dest" + testcommon.GenerateFileName(testName) + destFClient, err := file.NewClient(destFileURL, tokenCred, &file.ClientOptions{FileRequestIntent: to.Ptr(file.ShareTokenIntentBackup)}) + _require.NoError(err) + + _, err = destFClient.Create(context.Background(), fileSize, nil) + _require.NoError(err) + + uResp, err := destFClient.UploadRangeFromURL(context.Background(), srcFileSAS, 0, 0, int64(contentSize), &file.UploadRangeFromURLOptions{ + SourceContentValidation: file.SourceContentValidationTypeCRC64(contentCRC64), + }) + _require.NoError(err) + _require.NotNil(uResp.XMSContentCRC64) + _require.EqualValues(binary.LittleEndian.Uint64(uResp.XMSContentCRC64), contentCRC64) + + // validate the content uploaded + dResp, err := destFClient.DownloadStream(context.Background(), &file.DownloadStreamOptions{ + Range: file.HTTPRange{Offset: 0, Count: int64(contentSize)}, + }) + _require.NoError(err) + + data, err := io.ReadAll(dResp.Body) + defer func() { + err = dResp.Body.Close() + _require.NoError(err) + }() + + _require.EqualValues(data, content) +} + func (f *FileRecordedTestsSuite) TestFileRenameDifferentDir() { _require := require.New(f.T()) testName := f.T().Name() @@ -4151,7 +4296,7 @@ func (f *FileUnrecordedTestsSuite) TestFileUploadRangeFromURLTrailingDot() { }) _require.NoError(err) - data, err := ioutil.ReadAll(dResp.Body) + data, err := io.ReadAll(dResp.Body) defer func() { err = dResp.Body.Close() _require.NoError(err) @@ -4340,4 +4485,143 @@ func (f *FileUnrecordedTestsSuite) TestFileUploadRangeFromURLNow() { _require.NotEqualValues(*uResp.FileLastWriteTime, *cResp.FileLastWriteTime) } +type serviceVersionTest struct{} + +// newServiceVersionTestPolicy returns a policy that checks the x-ms-version header +func newServiceVersionTestPolicy() policy.Policy { + return &serviceVersionTest{} +} + +func (m serviceVersionTest) Do(req *policy.Request) (*http.Response, error) { + const versionHeader = "x-ms-version" + currentVersion := map[string][]string(req.Raw().Header)[versionHeader] + if currentVersion[0] != generated.ServiceVersion { + return nil, fmt.Errorf(currentVersion[0] + " service version doesn't match expected version: " + generated.ServiceVersion) + } + + return &http.Response{ + Request: req.Raw(), + Status: "Created", + StatusCode: http.StatusCreated, + Header: http.Header{}, + Body: http.NoBody, + }, nil +} + +func TestServiceVersion(t *testing.T) { + client, err := file.NewClientWithNoCredential("https://fake/file/testpath", &file.ClientOptions{ + ClientOptions: policy.ClientOptions{ + PerCallPolicies: []policy.Policy{newServiceVersionTestPolicy()}, + }, + }) + require.NoError(t, err) + require.NotNil(t, client) + + _, err = client.Create(context.Background(), 1024, nil) + require.NoError(t, err) +} + +func (f *FileRecordedTestsSuite) TestFileClientDefaultAudience() { + _require := require.New(f.T()) + testName := f.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(f.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + fileName := testcommon.GenerateFileName(testName) + fileURL := "https://" + accountName + ".file.core.windows.net/" + shareName + "/" + fileName + + options := &file.ClientOptions{ + FileRequestIntent: to.Ptr(file.ShareTokenIntentBackup), + Audience: "https://storage.azure.com/", + } + testcommon.SetClientOptions(f.T(), &options.ClientOptions) + fileClientAudience, err := file.NewClient(fileURL, cred, options) + _require.NoError(err) + + _, err = fileClientAudience.Create(context.Background(), 2048, nil) + _require.NoError(err) + + _, err = fileClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} + +func (f *FileRecordedTestsSuite) TestFileClientCustomAudience() { + _require := require.New(f.T()) + testName := f.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(f.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + fileName := testcommon.GenerateFileName(testName) + fileURL := "https://" + accountName + ".file.core.windows.net/" + shareName + "/" + fileName + + options := &file.ClientOptions{ + FileRequestIntent: to.Ptr(file.ShareTokenIntentBackup), + Audience: "https://" + accountName + ".file.core.windows.net", + } + testcommon.SetClientOptions(f.T(), &options.ClientOptions) + fileClientAudience, err := file.NewClient(fileURL, cred, options) + _require.NoError(err) + + _, err = fileClientAudience.Create(context.Background(), 2048, nil) + _require.NoError(err) + + _, err = fileClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} + +func (f *FileRecordedTestsSuite) TestFileClientAudienceNegative() { + _require := require.New(f.T()) + testName := f.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(f.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + fileName := testcommon.GenerateFileName(testName) + fileURL := "https://" + accountName + ".file.core.windows.net/" + shareName + "/" + fileName + + options := &file.ClientOptions{ + FileRequestIntent: to.Ptr(file.ShareTokenIntentBackup), + Audience: "https://badaudience.file.core.windows.net", + } + testcommon.SetClientOptions(f.T(), &options.ClientOptions) + fileClientAudience, err := file.NewClient(fileURL, cred, options) + _require.NoError(err) + + _, err = fileClientAudience.Create(context.Background(), 2048, nil) + _require.Error(err) + testcommon.ValidateFileErrorCode(_require, err, fileerror.AuthenticationFailed) +} + // TODO: Add tests for retry header options diff --git a/sdk/storage/azfile/file/examples_test.go b/sdk/storage/azfile/file/examples_test.go index fe9556abbda3..7795df8e33c4 100644 --- a/sdk/storage/azfile/file/examples_test.go +++ b/sdk/storage/azfile/file/examples_test.go @@ -19,7 +19,6 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/service" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/share" "io" - "io/ioutil" "log" "os" "strings" @@ -477,7 +476,7 @@ func Example_fileClient_UploadFile() { handleError(err) _, content := generateData(int(fileSize)) - err = ioutil.WriteFile(srcFileName, content, 0644) + err = os.WriteFile(srcFileName, content, 0644) handleError(err) defer func() { err = os.Remove(srcFileName) diff --git a/sdk/storage/azfile/internal/base/clients.go b/sdk/storage/azfile/internal/base/clients.go index 101a58a5f85e..e39baf006011 100644 --- a/sdk/storage/azfile/internal/base/clients.go +++ b/sdk/storage/azfile/internal/base/clients.go @@ -11,15 +11,30 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/exported" "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/generated" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azfile/internal/shared" + "strings" ) // ClientOptions contains the optional parameters when creating a Client. type ClientOptions struct { azcore.ClientOptions - AllowTrailingDot *bool - FileRequestIntent *generated.ShareTokenIntent + + // AllowTrailingDot specifies if a trailing dot present in request url should be trimmed or not. + AllowTrailingDot *bool + + // FileRequestIntent is required when using TokenCredential for authentication. + // Acceptable value is backup. + FileRequestIntent *generated.ShareTokenIntent + + // AllowSourceTrailingDot specifies if a trailing dot present in source url should be trimmed or not. AllowSourceTrailingDot *bool - pipelineOptions *runtime.PipelineOptions + + // Audience to use when requesting tokens for Azure Active Directory authentication. + // Only has an effect when credential is of type TokenCredential. The value could be + // https://storage.azure.com/ (default) or https://.file.core.windows.net. + Audience string + + pipelineOptions *runtime.PipelineOptions } type Client[T any] struct { @@ -48,6 +63,14 @@ func SetPipelineOptions(clOpts *ClientOptions, plOpts *runtime.PipelineOptions) clOpts.pipelineOptions = plOpts } +func GetAudience(clOpts *ClientOptions) string { + if clOpts == nil || len(strings.TrimSpace(clOpts.Audience)) == 0 { + return shared.TokenScope + } else { + return strings.TrimRight(clOpts.Audience, "/") + "/.default" + } +} + func NewServiceClient(serviceURL string, azClient *azcore.Client, sharedKey *exported.SharedKeyCredential, options *ClientOptions) *Client[generated.ServiceClient] { return &Client[generated.ServiceClient]{ inner: generated.NewServiceClient(serviceURL, azClient), diff --git a/sdk/storage/azfile/internal/generated/autorest.md b/sdk/storage/azfile/internal/generated/autorest.md index 921ad0ca976c..f887159b7f0b 100644 --- a/sdk/storage/azfile/internal/generated/autorest.md +++ b/sdk/storage/azfile/internal/generated/autorest.md @@ -7,7 +7,7 @@ go: true clear-output-folder: false version: "^3.0.0" license-header: MICROSOFT_MIT_NO_VERSION -input-file: "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/7dcd41cd28d46eb256bac034760a7e2f0a036238/specification/storage/data-plane/Microsoft.FileStorage/preview/2022-11-02/file.json" +input-file: "https://raw.githubusercontent.com/Azure/azure-rest-api-specs/4bafbf3ab1532e390ad5757433679e9ebb5cbf38/specification/storage/data-plane/Microsoft.FileStorage/preview/2023-08-03/file.json" credential-scope: "https://storage.azure.com/.default" output-folder: ../generated file-prefix: "zz_" @@ -19,7 +19,23 @@ modelerfour: seal-single-value-enum-by-default: true lenient-model-deduplication: true export-clients: true -use: "@autorest/go@4.0.0-preview.49" +use: "@autorest/go@4.0.0-preview.61" +``` + +### Updating service version to 2023-11-03 + +```yaml +directive: +- from: + - zz_directory_client.go + - zz_file_client.go + - zz_share_client.go + - zz_service_client.go + where: $ + transform: >- + return $. + replaceAll(`[]string{"2023-08-03"}`, `[]string{ServiceVersion}`). + replaceAll(`2023-08-03`, `2023-11-03`); ``` ### Don't include share name, directory, or file name in path - we have direct URIs @@ -144,6 +160,7 @@ directive: - zz_directory_client.go - zz_file_client.go - zz_models.go + - zz_options.go where: $ transform: >- return $. diff --git a/sdk/storage/azfile/internal/generated/constants.go b/sdk/storage/azfile/internal/generated/constants.go new file mode 100644 index 000000000000..8f2bbbb7cb81 --- /dev/null +++ b/sdk/storage/azfile/internal/generated/constants.go @@ -0,0 +1,9 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +package generated + +const ServiceVersion = "2023-11-03" diff --git a/sdk/storage/azfile/internal/generated/models.go b/sdk/storage/azfile/internal/generated/models.go index 3aeb9ae89d49..36a671cc6a86 100644 --- a/sdk/storage/azfile/internal/generated/models.go +++ b/sdk/storage/azfile/internal/generated/models.go @@ -38,12 +38,12 @@ func (h Handle) MarshalXML(enc *xml.Encoder, start xml.StartElement) error { type alias Handle aux := &struct { *alias - LastReconnectTime *timeRFC1123 `xml:"LastReconnectTime"` - OpenTime *timeRFC1123 `xml:"OpenTime"` + LastReconnectTime *dateTimeRFC1123 `xml:"LastReconnectTime"` + OpenTime *dateTimeRFC1123 `xml:"OpenTime"` }{ alias: (*alias)(&h), - LastReconnectTime: (*timeRFC1123)(h.LastReconnectTime), - OpenTime: (*timeRFC1123)(h.OpenTime), + LastReconnectTime: (*dateTimeRFC1123)(h.LastReconnectTime), + OpenTime: (*dateTimeRFC1123)(h.OpenTime), } return enc.EncodeElement(aux, start) } @@ -53,9 +53,9 @@ func (h *Handle) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) error { type alias Handle aux := &struct { *alias - Path *StringEncoded `xml:"Path"` - LastReconnectTime *timeRFC1123 `xml:"LastReconnectTime"` - OpenTime *timeRFC1123 `xml:"OpenTime"` + Path *StringEncoded `xml:"Path"` + LastReconnectTime *dateTimeRFC1123 `xml:"LastReconnectTime"` + OpenTime *dateTimeRFC1123 `xml:"OpenTime"` }{ alias: (*alias)(h), } diff --git a/sdk/storage/azfile/internal/generated/zz_constants.go b/sdk/storage/azfile/internal/generated/zz_constants.go index 2f356c7c3f63..edbc1a5c1c74 100644 --- a/sdk/storage/azfile/internal/generated/zz_constants.go +++ b/sdk/storage/azfile/internal/generated/zz_constants.go @@ -3,12 +3,29 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated +// AccessRight - Access rights of the access policy. +type AccessRight string + +const ( + AccessRightDelete AccessRight = "Delete" + AccessRightRead AccessRight = "Read" + AccessRightWrite AccessRight = "Write" +) + +// PossibleAccessRightValues returns the possible values for the AccessRight const type. +func PossibleAccessRightValues() []AccessRight { + return []AccessRight{ + AccessRightDelete, + AccessRightRead, + AccessRightWrite, + } +} + type CopyStatusType string const ( diff --git a/sdk/storage/azfile/internal/generated/zz_directory_client.go b/sdk/storage/azfile/internal/generated/zz_directory_client.go index 4e05f2f7d860..41d3367a1dd5 100644 --- a/sdk/storage/azfile/internal/generated/zz_directory_client.go +++ b/sdk/storage/azfile/internal/generated/zz_directory_client.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated @@ -35,21 +34,24 @@ type DirectoryClient struct { // Create - Creates a new directory under the specified share or parent directory. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - DirectoryClientCreateOptions contains the optional parameters for the DirectoryClient.Create method. func (client *DirectoryClient) Create(ctx context.Context, options *DirectoryClientCreateOptions) (DirectoryClientCreateResponse, error) { + var err error req, err := client.createCreateRequest(ctx, options) if err != nil { return DirectoryClientCreateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientCreateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return DirectoryClientCreateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return DirectoryClientCreateResponse{}, err } - return client.createHandleResponse(resp) + resp, err := client.createHandleResponse(httpResp) + return resp, err } // createCreateRequest creates the Create request. @@ -74,7 +76,7 @@ func (client *DirectoryClient) createCreateRequest(ctx context.Context, options } } } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.FilePermission != nil { req.Raw().Header["x-ms-file-permission"] = []string{*options.FilePermission} } @@ -103,22 +105,6 @@ func (client *DirectoryClient) createCreateRequest(ctx context.Context, options // createHandleResponse handles the Create response. func (client *DirectoryClient) createHandleResponse(resp *http.Response) (DirectoryClientCreateResponse, error) { result := DirectoryClientCreateResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return DirectoryClientCreateResponse{}, err - } - result.LastModified = &lastModified - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -126,19 +112,19 @@ func (client *DirectoryClient) createHandleResponse(resp *http.Response) (Direct } result.Date = &date } - if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { - isServerEncrypted, err := strconv.ParseBool(val) - if err != nil { - return DirectoryClientCreateResponse{}, err - } - result.IsServerEncrypted = &isServerEncrypted - } - if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { - result.FilePermissionKey = &val + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-file-attributes"); val != "" { result.FileAttributes = &val } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) + if err != nil { + return DirectoryClientCreateResponse{}, err + } + result.FileChangeTime = &fileChangeTime + } if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { fileCreationTime, err := time.Parse(ISO8601, val) if err != nil { @@ -146,6 +132,9 @@ func (client *DirectoryClient) createHandleResponse(resp *http.Response) (Direct } result.FileCreationTime = &fileCreationTime } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { @@ -153,18 +142,31 @@ func (client *DirectoryClient) createHandleResponse(resp *http.Response) (Direct } result.FileLastWriteTime = &fileLastWriteTime } - if val := resp.Header.Get("x-ms-file-change-time"); val != "" { - fileChangeTime, err := time.Parse(ISO8601, val) + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val + } + if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { + result.FilePermissionKey = &val + } + if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) if err != nil { return DirectoryClientCreateResponse{}, err } - result.FileChangeTime = &fileChangeTime + result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.ID = &val + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return DirectoryClientCreateResponse{}, err + } + result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.ParentID = &val + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val } return result, nil } @@ -172,21 +174,24 @@ func (client *DirectoryClient) createHandleResponse(resp *http.Response) (Direct // Delete - Removes the specified empty directory. Note that the directory must be empty before it can be deleted. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - DirectoryClientDeleteOptions contains the optional parameters for the DirectoryClient.Delete method. func (client *DirectoryClient) Delete(ctx context.Context, options *DirectoryClientDeleteOptions) (DirectoryClientDeleteResponse, error) { + var err error req, err := client.deleteCreateRequest(ctx, options) if err != nil { return DirectoryClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return DirectoryClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return DirectoryClientDeleteResponse{}, err } - return client.deleteHandleResponse(resp) + resp, err := client.deleteHandleResponse(httpResp) + return resp, err } // deleteCreateRequest creates the Delete request. @@ -204,7 +209,7 @@ func (client *DirectoryClient) deleteCreateRequest(ctx context.Context, options if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if client.fileRequestIntent != nil { req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} } @@ -215,12 +220,6 @@ func (client *DirectoryClient) deleteCreateRequest(ctx context.Context, options // deleteHandleResponse handles the Delete response. func (client *DirectoryClient) deleteHandleResponse(resp *http.Response) (DirectoryClientDeleteResponse, error) { result := DirectoryClientDeleteResponse{} - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -228,30 +227,39 @@ func (client *DirectoryClient) deleteHandleResponse(resp *http.Response) (Direct } result.Date = &date } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } // ForceCloseHandles - Closes all handles open for given directory. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - handleID - Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard that specifies // all handles. // - options - DirectoryClientForceCloseHandlesOptions contains the optional parameters for the DirectoryClient.ForceCloseHandles // method. func (client *DirectoryClient) ForceCloseHandles(ctx context.Context, handleID string, options *DirectoryClientForceCloseHandlesOptions) (DirectoryClientForceCloseHandlesResponse, error) { + var err error req, err := client.forceCloseHandlesCreateRequest(ctx, handleID, options) if err != nil { return DirectoryClientForceCloseHandlesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientForceCloseHandlesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DirectoryClientForceCloseHandlesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DirectoryClientForceCloseHandlesResponse{}, err } - return client.forceCloseHandlesHandleResponse(resp) + resp, err := client.forceCloseHandlesHandleResponse(httpResp) + return resp, err } // forceCloseHandlesCreateRequest creates the ForceCloseHandles request. @@ -276,7 +284,7 @@ func (client *DirectoryClient) forceCloseHandlesCreateRequest(ctx context.Contex if options != nil && options.Recursive != nil { req.Raw().Header["x-ms-recursive"] = []string{strconv.FormatBool(*options.Recursive)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } @@ -290,12 +298,6 @@ func (client *DirectoryClient) forceCloseHandlesCreateRequest(ctx context.Contex // forceCloseHandlesHandleResponse handles the ForceCloseHandles response. func (client *DirectoryClient) forceCloseHandlesHandleResponse(resp *http.Response) (DirectoryClientForceCloseHandlesResponse, error) { result := DirectoryClientForceCloseHandlesResponse{} - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -322,6 +324,12 @@ func (client *DirectoryClient) forceCloseHandlesHandleResponse(resp *http.Respon } result.NumberOfHandlesFailedToClose = &numberOfHandlesFailedToClose } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } @@ -330,21 +338,24 @@ func (client *DirectoryClient) forceCloseHandlesHandleResponse(resp *http.Respon // subdirectories. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - DirectoryClientGetPropertiesOptions contains the optional parameters for the DirectoryClient.GetProperties method. func (client *DirectoryClient) GetProperties(ctx context.Context, options *DirectoryClientGetPropertiesOptions) (DirectoryClientGetPropertiesResponse, error) { + var err error req, err := client.getPropertiesCreateRequest(ctx, options) if err != nil { return DirectoryClientGetPropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientGetPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DirectoryClientGetPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DirectoryClientGetPropertiesResponse{}, err } - return client.getPropertiesHandleResponse(resp) + resp, err := client.getPropertiesHandleResponse(httpResp) + return resp, err } // getPropertiesCreateRequest creates the GetProperties request. @@ -365,7 +376,7 @@ func (client *DirectoryClient) getPropertiesCreateRequest(ctx context.Context, o if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if client.fileRequestIntent != nil { req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} } @@ -376,30 +387,6 @@ func (client *DirectoryClient) getPropertiesCreateRequest(ctx context.Context, o // getPropertiesHandleResponse handles the GetProperties response. func (client *DirectoryClient) getPropertiesHandleResponse(resp *http.Response) (DirectoryClientGetPropertiesResponse, error) { result := DirectoryClientGetPropertiesResponse{} - for hh := range resp.Header { - if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") { - if result.Metadata == nil { - result.Metadata = map[string]*string{} - } - result.Metadata[hh[len("x-ms-meta-"):]] = to.Ptr(resp.Header.Get(hh)) - } - } - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return DirectoryClientGetPropertiesResponse{}, err - } - result.LastModified = &lastModified - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -407,16 +394,19 @@ func (client *DirectoryClient) getPropertiesHandleResponse(resp *http.Response) } result.Date = &date } - if val := resp.Header.Get("x-ms-server-encrypted"); val != "" { - isServerEncrypted, err := strconv.ParseBool(val) - if err != nil { - return DirectoryClientGetPropertiesResponse{}, err - } - result.IsServerEncrypted = &isServerEncrypted + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-file-attributes"); val != "" { result.FileAttributes = &val } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) + if err != nil { + return DirectoryClientGetPropertiesResponse{}, err + } + result.FileChangeTime = &fileChangeTime + } if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { fileCreationTime, err := time.Parse(ISO8601, val) if err != nil { @@ -424,6 +414,9 @@ func (client *DirectoryClient) getPropertiesHandleResponse(resp *http.Response) } result.FileCreationTime = &fileCreationTime } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { @@ -431,21 +424,39 @@ func (client *DirectoryClient) getPropertiesHandleResponse(resp *http.Response) } result.FileLastWriteTime = &fileLastWriteTime } - if val := resp.Header.Get("x-ms-file-change-time"); val != "" { - fileChangeTime, err := time.Parse(ISO8601, val) + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val + } + if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { + result.FilePermissionKey = &val + } + if val := resp.Header.Get("x-ms-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) if err != nil { return DirectoryClientGetPropertiesResponse{}, err } - result.FileChangeTime = &fileChangeTime + result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { - result.FilePermissionKey = &val + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return DirectoryClientGetPropertiesResponse{}, err + } + result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.ID = &val + for hh := range resp.Header { + if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") { + if result.Metadata == nil { + result.Metadata = map[string]*string{} + } + result.Metadata[hh[len("x-ms-meta-"):]] = to.Ptr(resp.Header.Get(hh)) + } } - if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.ParentID = &val + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val } return result, nil } @@ -453,7 +464,7 @@ func (client *DirectoryClient) getPropertiesHandleResponse(resp *http.Response) // NewListFilesAndDirectoriesSegmentPager - Returns a list of files or directories under the specified share or directory. // It lists the contents only for a single level of the directory hierarchy. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - DirectoryClientListFilesAndDirectoriesSegmentOptions contains the optional parameters for the DirectoryClient.NewListFilesAndDirectoriesSegmentPager // method. // @@ -485,7 +496,7 @@ func (client *DirectoryClient) ListFilesAndDirectoriesSegmentCreateRequest(ctx c reqQP.Set("include", strings.Join(strings.Fields(strings.Trim(fmt.Sprint(options.Include), "[]")), ",")) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.IncludeExtendedInfo != nil { req.Raw().Header["x-ms-file-extended-info"] = []string{strconv.FormatBool(*options.IncludeExtendedInfo)} } @@ -505,12 +516,6 @@ func (client *DirectoryClient) ListFilesAndDirectoriesSegmentHandleResponse(resp if val := resp.Header.Get("Content-Type"); val != "" { result.ContentType = &val } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -518,6 +523,12 @@ func (client *DirectoryClient) ListFilesAndDirectoriesSegmentHandleResponse(resp } result.Date = &date } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } if err := runtime.UnmarshalAsXML(resp, &result.ListFilesAndDirectoriesSegmentResponse); err != nil { return DirectoryClientListFilesAndDirectoriesSegmentResponse{}, err } @@ -527,21 +538,24 @@ func (client *DirectoryClient) ListFilesAndDirectoriesSegmentHandleResponse(resp // ListHandles - Lists handles for directory. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - DirectoryClientListHandlesOptions contains the optional parameters for the DirectoryClient.ListHandles method. func (client *DirectoryClient) ListHandles(ctx context.Context, options *DirectoryClientListHandlesOptions) (DirectoryClientListHandlesResponse, error) { + var err error req, err := client.listHandlesCreateRequest(ctx, options) if err != nil { return DirectoryClientListHandlesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientListHandlesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DirectoryClientListHandlesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DirectoryClientListHandlesResponse{}, err } - return client.listHandlesHandleResponse(resp) + resp, err := client.listHandlesHandleResponse(httpResp) + return resp, err } // listHandlesCreateRequest creates the ListHandles request. @@ -568,7 +582,7 @@ func (client *DirectoryClient) listHandlesCreateRequest(ctx context.Context, opt if options != nil && options.Recursive != nil { req.Raw().Header["x-ms-recursive"] = []string{strconv.FormatBool(*options.Recursive)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } @@ -585,12 +599,6 @@ func (client *DirectoryClient) listHandlesHandleResponse(resp *http.Response) (D if val := resp.Header.Get("Content-Type"); val != "" { result.ContentType = &val } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -598,6 +606,12 @@ func (client *DirectoryClient) listHandlesHandleResponse(resp *http.Response) (D } result.Date = &date } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } if err := runtime.UnmarshalAsXML(resp, &result.ListHandlesResponse); err != nil { return DirectoryClientListHandlesResponse{}, err } @@ -607,7 +621,7 @@ func (client *DirectoryClient) listHandlesHandleResponse(resp *http.Response) (D // Rename - Renames a directory // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - renameSource - Required. Specifies the URI-style path of the source file, up to 2 KB in length. // - options - DirectoryClientRenameOptions contains the optional parameters for the DirectoryClient.Rename method. // - SourceLeaseAccessConditions - SourceLeaseAccessConditions contains a group of parameters for the DirectoryClient.Rename @@ -616,18 +630,21 @@ func (client *DirectoryClient) listHandlesHandleResponse(resp *http.Response) (D // method. // - CopyFileSMBInfo - CopyFileSMBInfo contains a group of parameters for the DirectoryClient.Rename method. func (client *DirectoryClient) Rename(ctx context.Context, renameSource string, options *DirectoryClientRenameOptions, sourceLeaseAccessConditions *SourceLeaseAccessConditions, destinationLeaseAccessConditions *DestinationLeaseAccessConditions, copyFileSMBInfo *CopyFileSMBInfo) (DirectoryClientRenameResponse, error) { + var err error req, err := client.renameCreateRequest(ctx, renameSource, options, sourceLeaseAccessConditions, destinationLeaseAccessConditions, copyFileSMBInfo) if err != nil { return DirectoryClientRenameResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientRenameResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DirectoryClientRenameResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DirectoryClientRenameResponse{}, err } - return client.renameHandleResponse(resp) + resp, err := client.renameHandleResponse(httpResp) + return resp, err } // renameCreateRequest creates the Rename request. @@ -643,7 +660,7 @@ func (client *DirectoryClient) renameCreateRequest(ctx context.Context, renameSo reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} req.Raw().Header["x-ms-file-rename-source"] = []string{renameSource} if options != nil && options.ReplaceIfExists != nil { req.Raw().Header["x-ms-file-rename-replace-if-exists"] = []string{strconv.FormatBool(*options.ReplaceIfExists)} @@ -698,22 +715,6 @@ func (client *DirectoryClient) renameCreateRequest(ctx context.Context, renameSo // renameHandleResponse handles the Rename response. func (client *DirectoryClient) renameHandleResponse(resp *http.Response) (DirectoryClientRenameResponse, error) { result := DirectoryClientRenameResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return DirectoryClientRenameResponse{}, err - } - result.LastModified = &lastModified - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -721,19 +722,19 @@ func (client *DirectoryClient) renameHandleResponse(resp *http.Response) (Direct } result.Date = &date } - if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { - isServerEncrypted, err := strconv.ParseBool(val) - if err != nil { - return DirectoryClientRenameResponse{}, err - } - result.IsServerEncrypted = &isServerEncrypted - } - if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { - result.FilePermissionKey = &val + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-file-attributes"); val != "" { result.FileAttributes = &val } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) + if err != nil { + return DirectoryClientRenameResponse{}, err + } + result.FileChangeTime = &fileChangeTime + } if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { fileCreationTime, err := time.Parse(ISO8601, val) if err != nil { @@ -741,6 +742,9 @@ func (client *DirectoryClient) renameHandleResponse(resp *http.Response) (Direct } result.FileCreationTime = &fileCreationTime } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { @@ -748,18 +752,31 @@ func (client *DirectoryClient) renameHandleResponse(resp *http.Response) (Direct } result.FileLastWriteTime = &fileLastWriteTime } - if val := resp.Header.Get("x-ms-file-change-time"); val != "" { - fileChangeTime, err := time.Parse(ISO8601, val) + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val + } + if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { + result.FilePermissionKey = &val + } + if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) if err != nil { return DirectoryClientRenameResponse{}, err } - result.FileChangeTime = &fileChangeTime + result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.ID = &val + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return DirectoryClientRenameResponse{}, err + } + result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.ParentID = &val + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val } return result, nil } @@ -767,21 +784,24 @@ func (client *DirectoryClient) renameHandleResponse(resp *http.Response) (Direct // SetMetadata - Updates user defined metadata for the specified directory. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - DirectoryClientSetMetadataOptions contains the optional parameters for the DirectoryClient.SetMetadata method. func (client *DirectoryClient) SetMetadata(ctx context.Context, options *DirectoryClientSetMetadataOptions) (DirectoryClientSetMetadataResponse, error) { + var err error req, err := client.setMetadataCreateRequest(ctx, options) if err != nil { return DirectoryClientSetMetadataResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientSetMetadataResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DirectoryClientSetMetadataResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DirectoryClientSetMetadataResponse{}, err } - return client.setMetadataHandleResponse(resp) + resp, err := client.setMetadataHandleResponse(httpResp) + return resp, err } // setMetadataCreateRequest creates the SetMetadata request. @@ -804,7 +824,7 @@ func (client *DirectoryClient) setMetadataCreateRequest(ctx context.Context, opt } } } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } @@ -818,15 +838,6 @@ func (client *DirectoryClient) setMetadataCreateRequest(ctx context.Context, opt // setMetadataHandleResponse handles the SetMetadata response. func (client *DirectoryClient) setMetadataHandleResponse(resp *http.Response) (DirectoryClientSetMetadataResponse, error) { result := DirectoryClientSetMetadataResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -834,6 +845,9 @@ func (client *DirectoryClient) setMetadataHandleResponse(resp *http.Response) (D } result.Date = &date } + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) + } if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { isServerEncrypted, err := strconv.ParseBool(val) if err != nil { @@ -841,27 +855,36 @@ func (client *DirectoryClient) setMetadataHandleResponse(resp *http.Response) (D } result.IsServerEncrypted = &isServerEncrypted } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } // SetProperties - Sets properties on the directory. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - DirectoryClientSetPropertiesOptions contains the optional parameters for the DirectoryClient.SetProperties method. func (client *DirectoryClient) SetProperties(ctx context.Context, options *DirectoryClientSetPropertiesOptions) (DirectoryClientSetPropertiesResponse, error) { + var err error req, err := client.setPropertiesCreateRequest(ctx, options) if err != nil { return DirectoryClientSetPropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DirectoryClientSetPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DirectoryClientSetPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DirectoryClientSetPropertiesResponse{}, err } - return client.setPropertiesHandleResponse(resp) + resp, err := client.setPropertiesHandleResponse(httpResp) + return resp, err } // setPropertiesCreateRequest creates the SetProperties request. @@ -877,7 +900,7 @@ func (client *DirectoryClient) setPropertiesCreateRequest(ctx context.Context, o reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.FilePermission != nil { req.Raw().Header["x-ms-file-permission"] = []string{*options.FilePermission} } @@ -909,22 +932,6 @@ func (client *DirectoryClient) setPropertiesCreateRequest(ctx context.Context, o // setPropertiesHandleResponse handles the SetProperties response. func (client *DirectoryClient) setPropertiesHandleResponse(resp *http.Response) (DirectoryClientSetPropertiesResponse, error) { result := DirectoryClientSetPropertiesResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return DirectoryClientSetPropertiesResponse{}, err - } - result.LastModified = &lastModified - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -932,19 +939,19 @@ func (client *DirectoryClient) setPropertiesHandleResponse(resp *http.Response) } result.Date = &date } - if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { - isServerEncrypted, err := strconv.ParseBool(val) - if err != nil { - return DirectoryClientSetPropertiesResponse{}, err - } - result.IsServerEncrypted = &isServerEncrypted - } - if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { - result.FilePermissionKey = &val + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-file-attributes"); val != "" { result.FileAttributes = &val } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) + if err != nil { + return DirectoryClientSetPropertiesResponse{}, err + } + result.FileChangeTime = &fileChangeTime + } if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { fileCreationTime, err := time.Parse(ISO8601, val) if err != nil { @@ -952,6 +959,9 @@ func (client *DirectoryClient) setPropertiesHandleResponse(resp *http.Response) } result.FileCreationTime = &fileCreationTime } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { @@ -959,18 +969,31 @@ func (client *DirectoryClient) setPropertiesHandleResponse(resp *http.Response) } result.FileLastWriteTime = &fileLastWriteTime } - if val := resp.Header.Get("x-ms-file-change-time"); val != "" { - fileChangeTime, err := time.Parse(ISO8601, val) + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val + } + if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { + result.FilePermissionKey = &val + } + if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) if err != nil { return DirectoryClientSetPropertiesResponse{}, err } - result.FileChangeTime = &fileChangeTime + result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.ID = &val + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return DirectoryClientSetPropertiesResponse{}, err + } + result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.ParentID = &val + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val } return result, nil } diff --git a/sdk/storage/azfile/internal/generated/zz_file_client.go b/sdk/storage/azfile/internal/generated/zz_file_client.go index fda41c5f79a3..e8ce03fd2d10 100644 --- a/sdk/storage/azfile/internal/generated/zz_file_client.go +++ b/sdk/storage/azfile/internal/generated/zz_file_client.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated @@ -36,23 +35,26 @@ type FileClient struct { // AbortCopy - Aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - copyID - The copy identifier provided in the x-ms-copy-id header of the original Copy File operation. // - options - FileClientAbortCopyOptions contains the optional parameters for the FileClient.AbortCopy method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) AbortCopy(ctx context.Context, copyID string, options *FileClientAbortCopyOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientAbortCopyResponse, error) { + var err error req, err := client.abortCopyCreateRequest(ctx, copyID, options, leaseAccessConditions) if err != nil { return FileClientAbortCopyResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientAbortCopyResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusNoContent) { - return FileClientAbortCopyResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return FileClientAbortCopyResponse{}, err } - return client.abortCopyHandleResponse(resp) + resp, err := client.abortCopyHandleResponse(httpResp) + return resp, err } // abortCopyCreateRequest creates the AbortCopy request. @@ -69,7 +71,7 @@ func (client *FileClient) abortCopyCreateRequest(ctx context.Context, copyID str } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-copy-action"] = []string{"abort"} - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -86,12 +88,6 @@ func (client *FileClient) abortCopyCreateRequest(ctx context.Context, copyID str // abortCopyHandleResponse handles the AbortCopy response. func (client *FileClient) abortCopyHandleResponse(resp *http.Response) (FileClientAbortCopyResponse, error) { result := FileClientAbortCopyResponse{} - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -99,30 +95,39 @@ func (client *FileClient) abortCopyHandleResponse(resp *http.Response) (FileClie } result.Date = &date } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } // AcquireLease - [Update] The Lease File operation establishes and manages a lock on a file for write and delete operations // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - duration - Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A non-infinite // lease can be between 15 and 60 seconds. A lease duration cannot be changed using // renew or change. // - options - FileClientAcquireLeaseOptions contains the optional parameters for the FileClient.AcquireLease method. func (client *FileClient) AcquireLease(ctx context.Context, duration int32, options *FileClientAcquireLeaseOptions) (FileClientAcquireLeaseResponse, error) { + var err error req, err := client.acquireLeaseCreateRequest(ctx, duration, options) if err != nil { return FileClientAcquireLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientAcquireLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return FileClientAcquireLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return FileClientAcquireLeaseResponse{}, err } - return client.acquireLeaseHandleResponse(resp) + resp, err := client.acquireLeaseHandleResponse(httpResp) + return resp, err } // acquireLeaseCreateRequest creates the AcquireLease request. @@ -142,7 +147,7 @@ func (client *FileClient) acquireLeaseCreateRequest(ctx context.Context, duratio if options != nil && options.ProposedLeaseID != nil { req.Raw().Header["x-ms-proposed-lease-id"] = []string{*options.ProposedLeaseID} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -159,6 +164,16 @@ func (client *FileClient) acquireLeaseCreateRequest(ctx context.Context, duratio // acquireLeaseHandleResponse handles the AcquireLease response. func (client *FileClient) acquireLeaseHandleResponse(resp *http.Response) (FileClientAcquireLeaseResponse, error) { result := FileClientAcquireLeaseResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientAcquireLeaseResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -172,44 +187,37 @@ func (client *FileClient) acquireLeaseHandleResponse(resp *http.Response) (FileC if val := resp.Header.Get("x-ms-lease-id"); val != "" { result.LeaseID = &val } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientAcquireLeaseResponse{}, err - } - result.Date = &date - } return result, nil } // BreakLease - [Update] The Lease File operation establishes and manages a lock on a file for write and delete operations // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - FileClientBreakLeaseOptions contains the optional parameters for the FileClient.BreakLease method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) BreakLease(ctx context.Context, options *FileClientBreakLeaseOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientBreakLeaseResponse, error) { + var err error req, err := client.breakLeaseCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return FileClientBreakLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientBreakLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return FileClientBreakLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return FileClientBreakLeaseResponse{}, err } - return client.breakLeaseHandleResponse(resp) + resp, err := client.breakLeaseHandleResponse(httpResp) + return resp, err } // breakLeaseCreateRequest creates the BreakLease request. @@ -228,7 +236,7 @@ func (client *FileClient) breakLeaseCreateRequest(ctx context.Context, options * if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -245,6 +253,16 @@ func (client *FileClient) breakLeaseCreateRequest(ctx context.Context, options * // breakLeaseHandleResponse handles the BreakLease response. func (client *FileClient) breakLeaseHandleResponse(resp *http.Response) (FileClientBreakLeaseResponse, error) { result := FileClientBreakLeaseResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientBreakLeaseResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -258,44 +276,37 @@ func (client *FileClient) breakLeaseHandleResponse(resp *http.Response) (FileCli if val := resp.Header.Get("x-ms-lease-id"); val != "" { result.LeaseID = &val } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientBreakLeaseResponse{}, err - } - result.Date = &date - } return result, nil } // ChangeLease - [Update] The Lease File operation establishes and manages a lock on a file for write and delete operations // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - leaseID - Specifies the current lease ID on the resource. // - options - FileClientChangeLeaseOptions contains the optional parameters for the FileClient.ChangeLease method. func (client *FileClient) ChangeLease(ctx context.Context, leaseID string, options *FileClientChangeLeaseOptions) (FileClientChangeLeaseResponse, error) { + var err error req, err := client.changeLeaseCreateRequest(ctx, leaseID, options) if err != nil { return FileClientChangeLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientChangeLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileClientChangeLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileClientChangeLeaseResponse{}, err } - return client.changeLeaseHandleResponse(resp) + resp, err := client.changeLeaseHandleResponse(httpResp) + return resp, err } // changeLeaseCreateRequest creates the ChangeLease request. @@ -315,7 +326,7 @@ func (client *FileClient) changeLeaseCreateRequest(ctx context.Context, leaseID if options != nil && options.ProposedLeaseID != nil { req.Raw().Header["x-ms-proposed-lease-id"] = []string{*options.ProposedLeaseID} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -332,6 +343,16 @@ func (client *FileClient) changeLeaseCreateRequest(ctx context.Context, leaseID // changeLeaseHandleResponse handles the ChangeLease response. func (client *FileClient) changeLeaseHandleResponse(resp *http.Response) (FileClientChangeLeaseResponse, error) { result := FileClientChangeLeaseResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientChangeLeaseResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -345,46 +366,39 @@ func (client *FileClient) changeLeaseHandleResponse(resp *http.Response) (FileCl if val := resp.Header.Get("x-ms-lease-id"); val != "" { result.LeaseID = &val } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientChangeLeaseResponse{}, err - } - result.Date = &date - } return result, nil } // Create - Creates a new file or replaces a file. Note it only initializes the file with no content. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - fileContentLength - Specifies the maximum size for the file, up to 4 TB. // - options - FileClientCreateOptions contains the optional parameters for the FileClient.Create method. // - ShareFileHTTPHeaders - ShareFileHTTPHeaders contains a group of parameters for the FileClient.Create method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) Create(ctx context.Context, fileContentLength int64, options *FileClientCreateOptions, shareFileHTTPHeaders *ShareFileHTTPHeaders, leaseAccessConditions *LeaseAccessConditions) (FileClientCreateResponse, error) { + var err error req, err := client.createCreateRequest(ctx, fileContentLength, options, shareFileHTTPHeaders, leaseAccessConditions) if err != nil { return FileClientCreateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientCreateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return FileClientCreateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return FileClientCreateResponse{}, err } - return client.createHandleResponse(resp) + resp, err := client.createHandleResponse(httpResp) + return resp, err } // createCreateRequest creates the Create request. @@ -401,7 +415,7 @@ func (client *FileClient) createCreateRequest(ctx context.Context, fileContentLe if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} req.Raw().Header["x-ms-content-length"] = []string{strconv.FormatInt(fileContentLength, 10)} req.Raw().Header["x-ms-type"] = []string{"file"} if shareFileHTTPHeaders != nil && shareFileHTTPHeaders.ContentType != nil { @@ -460,22 +474,6 @@ func (client *FileClient) createCreateRequest(ctx context.Context, fileContentLe // createHandleResponse handles the Create response. func (client *FileClient) createHandleResponse(resp *http.Response) (FileClientCreateResponse, error) { result := FileClientCreateResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientCreateResponse{}, err - } - result.LastModified = &lastModified - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -483,19 +481,19 @@ func (client *FileClient) createHandleResponse(resp *http.Response) (FileClientC } result.Date = &date } - if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { - isServerEncrypted, err := strconv.ParseBool(val) - if err != nil { - return FileClientCreateResponse{}, err - } - result.IsServerEncrypted = &isServerEncrypted - } - if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { - result.FilePermissionKey = &val + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-file-attributes"); val != "" { result.FileAttributes = &val } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) + if err != nil { + return FileClientCreateResponse{}, err + } + result.FileChangeTime = &fileChangeTime + } if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { fileCreationTime, err := time.Parse(ISO8601, val) if err != nil { @@ -503,6 +501,9 @@ func (client *FileClient) createHandleResponse(resp *http.Response) (FileClientC } result.FileCreationTime = &fileCreationTime } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { @@ -510,18 +511,31 @@ func (client *FileClient) createHandleResponse(resp *http.Response) (FileClientC } result.FileLastWriteTime = &fileLastWriteTime } - if val := resp.Header.Get("x-ms-file-change-time"); val != "" { - fileChangeTime, err := time.Parse(ISO8601, val) + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val + } + if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { + result.FilePermissionKey = &val + } + if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) if err != nil { return FileClientCreateResponse{}, err } - result.FileChangeTime = &fileChangeTime + result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.ID = &val + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientCreateResponse{}, err + } + result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.ParentID = &val + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val } return result, nil } @@ -529,22 +543,25 @@ func (client *FileClient) createHandleResponse(resp *http.Response) (FileClientC // Delete - removes the file from the storage account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - FileClientDeleteOptions contains the optional parameters for the FileClient.Delete method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) Delete(ctx context.Context, options *FileClientDeleteOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientDeleteResponse, error) { + var err error req, err := client.deleteCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return FileClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return FileClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return FileClientDeleteResponse{}, err } - return client.deleteHandleResponse(resp) + resp, err := client.deleteHandleResponse(httpResp) + return resp, err } // deleteCreateRequest creates the Delete request. @@ -561,7 +578,7 @@ func (client *FileClient) deleteCreateRequest(ctx context.Context, options *File if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -575,12 +592,6 @@ func (client *FileClient) deleteCreateRequest(ctx context.Context, options *File // deleteHandleResponse handles the Delete response. func (client *FileClient) deleteHandleResponse(resp *http.Response) (FileClientDeleteResponse, error) { result := FileClientDeleteResponse{} - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -588,28 +599,37 @@ func (client *FileClient) deleteHandleResponse(resp *http.Response) (FileClientD } result.Date = &date } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } // Download - Reads or downloads a file from the system, including its metadata and properties. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - FileClientDownloadOptions contains the optional parameters for the FileClient.Download method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) Download(ctx context.Context, options *FileClientDownloadOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientDownloadResponse, error) { + var err error req, err := client.downloadCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return FileClientDownloadResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientDownloadResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusPartialContent) { - return FileClientDownloadResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusPartialContent) { + err = runtime.NewResponseError(httpResp) + return FileClientDownloadResponse{}, err } - return client.downloadHandleResponse(resp) + resp, err := client.downloadHandleResponse(httpResp) + return resp, err } // downloadCreateRequest creates the Download request. @@ -627,7 +647,7 @@ func (client *FileClient) downloadCreateRequest(ctx context.Context, options *Fi if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.Range != nil { req.Raw().Header["x-ms-range"] = []string{*options.Range} } @@ -647,20 +667,20 @@ func (client *FileClient) downloadCreateRequest(ctx context.Context, options *Fi // downloadHandleResponse handles the Download response. func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClientDownloadResponse, error) { result := FileClientDownloadResponse{Body: resp.Body} - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientDownloadResponse{}, err - } - result.LastModified = &lastModified + if val := resp.Header.Get("Accept-Ranges"); val != "" { + result.AcceptRanges = &val } - for hh := range resp.Header { - if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") { - if result.Metadata == nil { - result.Metadata = map[string]*string{} - } - result.Metadata[hh[len("x-ms-meta-"):]] = to.Ptr(resp.Header.Get(hh)) - } + if val := resp.Header.Get("Cache-Control"); val != "" { + result.CacheControl = &val + } + if val := resp.Header.Get("Content-Disposition"); val != "" { + result.ContentDisposition = &val + } + if val := resp.Header.Get("Content-Encoding"); val != "" { + result.ContentEncoding = &val + } + if val := resp.Header.Get("Content-Language"); val != "" { + result.ContentLanguage = &val } if val := resp.Header.Get("Content-Length"); val != "" { contentLength, err := strconv.ParseInt(val, 10, 64) @@ -669,15 +689,6 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien } result.ContentLength = &contentLength } - if val := resp.Header.Get("Content-Type"); val != "" { - result.ContentType = &val - } - if val := resp.Header.Get("Content-Range"); val != "" { - result.ContentRange = &val - } - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } if val := resp.Header.Get("Content-MD5"); val != "" { contentMD5, err := base64.StdEncoding.DecodeString(val) if err != nil { @@ -685,33 +696,11 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien } result.ContentMD5 = contentMD5 } - if val := resp.Header.Get("Content-Encoding"); val != "" { - result.ContentEncoding = &val - } - if val := resp.Header.Get("Cache-Control"); val != "" { - result.CacheControl = &val - } - if val := resp.Header.Get("Content-Disposition"); val != "" { - result.ContentDisposition = &val - } - if val := resp.Header.Get("Content-Language"); val != "" { - result.ContentLanguage = &val - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } - if val := resp.Header.Get("Accept-Ranges"); val != "" { - result.AcceptRanges = &val + if val := resp.Header.Get("Content-Range"); val != "" { + result.ContentRange = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientDownloadResponse{}, err - } - result.Date = &date + if val := resp.Header.Get("Content-Type"); val != "" { + result.ContentType = &val } if val := resp.Header.Get("x-ms-copy-completion-time"); val != "" { copyCompletionTime, err := time.Parse(time.RFC1123, val) @@ -720,9 +709,6 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien } result.CopyCompletionTime = ©CompletionTime } - if val := resp.Header.Get("x-ms-copy-status-description"); val != "" { - result.CopyStatusDescription = &val - } if val := resp.Header.Get("x-ms-copy-id"); val != "" { result.CopyID = &val } @@ -735,22 +721,35 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien if val := resp.Header.Get("x-ms-copy-status"); val != "" { result.CopyStatus = (*CopyStatusType)(&val) } - if val := resp.Header.Get("x-ms-content-md5"); val != "" { - fileContentMD5, err := base64.StdEncoding.DecodeString(val) + if val := resp.Header.Get("x-ms-copy-status-description"); val != "" { + result.CopyStatusDescription = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) if err != nil { return FileClientDownloadResponse{}, err } - result.FileContentMD5 = fileContentMD5 + result.Date = &date } - if val := resp.Header.Get("x-ms-server-encrypted"); val != "" { - isServerEncrypted, err := strconv.ParseBool(val) + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) + } + if val := resp.Header.Get("x-ms-file-attributes"); val != "" { + result.FileAttributes = &val + } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) if err != nil { return FileClientDownloadResponse{}, err } - result.IsServerEncrypted = &isServerEncrypted + result.FileChangeTime = &fileChangeTime } - if val := resp.Header.Get("x-ms-file-attributes"); val != "" { - result.FileAttributes = &val + if val := resp.Header.Get("x-ms-content-md5"); val != "" { + fileContentMD5, err := base64.StdEncoding.DecodeString(val) + if err != nil { + return FileClientDownloadResponse{}, err + } + result.FileContentMD5 = fileContentMD5 } if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { fileCreationTime, err := time.Parse(ISO8601, val) @@ -759,6 +758,9 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien } result.FileCreationTime = &fileCreationTime } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { @@ -766,21 +768,25 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien } result.FileLastWriteTime = &fileLastWriteTime } - if val := resp.Header.Get("x-ms-file-change-time"); val != "" { - fileChangeTime, err := time.Parse(ISO8601, val) - if err != nil { - return FileClientDownloadResponse{}, err - } - result.FileChangeTime = &fileChangeTime + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val } if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { result.FilePermissionKey = &val } - if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.ID = &val + if val := resp.Header.Get("x-ms-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) + if err != nil { + return FileClientDownloadResponse{}, err + } + result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.ParentID = &val + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientDownloadResponse{}, err + } + result.LastModified = &lastModified } if val := resp.Header.Get("x-ms-lease-duration"); val != "" { result.LeaseDuration = (*LeaseDurationType)(&val) @@ -791,29 +797,46 @@ func (client *FileClient) downloadHandleResponse(resp *http.Response) (FileClien if val := resp.Header.Get("x-ms-lease-status"); val != "" { result.LeaseStatus = (*LeaseStatusType)(&val) } + for hh := range resp.Header { + if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") { + if result.Metadata == nil { + result.Metadata = map[string]*string{} + } + result.Metadata[hh[len("x-ms-meta-"):]] = to.Ptr(resp.Header.Get(hh)) + } + } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } // ForceCloseHandles - Closes all handles open for given file // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - handleID - Specifies handle ID opened on the file or directory to be closed. Asterisk (‘*’) is a wildcard that specifies // all handles. // - options - FileClientForceCloseHandlesOptions contains the optional parameters for the FileClient.ForceCloseHandles method. func (client *FileClient) ForceCloseHandles(ctx context.Context, handleID string, options *FileClientForceCloseHandlesOptions) (FileClientForceCloseHandlesResponse, error) { + var err error req, err := client.forceCloseHandlesCreateRequest(ctx, handleID, options) if err != nil { return FileClientForceCloseHandlesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientForceCloseHandlesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileClientForceCloseHandlesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileClientForceCloseHandlesResponse{}, err } - return client.forceCloseHandlesHandleResponse(resp) + resp, err := client.forceCloseHandlesHandleResponse(httpResp) + return resp, err } // forceCloseHandlesCreateRequest creates the ForceCloseHandles request. @@ -835,7 +858,7 @@ func (client *FileClient) forceCloseHandlesCreateRequest(ctx context.Context, ha } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-handle-id"] = []string{handleID} - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } @@ -849,12 +872,6 @@ func (client *FileClient) forceCloseHandlesCreateRequest(ctx context.Context, ha // forceCloseHandlesHandleResponse handles the ForceCloseHandles response. func (client *FileClient) forceCloseHandlesHandleResponse(resp *http.Response) (FileClientForceCloseHandlesResponse, error) { result := FileClientForceCloseHandlesResponse{} - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -881,6 +898,12 @@ func (client *FileClient) forceCloseHandlesHandleResponse(resp *http.Response) ( } result.NumberOfHandlesFailedToClose = &numberOfHandlesFailedToClose } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } @@ -888,22 +911,25 @@ func (client *FileClient) forceCloseHandlesHandleResponse(resp *http.Response) ( // not return the content of the file. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - FileClientGetPropertiesOptions contains the optional parameters for the FileClient.GetProperties method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) GetProperties(ctx context.Context, options *FileClientGetPropertiesOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientGetPropertiesResponse, error) { + var err error req, err := client.getPropertiesCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return FileClientGetPropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientGetPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileClientGetPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileClientGetPropertiesResponse{}, err } - return client.getPropertiesHandleResponse(resp) + resp, err := client.getPropertiesHandleResponse(httpResp) + return resp, err } // getPropertiesCreateRequest creates the GetProperties request. @@ -923,7 +949,7 @@ func (client *FileClient) getPropertiesCreateRequest(ctx context.Context, option if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -937,23 +963,17 @@ func (client *FileClient) getPropertiesCreateRequest(ctx context.Context, option // getPropertiesHandleResponse handles the GetProperties response. func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (FileClientGetPropertiesResponse, error) { result := FileClientGetPropertiesResponse{} - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientGetPropertiesResponse{}, err - } - result.LastModified = &lastModified + if val := resp.Header.Get("Cache-Control"); val != "" { + result.CacheControl = &val } - for hh := range resp.Header { - if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") { - if result.Metadata == nil { - result.Metadata = map[string]*string{} - } - result.Metadata[hh[len("x-ms-meta-"):]] = to.Ptr(resp.Header.Get(hh)) - } + if val := resp.Header.Get("Content-Disposition"); val != "" { + result.ContentDisposition = &val } - if val := resp.Header.Get("x-ms-type"); val != "" { - result.FileType = &val + if val := resp.Header.Get("Content-Encoding"); val != "" { + result.ContentEncoding = &val + } + if val := resp.Header.Get("Content-Language"); val != "" { + result.ContentLanguage = &val } if val := resp.Header.Get("Content-Length"); val != "" { contentLength, err := strconv.ParseInt(val, 10, 64) @@ -962,12 +982,6 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File } result.ContentLength = &contentLength } - if val := resp.Header.Get("Content-Type"); val != "" { - result.ContentType = &val - } - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } if val := resp.Header.Get("Content-MD5"); val != "" { contentMD5, err := base64.StdEncoding.DecodeString(val) if err != nil { @@ -975,30 +989,8 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File } result.ContentMD5 = contentMD5 } - if val := resp.Header.Get("Content-Encoding"); val != "" { - result.ContentEncoding = &val - } - if val := resp.Header.Get("Cache-Control"); val != "" { - result.CacheControl = &val - } - if val := resp.Header.Get("Content-Disposition"); val != "" { - result.ContentDisposition = &val - } - if val := resp.Header.Get("Content-Language"); val != "" { - result.ContentLanguage = &val - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientGetPropertiesResponse{}, err - } - result.Date = &date + if val := resp.Header.Get("Content-Type"); val != "" { + result.ContentType = &val } if val := resp.Header.Get("x-ms-copy-completion-time"); val != "" { copyCompletionTime, err := time.Parse(time.RFC1123, val) @@ -1007,9 +999,6 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File } result.CopyCompletionTime = ©CompletionTime } - if val := resp.Header.Get("x-ms-copy-status-description"); val != "" { - result.CopyStatusDescription = &val - } if val := resp.Header.Get("x-ms-copy-id"); val != "" { result.CopyID = &val } @@ -1022,16 +1011,29 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File if val := resp.Header.Get("x-ms-copy-status"); val != "" { result.CopyStatus = (*CopyStatusType)(&val) } - if val := resp.Header.Get("x-ms-server-encrypted"); val != "" { - isServerEncrypted, err := strconv.ParseBool(val) + if val := resp.Header.Get("x-ms-copy-status-description"); val != "" { + result.CopyStatusDescription = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) if err != nil { return FileClientGetPropertiesResponse{}, err } - result.IsServerEncrypted = &isServerEncrypted + result.Date = &date + } + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-file-attributes"); val != "" { result.FileAttributes = &val } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) + if err != nil { + return FileClientGetPropertiesResponse{}, err + } + result.FileChangeTime = &fileChangeTime + } if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { fileCreationTime, err := time.Parse(ISO8601, val) if err != nil { @@ -1039,6 +1041,9 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File } result.FileCreationTime = &fileCreationTime } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { @@ -1046,21 +1051,28 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File } result.FileLastWriteTime = &fileLastWriteTime } - if val := resp.Header.Get("x-ms-file-change-time"); val != "" { - fileChangeTime, err := time.Parse(ISO8601, val) - if err != nil { - return FileClientGetPropertiesResponse{}, err - } - result.FileChangeTime = &fileChangeTime + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val } if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { result.FilePermissionKey = &val } - if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.ID = &val + if val := resp.Header.Get("x-ms-type"); val != "" { + result.FileType = &val } - if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.ParentID = &val + if val := resp.Header.Get("x-ms-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) + if err != nil { + return FileClientGetPropertiesResponse{}, err + } + result.IsServerEncrypted = &isServerEncrypted + } + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientGetPropertiesResponse{}, err + } + result.LastModified = &lastModified } if val := resp.Header.Get("x-ms-lease-duration"); val != "" { result.LeaseDuration = (*LeaseDurationType)(&val) @@ -1071,28 +1083,45 @@ func (client *FileClient) getPropertiesHandleResponse(resp *http.Response) (File if val := resp.Header.Get("x-ms-lease-status"); val != "" { result.LeaseStatus = (*LeaseStatusType)(&val) } + for hh := range resp.Header { + if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") { + if result.Metadata == nil { + result.Metadata = map[string]*string{} + } + result.Metadata[hh[len("x-ms-meta-"):]] = to.Ptr(resp.Header.Get(hh)) + } + } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } // GetRangeList - Returns the list of valid ranges for a file. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - FileClientGetRangeListOptions contains the optional parameters for the FileClient.GetRangeList method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) GetRangeList(ctx context.Context, options *FileClientGetRangeListOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientGetRangeListResponse, error) { + var err error req, err := client.getRangeListCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return FileClientGetRangeListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientGetRangeListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileClientGetRangeListResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileClientGetRangeListResponse{}, err } - return client.getRangeListHandleResponse(resp) + resp, err := client.getRangeListHandleResponse(httpResp) + return resp, err } // getRangeListCreateRequest creates the GetRangeList request. @@ -1113,7 +1142,7 @@ func (client *FileClient) getRangeListCreateRequest(ctx context.Context, options reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.Range != nil { req.Raw().Header["x-ms-range"] = []string{*options.Range} } @@ -1133,12 +1162,12 @@ func (client *FileClient) getRangeListCreateRequest(ctx context.Context, options // getRangeListHandleResponse handles the GetRangeList response. func (client *FileClient) getRangeListHandleResponse(resp *http.Response) (FileClientGetRangeListResponse, error) { result := FileClientGetRangeListResponse{} - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) if err != nil { return FileClientGetRangeListResponse{}, err } - result.LastModified = &lastModified + result.Date = &date } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) @@ -1150,19 +1179,19 @@ func (client *FileClient) getRangeListHandleResponse(resp *http.Response) (FileC } result.FileContentLength = &fileContentLength } + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientGetRangeListResponse{}, err + } + result.LastModified = &lastModified + } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientGetRangeListResponse{}, err - } - result.Date = &date - } if err := runtime.UnmarshalAsXML(resp, &result.ShareFileRangeList); err != nil { return FileClientGetRangeListResponse{}, err } @@ -1172,21 +1201,24 @@ func (client *FileClient) getRangeListHandleResponse(resp *http.Response) (FileC // ListHandles - Lists handles for file // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - FileClientListHandlesOptions contains the optional parameters for the FileClient.ListHandles method. func (client *FileClient) ListHandles(ctx context.Context, options *FileClientListHandlesOptions) (FileClientListHandlesResponse, error) { + var err error req, err := client.listHandlesCreateRequest(ctx, options) if err != nil { return FileClientListHandlesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientListHandlesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileClientListHandlesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileClientListHandlesResponse{}, err } - return client.listHandlesHandleResponse(resp) + resp, err := client.listHandlesHandleResponse(httpResp) + return resp, err } // listHandlesCreateRequest creates the ListHandles request. @@ -1210,7 +1242,7 @@ func (client *FileClient) listHandlesCreateRequest(ctx context.Context, options reqQP.Set("sharesnapshot", *options.Sharesnapshot) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if client.allowTrailingDot != nil { req.Raw().Header["x-ms-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowTrailingDot)} } @@ -1227,12 +1259,6 @@ func (client *FileClient) listHandlesHandleResponse(resp *http.Response) (FileCl if val := resp.Header.Get("Content-Type"); val != "" { result.ContentType = &val } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -1240,6 +1266,12 @@ func (client *FileClient) listHandlesHandleResponse(resp *http.Response) (FileCl } result.Date = &date } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } if err := runtime.UnmarshalAsXML(resp, &result.ListHandlesResponse); err != nil { return FileClientListHandlesResponse{}, err } @@ -1249,22 +1281,25 @@ func (client *FileClient) listHandlesHandleResponse(resp *http.Response) (FileCl // ReleaseLease - [Update] The Lease File operation establishes and manages a lock on a file for write and delete operations // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - leaseID - Specifies the current lease ID on the resource. // - options - FileClientReleaseLeaseOptions contains the optional parameters for the FileClient.ReleaseLease method. func (client *FileClient) ReleaseLease(ctx context.Context, leaseID string, options *FileClientReleaseLeaseOptions) (FileClientReleaseLeaseResponse, error) { + var err error req, err := client.releaseLeaseCreateRequest(ctx, leaseID, options) if err != nil { return FileClientReleaseLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientReleaseLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileClientReleaseLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileClientReleaseLeaseResponse{}, err } - return client.releaseLeaseHandleResponse(resp) + resp, err := client.releaseLeaseHandleResponse(httpResp) + return resp, err } // releaseLeaseCreateRequest creates the ReleaseLease request. @@ -1281,7 +1316,7 @@ func (client *FileClient) releaseLeaseCreateRequest(ctx context.Context, leaseID req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-lease-action"] = []string{"release"} req.Raw().Header["x-ms-lease-id"] = []string{leaseID} - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -1298,6 +1333,16 @@ func (client *FileClient) releaseLeaseCreateRequest(ctx context.Context, leaseID // releaseLeaseHandleResponse handles the ReleaseLease response. func (client *FileClient) releaseLeaseHandleResponse(resp *http.Response) (FileClientReleaseLeaseResponse, error) { result := FileClientReleaseLeaseResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientReleaseLeaseResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -1308,29 +1353,19 @@ func (client *FileClient) releaseLeaseHandleResponse(resp *http.Response) (FileC } result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientReleaseLeaseResponse{}, err - } - result.Date = &date - } return result, nil } // Rename - Renames a file // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - renameSource - Required. Specifies the URI-style path of the source file, up to 2 KB in length. // - options - FileClientRenameOptions contains the optional parameters for the FileClient.Rename method. // - SourceLeaseAccessConditions - SourceLeaseAccessConditions contains a group of parameters for the DirectoryClient.Rename @@ -1340,18 +1375,21 @@ func (client *FileClient) releaseLeaseHandleResponse(resp *http.Response) (FileC // - CopyFileSMBInfo - CopyFileSMBInfo contains a group of parameters for the DirectoryClient.Rename method. // - ShareFileHTTPHeaders - ShareFileHTTPHeaders contains a group of parameters for the FileClient.Create method. func (client *FileClient) Rename(ctx context.Context, renameSource string, options *FileClientRenameOptions, sourceLeaseAccessConditions *SourceLeaseAccessConditions, destinationLeaseAccessConditions *DestinationLeaseAccessConditions, copyFileSMBInfo *CopyFileSMBInfo, shareFileHTTPHeaders *ShareFileHTTPHeaders) (FileClientRenameResponse, error) { + var err error req, err := client.renameCreateRequest(ctx, renameSource, options, sourceLeaseAccessConditions, destinationLeaseAccessConditions, copyFileSMBInfo, shareFileHTTPHeaders) if err != nil { return FileClientRenameResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientRenameResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileClientRenameResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileClientRenameResponse{}, err } - return client.renameHandleResponse(resp) + resp, err := client.renameHandleResponse(httpResp) + return resp, err } // renameCreateRequest creates the Rename request. @@ -1366,7 +1404,7 @@ func (client *FileClient) renameCreateRequest(ctx context.Context, renameSource reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} req.Raw().Header["x-ms-file-rename-source"] = []string{renameSource} if options != nil && options.ReplaceIfExists != nil { req.Raw().Header["x-ms-file-rename-replace-if-exists"] = []string{strconv.FormatBool(*options.ReplaceIfExists)} @@ -1424,22 +1462,6 @@ func (client *FileClient) renameCreateRequest(ctx context.Context, renameSource // renameHandleResponse handles the Rename response. func (client *FileClient) renameHandleResponse(resp *http.Response) (FileClientRenameResponse, error) { result := FileClientRenameResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientRenameResponse{}, err - } - result.LastModified = &lastModified - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -1447,19 +1469,19 @@ func (client *FileClient) renameHandleResponse(resp *http.Response) (FileClientR } result.Date = &date } - if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { - isServerEncrypted, err := strconv.ParseBool(val) - if err != nil { - return FileClientRenameResponse{}, err - } - result.IsServerEncrypted = &isServerEncrypted - } - if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { - result.FilePermissionKey = &val + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-file-attributes"); val != "" { result.FileAttributes = &val } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) + if err != nil { + return FileClientRenameResponse{}, err + } + result.FileChangeTime = &fileChangeTime + } if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { fileCreationTime, err := time.Parse(ISO8601, val) if err != nil { @@ -1467,6 +1489,9 @@ func (client *FileClient) renameHandleResponse(resp *http.Response) (FileClientR } result.FileCreationTime = &fileCreationTime } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { @@ -1474,18 +1499,31 @@ func (client *FileClient) renameHandleResponse(resp *http.Response) (FileClientR } result.FileLastWriteTime = &fileLastWriteTime } - if val := resp.Header.Get("x-ms-file-change-time"); val != "" { - fileChangeTime, err := time.Parse(ISO8601, val) + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val + } + if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { + result.FilePermissionKey = &val + } + if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) if err != nil { return FileClientRenameResponse{}, err } - result.FileChangeTime = &fileChangeTime + result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.ID = &val + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientRenameResponse{}, err + } + result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.ParentID = &val + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val } return result, nil } @@ -1493,23 +1531,26 @@ func (client *FileClient) renameHandleResponse(resp *http.Response) (FileClientR // SetHTTPHeaders - Sets HTTP headers on the file. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - FileClientSetHTTPHeadersOptions contains the optional parameters for the FileClient.SetHTTPHeaders method. // - ShareFileHTTPHeaders - ShareFileHTTPHeaders contains a group of parameters for the FileClient.Create method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) SetHTTPHeaders(ctx context.Context, options *FileClientSetHTTPHeadersOptions, shareFileHTTPHeaders *ShareFileHTTPHeaders, leaseAccessConditions *LeaseAccessConditions) (FileClientSetHTTPHeadersResponse, error) { + var err error req, err := client.setHTTPHeadersCreateRequest(ctx, options, shareFileHTTPHeaders, leaseAccessConditions) if err != nil { return FileClientSetHTTPHeadersResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientSetHTTPHeadersResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileClientSetHTTPHeadersResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileClientSetHTTPHeadersResponse{}, err } - return client.setHTTPHeadersHandleResponse(resp) + resp, err := client.setHTTPHeadersHandleResponse(httpResp) + return resp, err } // setHTTPHeadersCreateRequest creates the SetHTTPHeaders request. @@ -1524,7 +1565,7 @@ func (client *FileClient) setHTTPHeadersCreateRequest(ctx context.Context, optio reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.FileContentLength != nil { req.Raw().Header["x-ms-content-length"] = []string{strconv.FormatInt(*options.FileContentLength, 10)} } @@ -1580,22 +1621,6 @@ func (client *FileClient) setHTTPHeadersCreateRequest(ctx context.Context, optio // setHTTPHeadersHandleResponse handles the SetHTTPHeaders response. func (client *FileClient) setHTTPHeadersHandleResponse(resp *http.Response) (FileClientSetHTTPHeadersResponse, error) { result := FileClientSetHTTPHeadersResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientSetHTTPHeadersResponse{}, err - } - result.LastModified = &lastModified - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -1603,19 +1628,19 @@ func (client *FileClient) setHTTPHeadersHandleResponse(resp *http.Response) (Fil } result.Date = &date } - if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { - isServerEncrypted, err := strconv.ParseBool(val) - if err != nil { - return FileClientSetHTTPHeadersResponse{}, err - } - result.IsServerEncrypted = &isServerEncrypted - } - if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { - result.FilePermissionKey = &val + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) } if val := resp.Header.Get("x-ms-file-attributes"); val != "" { result.FileAttributes = &val } + if val := resp.Header.Get("x-ms-file-change-time"); val != "" { + fileChangeTime, err := time.Parse(ISO8601, val) + if err != nil { + return FileClientSetHTTPHeadersResponse{}, err + } + result.FileChangeTime = &fileChangeTime + } if val := resp.Header.Get("x-ms-file-creation-time"); val != "" { fileCreationTime, err := time.Parse(ISO8601, val) if err != nil { @@ -1623,6 +1648,9 @@ func (client *FileClient) setHTTPHeadersHandleResponse(resp *http.Response) (Fil } result.FileCreationTime = &fileCreationTime } + if val := resp.Header.Get("x-ms-file-id"); val != "" { + result.ID = &val + } if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { @@ -1630,18 +1658,31 @@ func (client *FileClient) setHTTPHeadersHandleResponse(resp *http.Response) (Fil } result.FileLastWriteTime = &fileLastWriteTime } - if val := resp.Header.Get("x-ms-file-change-time"); val != "" { - fileChangeTime, err := time.Parse(ISO8601, val) + if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { + result.ParentID = &val + } + if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { + result.FilePermissionKey = &val + } + if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { + isServerEncrypted, err := strconv.ParseBool(val) if err != nil { return FileClientSetHTTPHeadersResponse{}, err } - result.FileChangeTime = &fileChangeTime + result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-id"); val != "" { - result.ID = &val + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientSetHTTPHeadersResponse{}, err + } + result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-file-parent-id"); val != "" { - result.ParentID = &val + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val } return result, nil } @@ -1649,22 +1690,25 @@ func (client *FileClient) setHTTPHeadersHandleResponse(resp *http.Response) (Fil // SetMetadata - Updates user-defined metadata for the specified file. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - FileClientSetMetadataOptions contains the optional parameters for the FileClient.SetMetadata method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) SetMetadata(ctx context.Context, options *FileClientSetMetadataOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientSetMetadataResponse, error) { + var err error req, err := client.setMetadataCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return FileClientSetMetadataResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientSetMetadataResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileClientSetMetadataResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileClientSetMetadataResponse{}, err } - return client.setMetadataHandleResponse(resp) + resp, err := client.setMetadataHandleResponse(httpResp) + return resp, err } // setMetadataCreateRequest creates the SetMetadata request. @@ -1686,7 +1730,7 @@ func (client *FileClient) setMetadataCreateRequest(ctx context.Context, options } } } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -1703,15 +1747,6 @@ func (client *FileClient) setMetadataCreateRequest(ctx context.Context, options // setMetadataHandleResponse handles the SetMetadata response. func (client *FileClient) setMetadataHandleResponse(resp *http.Response) (FileClientSetMetadataResponse, error) { result := FileClientSetMetadataResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -1719,6 +1754,9 @@ func (client *FileClient) setMetadataHandleResponse(resp *http.Response) (FileCl } result.Date = &date } + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) + } if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { isServerEncrypted, err := strconv.ParseBool(val) if err != nil { @@ -1733,13 +1771,19 @@ func (client *FileClient) setMetadataHandleResponse(resp *http.Response) (FileCl } result.LastModified = &lastModified } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } // StartCopy - Copies a blob or file to a destination file within the storage account. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - copySource - Specifies the URL of the source file or blob, up to 2 KB in length. To copy a file to another file within // the same storage account, you may use Shared Key to authenticate the source file. If you are // copying a file from another storage account, or if you are copying a blob from the same storage account or another storage @@ -1750,18 +1794,21 @@ func (client *FileClient) setMetadataHandleResponse(resp *http.Response) (FileCl // - CopyFileSMBInfo - CopyFileSMBInfo contains a group of parameters for the DirectoryClient.Rename method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) StartCopy(ctx context.Context, copySource string, options *FileClientStartCopyOptions, copyFileSMBInfo *CopyFileSMBInfo, leaseAccessConditions *LeaseAccessConditions) (FileClientStartCopyResponse, error) { + var err error req, err := client.startCopyCreateRequest(ctx, copySource, options, copyFileSMBInfo, leaseAccessConditions) if err != nil { return FileClientStartCopyResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientStartCopyResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return FileClientStartCopyResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return FileClientStartCopyResponse{}, err } - return client.startCopyHandleResponse(resp) + resp, err := client.startCopyHandleResponse(httpResp) + return resp, err } // startCopyCreateRequest creates the StartCopy request. @@ -1775,7 +1822,7 @@ func (client *FileClient) startCopyCreateRequest(ctx context.Context, copySource reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.Metadata != nil { for k, v := range options.Metadata { if v != nil { @@ -1830,6 +1877,19 @@ func (client *FileClient) startCopyCreateRequest(ctx context.Context, copySource // startCopyHandleResponse handles the StartCopy response. func (client *FileClient) startCopyHandleResponse(resp *http.Response) (FileClientStartCopyResponse, error) { result := FileClientStartCopyResponse{} + if val := resp.Header.Get("x-ms-copy-id"); val != "" { + result.CopyID = &val + } + if val := resp.Header.Get("x-ms-copy-status"); val != "" { + result.CopyStatus = (*CopyStatusType)(&val) + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return FileClientStartCopyResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -1846,26 +1906,13 @@ func (client *FileClient) startCopyHandleResponse(resp *http.Response) (FileClie if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientStartCopyResponse{}, err - } - result.Date = &date - } - if val := resp.Header.Get("x-ms-copy-id"); val != "" { - result.CopyID = &val - } - if val := resp.Header.Get("x-ms-copy-status"); val != "" { - result.CopyStatus = (*CopyStatusType)(&val) - } return result, nil } // UploadRange - Upload a range of bytes to a file. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - rangeParam - Specifies the range of bytes to be written. Both the start and end of the range must be specified. For an // update operation, the range can be up to 4 MB in size. For a clear operation, the range can be // up to the value of the file's full size. The File service accepts only a single byte range for the Range and 'x-ms-range' @@ -1882,18 +1929,21 @@ func (client *FileClient) startCopyHandleResponse(resp *http.Response) (FileClie // - options - FileClientUploadRangeOptions contains the optional parameters for the FileClient.UploadRange method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) UploadRange(ctx context.Context, rangeParam string, fileRangeWrite FileRangeWriteType, contentLength int64, optionalbody io.ReadSeekCloser, options *FileClientUploadRangeOptions, leaseAccessConditions *LeaseAccessConditions) (FileClientUploadRangeResponse, error) { + var err error req, err := client.uploadRangeCreateRequest(ctx, rangeParam, fileRangeWrite, contentLength, optionalbody, options, leaseAccessConditions) if err != nil { return FileClientUploadRangeResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientUploadRangeResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return FileClientUploadRangeResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return FileClientUploadRangeResponse{}, err } - return client.uploadRangeHandleResponse(resp) + resp, err := client.uploadRangeHandleResponse(httpResp) + return resp, err } // uploadRangeCreateRequest creates the UploadRange request. @@ -1914,7 +1964,7 @@ func (client *FileClient) uploadRangeCreateRequest(ctx context.Context, rangePar if options != nil && options.ContentMD5 != nil { req.Raw().Header["Content-MD5"] = []string{base64.StdEncoding.EncodeToString(options.ContentMD5)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -1937,16 +1987,6 @@ func (client *FileClient) uploadRangeCreateRequest(ctx context.Context, rangePar // uploadRangeHandleResponse handles the UploadRange response. func (client *FileClient) uploadRangeHandleResponse(resp *http.Response) (FileClientUploadRangeResponse, error) { result := FileClientUploadRangeResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) - if err != nil { - return FileClientUploadRangeResponse{}, err - } - result.LastModified = &lastModified - } if val := resp.Header.Get("Content-MD5"); val != "" { contentMD5, err := base64.StdEncoding.DecodeString(val) if err != nil { @@ -1954,12 +1994,6 @@ func (client *FileClient) uploadRangeHandleResponse(resp *http.Response) (FileCl } result.ContentMD5 = contentMD5 } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -1967,6 +2001,16 @@ func (client *FileClient) uploadRangeHandleResponse(resp *http.Response) (FileCl } result.Date = &date } + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) + } + if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { + fileLastWriteTime, err := time.Parse(ISO8601, val) + if err != nil { + return FileClientUploadRangeResponse{}, err + } + result.FileLastWriteTime = &fileLastWriteTime + } if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { isServerEncrypted, err := strconv.ParseBool(val) if err != nil { @@ -1974,12 +2018,18 @@ func (client *FileClient) uploadRangeHandleResponse(resp *http.Response) (FileCl } result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { - fileLastWriteTime, err := time.Parse(ISO8601, val) + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) if err != nil { return FileClientUploadRangeResponse{}, err } - result.FileLastWriteTime = &fileLastWriteTime + result.LastModified = &lastModified + } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val } return result, nil } @@ -1987,7 +2037,7 @@ func (client *FileClient) uploadRangeHandleResponse(resp *http.Response) (FileCl // UploadRangeFromURL - Upload a range of bytes to a file where the contents are read from a URL. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - rangeParam - Writes data to the specified byte range in the file. // - copySource - Specifies the URL of the source file or blob, up to 2 KB in length. To copy a file to another file within // the same storage account, you may use Shared Key to authenticate the source file. If you are @@ -2002,18 +2052,21 @@ func (client *FileClient) uploadRangeHandleResponse(resp *http.Response) (FileCl // method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *FileClient) UploadRangeFromURL(ctx context.Context, rangeParam string, copySource string, contentLength int64, options *FileClientUploadRangeFromURLOptions, sourceModifiedAccessConditions *SourceModifiedAccessConditions, leaseAccessConditions *LeaseAccessConditions) (FileClientUploadRangeFromURLResponse, error) { + var err error req, err := client.uploadRangeFromURLCreateRequest(ctx, rangeParam, copySource, contentLength, options, sourceModifiedAccessConditions, leaseAccessConditions) if err != nil { return FileClientUploadRangeFromURLResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileClientUploadRangeFromURLResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return FileClientUploadRangeFromURLResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return FileClientUploadRangeFromURLResponse{}, err } - return client.uploadRangeFromURLHandleResponse(resp) + resp, err := client.uploadRangeFromURLHandleResponse(httpResp) + return resp, err } // uploadRangeFromURLCreateRequest creates the UploadRangeFromURL request. @@ -2044,7 +2097,7 @@ func (client *FileClient) uploadRangeFromURLCreateRequest(ctx context.Context, r if sourceModifiedAccessConditions != nil && sourceModifiedAccessConditions.SourceIfNoneMatchCRC64 != nil { req.Raw().Header["x-ms-source-if-none-match-crc64"] = []string{base64.StdEncoding.EncodeToString(sourceModifiedAccessConditions.SourceIfNoneMatchCRC64)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -2060,6 +2113,9 @@ func (client *FileClient) uploadRangeFromURLCreateRequest(ctx context.Context, r if client.allowSourceTrailingDot != nil { req.Raw().Header["x-ms-source-allow-trailing-dot"] = []string{strconv.FormatBool(*client.allowSourceTrailingDot)} } + if client.fileRequestIntent != nil { + req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} + } req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -2067,35 +2123,29 @@ func (client *FileClient) uploadRangeFromURLCreateRequest(ctx context.Context, r // uploadRangeFromURLHandleResponse handles the UploadRangeFromURL response. func (client *FileClient) uploadRangeFromURLHandleResponse(resp *http.Response) (FileClientUploadRangeFromURLResponse, error) { result := FileClientUploadRangeFromURLResponse{} - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) - } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) + if val := resp.Header.Get("Content-MD5"); val != "" { + contentMD5, err := base64.StdEncoding.DecodeString(val) if err != nil { return FileClientUploadRangeFromURLResponse{}, err } - result.LastModified = &lastModified + result.ContentMD5 = contentMD5 } - if val := resp.Header.Get("x-ms-content-crc64"); val != "" { - xMSContentCRC64, err := base64.StdEncoding.DecodeString(val) + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) if err != nil { return FileClientUploadRangeFromURLResponse{}, err } - result.XMSContentCRC64 = xMSContentCRC64 - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val + result.Date = &date } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) + if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { + fileLastWriteTime, err := time.Parse(ISO8601, val) if err != nil { return FileClientUploadRangeFromURLResponse{}, err } - result.Date = &date + result.FileLastWriteTime = &fileLastWriteTime } if val := resp.Header.Get("x-ms-request-server-encrypted"); val != "" { isServerEncrypted, err := strconv.ParseBool(val) @@ -2104,19 +2154,25 @@ func (client *FileClient) uploadRangeFromURLHandleResponse(resp *http.Response) } result.IsServerEncrypted = &isServerEncrypted } - if val := resp.Header.Get("x-ms-file-last-write-time"); val != "" { - fileLastWriteTime, err := time.Parse(ISO8601, val) + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) if err != nil { return FileClientUploadRangeFromURLResponse{}, err } - result.FileLastWriteTime = &fileLastWriteTime + result.LastModified = &lastModified } - if val := resp.Header.Get("Content-MD5"); val != "" { - contentMD5, err := base64.StdEncoding.DecodeString(val) + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } + if val := resp.Header.Get("x-ms-content-crc64"); val != "" { + xMSContentCRC64, err := base64.StdEncoding.DecodeString(val) if err != nil { return FileClientUploadRangeFromURLResponse{}, err } - result.ContentMD5 = contentMD5 + result.XMSContentCRC64 = xMSContentCRC64 } return result, nil } diff --git a/sdk/storage/azfile/internal/generated/zz_models.go b/sdk/storage/azfile/internal/generated/zz_models.go index a27b53f42cea..448879f6564c 100644 --- a/sdk/storage/azfile/internal/generated/zz_models.go +++ b/sdk/storage/azfile/internal/generated/zz_models.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated @@ -34,30 +33,6 @@ type ClearRange struct { Start *int64 `xml:"Start"` } -// CopyFileSMBInfo contains a group of parameters for the DirectoryClient.Rename method. -type CopyFileSMBInfo struct { - // Specifies either the option to copy file attributes from a source file(source) to a target file or a list of attributes - // to set on a target file. - FileAttributes *string - // Specifies either the option to copy file last write time from a source file(source) to a target file or a time value in - // ISO 8601 format to set as last write time on a target file. - FileChangeTime *string - // Specifies either the option to copy file creation time from a source file(source) to a target file or a time value in ISO - // 8601 format to set as creation time on a target file. - FileCreationTime *string - // Specifies either the option to copy file last write time from a source file(source) to a target file or a time value in - // ISO 8601 format to set as last write time on a target file. - FileLastWriteTime *string - // Specifies the option to copy file security descriptor from source file or to set it using the value which is defined by - // the header value of x-ms-file-permission or x-ms-file-permission-key. - FilePermissionCopyMode *PermissionCopyModeType - // Specifies the option to overwrite the target file if it already exists and has read-only attribute set. - IgnoreReadOnly *bool - // Specifies the option to set archive attribute on a target file. True means archive attribute will be set on a target file - // despite attribute overrides or a source file state. - SetArchiveAttribute *bool -} - // CORSRule - CORS is an HTTP feature that enables a web application running under one domain to access resources in another // domain. Web browsers implement a security restriction known as same-origin policy that // prevents a web page from calling APIs in a different domain; CORS provides a secure way to allow one domain (the origin @@ -83,16 +58,6 @@ type CORSRule struct { MaxAgeInSeconds *int32 `xml:"MaxAgeInSeconds"` } -// DestinationLeaseAccessConditions contains a group of parameters for the DirectoryClient.Rename method. -type DestinationLeaseAccessConditions struct { - // Required if the destination file has an active infinite lease. The lease ID specified for this header must match the lease - // ID of the destination file. If the request does not include the lease ID or - // it is not valid, the operation fails with status code 412 (Precondition Failed). If this header is specified and the destination - // file does not currently have an active lease, the operation will also - // fail with status code 412 (Precondition Failed). - DestinationLeaseID *string -} - // Directory - A listed directory item. type Directory struct { // REQUIRED @@ -105,167 +70,6 @@ type Directory struct { Properties *FileProperty `xml:"Properties"` } -// DirectoryClientCreateOptions contains the optional parameters for the DirectoryClient.Create method. -type DirectoryClientCreateOptions struct { - // If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. - // ‘None’ can also be specified as default. - FileAttributes *string - // Change time for the file/directory. Default value: Now. - FileChangeTime *string - // Creation time for the file/directory. Default value: Now. - FileCreationTime *string - // Last write time for the file/directory. Default value: Now. - FileLastWriteTime *string - // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission - // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default - // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission - // or x-ms-file-permission-key should be specified. - FilePermission *string - // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key - // should be specified. - FilePermissionKey *string - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// DirectoryClientDeleteOptions contains the optional parameters for the DirectoryClient.Delete method. -type DirectoryClientDeleteOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// DirectoryClientForceCloseHandlesOptions contains the optional parameters for the DirectoryClient.ForceCloseHandles method. -type DirectoryClientForceCloseHandlesOptions struct { - // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns - // a marker value within the response body if the list returned was not complete. - // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque - // to the client. - Marker *string - // Specifies operation should apply to the directory specified in the URI, its files, its subdirectories and their files. - Recursive *bool - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// DirectoryClientGetPropertiesOptions contains the optional parameters for the DirectoryClient.GetProperties method. -type DirectoryClientGetPropertiesOptions struct { - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// DirectoryClientListFilesAndDirectoriesSegmentOptions contains the optional parameters for the DirectoryClient.NewListFilesAndDirectoriesSegmentPager -// method. -type DirectoryClientListFilesAndDirectoriesSegmentOptions struct { - // Include this parameter to specify one or more datasets to include in the response. - Include []ListFilesIncludeType - // Include extended information. - IncludeExtendedInfo *bool - // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns - // a marker value within the response body if the list returned was not complete. - // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque - // to the client. - Marker *string - // Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater - // than 5,000, the server will return up to 5,000 items. - Maxresults *int32 - // Filters the results to return only entries whose name begins with the specified prefix. - Prefix *string - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// DirectoryClientListHandlesOptions contains the optional parameters for the DirectoryClient.ListHandles method. -type DirectoryClientListHandlesOptions struct { - // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns - // a marker value within the response body if the list returned was not complete. - // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque - // to the client. - Marker *string - // Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater - // than 5,000, the server will return up to 5,000 items. - Maxresults *int32 - // Specifies operation should apply to the directory specified in the URI, its files, its subdirectories and their files. - Recursive *bool - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// DirectoryClientRenameOptions contains the optional parameters for the DirectoryClient.Rename method. -type DirectoryClientRenameOptions struct { - // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission - // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default - // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission - // or x-ms-file-permission-key should be specified. - FilePermission *string - // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key - // should be specified. - FilePermissionKey *string - // Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting destination file should be respected. - // If true, the rename will succeed, otherwise, a previous file at the - // destination with the ReadOnly attribute set will cause the rename to fail. - IgnoreReadOnly *bool - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // Optional. A boolean value for if the destination file already exists, whether this request will overwrite the file or not. - // If true, the rename will succeed and will overwrite the destination file. If - // not provided or if false and the destination file does exist, the request will not overwrite the destination file. If provided - // and the destination file doesn’t exist, the rename will succeed. Note: - // This value does not override the x-ms-file-copy-ignore-read-only header value. - ReplaceIfExists *bool - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// DirectoryClientSetMetadataOptions contains the optional parameters for the DirectoryClient.SetMetadata method. -type DirectoryClientSetMetadataOptions struct { - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// DirectoryClientSetPropertiesOptions contains the optional parameters for the DirectoryClient.SetProperties method. -type DirectoryClientSetPropertiesOptions struct { - // If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. - // ‘None’ can also be specified as default. - FileAttributes *string - // Change time for the file/directory. Default value: Now. - FileChangeTime *string - // Creation time for the file/directory. Default value: Now. - FileCreationTime *string - // Last write time for the file/directory. Default value: Now. - FileLastWriteTime *string - // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission - // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default - // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission - // or x-ms-file-permission-key should be specified. - FilePermission *string - // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key - // should be specified. - FilePermissionKey *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - // File - A listed file item. type File struct { // REQUIRED @@ -278,268 +82,6 @@ type File struct { PermissionKey *string `xml:"PermissionKey"` } -// FileClientAbortCopyOptions contains the optional parameters for the FileClient.AbortCopy method. -type FileClientAbortCopyOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientAcquireLeaseOptions contains the optional parameters for the FileClient.AcquireLease method. -type FileClientAcquireLeaseOptions struct { - // Proposed lease ID, in a GUID string format. The File service returns 400 (Invalid request) if the proposed lease ID is - // not in the correct format. See Guid Constructor (String) for a list of valid GUID - // string formats. - ProposedLeaseID *string - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientBreakLeaseOptions contains the optional parameters for the FileClient.BreakLease method. -type FileClientBreakLeaseOptions struct { - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientChangeLeaseOptions contains the optional parameters for the FileClient.ChangeLease method. -type FileClientChangeLeaseOptions struct { - // Proposed lease ID, in a GUID string format. The File service returns 400 (Invalid request) if the proposed lease ID is - // not in the correct format. See Guid Constructor (String) for a list of valid GUID - // string formats. - ProposedLeaseID *string - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientCreateOptions contains the optional parameters for the FileClient.Create method. -type FileClientCreateOptions struct { - // If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. - // ‘None’ can also be specified as default. - FileAttributes *string - // Change time for the file/directory. Default value: Now. - FileChangeTime *string - // Creation time for the file/directory. Default value: Now. - FileCreationTime *string - // Last write time for the file/directory. Default value: Now. - FileLastWriteTime *string - // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission - // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default - // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission - // or x-ms-file-permission-key should be specified. - FilePermission *string - // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key - // should be specified. - FilePermissionKey *string - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientDeleteOptions contains the optional parameters for the FileClient.Delete method. -type FileClientDeleteOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientDownloadOptions contains the optional parameters for the FileClient.Download method. -type FileClientDownloadOptions struct { - // Return file data only from the specified byte range. - Range *string - // When this header is set to true and specified together with the Range header, the service returns the MD5 hash for the - // range, as long as the range is less than or equal to 4 MB in size. - RangeGetContentMD5 *bool - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientForceCloseHandlesOptions contains the optional parameters for the FileClient.ForceCloseHandles method. -type FileClientForceCloseHandlesOptions struct { - // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns - // a marker value within the response body if the list returned was not complete. - // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque - // to the client. - Marker *string - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientGetPropertiesOptions contains the optional parameters for the FileClient.GetProperties method. -type FileClientGetPropertiesOptions struct { - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientGetRangeListOptions contains the optional parameters for the FileClient.GetRangeList method. -type FileClientGetRangeListOptions struct { - // The previous snapshot parameter is an opaque DateTime value that, when present, specifies the previous snapshot. - Prevsharesnapshot *string - // Specifies the range of bytes over which to list ranges, inclusively. - Range *string - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientListHandlesOptions contains the optional parameters for the FileClient.ListHandles method. -type FileClientListHandlesOptions struct { - // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns - // a marker value within the response body if the list returned was not complete. - // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque - // to the client. - Marker *string - // Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater - // than 5,000, the server will return up to 5,000 items. - Maxresults *int32 - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientReleaseLeaseOptions contains the optional parameters for the FileClient.ReleaseLease method. -type FileClientReleaseLeaseOptions struct { - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientRenameOptions contains the optional parameters for the FileClient.Rename method. -type FileClientRenameOptions struct { - // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission - // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default - // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission - // or x-ms-file-permission-key should be specified. - FilePermission *string - // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key - // should be specified. - FilePermissionKey *string - // Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting destination file should be respected. - // If true, the rename will succeed, otherwise, a previous file at the - // destination with the ReadOnly attribute set will cause the rename to fail. - IgnoreReadOnly *bool - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // Optional. A boolean value for if the destination file already exists, whether this request will overwrite the file or not. - // If true, the rename will succeed and will overwrite the destination file. If - // not provided or if false and the destination file does exist, the request will not overwrite the destination file. If provided - // and the destination file doesn’t exist, the rename will succeed. Note: - // This value does not override the x-ms-file-copy-ignore-read-only header value. - ReplaceIfExists *bool - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientSetHTTPHeadersOptions contains the optional parameters for the FileClient.SetHTTPHeaders method. -type FileClientSetHTTPHeadersOptions struct { - // If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. - // ‘None’ can also be specified as default. - FileAttributes *string - // Change time for the file/directory. Default value: Now. - FileChangeTime *string - // Resizes a file to the specified size. If the specified byte value is less than the current size of the file, then all ranges - // above the specified byte value are cleared. - FileContentLength *int64 - // Creation time for the file/directory. Default value: Now. - FileCreationTime *string - // Last write time for the file/directory. Default value: Now. - FileLastWriteTime *string - // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission - // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default - // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission - // or x-ms-file-permission-key should be specified. - FilePermission *string - // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key - // should be specified. - FilePermissionKey *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientSetMetadataOptions contains the optional parameters for the FileClient.SetMetadata method. -type FileClientSetMetadataOptions struct { - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientStartCopyOptions contains the optional parameters for the FileClient.StartCopy method. -type FileClientStartCopyOptions struct { - // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission - // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default - // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission - // or x-ms-file-permission-key should be specified. - FilePermission *string - // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key - // should be specified. - FilePermissionKey *string - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientUploadRangeFromURLOptions contains the optional parameters for the FileClient.UploadRangeFromURL method. -type FileClientUploadRangeFromURLOptions struct { - // Only Bearer type is supported. Credentials should be a valid OAuth access token to copy source. - CopySourceAuthorization *string - // If the file last write time should be preserved or overwritten - FileLastWrittenMode *FileLastWrittenMode - // Specify the crc64 calculated for the range of bytes that must be read from the copy source. - SourceContentCRC64 []byte - // Bytes of source data in the specified range. - SourceRange *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// FileClientUploadRangeOptions contains the optional parameters for the FileClient.UploadRange method. -type FileClientUploadRangeOptions struct { - // An MD5 hash of the content. This hash is used to verify the integrity of the data during transport. When the Content-MD5 - // header is specified, the File service compares the hash of the content that has - // arrived with the header value that was sent. If the two hashes do not match, the operation will fail with error code 400 - // (Bad Request). - ContentMD5 []byte - // If the file last write time should be preserved or overwritten - FileLastWrittenMode *FileLastWrittenMode - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - // FileProperty - File properties. type FileProperty struct { // REQUIRED; Content length of the file. This value may not be up-to-date since an SMB client may have modified the file locally. @@ -590,7 +132,8 @@ type Handle struct { Path *string `xml:"Path"` // REQUIRED; SMB session ID in context of which the file handle was opened - SessionID *string `xml:"SessionId"` + SessionID *string `xml:"SessionId"` + AccessRightList []*AccessRight `xml:"AccessRightList>AccessRight"` // Time handle was last connected to (UTC) LastReconnectTime *time.Time `xml:"LastReconnectTime"` @@ -599,12 +142,6 @@ type Handle struct { ParentID *string `xml:"ParentId"` } -// LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. -type LeaseAccessConditions struct { - // If specified, the operation only succeeds if the resource's lease is active and matches this ID. - LeaseID *string -} - // ListFilesAndDirectoriesSegmentResponse - An enumeration of directories and files. type ListFilesAndDirectoriesSegmentResponse struct { // REQUIRED @@ -689,40 +226,6 @@ type SMBSettings struct { Multichannel *SMBMultichannel `xml:"Multichannel"` } -// ServiceClientGetPropertiesOptions contains the optional parameters for the ServiceClient.GetProperties method. -type ServiceClientGetPropertiesOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ServiceClientListSharesSegmentOptions contains the optional parameters for the ServiceClient.NewListSharesSegmentPager -// method. -type ServiceClientListSharesSegmentOptions struct { - // Include this parameter to specify one or more datasets to include in the response. - Include []ListSharesIncludeType - // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns - // a marker value within the response body if the list returned was not complete. - // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque - // to the client. - Marker *string - // Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater - // than 5,000, the server will return up to 5,000 items. - Maxresults *int32 - // Filters the results to return only entries whose name begins with the specified prefix. - Prefix *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ServiceClientSetPropertiesOptions contains the optional parameters for the ServiceClient.SetProperties method. -type ServiceClientSetPropertiesOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - // Share - A listed Azure Storage share item. type Share struct { // REQUIRED @@ -738,214 +241,6 @@ type Share struct { Version *string `xml:"Version"` } -// ShareClientAcquireLeaseOptions contains the optional parameters for the ShareClient.AcquireLease method. -type ShareClientAcquireLeaseOptions struct { - // Proposed lease ID, in a GUID string format. The File service returns 400 (Invalid request) if the proposed lease ID is - // not in the correct format. See Guid Constructor (String) for a list of valid GUID - // string formats. - ProposedLeaseID *string - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientBreakLeaseOptions contains the optional parameters for the ShareClient.BreakLease method. -type ShareClientBreakLeaseOptions struct { - // For a break operation, proposed duration the lease should continue before it is broken, in seconds, between 0 and 60. This - // break period is only used if it is shorter than the time remaining on the - // lease. If longer, the time remaining on the lease is used. A new lease will not be available before the break period has - // expired, but the lease may be held for longer than the break period. If this - // header does not appear with a break operation, a fixed-duration lease breaks after the remaining lease period elapses, - // and an infinite lease breaks immediately. - BreakPeriod *int32 - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientChangeLeaseOptions contains the optional parameters for the ShareClient.ChangeLease method. -type ShareClientChangeLeaseOptions struct { - // Proposed lease ID, in a GUID string format. The File service returns 400 (Invalid request) if the proposed lease ID is - // not in the correct format. See Guid Constructor (String) for a list of valid GUID - // string formats. - ProposedLeaseID *string - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientCreateOptions contains the optional parameters for the ShareClient.Create method. -type ShareClientCreateOptions struct { - // Specifies the access tier of the share. - AccessTier *ShareAccessTier - // Protocols to enable on the share. - EnabledProtocols *string - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // Specifies the maximum size of the share, in gigabytes. - Quota *int32 - // Root squash to set on the share. Only valid for NFS shares. - RootSquash *ShareRootSquash - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientCreatePermissionOptions contains the optional parameters for the ShareClient.CreatePermission method. -type ShareClientCreatePermissionOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientCreateSnapshotOptions contains the optional parameters for the ShareClient.CreateSnapshot method. -type ShareClientCreateSnapshotOptions struct { - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientDeleteOptions contains the optional parameters for the ShareClient.Delete method. -type ShareClientDeleteOptions struct { - // Specifies the option include to delete the base share and all of its snapshots. - DeleteSnapshots *DeleteSnapshotsOptionType - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientGetAccessPolicyOptions contains the optional parameters for the ShareClient.GetAccessPolicy method. -type ShareClientGetAccessPolicyOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientGetPermissionOptions contains the optional parameters for the ShareClient.GetPermission method. -type ShareClientGetPermissionOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientGetPropertiesOptions contains the optional parameters for the ShareClient.GetProperties method. -type ShareClientGetPropertiesOptions struct { - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientGetStatisticsOptions contains the optional parameters for the ShareClient.GetStatistics method. -type ShareClientGetStatisticsOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientReleaseLeaseOptions contains the optional parameters for the ShareClient.ReleaseLease method. -type ShareClientReleaseLeaseOptions struct { - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientRenewLeaseOptions contains the optional parameters for the ShareClient.RenewLease method. -type ShareClientRenewLeaseOptions struct { - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. - Sharesnapshot *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientRestoreOptions contains the optional parameters for the ShareClient.Restore method. -type ShareClientRestoreOptions struct { - // Specifies the name of the previously-deleted share. - DeletedShareName *string - // Specifies the version of the previously-deleted share. - DeletedShareVersion *string - // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage - // analytics logging is enabled. - RequestID *string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientSetAccessPolicyOptions contains the optional parameters for the ShareClient.SetAccessPolicy method. -type ShareClientSetAccessPolicyOptions struct { - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientSetMetadataOptions contains the optional parameters for the ShareClient.SetMetadata method. -type ShareClientSetMetadataOptions struct { - // A name-value pair to associate with a file storage object. - Metadata map[string]*string - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareClientSetPropertiesOptions contains the optional parameters for the ShareClient.SetProperties method. -type ShareClientSetPropertiesOptions struct { - // Specifies the access tier of the share. - AccessTier *ShareAccessTier - // Specifies the maximum size of the share, in gigabytes. - Quota *int32 - // Root squash to set on the share. Only valid for NFS shares. - RootSquash *ShareRootSquash - // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. - // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] - Timeout *int32 -} - -// ShareFileHTTPHeaders contains a group of parameters for the FileClient.Create method. -type ShareFileHTTPHeaders struct { - // Sets the file's cache control. The File service stores this value but does not use or modify it. - CacheControl *string - // Sets the file's Content-Disposition header. - ContentDisposition *string - // Specifies which content encodings have been applied to the file. - ContentEncoding *string - // Specifies the natural languages used by this resource. - ContentLanguage *string - // Sets the file's MD5 hash. - ContentMD5 []byte - // Sets the MIME content type of the file. The default type is 'application/octet-stream'. - ContentType *string -} - // ShareFileRangeList - The list of file ranges type ShareFileRangeList struct { ClearRanges []*ClearRange `xml:"ClearRange"` @@ -1013,20 +308,6 @@ type SMBMultichannel struct { Enabled *bool `xml:"Enabled"` } -// SourceLeaseAccessConditions contains a group of parameters for the DirectoryClient.Rename method. -type SourceLeaseAccessConditions struct { - // Required if the source file has an active infinite lease. - SourceLeaseID *string -} - -// SourceModifiedAccessConditions contains a group of parameters for the FileClient.UploadRangeFromURL method. -type SourceModifiedAccessConditions struct { - // Specify the crc64 value to operate only on range with a matching crc64 checksum. - SourceIfMatchCRC64 []byte - // Specify the crc64 value to operate only on range without a matching crc64 checksum. - SourceIfNoneMatchCRC64 []byte -} - type StorageError struct { Message *string } diff --git a/sdk/storage/azfile/internal/generated/zz_models_serde.go b/sdk/storage/azfile/internal/generated/zz_models_serde.go index 94664adc2280..91a56c2eb3dc 100644 --- a/sdk/storage/azfile/internal/generated/zz_models_serde.go +++ b/sdk/storage/azfile/internal/generated/zz_models_serde.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated @@ -23,12 +22,12 @@ func (a AccessPolicy) MarshalXML(enc *xml.Encoder, start xml.StartElement) error type alias AccessPolicy aux := &struct { *alias - Expiry *timeRFC3339 `xml:"Expiry"` - Start *timeRFC3339 `xml:"Start"` + Expiry *dateTimeRFC3339 `xml:"Expiry"` + Start *dateTimeRFC3339 `xml:"Start"` }{ alias: (*alias)(&a), - Expiry: (*timeRFC3339)(a.Expiry), - Start: (*timeRFC3339)(a.Start), + Expiry: (*dateTimeRFC3339)(a.Expiry), + Start: (*dateTimeRFC3339)(a.Start), } return enc.EncodeElement(aux, start) } @@ -38,8 +37,8 @@ func (a *AccessPolicy) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) er type alias AccessPolicy aux := &struct { *alias - Expiry *timeRFC3339 `xml:"Expiry"` - Start *timeRFC3339 `xml:"Start"` + Expiry *dateTimeRFC3339 `xml:"Expiry"` + Start *dateTimeRFC3339 `xml:"Start"` }{ alias: (*alias)(a), } @@ -56,18 +55,18 @@ func (f FileProperty) MarshalXML(enc *xml.Encoder, start xml.StartElement) error type alias FileProperty aux := &struct { *alias - ChangeTime *timeRFC3339 `xml:"ChangeTime"` - CreationTime *timeRFC3339 `xml:"CreationTime"` - LastAccessTime *timeRFC3339 `xml:"LastAccessTime"` - LastModified *timeRFC1123 `xml:"Last-Modified"` - LastWriteTime *timeRFC3339 `xml:"LastWriteTime"` + ChangeTime *dateTimeRFC3339 `xml:"ChangeTime"` + CreationTime *dateTimeRFC3339 `xml:"CreationTime"` + LastAccessTime *dateTimeRFC3339 `xml:"LastAccessTime"` + LastModified *dateTimeRFC1123 `xml:"Last-Modified"` + LastWriteTime *dateTimeRFC3339 `xml:"LastWriteTime"` }{ alias: (*alias)(&f), - ChangeTime: (*timeRFC3339)(f.ChangeTime), - CreationTime: (*timeRFC3339)(f.CreationTime), - LastAccessTime: (*timeRFC3339)(f.LastAccessTime), - LastModified: (*timeRFC1123)(f.LastModified), - LastWriteTime: (*timeRFC3339)(f.LastWriteTime), + ChangeTime: (*dateTimeRFC3339)(f.ChangeTime), + CreationTime: (*dateTimeRFC3339)(f.CreationTime), + LastAccessTime: (*dateTimeRFC3339)(f.LastAccessTime), + LastModified: (*dateTimeRFC1123)(f.LastModified), + LastWriteTime: (*dateTimeRFC3339)(f.LastWriteTime), } return enc.EncodeElement(aux, start) } @@ -77,11 +76,11 @@ func (f *FileProperty) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) er type alias FileProperty aux := &struct { *alias - ChangeTime *timeRFC3339 `xml:"ChangeTime"` - CreationTime *timeRFC3339 `xml:"CreationTime"` - LastAccessTime *timeRFC3339 `xml:"LastAccessTime"` - LastModified *timeRFC1123 `xml:"Last-Modified"` - LastWriteTime *timeRFC3339 `xml:"LastWriteTime"` + ChangeTime *dateTimeRFC3339 `xml:"ChangeTime"` + CreationTime *dateTimeRFC3339 `xml:"CreationTime"` + LastAccessTime *dateTimeRFC3339 `xml:"LastAccessTime"` + LastModified *dateTimeRFC1123 `xml:"Last-Modified"` + LastWriteTime *dateTimeRFC3339 `xml:"LastWriteTime"` }{ alias: (*alias)(f), } @@ -212,16 +211,16 @@ func (s ShareProperties) MarshalXML(enc *xml.Encoder, start xml.StartElement) er type alias ShareProperties aux := &struct { *alias - AccessTierChangeTime *timeRFC1123 `xml:"AccessTierChangeTime"` - DeletedTime *timeRFC1123 `xml:"DeletedTime"` - LastModified *timeRFC1123 `xml:"Last-Modified"` - NextAllowedQuotaDowngradeTime *timeRFC1123 `xml:"NextAllowedQuotaDowngradeTime"` + AccessTierChangeTime *dateTimeRFC1123 `xml:"AccessTierChangeTime"` + DeletedTime *dateTimeRFC1123 `xml:"DeletedTime"` + LastModified *dateTimeRFC1123 `xml:"Last-Modified"` + NextAllowedQuotaDowngradeTime *dateTimeRFC1123 `xml:"NextAllowedQuotaDowngradeTime"` }{ alias: (*alias)(&s), - AccessTierChangeTime: (*timeRFC1123)(s.AccessTierChangeTime), - DeletedTime: (*timeRFC1123)(s.DeletedTime), - LastModified: (*timeRFC1123)(s.LastModified), - NextAllowedQuotaDowngradeTime: (*timeRFC1123)(s.NextAllowedQuotaDowngradeTime), + AccessTierChangeTime: (*dateTimeRFC1123)(s.AccessTierChangeTime), + DeletedTime: (*dateTimeRFC1123)(s.DeletedTime), + LastModified: (*dateTimeRFC1123)(s.LastModified), + NextAllowedQuotaDowngradeTime: (*dateTimeRFC1123)(s.NextAllowedQuotaDowngradeTime), } return enc.EncodeElement(aux, start) } @@ -231,10 +230,10 @@ func (s *ShareProperties) UnmarshalXML(dec *xml.Decoder, start xml.StartElement) type alias ShareProperties aux := &struct { *alias - AccessTierChangeTime *timeRFC1123 `xml:"AccessTierChangeTime"` - DeletedTime *timeRFC1123 `xml:"DeletedTime"` - LastModified *timeRFC1123 `xml:"Last-Modified"` - NextAllowedQuotaDowngradeTime *timeRFC1123 `xml:"NextAllowedQuotaDowngradeTime"` + AccessTierChangeTime *dateTimeRFC1123 `xml:"AccessTierChangeTime"` + DeletedTime *dateTimeRFC1123 `xml:"DeletedTime"` + LastModified *dateTimeRFC1123 `xml:"Last-Modified"` + NextAllowedQuotaDowngradeTime *dateTimeRFC1123 `xml:"NextAllowedQuotaDowngradeTime"` }{ alias: (*alias)(s), } diff --git a/sdk/storage/azfile/internal/generated/zz_options.go b/sdk/storage/azfile/internal/generated/zz_options.go new file mode 100644 index 000000000000..5c1c92079d19 --- /dev/null +++ b/sdk/storage/azfile/internal/generated/zz_options.go @@ -0,0 +1,852 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package generated + +// CopyFileSMBInfo contains a group of parameters for the DirectoryClient.Rename method. +type CopyFileSMBInfo struct { + // Specifies either the option to copy file attributes from a source file(source) to a target file or a list of attributes + // to set on a target file. + FileAttributes *string + + // Specifies either the option to copy file last write time from a source file(source) to a target file or a time value in + // ISO 8601 format to set as last write time on a target file. + FileChangeTime *string + + // Specifies either the option to copy file creation time from a source file(source) to a target file or a time value in ISO + // 8601 format to set as creation time on a target file. + FileCreationTime *string + + // Specifies either the option to copy file last write time from a source file(source) to a target file or a time value in + // ISO 8601 format to set as last write time on a target file. + FileLastWriteTime *string + + // Specifies the option to copy file security descriptor from source file or to set it using the value which is defined by + // the header value of x-ms-file-permission or x-ms-file-permission-key. + FilePermissionCopyMode *PermissionCopyModeType + + // Specifies the option to overwrite the target file if it already exists and has read-only attribute set. + IgnoreReadOnly *bool + + // Specifies the option to set archive attribute on a target file. True means archive attribute will be set on a target file + // despite attribute overrides or a source file state. + SetArchiveAttribute *bool +} + +// DestinationLeaseAccessConditions contains a group of parameters for the DirectoryClient.Rename method. +type DestinationLeaseAccessConditions struct { + // Required if the destination file has an active infinite lease. The lease ID specified for this header must match the lease + // ID of the destination file. If the request does not include the lease ID or + // it is not valid, the operation fails with status code 412 (Precondition Failed). If this header is specified and the destination + // file does not currently have an active lease, the operation will also + // fail with status code 412 (Precondition Failed). + DestinationLeaseID *string +} + +// DirectoryClientCreateOptions contains the optional parameters for the DirectoryClient.Create method. +type DirectoryClientCreateOptions struct { + // If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. + // ‘None’ can also be specified as default. + FileAttributes *string + + // Change time for the file/directory. Default value: Now. + FileChangeTime *string + + // Creation time for the file/directory. Default value: Now. + FileCreationTime *string + + // Last write time for the file/directory. Default value: Now. + FileLastWriteTime *string + + // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission + // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default + // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission + // or x-ms-file-permission-key should be specified. + FilePermission *string + + // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key + // should be specified. + FilePermissionKey *string + + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// DirectoryClientDeleteOptions contains the optional parameters for the DirectoryClient.Delete method. +type DirectoryClientDeleteOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// DirectoryClientForceCloseHandlesOptions contains the optional parameters for the DirectoryClient.ForceCloseHandles method. +type DirectoryClientForceCloseHandlesOptions struct { + // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns + // a marker value within the response body if the list returned was not complete. + // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque + // to the client. + Marker *string + + // Specifies operation should apply to the directory specified in the URI, its files, its subdirectories and their files. + Recursive *bool + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// DirectoryClientGetPropertiesOptions contains the optional parameters for the DirectoryClient.GetProperties method. +type DirectoryClientGetPropertiesOptions struct { + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// DirectoryClientListFilesAndDirectoriesSegmentOptions contains the optional parameters for the DirectoryClient.NewListFilesAndDirectoriesSegmentPager +// method. +type DirectoryClientListFilesAndDirectoriesSegmentOptions struct { + // Include this parameter to specify one or more datasets to include in the response. + Include []ListFilesIncludeType + + // Include extended information. + IncludeExtendedInfo *bool + + // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns + // a marker value within the response body if the list returned was not complete. + // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque + // to the client. + Marker *string + + // Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater + // than 5,000, the server will return up to 5,000 items. + Maxresults *int32 + + // Filters the results to return only entries whose name begins with the specified prefix. + Prefix *string + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// DirectoryClientListHandlesOptions contains the optional parameters for the DirectoryClient.ListHandles method. +type DirectoryClientListHandlesOptions struct { + // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns + // a marker value within the response body if the list returned was not complete. + // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque + // to the client. + Marker *string + + // Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater + // than 5,000, the server will return up to 5,000 items. + Maxresults *int32 + + // Specifies operation should apply to the directory specified in the URI, its files, its subdirectories and their files. + Recursive *bool + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// DirectoryClientRenameOptions contains the optional parameters for the DirectoryClient.Rename method. +type DirectoryClientRenameOptions struct { + // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission + // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default + // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission + // or x-ms-file-permission-key should be specified. + FilePermission *string + + // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key + // should be specified. + FilePermissionKey *string + + // Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting destination file should be respected. + // If true, the rename will succeed, otherwise, a previous file at the + // destination with the ReadOnly attribute set will cause the rename to fail. + IgnoreReadOnly *bool + + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // Optional. A boolean value for if the destination file already exists, whether this request will overwrite the file or not. + // If true, the rename will succeed and will overwrite the destination file. If + // not provided or if false and the destination file does exist, the request will not overwrite the destination file. If provided + // and the destination file doesn’t exist, the rename will succeed. Note: + // This value does not override the x-ms-file-copy-ignore-read-only header value. + ReplaceIfExists *bool + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// DirectoryClientSetMetadataOptions contains the optional parameters for the DirectoryClient.SetMetadata method. +type DirectoryClientSetMetadataOptions struct { + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// DirectoryClientSetPropertiesOptions contains the optional parameters for the DirectoryClient.SetProperties method. +type DirectoryClientSetPropertiesOptions struct { + // If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. + // ‘None’ can also be specified as default. + FileAttributes *string + + // Change time for the file/directory. Default value: Now. + FileChangeTime *string + + // Creation time for the file/directory. Default value: Now. + FileCreationTime *string + + // Last write time for the file/directory. Default value: Now. + FileLastWriteTime *string + + // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission + // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default + // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission + // or x-ms-file-permission-key should be specified. + FilePermission *string + + // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key + // should be specified. + FilePermissionKey *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientAbortCopyOptions contains the optional parameters for the FileClient.AbortCopy method. +type FileClientAbortCopyOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientAcquireLeaseOptions contains the optional parameters for the FileClient.AcquireLease method. +type FileClientAcquireLeaseOptions struct { + // Proposed lease ID, in a GUID string format. The File service returns 400 (Invalid request) if the proposed lease ID is + // not in the correct format. See Guid Constructor (String) for a list of valid GUID + // string formats. + ProposedLeaseID *string + + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientBreakLeaseOptions contains the optional parameters for the FileClient.BreakLease method. +type FileClientBreakLeaseOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientChangeLeaseOptions contains the optional parameters for the FileClient.ChangeLease method. +type FileClientChangeLeaseOptions struct { + // Proposed lease ID, in a GUID string format. The File service returns 400 (Invalid request) if the proposed lease ID is + // not in the correct format. See Guid Constructor (String) for a list of valid GUID + // string formats. + ProposedLeaseID *string + + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientCreateOptions contains the optional parameters for the FileClient.Create method. +type FileClientCreateOptions struct { + // If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. + // ‘None’ can also be specified as default. + FileAttributes *string + + // Change time for the file/directory. Default value: Now. + FileChangeTime *string + + // Creation time for the file/directory. Default value: Now. + FileCreationTime *string + + // Last write time for the file/directory. Default value: Now. + FileLastWriteTime *string + + // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission + // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default + // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission + // or x-ms-file-permission-key should be specified. + FilePermission *string + + // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key + // should be specified. + FilePermissionKey *string + + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientDeleteOptions contains the optional parameters for the FileClient.Delete method. +type FileClientDeleteOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientDownloadOptions contains the optional parameters for the FileClient.Download method. +type FileClientDownloadOptions struct { + // Return file data only from the specified byte range. + Range *string + + // When this header is set to true and specified together with the Range header, the service returns the MD5 hash for the + // range, as long as the range is less than or equal to 4 MB in size. + RangeGetContentMD5 *bool + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientForceCloseHandlesOptions contains the optional parameters for the FileClient.ForceCloseHandles method. +type FileClientForceCloseHandlesOptions struct { + // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns + // a marker value within the response body if the list returned was not complete. + // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque + // to the client. + Marker *string + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientGetPropertiesOptions contains the optional parameters for the FileClient.GetProperties method. +type FileClientGetPropertiesOptions struct { + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientGetRangeListOptions contains the optional parameters for the FileClient.GetRangeList method. +type FileClientGetRangeListOptions struct { + // The previous snapshot parameter is an opaque DateTime value that, when present, specifies the previous snapshot. + Prevsharesnapshot *string + + // Specifies the range of bytes over which to list ranges, inclusively. + Range *string + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientListHandlesOptions contains the optional parameters for the FileClient.ListHandles method. +type FileClientListHandlesOptions struct { + // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns + // a marker value within the response body if the list returned was not complete. + // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque + // to the client. + Marker *string + + // Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater + // than 5,000, the server will return up to 5,000 items. + Maxresults *int32 + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientReleaseLeaseOptions contains the optional parameters for the FileClient.ReleaseLease method. +type FileClientReleaseLeaseOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientRenameOptions contains the optional parameters for the FileClient.Rename method. +type FileClientRenameOptions struct { + // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission + // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default + // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission + // or x-ms-file-permission-key should be specified. + FilePermission *string + + // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key + // should be specified. + FilePermissionKey *string + + // Optional. A boolean value that specifies whether the ReadOnly attribute on a preexisting destination file should be respected. + // If true, the rename will succeed, otherwise, a previous file at the + // destination with the ReadOnly attribute set will cause the rename to fail. + IgnoreReadOnly *bool + + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // Optional. A boolean value for if the destination file already exists, whether this request will overwrite the file or not. + // If true, the rename will succeed and will overwrite the destination file. If + // not provided or if false and the destination file does exist, the request will not overwrite the destination file. If provided + // and the destination file doesn’t exist, the rename will succeed. Note: + // This value does not override the x-ms-file-copy-ignore-read-only header value. + ReplaceIfExists *bool + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientSetHTTPHeadersOptions contains the optional parameters for the FileClient.SetHTTPHeaders method. +type FileClientSetHTTPHeadersOptions struct { + // If specified, the provided file attributes shall be set. Default value: ‘Archive’ for file and ‘Directory’ for directory. + // ‘None’ can also be specified as default. + FileAttributes *string + + // Change time for the file/directory. Default value: Now. + FileChangeTime *string + + // Resizes a file to the specified size. If the specified byte value is less than the current size of the file, then all ranges + // above the specified byte value are cleared. + FileContentLength *int64 + + // Creation time for the file/directory. Default value: Now. + FileCreationTime *string + + // Last write time for the file/directory. Default value: Now. + FileLastWriteTime *string + + // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission + // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default + // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission + // or x-ms-file-permission-key should be specified. + FilePermission *string + + // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key + // should be specified. + FilePermissionKey *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientSetMetadataOptions contains the optional parameters for the FileClient.SetMetadata method. +type FileClientSetMetadataOptions struct { + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientStartCopyOptions contains the optional parameters for the FileClient.StartCopy method. +type FileClientStartCopyOptions struct { + // If specified the permission (security descriptor) shall be set for the directory/file. This header can be used if Permission + // size is <= 8KB, else x-ms-file-permission-key header shall be used. Default + // value: Inherit. If SDDL is specified as input, it must have owner, group and dacl. Note: Only one of the x-ms-file-permission + // or x-ms-file-permission-key should be specified. + FilePermission *string + + // Key of the permission to be set for the directory/file. Note: Only one of the x-ms-file-permission or x-ms-file-permission-key + // should be specified. + FilePermissionKey *string + + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientUploadRangeFromURLOptions contains the optional parameters for the FileClient.UploadRangeFromURL method. +type FileClientUploadRangeFromURLOptions struct { + // Only Bearer type is supported. Credentials should be a valid OAuth access token to copy source. + CopySourceAuthorization *string + + // If the file last write time should be preserved or overwritten + FileLastWrittenMode *FileLastWrittenMode + + // Specify the crc64 calculated for the range of bytes that must be read from the copy source. + SourceContentCRC64 []byte + + // Bytes of source data in the specified range. + SourceRange *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// FileClientUploadRangeOptions contains the optional parameters for the FileClient.UploadRange method. +type FileClientUploadRangeOptions struct { + // An MD5 hash of the content. This hash is used to verify the integrity of the data during transport. When the Content-MD5 + // header is specified, the File service compares the hash of the content that has + // arrived with the header value that was sent. If the two hashes do not match, the operation will fail with error code 400 + // (Bad Request). + ContentMD5 []byte + + // If the file last write time should be preserved or overwritten + FileLastWrittenMode *FileLastWrittenMode + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. +type LeaseAccessConditions struct { + // If specified, the operation only succeeds if the resource's lease is active and matches this ID. + LeaseID *string +} + +// ServiceClientGetPropertiesOptions contains the optional parameters for the ServiceClient.GetProperties method. +type ServiceClientGetPropertiesOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ServiceClientListSharesSegmentOptions contains the optional parameters for the ServiceClient.NewListSharesSegmentPager +// method. +type ServiceClientListSharesSegmentOptions struct { + // Include this parameter to specify one or more datasets to include in the response. + Include []ListSharesIncludeType + + // A string value that identifies the portion of the list to be returned with the next list operation. The operation returns + // a marker value within the response body if the list returned was not complete. + // The marker value may then be used in a subsequent call to request the next set of list items. The marker value is opaque + // to the client. + Marker *string + + // Specifies the maximum number of entries to return. If the request does not specify maxresults, or specifies a value greater + // than 5,000, the server will return up to 5,000 items. + Maxresults *int32 + + // Filters the results to return only entries whose name begins with the specified prefix. + Prefix *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ServiceClientSetPropertiesOptions contains the optional parameters for the ServiceClient.SetProperties method. +type ServiceClientSetPropertiesOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientAcquireLeaseOptions contains the optional parameters for the ShareClient.AcquireLease method. +type ShareClientAcquireLeaseOptions struct { + // Proposed lease ID, in a GUID string format. The File service returns 400 (Invalid request) if the proposed lease ID is + // not in the correct format. See Guid Constructor (String) for a list of valid GUID + // string formats. + ProposedLeaseID *string + + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientBreakLeaseOptions contains the optional parameters for the ShareClient.BreakLease method. +type ShareClientBreakLeaseOptions struct { + // For a break operation, proposed duration the lease should continue before it is broken, in seconds, between 0 and 60. This + // break period is only used if it is shorter than the time remaining on the + // lease. If longer, the time remaining on the lease is used. A new lease will not be available before the break period has + // expired, but the lease may be held for longer than the break period. If this + // header does not appear with a break operation, a fixed-duration lease breaks after the remaining lease period elapses, + // and an infinite lease breaks immediately. + BreakPeriod *int32 + + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientChangeLeaseOptions contains the optional parameters for the ShareClient.ChangeLease method. +type ShareClientChangeLeaseOptions struct { + // Proposed lease ID, in a GUID string format. The File service returns 400 (Invalid request) if the proposed lease ID is + // not in the correct format. See Guid Constructor (String) for a list of valid GUID + // string formats. + ProposedLeaseID *string + + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientCreateOptions contains the optional parameters for the ShareClient.Create method. +type ShareClientCreateOptions struct { + // Specifies the access tier of the share. + AccessTier *ShareAccessTier + + // Protocols to enable on the share. + EnabledProtocols *string + + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // Specifies the maximum size of the share, in gigabytes. + Quota *int32 + + // Root squash to set on the share. Only valid for NFS shares. + RootSquash *ShareRootSquash + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientCreatePermissionOptions contains the optional parameters for the ShareClient.CreatePermission method. +type ShareClientCreatePermissionOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientCreateSnapshotOptions contains the optional parameters for the ShareClient.CreateSnapshot method. +type ShareClientCreateSnapshotOptions struct { + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientDeleteOptions contains the optional parameters for the ShareClient.Delete method. +type ShareClientDeleteOptions struct { + // Specifies the option include to delete the base share and all of its snapshots. + DeleteSnapshots *DeleteSnapshotsOptionType + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientGetAccessPolicyOptions contains the optional parameters for the ShareClient.GetAccessPolicy method. +type ShareClientGetAccessPolicyOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientGetPermissionOptions contains the optional parameters for the ShareClient.GetPermission method. +type ShareClientGetPermissionOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientGetPropertiesOptions contains the optional parameters for the ShareClient.GetProperties method. +type ShareClientGetPropertiesOptions struct { + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientGetStatisticsOptions contains the optional parameters for the ShareClient.GetStatistics method. +type ShareClientGetStatisticsOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientReleaseLeaseOptions contains the optional parameters for the ShareClient.ReleaseLease method. +type ShareClientReleaseLeaseOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientRenewLeaseOptions contains the optional parameters for the ShareClient.RenewLease method. +type ShareClientRenewLeaseOptions struct { + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The snapshot parameter is an opaque DateTime value that, when present, specifies the share snapshot to query. + Sharesnapshot *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientRestoreOptions contains the optional parameters for the ShareClient.Restore method. +type ShareClientRestoreOptions struct { + // Specifies the name of the previously-deleted share. + DeletedShareName *string + + // Specifies the version of the previously-deleted share. + DeletedShareVersion *string + + // Provides a client-generated, opaque value with a 1 KB character limit that is recorded in the analytics logs when storage + // analytics logging is enabled. + RequestID *string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientSetAccessPolicyOptions contains the optional parameters for the ShareClient.SetAccessPolicy method. +type ShareClientSetAccessPolicyOptions struct { + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientSetMetadataOptions contains the optional parameters for the ShareClient.SetMetadata method. +type ShareClientSetMetadataOptions struct { + // A name-value pair to associate with a file storage object. + Metadata map[string]*string + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareClientSetPropertiesOptions contains the optional parameters for the ShareClient.SetProperties method. +type ShareClientSetPropertiesOptions struct { + // Specifies the access tier of the share. + AccessTier *ShareAccessTier + + // Specifies the maximum size of the share, in gigabytes. + Quota *int32 + + // Root squash to set on the share. Only valid for NFS shares. + RootSquash *ShareRootSquash + + // The timeout parameter is expressed in seconds. For more information, see Setting Timeouts for File Service Operations. + // [https://docs.microsoft.com/en-us/rest/api/storageservices/Setting-Timeouts-for-File-Service-Operations?redirectedfrom=MSDN] + Timeout *int32 +} + +// ShareFileHTTPHeaders contains a group of parameters for the FileClient.Create method. +type ShareFileHTTPHeaders struct { + // Sets the file's cache control. The File service stores this value but does not use or modify it. + CacheControl *string + + // Sets the file's Content-Disposition header. + ContentDisposition *string + + // Specifies which content encodings have been applied to the file. + ContentEncoding *string + + // Specifies the natural languages used by this resource. + ContentLanguage *string + + // Sets the file's MD5 hash. + ContentMD5 []byte + + // Sets the MIME content type of the file. The default type is 'application/octet-stream'. + ContentType *string +} + +// SourceLeaseAccessConditions contains a group of parameters for the DirectoryClient.Rename method. +type SourceLeaseAccessConditions struct { + // Required if the source file has an active infinite lease. + SourceLeaseID *string +} + +// SourceModifiedAccessConditions contains a group of parameters for the FileClient.UploadRangeFromURL method. +type SourceModifiedAccessConditions struct { + // Specify the crc64 value to operate only on range with a matching crc64 checksum. + SourceIfMatchCRC64 []byte + + // Specify the crc64 value to operate only on range without a matching crc64 checksum. + SourceIfNoneMatchCRC64 []byte +} diff --git a/sdk/storage/azfile/internal/generated/zz_response_types.go b/sdk/storage/azfile/internal/generated/zz_response_types.go index b94bd5e6fae4..69709e4aaabf 100644 --- a/sdk/storage/azfile/internal/generated/zz_response_types.go +++ b/sdk/storage/azfile/internal/generated/zz_response_types.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated @@ -137,34 +136,38 @@ type DirectoryClientGetPropertiesResponse struct { // DirectoryClientListFilesAndDirectoriesSegmentResponse contains the response from method DirectoryClient.NewListFilesAndDirectoriesSegmentPager. type DirectoryClientListFilesAndDirectoriesSegmentResponse struct { + // An enumeration of directories and files. ListFilesAndDirectoriesSegmentResponse + // ContentType contains the information returned from the Content-Type header response. - ContentType *string `xml:"ContentType"` + ContentType *string // Date contains the information returned from the Date header response. - Date *time.Time `xml:"Date"` + Date *time.Time // RequestID contains the information returned from the x-ms-request-id header response. - RequestID *string `xml:"RequestID"` + RequestID *string // Version contains the information returned from the x-ms-version header response. - Version *string `xml:"Version"` + Version *string } // DirectoryClientListHandlesResponse contains the response from method DirectoryClient.ListHandles. type DirectoryClientListHandlesResponse struct { + // An enumeration of handles. ListHandlesResponse + // ContentType contains the information returned from the Content-Type header response. - ContentType *string `xml:"ContentType"` + ContentType *string // Date contains the information returned from the Date header response. - Date *time.Time `xml:"Date"` + Date *time.Time // RequestID contains the information returned from the x-ms-request-id header response. - RequestID *string `xml:"RequestID"` + RequestID *string // Version contains the information returned from the x-ms-version header response. - Version *string `xml:"Version"` + Version *string } // DirectoryClientRenameResponse contains the response from method DirectoryClient.Rename. @@ -631,40 +634,44 @@ type FileClientGetPropertiesResponse struct { // FileClientGetRangeListResponse contains the response from method FileClient.GetRangeList. type FileClientGetRangeListResponse struct { + // The list of file ranges ShareFileRangeList + // Date contains the information returned from the Date header response. - Date *time.Time `xml:"Date"` + Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *azcore.ETag `xml:"ETag"` + ETag *azcore.ETag // FileContentLength contains the information returned from the x-ms-content-length header response. - FileContentLength *int64 `xml:"FileContentLength"` + FileContentLength *int64 // LastModified contains the information returned from the Last-Modified header response. - LastModified *time.Time `xml:"LastModified"` + LastModified *time.Time // RequestID contains the information returned from the x-ms-request-id header response. - RequestID *string `xml:"RequestID"` + RequestID *string // Version contains the information returned from the x-ms-version header response. - Version *string `xml:"Version"` + Version *string } // FileClientListHandlesResponse contains the response from method FileClient.ListHandles. type FileClientListHandlesResponse struct { + // An enumeration of handles. ListHandlesResponse + // ContentType contains the information returned from the Content-Type header response. - ContentType *string `xml:"ContentType"` + ContentType *string // Date contains the information returned from the Date header response. - Date *time.Time `xml:"Date"` + Date *time.Time // RequestID contains the information returned from the x-ms-request-id header response. - RequestID *string `xml:"RequestID"` + RequestID *string // Version contains the information returned from the x-ms-version header response. - Version *string `xml:"Version"` + Version *string } // FileClientReleaseLeaseResponse contains the response from method FileClient.ReleaseLease. @@ -876,22 +883,26 @@ type FileClientUploadRangeResponse struct { // ServiceClientGetPropertiesResponse contains the response from method ServiceClient.GetProperties. type ServiceClientGetPropertiesResponse struct { + // Storage service properties. StorageServiceProperties + // RequestID contains the information returned from the x-ms-request-id header response. - RequestID *string `xml:"RequestID"` + RequestID *string // Version contains the information returned from the x-ms-version header response. - Version *string `xml:"Version"` + Version *string } // ServiceClientListSharesSegmentResponse contains the response from method ServiceClient.NewListSharesSegmentPager. type ServiceClientListSharesSegmentResponse struct { + // An enumeration of shares. ListSharesResponse + // RequestID contains the information returned from the x-ms-request-id header response. - RequestID *string `xml:"RequestID"` + RequestID *string // Version contains the information returned from the x-ms-version header response. - Version *string `xml:"Version"` + Version *string } // ServiceClientSetPropertiesResponse contains the response from method ServiceClient.SetProperties. @@ -1047,27 +1058,29 @@ type ShareClientDeleteResponse struct { // ShareClientGetAccessPolicyResponse contains the response from method ShareClient.GetAccessPolicy. type ShareClientGetAccessPolicyResponse struct { // Date contains the information returned from the Date header response. - Date *time.Time `xml:"Date"` + Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *azcore.ETag `xml:"ETag"` + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. - LastModified *time.Time `xml:"LastModified"` + LastModified *time.Time // RequestID contains the information returned from the x-ms-request-id header response. - RequestID *string `xml:"RequestID"` + RequestID *string // A collection of signed identifiers. SignedIdentifiers []*SignedIdentifier `xml:"SignedIdentifier"` // Version contains the information returned from the x-ms-version header response. - Version *string `xml:"Version"` + Version *string } // ShareClientGetPermissionResponse contains the response from method ShareClient.GetPermission. type ShareClientGetPermissionResponse struct { + // A permission (a security descriptor) at the share level. SharePermission + // Date contains the information returned from the Date header response. Date *time.Time @@ -1144,21 +1157,23 @@ type ShareClientGetPropertiesResponse struct { // ShareClientGetStatisticsResponse contains the response from method ShareClient.GetStatistics. type ShareClientGetStatisticsResponse struct { + // Stats for the share. ShareStats + // Date contains the information returned from the Date header response. - Date *time.Time `xml:"Date"` + Date *time.Time // ETag contains the information returned from the ETag header response. - ETag *azcore.ETag `xml:"ETag"` + ETag *azcore.ETag // LastModified contains the information returned from the Last-Modified header response. - LastModified *time.Time `xml:"LastModified"` + LastModified *time.Time // RequestID contains the information returned from the x-ms-request-id header response. - RequestID *string `xml:"RequestID"` + RequestID *string // Version contains the information returned from the x-ms-version header response. - Version *string `xml:"Version"` + Version *string } // ShareClientReleaseLeaseResponse contains the response from method ShareClient.ReleaseLease. diff --git a/sdk/storage/azfile/internal/generated/zz_service_client.go b/sdk/storage/azfile/internal/generated/zz_service_client.go index 847b97903bae..436dc845336e 100644 --- a/sdk/storage/azfile/internal/generated/zz_service_client.go +++ b/sdk/storage/azfile/internal/generated/zz_service_client.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated @@ -31,21 +30,24 @@ type ServiceClient struct { // and CORS (Cross-Origin Resource Sharing) rules. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ServiceClientGetPropertiesOptions contains the optional parameters for the ServiceClient.GetProperties method. func (client *ServiceClient) GetProperties(ctx context.Context, options *ServiceClientGetPropertiesOptions) (ServiceClientGetPropertiesResponse, error) { + var err error req, err := client.getPropertiesCreateRequest(ctx, options) if err != nil { return ServiceClientGetPropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ServiceClientGetPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ServiceClientGetPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ServiceClientGetPropertiesResponse{}, err } - return client.getPropertiesHandleResponse(resp) + resp, err := client.getPropertiesHandleResponse(httpResp) + return resp, err } // getPropertiesCreateRequest creates the GetProperties request. @@ -61,7 +63,7 @@ func (client *ServiceClient) getPropertiesCreateRequest(ctx context.Context, opt reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -84,7 +86,7 @@ func (client *ServiceClient) getPropertiesHandleResponse(resp *http.Response) (S // NewListSharesSegmentPager - The List Shares Segment operation returns a list of the shares and share snapshots under the // specified account. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ServiceClientListSharesSegmentOptions contains the optional parameters for the ServiceClient.NewListSharesSegmentPager // method. // @@ -112,7 +114,7 @@ func (client *ServiceClient) ListSharesSegmentCreateRequest(ctx context.Context, reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -136,22 +138,25 @@ func (client *ServiceClient) ListSharesSegmentHandleResponse(resp *http.Response // metrics and CORS (Cross-Origin Resource Sharing) rules. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - storageServiceProperties - The StorageService properties. // - options - ServiceClientSetPropertiesOptions contains the optional parameters for the ServiceClient.SetProperties method. func (client *ServiceClient) SetProperties(ctx context.Context, storageServiceProperties StorageServiceProperties, options *ServiceClientSetPropertiesOptions) (ServiceClientSetPropertiesResponse, error) { + var err error req, err := client.setPropertiesCreateRequest(ctx, storageServiceProperties, options) if err != nil { return ServiceClientSetPropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ServiceClientSetPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return ServiceClientSetPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return ServiceClientSetPropertiesResponse{}, err } - return client.setPropertiesHandleResponse(resp) + resp, err := client.setPropertiesHandleResponse(httpResp) + return resp, err } // setPropertiesCreateRequest creates the SetProperties request. @@ -167,7 +172,7 @@ func (client *ServiceClient) setPropertiesCreateRequest(ctx context.Context, sto reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} req.Raw().Header["Accept"] = []string{"application/xml"} if err := runtime.MarshalAsXML(req, storageServiceProperties); err != nil { return nil, err diff --git a/sdk/storage/azfile/internal/generated/zz_share_client.go b/sdk/storage/azfile/internal/generated/zz_share_client.go index 3c83f97775df..9ef788133d07 100644 --- a/sdk/storage/azfile/internal/generated/zz_share_client.go +++ b/sdk/storage/azfile/internal/generated/zz_share_client.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated @@ -34,24 +33,27 @@ type ShareClient struct { // delete share operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - duration - Specifies the duration of the lease, in seconds, or negative one (-1) for a lease that never expires. A non-infinite // lease can be between 15 and 60 seconds. A lease duration cannot be changed using // renew or change. // - options - ShareClientAcquireLeaseOptions contains the optional parameters for the ShareClient.AcquireLease method. func (client *ShareClient) AcquireLease(ctx context.Context, duration int32, options *ShareClientAcquireLeaseOptions) (ShareClientAcquireLeaseResponse, error) { + var err error req, err := client.acquireLeaseCreateRequest(ctx, duration, options) if err != nil { return ShareClientAcquireLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientAcquireLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return ShareClientAcquireLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ShareClientAcquireLeaseResponse{}, err } - return client.acquireLeaseHandleResponse(resp) + resp, err := client.acquireLeaseHandleResponse(httpResp) + return resp, err } // acquireLeaseCreateRequest creates the AcquireLease request. @@ -75,7 +77,7 @@ func (client *ShareClient) acquireLeaseCreateRequest(ctx context.Context, durati if options != nil && options.ProposedLeaseID != nil { req.Raw().Header["x-ms-proposed-lease-id"] = []string{*options.ProposedLeaseID} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -86,6 +88,16 @@ func (client *ShareClient) acquireLeaseCreateRequest(ctx context.Context, durati // acquireLeaseHandleResponse handles the AcquireLease response. func (client *ShareClient) acquireLeaseHandleResponse(resp *http.Response) (ShareClientAcquireLeaseResponse, error) { result := ShareClientAcquireLeaseResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientAcquireLeaseResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -99,22 +111,12 @@ func (client *ShareClient) acquireLeaseHandleResponse(resp *http.Response) (Shar if val := resp.Header.Get("x-ms-lease-id"); val != "" { result.LeaseID = &val } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientAcquireLeaseResponse{}, err - } - result.Date = &date - } return result, nil } @@ -122,22 +124,25 @@ func (client *ShareClient) acquireLeaseHandleResponse(resp *http.Response) (Shar // delete share operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientBreakLeaseOptions contains the optional parameters for the ShareClient.BreakLease method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) BreakLease(ctx context.Context, options *ShareClientBreakLeaseOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientBreakLeaseResponse, error) { + var err error req, err := client.breakLeaseCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return ShareClientBreakLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientBreakLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return ShareClientBreakLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return ShareClientBreakLeaseResponse{}, err } - return client.breakLeaseHandleResponse(resp) + resp, err := client.breakLeaseHandleResponse(httpResp) + return resp, err } // breakLeaseCreateRequest creates the BreakLease request. @@ -163,7 +168,7 @@ func (client *ShareClient) breakLeaseCreateRequest(ctx context.Context, options if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -174,6 +179,16 @@ func (client *ShareClient) breakLeaseCreateRequest(ctx context.Context, options // breakLeaseHandleResponse handles the BreakLease response. func (client *ShareClient) breakLeaseHandleResponse(resp *http.Response) (ShareClientBreakLeaseResponse, error) { result := ShareClientBreakLeaseResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientBreakLeaseResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -184,6 +199,9 @@ func (client *ShareClient) breakLeaseHandleResponse(resp *http.Response) (ShareC } result.LastModified = &lastModified } + if val := resp.Header.Get("x-ms-lease-id"); val != "" { + result.LeaseID = &val + } if val := resp.Header.Get("x-ms-lease-time"); val != "" { leaseTime32, err := strconv.ParseInt(val, 10, 32) leaseTime := int32(leaseTime32) @@ -192,25 +210,12 @@ func (client *ShareClient) breakLeaseHandleResponse(resp *http.Response) (ShareC } result.LeaseTime = &leaseTime } - if val := resp.Header.Get("x-ms-lease-id"); val != "" { - result.LeaseID = &val - } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientBreakLeaseResponse{}, err - } - result.Date = &date - } return result, nil } @@ -218,22 +223,25 @@ func (client *ShareClient) breakLeaseHandleResponse(resp *http.Response) (ShareC // delete share operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - leaseID - Specifies the current lease ID on the resource. // - options - ShareClientChangeLeaseOptions contains the optional parameters for the ShareClient.ChangeLease method. func (client *ShareClient) ChangeLease(ctx context.Context, leaseID string, options *ShareClientChangeLeaseOptions) (ShareClientChangeLeaseResponse, error) { + var err error req, err := client.changeLeaseCreateRequest(ctx, leaseID, options) if err != nil { return ShareClientChangeLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientChangeLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientChangeLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientChangeLeaseResponse{}, err } - return client.changeLeaseHandleResponse(resp) + resp, err := client.changeLeaseHandleResponse(httpResp) + return resp, err } // changeLeaseCreateRequest creates the ChangeLease request. @@ -257,7 +265,7 @@ func (client *ShareClient) changeLeaseCreateRequest(ctx context.Context, leaseID if options != nil && options.ProposedLeaseID != nil { req.Raw().Header["x-ms-proposed-lease-id"] = []string{*options.ProposedLeaseID} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -268,6 +276,16 @@ func (client *ShareClient) changeLeaseCreateRequest(ctx context.Context, leaseID // changeLeaseHandleResponse handles the ChangeLease response. func (client *ShareClient) changeLeaseHandleResponse(resp *http.Response) (ShareClientChangeLeaseResponse, error) { result := ShareClientChangeLeaseResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientChangeLeaseResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -281,22 +299,12 @@ func (client *ShareClient) changeLeaseHandleResponse(resp *http.Response) (Share if val := resp.Header.Get("x-ms-lease-id"); val != "" { result.LeaseID = &val } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientChangeLeaseResponse{}, err - } - result.Date = &date - } return result, nil } @@ -304,21 +312,24 @@ func (client *ShareClient) changeLeaseHandleResponse(resp *http.Response) (Share // fails. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientCreateOptions contains the optional parameters for the ShareClient.Create method. func (client *ShareClient) Create(ctx context.Context, options *ShareClientCreateOptions) (ShareClientCreateResponse, error) { + var err error req, err := client.createCreateRequest(ctx, options) if err != nil { return ShareClientCreateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientCreateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return ShareClientCreateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ShareClientCreateResponse{}, err } - return client.createHandleResponse(resp) + resp, err := client.createHandleResponse(httpResp) + return resp, err } // createCreateRequest creates the Create request. @@ -346,7 +357,7 @@ func (client *ShareClient) createCreateRequest(ctx context.Context, options *Sha if options != nil && options.AccessTier != nil { req.Raw().Header["x-ms-access-tier"] = []string{string(*options.AccessTier)} } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.EnabledProtocols != nil { req.Raw().Header["x-ms-enabled-protocols"] = []string{*options.EnabledProtocols} } @@ -360,6 +371,13 @@ func (client *ShareClient) createCreateRequest(ctx context.Context, options *Sha // createHandleResponse handles the Create response. func (client *ShareClient) createHandleResponse(resp *http.Response) (ShareClientCreateResponse, error) { result := ShareClientCreateResponse{} + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientCreateResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -376,35 +394,31 @@ func (client *ShareClient) createHandleResponse(resp *http.Response) (ShareClien if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientCreateResponse{}, err - } - result.Date = &date - } return result, nil } // CreatePermission - Create a permission (a security descriptor). // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - sharePermission - A permission (a security descriptor) at the share level. // - options - ShareClientCreatePermissionOptions contains the optional parameters for the ShareClient.CreatePermission method. func (client *ShareClient) CreatePermission(ctx context.Context, sharePermission SharePermission, options *ShareClientCreatePermissionOptions) (ShareClientCreatePermissionResponse, error) { + var err error req, err := client.createPermissionCreateRequest(ctx, sharePermission, options) if err != nil { return ShareClientCreatePermissionResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientCreatePermissionResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return ShareClientCreatePermissionResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ShareClientCreatePermissionResponse{}, err } - return client.createPermissionHandleResponse(resp) + resp, err := client.createPermissionHandleResponse(httpResp) + return resp, err } // createPermissionCreateRequest creates the CreatePermission request. @@ -420,7 +434,7 @@ func (client *ShareClient) createPermissionCreateRequest(ctx context.Context, sh reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if client.fileRequestIntent != nil { req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} } @@ -434,12 +448,6 @@ func (client *ShareClient) createPermissionCreateRequest(ctx context.Context, sh // createPermissionHandleResponse handles the CreatePermission response. func (client *ShareClient) createPermissionHandleResponse(resp *http.Response) (ShareClientCreatePermissionResponse, error) { result := ShareClientCreatePermissionResponse{} - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -450,27 +458,36 @@ func (client *ShareClient) createPermissionHandleResponse(resp *http.Response) ( if val := resp.Header.Get("x-ms-file-permission-key"); val != "" { result.FilePermissionKey = &val } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } // CreateSnapshot - Creates a read-only snapshot of a share. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientCreateSnapshotOptions contains the optional parameters for the ShareClient.CreateSnapshot method. func (client *ShareClient) CreateSnapshot(ctx context.Context, options *ShareClientCreateSnapshotOptions) (ShareClientCreateSnapshotResponse, error) { + var err error req, err := client.createSnapshotCreateRequest(ctx, options) if err != nil { return ShareClientCreateSnapshotResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientCreateSnapshotResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return ShareClientCreateSnapshotResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ShareClientCreateSnapshotResponse{}, err } - return client.createSnapshotHandleResponse(resp) + resp, err := client.createSnapshotHandleResponse(httpResp) + return resp, err } // createSnapshotCreateRequest creates the CreateSnapshot request. @@ -493,7 +510,7 @@ func (client *ShareClient) createSnapshotCreateRequest(ctx context.Context, opti } } } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} req.Raw().Header["Accept"] = []string{"application/xml"} return req, nil } @@ -501,8 +518,12 @@ func (client *ShareClient) createSnapshotCreateRequest(ctx context.Context, opti // createSnapshotHandleResponse handles the CreateSnapshot response. func (client *ShareClient) createSnapshotHandleResponse(resp *http.Response) (ShareClientCreateSnapshotResponse, error) { result := ShareClientCreateSnapshotResponse{} - if val := resp.Header.Get("x-ms-snapshot"); val != "" { - result.Snapshot = &val + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientCreateSnapshotResponse{}, err + } + result.Date = &date } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) @@ -517,16 +538,12 @@ func (client *ShareClient) createSnapshotHandleResponse(resp *http.Response) (Sh if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } + if val := resp.Header.Get("x-ms-snapshot"); val != "" { + result.Snapshot = &val + } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientCreateSnapshotResponse{}, err - } - result.Date = &date - } return result, nil } @@ -534,22 +551,25 @@ func (client *ShareClient) createSnapshotHandleResponse(resp *http.Response) (Sh // contained within it are later deleted during garbage collection. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientDeleteOptions contains the optional parameters for the ShareClient.Delete method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) Delete(ctx context.Context, options *ShareClientDeleteOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientDeleteResponse, error) { + var err error req, err := client.deleteCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return ShareClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return ShareClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return ShareClientDeleteResponse{}, err } - return client.deleteHandleResponse(resp) + resp, err := client.deleteHandleResponse(httpResp) + return resp, err } // deleteCreateRequest creates the Delete request. @@ -567,7 +587,7 @@ func (client *ShareClient) deleteCreateRequest(ctx context.Context, options *Sha reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.DeleteSnapshots != nil { req.Raw().Header["x-ms-delete-snapshots"] = []string{string(*options.DeleteSnapshots)} } @@ -581,12 +601,6 @@ func (client *ShareClient) deleteCreateRequest(ctx context.Context, options *Sha // deleteHandleResponse handles the Delete response. func (client *ShareClient) deleteHandleResponse(resp *http.Response) (ShareClientDeleteResponse, error) { result := ShareClientDeleteResponse{} - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -594,28 +608,37 @@ func (client *ShareClient) deleteHandleResponse(resp *http.Response) (ShareClien } result.Date = &date } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } // GetAccessPolicy - Returns information about stored access policies specified on the share. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientGetAccessPolicyOptions contains the optional parameters for the ShareClient.GetAccessPolicy method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) GetAccessPolicy(ctx context.Context, options *ShareClientGetAccessPolicyOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientGetAccessPolicyResponse, error) { + var err error req, err := client.getAccessPolicyCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return ShareClientGetAccessPolicyResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientGetAccessPolicyResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientGetAccessPolicyResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientGetAccessPolicyResponse{}, err } - return client.getAccessPolicyHandleResponse(resp) + resp, err := client.getAccessPolicyHandleResponse(httpResp) + return resp, err } // getAccessPolicyCreateRequest creates the GetAccessPolicy request. @@ -631,7 +654,7 @@ func (client *ShareClient) getAccessPolicyCreateRequest(ctx context.Context, opt reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -642,6 +665,13 @@ func (client *ShareClient) getAccessPolicyCreateRequest(ctx context.Context, opt // getAccessPolicyHandleResponse handles the GetAccessPolicy response. func (client *ShareClient) getAccessPolicyHandleResponse(resp *http.Response) (ShareClientGetAccessPolicyResponse, error) { result := ShareClientGetAccessPolicyResponse{} + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientGetAccessPolicyResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -658,13 +688,6 @@ func (client *ShareClient) getAccessPolicyHandleResponse(resp *http.Response) (S if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientGetAccessPolicyResponse{}, err - } - result.Date = &date - } if err := runtime.UnmarshalAsXML(resp, &result); err != nil { return ShareClientGetAccessPolicyResponse{}, err } @@ -674,22 +697,25 @@ func (client *ShareClient) getAccessPolicyHandleResponse(resp *http.Response) (S // GetPermission - Returns the permission (security descriptor) for a given key // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - filePermissionKey - Key of the permission to be set for the directory/file. // - options - ShareClientGetPermissionOptions contains the optional parameters for the ShareClient.GetPermission method. func (client *ShareClient) GetPermission(ctx context.Context, filePermissionKey string, options *ShareClientGetPermissionOptions) (ShareClientGetPermissionResponse, error) { + var err error req, err := client.getPermissionCreateRequest(ctx, filePermissionKey, options) if err != nil { return ShareClientGetPermissionResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientGetPermissionResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientGetPermissionResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientGetPermissionResponse{}, err } - return client.getPermissionHandleResponse(resp) + resp, err := client.getPermissionHandleResponse(httpResp) + return resp, err } // getPermissionCreateRequest creates the GetPermission request. @@ -706,7 +732,7 @@ func (client *ShareClient) getPermissionCreateRequest(ctx context.Context, fileP } req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-file-permission-key"] = []string{filePermissionKey} - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if client.fileRequestIntent != nil { req.Raw().Header["x-ms-file-request-intent"] = []string{string(*client.fileRequestIntent)} } @@ -717,12 +743,6 @@ func (client *ShareClient) getPermissionCreateRequest(ctx context.Context, fileP // getPermissionHandleResponse handles the GetPermission response. func (client *ShareClient) getPermissionHandleResponse(resp *http.Response) (ShareClientGetPermissionResponse, error) { result := ShareClientGetPermissionResponse{} - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val - } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val - } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) if err != nil { @@ -730,6 +750,12 @@ func (client *ShareClient) getPermissionHandleResponse(resp *http.Response) (Sha } result.Date = &date } + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val + } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } if err := runtime.UnmarshalAsJSON(resp, &result.SharePermission); err != nil { return ShareClientGetPermissionResponse{}, err } @@ -740,22 +766,25 @@ func (client *ShareClient) getPermissionHandleResponse(resp *http.Response) (Sha // data returned does not include the share's list of files. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientGetPropertiesOptions contains the optional parameters for the ShareClient.GetProperties method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) GetProperties(ctx context.Context, options *ShareClientGetPropertiesOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientGetPropertiesResponse, error) { + var err error req, err := client.getPropertiesCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return ShareClientGetPropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientGetPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientGetPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientGetPropertiesResponse{}, err } - return client.getPropertiesHandleResponse(resp) + resp, err := client.getPropertiesHandleResponse(httpResp) + return resp, err } // getPropertiesCreateRequest creates the GetProperties request. @@ -773,7 +802,7 @@ func (client *ShareClient) getPropertiesCreateRequest(ctx context.Context, optio reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -784,29 +813,18 @@ func (client *ShareClient) getPropertiesCreateRequest(ctx context.Context, optio // getPropertiesHandleResponse handles the GetProperties response. func (client *ShareClient) getPropertiesHandleResponse(resp *http.Response) (ShareClientGetPropertiesResponse, error) { result := ShareClientGetPropertiesResponse{} - for hh := range resp.Header { - if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") { - if result.Metadata == nil { - result.Metadata = map[string]*string{} - } - result.Metadata[hh[len("x-ms-meta-"):]] = to.Ptr(resp.Header.Get(hh)) - } - } - if val := resp.Header.Get("ETag"); val != "" { - result.ETag = (*azcore.ETag)(&val) + if val := resp.Header.Get("x-ms-access-tier"); val != "" { + result.AccessTier = &val } - if val := resp.Header.Get("Last-Modified"); val != "" { - lastModified, err := time.Parse(time.RFC1123, val) + if val := resp.Header.Get("x-ms-access-tier-change-time"); val != "" { + accessTierChangeTime, err := time.Parse(time.RFC1123, val) if err != nil { return ShareClientGetPropertiesResponse{}, err } - result.LastModified = &lastModified - } - if val := resp.Header.Get("x-ms-request-id"); val != "" { - result.RequestID = &val + result.AccessTierChangeTime = &accessTierChangeTime } - if val := resp.Header.Get("x-ms-version"); val != "" { - result.Version = &val + if val := resp.Header.Get("x-ms-access-tier-transition-state"); val != "" { + result.AccessTierTransitionState = &val } if val := resp.Header.Get("Date"); val != "" { date, err := time.Parse(time.RFC1123, val) @@ -815,29 +833,50 @@ func (client *ShareClient) getPropertiesHandleResponse(resp *http.Response) (Sha } result.Date = &date } - if val := resp.Header.Get("x-ms-share-quota"); val != "" { - quota32, err := strconv.ParseInt(val, 10, 32) - quota := int32(quota32) + if val := resp.Header.Get("ETag"); val != "" { + result.ETag = (*azcore.ETag)(&val) + } + if val := resp.Header.Get("x-ms-enabled-protocols"); val != "" { + result.EnabledProtocols = &val + } + if val := resp.Header.Get("Last-Modified"); val != "" { + lastModified, err := time.Parse(time.RFC1123, val) if err != nil { return ShareClientGetPropertiesResponse{}, err } - result.Quota = "a + result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-share-provisioned-iops"); val != "" { - provisionedIops32, err := strconv.ParseInt(val, 10, 32) - provisionedIops := int32(provisionedIops32) + if val := resp.Header.Get("x-ms-lease-duration"); val != "" { + result.LeaseDuration = (*LeaseDurationType)(&val) + } + if val := resp.Header.Get("x-ms-lease-state"); val != "" { + result.LeaseState = (*LeaseStateType)(&val) + } + if val := resp.Header.Get("x-ms-lease-status"); val != "" { + result.LeaseStatus = (*LeaseStatusType)(&val) + } + for hh := range resp.Header { + if len(hh) > len("x-ms-meta-") && strings.EqualFold(hh[:len("x-ms-meta-")], "x-ms-meta-") { + if result.Metadata == nil { + result.Metadata = map[string]*string{} + } + result.Metadata[hh[len("x-ms-meta-"):]] = to.Ptr(resp.Header.Get(hh)) + } + } + if val := resp.Header.Get("x-ms-share-next-allowed-quota-downgrade-time"); val != "" { + nextAllowedQuotaDowngradeTime, err := time.Parse(time.RFC1123, val) if err != nil { return ShareClientGetPropertiesResponse{}, err } - result.ProvisionedIops = &provisionedIops + result.NextAllowedQuotaDowngradeTime = &nextAllowedQuotaDowngradeTime } - if val := resp.Header.Get("x-ms-share-provisioned-ingress-mbps"); val != "" { - provisionedIngressMBps32, err := strconv.ParseInt(val, 10, 32) - provisionedIngressMBps := int32(provisionedIngressMBps32) + if val := resp.Header.Get("x-ms-share-provisioned-bandwidth-mibps"); val != "" { + provisionedBandwidthMiBps32, err := strconv.ParseInt(val, 10, 32) + provisionedBandwidthMiBps := int32(provisionedBandwidthMiBps32) if err != nil { return ShareClientGetPropertiesResponse{}, err } - result.ProvisionedIngressMBps = &provisionedIngressMBps + result.ProvisionedBandwidthMiBps = &provisionedBandwidthMiBps } if val := resp.Header.Get("x-ms-share-provisioned-egress-mbps"); val != "" { provisionedEgressMBps32, err := strconv.ParseInt(val, 10, 32) @@ -847,71 +886,64 @@ func (client *ShareClient) getPropertiesHandleResponse(resp *http.Response) (Sha } result.ProvisionedEgressMBps = &provisionedEgressMBps } - if val := resp.Header.Get("x-ms-share-next-allowed-quota-downgrade-time"); val != "" { - nextAllowedQuotaDowngradeTime, err := time.Parse(time.RFC1123, val) + if val := resp.Header.Get("x-ms-share-provisioned-ingress-mbps"); val != "" { + provisionedIngressMBps32, err := strconv.ParseInt(val, 10, 32) + provisionedIngressMBps := int32(provisionedIngressMBps32) if err != nil { return ShareClientGetPropertiesResponse{}, err } - result.NextAllowedQuotaDowngradeTime = &nextAllowedQuotaDowngradeTime + result.ProvisionedIngressMBps = &provisionedIngressMBps } - if val := resp.Header.Get("x-ms-share-provisioned-bandwidth-mibps"); val != "" { - provisionedBandwidthMiBps32, err := strconv.ParseInt(val, 10, 32) - provisionedBandwidthMiBps := int32(provisionedBandwidthMiBps32) + if val := resp.Header.Get("x-ms-share-provisioned-iops"); val != "" { + provisionedIops32, err := strconv.ParseInt(val, 10, 32) + provisionedIops := int32(provisionedIops32) if err != nil { return ShareClientGetPropertiesResponse{}, err } - result.ProvisionedBandwidthMiBps = &provisionedBandwidthMiBps - } - if val := resp.Header.Get("x-ms-lease-duration"); val != "" { - result.LeaseDuration = (*LeaseDurationType)(&val) - } - if val := resp.Header.Get("x-ms-lease-state"); val != "" { - result.LeaseState = (*LeaseStateType)(&val) - } - if val := resp.Header.Get("x-ms-lease-status"); val != "" { - result.LeaseStatus = (*LeaseStatusType)(&val) - } - if val := resp.Header.Get("x-ms-access-tier"); val != "" { - result.AccessTier = &val + result.ProvisionedIops = &provisionedIops } - if val := resp.Header.Get("x-ms-access-tier-change-time"); val != "" { - accessTierChangeTime, err := time.Parse(time.RFC1123, val) + if val := resp.Header.Get("x-ms-share-quota"); val != "" { + quota32, err := strconv.ParseInt(val, 10, 32) + quota := int32(quota32) if err != nil { return ShareClientGetPropertiesResponse{}, err } - result.AccessTierChangeTime = &accessTierChangeTime - } - if val := resp.Header.Get("x-ms-access-tier-transition-state"); val != "" { - result.AccessTierTransitionState = &val + result.Quota = "a } - if val := resp.Header.Get("x-ms-enabled-protocols"); val != "" { - result.EnabledProtocols = &val + if val := resp.Header.Get("x-ms-request-id"); val != "" { + result.RequestID = &val } if val := resp.Header.Get("x-ms-root-squash"); val != "" { result.RootSquash = (*ShareRootSquash)(&val) } + if val := resp.Header.Get("x-ms-version"); val != "" { + result.Version = &val + } return result, nil } // GetStatistics - Retrieves statistics related to the share. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientGetStatisticsOptions contains the optional parameters for the ShareClient.GetStatistics method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) GetStatistics(ctx context.Context, options *ShareClientGetStatisticsOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientGetStatisticsResponse, error) { + var err error req, err := client.getStatisticsCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return ShareClientGetStatisticsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientGetStatisticsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientGetStatisticsResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientGetStatisticsResponse{}, err } - return client.getStatisticsHandleResponse(resp) + resp, err := client.getStatisticsHandleResponse(httpResp) + return resp, err } // getStatisticsCreateRequest creates the GetStatistics request. @@ -927,7 +959,7 @@ func (client *ShareClient) getStatisticsCreateRequest(ctx context.Context, optio reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -938,6 +970,13 @@ func (client *ShareClient) getStatisticsCreateRequest(ctx context.Context, optio // getStatisticsHandleResponse handles the GetStatistics response. func (client *ShareClient) getStatisticsHandleResponse(resp *http.Response) (ShareClientGetStatisticsResponse, error) { result := ShareClientGetStatisticsResponse{} + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientGetStatisticsResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -954,13 +993,6 @@ func (client *ShareClient) getStatisticsHandleResponse(resp *http.Response) (Sha if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientGetStatisticsResponse{}, err - } - result.Date = &date - } if err := runtime.UnmarshalAsXML(resp, &result.ShareStats); err != nil { return ShareClientGetStatisticsResponse{}, err } @@ -971,22 +1003,25 @@ func (client *ShareClient) getStatisticsHandleResponse(resp *http.Response) (Sha // delete share operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - leaseID - Specifies the current lease ID on the resource. // - options - ShareClientReleaseLeaseOptions contains the optional parameters for the ShareClient.ReleaseLease method. func (client *ShareClient) ReleaseLease(ctx context.Context, leaseID string, options *ShareClientReleaseLeaseOptions) (ShareClientReleaseLeaseResponse, error) { + var err error req, err := client.releaseLeaseCreateRequest(ctx, leaseID, options) if err != nil { return ShareClientReleaseLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientReleaseLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientReleaseLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientReleaseLeaseResponse{}, err } - return client.releaseLeaseHandleResponse(resp) + resp, err := client.releaseLeaseHandleResponse(httpResp) + return resp, err } // releaseLeaseCreateRequest creates the ReleaseLease request. @@ -1007,7 +1042,7 @@ func (client *ShareClient) releaseLeaseCreateRequest(ctx context.Context, leaseI req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-lease-action"] = []string{"release"} req.Raw().Header["x-ms-lease-id"] = []string{leaseID} - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -1018,6 +1053,16 @@ func (client *ShareClient) releaseLeaseCreateRequest(ctx context.Context, leaseI // releaseLeaseHandleResponse handles the ReleaseLease response. func (client *ShareClient) releaseLeaseHandleResponse(resp *http.Response) (ShareClientReleaseLeaseResponse, error) { result := ShareClientReleaseLeaseResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientReleaseLeaseResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -1028,22 +1073,12 @@ func (client *ShareClient) releaseLeaseHandleResponse(resp *http.Response) (Shar } result.LastModified = &lastModified } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientReleaseLeaseResponse{}, err - } - result.Date = &date - } return result, nil } @@ -1051,22 +1086,25 @@ func (client *ShareClient) releaseLeaseHandleResponse(resp *http.Response) (Shar // delete share operations. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - leaseID - Specifies the current lease ID on the resource. // - options - ShareClientRenewLeaseOptions contains the optional parameters for the ShareClient.RenewLease method. func (client *ShareClient) RenewLease(ctx context.Context, leaseID string, options *ShareClientRenewLeaseOptions) (ShareClientRenewLeaseResponse, error) { + var err error req, err := client.renewLeaseCreateRequest(ctx, leaseID, options) if err != nil { return ShareClientRenewLeaseResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientRenewLeaseResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientRenewLeaseResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientRenewLeaseResponse{}, err } - return client.renewLeaseHandleResponse(resp) + resp, err := client.renewLeaseHandleResponse(httpResp) + return resp, err } // renewLeaseCreateRequest creates the RenewLease request. @@ -1087,7 +1125,7 @@ func (client *ShareClient) renewLeaseCreateRequest(ctx context.Context, leaseID req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["x-ms-lease-action"] = []string{"renew"} req.Raw().Header["x-ms-lease-id"] = []string{leaseID} - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -1098,6 +1136,16 @@ func (client *ShareClient) renewLeaseCreateRequest(ctx context.Context, leaseID // renewLeaseHandleResponse handles the RenewLease response. func (client *ShareClient) renewLeaseHandleResponse(resp *http.Response) (ShareClientRenewLeaseResponse, error) { result := ShareClientRenewLeaseResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientRenewLeaseResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -1111,43 +1159,36 @@ func (client *ShareClient) renewLeaseHandleResponse(resp *http.Response) (ShareC if val := resp.Header.Get("x-ms-lease-id"); val != "" { result.LeaseID = &val } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientRenewLeaseResponse{}, err - } - result.Date = &date - } return result, nil } // Restore - Restores a previously deleted Share. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientRestoreOptions contains the optional parameters for the ShareClient.Restore method. func (client *ShareClient) Restore(ctx context.Context, options *ShareClientRestoreOptions) (ShareClientRestoreResponse, error) { + var err error req, err := client.restoreCreateRequest(ctx, options) if err != nil { return ShareClientRestoreResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientRestoreResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return ShareClientRestoreResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ShareClientRestoreResponse{}, err } - return client.restoreHandleResponse(resp) + resp, err := client.restoreHandleResponse(httpResp) + return resp, err } // restoreCreateRequest creates the Restore request. @@ -1163,7 +1204,7 @@ func (client *ShareClient) restoreCreateRequest(ctx context.Context, options *Sh reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.RequestID != nil { req.Raw().Header["x-ms-client-request-id"] = []string{*options.RequestID} } @@ -1180,6 +1221,16 @@ func (client *ShareClient) restoreCreateRequest(ctx context.Context, options *Sh // restoreHandleResponse handles the Restore response. func (client *ShareClient) restoreHandleResponse(resp *http.Response) (ShareClientRestoreResponse, error) { result := ShareClientRestoreResponse{} + if val := resp.Header.Get("x-ms-client-request-id"); val != "" { + result.ClientRequestID = &val + } + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientRestoreResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -1193,42 +1244,35 @@ func (client *ShareClient) restoreHandleResponse(resp *http.Response) (ShareClie if val := resp.Header.Get("x-ms-request-id"); val != "" { result.RequestID = &val } - if val := resp.Header.Get("x-ms-client-request-id"); val != "" { - result.ClientRequestID = &val - } if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientRestoreResponse{}, err - } - result.Date = &date - } return result, nil } // SetAccessPolicy - Sets a stored access policy for use with shared access signatures. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - shareACL - The ACL for the share. // - options - ShareClientSetAccessPolicyOptions contains the optional parameters for the ShareClient.SetAccessPolicy method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) SetAccessPolicy(ctx context.Context, shareACL []*SignedIdentifier, options *ShareClientSetAccessPolicyOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientSetAccessPolicyResponse, error) { + var err error req, err := client.setAccessPolicyCreateRequest(ctx, shareACL, options, leaseAccessConditions) if err != nil { return ShareClientSetAccessPolicyResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientSetAccessPolicyResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientSetAccessPolicyResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientSetAccessPolicyResponse{}, err } - return client.setAccessPolicyHandleResponse(resp) + resp, err := client.setAccessPolicyHandleResponse(httpResp) + return resp, err } // setAccessPolicyCreateRequest creates the SetAccessPolicy request. @@ -1244,7 +1288,7 @@ func (client *ShareClient) setAccessPolicyCreateRequest(ctx context.Context, sha reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -1262,6 +1306,13 @@ func (client *ShareClient) setAccessPolicyCreateRequest(ctx context.Context, sha // setAccessPolicyHandleResponse handles the SetAccessPolicy response. func (client *ShareClient) setAccessPolicyHandleResponse(resp *http.Response) (ShareClientSetAccessPolicyResponse, error) { result := ShareClientSetAccessPolicyResponse{} + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientSetAccessPolicyResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -1278,35 +1329,31 @@ func (client *ShareClient) setAccessPolicyHandleResponse(resp *http.Response) (S if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientSetAccessPolicyResponse{}, err - } - result.Date = &date - } return result, nil } // SetMetadata - Sets one or more user-defined name-value pairs for the specified share. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientSetMetadataOptions contains the optional parameters for the ShareClient.SetMetadata method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) SetMetadata(ctx context.Context, options *ShareClientSetMetadataOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientSetMetadataResponse, error) { + var err error req, err := client.setMetadataCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return ShareClientSetMetadataResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientSetMetadataResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientSetMetadataResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientSetMetadataResponse{}, err } - return client.setMetadataHandleResponse(resp) + resp, err := client.setMetadataHandleResponse(httpResp) + return resp, err } // setMetadataCreateRequest creates the SetMetadata request. @@ -1329,7 +1376,7 @@ func (client *ShareClient) setMetadataCreateRequest(ctx context.Context, options } } } - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if leaseAccessConditions != nil && leaseAccessConditions.LeaseID != nil { req.Raw().Header["x-ms-lease-id"] = []string{*leaseAccessConditions.LeaseID} } @@ -1340,6 +1387,13 @@ func (client *ShareClient) setMetadataCreateRequest(ctx context.Context, options // setMetadataHandleResponse handles the SetMetadata response. func (client *ShareClient) setMetadataHandleResponse(resp *http.Response) (ShareClientSetMetadataResponse, error) { result := ShareClientSetMetadataResponse{} + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientSetMetadataResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -1356,35 +1410,31 @@ func (client *ShareClient) setMetadataHandleResponse(resp *http.Response) (Share if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientSetMetadataResponse{}, err - } - result.Date = &date - } return result, nil } // SetProperties - Sets properties for the specified share. // If the operation fails it returns an *azcore.ResponseError type. // -// Generated from API version 2022-11-02 +// Generated from API version 2023-11-03 // - options - ShareClientSetPropertiesOptions contains the optional parameters for the ShareClient.SetProperties method. // - LeaseAccessConditions - LeaseAccessConditions contains a group of parameters for the ShareClient.GetProperties method. func (client *ShareClient) SetProperties(ctx context.Context, options *ShareClientSetPropertiesOptions, leaseAccessConditions *LeaseAccessConditions) (ShareClientSetPropertiesResponse, error) { + var err error req, err := client.setPropertiesCreateRequest(ctx, options, leaseAccessConditions) if err != nil { return ShareClientSetPropertiesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ShareClientSetPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ShareClientSetPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ShareClientSetPropertiesResponse{}, err } - return client.setPropertiesHandleResponse(resp) + resp, err := client.setPropertiesHandleResponse(httpResp) + return resp, err } // setPropertiesCreateRequest creates the SetProperties request. @@ -1400,7 +1450,7 @@ func (client *ShareClient) setPropertiesCreateRequest(ctx context.Context, optio reqQP.Set("timeout", strconv.FormatInt(int64(*options.Timeout), 10)) } req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["x-ms-version"] = []string{"2022-11-02"} + req.Raw().Header["x-ms-version"] = []string{ServiceVersion} if options != nil && options.Quota != nil { req.Raw().Header["x-ms-share-quota"] = []string{strconv.FormatInt(int64(*options.Quota), 10)} } @@ -1420,6 +1470,13 @@ func (client *ShareClient) setPropertiesCreateRequest(ctx context.Context, optio // setPropertiesHandleResponse handles the SetProperties response. func (client *ShareClient) setPropertiesHandleResponse(resp *http.Response) (ShareClientSetPropertiesResponse, error) { result := ShareClientSetPropertiesResponse{} + if val := resp.Header.Get("Date"); val != "" { + date, err := time.Parse(time.RFC1123, val) + if err != nil { + return ShareClientSetPropertiesResponse{}, err + } + result.Date = &date + } if val := resp.Header.Get("ETag"); val != "" { result.ETag = (*azcore.ETag)(&val) } @@ -1436,12 +1493,5 @@ func (client *ShareClient) setPropertiesHandleResponse(resp *http.Response) (Sha if val := resp.Header.Get("x-ms-version"); val != "" { result.Version = &val } - if val := resp.Header.Get("Date"); val != "" { - date, err := time.Parse(time.RFC1123, val) - if err != nil { - return ShareClientSetPropertiesResponse{}, err - } - result.Date = &date - } return result, nil } diff --git a/sdk/storage/azfile/internal/generated/zz_time_rfc1123.go b/sdk/storage/azfile/internal/generated/zz_time_rfc1123.go index 4b4d51aa3994..586650329724 100644 --- a/sdk/storage/azfile/internal/generated/zz_time_rfc1123.go +++ b/sdk/storage/azfile/internal/generated/zz_time_rfc1123.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated @@ -15,29 +14,29 @@ import ( ) const ( - rfc1123JSON = `"` + time.RFC1123 + `"` + dateTimeRFC1123JSON = `"` + time.RFC1123 + `"` ) -type timeRFC1123 time.Time +type dateTimeRFC1123 time.Time -func (t timeRFC1123) MarshalJSON() ([]byte, error) { - b := []byte(time.Time(t).Format(rfc1123JSON)) +func (t dateTimeRFC1123) MarshalJSON() ([]byte, error) { + b := []byte(time.Time(t).Format(dateTimeRFC1123JSON)) return b, nil } -func (t timeRFC1123) MarshalText() ([]byte, error) { +func (t dateTimeRFC1123) MarshalText() ([]byte, error) { b := []byte(time.Time(t).Format(time.RFC1123)) return b, nil } -func (t *timeRFC1123) UnmarshalJSON(data []byte) error { - p, err := time.Parse(rfc1123JSON, strings.ToUpper(string(data))) - *t = timeRFC1123(p) +func (t *dateTimeRFC1123) UnmarshalJSON(data []byte) error { + p, err := time.Parse(dateTimeRFC1123JSON, strings.ToUpper(string(data))) + *t = dateTimeRFC1123(p) return err } -func (t *timeRFC1123) UnmarshalText(data []byte) error { +func (t *dateTimeRFC1123) UnmarshalText(data []byte) error { p, err := time.Parse(time.RFC1123, string(data)) - *t = timeRFC1123(p) + *t = dateTimeRFC1123(p) return err } diff --git a/sdk/storage/azfile/internal/generated/zz_time_rfc3339.go b/sdk/storage/azfile/internal/generated/zz_time_rfc3339.go index 1ce9d621164e..82b370133fac 100644 --- a/sdk/storage/azfile/internal/generated/zz_time_rfc3339.go +++ b/sdk/storage/azfile/internal/generated/zz_time_rfc3339.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated @@ -15,45 +14,45 @@ import ( "time" ) -const ( - utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` - utcLayout = "2006-01-02T15:04:05.999999999" - rfc3339JSON = `"` + time.RFC3339Nano + `"` -) - // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) -type timeRFC3339 time.Time +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time -func (t timeRFC3339) MarshalJSON() (json []byte, err error) { +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { tt := time.Time(t) return tt.MarshalJSON() } -func (t timeRFC3339) MarshalText() (text []byte, err error) { +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { tt := time.Time(t) return tt.MarshalText() } -func (t *timeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcLayoutJSON +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON if tzOffsetRegex.Match(data) { - layout = rfc3339JSON + layout = dateTimeJSON } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { - layout := utcLayout +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime if tzOffsetRegex.Match(data) { layout = time.RFC3339Nano } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) Parse(layout, value string) error { +func (t *dateTimeRFC3339) Parse(layout, value string) error { p, err := time.Parse(layout, strings.ToUpper(value)) - *t = timeRFC3339(p) + *t = dateTimeRFC3339(p) return err } diff --git a/sdk/storage/azfile/internal/generated/zz_xml_helper.go b/sdk/storage/azfile/internal/generated/zz_xml_helper.go index 144ea18e1aba..1bd0e4de05a8 100644 --- a/sdk/storage/azfile/internal/generated/zz_xml_helper.go +++ b/sdk/storage/azfile/internal/generated/zz_xml_helper.go @@ -3,14 +3,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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package generated import ( "encoding/xml" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "io" "strings" ) @@ -19,22 +21,32 @@ type additionalProperties map[string]*string // UnmarshalXML implements the xml.Unmarshaler interface for additionalProperties. func (ap *additionalProperties) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error { tokName := "" - for t, err := d.Token(); err == nil; t, err = d.Token() { + tokValue := "" + for { + t, err := d.Token() + if errors.Is(err, io.EOF) { + break + } else if err != nil { + return err + } switch tt := t.(type) { case xml.StartElement: tokName = strings.ToLower(tt.Name.Local) - break + tokValue = "" case xml.CharData: + if tokName == "" { + continue + } + tokValue = string(tt) + case xml.EndElement: if tokName == "" { continue } if *ap == nil { *ap = additionalProperties{} } - s := string(tt) - (*ap)[tokName] = &s + (*ap)[tokName] = to.Ptr(tokValue) tokName = "" - break } } return nil diff --git a/sdk/storage/azfile/service/client.go b/sdk/storage/azfile/service/client.go index aec7d058169c..1fd1f819313e 100644 --- a/sdk/storage/azfile/service/client.go +++ b/sdk/storage/azfile/service/client.go @@ -38,7 +38,8 @@ type Client base.Client[generated.ServiceClient] // This constructor exists to allow the construction of a share.Client that has token credential authentication. // Also note that ClientOptions.FileRequestIntent is currently required for token authentication. func NewClient(serviceURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { - authPolicy := runtime.NewBearerTokenPolicy(cred, []string{shared.TokenScope}, nil) + audience := base.GetAudience((*base.ClientOptions)(options)) + authPolicy := runtime.NewBearerTokenPolicy(cred, []string{audience}, nil) conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{ PerRetry: []policy.Policy{authPolicy}, diff --git a/sdk/storage/azfile/service/client_test.go b/sdk/storage/azfile/service/client_test.go index 9f0521dd6e0f..0d83e8556f30 100644 --- a/sdk/storage/azfile/service/client_test.go +++ b/sdk/storage/azfile/service/client_test.go @@ -629,3 +629,38 @@ func (s *ServiceRecordedTestsSuite) TestPremiumAccountListShares() { } } } + +func (s *ServiceRecordedTestsSuite) TestServiceClientCustomAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + // create service client using token credential + options := &service.ClientOptions{ + FileRequestIntent: to.Ptr(service.ShareTokenIntentBackup), + Audience: "https://" + accountName + ".file.core.windows.net", + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + svcClientAudience, err := service.NewClient("https://"+accountName+".file.core.windows.net/", cred, options) + _require.NoError(err) + + dirClientAudience := svcClientAudience.NewShareClient(shareName).NewDirectoryClient(testcommon.GenerateDirectoryName(testName)) + + _, err = dirClientAudience.Create(context.Background(), nil) + _require.NoError(err) + + _, err = dirClientAudience.GetProperties(context.Background(), nil) + _require.NoError(err) +} diff --git a/sdk/storage/azfile/share/client.go b/sdk/storage/azfile/share/client.go index 466774c548dc..db30b3f48c16 100644 --- a/sdk/storage/azfile/share/client.go +++ b/sdk/storage/azfile/share/client.go @@ -37,7 +37,8 @@ type Client base.Client[generated.ShareClient] // Note that the only share-level operations that support token credential authentication are CreatePermission and GetPermission. // Also note that ClientOptions.FileRequestIntent is currently required for token authentication. func NewClient(shareURL string, cred azcore.TokenCredential, options *ClientOptions) (*Client, error) { - authPolicy := runtime.NewBearerTokenPolicy(cred, []string{shared.TokenScope}, nil) + audience := base.GetAudience((*base.ClientOptions)(options)) + authPolicy := runtime.NewBearerTokenPolicy(cred, []string{audience}, nil) conOptions := shared.GetClientOptions(options) plOpts := runtime.PipelineOptions{ PerRetry: []policy.Policy{authPolicy}, diff --git a/sdk/storage/azfile/share/client_test.go b/sdk/storage/azfile/share/client_test.go index 9d86d5d9a46e..a5dc7fb74d4e 100644 --- a/sdk/storage/azfile/share/client_test.go +++ b/sdk/storage/azfile/share/client_test.go @@ -1627,3 +1627,108 @@ func (s *ShareRecordedTestsSuite) TestPremiumShareBandwidth() { _require.NotNil(response.NextAllowedQuotaDowngradeTime) _require.Greater(*response.ProvisionedBandwidthMiBps, (int32)(0)) } + +func (s *ShareRecordedTestsSuite) TestShareClientDefaultAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + options := &share.ClientOptions{ + FileRequestIntent: to.Ptr(share.TokenIntentBackup), + Audience: "https://storage.azure.com/", + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + shareClientAudience, err := share.NewClient("https://"+accountName+".file.core.windows.net/"+shareName, cred, options) + _require.NoError(err) + + // Create a permission and check that it's not empty. + createResp, err := shareClientAudience.CreatePermission(context.Background(), testcommon.SampleSDDL, nil) + _require.NoError(err) + _require.NotNil(createResp.FilePermissionKey) + _require.NotEmpty(*createResp.FilePermissionKey) + + getResp, err := shareClientAudience.GetPermission(context.Background(), *createResp.FilePermissionKey, nil) + _require.NoError(err) + _require.NotNil(getResp.Permission) + _require.NotEmpty(*getResp.Permission) +} + +func (s *ShareRecordedTestsSuite) TestShareClientCustomAudience() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + options := &share.ClientOptions{ + FileRequestIntent: to.Ptr(share.TokenIntentBackup), + Audience: "https://" + accountName + ".file.core.windows.net", + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + shareClientAudience, err := share.NewClient("https://"+accountName+".file.core.windows.net/"+shareName, cred, options) + _require.NoError(err) + + // Create a permission and check that it's not empty. + createResp, err := shareClientAudience.CreatePermission(context.Background(), testcommon.SampleSDDL, nil) + _require.NoError(err) + _require.NotNil(createResp.FilePermissionKey) + _require.NotEmpty(*createResp.FilePermissionKey) + + getResp, err := shareClientAudience.GetPermission(context.Background(), *createResp.FilePermissionKey, nil) + _require.NoError(err) + _require.NotNil(getResp.Permission) + _require.NotEmpty(*getResp.Permission) +} + +func (s *ShareRecordedTestsSuite) TestShareClientAudienceNegative() { + _require := require.New(s.T()) + testName := s.T().Name() + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + cred, err := testcommon.GetGenericTokenCredential() + _require.NoError(err) + + svcClient, err := testcommon.GetServiceClient(s.T(), testcommon.TestAccountDefault, nil) + _require.NoError(err) + + shareName := testcommon.GenerateShareName(testName) + shareClient := testcommon.CreateNewShare(context.Background(), _require, shareName, svcClient) + defer testcommon.DeleteShare(context.Background(), _require, shareClient) + + options := &share.ClientOptions{ + FileRequestIntent: to.Ptr(share.TokenIntentBackup), + Audience: "https://badaudience.file.core.windows.net", + } + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + shareClientAudience, err := share.NewClient("https://"+accountName+".file.core.windows.net/"+shareName, cred, options) + _require.NoError(err) + + // Create a permission and check that it's not empty. + _, err = shareClientAudience.CreatePermission(context.Background(), testcommon.SampleSDDL, nil) + _require.Error(err) + testcommon.ValidateFileErrorCode(_require, err, fileerror.AuthenticationFailed) +} From 3ba68177f364dc84353a90c65b362c5c1190b0b2 Mon Sep 17 00:00:00 2001 From: Felix <9039899+fkarg@users.noreply.github.com> Date: Fri, 5 Jan 2024 17:06:42 +0100 Subject: [PATCH 06/32] update source link to new azopenai location (#22208) * link current instead of depricated path * remove newline at end of file --- sdk/ai/azopenai/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/ai/azopenai/README.md b/sdk/ai/azopenai/README.md index c564dc79bb54..f4590827a505 100644 --- a/sdk/ai/azopenai/README.md +++ b/sdk/ai/azopenai/README.md @@ -84,7 +84,7 @@ comments. [azure_openai_access]: https://learn.microsoft.com/azure/cognitive-services/openai/overview#how-do-i-get-access-to-azure-openai -[azopenai_repo]: https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/cognitiveservices/azopenai +[azopenai_repo]: https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/ai/azopenai [azopenai_pkg_go]: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai [azure_identity]: https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity [azure_sub]: https://azure.microsoft.com/free/ @@ -95,4 +95,4 @@ comments. [coc]: https://opensource.microsoft.com/codeofconduct/ [coc_faq]: https://opensource.microsoft.com/codeofconduct/faq/ [coc_contact]: mailto:opencode@microsoft.com -[azure_openai_quickstart]: https://learn.microsoft.com/azure/cognitive-services/openai/quickstart \ No newline at end of file +[azure_openai_quickstart]: https://learn.microsoft.com/azure/cognitive-services/openai/quickstart From 4162eea0d9eb5d2726e6c3b290f05c5f787c2980 Mon Sep 17 00:00:00 2001 From: Joel Hendrix Date: Fri, 5 Jan 2024 09:42:57 -0800 Subject: [PATCH 07/32] More azappconfig cleanup (#22209) * More azappconfig cleanup Update BeginCreateSnapshot to return the complete Snapshot type. Remove unused response types. Added some missed error checking in a few tests. * fix a few doc comments --- sdk/data/azappconfig/client_test.go | 20 +++++++----------- sdk/data/azappconfig/response_types.go | 25 +++++----------------- sdk/data/azappconfig/snapshot.go | 29 -------------------------- 3 files changed, 13 insertions(+), 61 deletions(-) diff --git a/sdk/data/azappconfig/client_test.go b/sdk/data/azappconfig/client_test.go index 4835051a823b..3cc538062d60 100644 --- a/sdk/data/azappconfig/client_test.go +++ b/sdk/data/azappconfig/client_test.go @@ -473,11 +473,12 @@ func TestSnapshotListConfigurationSettings(t *testing.T) { // Cleanup Settings for _, setting := range Settings { - _, _ = client.DeleteSetting(context.Background(), *setting.Key, nil) + _, err = client.DeleteSetting(context.Background(), *setting.Key, nil) + require.NoError(t, err) } // Cleanup Snapshots - _ = CleanupSnapshot(client, snapshotName) + require.NoError(t, CleanupSnapshot(client, snapshotName)) } func TestGetSnapshots(t *testing.T) { @@ -525,7 +526,7 @@ func TestGetSnapshots(t *testing.T) { // Cleanup Snapshots for i := 0; i < ssCreateCount; i++ { cleanSSName := snapshotName + fmt.Sprintf("%d", i) - _ = CleanupSnapshot(client, cleanSSName) + require.NoError(t, CleanupSnapshot(client, cleanSSName)) } } @@ -548,7 +549,7 @@ func TestSnapshotArchive(t *testing.T) { require.Equal(t, azappconfig.SnapshotStatusArchived, *archiveSnapshot.Snapshot.Status) //Best effort snapshot cleanup - _ = CleanupSnapshot(client, snapshotName) + require.NoError(t, CleanupSnapshot(client, snapshotName)) } func TestSnapshotRecover(t *testing.T) { @@ -576,7 +577,7 @@ func TestSnapshotRecover(t *testing.T) { require.Equal(t, azappconfig.SnapshotStatusReady, *readySnapshot.Snapshot.Status) // Best effort snapshot cleanup - _ = CleanupSnapshot(client, snapshotName) + require.NoError(t, CleanupSnapshot(client, snapshotName)) } func TestSnapshotCreate(t *testing.T) { @@ -591,7 +592,7 @@ func TestSnapshotCreate(t *testing.T) { require.Equal(t, snapshotName, *snapshot.Name) // Best effort cleanup snapshot - _ = CleanupSnapshot(client, snapshotName) + require.NoError(t, CleanupSnapshot(client, snapshotName)) } func CreateSnapshot(c *azappconfig.Client, snapshotName string, sf []azappconfig.SettingFilter) (azappconfig.CreateSnapshotResponse, error) { @@ -604,10 +605,8 @@ func CreateSnapshot(c *azappconfig.Client, snapshotName string, sf []azappconfig } } - retPer := int64(3600) - opts := &azappconfig.CreateSnapshotOptions{ - RetentionPeriod: &retPer, + RetentionPeriod: to.Ptr[int64](3600), } //Create a snapshot @@ -617,9 +616,6 @@ func CreateSnapshot(c *azappconfig.Client, snapshotName string, sf []azappconfig return azappconfig.CreateSnapshotResponse{}, err } - if resp == nil { - return azappconfig.CreateSnapshotResponse{}, fmt.Errorf("resp is nil") - } snapshot, err := resp.PollUntilDone(context.Background(), &runtime.PollUntilDoneOptions{ Frequency: 1 * time.Second, }) diff --git a/sdk/data/azappconfig/response_types.go b/sdk/data/azappconfig/response_types.go index c2f484d2f298..a85c587d1895 100644 --- a/sdk/data/azappconfig/response_types.go +++ b/sdk/data/azappconfig/response_types.go @@ -9,7 +9,6 @@ package azappconfig import ( "time" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/data/azappconfig/internal/exported" ) @@ -46,18 +45,18 @@ type GetSettingResponse struct { SyncToken SyncToken } -// ListRevisionsPageResponse contains the configuration settings returned by ListRevisionsPager. +// ListRevisionsPageResponse contains the response from the NewListRevisionsPager method. type ListRevisionsPageResponse struct { - // Contains the configuration settings returned that match the setting selector provided. + // Contains the configuration setting revisions that match the setting selector provided. Settings []Setting // SyncToken contains the value returned in the Sync-Token header. SyncToken SyncToken } -// ListSettingsPageResponse contains the configuration settings returned by ListRevisionsPager. +// ListSettingsPageResponse contains the response from the NewListSettingsPager method. type ListSettingsPageResponse struct { - // Contains the configuration settings returned that match the setting selector provided. + // Contains the configuration settings that match the setting selector provided. Settings []Setting // SyncToken contains the value returned in the Sync-Token header. @@ -103,7 +102,7 @@ type ListSnapshotsResponse struct { // CreateSnapshotResponse contains the response from the BeginCreateSnapshot method. type CreateSnapshotResponse struct { // Read-Only information about the snapshot retrieved from a Create Snapshot operation. - SnapshotInfo + Snapshot } // ListSettingsForSnapshotResponse contains the response from the ListConfigurationSettingsForSnapshot method. @@ -148,17 +147,3 @@ type updateSnapshotStatusResponse struct { // SyncToken contains the information returned from the Sync-Token header response. SyncToken SyncToken } - -// AzureAppConfigurationClientUpdateSnapshotResponse contains the response from method AzureAppConfigurationClient.UpdateSnapshot. -type AzureAppConfigurationClientUpdateSnapshotResponse struct { - Snapshot - - // ETag contains the information returned from the ETag header response. - ETag azcore.ETag - - // Link contains the information returned from the Link header response. - Link *string - - // SyncToken contains the information returned from the Sync-Token header response. - SyncToken *string -} diff --git a/sdk/data/azappconfig/snapshot.go b/sdk/data/azappconfig/snapshot.go index b21af781d35d..ba959d9dd948 100644 --- a/sdk/data/azappconfig/snapshot.go +++ b/sdk/data/azappconfig/snapshot.go @@ -12,37 +12,8 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" ) -// SnapshotInfo contains the snapshot information returned from a Create Snapshot Request -type SnapshotInfo struct { - - // READ-ONLY; The name of the snapshot. - Name *string `json:"name"` - - // READ-ONLY; The current status of the snapshot. - Status *SnapshotStatus `json:"status"` - - // READ-ONLY; The time that the snapshot was created. - Created *time.Time `json:"created"` - - // READ-ONLY; A value representing the current state of the snapshot. - ETag *azcore.ETag `json:"etag"` - - // READ-ONLY; The time that the snapshot will expire. - Expires *time.Time `json:"expires"` - - // READ-ONLY; The amount of key-values in the snapshot. - ItemsCount *int64 `json:"items_count"` - - // READ-ONLY; The size in bytes of the snapshot. - Size *int64 `json:"size"` - - // READ-ONLY; The retention period of the snapshot on archive in seconds. - RetentionPeriod *int64 `json:"retention_period"` -} - // Snapshot contains the snapshot information returned from a Get Snapshot Request type Snapshot struct { - // REQUIRED; A list of filters used to filter the key-values included in the snapshot. Filters []SettingFilter `json:"filters"` From 2d017b7022f10d2130e6da74c67abf3a81804210 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Fri, 5 Jan 2024 13:31:25 -0800 Subject: [PATCH 08/32] Fix spelling (preceeding=> preceding) (#22202) Co-authored-by: Anton Kolesnyk <41349689+antkmsft@users.noreply.github.com> --- eng/common/scripts/Submit-PullRequest.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/Submit-PullRequest.ps1 b/eng/common/scripts/Submit-PullRequest.ps1 index 890590fee6d4..f272ba479e3f 100644 --- a/eng/common/scripts/Submit-PullRequest.ps1 +++ b/eng/common/scripts/Submit-PullRequest.ps1 @@ -23,12 +23,12 @@ The body message for the pull request. The labels added to the PRs. Multple labels seperated by comma, e.g "bug, service" .PARAMETER UserReviewers User reviewers to request after opening the PR. Users should be a comma- -separated list with no preceeding `@` symbol (e.g. "user1,usertwo,user3") +separated list with no preceding `@` symbol (e.g. "user1,usertwo,user3") .PARAMETER TeamReviewers List of github teams to add as reviewers .PARAMETER Assignees Users to assign to the PR after opening. Users should be a comma-separated list -with no preceeding `@` symbol (e.g. "user1,usertwo,user3") +with no preceding `@` symbol (e.g. "user1,usertwo,user3") .PARAMETER CloseAfterOpenForTesting Close the PR after opening to save on CI resources and prevent alerts to code owners, assignees, requested reviewers, or others. From 06a9327c20438d10b59a289bddc3d58d747f76fe Mon Sep 17 00:00:00 2001 From: Sourav Gupta <98318303+souravgupta-msft@users.noreply.github.com> Date: Mon, 8 Jan 2024 11:18:26 +0530 Subject: [PATCH 09/32] Storage: Reject HTTP endpoints (#22183) --- sdk/storage/azblob/CHANGELOG.md | 2 ++ sdk/storage/azblob/assets.json | 2 +- .../exported/shared_key_credential.go | 20 +++++++++++++ sdk/storage/azblob/service/client_test.go | 29 ++++++++++++++++++ sdk/storage/azdatalake/CHANGELOG.md | 3 ++ sdk/storage/azdatalake/assets.json | 4 +-- .../exported/shared_key_credential.go | 24 +++++++++++++++ sdk/storage/azdatalake/service/client_test.go | 30 +++++++++++++++++++ sdk/storage/azfile/CHANGELOG.md | 1 + sdk/storage/azfile/assets.json | 2 +- .../exported/shared_key_credential.go | 20 +++++++++++++ sdk/storage/azfile/service/client_test.go | 28 +++++++++++++++++ 12 files changed, 161 insertions(+), 4 deletions(-) diff --git a/sdk/storage/azblob/CHANGELOG.md b/sdk/storage/azblob/CHANGELOG.md index 0d363352c48c..f3e61a635b7c 100644 --- a/sdk/storage/azblob/CHANGELOG.md +++ b/sdk/storage/azblob/CHANGELOG.md @@ -11,6 +11,8 @@ ### Bugs Fixed +* Block `SharedKeyCredential` authentication mode for non TLS protected endpoints. Fixes [#21841](https://github.com/Azure/azure-sdk-for-go/issues/21841). + ### Other Changes ## 1.2.1 (2023-12-13) diff --git a/sdk/storage/azblob/assets.json b/sdk/storage/azblob/assets.json index a2a2f83f8d49..df7d66f02108 100644 --- a/sdk/storage/azblob/assets.json +++ b/sdk/storage/azblob/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/storage/azblob", - "Tag": "go/storage/azblob_ceb9b7d6b4" + "Tag": "go/storage/azblob_9f40a5a13d" } diff --git a/sdk/storage/azblob/internal/exported/shared_key_credential.go b/sdk/storage/azblob/internal/exported/shared_key_credential.go index bd0bd5e260db..e4b076601f4e 100644 --- a/sdk/storage/azblob/internal/exported/shared_key_credential.go +++ b/sdk/storage/azblob/internal/exported/shared_key_credential.go @@ -11,7 +11,9 @@ import ( "crypto/hmac" "crypto/sha256" "encoding/base64" + "errors" "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/internal/errorinfo" "net/http" "net/url" "sort" @@ -195,6 +197,17 @@ func NewSharedKeyCredPolicy(cred *SharedKeyCredential) *SharedKeyCredPolicy { } func (s *SharedKeyCredPolicy) Do(req *policy.Request) (*http.Response, error) { + // skip adding the authorization header if no SharedKeyCredential was provided. + // this prevents a panic that might be hard to diagnose and allows testing + // against http endpoints that don't require authentication. + if s.cred == nil { + return req.Next() + } + + if err := checkHTTPSForAuth(req); err != nil { + return nil, err + } + if d := getHeader(shared.HeaderXmsDate, req.Raw().Header); d == "" { req.Raw().Header.Set(shared.HeaderXmsDate, time.Now().UTC().Format(http.TimeFormat)) } @@ -216,3 +229,10 @@ func (s *SharedKeyCredPolicy) Do(req *policy.Request) (*http.Response, error) { } return response, err } + +func checkHTTPSForAuth(req *policy.Request) error { + if strings.ToLower(req.Raw().URL.Scheme) != "https" { + return errorinfo.NonRetriableError(errors.New("authenticated requests are not permitted for non TLS protected (https) endpoints")) + } + return nil +} diff --git a/sdk/storage/azblob/service/client_test.go b/sdk/storage/azblob/service/client_test.go index 0449197a4013..bac044016dbf 100644 --- a/sdk/storage/azblob/service/client_test.go +++ b/sdk/storage/azblob/service/client_test.go @@ -1810,6 +1810,35 @@ func (s *ServiceUnrecordedTestsSuite) TestServiceBlobBatchErrors() { _require.Error(err) } +func (s *ServiceRecordedTestsSuite) TestServiceClientRejectHTTP() { + _require := require.New(s.T()) + + cred, err := testcommon.GetGenericSharedKeyCredential(testcommon.TestAccountDefault) + _require.NoError(err) + + svcClient, err := service.NewClientWithSharedKeyCredential("http://"+cred.AccountName()+".blob.core.windows.net/", cred, nil) + _require.NoError(err) + + _, err = svcClient.GetProperties(context.Background(), nil) + _require.Error(err) +} + +func (s *ServiceRecordedTestsSuite) TestServiceClientWithNilSharedKey() { + _require := require.New(s.T()) + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + options := &service.ClientOptions{} + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + svcClient, err := service.NewClientWithSharedKeyCredential("https://"+accountName+".blob.core.windows.net/", nil, options) + _require.NoError(err) + + _, err = svcClient.GetProperties(context.Background(), nil) + _require.Error(err) + testcommon.ValidateBlobErrorCode(_require, err, bloberror.NoAuthenticationInformation) +} + func (s *ServiceRecordedTestsSuite) TestServiceClientDefaultAudience() { _require := require.New(s.T()) testName := s.T().Name() diff --git a/sdk/storage/azdatalake/CHANGELOG.md b/sdk/storage/azdatalake/CHANGELOG.md index 1dd1454ebc94..40d907997e00 100644 --- a/sdk/storage/azdatalake/CHANGELOG.md +++ b/sdk/storage/azdatalake/CHANGELOG.md @@ -12,8 +12,11 @@ ### Bugs Fixed +* Block `SharedKeyCredential` authentication mode for non TLS protected endpoints. Fixes [#21841](https://github.com/Azure/azure-sdk-for-go/issues/21841). + ### Other Changes * Updated version of azblob to 1.2.1 +* Updated azcore version to `1.9.1` and azidentity version to `1.4.0`. ## 1.0.0 (2023-10-18) diff --git a/sdk/storage/azdatalake/assets.json b/sdk/storage/azdatalake/assets.json index 877057ad3692..626d6568abd4 100644 --- a/sdk/storage/azdatalake/assets.json +++ b/sdk/storage/azdatalake/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/storage/azdatalake", - "Tag": "go/storage/azdatalake_abd1896b54" -} \ No newline at end of file + "Tag": "go/storage/azdatalake_3ae5e1441b" +} diff --git a/sdk/storage/azdatalake/internal/exported/shared_key_credential.go b/sdk/storage/azdatalake/internal/exported/shared_key_credential.go index e75b29f0ad8b..bf0c728faf53 100644 --- a/sdk/storage/azdatalake/internal/exported/shared_key_credential.go +++ b/sdk/storage/azdatalake/internal/exported/shared_key_credential.go @@ -11,7 +11,9 @@ import ( "crypto/hmac" "crypto/sha256" "encoding/base64" + "errors" "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/internal/errorinfo" "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob" "net/http" "net/url" @@ -50,6 +52,9 @@ func (c *SharedKeyCredential) AccountName() string { } func ConvertToBlobSharedKey(c *SharedKeyCredential) (*azblob.SharedKeyCredential, error) { + if c == nil { + return nil, errors.New("SharedKeyCredential cannot be nil") + } cred, err := azblob.NewSharedKeyCredential(c.accountName, c.accountKeyString) if err != nil { return nil, err @@ -205,6 +210,17 @@ func NewSharedKeyCredPolicy(cred *SharedKeyCredential) *SharedKeyCredPolicy { } func (s *SharedKeyCredPolicy) Do(req *policy.Request) (*http.Response, error) { + // skip adding the authorization header if no SharedKeyCredential was provided. + // this prevents a panic that might be hard to diagnose and allows testing + // against http endpoints that don't require authentication. + if s.cred == nil { + return req.Next() + } + + if err := checkHTTPSForAuth(req); err != nil { + return nil, err + } + if d := getHeader(shared.HeaderXmsDate, req.Raw().Header); d == "" { req.Raw().Header.Set(shared.HeaderXmsDate, time.Now().UTC().Format(http.TimeFormat)) } @@ -226,3 +242,11 @@ func (s *SharedKeyCredPolicy) Do(req *policy.Request) (*http.Response, error) { } return response, err } + +// TODO: update the azblob dependency having checks for rejecting URLs that are not HTTPS +func checkHTTPSForAuth(req *policy.Request) error { + if strings.ToLower(req.Raw().URL.Scheme) != "https" { + return errorinfo.NonRetriableError(errors.New("authenticated requests are not permitted for non TLS protected (https) endpoints")) + } + return nil +} diff --git a/sdk/storage/azdatalake/service/client_test.go b/sdk/storage/azdatalake/service/client_test.go index a8a0f8c6f196..8720bba2980f 100644 --- a/sdk/storage/azdatalake/service/client_test.go +++ b/sdk/storage/azdatalake/service/client_test.go @@ -800,3 +800,33 @@ func (s *ServiceRecordedTestsSuite) TestAccountListFilesystemsEmptyPrefix() { } _require.GreaterOrEqual(count, 2) } + +func (s *ServiceRecordedTestsSuite) TestServiceClientRejectHTTP() { + _require := require.New(s.T()) + testName := s.T().Name() + + cred, err := testcommon.GetGenericSharedKeyCredential(testcommon.TestAccountDatalake) + _require.NoError(err) + + svcClient, err := service.NewClientWithSharedKeyCredential("http://"+cred.AccountName()+".dfs.core.windows.net/", cred, nil) + _require.NoError(err) + + fsName := testcommon.GenerateFileSystemName(testName) + fileName := testcommon.GenerateFileName(testName) + fileClient := svcClient.NewFileSystemClient(fsName).NewFileClient(fileName) + _require.Equal(fileClient.DFSURL(), "http://"+cred.AccountName()+".dfs.core.windows.net/"+fsName+"/"+fileName) + + _, err = fileClient.Create(context.Background(), nil) + _require.Error(err) +} + +func (s *ServiceRecordedTestsSuite) TestServiceClientWithNilSharedKey() { + _require := require.New(s.T()) + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDatalake) + _require.Greater(len(accountName), 0) + + svcClient, err := service.NewClientWithSharedKeyCredential("http://"+accountName+".dfs.core.windows.net/", nil, nil) + _require.Error(err) + _require.Nil(svcClient) +} diff --git a/sdk/storage/azfile/CHANGELOG.md b/sdk/storage/azfile/CHANGELOG.md index 973dbcf87a93..adc678058e38 100644 --- a/sdk/storage/azfile/CHANGELOG.md +++ b/sdk/storage/azfile/CHANGELOG.md @@ -12,6 +12,7 @@ ### Bugs Fixed +* Block `SharedKeyCredential` authentication mode for non TLS protected endpoints. Fixes [#21841](https://github.com/Azure/azure-sdk-for-go/issues/21841). * Fixed a bug where `UploadRangeFromURL` using OAuth was returning error. ### Other Changes diff --git a/sdk/storage/azfile/assets.json b/sdk/storage/azfile/assets.json index 4c4caf344b81..0c84c78afe62 100644 --- a/sdk/storage/azfile/assets.json +++ b/sdk/storage/azfile/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/storage/azfile", - "Tag": "go/storage/azfile_f80b868396" + "Tag": "go/storage/azfile_8f8ed3dd66" } diff --git a/sdk/storage/azfile/internal/exported/shared_key_credential.go b/sdk/storage/azfile/internal/exported/shared_key_credential.go index 50aaf889942f..b2545b2bbb72 100644 --- a/sdk/storage/azfile/internal/exported/shared_key_credential.go +++ b/sdk/storage/azfile/internal/exported/shared_key_credential.go @@ -11,7 +11,9 @@ import ( "crypto/hmac" "crypto/sha256" "encoding/base64" + "errors" "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/internal/errorinfo" "net/http" "net/url" "sort" @@ -195,6 +197,17 @@ func NewSharedKeyCredPolicy(cred *SharedKeyCredential) *SharedKeyCredPolicy { } func (s *SharedKeyCredPolicy) Do(req *policy.Request) (*http.Response, error) { + // skip adding the authorization header if no SharedKeyCredential was provided. + // this prevents a panic that might be hard to diagnose and allows testing + // against http endpoints that don't require authentication. + if s.cred == nil { + return req.Next() + } + + if err := checkHTTPSForAuth(req); err != nil { + return nil, err + } + if d := getHeader(shared.HeaderXmsDate, req.Raw().Header); d == "" { req.Raw().Header.Set(shared.HeaderXmsDate, time.Now().UTC().Format(http.TimeFormat)) } @@ -216,3 +229,10 @@ func (s *SharedKeyCredPolicy) Do(req *policy.Request) (*http.Response, error) { } return response, err } + +func checkHTTPSForAuth(req *policy.Request) error { + if strings.ToLower(req.Raw().URL.Scheme) != "https" { + return errorinfo.NonRetriableError(errors.New("authenticated requests are not permitted for non TLS protected (https) endpoints")) + } + return nil +} diff --git a/sdk/storage/azfile/service/client_test.go b/sdk/storage/azfile/service/client_test.go index 0d83e8556f30..61061fcbb121 100644 --- a/sdk/storage/azfile/service/client_test.go +++ b/sdk/storage/azfile/service/client_test.go @@ -630,6 +630,34 @@ func (s *ServiceRecordedTestsSuite) TestPremiumAccountListShares() { } } +func (s *ServiceRecordedTestsSuite) TestServiceClientRejectHTTP() { + _require := require.New(s.T()) + + cred, err := testcommon.GetGenericSharedKeyCredential(testcommon.TestAccountDefault) + _require.NoError(err) + + svcClient, err := service.NewClientWithSharedKeyCredential("http://"+cred.AccountName()+".file.core.windows.net/", cred, nil) + _require.NoError(err) + + _, err = svcClient.GetProperties(context.Background(), nil) + _require.Error(err) +} + +func (s *ServiceRecordedTestsSuite) TestServiceClientWithNilSharedKey() { + _require := require.New(s.T()) + + accountName, _ := testcommon.GetGenericAccountInfo(testcommon.TestAccountDefault) + _require.Greater(len(accountName), 0) + + options := &service.ClientOptions{} + testcommon.SetClientOptions(s.T(), &options.ClientOptions) + svcClient, err := service.NewClientWithSharedKeyCredential("https://"+accountName+".file.core.windows.net/", nil, options) + _require.NoError(err) + + _, err = svcClient.GetProperties(context.Background(), nil) + _require.Error(err) +} + func (s *ServiceRecordedTestsSuite) TestServiceClientCustomAudience() { _require := require.New(s.T()) testName := s.T().Name() From e63fa2461487e16f6b54a54191db7ac838bcd216 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Mon, 8 Jan 2024 15:40:49 -0800 Subject: [PATCH 10/32] [azeventhubs] Fixing an issue where a processor wouldn't grab partitions (#22153) The processor load balancer had a bug where a processor would not claim partitions even if it didn't yet have the proper share. Added in stress tests (balance, multibalance) to run several scenarios with our supported strategies and different parallel owners. Fixes #22097 --- sdk/messaging/azeventhubs/CHANGELOG.md | 8 +- .../inmemory_checkpoint_store_test.go | 5 + .../internal/eh/stress/scenarios-matrix.yaml | 4 + .../eh/stress/stress-test-resources.json | 24 +- .../azeventhubs/internal/eh/stress/stress.go | 2 + .../eh/stress/templates/stress-test-job.yaml | 4 + .../eh/stress/tests/balance_tester.go | 401 ++++++++++++++++++ .../eh/stress/tests/batch_stress_tester.go | 26 +- .../eh/stress/tests/multi_balance_tester.go | 85 ++++ .../stress/tests/processor_stress_tester.go | 6 +- .../internal/eh/stress/tests/shared.go | 45 +- .../azeventhubs/processor_load_balancer.go | 107 ++--- .../processor_load_balancers_test.go | 174 +++++++- .../azeventhubs/processor_unit_test.go | 6 +- 14 files changed, 801 insertions(+), 96 deletions(-) create mode 100644 sdk/messaging/azeventhubs/internal/eh/stress/tests/balance_tester.go create mode 100644 sdk/messaging/azeventhubs/internal/eh/stress/tests/multi_balance_tester.go diff --git a/sdk/messaging/azeventhubs/CHANGELOG.md b/sdk/messaging/azeventhubs/CHANGELOG.md index 901a89e01b25..cb0b0b33ed38 100644 --- a/sdk/messaging/azeventhubs/CHANGELOG.md +++ b/sdk/messaging/azeventhubs/CHANGELOG.md @@ -1,14 +1,10 @@ # Release History -## 1.0.3 (Unreleased) - -### Features Added - -### Breaking Changes +## 1.0.3 (2024-01-16) ### Bugs Fixed -### Other Changes +- Processor distributes partitions optimally, which would result in idle or over-assigned processors. (PR#22153) ## 1.0.2 (2023-11-07) diff --git a/sdk/messaging/azeventhubs/inmemory_checkpoint_store_test.go b/sdk/messaging/azeventhubs/inmemory_checkpoint_store_test.go index e0b0f50fa65c..55c3650d4869 100644 --- a/sdk/messaging/azeventhubs/inmemory_checkpoint_store_test.go +++ b/sdk/messaging/azeventhubs/inmemory_checkpoint_store_test.go @@ -4,6 +4,7 @@ package azeventhubs import ( "context" + "sort" "strings" "sync" "testing" @@ -277,6 +278,10 @@ func (cps *testCheckpointStore) ListOwnership(ctx context.Context, fullyQualifie ownerships = append(ownerships, v) } + sort.Slice(ownerships, func(i, j int) bool { + return ownerships[i].PartitionID < ownerships[j].PartitionID + }) + return ownerships, nil } diff --git a/sdk/messaging/azeventhubs/internal/eh/stress/scenarios-matrix.yaml b/sdk/messaging/azeventhubs/internal/eh/stress/scenarios-matrix.yaml index 84ea05ef7951..8d83d95134e9 100644 --- a/sdk/messaging/azeventhubs/internal/eh/stress/scenarios-matrix.yaml +++ b/sdk/messaging/azeventhubs/internal/eh/stress/scenarios-matrix.yaml @@ -61,3 +61,7 @@ matrix: prefetch: 0 verbose: "" sleepAfter: "5m" + multibalance: + testTarget: multibalance + rounds: 20 + verbose: "" diff --git a/sdk/messaging/azeventhubs/internal/eh/stress/stress-test-resources.json b/sdk/messaging/azeventhubs/internal/eh/stress/stress-test-resources.json index 8b5482ed8cad..5880de174968 100644 --- a/sdk/messaging/azeventhubs/internal/eh/stress/stress-test-resources.json +++ b/sdk/messaging/azeventhubs/internal/eh/stress/stress-test-resources.json @@ -52,9 +52,15 @@ "apiVersion": "[variables('apiVersion')]", "name": "[variables('authorizationName')]", "location": "[variables('location')]", - "dependsOn": ["[resourceId('Microsoft.EventHub/namespaces', variables('namespaceName'))]"], + "dependsOn": [ + "[resourceId('Microsoft.EventHub/namespaces', variables('namespaceName'))]" + ], "properties": { - "rights": ["Listen", "Manage", "Send"] + "rights": [ + "Listen", + "Manage", + "Send" + ] } }, { @@ -62,7 +68,9 @@ "apiVersion": "[variables('apiVersion')]", "name": "[variables('eventHubNameFull')]", "location": "[variables('location')]", - "dependsOn": ["[resourceId('Microsoft.EventHub/namespaces', variables('namespaceName'))]"], + "dependsOn": [ + "[resourceId('Microsoft.EventHub/namespaces', variables('namespaceName'))]" + ], "properties": { "messageRetentionInDays": 7, "partitionCount": 32 @@ -73,7 +81,9 @@ "apiVersion": "[variables('apiVersion')]", "name": "[concat(variables('namespaceName'), '/default')]", "location": "[variables('location')]", - "dependsOn": ["[resourceId('Microsoft.EventHub/namespaces', variables('namespaceName'))]"], + "dependsOn": [ + "[resourceId('Microsoft.EventHub/namespaces', variables('namespaceName'))]" + ], "properties": { "defaultAction": "Deny", "virtualNetworkRules": [], @@ -127,13 +137,15 @@ "name": "[concat('default/', variables('containerName'))]", "type": "blobServices/containers", "apiVersion": "[variables('storageApiVersion')]", - "dependsOn": ["[variables('storageAccountName')]"] + "dependsOn": [ + "[variables('storageAccountName')]" + ] } ] }, ], "outputs": { - "EVENTHUB_NAME": { + "EVENTHUB_NAME_STRESS": { "type": "string", "value": "[variables('eventHubName')]" }, diff --git a/sdk/messaging/azeventhubs/internal/eh/stress/stress.go b/sdk/messaging/azeventhubs/internal/eh/stress/stress.go index 81ab35a93964..54ea103925ab 100644 --- a/sdk/messaging/azeventhubs/internal/eh/stress/stress.go +++ b/sdk/messaging/azeventhubs/internal/eh/stress/stress.go @@ -17,6 +17,8 @@ func main() { fn func(ctx context.Context) error }{ {name: "batch", fn: tests.BatchStressTester}, + {name: "balance", fn: tests.BalanceTester}, + {name: "multibalance", fn: tests.MultiBalanceTester}, {name: "processor", fn: tests.ProcessorStressTester}, } diff --git a/sdk/messaging/azeventhubs/internal/eh/stress/templates/stress-test-job.yaml b/sdk/messaging/azeventhubs/internal/eh/stress/templates/stress-test-job.yaml index 4a6ff57cc6a0..305d0a512d05 100644 --- a/sdk/messaging/azeventhubs/internal/eh/stress/templates/stress-test-job.yaml +++ b/sdk/messaging/azeventhubs/internal/eh/stress/templates/stress-test-job.yaml @@ -22,7 +22,11 @@ spec: - > set -ex; mkdir -p "$DEBUG_SHARE"; + {{if eq .Stress.testTarget "multibalance" }} + /app/stress "{{.Stress.testTarget}}" "-rounds" "{{.Stress.rounds}}" "{{.Stress.verbose}}" 2>&1 | tee -a "${DEBUG_SHARE}/{{ .Stress.Scenario }}-`date +%s`.log"; + {{else}} /app/stress "{{.Stress.testTarget}}" "-rounds" "{{.Stress.rounds}}" "-prefetch" "{{.Stress.prefetch}}" "{{.Stress.verbose}}" "-sleepAfter" "{{.Stress.sleepAfter}}" 2>&1 | tee -a "${DEBUG_SHARE}/{{ .Stress.Scenario }}-`date +%s`.log"; + {{end}} # Pulls the image on pod start, always. We tend to push to the same image and tag over and over again # when iterating, so this is a must. imagePullPolicy: Always diff --git a/sdk/messaging/azeventhubs/internal/eh/stress/tests/balance_tester.go b/sdk/messaging/azeventhubs/internal/eh/stress/tests/balance_tester.go new file mode 100644 index 000000000000..0cfe64362c72 --- /dev/null +++ b/sdk/messaging/azeventhubs/internal/eh/stress/tests/balance_tester.go @@ -0,0 +1,401 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package tests + +import ( + "context" + "encoding/json" + "errors" + "flag" + "fmt" + golog "log" + "os" + "strings" + "sync" + "time" + + "github.com/Azure/azure-sdk-for-go/sdk/internal/log" + "github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs" + "github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs/checkpoints" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob" + "github.com/Azure/azure-sdk-for-go/sdk/storage/azblob/bloberror" +) + +const ( + EventBalanceTest log.Event = "balance.test" +) + +// BalanceTester checks that we can properly distribute partitions and +// maintain it over time. +func BalanceTester(ctx context.Context) error { + fs := flag.NewFlagSet("", flag.ContinueOnError) + + numProcessors := fs.Int("processors", 32, "The # of processor instances to run") + strategy := fs.String("strategy", string(azeventhubs.ProcessorStrategyBalanced), "The partition acquisition strategy to use (balanced, greedy)") + + if err := fs.Parse(os.Args[2:]); err != nil { + return err + } + + log.SetEvents(EventBalanceTest, azeventhubs.EventConsumer) + log.SetListener(func(e log.Event, s string) { + // we don't have structured logging in our SDK so this is the most reasonable way to + // see what partitions each processor + if e == azeventhubs.EventConsumer && + !strings.Contains(s, "Asked for") { + return + } + + golog.Printf("[%s] %s", e, s) + }) + + return balanceTesterImpl(ctx, *numProcessors, azeventhubs.ProcessorStrategy(*strategy)) +} + +func balanceTesterImpl(ctx context.Context, numProcessors int, strategy azeventhubs.ProcessorStrategy) error { + testData, err := newStressTestData("balancetester", map[string]string{ + "processors": fmt.Sprintf("%d", numProcessors), + "strategy": string(strategy), + }) + + if err != nil { + return err + } + + args := balanceTester{ + stressTestData: testData, + numProcessors: numProcessors, + strategy: strategy, + } + + args.numPartitions, err = func(ctx context.Context) (int, error) { + client, err := azeventhubs.NewProducerClientFromConnectionString(args.ConnectionString, args.HubName, nil) + + if err != nil { + return 0, err + } + + defer func() { + _ = client.Close(ctx) + }() + + props, err := client.GetEventHubProperties(ctx, nil) + + if err != nil { + return 0, err + } + + return len(props.PartitionIDs), nil + }(ctx) + + if err != nil { + return err + } + + return args.Run(ctx) +} + +type balanceTester struct { + *stressTestData + + strategy azeventhubs.ProcessorStrategy + numProcessors int + numPartitions int +} + +func (bt *balanceTester) Run(ctx context.Context) error { + defer bt.cleanupContainer() + + wg := sync.WaitGroup{} + failuresChan := make(chan error, bt.numProcessors) + + testCtx, cancelTest := context.WithTimeout(context.Background(), 10*time.Minute) + defer cancelTest() + + mu := sync.Mutex{} + var lastBalanceError error + startTime := time.Now() + + go func() { + balancedCount := 0 + var firstBalance time.Duration + + Loop: + // poll every 5 seconds to see if the checkpoint store is "balanced" (all owners + // own a fair-share of the partitions). + for { + select { + case <-ctx.Done(): + break Loop + case <-time.After(5 * time.Second): + err := bt.checkBalance(ctx) + + if ibErr := (unbalancedError)(nil); errors.As(err, &ibErr) { + mu.Lock() + lastBalanceError = err + mu.Unlock() + + log.Writef(EventBalanceTest, "Balance not achieved, resetting balancedCount: %s", ibErr) + balancedCount = 0 + + bt.TC.TrackEvent("Unbalanced", map[string]string{ + "Message": ibErr.Error(), + }) + continue + } else if err != nil { + mu.Lock() + lastBalanceError = err + mu.Unlock() + + bt.TC.TrackException(err) + break Loop + } + + if balancedCount == 0 { + firstBalance = time.Since(startTime) + } + + balancedCount++ + log.Writef(EventBalanceTest, "Balanced, with %d consecutive checks", balancedCount) + + bt.TC.TrackEvent("Balanced", map[string]string{ + "Count": fmt.Sprintf("%d", balancedCount), + "DurationSeconds": fmt.Sprintf("%d", firstBalance/time.Second), + }) + + if balancedCount == 3 { + log.Writef(EventBalanceTest, "Balanced at %d seconds (approx)", firstBalance/time.Second) + + mu.Lock() + lastBalanceError = nil + mu.Unlock() + + cancelTest() + break Loop + } + } + } + }() + + for i := 0; i < bt.numProcessors; i++ { + wg.Add(1) + + go func(i int) { + defer wg.Done() + + if err := bt.process(testCtx, fmt.Sprintf("proc%02d", i)); err != nil { + failuresChan <- err + cancelTest() + return + } + }(i) + } + + wg.Wait() + close(failuresChan) + cancelTest() + + // any errors? + for err := range failuresChan { + bt.TC.TrackException(err) + fmt.Printf("ERROR: %s\n", err) + return err + } + + mu.Lock() + err := lastBalanceError + mu.Unlock() + + if err != nil { + bt.TC.TrackException(err) + return err + } + + log.Writef(EventBalanceTest, "BALANCED") + return nil +} + +func (bt *balanceTester) process(ctx context.Context, name string) error { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + client, err := azeventhubs.NewConsumerClientFromConnectionString(bt.ConnectionString, bt.HubName, azeventhubs.DefaultConsumerGroup, nil) + + if err != nil { + return err + } + + defer func() { _ = client.Close(ctx) }() + + blobClient, err := azblob.NewClientFromConnectionString(bt.StorageConnectionString, nil) + + if err != nil { + return err + } + + containerClient := blobClient.ServiceClient().NewContainerClient(bt.runID) + + if _, err := containerClient.Create(ctx, nil); err != nil { + if !bloberror.HasCode(err, bloberror.ContainerAlreadyExists) { + return err + } + } + + blobStore, err := checkpoints.NewBlobStore(containerClient, nil) + + if err != nil { + return err + } + + processor, err := azeventhubs.NewProcessor(client, blobStore, &azeventhubs.ProcessorOptions{ + LoadBalancingStrategy: bt.strategy, + }) + + if err != nil { + return err + } + + ch := make(chan struct{}) + go func() { + defer close(ch) + for { + pc := processor.NextPartitionClient(ctx) + + if pc == nil { + break + } + + go bt.keepAlive(ctx, pc) + } + }() + + err = processor.Run(ctx) + cancel() + <-ch + + return err +} + +func (bt *balanceTester) keepAlive(ctx context.Context, pc *azeventhubs.ProcessorPartitionClient) { + defer func() { + _ = pc.Close(context.Background()) + }() + + for { + if _, err := pc.ReceiveEvents(ctx, 1, nil); err != nil { + break + } + } +} + +type unbalancedError error + +// checkBalance queries the checkpoint store. +// It returns `nil` if no error occurred and the checkpoint store was balanced. +// If the checkpoint store is NOT balanced it returns an unbalancedError +func (bt *balanceTester) checkBalance(ctx context.Context) error { + blobClient, err := azblob.NewClientFromConnectionString(bt.StorageConnectionString, nil) + + if err != nil { + return err + } + + blobStore, err := checkpoints.NewBlobStore( + blobClient.ServiceClient().NewContainerClient(bt.runID), + nil) + + if err != nil { + return err + } + + ownerships, err := blobStore.ListOwnership(ctx, bt.Namespace, bt.HubName, azeventhubs.DefaultConsumerGroup, nil) + + if err != nil { + return err + } + + stats := bt.summarizeBalance(ownerships) + + if !stats.Balanced { + return unbalancedError(fmt.Errorf("unbalanced: %s", stats.String())) + } + + return nil +} + +func (bt *balanceTester) cleanupContainer() { + blobClient, err := azblob.NewClientFromConnectionString(bt.StorageConnectionString, nil) + + if err != nil { + return + } + + containerClient := blobClient.ServiceClient().NewContainerClient(bt.runID) + + _, _ = containerClient.Delete(context.Background(), nil) +} + +func (bt *balanceTester) summarizeBalance(ownerships []azeventhubs.Ownership) stats { + counts := map[string]int{} + + for _, o := range ownerships { + counts[o.OwnerID]++ + } + + // now let's make sure everyone only took a fair share + min := bt.numPartitions / bt.numProcessors + max := min + + if bt.numPartitions%bt.numProcessors != 0 { + max += 1 + } + + tooFew := 0 + tooMany := 0 + + for _, owned := range counts { + if owned < min { + tooFew++ + } else if owned > max { + tooMany++ + } + } + + sum := 0 + + for _, v := range counts { + sum += v + } + + return stats{ + Processors: fmt.Sprintf("%d/%d", len(counts), bt.numProcessors), + Partitions: fmt.Sprintf("%d/%d", sum, bt.numPartitions), + OwnTooFew: tooFew, + OwnTooMany: tooMany, + Balanced: len(counts) == bt.numProcessors && + sum == bt.numPartitions && + tooFew == 0 && + tooMany == 0, + Raw: counts, + } +} + +type stats struct { + Processors string + Partitions string + OwnTooFew int + OwnTooMany int + Balanced bool + Raw map[string]int +} + +func (s *stats) String() string { + jsonBytes, err := json.Marshal(s) + + if err != nil { + panic(err) + } + + return string(jsonBytes) +} diff --git a/sdk/messaging/azeventhubs/internal/eh/stress/tests/batch_stress_tester.go b/sdk/messaging/azeventhubs/internal/eh/stress/tests/batch_stress_tester.go index 3b23c3a9815f..8b974a05bb9d 100644 --- a/sdk/messaging/azeventhubs/internal/eh/stress/tests/batch_stress_tester.go +++ b/sdk/messaging/azeventhubs/internal/eh/stress/tests/batch_stress_tester.go @@ -47,7 +47,8 @@ func getBatchTesterParams(args []string) (batchTesterParams, error) { fs.IntVar(¶ms.paddingBytes, "padding", 1024, "Extra number of bytes to add into each message body") fs.StringVar(¶ms.partitionID, "partition", "0", "Partition ID to send and receive events to") fs.IntVar(¶ms.maxDeadlineExceeded, "maxtimeouts", 10, "Number of consecutive receive timeouts allowed before quitting") - fs.BoolVar(¶ms.enableVerboseLogging, "verbose", false, "enable verbose azure sdk logging") + enableVerboseLoggingFn := addVerboseLoggingFlag(fs, nil) + sleepAfterFn := addSleepAfterFlag(fs) if err := fs.Parse(os.Args[2:]); err != nil { @@ -55,6 +56,7 @@ func getBatchTesterParams(args []string) (batchTesterParams, error) { return batchTesterParams{}, err } + enableVerboseLoggingFn() params.prefetch = int32(*prefetch) if params.rounds == -1 { @@ -85,7 +87,7 @@ func BatchStressTester(ctx context.Context) error { defer params.sleepAfterFn() - testData, err := newStressTestData("batch", params.enableVerboseLogging, map[string]string{ + testData, err := newStressTestData("batch", map[string]string{ "BatchDuration": params.batchDuration.String(), "BatchSize": fmt.Sprintf("%d", params.batchSize), "NumToSend": fmt.Sprintf("%d", params.numToSend), @@ -93,7 +95,6 @@ func BatchStressTester(ctx context.Context) error { "PartitionId": params.partitionID, "Prefetch": fmt.Sprintf("%d", params.prefetch), "Rounds": fmt.Sprintf("%d", params.rounds), - "Verbose": fmt.Sprintf("%t", params.enableVerboseLogging), "MaxDeadlineExceeded": fmt.Sprintf("%d", params.maxDeadlineExceeded), }) @@ -155,16 +156,15 @@ func BatchStressTester(ctx context.Context) error { } type batchTesterParams struct { - numToSend int - paddingBytes int - partitionID string - batchSize int - batchDuration time.Duration - rounds int64 - prefetch int32 - maxDeadlineExceeded int - enableVerboseLogging bool - sleepAfterFn func() + numToSend int + paddingBytes int + partitionID string + batchSize int + batchDuration time.Duration + rounds int64 + prefetch int32 + maxDeadlineExceeded int + sleepAfterFn func() } func consumeForBatchTester(ctx context.Context, round int64, cc *azeventhubs.ConsumerClient, sp azeventhubs.StartPosition, params batchTesterParams, testData *stressTestData) error { diff --git a/sdk/messaging/azeventhubs/internal/eh/stress/tests/multi_balance_tester.go b/sdk/messaging/azeventhubs/internal/eh/stress/tests/multi_balance_tester.go new file mode 100644 index 000000000000..d2fd99f5c316 --- /dev/null +++ b/sdk/messaging/azeventhubs/internal/eh/stress/tests/multi_balance_tester.go @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package tests + +import ( + "context" + "flag" + "fmt" + golog "log" + "os" + "strings" + + "github.com/Azure/azure-sdk-for-go/sdk/internal/log" + "github.com/Azure/azure-sdk-for-go/sdk/messaging/azeventhubs" +) + +// MultiBalanceTester runs the BalanceTest multiple times against different +// combinations of partition acquisition strategy and number of processors. +// +// NOTE: this test assumes that the Event Hub you're using has 32 partitions. +func MultiBalanceTester(ctx context.Context) error { + fs := flag.NewFlagSet("", flag.ContinueOnError) + + rounds := fs.Int("rounds", 1, "Number of rounds to run") + + if err := fs.Parse(os.Args[2:]); err != nil { + return err + } + + ch := make(chan string, 10000) + + log.SetEvents(EventBalanceTest, azeventhubs.EventConsumer) + log.SetListener(func(e log.Event, s string) { + if e == azeventhubs.EventConsumer && + !strings.Contains(s, "Asked for") { + return + } + + ch <- fmt.Sprintf("[%s] %s", e, s) + }) + + go func() { + for { + select { + case s := <-ch: + golog.Println(s) + case <-ctx.Done(): + break + } + } + }() + + for i := 0; i < *rounds; i++ { + testData := []struct { + Processors int + Strategy azeventhubs.ProcessorStrategy + }{ + {32, azeventhubs.ProcessorStrategyGreedy}, + {31, azeventhubs.ProcessorStrategyGreedy}, + {16, azeventhubs.ProcessorStrategyGreedy}, + {5, azeventhubs.ProcessorStrategyGreedy}, + {1, azeventhubs.ProcessorStrategyGreedy}, + + {32, azeventhubs.ProcessorStrategyBalanced}, + {31, azeventhubs.ProcessorStrategyBalanced}, + {16, azeventhubs.ProcessorStrategyBalanced}, + {5, azeventhubs.ProcessorStrategyBalanced}, + {1, azeventhubs.ProcessorStrategyBalanced}, + } + + for _, td := range testData { + log.Writef(EventBalanceTest, "----- BEGIN[%d]: %s, %d processors -----", i, td.Strategy, td.Processors) + + if err := balanceTesterImpl(ctx, td.Processors, td.Strategy); err != nil { + log.Writef(EventBalanceTest, "----- END[%d]: FAIL: %s, %d processors, %s -----", i, td.Strategy, td.Processors, err) + return err + } + + log.Writef(EventBalanceTest, "----- END[%d]: %s, %d processors -----", i, td.Strategy, td.Processors) + } + } + + return nil +} diff --git a/sdk/messaging/azeventhubs/internal/eh/stress/tests/processor_stress_tester.go b/sdk/messaging/azeventhubs/internal/eh/stress/tests/processor_stress_tester.go index 9e9a48032059..13485da36fb7 100644 --- a/sdk/messaging/azeventhubs/internal/eh/stress/tests/processor_stress_tester.go +++ b/sdk/messaging/azeventhubs/internal/eh/stress/tests/processor_stress_tester.go @@ -53,7 +53,7 @@ func newProcessorStressTest(args []string) (*processorStressTest, error) { eventsPerRound := fs.Int("send", 5000, "Number of events to send per round") rounds := fs.Int64("rounds", 100, "Number of rounds. -1 means math.MaxInt64") prefetch := fs.Int("prefetch", 0, "Number of events to set for the prefetch. Negative numbers disable prefetch altogether. 0 uses the default for the package.") - enableVerboseLogging := fs.Bool("verbose", false, "enable verbose azure sdk logging") + enableVerboseLoggingFn := addVerboseLoggingFlag(fs, nil) sleepAfterFn := addSleepAfterFlag(fs) if err := fs.Parse(args); err != nil { @@ -61,11 +61,13 @@ func newProcessorStressTest(args []string) (*processorStressTest, error) { return nil, err } + enableVerboseLoggingFn() + if *rounds == -1 { *rounds = math.MaxInt64 } - testData, err := newStressTestData("infiniteprocessor", *enableVerboseLogging, map[string]string{ + testData, err := newStressTestData("infiniteprocessor", map[string]string{ "Processors": fmt.Sprintf("%d", numProcessors), "EventsPerRound": fmt.Sprintf("%d", eventsPerRound), "Rounds": fmt.Sprintf("%d", rounds), diff --git a/sdk/messaging/azeventhubs/internal/eh/stress/tests/shared.go b/sdk/messaging/azeventhubs/internal/eh/stress/tests/shared.go index 5e5e210c9245..b5ee828ec37d 100644 --- a/sdk/messaging/azeventhubs/internal/eh/stress/tests/shared.go +++ b/sdk/messaging/azeventhubs/internal/eh/stress/tests/shared.go @@ -60,7 +60,7 @@ func (td *stressTestData) Close() { type logf func(format string, v ...any) -func newStressTestData(name string, verbose bool, baggage map[string]string) (*stressTestData, error) { +func newStressTestData(name string, baggage map[string]string) (*stressTestData, error) { td := &stressTestData{ name: name, runID: fmt.Sprintf("%s-%d", name, time.Now().UnixNano()), @@ -80,7 +80,7 @@ func newStressTestData(name string, verbose bool, baggage map[string]string) (*s variables := map[string]*string{ "EVENTHUB_CONNECTION_STRING": &td.ConnectionString, - "EVENTHUB_NAME": &td.HubName, + "EVENTHUB_NAME_STRESS": &td.HubName, "CHECKPOINTSTORE_STORAGE_CONNECTION_STRING": &td.StorageConnectionString, } @@ -98,10 +98,6 @@ func newStressTestData(name string, verbose bool, baggage map[string]string) (*s return nil, fmt.Errorf("missing environment variables (%s)", strings.Join(missing, ",")) } - if verbose { - enableVerboseLogging() - } - tc, err := loadAppInsights() if err != nil { @@ -377,13 +373,6 @@ func closeOrPanic(closeable interface { } } -func enableVerboseLogging() { - //azlog.SetEvents(azeventhubs.EventAuth, azeventhubs.EventConn, azeventhubs.EventConsumer) - azlog.SetListener(func(e azlog.Event, s string) { - log.Printf("[%s] %s", e, s) - }) -} - func addSleepAfterFlag(fs *flag.FlagSet) func() { var durationStr string fs.StringVar(&durationStr, "sleepAfter", "0m", "Time to sleep after test completes") @@ -403,3 +392,33 @@ func addSleepAfterFlag(fs *flag.FlagSet) func() { } } } + +func addVerboseLoggingFlag(fs *flag.FlagSet, customLogFn func(verbose string, e azlog.Event, s string)) func() { + verbose := fs.String("v", "", "Enable verbose SDK logging. Valid values are test or sdk or all") + + logFn := func(e azlog.Event, s string) { + log.Printf("[%s] %s", e, s) + } + + if customLogFn != nil { + logFn = func(e azlog.Event, s string) { + customLogFn(*verbose, e, s) + } + } + + return func() { + switch *verbose { + case "": + case "test": + azlog.SetEvents(EventBalanceTest) + azlog.SetListener(logFn) + case "sdk": + azlog.SetEvents(EventBalanceTest, azeventhubs.EventConsumer, azeventhubs.EventProducer) + azlog.SetListener(logFn) + case "all": + azlog.SetListener(logFn) + default: + fmt.Printf("%s is not a valid logging value. Valid values are test or sdk or all", *verbose) + } + } +} diff --git a/sdk/messaging/azeventhubs/processor_load_balancer.go b/sdk/messaging/azeventhubs/processor_load_balancer.go index 7ab002a421f5..62ec59a88e49 100644 --- a/sdk/messaging/azeventhubs/processor_load_balancer.go +++ b/sdk/messaging/azeventhubs/processor_load_balancer.go @@ -46,16 +46,17 @@ type loadBalancerInfo struct { // it contains _all_ the partitions for that particular consumer. aboveMax []Ownership - // maxAllowed is the maximum number of partitions a consumer should have - // If partitions do not divide evenly this will be the "theoretical" max - // with the assumption that this particular consumer will get an extra - // partition. + // claimMorePartitions is true when we should try to claim more partitions + // because we're under the limit, or we're in a situation where we could claim + // one extra partition. + claimMorePartitions bool + + // maxAllowed is the maximum number of partitions that other processors are allowed + // to own during this round. It can change based on how many partitions we own and whether + // an 'extra' partition is allowed (ie, partitions %owners is not 0). Look at + // [processorLoadBalancer.getAvailablePartitions] for more details. maxAllowed int - // extraPartitionPossible is true if the partitions cannot split up evenly - // amongst all the known consumers. - extraPartitionPossible bool - raw []Ownership } @@ -68,45 +69,22 @@ func (lb *processorLoadBalancer) LoadBalance(ctx context.Context, partitionIDs [ return nil, err } - claimMorePartitions := true - - if len(lbinfo.current) >= lbinfo.maxAllowed { - // - I have _exactly_ the right amount - // or - // - I have too many. We expect to have some stolen from us, but we'll maintain - // ownership for now. - claimMorePartitions = false - log.Writef(EventConsumer, "Owns %d/%d, no more needed", len(lbinfo.current), lbinfo.maxAllowed) - } else if lbinfo.extraPartitionPossible && len(lbinfo.current) == lbinfo.maxAllowed-1 { - // In the 'extraPartitionPossible' scenario, some consumers will have an extra partition - // since things don't divide up evenly. We're one under the max, which means we _might_ - // be able to claim another one. - // - // We will attempt to grab _one_ more but only if there are free partitions available - // or if one of the consumers has more than the max allowed. - claimMorePartitions = len(lbinfo.unownedOrExpired) > 0 || len(lbinfo.aboveMax) > 0 - log.Writef(EventConsumer, "Unowned/expired: %d, above max: %d, need to claim: %t", - len(lbinfo.unownedOrExpired), - len(lbinfo.aboveMax), - claimMorePartitions) - } - ownerships := lbinfo.current - if claimMorePartitions { + if lbinfo.claimMorePartitions { switch lb.strategy { case ProcessorStrategyGreedy: - log.Writef(EventConsumer, "Using greedy strategy to claim partitions") + log.Writef(EventConsumer, "[%s] Using greedy strategy to claim partitions", lb.details.ClientID) ownerships = lb.greedyLoadBalancer(ctx, lbinfo) case ProcessorStrategyBalanced: - log.Writef(EventConsumer, "Using balanced strategy to claim partitions") + log.Writef(EventConsumer, "[%s] Using balanced strategy to claim partitions", lb.details.ClientID) o := lb.balancedLoadBalancer(ctx, lbinfo) if o != nil { ownerships = append(lbinfo.current, *o) } default: - return nil, fmt.Errorf("invalid load balancing strategy '%s'", lb.strategy) + return nil, fmt.Errorf("[%s] invalid load balancing strategy '%s'", lb.details.ClientID, lb.strategy) } } @@ -133,8 +111,11 @@ func partitionsForOwnerships(all []Ownership) string { return strings.Join(parts, ",") } -// getAvailablePartitions finds all partitions that are either completely unowned _or_ -// their ownership is stale. +// getAvailablePartitions looks through the ownership list (using the checkpointstore.ListOwnership) and evaluates: +// - Whether we should claim more partitions +// - Which partitions are available - unowned/relinquished, expired or processors that own more than the maximum allowed. +// +// Load balancing happens in individual functions func (lb *processorLoadBalancer) getAvailablePartitions(ctx context.Context, partitionIDs []string) (loadBalancerInfo, error) { log.Writef(EventConsumer, "[%s] Listing ownership for %s/%s/%s", lb.details.ClientID, lb.details.FullyQualifiedNamespace, lb.details.EventHubName, lb.details.ConsumerGroup) @@ -170,7 +151,6 @@ func (lb *processorLoadBalancer) getAvailablePartitions(ctx context.Context, par } numExpired := len(unownedOrExpired) - log.Writef(EventConsumer, "Expired: %d", numExpired) // add in all the unowned partitions for _, partID := range partitionIDs { @@ -189,12 +169,13 @@ func (lb *processorLoadBalancer) getAvailablePartitions(ctx context.Context, par }) } - log.Writef(EventConsumer, "Unowned: %d", len(unownedOrExpired)-numExpired) + minRequired := len(partitionIDs) / len(groupedByOwner) + maxAllowed := minRequired + allowExtraPartition := len(partitionIDs)%len(groupedByOwner) > 0 - maxAllowed := len(partitionIDs) / len(groupedByOwner) - hasRemainder := len(partitionIDs)%len(groupedByOwner) > 0 - - if hasRemainder { + // only allow owners to keep extra partitions if we've already met our minimum bar. Otherwise + // above the minimum is fair game. + if allowExtraPartition && len(groupedByOwner[lb.details.ClientID]) >= minRequired { maxAllowed += 1 } @@ -210,13 +191,41 @@ func (lb *processorLoadBalancer) getAvailablePartitions(ctx context.Context, par } } + claimMorePartitions := true + current := groupedByOwner[lb.details.ClientID] + + if len(current) >= maxAllowed { + // - I have _exactly_ the right amount + // or + // - I have too many. We expect to have some stolen from us, but we'll maintain + // ownership for now. + claimMorePartitions = false + } else if allowExtraPartition && len(current) == maxAllowed-1 { + // In the 'allowExtraPartition' scenario, some consumers will have an extra partition + // since things don't divide up evenly. We're one under the max, which means we _might_ + // be able to claim another one. + // + // We will attempt to grab _one_ more but only if there are free partitions available + // or if one of the consumers has more than the max allowed. + claimMorePartitions = len(unownedOrExpired) > 0 || len(aboveMax) > 0 + } + + log.Writef(EventConsumer, "[%s] claimMorePartitions: %t, owners: %d, current: %d, unowned: %d, expired: %d, above: %d", + lb.details.ClientID, + claimMorePartitions, + len(groupedByOwner), + len(current), + len(unownedOrExpired)-numExpired, + numExpired, + len(aboveMax)) + return loadBalancerInfo{ - current: groupedByOwner[lb.details.ClientID], - unownedOrExpired: unownedOrExpired, - aboveMax: aboveMax, - maxAllowed: maxAllowed, - extraPartitionPossible: hasRemainder, - raw: ownerships, + current: current, + unownedOrExpired: unownedOrExpired, + aboveMax: aboveMax, + claimMorePartitions: claimMorePartitions, + raw: ownerships, + maxAllowed: maxAllowed, }, nil } diff --git a/sdk/messaging/azeventhubs/processor_load_balancers_test.go b/sdk/messaging/azeventhubs/processor_load_balancers_test.go index 40df95fc14d4..c6c3611797b0 100644 --- a/sdk/messaging/azeventhubs/processor_load_balancers_test.go +++ b/sdk/messaging/azeventhubs/processor_load_balancers_test.go @@ -4,7 +4,10 @@ package azeventhubs import ( "context" + "fmt" + "math/rand" "sort" + "strconv" "testing" "time" @@ -283,15 +286,15 @@ func TestProcessorLoadBalancers_AnyStrategy_StealsToBalance(t *testing.T) { func TestProcessorLoadBalancers_InvalidStrategy(t *testing.T) { cps := newCheckpointStoreForTest() - lb := newProcessorLoadBalancer(cps, newTestConsumerDetails("does not matter"), "", time.Hour) + lb := newProcessorLoadBalancer(cps, newTestConsumerDetails("clientid"), "", time.Hour) ownerships, err := lb.LoadBalance(context.Background(), []string{"0"}) require.Nil(t, ownerships) - require.EqualError(t, err, "invalid load balancing strategy ''") + require.EqualError(t, err, "[clientid] invalid load balancing strategy ''") - lb = newProcessorLoadBalancer(cps, newTestConsumerDetails("does not matter"), "super-greedy", time.Hour) + lb = newProcessorLoadBalancer(cps, newTestConsumerDetails("clientid"), "super-greedy", time.Hour) ownerships, err = lb.LoadBalance(context.Background(), []string{"0"}) require.Nil(t, ownerships) - require.EqualError(t, err, "invalid load balancing strategy 'super-greedy'") + require.EqualError(t, err, "[clientid] invalid load balancing strategy 'super-greedy'") } func TestProcessorLoadBalancers_AnyStrategy_GrabRelinquishedPartition(t *testing.T) { @@ -328,6 +331,86 @@ func TestProcessorLoadBalancers_AnyStrategy_GrabRelinquishedPartition(t *testing } } +func TestUnit_ProcessorLoadBalancer_Balanced(t *testing.T) { + for _, td := range []string{"abc", "abbc", "abbcc"} { + for _, ownerID := range []string{"a", "b", "c"} { + t.Run(fmt.Sprintf("Layout %q, with owner %q", td, ownerID), func(t *testing.T) { + lb, parts := createLoadBalancerForTest(t, td, ownerID) + lbi, err := lb.getAvailablePartitions(context.Background(), parts) + require.NoError(t, err) + require.False(t, lbi.claimMorePartitions) + require.Empty(t, lbi.aboveMax) + }) + } + } + + t.Run("balanced with unequal ownership", func(t *testing.T) { + lb, parts := createLoadBalancerForTest(t, "aaaabbb", "a") + lbi, err := lb.getAvailablePartitions(context.Background(), parts) + require.NoError(t, err) + require.False(t, lbi.claimMorePartitions) + require.Equal(t, 4, lbi.maxAllowed) + require.Empty(t, lbi.aboveMax) + + lb, parts = createLoadBalancerForTest(t, "aaaabbb", "b") + lbi, err = lb.getAvailablePartitions(context.Background(), parts) + require.NoError(t, err) + require.False(t, lbi.claimMorePartitions) + require.Equal(t, 4, lbi.maxAllowed) + require.Empty(t, lbi.aboveMax) + }) +} + +func TestUnit_ProcessorLoadBalancer_Unbalanced(t *testing.T) { + t.Run("new owner enters the field", func(t *testing.T) { + lb, parts := createLoadBalancerForTest(t, "abb", "c") + lbi, err := lb.getAvailablePartitions(context.Background(), parts) + require.NoError(t, err) + require.True(t, lbi.claimMorePartitions) + require.Equal(t, 1, lbi.maxAllowed) + require.Equal(t, ".c.", greedyLoadBalance(lb, lbi, parts)) + }) + + t.Run("deficit, single partition", func(t *testing.T) { + // existing owner, needs to steal a partition + lb, parts := createLoadBalancerForTest(t, "aaaabb", "b") + lbi, err := lb.getAvailablePartitions(context.Background(), parts) + require.NoError(t, err) + require.True(t, lbi.claimMorePartitions) + require.Equal(t, 3, lbi.maxAllowed) + require.Equal(t, "b...bb", greedyLoadBalance(lb, lbi, parts)) + }) + + t.Run("deficit, multiple partitions", func(t *testing.T) { + lb, parts := createLoadBalancerForTest(t, "aaabbbcccd", "d") + lbi, err := lb.getAvailablePartitions(context.Background(), parts) + require.NoError(t, err) + require.True(t, lbi.claimMorePartitions) + require.Equal(t, 2, lbi.maxAllowed) + require.Equal(t, "d........d", greedyLoadBalance(lb, lbi, parts)) + }) + + t.Run("deficit, multiple owners", func(t *testing.T) { + lb, parts := createLoadBalancerForTest(t, "aaabbbccde", "d") + lbi, err := lb.getAvailablePartitions(context.Background(), parts) + require.NoError(t, err) + require.True(t, lbi.claimMorePartitions) + require.Equal(t, 2, lbi.maxAllowed) + require.Equal(t, "d.......d.", greedyLoadBalance(lb, lbi, parts)) + }) + + t.Run("can grab an extra partition", func(t *testing.T) { + // this tests when we have met our minimum but another processor actually owns + // more than it should (even accounting for the extra partition). + lb, parts := createLoadBalancerForTest(t, "aaaabbc", "b") + lbi, err := lb.getAvailablePartitions(context.Background(), parts) + require.NoError(t, err) + require.True(t, lbi.claimMorePartitions) + require.Equal(t, 3, lbi.maxAllowed) + require.Equal(t, "b...bb.", greedyLoadBalance(lb, lbi, parts)) + }) +} + func mapToStrings[T any](src []T, fn func(t T) string) []string { var dest []string @@ -418,3 +501,86 @@ func groupBy[T any](src []T, fn func(t T) string) map[string][]T { return dest } + +// ownershipsAsString converts the list of owners into a string where each character represents a partition +// with the owner or a '.' if nobody owns a partition. +// +// Examples: +// - '..' => two partitions, both unowned. +// - 'a.' => first partition is owned by 'a', second partition is unowned. +// - 'ab' => first partition is owned by 'a', second partition owned by 'b' +func ownershipsAsString(owners []Ownership, total int) string { + bits := make([]rune, total) + + for i := 0; i < len(bits); i++ { + bits[i] = '.' + } + + for _, o := range owners { + idx, err := strconv.ParseInt(o.PartitionID, 10, 32) + + if err != nil { + panic(err) + } + + bits[int(idx)] = ([]rune(o.OwnerID))[0] + } + + return string(bits) +} + +// createLoadBalancerForTest creates a load balancer from initialState, seeding it with a consistent random +// seed so it's safe for unit tests. +// +// initialState - each index in the string represents the owner for that index, which are 1:1 with partition IDs. +// Example: ab" => a owns partition 0, b owns partition 1 +// clientID - the client ID for this load balancer. Changing this lets you test from each owners "perspective". +func createLoadBalancerForTest(t *testing.T, initialState string, clientID string) (*processorLoadBalancer, []string) { + var ownerships []Ownership + var partitions []string + + details := consumerClientDetails{ + FullyQualifiedNamespace: "fakens.servicebus.windows.net", + ConsumerGroup: DefaultConsumerGroup, + EventHubName: "eventhub", + ClientID: clientID, + } + + for partNum, rn := range initialState { + partID := fmt.Sprintf("%d", partNum) + partitions = append(partitions, partID) + + ownerships = append(ownerships, Ownership{ + FullyQualifiedNamespace: details.FullyQualifiedNamespace, + ConsumerGroup: details.ConsumerGroup, + EventHubName: details.EventHubName, + PartitionID: partID, + OwnerID: string(rn), + }) + } + + cps := newCheckpointStoreForTest() + + claimed, err := cps.ClaimOwnership(context.Background(), ownerships, nil) + require.NoError(t, err) + require.Equal(t, len(partitions), len(claimed), "All partitions are owned") + + lb := newProcessorLoadBalancer(cps, details, + ProcessorStrategyBalanced, // we're not claiming for this test so this is ignored. + time.Hour) // no partitions should be considered expired. + + lb.rnd = rand.New(rand.NewSource(1)) + + return lb, partitions +} + +// greedyLoadBalance runs the greedy load balancer algorithm so it's results are deterministic. +func greedyLoadBalance(lb *processorLoadBalancer, lbi loadBalancerInfo, partitionIDs []string) string { + // make the results deterministic by using the same seed for RNG (taken care of in [createLoadBalancerForTest]) + // and ensuring a consistent ordering of this slice since the greedyLoadBalancer generates permutations from it. + sort.Slice(lbi.aboveMax, func(i, j int) bool { + return lbi.aboveMax[i].PartitionID < lbi.aboveMax[j].PartitionID + }) + + return ownershipsAsString(lb.greedyLoadBalancer(context.Background(), lbi), len(partitionIDs)) +} diff --git a/sdk/messaging/azeventhubs/processor_unit_test.go b/sdk/messaging/azeventhubs/processor_unit_test.go index 950ec342d18e..8f47799a0fcc 100644 --- a/sdk/messaging/azeventhubs/processor_unit_test.go +++ b/sdk/messaging/azeventhubs/processor_unit_test.go @@ -38,7 +38,7 @@ func TestUnit_Processor_loadBalancing(t *testing.T) { // which means that we get to claim them all require.Empty(t, lbinfo.aboveMax) require.Empty(t, lbinfo.current) - require.False(t, lbinfo.extraPartitionPossible) + require.True(t, lbinfo.claimMorePartitions) require.Equal(t, 3, lbinfo.maxAllowed, "only 1 possible owner (us), so we're allowed all the available partitions") expectedOwnerships := []Ownership{ @@ -89,8 +89,8 @@ func TestUnit_Processor_loadBalancing(t *testing.T) { require.NoError(t, err) require.Empty(t, lbinfo.aboveMax) require.Empty(t, lbinfo.current) - require.True(t, lbinfo.extraPartitionPossible, "divvying 3 partitions amongst 2 processors") - require.Equal(t, 2, lbinfo.maxAllowed, "now we're divvying up 3 partitions between 2 processors. At _most_ you can have min+1") + require.True(t, lbinfo.claimMorePartitions) + require.Equal(t, 1, lbinfo.maxAllowed, "the max is now 1 (instead of 2) because _our_ processor doesn't own enough") // there are two available partition ownerships - we should be getting one of them. newProcessorOwnerships, err := secondProcessor.lb.LoadBalance(context.Background(), allPartitionIDs) From 9f9219c60c9f513dec26ce03bdb6a765f1385217 Mon Sep 17 00:00:00 2001 From: Joel Hendrix Date: Mon, 8 Jan 2024 16:18:55 -0800 Subject: [PATCH 11/32] Clean up ETags in azappconfig (#22212) Use azcore.ETag instead of string for public surface area. Add doc comments for non-standard ETag option names. --- sdk/data/azappconfig/client.go | 36 +++++++++++++++------------------ sdk/data/azappconfig/options.go | 30 +++++++++++++++++---------- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/sdk/data/azappconfig/client.go b/sdk/data/azappconfig/client.go index 15b2c324ce4d..fe6ccc9f982c 100644 --- a/sdk/data/azappconfig/client.go +++ b/sdk/data/azappconfig/client.go @@ -300,8 +300,6 @@ func (c *Client) NewListSnapshotsPager(options *ListSnapshotsOptions) *runtime.P for i := range page.Items { snapshot := page.Items[i] - convertedETag := azcore.ETag(*snapshot.Etag) - convertedFilters := make([]SettingFilter, len(snapshot.Filters)) for j := range snapshot.Filters { convertedFilters[j] = SettingFilter{ @@ -316,7 +314,7 @@ func (c *Client) NewListSnapshotsPager(options *ListSnapshotsOptions) *runtime.P RetentionPeriod: snapshot.RetentionPeriod, Tags: snapshot.Tags, Created: snapshot.Created, - ETag: &convertedETag, + ETag: (*azcore.ETag)(snapshot.Etag), Expires: snapshot.Expires, ItemsCount: snapshot.ItemsCount, Name: snapshot.Name, @@ -343,17 +341,16 @@ func (c *Client) NewListSettingsForSnapshotPager(snapshotName string, options *L options = &ListSettingsForSnapshotOptions{} } - opts := generated.AzureAppConfigurationClientGetKeyValuesOptions{ + ssRespPager := c.appConfigClient.NewGetKeyValuesPager(&generated.AzureAppConfigurationClientGetKeyValuesOptions{ AcceptDatetime: options.AcceptDatetime, After: options.After, - IfMatch: options.IfMatch, - IfNoneMatch: options.IfNoneMatch, + IfMatch: (*string)(options.IfMatch), + IfNoneMatch: (*string)(options.IfNoneMatch), Select: options.Select, Snapshot: &snapshotName, Key: &options.Key, Label: &options.Label, - } - ssRespPager := c.appConfigClient.NewGetKeyValuesPager(&opts) + }) return runtime.NewPager(runtime.PagingHandler[ListSettingsForSnapshotResponse]{ More: func(ListSettingsForSnapshotResponse) bool { @@ -445,16 +442,16 @@ func (c *Client) GetSnapshot(ctx context.Context, snapshotName string, options * options = &GetSnapshotOptions{} } - opts := (*generated.AzureAppConfigurationClientGetSnapshotOptions)(options) - - getResp, err := c.appConfigClient.GetSnapshot(ctx, snapshotName, opts) + getResp, err := c.appConfigClient.GetSnapshot(ctx, snapshotName, &generated.AzureAppConfigurationClientGetSnapshotOptions{ + IfMatch: (*string)(options.IfMatch), + IfNoneMatch: options.IfNoneMatch, + Select: options.Select, + }) if err != nil { return GetSnapshotResponse{}, err } - convertedETag := azcore.ETag(*getResp.Etag) - convertedFilters := make([]SettingFilter, len(getResp.Filters)) for i := range getResp.Filters { convertedFilters[i] = SettingFilter{ @@ -470,7 +467,7 @@ func (c *Client) GetSnapshot(ctx context.Context, snapshotName string, options * RetentionPeriod: getResp.RetentionPeriod, Tags: getResp.Tags, Created: getResp.Created, - ETag: &convertedETag, + ETag: (*azcore.ETag)(getResp.Etag), Expires: getResp.Expires, ItemsCount: getResp.ItemsCount, Name: getResp.Snapshot.Name, @@ -541,16 +538,15 @@ func (c *Client) updateSnapshotStatus(ctx context.Context, snapshotName string, Status: &status, } - opts := (*generated.AzureAppConfigurationClientUpdateSnapshotOptions)(options) - - updateResp, err := c.appConfigClient.UpdateSnapshot(ctx, snapshotName, entity, opts) + updateResp, err := c.appConfigClient.UpdateSnapshot(ctx, snapshotName, entity, &generated.AzureAppConfigurationClientUpdateSnapshotOptions{ + IfMatch: (*string)(options.IfMatch), + IfNoneMatch: (*string)(options.IfNoneMatch), + }) if err != nil { return updateSnapshotStatusResponse{}, err } - convertedETag := azcore.ETag(*updateResp.Etag) - convertedFilters := make([]SettingFilter, len(updateResp.Filters)) for i := range updateResp.Filters { convertedFilters[i] = SettingFilter{ @@ -566,7 +562,7 @@ func (c *Client) updateSnapshotStatus(ctx context.Context, snapshotName string, RetentionPeriod: updateResp.RetentionPeriod, Tags: updateResp.Tags, Created: updateResp.Created, - ETag: &convertedETag, + ETag: (*azcore.ETag)(updateResp.Etag), Expires: updateResp.Expires, ItemsCount: updateResp.ItemsCount, Name: updateResp.Snapshot.Name, diff --git a/sdk/data/azappconfig/options.go b/sdk/data/azappconfig/options.go index ecc42dbc20de..8f0c8937eff4 100644 --- a/sdk/data/azappconfig/options.go +++ b/sdk/data/azappconfig/options.go @@ -28,6 +28,8 @@ type DeleteSettingOptions struct { // If set, and the configuration setting exists in the configuration store, // delete the setting if the passed-in ETag is the same as the setting's ETag in the configuration store. + // + // This has IfMatch semantics. OnlyIfUnchanged *azcore.ETag } @@ -41,6 +43,8 @@ type GetSettingOptions struct { // If set, only retrieve the setting from the configuration store if setting has changed // since the client last retrieved it with the ETag provided. + // + // This has IfNoneMatch semantics. OnlyIfChanged *azcore.ETag } @@ -61,6 +65,8 @@ type SetReadOnlyOptions struct { // If set, and the configuration setting exists in the configuration store, update the setting // if the passed-in configuration setting ETag is the same version as the one in the configuration store. + // + // This has IfMatch semantics. OnlyIfUnchanged *azcore.ETag } @@ -74,6 +80,8 @@ type SetSettingOptions struct { // If set, and the configuration setting exists in the configuration store, overwrite the setting // if the passed-in ETag is the same version as the one in the configuration store. + // + // This has IfMatch semantics. OnlyIfUnchanged *azcore.ETag } @@ -99,19 +107,19 @@ type CreateSnapshotOptions struct { // ArchiveSnapshotOptions contains the optional parameters for the ArchiveSnapshot method. type ArchiveSnapshotOptions struct { // Used to perform an operation only if the targeted resource's etag matches the value provided. - IfMatch *string + IfMatch *azcore.ETag // Used to perform an operation only if the targeted resource's etag does not match the value provided. - IfNoneMatch *string + IfNoneMatch *azcore.ETag } // RestoreSnapshotOptions contains the optional parameters for the RestoreSnapshot method. type RestoreSnapshotOptions struct { // Used to perform an operation only if the targeted resource's etag matches the value provided. - IfMatch *string + IfMatch *azcore.ETag // Used to perform an operation only if the targeted resource's etag does not match the value provided. - IfNoneMatch *string + IfNoneMatch *azcore.ETag } // ListSnapshotsOptions contains the optional parameters for the ListSnapshotsPager method. @@ -138,10 +146,10 @@ type ListSettingsForSnapshotOptions struct { After *string // Used to perform an operation only if the targeted resource's etag matches the value provided. - IfMatch *string + IfMatch *azcore.ETag // Used to perform an operation only if the targeted resource's etag does not match the value provided. - IfNoneMatch *string + IfNoneMatch *azcore.ETag // Used to select what fields are present in the returned resource(s). Select []SettingFields @@ -156,7 +164,7 @@ type ListSettingsForSnapshotOptions struct { // GetSnapshotOptions contains the optional parameters for the GetSnapshot method. type GetSnapshotOptions struct { // Used to perform an operation only if the targeted resource's etag matches the value provided. - IfMatch *string + IfMatch *azcore.ETag // Used to perform an operation only if the targeted resource's etag does not match the value provided. IfNoneMatch *string @@ -168,17 +176,17 @@ type GetSnapshotOptions struct { // RecoverSnapshotOptions contains the optional parameters for the RecoverSnapshot method. type RecoverSnapshotOptions struct { // Used to perform an operation only if the targeted resource's etag matches the value provided. - IfMatch *string + IfMatch *azcore.ETag // Used to perform an operation only if the targeted resource's etag does not match the value provided. - IfNoneMatch *string + IfNoneMatch *azcore.ETag } // UpdateSnapshotStatusOptions contains the optional parameters for the UpdateSnapshotStatus method. type updateSnapshotStatusOptions struct { // Used to perform an operation only if the targeted resource's etag matches the value provided. - IfMatch *string + IfMatch *azcore.ETag // Used to perform an operation only if the targeted resource's etag does not match the value provided. - IfNoneMatch *string + IfNoneMatch *azcore.ETag } From ecdb3a6d054b408a3a0b9b2b55aef4ac21791bfd Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Mon, 8 Jan 2024 16:35:11 -0800 Subject: [PATCH 12/32] [azopenai] Fixing issue where you can't use whisper with m4a files. (#22210) Fixing issue where you can't use whisper with m4a files. * It's one of the formats that doesn't seem to be recognized without an explicit file extension, which you can pass via Filename * My tests were too heavily dependent on implementation details of the models. Changing this out to check that things are working correctly without checking the exact contents of the response. * Also, rerecorded tests since we're doing multiple audio tests as well. Fixes #22195 --- sdk/ai/azopenai/CHANGELOG.md | 3 + sdk/ai/azopenai/assets.json | 2 +- sdk/ai/azopenai/client_audio_test.go | 331 ++++++++++-------- sdk/ai/azopenai/client_completions_test.go | 40 +-- sdk/ai/azopenai/client_shared_test.go | 4 +- sdk/ai/azopenai/custom_client_audio.go | 17 +- sdk/ai/azopenai/custom_client_test.go | 3 +- ...diofiles_myVoiceIsMyPassportVerifyMe01.m4a | Bin 0 -> 30246 bytes 8 files changed, 227 insertions(+), 173 deletions(-) create mode 100644 sdk/ai/azopenai/testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.m4a diff --git a/sdk/ai/azopenai/CHANGELOG.md b/sdk/ai/azopenai/CHANGELOG.md index 8cba1e8685ed..17324cfcb95d 100644 --- a/sdk/ai/azopenai/CHANGELOG.md +++ b/sdk/ai/azopenai/CHANGELOG.md @@ -8,6 +8,9 @@ ### Bugs Fixed +- `AudioTranscriptionOptions.Filename` and `AudioTranslationOptions.Filename` fields are now properly propagated, allowing + for disambiguating the format of an audio file when OpenAI can't detect it. (PR#22210) + ### Other Changes ## 0.4.0 (2023-12-11) diff --git a/sdk/ai/azopenai/assets.json b/sdk/ai/azopenai/assets.json index 0326a3ded597..7cbfc913d854 100644 --- a/sdk/ai/azopenai/assets.json +++ b/sdk/ai/azopenai/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/ai/azopenai", - "Tag": "go/ai/azopenai_b42da78821" + "Tag": "go/ai/azopenai_85a01b7ac6" } diff --git a/sdk/ai/azopenai/client_audio_test.go b/sdk/ai/azopenai/client_audio_test.go index f49a9e4065ad..fb6d3a2e1dd6 100644 --- a/sdk/ai/azopenai/client_audio_test.go +++ b/sdk/ai/azopenai/client_audio_test.go @@ -8,7 +8,9 @@ package azopenai_test import ( "context" + "fmt" "os" + "path/filepath" "testing" "github.com/Azure/azure-sdk-for-go/sdk/ai/azopenai" @@ -24,20 +26,27 @@ func TestClient_GetAudioTranscription_AzureOpenAI(t *testing.T) { func TestClient_GetAudioTranscription_OpenAI(t *testing.T) { client := newOpenAIClientForTest(t) - mp3Bytes, err := os.ReadFile(`testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.mp3`) - require.NoError(t, err) - - args := newTranscriptionOptions(azopenai.AudioTranscriptionFormatVerboseJSON, openAI.Whisper.Model, mp3Bytes) - transcriptResp, err := client.GetAudioTranscription(context.Background(), args, nil) - require.NoError(t, err) - require.NotEmpty(t, transcriptResp) + testFiles := []string{ + `testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.m4a`, + `testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.mp3`, + } - require.NotEmpty(t, *transcriptResp.Text) - require.Greater(t, *transcriptResp.Duration, float32(0.0)) - require.NotEmpty(t, *transcriptResp.Language) - require.NotEmpty(t, transcriptResp.Segments) - require.NotEmpty(t, transcriptResp.Segments[0]) - require.NotEmpty(t, transcriptResp.Task) + for _, audioFile := range testFiles { + t.Run(fmt.Sprintf("verbose (%s)", filepath.Ext(audioFile)), func(t *testing.T) { + args := newTranscriptionOptions(azopenai.AudioTranscriptionFormatVerboseJSON, openAI.Whisper.Model, audioFile) + + transcriptResp, err := client.GetAudioTranscription(context.Background(), args, nil) + require.NoError(t, err) + require.NotEmpty(t, transcriptResp) + + require.NotEmpty(t, *transcriptResp.Text) + require.Greater(t, *transcriptResp.Duration, float32(0.0)) + require.NotEmpty(t, *transcriptResp.Language) + require.NotEmpty(t, transcriptResp.Segments) + require.NotEmpty(t, transcriptResp.Segments[0]) + require.NotEmpty(t, transcriptResp.Task) + }) + } } func TestClient_GetAudioTranslation_AzureOpenAI(t *testing.T) { @@ -48,154 +57,192 @@ func TestClient_GetAudioTranslation_AzureOpenAI(t *testing.T) { func TestClient_GetAudioTranslation_OpenAI(t *testing.T) { client := newOpenAIClientForTest(t) - mp3Bytes, err := os.ReadFile(`testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.mp3`) - require.NoError(t, err) - - args := newTranslationOptions(azopenai.AudioTranslationFormatVerboseJSON, openAI.Whisper.Model, mp3Bytes) - transcriptResp, err := client.GetAudioTranslation(context.Background(), args, nil) - require.NoError(t, err) - require.NotEmpty(t, transcriptResp) + testFiles := []string{ + `testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.m4a`, + `testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.mp3`, + } - require.NotEmpty(t, *transcriptResp.Text) - require.Greater(t, *transcriptResp.Duration, float32(0.0)) - require.NotEmpty(t, *transcriptResp.Language) - require.NotEmpty(t, transcriptResp.Segments) - require.NotEmpty(t, transcriptResp.Segments[0]) - require.NotEmpty(t, transcriptResp.Task) + for _, audioFile := range testFiles { + t.Run(fmt.Sprintf("verbose (%s)", filepath.Ext(audioFile)), func(t *testing.T) { + args := newTranslationOptions(azopenai.AudioTranslationFormatVerboseJSON, openAI.Whisper.Model, audioFile) + transcriptResp, err := client.GetAudioTranslation(context.Background(), args, nil) + require.NoError(t, err) + require.NotEmpty(t, transcriptResp) + + require.NotEmpty(t, *transcriptResp.Text) + require.Greater(t, *transcriptResp.Duration, float32(0.0)) + require.NotEmpty(t, *transcriptResp.Language) + require.NotEmpty(t, transcriptResp.Segments) + require.NotEmpty(t, transcriptResp.Segments[0]) + require.NotEmpty(t, transcriptResp.Task) + }) + } } func runTranscriptionTests(t *testing.T, client *azopenai.Client, model string) { - mp3Bytes, err := os.ReadFile(`testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.mp3`) - require.NoError(t, err) - - t.Run(string(azopenai.AudioTranscriptionFormatText), func(t *testing.T) { - args := newTranscriptionOptions(azopenai.AudioTranscriptionFormatText, model, mp3Bytes) - transcriptResp, err := client.GetAudioTranscription(context.Background(), args, nil) - require.NoError(t, err) - require.NotEmpty(t, transcriptResp) - - require.NotEmpty(t, *transcriptResp.Text) - requireEmptyAudioTranscription(t, transcriptResp.AudioTranscription) - }) - - t.Run(string(azopenai.AudioTranscriptionFormatSrt), func(t *testing.T) { - args := newTranscriptionOptions(azopenai.AudioTranscriptionFormatSrt, model, mp3Bytes) - transcriptResp, err := client.GetAudioTranscription(context.Background(), args, nil) - require.NoError(t, err) - require.NotEmpty(t, transcriptResp) - - require.NotEmpty(t, *transcriptResp.Text) - requireEmptyAudioTranscription(t, transcriptResp.AudioTranscription) - }) - - t.Run(string(azopenai.AudioTranscriptionFormatVtt), func(t *testing.T) { - args := newTranscriptionOptions(azopenai.AudioTranscriptionFormatVtt, model, mp3Bytes) - transcriptResp, err := client.GetAudioTranscription(context.Background(), args, nil) - require.NoError(t, err) - require.NotEmpty(t, transcriptResp) - - require.NotEmpty(t, *transcriptResp.Text) - requireEmptyAudioTranscription(t, transcriptResp.AudioTranscription) - }) - - t.Run(string(azopenai.AudioTranscriptionFormatVerboseJSON), func(t *testing.T) { - args := newTranscriptionOptions(azopenai.AudioTranscriptionFormatVerboseJSON, model, mp3Bytes) - transcriptResp, err := client.GetAudioTranscription(context.Background(), args, nil) - require.NoError(t, err) - require.NotEmpty(t, transcriptResp) - - require.NotEmpty(t, *transcriptResp.Text) - require.Greater(t, *transcriptResp.Duration, float32(0.0)) - require.NotEmpty(t, *transcriptResp.Language) - require.NotEmpty(t, transcriptResp.Segments) - require.NotEmpty(t, transcriptResp.Segments[0]) - require.NotEmpty(t, transcriptResp.Task) - }) - - t.Run(string(azopenai.AudioTranscriptionFormatJSON), func(t *testing.T) { - args := newTranscriptionOptions(azopenai.AudioTranscriptionFormatJSON, model, mp3Bytes) - transcriptResp, err := client.GetAudioTranscription(context.Background(), args, nil) - require.NoError(t, err) - require.NotEmpty(t, transcriptResp) - - require.NotEmpty(t, *transcriptResp.Text) - requireEmptyAudioTranscription(t, transcriptResp.AudioTranscription) - }) + testFiles := []string{ + `testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.m4a`, + `testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.mp3`, + } + + for _, audioFile := range testFiles { + ext := filepath.Ext(audioFile) + + t.Run(fmt.Sprintf("%s (%s)", azopenai.AudioTranscriptionFormatText, ext), func(t *testing.T) { + args := newTranscriptionOptions(azopenai.AudioTranscriptionFormatText, model, audioFile) + transcriptResp, err := client.GetAudioTranscription(context.Background(), args, nil) + require.NoError(t, err) + require.NotEmpty(t, transcriptResp) + + require.NotEmpty(t, *transcriptResp.Text) + requireEmptyAudioTranscription(t, transcriptResp.AudioTranscription) + }) + + t.Run(fmt.Sprintf("%s (%s)", azopenai.AudioTranscriptionFormatSrt, ext), func(t *testing.T) { + args := newTranscriptionOptions(azopenai.AudioTranscriptionFormatSrt, model, audioFile) + transcriptResp, err := client.GetAudioTranscription(context.Background(), args, nil) + require.NoError(t, err) + require.NotEmpty(t, transcriptResp) + + require.NotEmpty(t, *transcriptResp.Text) + requireEmptyAudioTranscription(t, transcriptResp.AudioTranscription) + }) + + t.Run(fmt.Sprintf("%s (%s)", azopenai.AudioTranscriptionFormatVtt, ext), func(t *testing.T) { + args := newTranscriptionOptions(azopenai.AudioTranscriptionFormatVtt, model, audioFile) + transcriptResp, err := client.GetAudioTranscription(context.Background(), args, nil) + require.NoError(t, err) + require.NotEmpty(t, transcriptResp) + + require.NotEmpty(t, *transcriptResp.Text) + requireEmptyAudioTranscription(t, transcriptResp.AudioTranscription) + }) + + t.Run(fmt.Sprintf("%s (%s)", azopenai.AudioTranscriptionFormatVerboseJSON, ext), func(t *testing.T) { + args := newTranscriptionOptions(azopenai.AudioTranscriptionFormatVerboseJSON, model, audioFile) + transcriptResp, err := client.GetAudioTranscription(context.Background(), args, nil) + require.NoError(t, err) + require.NotEmpty(t, transcriptResp) + + require.NotEmpty(t, *transcriptResp.Text) + require.Greater(t, *transcriptResp.Duration, float32(0.0)) + require.NotEmpty(t, *transcriptResp.Language) + require.NotEmpty(t, transcriptResp.Segments) + require.NotEmpty(t, transcriptResp.Segments[0]) + require.NotEmpty(t, transcriptResp.Task) + }) + + t.Run(fmt.Sprintf("%s (%s)", azopenai.AudioTranscriptionFormatJSON, ext), func(t *testing.T) { + args := newTranscriptionOptions(azopenai.AudioTranscriptionFormatJSON, model, audioFile) + transcriptResp, err := client.GetAudioTranscription(context.Background(), args, nil) + require.NoError(t, err) + require.NotEmpty(t, transcriptResp) + + require.NotEmpty(t, *transcriptResp.Text) + requireEmptyAudioTranscription(t, transcriptResp.AudioTranscription) + }) + } } func runTranslationTests(t *testing.T, client *azopenai.Client, model string) { - mp3Bytes, err := os.ReadFile(`testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.mp3`) - require.NoError(t, err) - - t.Run(string(azopenai.AudioTranscriptionFormatText), func(t *testing.T) { - args := newTranslationOptions(azopenai.AudioTranslationFormatText, model, mp3Bytes) - transcriptResp, err := client.GetAudioTranslation(context.Background(), args, nil) - require.NoError(t, err) - require.NotEmpty(t, transcriptResp) - - require.NotEmpty(t, *transcriptResp.Text) - requireEmptyAudioTranslation(t, transcriptResp.AudioTranslation) - }) - - t.Run(string(azopenai.AudioTranscriptionFormatSrt), func(t *testing.T) { - args := newTranslationOptions(azopenai.AudioTranslationFormatSrt, model, mp3Bytes) - transcriptResp, err := client.GetAudioTranslation(context.Background(), args, nil) - require.NoError(t, err) - require.NotEmpty(t, transcriptResp) - - require.NotEmpty(t, *transcriptResp.Text) - requireEmptyAudioTranslation(t, transcriptResp.AudioTranslation) - }) - - t.Run(string(azopenai.AudioTranscriptionFormatVtt), func(t *testing.T) { - args := newTranslationOptions(azopenai.AudioTranslationFormatVtt, model, mp3Bytes) - transcriptResp, err := client.GetAudioTranslation(context.Background(), args, nil) - require.NoError(t, err) - require.NotEmpty(t, transcriptResp) - - require.NotEmpty(t, *transcriptResp.Text) - requireEmptyAudioTranslation(t, transcriptResp.AudioTranslation) - }) - - t.Run(string(azopenai.AudioTranscriptionFormatVerboseJSON), func(t *testing.T) { - args := newTranslationOptions(azopenai.AudioTranslationFormatVerboseJSON, model, mp3Bytes) - transcriptResp, err := client.GetAudioTranslation(context.Background(), args, nil) - require.NoError(t, err) - require.NotEmpty(t, transcriptResp) - - require.NotEmpty(t, *transcriptResp.Text) - require.Greater(t, *transcriptResp.Duration, float32(0.0)) - require.NotEmpty(t, *transcriptResp.Language) - require.NotEmpty(t, transcriptResp.Segments) - require.NotEmpty(t, transcriptResp.Segments[0]) - require.NotEmpty(t, transcriptResp.Task) - }) - - t.Run(string(azopenai.AudioTranscriptionFormatJSON), func(t *testing.T) { - args := newTranslationOptions(azopenai.AudioTranslationFormatJSON, model, mp3Bytes) - transcriptResp, err := client.GetAudioTranslation(context.Background(), args, nil) - require.NoError(t, err) - require.NotEmpty(t, transcriptResp) - - require.NotEmpty(t, *transcriptResp.Text) - requireEmptyAudioTranslation(t, transcriptResp.AudioTranslation) - }) + testFiles := []string{ + `testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.m4a`, + `testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.mp3`, + } + + for _, audioFile := range testFiles { + ext := filepath.Ext(audioFile) + + t.Run(fmt.Sprintf("%s (%s)", azopenai.AudioTranscriptionFormatText, ext), func(t *testing.T) { + args := newTranslationOptions(azopenai.AudioTranslationFormatText, model, audioFile) + transcriptResp, err := client.GetAudioTranslation(context.Background(), args, nil) + require.NoError(t, err) + require.NotEmpty(t, transcriptResp) + + require.NotEmpty(t, *transcriptResp.Text) + requireEmptyAudioTranslation(t, transcriptResp.AudioTranslation) + }) + + t.Run(fmt.Sprintf("%s (%s)", azopenai.AudioTranscriptionFormatSrt, ext), func(t *testing.T) { + args := newTranslationOptions(azopenai.AudioTranslationFormatSrt, model, audioFile) + transcriptResp, err := client.GetAudioTranslation(context.Background(), args, nil) + require.NoError(t, err) + require.NotEmpty(t, transcriptResp) + + require.NotEmpty(t, *transcriptResp.Text) + requireEmptyAudioTranslation(t, transcriptResp.AudioTranslation) + }) + + t.Run(fmt.Sprintf("%s (%s)", azopenai.AudioTranscriptionFormatVtt, ext), func(t *testing.T) { + args := newTranslationOptions(azopenai.AudioTranslationFormatVtt, model, audioFile) + transcriptResp, err := client.GetAudioTranslation(context.Background(), args, nil) + require.NoError(t, err) + require.NotEmpty(t, transcriptResp) + + require.NotEmpty(t, *transcriptResp.Text) + requireEmptyAudioTranslation(t, transcriptResp.AudioTranslation) + }) + + t.Run(fmt.Sprintf("%s (%s)", azopenai.AudioTranscriptionFormatVerboseJSON, ext), func(t *testing.T) { + args := newTranslationOptions(azopenai.AudioTranslationFormatVerboseJSON, model, audioFile) + transcriptResp, err := client.GetAudioTranslation(context.Background(), args, nil) + require.NoError(t, err) + require.NotEmpty(t, transcriptResp) + + require.NotEmpty(t, *transcriptResp.Text) + require.Greater(t, *transcriptResp.Duration, float32(0.0)) + require.NotEmpty(t, *transcriptResp.Language) + require.NotEmpty(t, transcriptResp.Segments) + require.NotEmpty(t, transcriptResp.Segments[0]) + require.NotEmpty(t, transcriptResp.Task) + }) + + t.Run(fmt.Sprintf("%s (%s)", azopenai.AudioTranscriptionFormatJSON, ext), func(t *testing.T) { + args := newTranslationOptions(azopenai.AudioTranslationFormatJSON, model, audioFile) + transcriptResp, err := client.GetAudioTranslation(context.Background(), args, nil) + require.NoError(t, err) + require.NotEmpty(t, transcriptResp) + + require.NotEmpty(t, *transcriptResp.Text) + requireEmptyAudioTranslation(t, transcriptResp.AudioTranslation) + }) + } } -func newTranscriptionOptions(format azopenai.AudioTranscriptionFormat, model string, mp3Bytes []byte) azopenai.AudioTranscriptionOptions { +func newTranscriptionOptions(format azopenai.AudioTranscriptionFormat, model string, path string) azopenai.AudioTranscriptionOptions { + audioBytes, err := os.ReadFile(path) + + if err != nil { + panic(err) + } + return azopenai.AudioTranscriptionOptions{ DeploymentName: to.Ptr(model), - File: mp3Bytes, + File: audioBytes, + Filename: &path, ResponseFormat: &format, Language: to.Ptr("en"), Temperature: to.Ptr[float32](0.0), } } -func newTranslationOptions(format azopenai.AudioTranslationFormat, model string, mp3Bytes []byte) azopenai.AudioTranslationOptions { +func newTranslationOptions(format azopenai.AudioTranslationFormat, model string, path string) azopenai.AudioTranslationOptions { + audioBytes, err := os.ReadFile(path) + + if err != nil { + panic(err) + } + + var filename *string + + if filepath.Ext(path) != ".mp3" { + filename = &path + } + return azopenai.AudioTranslationOptions{ DeploymentName: to.Ptr(model), - File: mp3Bytes, + File: audioBytes, + Filename: filename, ResponseFormat: &format, Temperature: to.Ptr[float32](0.0), } diff --git a/sdk/ai/azopenai/client_completions_test.go b/sdk/ai/azopenai/client_completions_test.go index 13242d371f2c..96a408b28425 100644 --- a/sdk/ai/azopenai/client_completions_test.go +++ b/sdk/ai/azopenai/client_completions_test.go @@ -45,33 +45,23 @@ func testGetCompletions(t *testing.T, client *azopenai.Client, isAzure bool) { skipNowIfThrottled(t, err) require.NoError(t, err) - want := azopenai.GetCompletionsResponse{ - Completions: azopenai.Completions{ - Choices: []azopenai.Choice{ - { - Text: to.Ptr("\n\nAzure OpenAI is a platform from Microsoft that provides access to OpenAI's artificial intelligence (AI) technologies. It enables developers to build, train, and deploy AI models in the cloud. Azure OpenAI provides access to OpenAI's powerful AI technologies, such as GPT-3, which can be used to create natural language processing (NLP) applications, computer vision models, and reinforcement learning models."), - Index: to.Ptr(int32(0)), - FinishReason: to.Ptr(azopenai.CompletionsFinishReason("stop")), - LogProbs: nil, - }, - }, - Usage: &azopenai.CompletionsUsage{ - CompletionTokens: to.Ptr(int32(85)), - PromptTokens: to.Ptr(int32(6)), - TotalTokens: to.Ptr(int32(91)), - }, - }, - } + // we'll do a general check here - as models change the answers can also change, token usages are different, + // etc... So we'll just make sure data is coming back and is reasonable. + require.NotZero(t, *resp.Completions.Usage.PromptTokens) + require.NotZero(t, *resp.Completions.Usage.CompletionTokens) + require.NotZero(t, *resp.Completions.Usage.TotalTokens) + require.Equal(t, int32(0), *resp.Completions.Choices[0].Index) + require.Equal(t, azopenai.CompletionsFinishReasonStopped, *resp.Completions.Choices[0].FinishReason) + + require.NotEmpty(t, *resp.Completions.Choices[0].Text) if isAzure { - want.Choices[0].ContentFilterResults = (*azopenai.ContentFilterResultsForChoice)(safeContentFilter) - want.PromptFilterResults = []azopenai.ContentFilterResultsForPrompt{ - {PromptIndex: to.Ptr[int32](0), ContentFilterResults: safeContentFilterResultDetailsForPrompt}, - } + require.Equal(t, safeContentFilter, resp.Completions.Choices[0].ContentFilterResults) + require.Equal(t, []azopenai.ContentFilterResultsForPrompt{ + { + PromptIndex: to.Ptr[int32](0), + ContentFilterResults: safeContentFilterResultDetailsForPrompt, + }}, resp.PromptFilterResults) } - want.ID = resp.Completions.ID - want.Created = resp.Completions.Created - - require.Equal(t, want, resp) } diff --git a/sdk/ai/azopenai/client_shared_test.go b/sdk/ai/azopenai/client_shared_test.go index 5651136e5792..400ddaa01f57 100644 --- a/sdk/ai/azopenai/client_shared_test.go +++ b/sdk/ai/azopenai/client_shared_test.go @@ -246,8 +246,8 @@ func initEnvVars() { openAI.Vision = azureOpenAI.Vision - azureOpenAI.Completions = "text-davinci-003" - openAI.Completions = "text-davinci-003" + azureOpenAI.Completions = "gpt-35-turbo-instruct" + openAI.Completions = "gpt-3.5-turbo-instruct" azureOpenAI.ChatCompletions = "gpt-35-turbo-0613" azureOpenAI.ChatCompletionsLegacyFunctions = "gpt-4-0613" diff --git a/sdk/ai/azopenai/custom_client_audio.go b/sdk/ai/azopenai/custom_client_audio.go index caf80ef65768..d9ce56f5177d 100644 --- a/sdk/ai/azopenai/custom_client_audio.go +++ b/sdk/ai/azopenai/custom_client_audio.go @@ -44,6 +44,7 @@ func (client *Client) GetAudioTranscription(ctx context.Context, body AudioTrans audioStream := streaming.NopCloser(bytes.NewReader(body.File)) resp, err := client.getAudioTranscriptionInternal(ctx, getDeployment(body), audioStream, &getAudioTranscriptionInternalOptions{ + Filename: body.Filename, Language: body.Language, Model: body.DeploymentName, Prompt: body.Prompt, @@ -79,6 +80,7 @@ func (client *Client) GetAudioTranslation(ctx context.Context, body AudioTransla audioStream := streaming.NopCloser(bytes.NewReader(body.File)) resp, err := client.getAudioTranslationInternal(ctx, getDeployment(body), audioStream, &getAudioTranslationInternalOptions{ + Filename: body.Filename, Model: body.DeploymentName, Prompt: body.Prompt, ResponseFormat: body.ResponseFormat, @@ -106,7 +108,20 @@ func setMultipartFormData[T getAudioTranscriptionInternalOptions | getAudioTrans return err } - if err := writeContent("file", "audio.mp3", file); err != nil { + var filename = "audio.mp3" + + switch opt := any(options).(type) { + case getAudioTranscriptionInternalOptions: + if opt.Filename != nil { + filename = *opt.Filename + } + case getAudioTranslationInternalOptions: + if opt.Filename != nil { + filename = *opt.Filename + } + } + + if err := writeContent("file", filename, file); err != nil { return err } diff --git a/sdk/ai/azopenai/custom_client_test.go b/sdk/ai/azopenai/custom_client_test.go index 9d851d213171..7b024096c41c 100644 --- a/sdk/ai/azopenai/custom_client_test.go +++ b/sdk/ai/azopenai/custom_client_test.go @@ -137,9 +137,8 @@ func testGetCompletionsStream(t *testing.T, client *azopenai.Client, tv testVars } } got := sb.String() - const want = "\n\nAzure OpenAI is a platform from Microsoft that provides access to OpenAI's artificial intelligence (AI) technologies. It enables developers to build, train, and deploy AI models in the cloud. Azure OpenAI provides access to OpenAI's powerful AI technologies, such as GPT-3, which can be used to create natural language processing (NLP) applications, computer vision models, and reinforcement learning models." - require.Equal(t, want, got) + require.NotEmpty(t, got) // there's no strict requirement of how the response is streamed so just // choosing something that's reasonable but will be lower than typical usage diff --git a/sdk/ai/azopenai/testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.m4a b/sdk/ai/azopenai/testdata/sampledata_audiofiles_myVoiceIsMyPassportVerifyMe01.m4a new file mode 100644 index 0000000000000000000000000000000000000000..716d6d2067469949de16a3b32082b151674bb3a2 GIT binary patch literal 30246 zcmXt<1ytP3_xE>km&M%{hvM$OcyTMmp%jN=#bI%GDORAk(-ti*ixi4Oakt{G`?k;T z{pTc^oH;YenapQyZsvOj002+W?{i1J87rjmwI3SAZWQcEd_QvdTxGUx3`9P#c#!hJVzjD%p@IOV!rs}AV z%dv3kftT2maa40h7#H?nS-*>JXa?oKVzuU?QKUd0BqGhYyB*Uo<>w1eg*Ixh3ZP^$ zpPTd4U70(3r1@Q*Eugcm@91jV%wXgCKDet39vJ_xdJTwA0!_XjG1znA&|9@H){!px z(ui5%8|@o^!6K>>ay;Bch{Q&UTkT?V+tOrMmvMJdJB?Bmt?)_<+x~nX;l}#klQr^2tcz)VED)_O%ZIGw%$5Ym0JWr`Odb;lDk}?xVJL6uBm`h>@MguLXALz$B&TljeWP6;FLFt@OQmvtmZip z^`YfQ6X*GudK+T(B3|iHFP~1oYHd>PDW|wXs-e<){&yT7-}R`s@t~&XxIwRRr_}b7 z@IJ!BniLfccw?Elw+T|S5`yk0T?y5#|LPNU9ffe0JZDU`k$GSAKWoOR-@fYf6!gfw`(* zryj^&s-}+!kZ5x|Z{kz4($&^-5|gV*&7gfFhFAVwY^QZ~ml|ES ziyoUDO!KE=k4j%{OQ&n&7tUvx@_u>>b78ue^sVm*3IwD{{j$S#F?ViGCp>u8)Yz+Q zbWqy>+ajx`ws0wWOOAGRc)q+^WV>&|^2hnx|CG3@J9UksnuJEuD$TTvy@F8TaaaNo z(jIrPmNvz8zS}zlZ)`#i9~z3s@9GM+6x`GWtyL-d_CujANf=ULT#^2Z+h5V0Q{GC& zqzW?vM{J8CUu9*5JmcooguTz0Bbf%D&kY_f^H(j5vnm;_BvVZYR=IpryQG2#8F?@iNmJgP2_j}>c?67wchIgsOom7kRM z>e@n;1+k;xy4)Vz8^<#ElYbnpJj>|3(+woOuG^pbH+%rzzK6YY)>*^F$muaktTPbT z6GbJcGsMCQluekj35uPs_e?!gq)j+w&9lXiev`l)Oz?9X-O?thcZo5jP!5Y1zgyNm z%JGtHb&^9LAxxRYWSIg*O_<((*z{Xedw6PvWB!(`M#ggb@@H(u3m#uZ_4SgQXWi8M z3hd?(2&6Z;?kk-bhvJYgLw>QOGn$)8$vIgH?NIX8qpVS&t6ZW9V=p)K&j6zsrA7;^ zABO*Ih~I3J^7wPd^iVl+pF<>^YS!|iWFgA!)|#PC=o^Vizct8|m+~A2 zz&3cv;^8@9ZqgV~Udsi3@e{g8eWOK`yddC6&Ha6JA3Aq#uF|?X(?QeStMz2*;g*X< zpND=PpmaL9tRn)83?EXMYXP-}lbT@oO1jzWa4zdPbP7 zJhQ%n62pT$83B7zo~W+L5u&>cB6)ChDANa`a`p;7*27+4P(Q4zjv2Xy{2nJZ%hmOI zw&f#j!BGNvr8J((2TcLU>)IqZD{tyVbM@_uyB$jNY96!R>DbCU+{?U7b5+1m9G?{R zvvUG{+Uv;fc|QImRGnD1f`pji{kRCM-PAuhKtORE`%B7#SZLxO;WVP<{daNnvB)GI zyXyAQ1%IuYc2*HvQ4SyxbBtnyr*d&Q^LMMSqC|oj-VS!$OBgFGo3rcmjoW)6#XZcv z%vVe|d2y$E&uY11Wn$mIxsdy0^4@vJa-xz!?kVEG@rRb-Kfi*glj#_JI@66!kvn^j zM}DD+JclM%Y;gWI&o!Vg>8B~o`rT#HbbO9tfpGWgFP#i?000%RFAywr@heRlANS=y z*n_sG)Yk5hKCQbV<Q9+{TbR(dQ&R1lIb($(;(x?m%l%uCcQ<;1z1VEUF zCJz3P5#^vQRw}Z=e)c4H%P|O8dCbxKy%{tUE$@B@%7EZHh@RZ7P7aQNTCEKqzlX1AK*z zmX6-fAj6=8rrts?m!^tbz!=?al-2t#NkxzTHG-m|JanYLp0v^EO$CcOj0cj)p#<5~ z)mNN`AEU0AGukzMDT#6VE1A{_tg~pUprWVr(Y}QMsL$E@BA`dWY^u!{5Tg{6h9{`sG8x zTiCMRK|M24D%F5tMU998nfW_X004{sn71cdO!-5?BF)d9yAcNY z^Z^2ME4c0U33FSk!6Uts&w4xZ!MIC0vj%nVc5Jn_efQ<_4lhll(SfQSPtNm$0ZO+& zz7OPCe$y}=zRsMGV|ZN7tn$cHvha;JVzf+IZPyeSqR=--EP~keHSgEJP)4?1B>V&X zg%T24=PBP&`R(oJ*TxiRE(%Sax9}q%byEU%|BiukEys^E5C07T@f_teZpu`196$!U zI-lpJL^JS}YYIE7um#Njbz+$BB&F?gLYShWXf$<#9vx-gQzeK=U&0q9DecV$=ip4n z5TRNjeG|T;EdTqz~R0D5J(>-1pR;I2qYja4pL0-rP{HS0--nM-X|mYUJ6r9&McdIwKg?UkK@r8hBS7ZStY{sT11)x4{8FncELBgXjF(>G(rb z9rQcjTF{6^zx&`z5AcH0XzjXHs%|@f@@BCloj6n&O92`r!h`AU)9*|DGrxR(lH(yr zsFQ9EDJ15SDolB($u`P!%5Djw30q`d@?3IubQHdu>^`}RMhr3D$njK7#QV*?$i?+T zf!{j0ydTZ`XC+p*W~s=4eHGY5i8HPPdozK~mtMVERQUU+MgZ-?kK7Gq&v6?u}da@7Ww+ z3DfH#C2sTv>GKz&y8|hN(|Y|w>*(M(4qnet#CJTv+3Hdp3AVl3%pcMrYeEYRbDie1}}T& zw8AWew}Sse*A+-AP`6pMP|iz*_Fu*ZcG-`4R;7_521)hLco_vMO5W?efk?@g21Ajl zw5jp_1!NoYcamA@j&6b;yhhGba{YN9B0-~ujnV7g*7vxK%sm4Au_Lfc^+ic|4c$z~ z8@V3;^6+!M+BPxFTevqBSnLZ=iBXp& za}%LPUkuQsz2%y3AGg6$&2M6TK-0&v9I6$h{$+ST2BG*(kt(+U9mJY8#GK#iFnY#+ zS2)ym&ouPP&GoAhZ#TQUJe+RNQOu7mM(O0wzNlC1D-5a-_$`&V4OisNkK)PaojY=) zSrMzzS$!m&e6$>~JhxhFdhyECIbB1ll@yg8wyjU{1{Qw4qWO?aJXh#fNtajM@dfOBrh+6zy16UCQ^dpf_5E z^=&6M&E#bGiLUErOMzu89@zZ6EQELthoVQ))de1*Lu@Q8ah);3)h=^i-2}>G+cak$ z^+#bO{glg}zxbB*+H*#1q%^*)=-^jWR4C|B4vk7KHG*r>$#c9!2NKhPy%vOXd>`5! zp4&6NeLvSl;uM-2582>VWZaw|CkaC#qb*lj8Q*& zUwp*Iocc_%B=PvHIpJ@&v$A$9!4*Jm5# zh#ReDbcq8dv!-DA1k=!v&R>frSbv7*n~g!mGus#|$(U7`_MuneuQOR!Qa9S%UmMCP z{epPXh@>{3xKky*)>Qg2^4yZ>dkhXZ-b8p)++!^wL`c_uM)yj;H}Lu90LKZbAph<_ z615NJcBqwg#-_&h`YE+82-4s>>J!4slRQ8 z9m{?%%V%t*6F6xTU0M4Kff&X<4vXfJW^$h&5c?oyifzhQm{pvEk6e3kXBQfxw|(p- zlgFdak3WmAE*IcT5zJJlZ_MMvEQdezJ}6`OT#$;Z9fZ*Z@*wrojzGy+vgn49fxtdw5MzZ4ta7PKmyeVLv<&Z@SS3Twrs{kGn0q4+e zwQ6l<8Y(8NF%TJPWAro*HcK?BeJnG|aS-2*%}Y`g{aAMoezkH`py`Pei80O$>eH1c zyF^t^1ZcoWGi32WYJKFqaq%72e1g9gC3?%X1vk&Ui0SZN^i}8jQt5-;h+qCebzt4) z+LL?RV9%dthXvuM2n<98Rm?lj3D)ngfixlr4!LgmF17lWy#JwCnqIbT!h4v7<^pqR8fb+WFU8P&V>zD1D=&SkE1t zP6=%Q9D@idT<>1}_h(=sCznk)RK~gH-eUDaB zI?70oj-`ZFEz0u>zmjPzn;N;4p<7-q)J}Q*%G&!vSz`*+y#YI{!f*J^^j2D>A!?%@ z$s?TUC(kRFLD;#*vQqU9nv-Sn{-d^dRV$uiVN8oJwM{?7o*`w}UfIo2hTLr*j8ECB z5yGa;Z8!60q$a!1xjJeCzde$U7Fs^a$e%ZzXp}S%+8B+_Bnvizmi03t+;e28rH>Ho z598hONol2*faKk^$yGY}Gq?~`!c**lq(1ig$#gKVhxN2K8Ovn#y8br3!kjK7PVbAh z2jg5AQ^_`S;Kxv)Koz3r7twx617G3OxQ^OV9wfPPh=!VfH~@OM&D<_Fz^v6DoB{}y zB?1wYBtiYN=utvtDe2KH0Hk4yskBMuG+}O_{ILa*BH6C(ld5eSA-S%XAx$0tpTDXZ%6) z*A^S&VY459;uu&M<|ObjiUYhQZKalPH6L7p)*ifO^VtZz;2zuE0=EUM6Pp9K&xTop z2@I^i7OUKWy$BTbyKHm}ArqEoXC_EnrEe(S%S+|X9-A1~oZU=VdvC>7Fduw7)O&xW z^_GWNl=utdR`qMb5>hK=ksaBGK^CD)O^Yi}`B9l)@{! zqv+GCZDEWfpxPcS1SzqWAw+418(@kE9x3Ud%cRrjIuXnk$3}Q_T5XNRDomf2q)deV zc2kePT~so8uUD1|H5iNxB6XXim7aCHqipJ@d-H5nJihXAP)lN=(>JWhkDful@CTLu zj2ifx&g1m7)9|7Mvbgij1_Nffz_)L%?(=0vs&X|2pB<~V_ zK2SR!n&3@I9S4F<6iO`lV`k+)p}6rE#wp=f5XLR`TN7lVrC5;3F>r%TSdvQ#8aNUZ z&nXfZKqBa~!>aj8tg$dxG!z~J+Vm%h`6Om;YdT&dVvSH$+6%#Mb^YOv5(=aYjAttf z6dVoI8c^cv49|WyO$NziZuRkL4o6?CB)5ls@K{1dj0UVW2Fda#vkqob2)hCuhUo{; zdnH4-Y^WqQ#+X7GUe;%VTu9$qD)%uSx@qFUBKH%?K?%%M>d#lhBe&#kR1?Y17nijqtM{Lub!27wSCk+#WodO4M49&LyD7xxLjwoB3qRWSZ&M?b-Y} zvwBjle+q`4R`qxFGBdA(wx;iu(2YKhoSZf!z3Yc=qoZ4;fp$yBi5h98=Vn590{9rQ zSKp_O_A79tPb(M@sDNV(_D^2AyPJtEv_4onJ8lPP9L2tP5V>nNb*v*{CynVZXp1OxB| zNLIZm%lIo@aJ2=9TKt!ij=sNpRbgPGis#XL`9fFkGA@k+q!p;qUCM&~V-*00(Y=UVpQXPkUdZ7 z$#n7D)Y`|fc`8jcEQo2}b!%T#4;2w0w}FN#`kg8Y^SE*LaQX;x1=jY|RH z6sh~xv}^T+!OyvxyGh~I?qtE|l)90sLH=T&z;3Vj1n2i&4_d09<`+Q7LJ;D}pqtLb ziXI`Iq@U2t%7h|r8fkmwZXaPW~aned=&)|{(!Azx*65pW`86=aF* zk}Ax@W1-x7e{?*AoPFUzp31x}IejF|D2w8fNO>d#_`^NezZ&s2lhTpGw(z3Rm%V(q zrYvOm2_CIs&TnrupY7ZhH#%M_)UMZZ+>}y}pBWd0d>V@((#n7==tpag^(b?DeD2{N z2I-x$j-eW0ku06^QjgaFrt)j?Hvp4@=YWDEqE_V^?Rzw$>(Jp+9^p8q*H8XbEtURQ z|6s++?*<6}#rHFqO>ai_Uk)H>o3f;Q9~!SWlbyn>QOrq7qd{`~swWz#3$-3b5O!QX zIVYv$AV2#s#&r^BY&G$kU;wDNO3Mhb`Hpc-)w>Qi>F0Glg3jn#=E&*!C=b)H-`rid zbF<|c2uGZEeE*KgG0af0hLb3Ec_aFWJ#D-s=q~7u>f$hX+I$8VAEjve)OZkwVwI_X zFsr77?Q-7P_Ln#x4+bS$cGV?`>YucJTqE9F zQLJa_N1vVal{M-o{t%R0S%j(j^_wxrCU4~f>u6s{I&_P-CkKSj2FG0nmd#5~`#Wdp zK1&TJkNR!t8&ew2<1{uwWu`$3XZR;+T-(1=Z++W4D}al}_tqJ4f3vxn~~UgunVDJoV6wbT3)3S&^278c*xlg(axrjMklDp)mqWN z-e9jyP6;R0<}%va0*QA78Uy7A+dFH|!8!zBbndR?;Uu)U7>dC9a68C8RwX?xWwCJB zE!Y#n2%u3)DKH57rmS+81q`1Cqjkft-w;SF~{ zc|kRf>BWl^i|sez=)z32?gpMwoX{;U_@T(q&s=p+;>I+l7>Ifu>=n)h{5 znl@y@M3w`HQP*(9}mqRK^9YU<5?ek&inhogNH; zCI`CSoK&UD=l5hQC_>I#^-~mHX3iCMqUSYXX3c^70bMeLab5nS5AAlwOGZPm7s2~+ z^0hdzpiidl%=zaE3mG00-{(JUZwkH4milqwNc-AdtZ`=i{lF6OFoN#&EX72!kvy=( zs?Q~e?tbl`T95f%$|-(ix6zd@4F6e}K{HJTe>a(Z`a!Dkl;~0|eUX}3iJqTKgo=E+ z^Njl@66XG#>`B3tS$z?f`Z7ggctcYB(Tv5h${C|PyUex~T+^O^KD-IVldUkBgL9X@ zWv07T8*(3$RCRY7 zpZ1V$`ux#;6xoR1E!M(F^q(#H8?jOG-OyA$uFRM)%^q4l-jLb+)u2cJ3^E<4{fl&? zWz~LOa8p?~A7agj5h5DQKxa*7=-TMb;8ngW(1Mrh3)rCErI8X@>Yn{vwkL)Z8UX2eA5lYg z6NX3Y4JLLz+$FxBF=qfN6W7N<`Ykdj%(i}|P?DqNg)t-(vg&KG@^0?4%fQ#k-am%pl|?f^dmJiF{9 zE<09%L*M+yCE*K!HQ;f%6y>gNAah}EPRW6M`)K2yY*I2mbbbjb6&&J%M=4@>lNL&F zf+yW|@s%Q-TABbR-IJ7T2yH=Pu5Ad@D*Uvans7q4+PVV$J>?>huXGE;W0gWH3vX^5 z_a@_sWRFBewgur^;Ju+{Wg-=HbJ`j|rjOE(=e6mOzvLK5N)-;H(&o-eQ|n1DO}5Tw z&y&`u1$^R}@~7vpAZKAf&=NFYh^LGCv*&*yJ#FA0i~}Tcvb=n6#V2SO8Z8uc$;N)nNjQO`EtG~#XW2aR_4s9 zydfdiqMWpFgzU=)4p!gdCxv0n`!si{!{OJsgxLc{oi0<~6enhkxpuay6RDhVQMbR` zccD!@)Cv^!IC{zs3Mu7_QBA!`m%(iMI={o18qn-wP5VpZQnTRn+0Owrx4z)dO8HkA z$B#kh4MEp0aJM^w76~fYc-`^Wxx!N#{Ir=hN60tZ0qsGXE63eu1KiQMB%dWELD3*a zSJSS{dl&f$lGj0B3j884g_N=~zlr|7uR7B+FtW2uQ5hBvN~E(hBVMHOs8e`$!SMxhUqLr53}TUwe0TWF?J8NV)6j4!QPU zn!g1#-GXRYL5S}Ia#D(eroAGhPin9!4x4ID-Y(95P_K$~(|>u&3{!h!RVDF}clY!f zgeNNY@?@gnrZ*+Ex<~DD)k?B`vUnTw;5(d;ayVcMCpqpqfj{KN2^@atmsE;dFtg_D z{J7zbd}ef45Rgf7FM-M$TnsORueKvTE<2LM+gBJ=zaFqN2dT+w+k#wSr6_7d%Wo~b znPulCCY&7XNAYAZ{xb;c|0#SUoW*kR!hacv{df_ZVvgAyB{9*4q|t*SY{sFY`5cNf z+Pu5TM!ZGJ8r5o-rAAN_tXvj(Cd=sYLPhWeJ5)9+YA#e&ASR>dGo)rpQmsY9vr(A- z{j0@^u9T7f{&z1d*S}#U8sbrKjj*!X08F)uHLS@1%O3)wfA01jKDa2C7O}*5J1l?0 z6l5*hMMr-a{7mDA!x`bU`u^(8MwY&Thfu(2G=ut zRQ?bJXyh)v(ine0Y{yC+cHw)MX}eYbB|O4fLOT_(=`A*NH~yAAf{UN{d)CiOk$HO| z$d;md;~ne6Ew`j3^Q#Y+$4W=fp31iox+rvB(MLw2b&)nA1)J^?I~i|M_=k#as8b*F z`<8LS(X0~}-1Xn-nj7`6yy@|DqKrd;J2n7^Y@?e6pQ2MY~8QFs1{h8|xw z-^@&}QS7*yTb@02&Z0f-)$4Uw92D^6AxSfhb~M4^Hg{5t{ak2uGZ#M5X-NI_79=&P z054))Rzz?Zu}oz;FlkIZ3B4y+y?jG14@c&hHrR-YIrEa{?^Ha}oF8T2YZ-1dxlkG4 zzP2SRFXrv}cRFO41(R$lso;Z;Byl3^iPXePSN(c{|6eaB>IHR86yfo*tLmle+ihMx zRv>QXQ!fHKLhQ|_rUJMb{GJ<-t)e!-#N%%!k4KLNzBNBsYu)Y=9tokvx9Yx@?T!Lb zvit-1pZi?H@m^u#f9|t@96zgtzduCwN9iq>`CUzN(kY+sw^Qm!)cCj7NAkiB`Q~feoRYn_DsDyrXvF4i} zPW;4GoXAHad!M(g3(X7%*Q-DN6quVaHi)O8s?1=pnE9cKf#ME#9M;NLzOFS|q-f{w z|ID?l?4*Prqj-t6Tzgf6?slE$UKv==67{9=!rwZ%u8OF;+ar@?Dy3+I z;Z>%Uvjs$hf=S}1)Tx}lUHz)-^fETKaB6E}B>zgu?H9A`xc1u^y|211NJ*zOv-Xm# zFSqoUWg9iWy!M=|CiQ#H17ycnnNSd3vC@kUv64c;c0n$;P3Kkg+jyRdJ^H1`xqmps zqg5p_40uR}Xx&nx7MGW4J5@K!Ch=LBV3dmZskzqPeEVI^DhwCS)nK)LwR#6$=>J@d z0Hn|CgLU$da?rzwSbo^i@u%HSi$xW}?Ryjz(CD?cf8nDsTcyaL6K==R7|;`}vn4Z$ zpb*_~W?muXZmL67@V_s3I^xRCFPxfJfrtCkqxGMok`(5i-peBwDYzw*`Ps=Nh*dnB zAcPXjh!Dm_DcDBFJFDZ!SJTfWzZTtd00EW3OBj~lYc^7p?+DSqS6SGWX;1S={|`~n zKNU`fQ1pLFMjQQa+0M2-Ypf8m9XbR7NC&d~Z4=DSJZV6NwjA8_29kjLS3-`N@N&=raPKXFebts3t`uU1+_E zn!B)yb$wP_rjy-1Y;1JYq*2tw`u=4s;xY=a$v>hsLozr5?j?r}$l(TmF{4Xz6VhUi zgn^iFKF@&02_vWvFt4NMN0J0a0|IC$>ryHXoAL2j@a z5phCyta917XvqV1*C^{Fg79eO>UC(t!W0Dsc+1?$!J5}Nl++H->ZCUnnb%kCUOWLS zp8!V_Ig~lrA13SK#!o%P0ZYgoiJ-&L0OIU(w&kG9qlALMaIZohg#0l@Z)(mc>wLjN z#M&sru8u!%N1n_0Z6vMd-M;%DA(&&)OO8v}Y{YaXwx7AZHL1>$YlM+=jBwg(zWoGW zIdt9h<&{AnEJ%{&g$X8;CZCDk&uD+Z3_{Vw2*tEVPRcTt_JSFU@ZjYTyg@0Z;c*!0 zwjQHLOOfS$c??0NmSx&UnwnA|LYQ(Uqzzt7SI$fIk~!hER-eR*B9bYPOQNs2BNG9W z+gpQw*OzZg@b> zrfuy}pse+GlJ-n}_=opK3~U99bKUv#B+L%lDw>m@!opX)4F?)+p^P(0(;Mh%%p#-m z*o16)dU~3Z>&MC}%HoD}6%X(wII~dPAY;})tBWB}x0QnSA^0EQL9ak4 z1;nxVWuc6vW1uMq^jkA}g1v-n@;)E*9LE;dsTL!2q-}q=$WFhkcj9 z>(8K_DFgdj*9*Klu(p`XMp91RFHO$okK13MQ&#b1aT}Hog)D$vAsW~qaINABMKhv~ zY@6kHEMwYg%ErT#Q5+AGA(%~{7dGCPJYkQvxvUbQmJuncio$CgC-TammbqsWf8GBq z5n(E2*bTu%#oF_pRfk*^_d9d8422M6Izg2zgwB|bG+UNoeCrsUBafU|06i?VbRK`d z2|o-Rm*wv+!iw^B*tz_#F4NDEWh8I$C1X^Zmon5EokUV2O=T6MM2k`oFKq#OhQh2p zjHPBtiUJD3h?y{H{g~0i>KjLHFV2O+(4Hk5gvL0=i2r*REhdB$m#DB9-@lRX51v}1 z8(nf>=+Ctj`B1$N@&_^u{=TBV9G;D?cF7I=2?*FFyvoWT3&vPz$$GT8t~@h?LYD@k zTE7fsydRhXD;>?ql$c!^*k248I$*$XLI)Wj7tu2%AMv^?lR*`$lRtj-}oOA2V zpU7rv!SXs9lAqc@y@w)6b0$Z-B`x-S z5y!N2nnOoPM8&tu}|>5ad5hXHvLX~%hdF+OQMVjl_<{cbxhl>x5C z%Sy*{{*cGe@W$%f^&Uu3)AuPop#+hBf4eP@+K)Z&;yTgUe?Iy?y`BGd?Dtkf{rS1I z@fQ$p0uYK+;W0yynwk}-Nbgp%lZqde8~4tvGiJ>Zvy9D`jFf$K@;^bE+3MJjcJe^8Ujf%h5ijz_OmOP}fNLI?|!-G(q)gY4C zfrY(u|DdYtz`DVk&brx$E`yP+rGGb?sFLne#@b5o!j*rV=(y69|F>)Kq}fp@g!Jdd zKV2F9EA;n)8GosX{(kr~pAPX~z0I2+wS(1*O}0zT&MU2r6Vd=AZfOAEgO+?$Q1g+` zMG0Sm$gE&20`y<~p(=4iY;qRbZ6!fRzB?dc{%^R@edj?>Q($l7-`mdZ)^!7<3f6H% z1iHFTf|uH{yWJ_cXrWM$(dq0GikTjWg^)(~56!gfSF<<0rQ`aKJ1A`6wZJJhqgw;! zJ4YlFQHI6WnYXSj_$_??6rjjKaTCGn8|E;DTFHvFudLxMKx)aSaTeQ#-g@ZF(vrX&qwx(W_*~o1HV&Es+IqBtYuQ zA^9@poOv}Ke)a;`D zvWV!B6 z`VsJbT0YD5P`mm0%_TZyx!w~hfhf-5r}Jga)EFhE2#|&I<=2Vd_n;31&z>tD? zoEk6+%sOx<#)=-%f~n16u&S+Cs9#lC!hu$9@%+;5yhtLL_%%QX-gA3ezytu;!wZ*2 z`2NyYUN2w0HgXMHuZL13G3VFH8N@S^qZ19ZeNIifAaesn9fpG~K*t7re<^5Y<|Nn71NgghLsu5H}SWra=Xd{yo5!yspe^7=r$sejW^CC5lFephXnOPcSDG9p^ zQ#8&4J~w7v+_TN1jT%uHZmK~wF|G53EL9Eo(<#f z4C|FN`=VaSh+8Xb0#x9fMdv~qEa7kIl`8hoE{4IalFNC|SbswG^OcI+RG2DQpEx4+ zped7U%#js|q$)&37CA~Zx==@DW-CZ{oU$8wp|#WR3W^Wa(e>61`nAV0B2VN7Ei$B2 zqRXGrQh2U<-LAlO+RSMYic(BWm&v{B)#Hk)Q5P3}=t%D;nF~Ud=z5~otw3{D&inEu z=E?)PN>l|!uF!f17=0}rDAC((Go2i5FqUJqnRY1&9Ys*qh}3RLnIo|05E?^1HWk9? zVP~*XSrl$WKyNhBJRh72Yh2ScmOiIfVFh!wKuUt%d{r1Js7+OPG|Sl^JNzVo6oEU& zh{A-j$r~9A$TAQ`WM)a@yL6hNXNptwdwiXTY^*nIu|9qg1r^+2cGH4@8&<##xQTcQ z3g`LF=WUB6S#}4&2=o+QU?rXA{`p$Vj{Yy^UyC1-`yq4}&MAw_)I38*b{l@g4Vv}U z^93mnw=<3PLR~2^{E6icuNEz1hj=*S_sl|66kdGa{ZnUr z?&P8Nwas>QBc|=qq_LBIvq?_^_{Bq0u`#f!a&lqaJ&Qg8Q4KgMkbv_&evQO{yCIGm zC;1~YMm_nYpHdiPLF&macJAf$R~2DKKd54jarmb#8Y)h7;bESYO_ae)XzIl{prr`oY)0%6+F z*hjWtj!&W?Dt_%94pQW@6cMKij2_5w{#QqLd$Fe%O8{B`Dv(K__Uov||8xvTgh{%( zo8wGbXlj;1OQ;A1??(C4Ru(LdY8fIk($9!v#G-U+J@VG$u^@U#BF!)E<8BcT7_GA#%3F2Q2}VaRw@|#Fcpkp~`SE8Cj?+)F zssj`DK6`BCxtc)4@Tt^~OdHQ)q5IP%y5%hCa}n!bB27ZvboC6A!=S*2I;ZWk)Vf{f z>DEl~&L8EIcaoVUd?lTjEVR={TYG2lt!s&$>ysZ%wRunD6MFT7E{Yd^ZC->K3PQD7 z?;700jqM(=iI(_GY&59yz?3fjm zW8PP=H_=LMfwvp7^79XfahUW#@@Syb;*l&cDR@>Jzx5MG%kj&ecLj$SYxrP7(EwD8 z39XmaY}QSPQ1O$;v>Ve;$*tVyuIkHe2d7=(k88AWMF0-u%cGgnW7pzK*F8VU8re-3 z#d(+8@e>^Mop*Qs`k6-WiDtB-XsrOh_G6vr;(Gme+pgmaEAd*UA&P5e7DZQ=$5h@b z-e(kXTsl_`gSnDG028%Hj2?2PaBnn<2pB!&K75;PZ=7tG`aX%yIXRt zaiL3jAR7S2B8x=DL7_AgOUyiPOB7bW`}4%(?Dk!B>p{k8C4of#rS7jJPlopX9%O^d zqZ&NCS>5*q4WHUrO_9ka)vcXIdCLu+U!NasVy+) z4=(eL%aj|kJXSpaUuWRIX)e9$bccxlLFo+qsg!KO$)++h&zovuxHql%TdcFm@Gw%#_?DOOo{&K21)HA=?nEwmBm zZy`5J=seWT{Fxc~vLVXL`GyyxO!;`#dZ94gs9>AeukzDfu4qoNEwQtc)FCgkz=w&F z-cPSh#afy&0!nBmAQ?06M+I4KLpGx4sq^78UHZH5<&8O--yZyCa~>$F*Lh({(R`Q> zVme|7LC7i?Iy}k&eIFr^$bL^IFOuv4rB`Wvr;V=S?MLmwNvgX6TjoKkIuMaqH^+Ac zvo5OdNodbAyl}-O}pk>f~EONfxcazoXs7=Xu9KTd#yCX-|oMt*#;Mdkz%{Oa}m*)(%rIHwwAEg>! zcJ8TMP6i%o)$#GMqKW0#AL`6~yaST~qI?JP>3~%AmphFedVo3Yc;W7H@v&6?0Vl5h zi(xXJ@>o-N#oat@*hAMBdIWq~*bm>CMp$a6_w@`&n&w5@K58&Qp=X(^=Se>(^bRl1Q!N01g$KPAS%V5=Wv<=d2%u(a3$#$nu5#6`8GF>UWi9h3I%h4dwK?Co3?F z#l6Gt!R6eLv|9V*cH@h$uN4u{vK~WeA?rU|eZQtFCzb?0HtP}Kuqp)qBl7P$?1Iu6 zH-(?0PiwnyS^!NoU}?U20dutH`r@y91!oFXTajG+C#N`YoM_t=LP<_I;T%`R>}ryg{n~pYyd6sl0$lXn`J~JOP^`9tYYyr)(9?-gG>N9 zn)Y$Qcxo}J2v65V^uY>DU_y`#TPCW5KQX<$+V7v9 zrLR$2;J3SNip+Uag%{4_R&iStq>)Kmss`*|@FE2|I4ZSWK>%lfV)2qmI_e(@MFlI` z6_vqYx{ z@FK6wgdGm&(8(3kNFmVnPmoDopUh!CoD0qIHT(xoF1T0#dwrAQ6E_aaK~y`yvtC`A!a zs`OB$D+&nG1*AxmCgt1Q&;6eByx;lbtRELs*2uM-zR1 z`{OE>x z##FULyg9$Rqd^Q4Z;=k7&Diuunw%8NU5>CNla~bqO4`n}$^lLB8Ws7>7KWn7s1Hxs z(p4KAqX{2a@b%gxJ(98{&ZDC4ZpyV6fFQN4ECtWW_y}j}J~7pNVs#y;;mdZni}|JAe>VoQ z`%uS%$BO!x^)Xs)!4rR-6?dR;J!QW*i{S0g-AG{;seY}R7uwFe0rV=1;QSE~JiBU` z`@SC91cGIK;PwKI<&LaDD4X$Bg;Dm4x zdn&-69qV6nPvRY-rvcu0?8x5pNBOW77cLC39zraelNy+mJaWxY8qe=fvP+@dkv-3x zGvYg)kTyNNmtVm~s`avi$W46ZtulM*;5VB7xlbmkM6y)x9KBM6M6ep(FLL#BY>qaB zKTOTgk!}~9fJF%NyHv`|Tx4l@nIp*|UuV8_wp!BMTs?13A>6+-|MbOS&FU>{;m;FJ z6h8>;!)1VWea8=~kaz4I>)j0mf!NGIIt4h`XQ@2_iPc(`=Q$c}HZePXm|EGf0;dj) zWb_;8@lLZw=UhZ|)Qpa;hy*c8_3&%@rr=``ykdy1Zw zSbwg9)Wvh%g8NKLkv}-lX{iD+k7&YtO9NNcSuTgfzhRF0L(7>C^y^!{YTeKC$zPuo`iRZ+Rkv3?XR8cYWUR&ny~&B~Fp}!o&9awZ38q2>j;qs>Yw$ZccmyvZK&a zlGY81$OFq_YL%s+-0ZdW+7dpnwiRVQf8{6{QlyI&Q*ne9TQcP$2GJO$_*{?9%ZVN{ zga^08yD4_+LH(u1M9)G(MKw(vK7Cs2uh~TQK8-WoZiedxC6OP|(KBA9=MT9Im3LRU zJmlNB8b?wz@dDVX)2i2=wxv4WfzEll%Y4)lexaEW(=CNZYlJ+dtPGrY_&fM4RiYpa z9v3`LO`Uk-S<>th{-;r(wNfaEHxd*x?aWPOge3Mz&o?7MgFZ5XuI)-Y+mu44KWHzgzPYD&&z{lh2TFN+|4 zQ&k0CHQHGpniQ;)S3-uE_cv2yt{*7i+@xddZ)nW@bb-GeaC0D-H?;!{Equ`!(>s(a zaoRq7seu3I_~Pmv$YX5_1Ue5|IMBh#_|aamG5sBMBCjmkA^tkIO2F$SGMG&M4 z0mUFgbl;XmB;1x8o6(&nCMoICw*e^;yV9C-Od!8-3E6SIaygCnO5!55mIF2D2>fVQ zSO9@n^OgHFhp$B615*)M?smi1lm!3Q*ycHt?V)cwTMUeQAR(sTJB6}S?z>CYU!F;9 z2Qgp11!O^>#6V;SaF4VAWxi`2qCW^C773P;N`Jc!VNi(J@QE9Et0(0?099sOBEO+3 zVsn#~g1Zry6Yc|zaK!NIcCat(aNY3qfC_sf(JzFh@7vo^7~oNS7fE@Zte6bpx$$aR zMsO!!^CO#7a?!+RhA2(IHEK&MTt56`KY<=pui1(U_??6ogU7tEF7XaDFHBX3tu#Go zr#QV=){hVqH*-{}YC%t)Bp%cuj&wVo_pAo|{dEA3d&yFr;oPE^-KLz?HzaNUyhEX6 zq?i+x`De}Tl6+70}#;AmSR!)T{c+62a3cIC-0A@-M@Nlw3Qkm^~lo0MSd1oGKiZo>ZDZ5zo z!=H$ zdayx6Xo~vegn^AO%@BzeJrP22h6_&V?8#@zi-6I|<>3jTP`gA--V{WrjQRO;w$$X0+5Gwk~h(G(?~ zgamu6s>4{lF#j9PH*SPHzvEtMUYu!>YwL+LCOQW&xsoPQQ$Cuf$(lRs*vU`fBB(c8#qDjIdVH*$ zgWF4Niu7b9>Uva?30#yA5eaug{-yg)R9U8Zo@%PvM2OcZ324iB=VataX$NZUjC&|1 zH(7BQj+FC9CDmn44_1+qtK#3}=9l|+#O+D3Ea^X(_)P}qlxjaC7DJ(;v^pPpv31UY zR)NT7_D%^C(HwbtRiZu~+1I{4!Anj{)tBwt{F<|#?k~^;_-gQHfiE$?e!y}(p{RTs z)YbBVlmX5_69QLW61Mn+g@Z5)X;8GV{Cy6kRPI`PRH>iC`{Xq@otmec5C0^^eH~9S zUbb&NxMJ=9ncRARUjMJ(Uak8*zR&HKGml%Q?kc-Av;``P2YS20s{-4b5uT{T$z_wng zV;cCO#~Y!Q2$*m}OAcN9%T!O8eg9@UO_`R7rD(^3vDmAPtEh?~!ygrAn0`*p=Z@bp zE;Lp=47Vzt#GUY5b|*e((p4)V8d=eFf9yz)TE8_W^xaqEvN|j2O5*9l;^(XCf%Qv) z@8v6h+ZB{$g@4=kbcf}?lYe|KzJlN4Fu#Je&YNy{?RVBE39ex+BOL;9IxpUWGLb)4 zrn!y}(rK=UPL1`mmHO8tXU~wWkp~e;a-B@|cd88SWd%O3N~=And_9w$ZkAjXL8IFC zg&|!fEkWVo>jrl(>4hE!$I0?|u_KjI+UI-1WUXb~@bK zYHZEhYD`L_NLYR)xPC4;vTBnNa(yQ#RJG;KgT3~k6iwB&L+WWSs-(7?=crF*3GrfG zw95xa*5b`W*Ve6DdOZ0(ENmSE&l&S<6~xtdQ;c%>x)eN!Y!(iyCw59epI&gfB?h`3 z>&^wf-Dq8JDZ19qpCZ%`YSl=7)qmV@@kC?(igo|ntv5S!5h+S?KZZYAj1Ro91NvO7 zdZAd6+lpej^4;}x=52eE{(Y`3UwlwThzTc&*YfTP`$hVIoYyu>$9zMmcesZx_>#rV z;&22t4#D#zlWUvdK2-QC(EaDEg=RlE*{gRyhv<#x3EXdv;rNrL=ZTM^kOCLwW4oNm z6mgGfkYof`iZO}@Lv{Pc`9i4-hgj~xmCfYgiZD!a*fH&Bh89lJr^FAF^_2{Mpb5JC=$!Ta5Ap_Gj=f}YP&(z4JWLiOpj!k4WyX+;;NQfM z)|12MC%BdONX2w5=)6vvXV4_@Wi{HrjCW_| zMbRrp(F0p61tJE#R;(x>P;LJN=^$AT-F{rQ>;lO5NyFm)xt!Y6jxdW(^kS(9U2pge zLKgNgaQd4?NnBZwxsr{PxSW^;0-KP_vQZqyvNkAW0WFCkpiJ=<8;@Y7(NnqpQ-F5b zvcBoY_S;ZMnVi1sv#lnYWW~RE9vpM+n?L|~*}Rlg{?~DANRWr6ol`f3-kyT`WdT>W z6wkf*N%Vo-socGsg3%zI@NJ?cI%HxOEK0kLJD;6GnZq8JK461>XhbUR9_0sDBJ_`9 zl~uB-V=ur_)P%7YEI=g1pYW~@Y`=$uCa|aL$!fnV@YU%^ugTy_FF>jaMS+!<7h-=z zpWWRMy1B1R-i1#PyHx`9fD&yKgk2Jv%Gn?(xSL+dL`z*NZIcO9U~(q3)VHfm4<;Ox z>qYSNZeT-)6xP_RT$v3N@1u;{kg@2pSZTeTvXpfGh(@}YfzAwVArt{S6!m6A3xA(y zi5f;h(cC8!UKsA+2uqEnT$Re4DTO z0q+p8(-VmwieV8Zy7PB*`%iY5JqddE((MgI;a3agp+CLYe3@!A^~>EqG^zEae(|ypnv}`B%Gj<22sY@hU!2lDWX2 zp&+=!o2*bU&r(Y1_^e?YW<8lz@@nnq_s7JoXTkb^2fi0lu4PEvwXDm|AQ61;J34tN zmu~vR{2lky?kvai{S!Q=-+%i0h+dH{{W@1Ooj*FC=-fV*JE%85&EHQsIx9A0M$w>R7M{DkjL*Gwp% z6G|jONh5MULjBo!AA##3tzPbhTRg`mmolQKRx;Pyc zKmw_1s~6kke5jeHuRugY8bKssRcdcI*dKyjg-yH-Nl9wX!BA+v(6>uaXXpC-W!L5Y zobr2}wiw7`XKlO~q#5yqHcgvA6Q>v8c#Y=*HZJL)=v#;#Z`6`(CMPX~;SYStjJeIN z8igsSFDL!+_B}2&I|S}rPL}EE&j?>x*f}33g#?nVFmce>kM5$ywPp(CI8W+VoU1Jg zsF`$ltk$>$c<^=E9X$wHe&~@LM|38RvN1@CzS^6OY;)*xt%$%|1&qv=?jK_L7->I@2v!v{>OQa8SIo!EbxZ zfdJQb+$L8vRY^aX>tMv}vi!ySm|vO9Q$$UvpPE^|s^!&(y68N&A7(j^WG=l4^t|o% z@tl9T4H!gsvhpy;%_@k-aXh|x?c(R4nmc9PKO>EvAKa5WtQOE4Ewuyfv7?!sug@pPP93p9T~kR zC7NB_2Igg`nU{%pre4mup;8bU_dc~*x_j!+V6NT7d_~StNb3UDp_u5|JGpu8m)#GX z-6%5aV{Lj(ruEVF5rsJ#ei4;3itVO+zYQ|{2F+LK`})o2rg`@%s_`t4Zo@?j0rPkWm0=S&;I2ItJ8tTXVFRA zi1jnB_ltlYjJ($Q7!Z+cbfT-4?ih2ZBSW=S5Q|7!!%0<}a0H{$`c85pbZ$`Db#a(+ z?beWoF4f8q;{uN_hhn^bYr1bXZdC%YiGMuJ1Cr5I?IP`*0W zX$N+t{TneF-3BrKUa2YDZD#Dr3%JIc#VF5b`p80MuG*ayS&|CQHjrB5{?^k4UMS|= zS~)LH+0tWQuCKx<0ueWqwlu3-FgQ)B1f9=PqF6EzhL_tB*@$2js0gDpv-|r3C{V?g zx_f^ORg;&)J02mS-gni*P`AQV_3fMPesHlZ_2K>U&^{*5_qC7r`905tyH6T!&9|m& zuI7Gnj`h+~5PbM^C}SWkgOQA&9?Q3hw0kRkbN7MJ@l@mefwDuUutFi@jMy)pAr%(; zSSS1VS%>D!&o_U&rd%N)zG(`wRivk5Sk>ENN0v2*taHZ5ev1#$U-m6xg_JWG8RaNQ zEAZ}GP$5K6A?gO6yxI1A9Xn-jjFqcMdKj~+%m{bvWII40`t_}@cMIoh8XIzP8D3^$ zK73kgquR$qTnc6&`;s`2YxJeTW4>fkR5)zrS=q#JX}r~9rt55D)RYr5)`zofq?~!i zzI`}Jvb*K`_prGN%#-!@E~#^7TSi+1U_JhDdiU{+{(~yhLlkX4`Hj#rJZ+4B=Mc>j zAr+I%w}+V;rCweR-mgPit%&1(-!Z$k!d>V?v`*HcxjSiZBorlN0sA-z6sV6zW!?B-L?g z*@)*rGUzkl^NwWMCuLFG`Ki@_c$!}XAN%eZ>{X@i1dE07yZ<%!x6R} zRryD6Ay*N`tC_4!KR%Z?40cHvI~BV3rTW20a_Q~bhJ;_`1(Wa+^1l6it3nk!#yAB* z@cc|@%{82UooXEd60yo6-F?K^g31En`?%vzcaX1xl*ueqPCcKt9qB-L08DA70&G{-9J&JCMcYr?<*-60tp6+ISE23PP6Dn*E^4G9y zEte9$N0iN8w*=qt?lQ&ifXJ?`lt=@Mu##UW50-aIX@*>iI5u*pr4-q* zvZ}z7+NIkwxILpKIgUjZVa+kk@{#I8A=v7r zy;_Tss zN&2dhm$hsj6eUKAbh*Bs!?XNb0+J5)liUH9`m`nGhFI%YUa6_KPFHVSLepSW5gJt( z+xr}g;{>l?pgTG2y|%2V*wQiyeuQc1L4Ux1b0=_GSi{{PC=9+VH(YpbB=;vhS}!BE zds4dk*R-7sC0zx_4LjWpp1k?QuTnodi{b_1XG)c*@m6-P$n)wx<+{B5Wa>70yF`7+ ziOS!3H#qp`$m^b+ptr<%t}A+IPS%2rH$++uOds9q7RE?n9=*E*J7AKWEu!TSK{T0m zvY!_c%lCmlq2^3;kzi@yhNxxallyO(V-(mDoZT6E^x)lTZ1$$ktJ{@1a$(LVIwf3L+EYxu!grZtiGa3H!jiTkM8&k0K>D$zOWOVTk+Dpvc5&3`UA z^YoI$lt%d5M;oTAgPkWVZF}M-3M@3cLC#;PCneQxJQkh1S5ooDxQ>8={Wo8st6S!e z#?>N;1l6YeJ}k9l71JK!;(kNr{i-h~tP8vMxQZqh|9J{{S8y}>2LaZCq(<5^=ty79NNRzS?NJ$EKem`72I(o?Tor2dc?7viL0+k&d4U zzSPWl@@{JRcY(|Ydm&#sZ@TmOChd3@0-g5D`IKh)fO8}P>s6M;*~?!{m2s+`Cq$tE z+JZ;t1^RXbu_fWdE2Qe&`u0#bmVmVpb?e@%zdz(@_^$4mA8t|<;!a{MSi<+ps@7{o!#98l;4H)JT+BUeGVO-vZW~WGe>SyF{@o1l=dRh4?fdDe?f*A3dRVOT z4-4{cLOv`kB~CFUck3c``drD{N2HUD+?dd@kM>#XC0QI4l00{J)g0?E^XiZ38`^y* zdR8kAwSDotHpc-o;?zm7VMx720EAiZxat$8d}OVYt@p9p3+xNO9SJ&8rz#p=KF?Lf zr^$RI?d`0*(R;G#Yw(D|D}u0DB4sdFlb%jI*06M znw`5Me3}`gAM0g=$cSwHklcIqMT78J*l1e%Xl(x=MLK_`?3Z@;tYC;LS(;XwHXh1l zR@IyWffp*v;+{kulG3{bUCq-VE6BH}toIBAQ6-^|X^=fuT5FI6t5`ch%KUglS+h>W z0&16qSlNmFU4mNici6&Zjt17T-%(d5&SS~r5ZkOK4Z#);VA8@WPejcV+rrCwyV$&|&CoEI{5tO<(_ov^HPJ@~vuW?1&3NxJ2_Wp=9AE38)KCqe?G0Vd5Tpfmwxo_ETY#B5IJFhnId!Pn3iz?+CTuz|Z7B-F<~U?+?AKoEtR+wP z!@En$W?- z8;EBUr3|a`w<2MunPszGp`GJoGi8TYWuAxfb3!7CFvasQ0>dx07N##s@EvG~vj$@e z6;u?;QMJ*)}e6S@mT%i~uoPPU=M zzw{)rOYfxO=|@T>ootf{oxJw{${1&9u1Sr62t4#tN@I3dHikuq3~hKHWMyWd(^-%i z`k`xzGA=e^)PXw2u~l1JhB&W;$BB6_4-{Q7OFba8Ghzt* zi5@mWIs6hH*S#V_zuy?Gp}x~e84^-9t8Nr|JtRRRZkwysg{;vR!ABnBLU|ndd@l6d zD@()SgGUXIChzC_90VVKNHll|#uF1<85_&_&(pCDmSK4R{3ZHbJ2+Q*qJdp9M?WwS z&S4YdX^h#+?Rs(#ixdY%Lw`c{rjbuYLn$`SmGj%Ul^SRbt>j zF0GGRYAhBAoq+BO%qlhfBJvDorrv)uVS3d8uMI?6PEeP#CD|_WN~Ia?aBC#Hb4U$f zO1lwW57eZ?B)2-bJ>2oAV%xYPz_PUhvqqBo+;=H^INv+)>7i9h6e~F$^|!mgE;A-36W|flsJ`0M|U)h}=DY{#z z4~rR19iJTd9IHx1{}uYJN{tMfWFjcN2;FOKV&SVn@M&tq?&=$X?a;V)J_BmK)P*(h z1OmA+s_#xjo07uh;Bds_h}SDZPs>T=`8YMF?{uKlnXN%Nuc>T9G92M9id<18=(8^W zkIxxLM+P%-+L(QMT8fTloh0>+y;UOgN{xQ(12og6LXto)5r3#FwYcvvB@vB~lz7r? zl&v0O9o?0CpF65-K-Nq$W14EURvJrPoQSwbM3Rd75~f|n6oPcsYA4ssK&B8)zSerh zuIe*&`t0VZv!b!pr-$}eg`IW9+kVqUqjkIDpBL=cjx;kvsc+m+7re^iOF4(Var#(e z5{)gz3v_!vQK337m~3`X0g}%C*b)a`_g$3sQrSpI(X`wPT2GAj@&zAC|!ChEtzEXOEqr_<7D2^_xWn!|p_(q*%f(s;t4B zhzNs;7V!Mvi=FIy<54^GigIv&p=5&u}BKlo@+Rv-~H zVC+YPvfvi$f=SQRDFkO`btgoXMg$(B5;};>AV8_ZGpXXC8DdnHZ<_NU1?4Zy*HB&B zS{`EEoYUCl0`s?81DSXV?%Unej00n}+B+5nB;wkaGzA2d()$BlNm^xG9ENV>`e63F zm^rXeFsO@7NxU~i#$muHM2`)r;bH21B$9Z zw$!YcMi4JVu<>pSD3#~0enP&DP>f_ZUL^6SqMp8&mwTTtCPZ<7ymd?ger7juB#g%v z8aY7ueG_GvahdGri~T; z5b~nKpq-mN(=OhZ2a9h>944#pO&`S}MdRPRdBx<>2O;l^6vSG9S^;B;;_4H32-K61 z^W-FmG?4i>_R2gRr}>LBWC_AZ1!aBos5tY+Mj>@bJSN8>oY4pEItQkDv3+~@Y>*wN zIb524U$l%4bR*>20$KeN1pXVBJOyI)a1+qE>m-&GADS|69W%0mIa`kzN>J;+WaLU- z#z{7Sxjrmm&JA<9TJ{~t7uTrl*RX*H2yV}{@PVUzH2;k*S=RTd{Vp-+k(8M+MEM7< zUr?LZ>Dg6?(X&%B)%B#Sh}6k_4pXmj%>DzS!Bx1Q>1Y=M;X$5wVUb-umVHBYs%5Ru=s9Zl_Ld4fBl?~CPFL{*b z!QfO51EZ!r4}Y$j+4hlxq($HaxzDN=Qx#S_)Q_HicH%+VrN4@$@26 z3PX?L3iXm;N32UL%T($784pd05;iUTnkZ`xrC`#wXzCuAfDwIVGl4n+@4=n451JY7 zGl&|+#g(E}BFxL7jTRTmSVuoSlJ}@3Z4I>yt~Z@2omGjm<5H7ot7?k=39hmZD!kLT z^Iucts2CjKF!v?#?S($}oYItC_#eh4sYe*^Y$z+edVNTWYijy1uMvcQ5+?He9%VPw zxe1NXhV{P8G>#V>CGMnj;NE@x{=C!<|KO=}~jIAMpp~87KcN zk2hnZbtuZhJJx-550K~q5N@SGmojSbj-1vVP|OdN;(@{EDavDSzomG^-sjJw5?*>} z4?o4A@C1ugF?@jxY@~TrrcI)p$nre2MV)cCC~jai%VN%>z5GD;XD(sFsZ8psTD!}H&^qer1mGtQ)sbX=I z*y67U$4K&84%VX8>UPU#bxF$nfJYH%MI=OgRV?ir`$Y(d@b_Q9HM~Vq?dc%&&t;fe z*5<%177bWJ)(e$sD%rmJ)LnTG_PihIrG7Q?IZk!8OPE8QcEC;yQ%BFIMxlmIgXxFzrqwmtt;5qe5RFI&K7(1DRqh{_ z5moL1V#r696Zm-Q9TOD;GT9ss_bzo4gr+c+Q5{;Ectd59)-<2-5GyOSDA}@|>kPC`+zgiOURX1me*JdaaIWQtRCJ=Z z^MP}-sqPBl4VnjxG7?Xn>hjh|z$)CGKW880|76*-kNGX&I;2lo#;NIVX;8y&LbdIb zR7&vR4n#%9x;rLR9#_<%4EYnsZ7Rcev#~!To##o*ou3sSexFDrhg-bNA-@07e`bf~ z7kOt8t;Fx{%IGJbl@;Vo*Z*Rr!?Rihdhj>npK(%tdD`t(8VtMIyc7l8Jwia2hHrkN z5LuA~DeFVV6d>|fAt3N(pIh}8Ntl_~;Ac@EN4FPcKEbD+Eip0eekb1xWx`b+BiElr zMZNDRcm8t8q$@AJ;y@m7Vlw&tsd;ezc~ZGXhPR81=4)+Cg7>OF3#?aeSuA2nQb+4) zC7nm7v377^Z1uNgZ;)_;wIsK}HECLg-O8Rje$rguEBL88y~c$P6RAzhnRIyX0O*ugpxc{-w0mpf(+gt|$Ex*@=_1GKU+ zIZ9267o|E;6fWiPx$@KJxzDtH9AyeuI4_g zmO0^s1NjD%=PugYAE*Akx2g=6d0O(( zP{##@a9F_emN;qJ3Uog|EHmHMOjdIZ5Nf(BW{M=?5#e0-X|7`QZh>V*@M~0M0)uN)^@aO&3Emb=~QSs6gGlh#0^*o`RR~P@eU5$ z)=@tmD`OGbEjJ4R$!kqDd5p5*zJHz+_s1+Gj(sG%O5gZ#Q57O$3 z|4Zy&Z9uvIFM3ea$^7r1o((S?`kf^o0}cx*11 z|NFb&3ju-lN(^!TeDaPx#@X{<9Uw0^AJ_khUx)XBGzMkqigC8NmcdhSad5Q-A{1UO z|4S(x^PhYsjHk^t|C+9=LF(h_%=Vu+9>mMr${C0|dU<>OPiI`q7`wQOU03v)uG9Y^ zJP^fouaKZb-L05J#<-cq2w&H|kQSigM($hkoSeXt550AgUED?n^s z-v2bywa|51?w{uQrxb7rkY)mEVtvg7=(^-<-1|=mCIxtbK>UB`Iv)vu69BLc1;hnF z9)Lf99ss2Pu4P04=mDw-fg)uAtO0cf`UGzXKns8o02Kg$qZRPl0So{r2LQa?5^o&9 zO8}n%3<8J(&uxgx0Mre92;@})08WL#TLSPL z0I-t?pBM;-0el5e1^}oV_!j`+JN(n|D!}I%{sjjR!T?-1F^!kEwHpv#)3xCBbjIjq z=Z?8fc)B@X_bMI$@YNOYpUKM#a1sOPU(SEED#*$Q<82ABj9qO039rT2|9b!egVxj1 s-ThkQ|3h~i{xixE<=$@B)nEqR@p`S~TJiOpUTuLly-J8*zv%V<0KPr(-2eap literal 0 HcmV?d00001 From ed7cbbe6bdfd2963b5a3074b6346c00bb59ff54a Mon Sep 17 00:00:00 2001 From: Sourav Gupta <98318303+souravgupta-msft@users.noreply.github.com> Date: Tue, 9 Jan 2024 20:55:35 +0530 Subject: [PATCH 13/32] Updating changelog for STG91 preview (#22216) --- sdk/storage/azblob/CHANGELOG.md | 6 +----- sdk/storage/azblob/internal/exported/version.go | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/sdk/storage/azblob/CHANGELOG.md b/sdk/storage/azblob/CHANGELOG.md index f3e61a635b7c..8c8049fc228b 100644 --- a/sdk/storage/azblob/CHANGELOG.md +++ b/sdk/storage/azblob/CHANGELOG.md @@ -1,20 +1,16 @@ # Release History -## 1.2.2 (Unreleased) +## 1.3.0-beta.1 (2024-01-09) ### Features Added * Updated service version to `2023-11-03`. * Added support for Audience when OAuth is used. -### Breaking Changes - ### Bugs Fixed * Block `SharedKeyCredential` authentication mode for non TLS protected endpoints. Fixes [#21841](https://github.com/Azure/azure-sdk-for-go/issues/21841). -### Other Changes - ## 1.2.1 (2023-12-13) ### Features Added diff --git a/sdk/storage/azblob/internal/exported/version.go b/sdk/storage/azblob/internal/exported/version.go index 0a657c4bb0cc..6dfd71d6c577 100644 --- a/sdk/storage/azblob/internal/exported/version.go +++ b/sdk/storage/azblob/internal/exported/version.go @@ -8,5 +8,5 @@ package exported const ( ModuleName = "azblob" - ModuleVersion = "v1.2.2" + ModuleVersion = "v1.3.0-beta.1" ) From a672b5d2ee29a990135b42750c4290cc6e45b594 Mon Sep 17 00:00:00 2001 From: Sourav Gupta <98318303+souravgupta-msft@users.noreply.github.com> Date: Tue, 9 Jan 2024 21:52:49 +0530 Subject: [PATCH 14/32] azfile: STG 91 Preview (#22217) --- sdk/storage/azfile/CHANGELOG.md | 6 ++--- sdk/storage/azfile/go.mod | 12 +++++----- sdk/storage/azfile/go.sum | 24 +++++++++---------- .../azfile/internal/exported/version.go | 2 +- 4 files changed, 21 insertions(+), 23 deletions(-) diff --git a/sdk/storage/azfile/CHANGELOG.md b/sdk/storage/azfile/CHANGELOG.md index adc678058e38..799a5d723d92 100644 --- a/sdk/storage/azfile/CHANGELOG.md +++ b/sdk/storage/azfile/CHANGELOG.md @@ -1,15 +1,12 @@ # Release History - -## 1.1.2 (Unreleased) +## 1.2.0-beta.1 (2024-01-09) ### Features Added * Updated service version to `2023-11-03`. * Added support for Audience when OAuth is used. -### Breaking Changes - ### Bugs Fixed * Block `SharedKeyCredential` authentication mode for non TLS protected endpoints. Fixes [#21841](https://github.com/Azure/azure-sdk-for-go/issues/21841). @@ -17,6 +14,7 @@ ### Other Changes +* Updated azcore version to `1.9.1`. ## 1.1.1 (2023-11-15) diff --git a/sdk/storage/azfile/go.mod b/sdk/storage/azfile/go.mod index c3fc95785bb9..cd58abc65384 100644 --- a/sdk/storage/azfile/go.mod +++ b/sdk/storage/azfile/go.mod @@ -3,9 +3,9 @@ module github.com/Azure/azure-sdk-for-go/sdk/storage/azfile go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 - github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0 github.com/stretchr/testify v1.8.4 ) @@ -19,10 +19,10 @@ require ( github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/crypto v0.14.0 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/crypto v0.16.0 // indirect + golang.org/x/net v0.19.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/sdk/storage/azfile/go.sum b/sdk/storage/azfile/go.sum index 89fe67478eeb..76c27d3cd861 100644 --- a/sdk/storage/azfile/go.sum +++ b/sdk/storage/azfile/go.sum @@ -1,9 +1,9 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 h1:lGlwhPtrX6EVml1hO0ivjkUxsSyl4dsiw9qcA1k/3IQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1/go.mod h1:RKUqNu35KJYcVG/fqTRqmuXJZYNhYkBrnC/hX7yGbTA= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 h1:6oNBlSdi1QqM1PNW7FPA6xOGA5UNsXnkaYZz9vdPGhA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.2.0 h1:Ma67P/GGprNwsslzEH6+Kb8nybI8jpDTm4Wmzu2ReK8= github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0 h1:gggzg0SUMs6SQbEw+3LoSsYf9YMjkupeAnHMX8O9mmY= github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0/go.mod h1:+6KLcKIVgxoBDMqMO/Nvy7bZ9a0nbU3I1DtFQK3YvB4= @@ -26,15 +26,15 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= +golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= 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= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/sdk/storage/azfile/internal/exported/version.go b/sdk/storage/azfile/internal/exported/version.go index 182f1c3cdab3..3d56adb36de4 100644 --- a/sdk/storage/azfile/internal/exported/version.go +++ b/sdk/storage/azfile/internal/exported/version.go @@ -8,5 +8,5 @@ package exported const ( ModuleName = "azfile" - ModuleVersion = "v1.1.2" + ModuleVersion = "v1.2.0-beta.1" ) From a5c4497d9de4b772369891d1b7bbd3508ae34a54 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Tue, 9 Jan 2024 10:20:20 -0800 Subject: [PATCH 15/32] Increment package version after release of storage/azblob (#22219) --- sdk/storage/azblob/CHANGELOG.md | 10 ++++++++++ sdk/storage/azblob/internal/exported/version.go | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sdk/storage/azblob/CHANGELOG.md b/sdk/storage/azblob/CHANGELOG.md index 8c8049fc228b..7270e1383744 100644 --- a/sdk/storage/azblob/CHANGELOG.md +++ b/sdk/storage/azblob/CHANGELOG.md @@ -1,5 +1,15 @@ # Release History +## 1.3.0-beta.2 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes + ## 1.3.0-beta.1 (2024-01-09) ### Features Added diff --git a/sdk/storage/azblob/internal/exported/version.go b/sdk/storage/azblob/internal/exported/version.go index 6dfd71d6c577..b8b34739239f 100644 --- a/sdk/storage/azblob/internal/exported/version.go +++ b/sdk/storage/azblob/internal/exported/version.go @@ -8,5 +8,5 @@ package exported const ( ModuleName = "azblob" - ModuleVersion = "v1.3.0-beta.1" + ModuleVersion = "v1.3.0-beta.2" ) From c7abe2deb6b2c1c2299dec8e033851faf5efaad1 Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Tue, 9 Jan 2024 10:22:50 -0800 Subject: [PATCH 16/32] [azopenai] Update changelog for release. (#22215) --- sdk/ai/azopenai/CHANGELOG.md | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/sdk/ai/azopenai/CHANGELOG.md b/sdk/ai/azopenai/CHANGELOG.md index 17324cfcb95d..65e4470edcd1 100644 --- a/sdk/ai/azopenai/CHANGELOG.md +++ b/sdk/ai/azopenai/CHANGELOG.md @@ -1,18 +1,12 @@ # Release History -## 0.4.1 (Unreleased) - -### Features Added - -### Breaking Changes +## 0.4.1 (2024-01-16) ### Bugs Fixed - `AudioTranscriptionOptions.Filename` and `AudioTranslationOptions.Filename` fields are now properly propagated, allowing for disambiguating the format of an audio file when OpenAI can't detect it. (PR#22210) -### Other Changes - ## 0.4.0 (2023-12-11) Support for many of the features mentioned in OpenAI's November Dev Day and Microsoft's 2023 Ignite conference From f386581c1d4e34aa6631e8c01449999a5b3bc120 Mon Sep 17 00:00:00 2001 From: Joel Hendrix Date: Tue, 9 Jan 2024 10:25:20 -0800 Subject: [PATCH 17/32] Replace string with azcore.ETag (#22218) Missed one in last round of clean-up. --- sdk/data/azappconfig/client.go | 2 +- sdk/data/azappconfig/options.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/data/azappconfig/client.go b/sdk/data/azappconfig/client.go index fe6ccc9f982c..aea6bab6732b 100644 --- a/sdk/data/azappconfig/client.go +++ b/sdk/data/azappconfig/client.go @@ -444,7 +444,7 @@ func (c *Client) GetSnapshot(ctx context.Context, snapshotName string, options * getResp, err := c.appConfigClient.GetSnapshot(ctx, snapshotName, &generated.AzureAppConfigurationClientGetSnapshotOptions{ IfMatch: (*string)(options.IfMatch), - IfNoneMatch: options.IfNoneMatch, + IfNoneMatch: (*string)(options.IfNoneMatch), Select: options.Select, }) diff --git a/sdk/data/azappconfig/options.go b/sdk/data/azappconfig/options.go index 8f0c8937eff4..5fd21e38d9c4 100644 --- a/sdk/data/azappconfig/options.go +++ b/sdk/data/azappconfig/options.go @@ -167,7 +167,7 @@ type GetSnapshotOptions struct { IfMatch *azcore.ETag // Used to perform an operation only if the targeted resource's etag does not match the value provided. - IfNoneMatch *string + IfNoneMatch *azcore.ETag // Used to select what fields are present in the returned resource(s). Select []SnapshotFields From dbf4d0d68dea49636ecef2fb4977b740095ee0ce Mon Sep 17 00:00:00 2001 From: Joel Hendrix Date: Tue, 9 Jan 2024 10:26:42 -0800 Subject: [PATCH 18/32] Add script to go mod tidy modules (#22214) Will tidy all modules under the current working directory or under the specified directory. --- eng/scripts/modtidy.ps1 | 15 ++++++ sdk/data/aztables/testdata/perf/go.mod | 4 -- sdk/data/aztables/testdata/perf/go.sum | 6 --- .../dataprotection/armdataprotection/go.mod | 1 - .../dataprotection/armdataprotection/go.sum | 2 - .../dnsresolver/armdnsresolver/go.mod | 2 +- .../managed-identity/functions/go.mod | 20 ++++---- .../managed-identity/functions/go.sum | 47 ++++++++++--------- .../managed-identity/general/go.mod | 20 ++++---- .../managed-identity/general/go.sum | 47 ++++++++++--------- .../managed-identity/service-fabric/go.mod | 20 ++++---- .../managed-identity/service-fabric/go.sum | 47 ++++++++++--------- sdk/samples/fakes/go.mod | 6 +-- sdk/samples/fakes/go.sum | 16 +++---- 14 files changed, 132 insertions(+), 121 deletions(-) create mode 100644 eng/scripts/modtidy.ps1 diff --git a/eng/scripts/modtidy.ps1 b/eng/scripts/modtidy.ps1 new file mode 100644 index 000000000000..3acfc655796c --- /dev/null +++ b/eng/scripts/modtidy.ps1 @@ -0,0 +1,15 @@ +Param( + [string]$searchPath = $PWD.Path +) + +$modFiles = Get-ChildItem -Path $searchPath -Include "go.mod" -Recurse + +$modFiles | ForEach-Object -Parallel { + Push-Location $_.Directory + Write-Host (Get-Location) + go mod tidy + Pop-Location + if ($LASTEXITCODE) { + exit 1 + } +} diff --git a/sdk/data/aztables/testdata/perf/go.mod b/sdk/data/aztables/testdata/perf/go.mod index d8fe2bcd77cc..94946090fea2 100644 --- a/sdk/data/aztables/testdata/perf/go.mod +++ b/sdk/data/aztables/testdata/perf/go.mod @@ -9,12 +9,8 @@ require ( ) require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/stretchr/testify v1.8.4 // indirect golang.org/x/net v0.17.0 // indirect golang.org/x/text v0.13.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect ) replace github.com/Azure/azure-sdk-for-go/sdk/data/aztables => ../.. diff --git a/sdk/data/aztables/testdata/perf/go.sum b/sdk/data/aztables/testdata/perf/go.sum index 5467a25f0629..f901072b0a64 100644 --- a/sdk/data/aztables/testdata/perf/go.sum +++ b/sdk/data/aztables/testdata/perf/go.sum @@ -5,24 +5,18 @@ github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EX github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= 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.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= 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/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -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= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/go.mod b/sdk/resourcemanager/dataprotection/armdataprotection/go.mod index aa8ac8ac5b78..07a53b1d160e 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/go.mod +++ b/sdk/resourcemanager/dataprotection/armdataprotection/go.mod @@ -5,7 +5,6 @@ go 1.18 require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2 v2.4.0 ) require ( diff --git a/sdk/resourcemanager/dataprotection/armdataprotection/go.sum b/sdk/resourcemanager/dataprotection/armdataprotection/go.sum index 103f7bc7887f..7985f1da436f 100644 --- a/sdk/resourcemanager/dataprotection/armdataprotection/go.sum +++ b/sdk/resourcemanager/dataprotection/armdataprotection/go.sum @@ -4,8 +4,6 @@ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZM github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2 v2.4.0 h1:FaeGze9Jb68rw4DAHTuA7pNHOU43kMLe1hFgg5VXQsQ= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/dataprotection/armdataprotection/v2 v2.4.0/go.mod h1:VYwros1l9KigmAY7/DnDsKI+Zs1ugXjCec2KnoGyN1k= github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/sdk/resourcemanager/dnsresolver/armdnsresolver/go.mod b/sdk/resourcemanager/dnsresolver/armdnsresolver/go.mod index 47f0e97684b5..26b72ce72532 100644 --- a/sdk/resourcemanager/dnsresolver/armdnsresolver/go.mod +++ b/sdk/resourcemanager/dnsresolver/armdnsresolver/go.mod @@ -7,11 +7,11 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 github.com/stretchr/testify v1.8.4 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dnaeon/go-vcr v1.2.0 // indirect diff --git a/sdk/samples/azidentity/manual-tests/managed-identity/functions/go.mod b/sdk/samples/azidentity/manual-tests/managed-identity/functions/go.mod index 5e3ec21fa43a..a6af39640737 100644 --- a/sdk/samples/azidentity/manual-tests/managed-identity/functions/go.mod +++ b/sdk/samples/azidentity/manual-tests/managed-identity/functions/go.mod @@ -8,18 +8,18 @@ require ( ) require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 // indirect github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v0.8.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 // indirect + github.com/golang-jwt/jwt/v5 v5.2.0 // indirect + github.com/google/uuid v1.5.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.7.0 // indirect - golang.org/x/net v0.8.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/text v0.8.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + golang.org/x/crypto v0.17.0 // indirect + golang.org/x/net v0.19.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect ) // intent is to test main:HEAD diff --git a/sdk/samples/azidentity/manual-tests/managed-identity/functions/go.sum b/sdk/samples/azidentity/manual-tests/managed-identity/functions/go.sum index 24f7c624aa25..806ba6555561 100644 --- a/sdk/samples/azidentity/manual-tests/managed-identity/functions/go.sum +++ b/sdk/samples/azidentity/manual-tests/managed-identity/functions/go.sum @@ -1,33 +1,36 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 h1:8kDqDngH+DmVBiCtIjCFTGa7MBnsIOkF9IccInFEbjk= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 h1:lGlwhPtrX6EVml1hO0ivjkUxsSyl4dsiw9qcA1k/3IQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1/go.mod h1:RKUqNu35KJYcVG/fqTRqmuXJZYNhYkBrnC/hX7yGbTA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.2.0 h1:xZaKaIde2fNBQ6cvgvsdlMMeD4OTpLaOQ1UTVDXGicI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 h1:6oNBlSdi1QqM1PNW7FPA6xOGA5UNsXnkaYZz9vdPGhA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v0.13.0 h1:XY0plaTx8oeipK+XogAck2Qzv39KdnJNBwrxC4A0GL4= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azsecrets v0.13.0/go.mod h1:tj2JhpZY+NjcQcZ207YHkfwYuivmTrcj5ZNpQxpT3Qk= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v0.8.0 h1:T028gtTPiYt/RMUfs8nVsAL7FDQrfLlrm/NnRG/zcC4= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v0.8.0/go.mod h1:cw4zVQgBby0Z5f2v0itn6se2dDP17nTjbZFXW5uPyHA= -github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY= -github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 h1:DzHpqpoJVaCgOUdVHxE8QB52S6NiVdDQvGlny1qvPqA= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw= +github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= +github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/keybase/go-keychain v0.0.0-20230523030712-b5615109f100 h1:rG3VnJUnAWyiv7qYmmdOdSapzz6HM+zb9/uRFr0T5EM= 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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/samples/azidentity/manual-tests/managed-identity/general/go.mod b/sdk/samples/azidentity/manual-tests/managed-identity/general/go.mod index 68e5139b14c4..774c4c605f28 100644 --- a/sdk/samples/azidentity/manual-tests/managed-identity/general/go.mod +++ b/sdk/samples/azidentity/manual-tests/managed-identity/general/go.mod @@ -3,21 +3,21 @@ module main go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 // indirect + github.com/golang-jwt/jwt/v5 v5.2.0 // indirect + github.com/google/uuid v1.5.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.7.0 // indirect - golang.org/x/net v0.8.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/text v0.8.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + golang.org/x/crypto v0.17.0 // indirect + golang.org/x/net v0.19.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect ) // intent is to test main:HEAD diff --git a/sdk/samples/azidentity/manual-tests/managed-identity/general/go.sum b/sdk/samples/azidentity/manual-tests/managed-identity/general/go.sum index 1d309dbaf710..ca34df7b4ec4 100644 --- a/sdk/samples/azidentity/manual-tests/managed-identity/general/go.sum +++ b/sdk/samples/azidentity/manual-tests/managed-identity/general/go.sum @@ -1,29 +1,32 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 h1:8kDqDngH+DmVBiCtIjCFTGa7MBnsIOkF9IccInFEbjk= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= -github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY= -github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 h1:lGlwhPtrX6EVml1hO0ivjkUxsSyl4dsiw9qcA1k/3IQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1/go.mod h1:RKUqNu35KJYcVG/fqTRqmuXJZYNhYkBrnC/hX7yGbTA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.2.0 h1:xZaKaIde2fNBQ6cvgvsdlMMeD4OTpLaOQ1UTVDXGicI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 h1:6oNBlSdi1QqM1PNW7FPA6xOGA5UNsXnkaYZz9vdPGhA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= +github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 h1:DzHpqpoJVaCgOUdVHxE8QB52S6NiVdDQvGlny1qvPqA= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw= +github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= +github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/keybase/go-keychain v0.0.0-20230523030712-b5615109f100 h1:rG3VnJUnAWyiv7qYmmdOdSapzz6HM+zb9/uRFr0T5EM= 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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/samples/azidentity/manual-tests/managed-identity/service-fabric/go.mod b/sdk/samples/azidentity/manual-tests/managed-identity/service-fabric/go.mod index 68e5139b14c4..774c4c605f28 100644 --- a/sdk/samples/azidentity/manual-tests/managed-identity/service-fabric/go.mod +++ b/sdk/samples/azidentity/manual-tests/managed-identity/service-fabric/go.mod @@ -3,21 +3,21 @@ module main go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 // indirect + github.com/golang-jwt/jwt/v5 v5.2.0 // indirect + github.com/google/uuid v1.5.0 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.7.0 // indirect - golang.org/x/net v0.8.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/text v0.8.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + golang.org/x/crypto v0.17.0 // indirect + golang.org/x/net v0.19.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect ) // intent is to test main:HEAD diff --git a/sdk/samples/azidentity/manual-tests/managed-identity/service-fabric/go.sum b/sdk/samples/azidentity/manual-tests/managed-identity/service-fabric/go.sum index 1d309dbaf710..ca34df7b4ec4 100644 --- a/sdk/samples/azidentity/manual-tests/managed-identity/service-fabric/go.sum +++ b/sdk/samples/azidentity/manual-tests/managed-identity/service-fabric/go.sum @@ -1,29 +1,32 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0 h1:8kDqDngH+DmVBiCtIjCFTGa7MBnsIOkF9IccInFEbjk= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.0/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= -github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY= -github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 h1:lGlwhPtrX6EVml1hO0ivjkUxsSyl4dsiw9qcA1k/3IQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1/go.mod h1:RKUqNu35KJYcVG/fqTRqmuXJZYNhYkBrnC/hX7yGbTA= +github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache v0.2.0 h1:xZaKaIde2fNBQ6cvgvsdlMMeD4OTpLaOQ1UTVDXGicI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 h1:6oNBlSdi1QqM1PNW7FPA6xOGA5UNsXnkaYZz9vdPGhA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= +github.com/AzureAD/microsoft-authentication-extensions-for-go/cache v0.1.1 h1:WJTmL004Abzc5wDB5VtZG2PJk5ndYDgVacGqfirKxjM= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 h1:DzHpqpoJVaCgOUdVHxE8QB52S6NiVdDQvGlny1qvPqA= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw= +github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.5.0 h1:1p67kYwdtXjb0gL0BPiP1Av9wiZPo5A8z2cWkTZ+eyU= +github.com/google/uuid v1.5.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/keybase/go-keychain v0.0.0-20230523030712-b5615109f100 h1:rG3VnJUnAWyiv7qYmmdOdSapzz6HM+zb9/uRFr0T5EM= 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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= -github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/samples/fakes/go.mod b/sdk/samples/fakes/go.mod index 115d039e91f0..a7b48b0bd4d1 100644 --- a/sdk/samples/fakes/go.mod +++ b/sdk/samples/fakes/go.mod @@ -8,9 +8,9 @@ require ( ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.4.0 // indirect - golang.org/x/net v0.17.0 // indirect - golang.org/x/text v0.13.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 // indirect + golang.org/x/net v0.19.0 // indirect + golang.org/x/text v0.14.0 // indirect ) replace github.com/Azure/azure-sdk-for-go/sdk/azcore => ../../azcore diff --git a/sdk/samples/fakes/go.sum b/sdk/samples/fakes/go.sum index 79e6f7f45238..612d5772409d 100644 --- a/sdk/samples/fakes/go.sum +++ b/sdk/samples/fakes/go.sum @@ -1,6 +1,6 @@ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.4.0 h1:TuEMD+E+1aTjjLICGQOW6vLe8UWES7kopac9mUXL56Y= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.4.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 h1:6oNBlSdi1QqM1PNW7FPA6xOGA5UNsXnkaYZz9vdPGhA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5 v5.3.0-beta.2 h1:RBfZY7RzRdkxUkjjKPT25FmqAp/oSFRb9V/57q9wqNw= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v5 v5.3.0-beta.2/go.mod h1:lnOBBuKriNkBc3Bybhmcnszj/qBliLx+7Oisguurg9I= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 h1:mLY+pNLjCUeKhgnAJWAKhEUQM+RJQo2H1fuGSw1Ky1E= @@ -14,11 +14,11 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/crypto v0.16.0 h1:mMMrFzRSCF0GvB7Ne27XVtVAaXLrPmgPC7/v0tkwHaY= +golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c= +golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= From 8b197871df29657aaeb04a1150de5ed01c27e589 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Tue, 9 Jan 2024 10:40:43 -0800 Subject: [PATCH 19/32] Increment package version after release of storage/azfile (#22220) --- sdk/storage/azfile/CHANGELOG.md | 10 ++++++++++ sdk/storage/azfile/internal/exported/version.go | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sdk/storage/azfile/CHANGELOG.md b/sdk/storage/azfile/CHANGELOG.md index 799a5d723d92..14092c78f46f 100644 --- a/sdk/storage/azfile/CHANGELOG.md +++ b/sdk/storage/azfile/CHANGELOG.md @@ -1,5 +1,15 @@ # Release History +## 1.2.0-beta.2 (Unreleased) + +### Features Added + +### Breaking Changes + +### Bugs Fixed + +### Other Changes + ## 1.2.0-beta.1 (2024-01-09) ### Features Added diff --git a/sdk/storage/azfile/internal/exported/version.go b/sdk/storage/azfile/internal/exported/version.go index 3d56adb36de4..bc0ddccee738 100644 --- a/sdk/storage/azfile/internal/exported/version.go +++ b/sdk/storage/azfile/internal/exported/version.go @@ -8,5 +8,5 @@ package exported const ( ModuleName = "azfile" - ModuleVersion = "v1.2.0-beta.1" + ModuleVersion = "v1.2.0-beta.2" ) From bdf62de767180735d12984ae5edd5d5791bf61b9 Mon Sep 17 00:00:00 2001 From: Kushagra Thapar Date: Tue, 9 Jan 2024 10:55:26 -0800 Subject: [PATCH 20/32] Added Simon and Kushagra as code owners on GO Cosmos SDK (#22221) --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 0db2a10d1862..0402b2c22e34 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -28,7 +28,7 @@ /sdk/data/azappconfig/ @antkmsft @jhendrixMSFT @rickwinter # PRLabel: %Cosmos -/sdk/data/azcosmos/ @ealsur @kirankumarkolli +/sdk/data/azcosmos/ @ealsur @kirankumarkolli @simorenoh @kushagraThapar # PRLabel: %Tables /sdk/data/aztables/ @jhendrixMSFT From 46b361407a5c18c19e6633672124091496b6a9ed Mon Sep 17 00:00:00 2001 From: Richard Park <51494936+richardpark-msft@users.noreply.github.com> Date: Tue, 9 Jan 2024 10:57:13 -0800 Subject: [PATCH 21/32] [azservicebus] Updating batching to allow for a configurable wait time (#22154) Updating batching to allow for a configurable wait time. Can lead to fuller batches for people that want to tune it. Fixes #19172 --- sdk/messaging/azservicebus/CHANGELOG.md | 8 +-- sdk/messaging/azservicebus/receiver.go | 27 ++++--- sdk/messaging/azservicebus/receiver_test.go | 72 +++++++++++++++++++ .../azservicebus/receiver_unit_test.go | 1 - 4 files changed, 90 insertions(+), 18 deletions(-) diff --git a/sdk/messaging/azservicebus/CHANGELOG.md b/sdk/messaging/azservicebus/CHANGELOG.md index a92a3642ba94..13aba620af71 100644 --- a/sdk/messaging/azservicebus/CHANGELOG.md +++ b/sdk/messaging/azservicebus/CHANGELOG.md @@ -1,14 +1,10 @@ # Release History -## 1.5.1 (Unreleased) +## 1.5.1 (2024-01-16) ### Features Added -### Breaking Changes - -### Bugs Fixed - -### Other Changes +- ReceiverOptions.TimeAfterFirstMessage lets you configure the amount of time, after the first message in a batch is received, before we return messages. (PR#22154) ## 1.5.0 (2023-10-10) diff --git a/sdk/messaging/azservicebus/receiver.go b/sdk/messaging/azservicebus/receiver.go index b1adb4188b9b..a03395e10854 100644 --- a/sdk/messaging/azservicebus/receiver.go +++ b/sdk/messaging/azservicebus/receiver.go @@ -47,7 +47,6 @@ type Receiver struct { amqpLinks internal.AMQPLinks cancelReleaser *atomic.Value cleanupOnClose func() - defaultTimeAfterFirstMsg time.Duration entityPath string lastPeekedSequenceNumber int64 maxAllowedCredits uint32 @@ -131,7 +130,6 @@ func newReceiver(args newReceiverArgs, options *ReceiverOptions) (*Receiver, err receiver := &Receiver{ cancelReleaser: &atomic.Value{}, cleanupOnClose: args.cleanupOnClose, - defaultTimeAfterFirstMsg: 20 * time.Millisecond, lastPeekedSequenceNumber: 0, maxAllowedCredits: defaultLinkRxBuffer, retryOptions: args.retryOptions, @@ -143,13 +141,6 @@ func newReceiver(args newReceiverArgs, options *ReceiverOptions) (*Receiver, err return nil, err } - if receiver.receiveMode == ReceiveModeReceiveAndDelete { - // TODO: there appears to be a bit more overhead when receiving messages - // in ReceiveAndDelete. Need to investigate if this is related to our - // auto-accepting logic in go-amqp. - receiver.defaultTimeAfterFirstMsg = time.Second - } - newLinkFn := receiver.newReceiverLink if args.newLinkFn != nil { @@ -181,7 +172,13 @@ func (r *Receiver) newReceiverLink(ctx context.Context, session amqpwrap.AMQPSes // ReceiveMessagesOptions are options for the ReceiveMessages function. type ReceiveMessagesOptions struct { - // For future expansion + // TimeAfterFirstMessage controls how long, after a message has been received, before we return the + // accumulated batch of messages. + // + // Default value depends on the receive mode: + // - 20ms when the receiver is in ReceiveModePeekLock + // - 1s when the receiver is in ReceiveModeReceiveAndDelete + TimeAfterFirstMessage time.Duration } // ReceiveMessages receives a fixed number of messages, up to numMessages. @@ -400,7 +397,15 @@ func (r *Receiver) receiveMessagesImpl(ctx context.Context, maxMessages int, opt r.amqpLinks.Writef(EventReceiver, "Have %d credits, no new credits needed", currentReceiverCredits) } - result := r.fetchMessages(ctx, linksWithID.Receiver, maxMessages, r.defaultTimeAfterFirstMsg) + timeAfterFirstMessage := 20 * time.Millisecond + + if options != nil && options.TimeAfterFirstMessage > 0 { + timeAfterFirstMessage = options.TimeAfterFirstMessage + } else if r.receiveMode == ReceiveModeReceiveAndDelete { + timeAfterFirstMessage = time.Second + } + + result := r.fetchMessages(ctx, linksWithID.Receiver, maxMessages, timeAfterFirstMessage) r.amqpLinks.Writef(EventReceiver, "Received %d/%d messages", len(result.Messages), maxMessages) diff --git a/sdk/messaging/azservicebus/receiver_test.go b/sdk/messaging/azservicebus/receiver_test.go index a51b410b1d9a..bbeecb0b710e 100644 --- a/sdk/messaging/azservicebus/receiver_test.go +++ b/sdk/messaging/azservicebus/receiver_test.go @@ -5,6 +5,7 @@ package azservicebus import ( "context" + "errors" "fmt" "regexp" "sort" @@ -941,6 +942,77 @@ func TestReceiveAndSendAndReceive(t *testing.T) { require.Equal(t, msgs[0].Message(), rereceivedMsgs[0].Message(), "all sendable fields are preserved when resending") } +func TestReceiveWithDifferentWaitTime(t *testing.T) { + setup := func(t *testing.T, timeAfterFirstMessage *time.Duration) int { + serviceBusClient, cleanup, queueName := setupLiveTest(t, nil) + defer cleanup() + + sender, err := serviceBusClient.NewSender(queueName, nil) + require.NoError(t, err) + defer sender.Close(context.Background()) + + batch, err := sender.NewMessageBatch(context.Background(), nil) + require.NoError(t, err) + + bigBody := make([]byte, 1000) + + // send a bunch of messages + for i := 0; i < 1000; i++ { + err := batch.AddMessage(&Message{ + Body: bigBody, + }, nil) + + if errors.Is(err, ErrMessageTooLarge) { + err = sender.SendMessageBatch(context.Background(), batch, nil) + require.NoError(t, err) + + batch, err = sender.NewMessageBatch(context.Background(), nil) + require.NoError(t, err) + + i-- + } + } + + if batch.NumMessages() > 0 { + err = sender.SendMessageBatch(context.Background(), batch, nil) + require.NoError(t, err) + } + + receiver, err := serviceBusClient.NewReceiverForQueue(queueName, nil) + require.NoError(t, err) + + var opts *ReceiveMessagesOptions + + if timeAfterFirstMessage != nil { + opts = &ReceiveMessagesOptions{ + TimeAfterFirstMessage: *timeAfterFirstMessage, + } + + t.Logf("Setting time after first message: %s", *timeAfterFirstMessage) + } else { + t.Log("Using default time after first message") + } + + messages, err := receiver.ReceiveMessages(context.Background(), 1000, opts) + require.NoError(t, err) + + return len(messages) + } + + base := setup(t, nil) + require.NotZero(t, base) + t.Logf("Base case: %d messages", base) + + base2 := setup(t, to.Ptr[time.Duration](0)) + require.NotZero(t, base2) + t.Logf("Base case2: %d messages", base2) + + bigger := setup(t, to.Ptr(20*time.Second)) + t.Logf("Bigger: %d messages", bigger) + require.Greater(t, bigger, base) + require.Greater(t, bigger, base2) +} + type receivedMessageSlice []*ReceivedMessage func (messages receivedMessageSlice) Len() int { diff --git a/sdk/messaging/azservicebus/receiver_unit_test.go b/sdk/messaging/azservicebus/receiver_unit_test.go index 0b131f4ee9ca..af705cd1bb42 100644 --- a/sdk/messaging/azservicebus/receiver_unit_test.go +++ b/sdk/messaging/azservicebus/receiver_unit_test.go @@ -82,7 +82,6 @@ func TestReceiverCancellationUnitTests(t *testing.T) { ctx, cancel := context.WithCancel(context.Background()) r := &Receiver{ - defaultTimeAfterFirstMsg: time.Second, amqpLinks: &internal.FakeAMQPLinks{ Receiver: &internal.FakeAMQPReceiver{ ReceiveFn: func(ctx context.Context) (*amqp.Message, error) { From 0fbeb230fa29af5cc73dd1a811b8178ddb9570dd Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Tue, 9 Jan 2024 12:31:28 -0800 Subject: [PATCH 22/32] Sync eng/common directory with azure-sdk-tools for PR 7459 (#22222) * check for the presence of a compatible powershell. ensure that we always return a list of tags * allow the script to require pshell6+ * remove the en-us from the link --------- Co-authored-by: Scott Beddall (from Dev Box) --- .../testproxy/scripts/tag-merge/README.md | 1 + .../scripts/tag-merge/merge-proxy-tags.ps1 | 28 +++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/eng/common/testproxy/scripts/tag-merge/README.md b/eng/common/testproxy/scripts/tag-merge/README.md index aa524282e8a7..d72dd4dbefac 100644 --- a/eng/common/testproxy/scripts/tag-merge/README.md +++ b/eng/common/testproxy/scripts/tag-merge/README.md @@ -11,6 +11,7 @@ This script merely allows the abstraction of some of this "combination" work. ### PreReqs +- Must have []`pshell 6+`](https://learn.microsoft.com/powershell/scripting/install/installing-powershell-on-windows) - Must have `git` available on your PATH - Must have the `test-proxy` available on your PATH - `test-proxy` is honored when the proxy is installed as a `dotnet tool` diff --git a/eng/common/testproxy/scripts/tag-merge/merge-proxy-tags.ps1 b/eng/common/testproxy/scripts/tag-merge/merge-proxy-tags.ps1 index 866a5f787de4..18e57acc589f 100644 --- a/eng/common/testproxy/scripts/tag-merge/merge-proxy-tags.ps1 +++ b/eng/common/testproxy/scripts/tag-merge/merge-proxy-tags.ps1 @@ -1,3 +1,6 @@ +#Requires -Version 6.0 +#Requires -PSEdition Core + <# .SYNOPSIS Merge multiple asset tagss worth of content into a single asset tag. @@ -66,9 +69,6 @@ function Git-Command($CommandString, $WorkingDirectory, $HardExit=$true) { } function Resolve-Proxy { - # this script requires the presence of git - Test-Exe-In-Path -ExeToLookFor "git" | Out-Null - $testProxyExe = "test-proxy" # this script requires the presence of the test-proxy on the PATH $proxyToolPresent = Test-Exe-In-Path -ExeToLookFor "test-proxy" -ExitOnError $false @@ -184,7 +184,13 @@ function Start-Message($AssetsJson, $TargetTags, $AssetsRepoLocation, $MountDire function Finish-Message($AssetsJson, $TargetTags, $AssetsRepoLocation, $MountDirectory) { $len = $TargetTags.Length - Write-Host "`nSuccessfully combined $len tags. Invoke `"test-proxy push " -NoNewLine + if ($TargetTags.GetType().Name -eq "String") { + $len = 1 + } + + $suffix = if ($len -gt 1) { "s" } else { "" } + + Write-Host "`nSuccessfully combined $len tag$suffix. Invoke `"test-proxy push " -NoNewLine Write-Host $AssetsJson -ForegroundColor Green -NoNewLine Write-Host "`" to push the results as a new tag." } @@ -270,12 +276,22 @@ function Combine-Tags($RemainingTags, $AssetsRepoLocation, $MountDirectory){ # if we have successfully gotten to the end without any non-zero exit codes...delete the mergeprogress file, we're g2g Cleanup-Incomplete-Progress $MountDirectory - return $pushedTags + return @($pushedTags) } $ErrorActionPreference = "Stop" -# resolve the proxy location so that we can invoke it easily +# this script requires the presence of git +Test-Exe-In-Path -ExeToLookFor "git" | Out-Null + +# this script expects at least powershell 6 (core) + +if ($PSVersionTable["PSVersion"].Major -lt 6) { + Write-Error "This script requires a version of powershell newer than 6. See http://aka.ms/powershell for resolution." + exit 1 +} + +# resolve the proxy location so that we can invoke it easily, if not present we exit here. $proxyExe = Resolve-Proxy $AssetsJson = Resolve-Path $AssetsJson From 58413e0830932963eff8889e846cf06f87dc4103 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Tue, 9 Jan 2024 13:52:28 -0800 Subject: [PATCH 23/32] Fix image tag for multiimage deployments (#22224) Co-authored-by: Liudmila Molkova --- .../scripts/stress-testing/stress-test-deployment-lib.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 index 60a567c4e8af..2e71a6bd7396 100644 --- a/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 +++ b/eng/common/scripts/stress-testing/stress-test-deployment-lib.ps1 @@ -257,7 +257,7 @@ function DeployStressPackage( if ($pkg.Dockerfile -or $pkg.DockerBuildDir) { throw "The chart.yaml docker config is deprecated, please use the scenarios matrix instead." } - + foreach ($dockerBuildConfig in $dockerBuildConfigs) { $dockerFilePath = $dockerBuildConfig.dockerFilePath @@ -285,7 +285,7 @@ function DeployStressPackage( $dockerBuildCmd += $dockerBuildFolder Run @dockerBuildCmd - + Write-Host "`nContainer image '$imageTag' successfully built. To run commands on the container locally:" -ForegroundColor Blue Write-Host " docker run -it $imageTag" -ForegroundColor DarkBlue Write-Host " docker run -it $imageTag " -ForegroundColor DarkBlue @@ -302,7 +302,7 @@ function DeployStressPackage( } } $generatedHelmValues.scenarios = @( foreach ($scenario in $generatedHelmValues.scenarios) { - $dockerPath = if ("image" -notin $scenario) { + $dockerPath = if ("image" -notin $scenario.keys) { $dockerFilePath } else { Join-Path $pkg.Directory $scenario.image @@ -476,7 +476,7 @@ function generateRetryTestsHelmValues ($pkg, $releaseName, $generatedHelmValues) $failedJobsScenario += $job.split("-$($pkg.ReleaseName)")[0] } } - + $releaseName = "$($pkg.ReleaseName)-$revision-retry" $retryTestsHelmVal = @{"scenarios"=@()} From e274f377098fbd866460ae998f6446c0f9214b25 Mon Sep 17 00:00:00 2001 From: Chenjie Shi Date: Wed, 10 Jan 2024 09:30:49 +0800 Subject: [PATCH 24/32] Refresh azcontainerregistry module (#22161) * upgrade to latest codegen * merge resolver * enable span and add changelog * update module name --- .../azcontainerregistry/CHANGELOG.md | 2 + .../authentication_client.go | 44 ++- .../authentication_client_test.go | 26 +- .../authentication_custom_client.go | 11 +- .../authentication_custom_client_test.go | 3 +- .../authentication_policy_test.go | 12 +- .../azcontainerregistry/autorest.md | 10 +- .../azcontainerregistry/blob_client.go | 185 ++++++++---- .../azcontainerregistry/blob_client_test.go | 13 +- .../azcontainerregistry/blob_custom_client.go | 14 +- .../blob_custom_client_test.go | 7 +- sdk/containers/azcontainerregistry/client.go | 234 +++++++++------ .../azcontainerregistry/client_test.go | 39 ++- .../azcontainerregistry/constants.go | 35 ++- .../azcontainerregistry/custom_client.go | 14 +- .../azcontainerregistry/custom_constants.go | 2 +- sdk/containers/azcontainerregistry/models.go | 280 ++++-------------- .../azcontainerregistry/models_serde.go | 15 +- sdk/containers/azcontainerregistry/options.go | 182 ++++++++++++ .../azcontainerregistry/response_types.go | 15 +- .../azcontainerregistry/time_rfc3339.go | 43 ++- .../azcontainerregistry/time_rfc3339_test.go | 40 +-- 22 files changed, 708 insertions(+), 518 deletions(-) create mode 100644 sdk/containers/azcontainerregistry/options.go diff --git a/sdk/containers/azcontainerregistry/CHANGELOG.md b/sdk/containers/azcontainerregistry/CHANGELOG.md index db876da499da..e544357e66ae 100644 --- a/sdk/containers/azcontainerregistry/CHANGELOG.md +++ b/sdk/containers/azcontainerregistry/CHANGELOG.md @@ -4,9 +4,11 @@ ### Features Added * Add `ConfigMediaType` and `MediaType` properties to `ManifestAttributes` +* Enabled spans for distributed tracing ### Other Changes * Refine some logics and comments +* Updated to latest version of azcore ## 0.2.0 (2023-06-06) diff --git a/sdk/containers/azcontainerregistry/authentication_client.go b/sdk/containers/azcontainerregistry/authentication_client.go index de75e60e1fb0..72cf8301a127 100644 --- a/sdk/containers/azcontainerregistry/authentication_client.go +++ b/sdk/containers/azcontainerregistry/authentication_client.go @@ -3,14 +3,14 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package azcontainerregistry import ( "context" + "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" "github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming" @@ -20,10 +20,10 @@ import ( ) // authenticationClient contains the methods for the Authentication group. -// Don't use this type directly, use newAuthenticationClient() instead. +// Don't use this type directly, use a constructor function instead. type authenticationClient struct { + internal *azcore.Client endpoint string - pl runtime.Pipeline } // ExchangeAADAccessTokenForACRRefreshToken - Exchange AAD tokens for an ACR refresh Token @@ -35,18 +35,23 @@ type authenticationClient struct { // - options - authenticationClientExchangeAADAccessTokenForACRRefreshTokenOptions contains the optional parameters for the // authenticationClient.ExchangeAADAccessTokenForACRRefreshToken method. func (client *authenticationClient) ExchangeAADAccessTokenForACRRefreshToken(ctx context.Context, grantType postContentSchemaGrantType, service string, options *authenticationClientExchangeAADAccessTokenForACRRefreshTokenOptions) (authenticationClientExchangeAADAccessTokenForACRRefreshTokenResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "AuthenticationClient.ExchangeAADAccessTokenForACRRefreshToken", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.exchangeAADAccessTokenForACRRefreshTokenCreateRequest(ctx, grantType, service, options) if err != nil { return authenticationClientExchangeAADAccessTokenForACRRefreshTokenResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return authenticationClientExchangeAADAccessTokenForACRRefreshTokenResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return authenticationClientExchangeAADAccessTokenForACRRefreshTokenResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return authenticationClientExchangeAADAccessTokenForACRRefreshTokenResponse{}, err } - return client.exchangeAADAccessTokenForACRRefreshTokenHandleResponse(resp) + resp, err := client.exchangeAADAccessTokenForACRRefreshTokenHandleResponse(httpResp) + return resp, err } // exchangeAADAccessTokenForACRRefreshTokenCreateRequest creates the ExchangeAADAccessTokenForACRRefreshToken request. @@ -73,7 +78,10 @@ func (client *authenticationClient) exchangeAADAccessTokenForACRRefreshTokenCrea formData.Set("access_token", *options.AccessToken) } body := streaming.NopCloser(strings.NewReader(formData.Encode())) - return req, req.SetBody(body, "application/x-www-form-urlencoded") + if err := req.SetBody(body, "application/x-www-form-urlencoded"); err != nil { + return nil, err + } + return req, nil } // exchangeAADAccessTokenForACRRefreshTokenHandleResponse handles the ExchangeAADAccessTokenForACRRefreshToken response. @@ -96,18 +104,23 @@ func (client *authenticationClient) exchangeAADAccessTokenForACRRefreshTokenHand // - options - authenticationClientExchangeACRRefreshTokenForACRAccessTokenOptions contains the optional parameters for the // authenticationClient.ExchangeACRRefreshTokenForACRAccessToken method. func (client *authenticationClient) ExchangeACRRefreshTokenForACRAccessToken(ctx context.Context, service string, scope string, refreshToken string, options *authenticationClientExchangeACRRefreshTokenForACRAccessTokenOptions) (authenticationClientExchangeACRRefreshTokenForACRAccessTokenResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "AuthenticationClient.ExchangeACRRefreshTokenForACRAccessToken", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.exchangeACRRefreshTokenForACRAccessTokenCreateRequest(ctx, service, scope, refreshToken, options) if err != nil { return authenticationClientExchangeACRRefreshTokenForACRAccessTokenResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return authenticationClientExchangeACRRefreshTokenForACRAccessTokenResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return authenticationClientExchangeACRRefreshTokenForACRAccessTokenResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return authenticationClientExchangeACRRefreshTokenForACRAccessTokenResponse{}, err } - return client.exchangeACRRefreshTokenForACRAccessTokenHandleResponse(resp) + resp, err := client.exchangeACRRefreshTokenForACRAccessTokenHandleResponse(httpResp) + return resp, err } // exchangeACRRefreshTokenForACRAccessTokenCreateRequest creates the ExchangeACRRefreshTokenForACRAccessToken request. @@ -129,7 +142,10 @@ func (client *authenticationClient) exchangeACRRefreshTokenForACRAccessTokenCrea formData.Set("grant_type", string(*options.GrantType)) } body := streaming.NopCloser(strings.NewReader(formData.Encode())) - return req, req.SetBody(body, "application/x-www-form-urlencoded") + if err := req.SetBody(body, "application/x-www-form-urlencoded"); err != nil { + return nil, err + } + return req, nil } // exchangeACRRefreshTokenForACRAccessTokenHandleResponse handles the ExchangeACRRefreshTokenForACRAccessToken response. diff --git a/sdk/containers/azcontainerregistry/authentication_client_test.go b/sdk/containers/azcontainerregistry/authentication_client_test.go index 8dc02f2b20dd..fc77da0b1a7d 100644 --- a/sdk/containers/azcontainerregistry/authentication_client_test.go +++ b/sdk/containers/azcontainerregistry/authentication_client_test.go @@ -23,7 +23,8 @@ import ( func Test_authenticationClient_ExchangeAADAccessTokenForACRRefreshToken(t *testing.T) { startRecording(t) endpoint, cred, options := getEndpointCredAndClientOptions(t) - client := newAuthenticationClient(endpoint, &authenticationClientOptions{ClientOptions: options}) + client, err := newAuthenticationClient(endpoint, &authenticationClientOptions{ClientOptions: options}) + require.NoError(t, err) ctx := context.Background() if reflect.ValueOf(options.Cloud).IsZero() { options.Cloud = cloud.AzurePublic @@ -44,9 +45,10 @@ func Test_authenticationClient_ExchangeAADAccessTokenForACRRefreshToken(t *testi func Test_authenticationClient_ExchangeAADAccessTokenForACRRefreshToken_fail(t *testing.T) { startRecording(t) endpoint, _, options := getEndpointCredAndClientOptions(t) - client := newAuthenticationClient(endpoint, &authenticationClientOptions{ClientOptions: options}) + client, err := newAuthenticationClient(endpoint, &authenticationClientOptions{ClientOptions: options}) + require.NoError(t, err) ctx := context.Background() - _, err := client.ExchangeAADAccessTokenForACRRefreshToken(ctx, postContentSchemaGrantTypeAccessToken, strings.TrimPrefix(endpoint, "https://"), &authenticationClientExchangeAADAccessTokenForACRRefreshTokenOptions{ + _, err = client.ExchangeAADAccessTokenForACRRefreshToken(ctx, postContentSchemaGrantTypeAccessToken, strings.TrimPrefix(endpoint, "https://"), &authenticationClientExchangeAADAccessTokenForACRRefreshTokenOptions{ Tenant: to.Ptr("wrong tenant"), RefreshToken: to.Ptr("wrong token"), AccessToken: to.Ptr("wrong token"), @@ -58,16 +60,18 @@ func Test_authenticationClient_ExchangeAADAccessTokenForACRRefreshToken_error(t srv, closeServer := mock.NewServer() defer closeServer() srv.AppendResponse(mock.WithStatusCode(http.StatusOK), mock.WithBody([]byte("wrong response"))) - client := newAuthenticationClient(srv.URL(), &authenticationClientOptions{ClientOptions: azcore.ClientOptions{Transport: srv}}) + client, err := newAuthenticationClient(srv.URL(), &authenticationClientOptions{ClientOptions: azcore.ClientOptions{Transport: srv}}) + require.NoError(t, err) ctx := context.Background() - _, err := client.ExchangeAADAccessTokenForACRRefreshToken(ctx, "grantType", "service", nil) + _, err = client.ExchangeAADAccessTokenForACRRefreshToken(ctx, "grantType", "service", nil) require.Error(t, err) } func Test_authenticationClient_ExchangeACRRefreshTokenForACRAccessToken(t *testing.T) { startRecording(t) endpoint, cred, options := getEndpointCredAndClientOptions(t) - client := newAuthenticationClient(endpoint, &authenticationClientOptions{ClientOptions: options}) + client, err := newAuthenticationClient(endpoint, &authenticationClientOptions{ClientOptions: options}) + require.NoError(t, err) ctx := context.Background() if reflect.ValueOf(options.Cloud).IsZero() { options.Cloud = cloud.AzurePublic @@ -91,9 +95,10 @@ func Test_authenticationClient_ExchangeACRRefreshTokenForACRAccessToken(t *testi func Test_authenticationClient_ExchangeACRRefreshTokenForACRAccessToken_fail(t *testing.T) { startRecording(t) endpoint, _, options := getEndpointCredAndClientOptions(t) - client := newAuthenticationClient(endpoint, &authenticationClientOptions{ClientOptions: options}) + client, err := newAuthenticationClient(endpoint, &authenticationClientOptions{ClientOptions: options}) + require.NoError(t, err) ctx := context.Background() - _, err := client.ExchangeACRRefreshTokenForACRAccessToken(ctx, strings.TrimPrefix(endpoint, "https://"), "registry:catalog:*", "wrong token", &authenticationClientExchangeACRRefreshTokenForACRAccessTokenOptions{GrantType: to.Ptr(tokenGrantTypeRefreshToken)}) + _, err = client.ExchangeACRRefreshTokenForACRAccessToken(ctx, strings.TrimPrefix(endpoint, "https://"), "registry:catalog:*", "wrong token", &authenticationClientExchangeACRRefreshTokenForACRAccessTokenOptions{GrantType: to.Ptr(tokenGrantTypeRefreshToken)}) require.Error(t, err) } @@ -101,8 +106,9 @@ func Test_authenticationClient_ExchangeACRRefreshTokenForACRAccessToken_error(t srv, closeServer := mock.NewServer() defer closeServer() srv.AppendResponse(mock.WithStatusCode(http.StatusOK), mock.WithBody([]byte("wrong response"))) - client := newAuthenticationClient(srv.URL(), &authenticationClientOptions{ClientOptions: azcore.ClientOptions{Transport: srv}}) + client, err := newAuthenticationClient(srv.URL(), &authenticationClientOptions{ClientOptions: azcore.ClientOptions{Transport: srv}}) + require.NoError(t, err) ctx := context.Background() - _, err := client.ExchangeACRRefreshTokenForACRAccessToken(ctx, "service", "scope", "refresh token", nil) + _, err = client.ExchangeACRRefreshTokenForACRAccessToken(ctx, "service", "scope", "refresh token", nil) require.Error(t, err) } diff --git a/sdk/containers/azcontainerregistry/authentication_custom_client.go b/sdk/containers/azcontainerregistry/authentication_custom_client.go index 6083d6afa54f..f8bf0fa80b1a 100644 --- a/sdk/containers/azcontainerregistry/authentication_custom_client.go +++ b/sdk/containers/azcontainerregistry/authentication_custom_client.go @@ -19,16 +19,19 @@ type authenticationClientOptions struct { // newAuthenticationClient creates a new instance of AuthenticationClient with the specified values. // - endpoint - Registry login URL // - options - Client options, pass nil to accept the default values. -func newAuthenticationClient(endpoint string, options *authenticationClientOptions) *authenticationClient { +func newAuthenticationClient(endpoint string, options *authenticationClientOptions) (*authenticationClient, error) { if options == nil { options = &authenticationClientOptions{} } - pipeline := runtime.NewPipeline(moduleName, moduleVersion, runtime.PipelineOptions{}, &options.ClientOptions) + azcoreClient, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{}, &options.ClientOptions) + if err != nil { + return nil, err + } client := &authenticationClient{ + internal: azcoreClient, endpoint: endpoint, - pl: pipeline, } - return client + return client, nil } diff --git a/sdk/containers/azcontainerregistry/authentication_custom_client_test.go b/sdk/containers/azcontainerregistry/authentication_custom_client_test.go index 133cfac0c60d..a1ce580b9c89 100644 --- a/sdk/containers/azcontainerregistry/authentication_custom_client_test.go +++ b/sdk/containers/azcontainerregistry/authentication_custom_client_test.go @@ -12,6 +12,7 @@ import ( ) func Test_newAuthenticationClient(t *testing.T) { - client := newAuthenticationClient("test", nil) + client, err := newAuthenticationClient("test", nil) + require.NoError(t, err) require.NotNil(t, client) } diff --git a/sdk/containers/azcontainerregistry/authentication_policy_test.go b/sdk/containers/azcontainerregistry/authentication_policy_test.go index dcf5f79dcfda..5847558422cd 100644 --- a/sdk/containers/azcontainerregistry/authentication_policy_test.go +++ b/sdk/containers/azcontainerregistry/authentication_policy_test.go @@ -131,7 +131,8 @@ func Test_authenticationPolicy_getAccessToken_live(t *testing.T) { if reflect.ValueOf(options.Cloud).IsZero() { options.Cloud = cloud.AzurePublic } - authClient := newAuthenticationClient(endpoint, &authenticationClientOptions{options}) + authClient, err := newAuthenticationClient(endpoint, &authenticationClientOptions{options}) + require.NoError(t, err) p := &authenticationPolicy{ temporal.NewResource(acquireRefreshToken), atomic.Value{}, @@ -154,7 +155,8 @@ func Test_authenticationPolicy_getAccessToken_error(t *testing.T) { srv.AppendResponse(mock.WithStatusCode(http.StatusOK), mock.WithBody([]byte("{\"refresh_token\": \".eyJqdGkiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDAiLCJzdWIiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDAiLCJuYmYiOjQ2NzA0MTEyMTIsImV4cCI6NDY3MDQyMjkxMiwiaWF0Ijo0NjcwNDExMjEyLCJpc3MiOiJBenVyZSBDb250YWluZXIgUmVnaXN0cnkiLCJhdWQiOiJhemFjcmxpdmV0ZXN0LmF6dXJlY3IuaW8iLCJ2ZXJzaW9uIjoiMS4wIiwicmlkIjoiMDAwMCIsImdyYW50X3R5cGUiOiJyZWZyZXNoX3Rva2VuIiwiYXBwaWQiOiIwMDAwMDAwMC0wMDAwLTAwMDAtMDAwMC0wMDAwMDAwMDAwMDAiLCJwZXJtaXNzaW9ucyI6eyJBY3Rpb25zIjpbInJlYWQiLCJ3cml0ZSIsImRlbGV0ZSIsImRlbGV0ZWQvcmVhZCIsImRlbGV0ZWQvcmVzdG9yZS9hY3Rpb24iXSwiTm90QWN0aW9ucyI6bnVsbH0sInJvbGVzIjpbXX0.\"}"))) srv.AppendResponse(mock.WithStatusCode(http.StatusOK), mock.WithBody([]byte("wrong response"))) srv.AppendResponse(mock.WithStatusCode(http.StatusOK), mock.WithBody([]byte("wrong response"))) - authClient := newAuthenticationClient(srv.URL(), &authenticationClientOptions{ClientOptions: azcore.ClientOptions{Transport: srv}}) + authClient, err := newAuthenticationClient(srv.URL(), &authenticationClientOptions{ClientOptions: azcore.ClientOptions{Transport: srv}}) + require.NoError(t, err) p := &authenticationPolicy{ temporal.NewResource(acquireRefreshToken), @@ -179,7 +181,8 @@ func Test_authenticationPolicy_getAccessToken_error(t *testing.T) { func Test_authenticationPolicy_getAccessToken_live_anonymous(t *testing.T) { startRecording(t) endpoint, _, options := getEndpointCredAndClientOptions(t) - authClient := newAuthenticationClient(endpoint, &authenticationClientOptions{options}) + authClient, err := newAuthenticationClient(endpoint, &authenticationClientOptions{options}) + require.NoError(t, err) p := &authenticationPolicy{ refreshTokenCache: temporal.NewResource(acquireRefreshToken), authClient: authClient, @@ -237,7 +240,8 @@ func Test_authenticationPolicy(t *testing.T) { srv.AppendResponse(mock.WithStatusCode(http.StatusOK), mock.WithBody([]byte("{\"access_token\": \"test\"}"))) srv.AppendResponse(mock.WithStatusCode(http.StatusOK)) - authClient := newAuthenticationClient(srv.URL(), &authenticationClientOptions{ClientOptions: azcore.ClientOptions{Transport: srv}}) + authClient, err := newAuthenticationClient(srv.URL(), &authenticationClientOptions{ClientOptions: azcore.ClientOptions{Transport: srv}}) + require.NoError(t, err) authPolicy := &authenticationPolicy{ temporal.NewResource(acquireRefreshToken), atomic.Value{}, diff --git a/sdk/containers/azcontainerregistry/autorest.md b/sdk/containers/azcontainerregistry/autorest.md index ff1d683e0641..fa2c270a4c86 100644 --- a/sdk/containers/azcontainerregistry/autorest.md +++ b/sdk/containers/azcontainerregistry/autorest.md @@ -12,9 +12,12 @@ clear-output-folder: false export-clients: true openapi-type: "data-plane" output-folder: ../azcontainerregistry -use: "@autorest/go@4.0.0-preview.45" +use: "@autorest/go@4.0.0-preview.60" honor-body-placement: true remove-unreferenced-types: true +module-name: sdk/containers/azcontainerregistry +module: github.com/Azure/azure-sdk-for-go/$(module-name) +inject-spans: true ``` ## Customizations @@ -328,10 +331,11 @@ directive: transform: return $.replaceAll(/AuthenticationClient/g, "authenticationClient").replace(/AcrRefreshToken\n/, "acrRefreshToken\n").replace(/AcrAccessToken\n/, "acrAccessToken\n"); - from: - models.go + - options.go where: $ transform: return $.replaceAll(/AuthenticationClient/g, "authenticationClient").replace(/AcrRefreshToken struct/, "acrRefreshToken struct").replace(/AcrAccessToken struct/, "acrAccessToken struct"); - from: - - models.go + - options.go where: $ transform: return $.replace(/TokenGrantType/, "tokenGrantType"); - from: @@ -444,7 +448,7 @@ directive: }); - from: - blob_client.go - - models.go + - options.go where: $ transform: return $.replaceAll(/BlobClientUploadChunkOptions/g, "blobClientUploadChunkOptions").replace(/BlobClient\.UploadChunk/, "BlobClient.uploadChunk"); ``` diff --git a/sdk/containers/azcontainerregistry/blob_client.go b/sdk/containers/azcontainerregistry/blob_client.go index 5c438d21a74e..6c1d8962862c 100644 --- a/sdk/containers/azcontainerregistry/blob_client.go +++ b/sdk/containers/azcontainerregistry/blob_client.go @@ -3,15 +3,15 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package azcontainerregistry import ( "context" "errors" + "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" "io" @@ -22,10 +22,10 @@ import ( ) // BlobClient contains the methods for the ContainerRegistryBlob group. -// Don't use this type directly, use NewBlobClient() instead. +// Don't use this type directly, use a constructor function instead. type BlobClient struct { + internal *azcore.Client endpoint string - pl runtime.Pipeline } // CancelUpload - Cancel outstanding upload processes, releasing associated resources. If this is not called, the unfinished @@ -36,16 +36,20 @@ type BlobClient struct { // - location - Link acquired from upload start or previous chunk. Note, do not include initial / (must do substring(1) ) // - options - BlobClientCancelUploadOptions contains the optional parameters for the BlobClient.CancelUpload method. func (client *BlobClient) CancelUpload(ctx context.Context, location string, options *BlobClientCancelUploadOptions) (BlobClientCancelUploadResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "BlobClient.CancelUpload", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.cancelUploadCreateRequest(ctx, location, options) if err != nil { return BlobClientCancelUploadResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobClientCancelUploadResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusNoContent) { - return BlobClientCancelUploadResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return BlobClientCancelUploadResponse{}, err } return BlobClientCancelUploadResponse{}, nil } @@ -70,18 +74,23 @@ func (client *BlobClient) cancelUploadCreateRequest(ctx context.Context, locatio // - digest - Digest of a BLOB // - options - BlobClientCheckBlobExistsOptions contains the optional parameters for the BlobClient.CheckBlobExists method. func (client *BlobClient) CheckBlobExists(ctx context.Context, name string, digest string, options *BlobClientCheckBlobExistsOptions) (BlobClientCheckBlobExistsResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "BlobClient.CheckBlobExists", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.checkBlobExistsCreateRequest(ctx, name, digest, options) if err != nil { return BlobClientCheckBlobExistsResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobClientCheckBlobExistsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobClientCheckBlobExistsResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BlobClientCheckBlobExistsResponse{}, err } - return client.checkBlobExistsHandleResponse(resp) + resp, err := client.checkBlobExistsHandleResponse(httpResp) + return resp, err } // checkBlobExistsCreateRequest creates the CheckBlobExists request. @@ -128,18 +137,23 @@ func (client *BlobClient) checkBlobExistsHandleResponse(resp *http.Response) (Bl // - rangeParam - Format : bytes=-, HTTP Range header specifying blob chunk. // - options - BlobClientCheckChunkExistsOptions contains the optional parameters for the BlobClient.CheckChunkExists method. func (client *BlobClient) CheckChunkExists(ctx context.Context, name string, digest string, rangeParam string, options *BlobClientCheckChunkExistsOptions) (BlobClientCheckChunkExistsResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "BlobClient.CheckChunkExists", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.checkChunkExistsCreateRequest(ctx, name, digest, rangeParam, options) if err != nil { return BlobClientCheckChunkExistsResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobClientCheckChunkExistsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobClientCheckChunkExistsResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BlobClientCheckChunkExistsResponse{}, err } - return client.checkChunkExistsHandleResponse(resp) + resp, err := client.checkChunkExistsHandleResponse(httpResp) + return resp, err } // checkChunkExistsCreateRequest creates the CheckChunkExists request. @@ -187,18 +201,23 @@ func (client *BlobClient) checkChunkExistsHandleResponse(resp *http.Response) (B // - location - Link acquired from upload start or previous chunk. Note, do not include initial / (must do substring(1) ) // - options - BlobClientCompleteUploadOptions contains the optional parameters for the BlobClient.completeUpload method. func (client *BlobClient) completeUpload(ctx context.Context, digest string, location string, options *BlobClientCompleteUploadOptions) (BlobClientCompleteUploadResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "BlobClient.CompleteUpload", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.completeUploadCreateRequest(ctx, digest, location, options) if err != nil { return BlobClientCompleteUploadResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobClientCompleteUploadResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return BlobClientCompleteUploadResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return BlobClientCompleteUploadResponse{}, err } - return client.completeUploadHandleResponse(resp) + resp, err := client.completeUploadHandleResponse(httpResp) + return resp, err } // completeUploadCreateRequest creates the completeUpload request. @@ -219,15 +238,15 @@ func (client *BlobClient) completeUploadCreateRequest(ctx context.Context, diges // completeUploadHandleResponse handles the completeUpload response. func (client *BlobClient) completeUploadHandleResponse(resp *http.Response) (BlobClientCompleteUploadResponse, error) { result := BlobClientCompleteUploadResponse{} + if val := resp.Header.Get("Docker-Content-Digest"); val != "" { + result.DockerContentDigest = &val + } if val := resp.Header.Get("Location"); val != "" { result.Location = &val } if val := resp.Header.Get("Range"); val != "" { result.Range = &val } - if val := resp.Header.Get("Docker-Content-Digest"); val != "" { - result.DockerContentDigest = &val - } return result, nil } @@ -239,18 +258,23 @@ func (client *BlobClient) completeUploadHandleResponse(resp *http.Response) (Blo // - digest - Digest of a BLOB // - options - BlobClientDeleteBlobOptions contains the optional parameters for the BlobClient.DeleteBlob method. func (client *BlobClient) DeleteBlob(ctx context.Context, name string, digest string, options *BlobClientDeleteBlobOptions) (BlobClientDeleteBlobResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "BlobClient.DeleteBlob", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.deleteBlobCreateRequest(ctx, name, digest, options) if err != nil { return BlobClientDeleteBlobResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobClientDeleteBlobResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return BlobClientDeleteBlobResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return BlobClientDeleteBlobResponse{}, err } - return client.deleteBlobHandleResponse(resp) + resp, err := client.deleteBlobHandleResponse(httpResp) + return resp, err } // deleteBlobCreateRequest creates the DeleteBlob request. @@ -288,18 +312,23 @@ func (client *BlobClient) deleteBlobHandleResponse(resp *http.Response) (BlobCli // - digest - Digest of a BLOB // - options - BlobClientGetBlobOptions contains the optional parameters for the BlobClient.GetBlob method. func (client *BlobClient) GetBlob(ctx context.Context, name string, digest string, options *BlobClientGetBlobOptions) (BlobClientGetBlobResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "BlobClient.GetBlob", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getBlobCreateRequest(ctx, name, digest, options) if err != nil { return BlobClientGetBlobResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobClientGetBlobResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return BlobClientGetBlobResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return BlobClientGetBlobResponse{}, err } - return client.getBlobHandleResponse(resp) + resp, err := client.getBlobHandleResponse(httpResp) + return resp, err } // getBlobCreateRequest creates the GetBlob request. @@ -349,18 +378,23 @@ func (client *BlobClient) getBlobHandleResponse(resp *http.Response) (BlobClient // - rangeParam - Format : bytes=-, HTTP Range header specifying blob chunk. // - options - BlobClientGetChunkOptions contains the optional parameters for the BlobClient.GetChunk method. func (client *BlobClient) GetChunk(ctx context.Context, name string, digest string, rangeParam string, options *BlobClientGetChunkOptions) (BlobClientGetChunkResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "BlobClient.GetChunk", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getChunkCreateRequest(ctx, name, digest, rangeParam, options) if err != nil { return BlobClientGetChunkResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobClientGetChunkResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusPartialContent) { - return BlobClientGetChunkResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusPartialContent) { + err = runtime.NewResponseError(httpResp) + return BlobClientGetChunkResponse{}, err } - return client.getChunkHandleResponse(resp) + resp, err := client.getChunkHandleResponse(httpResp) + return resp, err } // getChunkCreateRequest creates the GetChunk request. @@ -408,18 +442,23 @@ func (client *BlobClient) getChunkHandleResponse(resp *http.Response) (BlobClien // - location - Link acquired from upload start or previous chunk. Note, do not include initial / (must do substring(1) ) // - options - BlobClientGetUploadStatusOptions contains the optional parameters for the BlobClient.GetUploadStatus method. func (client *BlobClient) GetUploadStatus(ctx context.Context, location string, options *BlobClientGetUploadStatusOptions) (BlobClientGetUploadStatusResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "BlobClient.GetUploadStatus", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getUploadStatusCreateRequest(ctx, location, options) if err != nil { return BlobClientGetUploadStatusResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobClientGetUploadStatusResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusNoContent) { - return BlobClientGetUploadStatusResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return BlobClientGetUploadStatusResponse{}, err } - return client.getUploadStatusHandleResponse(resp) + resp, err := client.getUploadStatusHandleResponse(httpResp) + return resp, err } // getUploadStatusCreateRequest creates the GetUploadStatus request. @@ -437,12 +476,12 @@ func (client *BlobClient) getUploadStatusCreateRequest(ctx context.Context, loca // getUploadStatusHandleResponse handles the GetUploadStatus response. func (client *BlobClient) getUploadStatusHandleResponse(resp *http.Response) (BlobClientGetUploadStatusResponse, error) { result := BlobClientGetUploadStatusResponse{} - if val := resp.Header.Get("Range"); val != "" { - result.Range = &val - } if val := resp.Header.Get("Docker-Upload-UUID"); val != "" { result.DockerUploadUUID = &val } + if val := resp.Header.Get("Range"); val != "" { + result.Range = &val + } return result, nil } @@ -455,18 +494,23 @@ func (client *BlobClient) getUploadStatusHandleResponse(resp *http.Response) (Bl // - mount - Digest of blob to mount from the source repository. // - options - BlobClientMountBlobOptions contains the optional parameters for the BlobClient.MountBlob method. func (client *BlobClient) MountBlob(ctx context.Context, name string, from string, mount string, options *BlobClientMountBlobOptions) (BlobClientMountBlobResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "BlobClient.MountBlob", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.mountBlobCreateRequest(ctx, name, from, mount, options) if err != nil { return BlobClientMountBlobResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobClientMountBlobResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated, http.StatusAccepted) { - return BlobClientMountBlobResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return BlobClientMountBlobResponse{}, err } - return client.mountBlobHandleResponse(resp) + resp, err := client.mountBlobHandleResponse(httpResp) + return resp, err } // mountBlobCreateRequest creates the MountBlob request. @@ -491,14 +535,14 @@ func (client *BlobClient) mountBlobCreateRequest(ctx context.Context, name strin // mountBlobHandleResponse handles the MountBlob response. func (client *BlobClient) mountBlobHandleResponse(resp *http.Response) (BlobClientMountBlobResponse, error) { result := BlobClientMountBlobResponse{} - if val := resp.Header.Get("Location"); val != "" { - result.Location = &val + if val := resp.Header.Get("Docker-Content-Digest"); val != "" { + result.DockerContentDigest = &val } if val := resp.Header.Get("Docker-Upload-UUID"); val != "" { result.DockerUploadUUID = &val } - if val := resp.Header.Get("Docker-Content-Digest"); val != "" { - result.DockerContentDigest = &val + if val := resp.Header.Get("Location"); val != "" { + result.Location = &val } return result, nil } @@ -510,18 +554,23 @@ func (client *BlobClient) mountBlobHandleResponse(resp *http.Response) (BlobClie // - name - Name of the image (including the namespace) // - options - BlobClientStartUploadOptions contains the optional parameters for the BlobClient.StartUpload method. func (client *BlobClient) StartUpload(ctx context.Context, name string, options *BlobClientStartUploadOptions) (BlobClientStartUploadResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "BlobClient.StartUpload", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.startUploadCreateRequest(ctx, name, options) if err != nil { return BlobClientStartUploadResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobClientStartUploadResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return BlobClientStartUploadResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return BlobClientStartUploadResponse{}, err } - return client.startUploadHandleResponse(resp) + resp, err := client.startUploadHandleResponse(httpResp) + return resp, err } // startUploadCreateRequest creates the StartUpload request. @@ -542,15 +591,15 @@ func (client *BlobClient) startUploadCreateRequest(ctx context.Context, name str // startUploadHandleResponse handles the StartUpload response. func (client *BlobClient) startUploadHandleResponse(resp *http.Response) (BlobClientStartUploadResponse, error) { result := BlobClientStartUploadResponse{} + if val := resp.Header.Get("Docker-Upload-UUID"); val != "" { + result.DockerUploadUUID = &val + } if val := resp.Header.Get("Location"); val != "" { result.Location = &val } if val := resp.Header.Get("Range"); val != "" { result.Range = &val } - if val := resp.Header.Get("Docker-Upload-UUID"); val != "" { - result.DockerUploadUUID = &val - } return result, nil } @@ -562,18 +611,23 @@ func (client *BlobClient) startUploadHandleResponse(resp *http.Response) (BlobCl // - chunkData - Raw data of blob // - options - blobClientUploadChunkOptions contains the optional parameters for the BlobClient.uploadChunk method. func (client *BlobClient) uploadChunk(ctx context.Context, location string, chunkData io.ReadSeekCloser, options *blobClientUploadChunkOptions) (BlobClientUploadChunkResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "BlobClient.uploadChunk", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.uploadChunkCreateRequest(ctx, location, chunkData, options) if err != nil { return BlobClientUploadChunkResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return BlobClientUploadChunkResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return BlobClientUploadChunkResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return BlobClientUploadChunkResponse{}, err } - return client.uploadChunkHandleResponse(resp) + resp, err := client.uploadChunkHandleResponse(httpResp) + return resp, err } // uploadChunkCreateRequest creates the uploadChunk request. @@ -588,20 +642,23 @@ func (client *BlobClient) uploadChunkCreateRequest(ctx context.Context, location req.Raw().Header["Content-Range"] = []string{*options.ContentRange} } req.Raw().Header["Accept"] = []string{"application/json"} - return req, req.SetBody(chunkData, "application/octet-stream") + if err := req.SetBody(chunkData, "application/octet-stream"); err != nil { + return nil, err + } + return req, nil } // uploadChunkHandleResponse handles the uploadChunk response. func (client *BlobClient) uploadChunkHandleResponse(resp *http.Response) (BlobClientUploadChunkResponse, error) { result := BlobClientUploadChunkResponse{} + if val := resp.Header.Get("Docker-Upload-UUID"); val != "" { + result.DockerUploadUUID = &val + } if val := resp.Header.Get("Location"); val != "" { result.Location = &val } if val := resp.Header.Get("Range"); val != "" { result.Range = &val } - if val := resp.Header.Get("Docker-Upload-UUID"); val != "" { - result.DockerUploadUUID = &val - } return result, nil } diff --git a/sdk/containers/azcontainerregistry/blob_client_test.go b/sdk/containers/azcontainerregistry/blob_client_test.go index 635a446993b5..b4b2e30727a6 100644 --- a/sdk/containers/azcontainerregistry/blob_client_test.go +++ b/sdk/containers/azcontainerregistry/blob_client_test.go @@ -10,6 +10,7 @@ import ( "bytes" "context" "fmt" + "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" "github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming" @@ -176,10 +177,11 @@ func TestBlobClient_GetBlob_wrongDigest(t *testing.T) { defer closeServer() srv.AppendResponse(mock.WithStatusCode(http.StatusOK), mock.WithBody([]byte("test"))) - pl := runtime.NewPipeline(moduleName, moduleVersion, runtime.PipelineOptions{}, &policy.ClientOptions{Transport: srv}) + azcoreClient, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{}, &policy.ClientOptions{Transport: srv}) + require.NoError(t, err) client := &BlobClient{ + azcoreClient, srv.URL(), - pl, } ctx := context.Background() resp, err := client.GetBlob(ctx, "name", "sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08", nil) @@ -335,13 +337,14 @@ func TestBlobClient_StartUpload_empty(t *testing.T) { } func TestBlobClient_wrongEndpoint(t *testing.T) { - pl := runtime.NewPipeline(moduleName, moduleVersion, runtime.PipelineOptions{}, nil) + azcoreClient, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{}, nil) + require.NoError(t, err) client := &BlobClient{ + azcoreClient, "wrong-endpoint", - pl, } ctx := context.Background() - _, err := client.CancelUpload(ctx, "location", nil) + _, err = client.CancelUpload(ctx, "location", nil) require.Error(t, err) _, err = client.CheckBlobExists(ctx, "name", "digest", nil) require.Error(t, err) diff --git a/sdk/containers/azcontainerregistry/blob_custom_client.go b/sdk/containers/azcontainerregistry/blob_custom_client.go index f7ce95d65c09..fc79bbe43663 100644 --- a/sdk/containers/azcontainerregistry/blob_custom_client.go +++ b/sdk/containers/azcontainerregistry/blob_custom_client.go @@ -41,9 +41,13 @@ func NewBlobClient(endpoint string, credential azcore.TokenCredential, options * return nil, errors.New("provided Cloud field is missing Azure Container Registry configuration") } - authClient := newAuthenticationClient(endpoint, &authenticationClientOptions{ + authClient, err := newAuthenticationClient(endpoint, &authenticationClientOptions{ options.ClientOptions, }) + if err != nil { + return nil, err + } + authPolicy := newAuthenticationPolicy( credential, []string{c.Audience + "/.default"}, @@ -51,10 +55,14 @@ func NewBlobClient(endpoint string, credential azcore.TokenCredential, options * nil, ) - pl := runtime.NewPipeline(moduleName, moduleVersion, runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}}, &options.ClientOptions) + azcoreClient, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}}, &options.ClientOptions) + if err != nil { + return nil, err + } + return &BlobClient{ + azcoreClient, endpoint, - pl, }, nil } diff --git a/sdk/containers/azcontainerregistry/blob_custom_client_test.go b/sdk/containers/azcontainerregistry/blob_custom_client_test.go index a1721077c132..feab78a9bc1e 100644 --- a/sdk/containers/azcontainerregistry/blob_custom_client_test.go +++ b/sdk/containers/azcontainerregistry/blob_custom_client_test.go @@ -150,15 +150,16 @@ func TestBlobClient_UploadChunk_retry(t *testing.T) { srv.AppendResponse(mock.WithStatusCode(http.StatusGatewayTimeout)) srv.AppendResponse(mock.WithStatusCode(http.StatusAccepted)) - pl := runtime.NewPipeline(moduleName, moduleVersion, runtime.PipelineOptions{}, &policy.ClientOptions{Transport: srv}) + azcoreClient, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{}, &policy.ClientOptions{Transport: srv}) + require.NoError(t, err) client := &BlobClient{ + azcoreClient, srv.URL(), - pl, } ctx := context.Background() chunkData := bytes.NewReader([]byte("test")) calculator := NewBlobDigestCalculator() - _, err := client.UploadChunk(ctx, "location", chunkData, calculator, nil) + _, err = client.UploadChunk(ctx, "location", chunkData, calculator, nil) require.NoError(t, err) require.Equal(t, "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08", fmt.Sprintf("%x", calculator.h.Sum(nil))) } diff --git a/sdk/containers/azcontainerregistry/client.go b/sdk/containers/azcontainerregistry/client.go index 2dd119a1c311..bcc0d067c499 100644 --- a/sdk/containers/azcontainerregistry/client.go +++ b/sdk/containers/azcontainerregistry/client.go @@ -3,15 +3,15 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package azcontainerregistry import ( "context" "errors" + "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" "io" @@ -22,10 +22,10 @@ import ( ) // Client contains the methods for the ContainerRegistry group. -// Don't use this type directly, use NewClient() instead. +// Don't use this type directly, use a constructor function instead. type Client struct { + internal *azcore.Client endpoint string - pl runtime.Pipeline } // DeleteManifest - Delete the manifest identified by name and reference. Note that a manifest can only be deleted by digest. @@ -36,16 +36,20 @@ type Client struct { // - digest - Digest of a BLOB // - options - ClientDeleteManifestOptions contains the optional parameters for the Client.DeleteManifest method. func (client *Client) DeleteManifest(ctx context.Context, name string, digest string, options *ClientDeleteManifestOptions) (ClientDeleteManifestResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "Client.DeleteManifest", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.deleteManifestCreateRequest(ctx, name, digest, options) if err != nil { return ClientDeleteManifestResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientDeleteManifestResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNotFound) { - return ClientDeleteManifestResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNotFound) { + err = runtime.NewResponseError(httpResp) + return ClientDeleteManifestResponse{}, err } return ClientDeleteManifestResponse{}, nil } @@ -76,16 +80,20 @@ func (client *Client) deleteManifestCreateRequest(ctx context.Context, name stri // - name - Name of the image (including the namespace) // - options - ClientDeleteRepositoryOptions contains the optional parameters for the Client.DeleteRepository method. func (client *Client) DeleteRepository(ctx context.Context, name string, options *ClientDeleteRepositoryOptions) (ClientDeleteRepositoryResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "Client.DeleteRepository", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.deleteRepositoryCreateRequest(ctx, name, options) if err != nil { return ClientDeleteRepositoryResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientDeleteRepositoryResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNotFound) { - return ClientDeleteRepositoryResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNotFound) { + err = runtime.NewResponseError(httpResp) + return ClientDeleteRepositoryResponse{}, err } return ClientDeleteRepositoryResponse{}, nil } @@ -116,16 +124,20 @@ func (client *Client) deleteRepositoryCreateRequest(ctx context.Context, name st // - tag - Tag name // - options - ClientDeleteTagOptions contains the optional parameters for the Client.DeleteTag method. func (client *Client) DeleteTag(ctx context.Context, name string, tag string, options *ClientDeleteTagOptions) (ClientDeleteTagResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "Client.DeleteTag", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.deleteTagCreateRequest(ctx, name, tag, options) if err != nil { return ClientDeleteTagResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientDeleteTagResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNotFound) { - return ClientDeleteTagResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNotFound) { + err = runtime.NewResponseError(httpResp) + return ClientDeleteTagResponse{}, err } return ClientDeleteTagResponse{}, nil } @@ -160,18 +172,23 @@ func (client *Client) deleteTagCreateRequest(ctx context.Context, name string, t // - reference - A tag or a digest, pointing to a specific image // - options - ClientGetManifestOptions contains the optional parameters for the Client.GetManifest method. func (client *Client) GetManifest(ctx context.Context, name string, reference string, options *ClientGetManifestOptions) (ClientGetManifestResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "Client.GetManifest", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getManifestCreateRequest(ctx, name, reference, options) if err != nil { return ClientGetManifestResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientGetManifestResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ClientGetManifestResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetManifestResponse{}, err } - return client.getManifestHandleResponse(resp) + resp, err := client.getManifestHandleResponse(httpResp) + return resp, err } // getManifestCreateRequest creates the GetManifest request. @@ -214,18 +231,23 @@ func (client *Client) getManifestHandleResponse(resp *http.Response) (ClientGetM // - digest - Digest of a BLOB // - options - ClientGetManifestPropertiesOptions contains the optional parameters for the Client.GetManifestProperties method. func (client *Client) GetManifestProperties(ctx context.Context, name string, digest string, options *ClientGetManifestPropertiesOptions) (ClientGetManifestPropertiesResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "Client.GetManifestProperties", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getManifestPropertiesCreateRequest(ctx, name, digest, options) if err != nil { return ClientGetManifestPropertiesResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientGetManifestPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ClientGetManifestPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetManifestPropertiesResponse{}, err } - return client.getManifestPropertiesHandleResponse(resp) + resp, err := client.getManifestPropertiesHandleResponse(httpResp) + return resp, err } // getManifestPropertiesCreateRequest creates the GetManifestProperties request. @@ -267,18 +289,23 @@ func (client *Client) getManifestPropertiesHandleResponse(resp *http.Response) ( // - options - ClientGetRepositoryPropertiesOptions contains the optional parameters for the Client.GetRepositoryProperties // method. func (client *Client) GetRepositoryProperties(ctx context.Context, name string, options *ClientGetRepositoryPropertiesOptions) (ClientGetRepositoryPropertiesResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "Client.GetRepositoryProperties", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getRepositoryPropertiesCreateRequest(ctx, name, options) if err != nil { return ClientGetRepositoryPropertiesResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientGetRepositoryPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ClientGetRepositoryPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetRepositoryPropertiesResponse{}, err } - return client.getRepositoryPropertiesHandleResponse(resp) + resp, err := client.getRepositoryPropertiesHandleResponse(httpResp) + return resp, err } // getRepositoryPropertiesCreateRequest creates the GetRepositoryProperties request. @@ -316,18 +343,23 @@ func (client *Client) getRepositoryPropertiesHandleResponse(resp *http.Response) // - tag - Tag name // - options - ClientGetTagPropertiesOptions contains the optional parameters for the Client.GetTagProperties method. func (client *Client) GetTagProperties(ctx context.Context, name string, tag string, options *ClientGetTagPropertiesOptions) (ClientGetTagPropertiesResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "Client.GetTagProperties", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getTagPropertiesCreateRequest(ctx, name, tag, options) if err != nil { return ClientGetTagPropertiesResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientGetTagPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ClientGetTagPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientGetTagPropertiesResponse{}, err } - return client.getTagPropertiesHandleResponse(resp) + resp, err := client.getTagPropertiesHandleResponse(httpResp) + return resp, err } // getTagPropertiesCreateRequest creates the GetTagProperties request. @@ -372,25 +404,19 @@ func (client *Client) NewListManifestsPager(name string, options *ClientListMani return page.Link != nil && len(*page.Link) > 0 }, Fetcher: func(ctx context.Context, page *ClientListManifestsResponse) (ClientListManifestsResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listManifestsCreateRequest(ctx, name, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.Link) + nextLink := "" + if page != nil { + nextLink = *page.Link } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listManifestsCreateRequest(ctx, name, options) + }, nil) if err != nil { return ClientListManifestsResponse{}, err } - resp, err := client.pl.Do(req) - if err != nil { - return ClientListManifestsResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ClientListManifestsResponse{}, runtime.NewResponseError(resp) - } return client.listManifestsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -444,25 +470,19 @@ func (client *Client) NewListRepositoriesPager(options *ClientListRepositoriesOp return page.Link != nil && len(*page.Link) > 0 }, Fetcher: func(ctx context.Context, page *ClientListRepositoriesResponse) (ClientListRepositoriesResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listRepositoriesCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.Link) + nextLink := "" + if page != nil { + nextLink = *page.Link } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listRepositoriesCreateRequest(ctx, options) + }, nil) if err != nil { return ClientListRepositoriesResponse{}, err } - resp, err := client.pl.Do(req) - if err != nil { - return ClientListRepositoriesResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ClientListRepositoriesResponse{}, runtime.NewResponseError(resp) - } return client.listRepositoriesHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -510,25 +530,19 @@ func (client *Client) NewListTagsPager(name string, options *ClientListTagsOptio return page.Link != nil && len(*page.Link) > 0 }, Fetcher: func(ctx context.Context, page *ClientListTagsResponse) (ClientListTagsResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listTagsCreateRequest(ctx, name, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.Link) - } - if err != nil { - return ClientListTagsResponse{}, err + nextLink := "" + if page != nil { + nextLink = *page.Link } - resp, err := client.pl.Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listTagsCreateRequest(ctx, name, options) + }, nil) if err != nil { return ClientListTagsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ClientListTagsResponse{}, runtime.NewResponseError(resp) - } return client.listTagsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -584,18 +598,23 @@ func (client *Client) listTagsHandleResponse(resp *http.Response) (ClientListTag // - options - ClientUpdateManifestPropertiesOptions contains the optional parameters for the Client.UpdateManifestProperties // method. func (client *Client) UpdateManifestProperties(ctx context.Context, name string, digest string, options *ClientUpdateManifestPropertiesOptions) (ClientUpdateManifestPropertiesResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "Client.UpdateManifestProperties", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.updateManifestPropertiesCreateRequest(ctx, name, digest, options) if err != nil { return ClientUpdateManifestPropertiesResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientUpdateManifestPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ClientUpdateManifestPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientUpdateManifestPropertiesResponse{}, err } - return client.updateManifestPropertiesHandleResponse(resp) + resp, err := client.updateManifestPropertiesHandleResponse(httpResp) + return resp, err } // updateManifestPropertiesCreateRequest creates the UpdateManifestProperties request. @@ -618,7 +637,10 @@ func (client *Client) updateManifestPropertiesCreateRequest(ctx context.Context, req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Value != nil { - return req, runtime.MarshalAsJSON(req, *options.Value) + if err := runtime.MarshalAsJSON(req, *options.Value); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -640,18 +662,23 @@ func (client *Client) updateManifestPropertiesHandleResponse(resp *http.Response // - options - ClientUpdateRepositoryPropertiesOptions contains the optional parameters for the Client.UpdateRepositoryProperties // method. func (client *Client) UpdateRepositoryProperties(ctx context.Context, name string, options *ClientUpdateRepositoryPropertiesOptions) (ClientUpdateRepositoryPropertiesResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "Client.UpdateRepositoryProperties", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.updateRepositoryPropertiesCreateRequest(ctx, name, options) if err != nil { return ClientUpdateRepositoryPropertiesResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientUpdateRepositoryPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ClientUpdateRepositoryPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientUpdateRepositoryPropertiesResponse{}, err } - return client.updateRepositoryPropertiesHandleResponse(resp) + resp, err := client.updateRepositoryPropertiesHandleResponse(httpResp) + return resp, err } // updateRepositoryPropertiesCreateRequest creates the UpdateRepositoryProperties request. @@ -670,7 +697,10 @@ func (client *Client) updateRepositoryPropertiesCreateRequest(ctx context.Contex req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Value != nil { - return req, runtime.MarshalAsJSON(req, *options.Value) + if err := runtime.MarshalAsJSON(req, *options.Value); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -692,18 +722,23 @@ func (client *Client) updateRepositoryPropertiesHandleResponse(resp *http.Respon // - tag - Tag name // - options - ClientUpdateTagPropertiesOptions contains the optional parameters for the Client.UpdateTagProperties method. func (client *Client) UpdateTagProperties(ctx context.Context, name string, tag string, options *ClientUpdateTagPropertiesOptions) (ClientUpdateTagPropertiesResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "Client.UpdateTagProperties", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.updateTagPropertiesCreateRequest(ctx, name, tag, options) if err != nil { return ClientUpdateTagPropertiesResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientUpdateTagPropertiesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ClientUpdateTagPropertiesResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ClientUpdateTagPropertiesResponse{}, err } - return client.updateTagPropertiesHandleResponse(resp) + resp, err := client.updateTagPropertiesHandleResponse(httpResp) + return resp, err } // updateTagPropertiesCreateRequest creates the UpdateTagProperties request. @@ -726,7 +761,10 @@ func (client *Client) updateTagPropertiesCreateRequest(ctx context.Context, name req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Value != nil { - return req, runtime.MarshalAsJSON(req, *options.Value) + if err := runtime.MarshalAsJSON(req, *options.Value); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -750,18 +788,23 @@ func (client *Client) updateTagPropertiesHandleResponse(resp *http.Response) (Cl // - manifestData - Manifest body, can take v1 or v2 values depending on accept header // - options - ClientUploadManifestOptions contains the optional parameters for the Client.UploadManifest method. func (client *Client) UploadManifest(ctx context.Context, name string, reference string, contentType ContentType, manifestData io.ReadSeekCloser, options *ClientUploadManifestOptions) (ClientUploadManifestResponse, error) { + var err error + ctx, endSpan := runtime.StartSpan(ctx, "Client.UploadManifest", client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.uploadManifestCreateRequest(ctx, name, reference, contentType, manifestData, options) if err != nil { return ClientUploadManifestResponse{}, err } - resp, err := client.pl.Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ClientUploadManifestResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusCreated) { - return ClientUploadManifestResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return ClientUploadManifestResponse{}, err } - return client.uploadManifestHandleResponse(resp) + resp, err := client.uploadManifestHandleResponse(httpResp) + return resp, err } // uploadManifestCreateRequest creates the UploadManifest request. @@ -781,18 +824,15 @@ func (client *Client) uploadManifestCreateRequest(ctx context.Context, name stri } req.Raw().Header["Content-Type"] = []string{string(contentType)} req.Raw().Header["Accept"] = []string{"application/json"} - return req, req.SetBody(manifestData, string(contentType)) + if err := req.SetBody(manifestData, string(contentType)); err != nil { + return nil, err + } + return req, nil } // uploadManifestHandleResponse handles the UploadManifest response. func (client *Client) uploadManifestHandleResponse(resp *http.Response) (ClientUploadManifestResponse, error) { result := ClientUploadManifestResponse{} - if val := resp.Header.Get("Docker-Content-Digest"); val != "" { - result.DockerContentDigest = &val - } - if val := resp.Header.Get("Location"); val != "" { - result.Location = &val - } if val := resp.Header.Get("Content-Length"); val != "" { contentLength, err := strconv.ParseInt(val, 10, 64) if err != nil { @@ -800,5 +840,11 @@ func (client *Client) uploadManifestHandleResponse(resp *http.Response) (ClientU } result.ContentLength = &contentLength } + if val := resp.Header.Get("Docker-Content-Digest"); val != "" { + result.DockerContentDigest = &val + } + if val := resp.Header.Get("Location"); val != "" { + result.Location = &val + } return result, nil } diff --git a/sdk/containers/azcontainerregistry/client_test.go b/sdk/containers/azcontainerregistry/client_test.go index b43fe8345733..dff2ae5ee51b 100644 --- a/sdk/containers/azcontainerregistry/client_test.go +++ b/sdk/containers/azcontainerregistry/client_test.go @@ -10,6 +10,7 @@ import ( "bytes" "context" "fmt" + "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" "github.com/Azure/azure-sdk-for-go/sdk/azcore/streaming" @@ -80,13 +81,14 @@ func TestClient_DeleteRepository_error(t *testing.T) { defer closeServer() srv.AppendResponse(mock.WithStatusCode(http.StatusBadRequest)) - pl := runtime.NewPipeline(moduleName, moduleVersion, runtime.PipelineOptions{}, &policy.ClientOptions{Transport: srv}) + azcoreClient, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{}, &policy.ClientOptions{Transport: srv}) + require.NoError(t, err) client := &Client{ + azcoreClient, srv.URL(), - pl, } ctx := context.Background() - _, err := client.DeleteRepository(ctx, "test", nil) + _, err = client.DeleteRepository(ctx, "test", nil) require.Error(t, err) } @@ -115,13 +117,14 @@ func TestClient_DeleteTag_error(t *testing.T) { defer closeServer() srv.AppendResponse(mock.WithStatusCode(http.StatusBadRequest)) - pl := runtime.NewPipeline(moduleName, moduleVersion, runtime.PipelineOptions{}, &policy.ClientOptions{Transport: srv}) + azcoreClient, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{}, &policy.ClientOptions{Transport: srv}) + require.NoError(t, err) client := &Client{ + azcoreClient, srv.URL(), - pl, } ctx := context.Background() - _, err := client.DeleteTag(ctx, "name", "tag", nil) + _, err = client.DeleteTag(ctx, "name", "tag", nil) require.Error(t, err) } @@ -146,10 +149,11 @@ func TestClient_GetManifest_wrongServerDigest(t *testing.T) { defer closeServer() srv.AppendResponse(mock.WithStatusCode(http.StatusOK), mock.WithBody([]byte("test")), mock.WithHeader("Docker-Content-Digest", "sha256:wrong")) - pl := runtime.NewPipeline(moduleName, moduleVersion, runtime.PipelineOptions{}, &policy.ClientOptions{Transport: srv}) + azcoreClient, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{}, &policy.ClientOptions{Transport: srv}) + require.NoError(t, err) client := &Client{ + azcoreClient, srv.URL(), - pl, } ctx := context.Background() resp, err := client.GetManifest(ctx, "name", "sha256:9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08", nil) @@ -395,10 +399,11 @@ func TestClient_NewListRepositoriesPager_error(t *testing.T) { defer closeServer() srv.AppendResponse(mock.WithStatusCode(http.StatusBadRequest)) - pl := runtime.NewPipeline(moduleName, moduleVersion, runtime.PipelineOptions{}, &policy.ClientOptions{Transport: srv}) + azcoreClient, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{}, &policy.ClientOptions{Transport: srv}) + require.NoError(t, err) client := &Client{ + azcoreClient, srv.URL(), - pl, } ctx := context.Background() pager := client.NewListRepositoriesPager(nil) @@ -655,24 +660,26 @@ func TestClient_UploadManifest_error(t *testing.T) { defer closeServer() srv.AppendResponse(mock.WithStatusCode(http.StatusBadRequest)) - pl := runtime.NewPipeline(moduleName, moduleVersion, runtime.PipelineOptions{}, &policy.ClientOptions{Transport: srv}) + azcoreClient, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{}, &policy.ClientOptions{Transport: srv}) + require.NoError(t, err) client := &Client{ + azcoreClient, srv.URL(), - pl, } ctx := context.Background() - _, err := client.UploadManifest(ctx, "name", "reference", "contentType", nil, nil) + _, err = client.UploadManifest(ctx, "name", "reference", "contentType", nil, nil) require.Error(t, err) } func TestClient_wrongEndpoint(t *testing.T) { - pl := runtime.NewPipeline(moduleName, moduleVersion, runtime.PipelineOptions{}, nil) + azcoreClient, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{}, nil) + require.NoError(t, err) client := &Client{ + azcoreClient, "wrong-endpoint", - pl, } ctx := context.Background() - _, err := client.DeleteManifest(ctx, "name", "digest", nil) + _, err = client.DeleteManifest(ctx, "name", "digest", nil) require.Error(t, err) _, err = client.DeleteRepository(ctx, "name", nil) require.Error(t, err) diff --git a/sdk/containers/azcontainerregistry/constants.go b/sdk/containers/azcontainerregistry/constants.go index 304df483ffd1..8dcf5c0b1e85 100644 --- a/sdk/containers/azcontainerregistry/constants.go +++ b/sdk/containers/azcontainerregistry/constants.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package azcontainerregistry @@ -64,22 +63,22 @@ func PossibleArtifactArchitectureValues() []ArtifactArchitecture { type ArtifactManifestOrderBy string const ( - // ArtifactManifestOrderByNone - Do not provide an orderby value in the request. - ArtifactManifestOrderByNone ArtifactManifestOrderBy = "none" - // ArtifactManifestOrderByLastUpdatedOnDescending - Order manifests by LastUpdatedOn field, from most recently updated to - // least recently updated. - ArtifactManifestOrderByLastUpdatedOnDescending ArtifactManifestOrderBy = "timedesc" // ArtifactManifestOrderByLastUpdatedOnAscending - Order manifest by LastUpdatedOn field, from least recently updated to most // recently updated. ArtifactManifestOrderByLastUpdatedOnAscending ArtifactManifestOrderBy = "timeasc" + // ArtifactManifestOrderByLastUpdatedOnDescending - Order manifests by LastUpdatedOn field, from most recently updated to + // least recently updated. + ArtifactManifestOrderByLastUpdatedOnDescending ArtifactManifestOrderBy = "timedesc" + // ArtifactManifestOrderByNone - Do not provide an orderby value in the request. + ArtifactManifestOrderByNone ArtifactManifestOrderBy = "none" ) // PossibleArtifactManifestOrderByValues returns the possible values for the ArtifactManifestOrderBy const type. func PossibleArtifactManifestOrderByValues() []ArtifactManifestOrderBy { return []ArtifactManifestOrderBy{ - ArtifactManifestOrderByNone, - ArtifactManifestOrderByLastUpdatedOnDescending, ArtifactManifestOrderByLastUpdatedOnAscending, + ArtifactManifestOrderByLastUpdatedOnDescending, + ArtifactManifestOrderByNone, } } @@ -127,22 +126,22 @@ func PossibleArtifactOperatingSystemValues() []ArtifactOperatingSystem { type ArtifactTagOrderBy string const ( - // ArtifactTagOrderByNone - Do not provide an orderby value in the request. - ArtifactTagOrderByNone ArtifactTagOrderBy = "none" - // ArtifactTagOrderByLastUpdatedOnDescending - Order tags by LastUpdatedOn field, from most recently updated to least recently - // updated. - ArtifactTagOrderByLastUpdatedOnDescending ArtifactTagOrderBy = "timedesc" // ArtifactTagOrderByLastUpdatedOnAscending - Order tags by LastUpdatedOn field, from least recently updated to most recently // updated. ArtifactTagOrderByLastUpdatedOnAscending ArtifactTagOrderBy = "timeasc" + // ArtifactTagOrderByLastUpdatedOnDescending - Order tags by LastUpdatedOn field, from most recently updated to least recently + // updated. + ArtifactTagOrderByLastUpdatedOnDescending ArtifactTagOrderBy = "timedesc" + // ArtifactTagOrderByNone - Do not provide an orderby value in the request. + ArtifactTagOrderByNone ArtifactTagOrderBy = "none" ) // PossibleArtifactTagOrderByValues returns the possible values for the ArtifactTagOrderBy const type. func PossibleArtifactTagOrderByValues() []ArtifactTagOrderBy { return []ArtifactTagOrderBy{ - ArtifactTagOrderByNone, - ArtifactTagOrderByLastUpdatedOnDescending, ArtifactTagOrderByLastUpdatedOnAscending, + ArtifactTagOrderByLastUpdatedOnDescending, + ArtifactTagOrderByNone, } } @@ -186,14 +185,14 @@ func possiblePostContentSchemaGrantTypeValues() []postContentSchemaGrantType { type tokenGrantType string const ( - tokenGrantTypeRefreshToken tokenGrantType = "refresh_token" tokenGrantTypePassword tokenGrantType = "password" + tokenGrantTypeRefreshToken tokenGrantType = "refresh_token" ) // possibleTokenGrantTypeValues returns the possible values for the tokenGrantType const type. func possibleTokenGrantTypeValues() []tokenGrantType { return []tokenGrantType{ - tokenGrantTypeRefreshToken, tokenGrantTypePassword, + tokenGrantTypeRefreshToken, } } diff --git a/sdk/containers/azcontainerregistry/custom_client.go b/sdk/containers/azcontainerregistry/custom_client.go index 6719e63494a4..ed9fdbad4246 100644 --- a/sdk/containers/azcontainerregistry/custom_client.go +++ b/sdk/containers/azcontainerregistry/custom_client.go @@ -37,9 +37,13 @@ func NewClient(endpoint string, credential azcore.TokenCredential, options *Clie return nil, errors.New("provided Cloud field is missing Azure Container Registry configuration") } - authClient := newAuthenticationClient(endpoint, &authenticationClientOptions{ + authClient, err := newAuthenticationClient(endpoint, &authenticationClientOptions{ options.ClientOptions, }) + if err != nil { + return nil, err + } + authPolicy := newAuthenticationPolicy( credential, []string{c.Audience + "/.default"}, @@ -47,10 +51,14 @@ func NewClient(endpoint string, credential azcore.TokenCredential, options *Clie nil, ) - pl := runtime.NewPipeline(moduleName, moduleVersion, runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}}, &options.ClientOptions) + azcoreClient, err := azcore.NewClient(moduleName, moduleVersion, runtime.PipelineOptions{PerRetry: []policy.Policy{authPolicy}}, &options.ClientOptions) + if err != nil { + return nil, err + } + return &Client{ + azcoreClient, endpoint, - pl, }, nil } diff --git a/sdk/containers/azcontainerregistry/custom_constants.go b/sdk/containers/azcontainerregistry/custom_constants.go index 6755645e6f8a..43d030b4c155 100644 --- a/sdk/containers/azcontainerregistry/custom_constants.go +++ b/sdk/containers/azcontainerregistry/custom_constants.go @@ -7,7 +7,7 @@ package azcontainerregistry const ( - moduleName = "azcontainerregistry" + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/containers/azcontainerregistry" moduleVersion = "v0.2.1" defaultAudience = "https://containerregistry.azure.net" ) diff --git a/sdk/containers/azcontainerregistry/models.go b/sdk/containers/azcontainerregistry/models.go index d9bf10a50405..cb37a1fe1655 100644 --- a/sdk/containers/azcontainerregistry/models.go +++ b/sdk/containers/azcontainerregistry/models.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package azcontainerregistry @@ -13,369 +12,204 @@ import "time" type acrAccessToken struct { // The access token for performing authenticated requests - AccessToken *string `json:"access_token,omitempty"` + AccessToken *string } type acrRefreshToken struct { // The refresh token to be used for generating access tokens - RefreshToken *string `json:"refresh_token,omitempty"` + RefreshToken *string } // ArtifactManifestPlatform - The artifact's platform, consisting of operating system and architecture. type ArtifactManifestPlatform struct { // READ-ONLY; Manifest digest - Digest *string `json:"digest,omitempty" azure:"ro"` + Digest *string // READ-ONLY; CPU architecture - Architecture *ArtifactArchitecture `json:"architecture,omitempty" azure:"ro"` + Architecture *ArtifactArchitecture // READ-ONLY; Operating system - OperatingSystem *ArtifactOperatingSystem `json:"os,omitempty" azure:"ro"` + OperatingSystem *ArtifactOperatingSystem } // ArtifactManifestProperties - Manifest attributes details type ArtifactManifestProperties struct { // READ-ONLY; Manifest attributes - Manifest *ManifestAttributes `json:"manifest,omitempty" azure:"ro"` + Manifest *ManifestAttributes // READ-ONLY; Registry login server name. This is likely to be similar to {registry-name}.azurecr.io. - RegistryLoginServer *string `json:"registry,omitempty" azure:"ro"` + RegistryLoginServer *string // READ-ONLY; Repository name - RepositoryName *string `json:"imageName,omitempty" azure:"ro"` + RepositoryName *string } // ArtifactTagProperties - Tag attributes type ArtifactTagProperties struct { // READ-ONLY; Registry login server name. This is likely to be similar to {registry-name}.azurecr.io. - RegistryLoginServer *string `json:"registry,omitempty" azure:"ro"` + RegistryLoginServer *string // READ-ONLY; Image name - RepositoryName *string `json:"imageName,omitempty" azure:"ro"` + RepositoryName *string // READ-ONLY; List of tag attribute details - Tag *TagAttributes `json:"tag,omitempty" azure:"ro"` -} - -// authenticationClientExchangeAADAccessTokenForACRRefreshTokenOptions contains the optional parameters for the authenticationClient.ExchangeAADAccessTokenForACRRefreshToken -// method. -type authenticationClientExchangeAADAccessTokenForACRRefreshTokenOptions struct { - // AAD access token, mandatory when granttype is accesstokenrefreshtoken or access_token. - AccessToken *string - // AAD refresh token, mandatory when granttype is accesstokenrefreshtoken or refresh_token - RefreshToken *string - // AAD tenant associated to the AAD credentials. - Tenant *string -} - -// authenticationClientExchangeACRRefreshTokenForACRAccessTokenOptions contains the optional parameters for the authenticationClient.ExchangeACRRefreshTokenForACRAccessToken -// method. -type authenticationClientExchangeACRRefreshTokenForACRAccessTokenOptions struct { - // Grant type is expected to be refresh_token - GrantType *tokenGrantType -} - -// BlobClientCancelUploadOptions contains the optional parameters for the BlobClient.CancelUpload method. -type BlobClientCancelUploadOptions struct { - // placeholder for future optional parameters -} - -// BlobClientCheckBlobExistsOptions contains the optional parameters for the BlobClient.CheckBlobExists method. -type BlobClientCheckBlobExistsOptions struct { - // placeholder for future optional parameters -} - -// BlobClientCheckChunkExistsOptions contains the optional parameters for the BlobClient.CheckChunkExists method. -type BlobClientCheckChunkExistsOptions struct { - // placeholder for future optional parameters -} - -// BlobClientCompleteUploadOptions contains the optional parameters for the BlobClient.CompleteUpload method. -type BlobClientCompleteUploadOptions struct { - // placeholder for future optional parameters -} - -// BlobClientDeleteBlobOptions contains the optional parameters for the BlobClient.DeleteBlob method. -type BlobClientDeleteBlobOptions struct { - // placeholder for future optional parameters -} - -// BlobClientGetBlobOptions contains the optional parameters for the BlobClient.GetBlob method. -type BlobClientGetBlobOptions struct { - // placeholder for future optional parameters -} - -// BlobClientGetChunkOptions contains the optional parameters for the BlobClient.GetChunk method. -type BlobClientGetChunkOptions struct { - // placeholder for future optional parameters -} - -// BlobClientGetUploadStatusOptions contains the optional parameters for the BlobClient.GetUploadStatus method. -type BlobClientGetUploadStatusOptions struct { - // placeholder for future optional parameters -} - -// BlobClientMountBlobOptions contains the optional parameters for the BlobClient.MountBlob method. -type BlobClientMountBlobOptions struct { - // placeholder for future optional parameters -} - -// BlobClientStartUploadOptions contains the optional parameters for the BlobClient.StartUpload method. -type BlobClientStartUploadOptions struct { - // placeholder for future optional parameters -} - -// blobClientUploadChunkOptions contains the optional parameters for the BlobClient.uploadChunk method. -type blobClientUploadChunkOptions struct { - // Range of bytes identifying the desired block of content represented by the body. Start must the end offset retrieved via - // status check plus one. Note that this is a non-standard use of the - // Content-Range header. - ContentRange *string -} - -// ClientDeleteManifestOptions contains the optional parameters for the Client.DeleteManifest method. -type ClientDeleteManifestOptions struct { - // placeholder for future optional parameters -} - -// ClientDeleteRepositoryOptions contains the optional parameters for the Client.DeleteRepository method. -type ClientDeleteRepositoryOptions struct { - // placeholder for future optional parameters -} - -// ClientDeleteTagOptions contains the optional parameters for the Client.DeleteTag method. -type ClientDeleteTagOptions struct { - // placeholder for future optional parameters -} - -// ClientGetManifestOptions contains the optional parameters for the Client.GetManifest method. -type ClientGetManifestOptions struct { - // Accept header string delimited by comma. For example, application/vnd.docker.distribution.manifest.v2+json - Accept *string -} - -// ClientGetManifestPropertiesOptions contains the optional parameters for the Client.GetManifestProperties method. -type ClientGetManifestPropertiesOptions struct { - // placeholder for future optional parameters -} - -// ClientGetRepositoryPropertiesOptions contains the optional parameters for the Client.GetRepositoryProperties method. -type ClientGetRepositoryPropertiesOptions struct { - // placeholder for future optional parameters -} - -// ClientGetTagPropertiesOptions contains the optional parameters for the Client.GetTagProperties method. -type ClientGetTagPropertiesOptions struct { - // placeholder for future optional parameters -} - -// ClientListManifestsOptions contains the optional parameters for the Client.NewListManifestsPager method. -type ClientListManifestsOptions struct { - // Query parameter for the last item in previous query. Result set will include values lexically after last. - Last *string - // query parameter for max number of items - MaxNum *int32 - // Sort options for ordering manifests in a collection. - OrderBy *ArtifactManifestOrderBy -} - -// ClientListRepositoriesOptions contains the optional parameters for the Client.NewListRepositoriesPager method. -type ClientListRepositoriesOptions struct { - // Query parameter for the last item in previous query. Result set will include values lexically after last. - Last *string - // query parameter for max number of items - MaxNum *int32 -} - -// ClientListTagsOptions contains the optional parameters for the Client.NewListTagsPager method. -type ClientListTagsOptions struct { - // filter by digest - Digest *string - // Query parameter for the last item in previous query. Result set will include values lexically after last. - Last *string - // query parameter for max number of items - MaxNum *int32 - // Sort options for ordering tags in a collection. - OrderBy *ArtifactTagOrderBy -} - -// ClientUpdateManifestPropertiesOptions contains the optional parameters for the Client.UpdateManifestProperties method. -type ClientUpdateManifestPropertiesOptions struct { - // Manifest attribute value - Value *ManifestWriteableProperties -} - -// ClientUpdateRepositoryPropertiesOptions contains the optional parameters for the Client.UpdateRepositoryProperties method. -type ClientUpdateRepositoryPropertiesOptions struct { - // Repository attribute value - Value *RepositoryWriteableProperties -} - -// ClientUpdateTagPropertiesOptions contains the optional parameters for the Client.UpdateTagProperties method. -type ClientUpdateTagPropertiesOptions struct { - // Tag attribute value - Value *TagWriteableProperties -} - -// ClientUploadManifestOptions contains the optional parameters for the Client.UploadManifest method. -type ClientUploadManifestOptions struct { - // placeholder for future optional parameters + Tag *TagAttributes } // ContainerRepositoryProperties - Properties of this repository. type ContainerRepositoryProperties struct { // REQUIRED; Writeable properties of the resource - ChangeableAttributes *RepositoryWriteableProperties `json:"changeableAttributes,omitempty"` + ChangeableAttributes *RepositoryWriteableProperties // READ-ONLY; Image created time - CreatedOn *time.Time `json:"createdTime,omitempty" azure:"ro"` + CreatedOn *time.Time // READ-ONLY; Image last update time - LastUpdatedOn *time.Time `json:"lastUpdateTime,omitempty" azure:"ro"` + LastUpdatedOn *time.Time // READ-ONLY; Number of the manifests - ManifestCount *int32 `json:"manifestCount,omitempty" azure:"ro"` + ManifestCount *int32 // READ-ONLY; Image name - Name *string `json:"imageName,omitempty" azure:"ro"` + Name *string // READ-ONLY; Registry login server name. This is likely to be similar to {registry-name}.azurecr.io. - RegistryLoginServer *string `json:"registry,omitempty" azure:"ro"` + RegistryLoginServer *string // READ-ONLY; Number of the tags - TagCount *int32 `json:"tagCount,omitempty" azure:"ro"` + TagCount *int32 } // ManifestAttributes - Manifest details type ManifestAttributes struct { // READ-ONLY; Created time - CreatedOn *time.Time `json:"createdTime,omitempty" azure:"ro"` + CreatedOn *time.Time // READ-ONLY; Manifest - Digest *string `json:"digest,omitempty" azure:"ro"` + Digest *string // READ-ONLY; Last update time - LastUpdatedOn *time.Time `json:"lastUpdateTime,omitempty" azure:"ro"` + LastUpdatedOn *time.Time // Writeable properties of the resource - ChangeableAttributes *ManifestWriteableProperties `json:"changeableAttributes,omitempty"` + ChangeableAttributes *ManifestWriteableProperties // Config blob media type - ConfigMediaType *string `json:"configMediaType,omitempty"` + ConfigMediaType *string // Media type for this Manifest - MediaType *string `json:"mediaType,omitempty"` + MediaType *string // READ-ONLY; CPU architecture - Architecture *ArtifactArchitecture `json:"architecture,omitempty" azure:"ro"` + Architecture *ArtifactArchitecture // READ-ONLY; Operating system - OperatingSystem *ArtifactOperatingSystem `json:"os,omitempty" azure:"ro"` + OperatingSystem *ArtifactOperatingSystem // READ-ONLY; List of artifacts that are referenced by this manifest list, with information about the platform each supports. // This list will be empty if this is a leaf manifest and not a manifest list. - RelatedArtifacts []*ArtifactManifestPlatform `json:"references,omitempty" azure:"ro"` + RelatedArtifacts []*ArtifactManifestPlatform // READ-ONLY; Image size - Size *int64 `json:"imageSize,omitempty" azure:"ro"` + Size *int64 // READ-ONLY; List of tags - Tags []*string `json:"tags,omitempty" azure:"ro"` + Tags []*string } // ManifestWriteableProperties - Changeable attributes type ManifestWriteableProperties struct { // Delete enabled - CanDelete *bool `json:"deleteEnabled,omitempty"` + CanDelete *bool // List enabled - CanList *bool `json:"listEnabled,omitempty"` + CanList *bool // Read enabled - CanRead *bool `json:"readEnabled,omitempty"` + CanRead *bool // Write enabled - CanWrite *bool `json:"writeEnabled,omitempty"` + CanWrite *bool } // Manifests - Manifest attributes type Manifests struct { // List of manifests - Attributes []*ManifestAttributes `json:"manifests,omitempty"` - Link *string `json:"link,omitempty"` + Attributes []*ManifestAttributes + Link *string // Registry login server name. This is likely to be similar to {registry-name}.azurecr.io. - RegistryLoginServer *string `json:"registry,omitempty"` + RegistryLoginServer *string // Image name - Repository *string `json:"imageName,omitempty"` + Repository *string } // Repositories - List of repositories type Repositories struct { - Link *string `json:"link,omitempty"` + Link *string // Repository names - Names []*string `json:"repositories,omitempty"` + Names []*string } // RepositoryWriteableProperties - Changeable attributes for Repository type RepositoryWriteableProperties struct { // Delete enabled - CanDelete *bool `json:"deleteEnabled,omitempty"` + CanDelete *bool // List enabled - CanList *bool `json:"listEnabled,omitempty"` + CanList *bool // Read enabled - CanRead *bool `json:"readEnabled,omitempty"` + CanRead *bool // Write enabled - CanWrite *bool `json:"writeEnabled,omitempty"` + CanWrite *bool } // TagAttributes - Tag attribute details type TagAttributes struct { // REQUIRED; Writeable properties of the resource - ChangeableAttributes *TagWriteableProperties `json:"changeableAttributes,omitempty"` + ChangeableAttributes *TagWriteableProperties // READ-ONLY; Tag created time - CreatedOn *time.Time `json:"createdTime,omitempty" azure:"ro"` + CreatedOn *time.Time // READ-ONLY; Tag digest - Digest *string `json:"digest,omitempty" azure:"ro"` + Digest *string // READ-ONLY; Tag last update time - LastUpdatedOn *time.Time `json:"lastUpdateTime,omitempty" azure:"ro"` + LastUpdatedOn *time.Time // READ-ONLY; Tag name - Name *string `json:"name,omitempty" azure:"ro"` + Name *string } // TagList - List of tag details type TagList struct { // REQUIRED; Registry login server name. This is likely to be similar to {registry-name}.azurecr.io. - RegistryLoginServer *string `json:"registry,omitempty"` + RegistryLoginServer *string // REQUIRED; Image name - Repository *string `json:"imageName,omitempty"` + Repository *string // REQUIRED; List of tag attribute details - Tags []*TagAttributes `json:"tags,omitempty"` - Link *string `json:"link,omitempty"` + Tags []*TagAttributes + Link *string } // TagWriteableProperties - Changeable attributes type TagWriteableProperties struct { // Delete enabled - CanDelete *bool `json:"deleteEnabled,omitempty"` + CanDelete *bool // List enabled - CanList *bool `json:"listEnabled,omitempty"` + CanList *bool // Read enabled - CanRead *bool `json:"readEnabled,omitempty"` + CanRead *bool // Write enabled - CanWrite *bool `json:"writeEnabled,omitempty"` + CanWrite *bool } diff --git a/sdk/containers/azcontainerregistry/models_serde.go b/sdk/containers/azcontainerregistry/models_serde.go index a063ae11fb02..0a3ab4bc99cd 100644 --- a/sdk/containers/azcontainerregistry/models_serde.go +++ b/sdk/containers/azcontainerregistry/models_serde.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package azcontainerregistry @@ -147,10 +146,10 @@ func (c *ContainerRepositoryProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "ChangeableAttributes", &c.ChangeableAttributes) delete(rawMsg, key) case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedOn", &c.CreatedOn) + err = unpopulateDateTimeRFC3339(val, "CreatedOn", &c.CreatedOn) delete(rawMsg, key) case "lastUpdateTime": - err = unpopulateTimeRFC3339(val, "LastUpdatedOn", &c.LastUpdatedOn) + err = unpopulateDateTimeRFC3339(val, "LastUpdatedOn", &c.LastUpdatedOn) delete(rawMsg, key) case "manifestCount": err = unpopulate(val, "ManifestCount", &c.ManifestCount) @@ -191,13 +190,13 @@ func (m *ManifestAttributes) UnmarshalJSON(data []byte) error { err = unpopulate(val, "ConfigMediaType", &m.ConfigMediaType) delete(rawMsg, key) case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedOn", &m.CreatedOn) + err = unpopulateDateTimeRFC3339(val, "CreatedOn", &m.CreatedOn) delete(rawMsg, key) case "digest": err = unpopulate(val, "Digest", &m.Digest) delete(rawMsg, key) case "lastUpdateTime": - err = unpopulateTimeRFC3339(val, "LastUpdatedOn", &m.LastUpdatedOn) + err = unpopulateDateTimeRFC3339(val, "LastUpdatedOn", &m.LastUpdatedOn) delete(rawMsg, key) case "mediaType": err = unpopulate(val, "MediaType", &m.MediaType) @@ -365,13 +364,13 @@ func (t *TagAttributes) UnmarshalJSON(data []byte) error { err = unpopulate(val, "ChangeableAttributes", &t.ChangeableAttributes) delete(rawMsg, key) case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedOn", &t.CreatedOn) + err = unpopulateDateTimeRFC3339(val, "CreatedOn", &t.CreatedOn) delete(rawMsg, key) case "digest": err = unpopulate(val, "Digest", &t.Digest) delete(rawMsg, key) case "lastUpdateTime": - err = unpopulateTimeRFC3339(val, "LastUpdatedOn", &t.LastUpdatedOn) + err = unpopulateDateTimeRFC3339(val, "LastUpdatedOn", &t.LastUpdatedOn) delete(rawMsg, key) case "name": err = unpopulate(val, "Name", &t.Name) diff --git a/sdk/containers/azcontainerregistry/options.go b/sdk/containers/azcontainerregistry/options.go new file mode 100644 index 000000000000..f1a7ebc2dc4e --- /dev/null +++ b/sdk/containers/azcontainerregistry/options.go @@ -0,0 +1,182 @@ +//go:build go1.18 +// +build go1.18 + +// 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. DO NOT EDIT. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package azcontainerregistry + +// authenticationClientExchangeAADAccessTokenForACRRefreshTokenOptions contains the optional parameters for the authenticationClient.ExchangeAADAccessTokenForACRRefreshToken +// method. +type authenticationClientExchangeAADAccessTokenForACRRefreshTokenOptions struct { + // AAD access token, mandatory when granttype is accesstokenrefreshtoken or access_token. + AccessToken *string + + // AAD refresh token, mandatory when granttype is accesstokenrefreshtoken or refresh_token + RefreshToken *string + + // AAD tenant associated to the AAD credentials. + Tenant *string +} + +// authenticationClientExchangeACRRefreshTokenForACRAccessTokenOptions contains the optional parameters for the authenticationClient.ExchangeACRRefreshTokenForACRAccessToken +// method. +type authenticationClientExchangeACRRefreshTokenForACRAccessTokenOptions struct { + // Grant type is expected to be refresh_token + GrantType *tokenGrantType +} + +// BlobClientCancelUploadOptions contains the optional parameters for the BlobClient.CancelUpload method. +type BlobClientCancelUploadOptions struct { + // placeholder for future optional parameters +} + +// BlobClientCheckBlobExistsOptions contains the optional parameters for the BlobClient.CheckBlobExists method. +type BlobClientCheckBlobExistsOptions struct { + // placeholder for future optional parameters +} + +// BlobClientCheckChunkExistsOptions contains the optional parameters for the BlobClient.CheckChunkExists method. +type BlobClientCheckChunkExistsOptions struct { + // placeholder for future optional parameters +} + +// BlobClientCompleteUploadOptions contains the optional parameters for the BlobClient.CompleteUpload method. +type BlobClientCompleteUploadOptions struct { + // placeholder for future optional parameters +} + +// BlobClientDeleteBlobOptions contains the optional parameters for the BlobClient.DeleteBlob method. +type BlobClientDeleteBlobOptions struct { + // placeholder for future optional parameters +} + +// BlobClientGetBlobOptions contains the optional parameters for the BlobClient.GetBlob method. +type BlobClientGetBlobOptions struct { + // placeholder for future optional parameters +} + +// BlobClientGetChunkOptions contains the optional parameters for the BlobClient.GetChunk method. +type BlobClientGetChunkOptions struct { + // placeholder for future optional parameters +} + +// BlobClientGetUploadStatusOptions contains the optional parameters for the BlobClient.GetUploadStatus method. +type BlobClientGetUploadStatusOptions struct { + // placeholder for future optional parameters +} + +// BlobClientMountBlobOptions contains the optional parameters for the BlobClient.MountBlob method. +type BlobClientMountBlobOptions struct { + // placeholder for future optional parameters +} + +// BlobClientStartUploadOptions contains the optional parameters for the BlobClient.StartUpload method. +type BlobClientStartUploadOptions struct { + // placeholder for future optional parameters +} + +// blobClientUploadChunkOptions contains the optional parameters for the BlobClient.uploadChunk method. +type blobClientUploadChunkOptions struct { + // Range of bytes identifying the desired block of content represented by the body. Start must the end offset retrieved via + // status check plus one. Note that this is a non-standard use of the + // Content-Range header. + ContentRange *string +} + +// ClientDeleteManifestOptions contains the optional parameters for the Client.DeleteManifest method. +type ClientDeleteManifestOptions struct { + // placeholder for future optional parameters +} + +// ClientDeleteRepositoryOptions contains the optional parameters for the Client.DeleteRepository method. +type ClientDeleteRepositoryOptions struct { + // placeholder for future optional parameters +} + +// ClientDeleteTagOptions contains the optional parameters for the Client.DeleteTag method. +type ClientDeleteTagOptions struct { + // placeholder for future optional parameters +} + +// ClientGetManifestOptions contains the optional parameters for the Client.GetManifest method. +type ClientGetManifestOptions struct { + // Accept header string delimited by comma. For example, application/vnd.docker.distribution.manifest.v2+json + Accept *string +} + +// ClientGetManifestPropertiesOptions contains the optional parameters for the Client.GetManifestProperties method. +type ClientGetManifestPropertiesOptions struct { + // placeholder for future optional parameters +} + +// ClientGetRepositoryPropertiesOptions contains the optional parameters for the Client.GetRepositoryProperties method. +type ClientGetRepositoryPropertiesOptions struct { + // placeholder for future optional parameters +} + +// ClientGetTagPropertiesOptions contains the optional parameters for the Client.GetTagProperties method. +type ClientGetTagPropertiesOptions struct { + // placeholder for future optional parameters +} + +// ClientListManifestsOptions contains the optional parameters for the Client.NewListManifestsPager method. +type ClientListManifestsOptions struct { + // Query parameter for the last item in previous query. Result set will include values lexically after last. + Last *string + + // query parameter for max number of items + MaxNum *int32 + + // Sort options for ordering manifests in a collection. + OrderBy *ArtifactManifestOrderBy +} + +// ClientListRepositoriesOptions contains the optional parameters for the Client.NewListRepositoriesPager method. +type ClientListRepositoriesOptions struct { + // Query parameter for the last item in previous query. Result set will include values lexically after last. + Last *string + + // query parameter for max number of items + MaxNum *int32 +} + +// ClientListTagsOptions contains the optional parameters for the Client.NewListTagsPager method. +type ClientListTagsOptions struct { + // filter by digest + Digest *string + + // Query parameter for the last item in previous query. Result set will include values lexically after last. + Last *string + + // query parameter for max number of items + MaxNum *int32 + + // Sort options for ordering tags in a collection. + OrderBy *ArtifactTagOrderBy +} + +// ClientUpdateManifestPropertiesOptions contains the optional parameters for the Client.UpdateManifestProperties method. +type ClientUpdateManifestPropertiesOptions struct { + // Manifest attribute value + Value *ManifestWriteableProperties +} + +// ClientUpdateRepositoryPropertiesOptions contains the optional parameters for the Client.UpdateRepositoryProperties method. +type ClientUpdateRepositoryPropertiesOptions struct { + // Repository attribute value + Value *RepositoryWriteableProperties +} + +// ClientUpdateTagPropertiesOptions contains the optional parameters for the Client.UpdateTagProperties method. +type ClientUpdateTagPropertiesOptions struct { + // Tag attribute value + Value *TagWriteableProperties +} + +// ClientUploadManifestOptions contains the optional parameters for the Client.UploadManifest method. +type ClientUploadManifestOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/containers/azcontainerregistry/response_types.go b/sdk/containers/azcontainerregistry/response_types.go index 8227369e5fdf..ed310e0c02be 100644 --- a/sdk/containers/azcontainerregistry/response_types.go +++ b/sdk/containers/azcontainerregistry/response_types.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package azcontainerregistry @@ -148,6 +147,7 @@ type ClientDeleteTagResponse struct { // ClientGetManifestPropertiesResponse contains the response from method Client.GetManifestProperties. type ClientGetManifestPropertiesResponse struct { + // Manifest attributes details ArtifactManifestProperties } @@ -162,47 +162,58 @@ type ClientGetManifestResponse struct { // ClientGetRepositoryPropertiesResponse contains the response from method Client.GetRepositoryProperties. type ClientGetRepositoryPropertiesResponse struct { + // Properties of this repository. ContainerRepositoryProperties } // ClientGetTagPropertiesResponse contains the response from method Client.GetTagProperties. type ClientGetTagPropertiesResponse struct { + // Tag attributes ArtifactTagProperties } // ClientListManifestsResponse contains the response from method Client.NewListManifestsPager. type ClientListManifestsResponse struct { + // Manifest attributes Manifests + // Link contains the information returned from the Link header response. Link *string } // ClientListRepositoriesResponse contains the response from method Client.NewListRepositoriesPager. type ClientListRepositoriesResponse struct { + // List of repositories Repositories + // Link contains the information returned from the Link header response. Link *string } // ClientListTagsResponse contains the response from method Client.NewListTagsPager. type ClientListTagsResponse struct { + // List of tag details TagList + // Link contains the information returned from the Link header response. Link *string } // ClientUpdateManifestPropertiesResponse contains the response from method Client.UpdateManifestProperties. type ClientUpdateManifestPropertiesResponse struct { + // Manifest attributes details ArtifactManifestProperties } // ClientUpdateRepositoryPropertiesResponse contains the response from method Client.UpdateRepositoryProperties. type ClientUpdateRepositoryPropertiesResponse struct { + // Properties of this repository. ContainerRepositoryProperties } // ClientUpdateTagPropertiesResponse contains the response from method Client.UpdateTagProperties. type ClientUpdateTagPropertiesResponse struct { + // Tag attributes ArtifactTagProperties } diff --git a/sdk/containers/azcontainerregistry/time_rfc3339.go b/sdk/containers/azcontainerregistry/time_rfc3339.go index 8ef526fa064c..a594fec3aab8 100644 --- a/sdk/containers/azcontainerregistry/time_rfc3339.go +++ b/sdk/containers/azcontainerregistry/time_rfc3339.go @@ -3,9 +3,8 @@ // 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. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package azcontainerregistry @@ -19,50 +18,50 @@ import ( "time" ) -const ( - utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` - utcLayout = "2006-01-02T15:04:05.999999999" - rfc3339JSON = `"` + time.RFC3339Nano + `"` -) - // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) -type timeRFC3339 time.Time +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time -func (t timeRFC3339) MarshalJSON() (json []byte, err error) { +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { tt := time.Time(t) return tt.MarshalJSON() } -func (t timeRFC3339) MarshalText() (text []byte, err error) { +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { tt := time.Time(t) return tt.MarshalText() } -func (t *timeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcLayoutJSON +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON if tzOffsetRegex.Match(data) { - layout = rfc3339JSON + layout = dateTimeJSON } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { - layout := utcLayout +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime if tzOffsetRegex.Match(data) { layout = time.RFC3339Nano } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) Parse(layout, value string) error { +func (t *dateTimeRFC3339) Parse(layout, value string) error { p, err := time.Parse(layout, strings.ToUpper(value)) - *t = timeRFC3339(p) + *t = dateTimeRFC3339(p) return err } -func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { @@ -71,14 +70,14 @@ func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { } else if reflect.ValueOf(t).IsNil() { return } - m[k] = (*timeRFC3339)(t) + m[k] = (*dateTimeRFC3339)(t) } -func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { if data == nil || strings.EqualFold(string(data), "null") { return nil } - var aux timeRFC3339 + var aux dateTimeRFC3339 if err := json.Unmarshal(data, &aux); err != nil { return fmt.Errorf("struct field %s: %v", fn, err) } diff --git a/sdk/containers/azcontainerregistry/time_rfc3339_test.go b/sdk/containers/azcontainerregistry/time_rfc3339_test.go index fa8f02222746..acc378b3ce3c 100644 --- a/sdk/containers/azcontainerregistry/time_rfc3339_test.go +++ b/sdk/containers/azcontainerregistry/time_rfc3339_test.go @@ -14,62 +14,62 @@ import ( "time" ) -func Test_timeRFC3339_MarshalJSON(t *testing.T) { - t1 := timeRFC3339(time.Date(2023, 5, 6, 10, 23, 15, 123456789, time.UTC)) +func Test_dateTimeRFC3339_MarshalJSON(t *testing.T) { + t1 := dateTimeRFC3339(time.Date(2023, 5, 6, 10, 23, 15, 123456789, time.UTC)) b, err := t1.MarshalJSON() require.NoError(t, err) require.Equal(t, `"2023-05-06T10:23:15.123456789Z"`, string(b)) } -func Test_timeRFC3339_MarshalText(t *testing.T) { - t1 := timeRFC3339(time.Date(2023, 5, 6, 10, 23, 15, 123456789, time.UTC)) +func Test_dateTimeRFC3339_MarshalText(t *testing.T) { + t1 := dateTimeRFC3339(time.Date(2023, 5, 6, 10, 23, 15, 123456789, time.UTC)) b, err := t1.MarshalText() require.NoError(t, err) require.Equal(t, "2023-05-06T10:23:15.123456789Z", string(b)) } -func Test_timeRFC3339_UnmarshalJSON(t *testing.T) { - var t1 timeRFC3339 +func Test_dateTimeRFC3339_UnmarshalJSON(t *testing.T) { + var t1 dateTimeRFC3339 err := t1.UnmarshalJSON([]byte(`"2023-05-06T10:23:15.123456789Z"`)) require.NoError(t, err) - require.Equal(t, timeRFC3339(time.Date(2023, 5, 6, 10, 23, 15, 123456789, time.UTC)), t1) + require.Equal(t, dateTimeRFC3339(time.Date(2023, 5, 6, 10, 23, 15, 123456789, time.UTC)), t1) } -func Test_timeRFC3339_UnmarshalText(t *testing.T) { - var t1 timeRFC3339 +func Test_dateTimeRFC3339_UnmarshalText(t *testing.T) { + var t1 dateTimeRFC3339 err := t1.UnmarshalText([]byte("2023-05-06T10:23:15.123456789Z")) require.NoError(t, err) - require.Equal(t, timeRFC3339(time.Date(2023, 5, 6, 10, 23, 15, 123456789, time.UTC)), t1) + require.Equal(t, dateTimeRFC3339(time.Date(2023, 5, 6, 10, 23, 15, 123456789, time.UTC)), t1) } -func Test_populateTimeRFC3339(t *testing.T) { +func Test_populateDateTimeRFC3339(t *testing.T) { m := map[string]any{} - populateTimeRFC3339(m, "test", nil) + populateDateTimeRFC3339(m, "test", nil) require.Equal(t, map[string]any{}, m) - populateTimeRFC3339(m, "test", azcore.NullValue[*time.Time]()) + populateDateTimeRFC3339(m, "test", azcore.NullValue[*time.Time]()) require.Equal(t, map[string]any{"test": nil}, m) t1 := time.Date(2023, 5, 6, 10, 23, 15, 123456789, time.UTC) - populateTimeRFC3339(m, "test", &t1) - tt1 := timeRFC3339(t1) + populateDateTimeRFC3339(m, "test", &t1) + tt1 := dateTimeRFC3339(t1) require.Equal(t, map[string]any{"test": &tt1}, m) } -func Test_unpopulateTimeRFC3339(t *testing.T) { +func Test_unpopulateDateTimeRFC3339(t *testing.T) { var t1 *time.Time var data json.RawMessage - err := unpopulateTimeRFC3339(data, "test", &t1) + err := unpopulateDateTimeRFC3339(data, "test", &t1) require.NoError(t, err) var tt1 *time.Time require.Equal(t, tt1, t1) data = json.RawMessage("null") - err = unpopulateTimeRFC3339(data, "test", &t1) + err = unpopulateDateTimeRFC3339(data, "test", &t1) require.NoError(t, err) require.Equal(t, tt1, t1) data = json.RawMessage("wrong value") - err = unpopulateTimeRFC3339(data, "test", &t1) + err = unpopulateDateTimeRFC3339(data, "test", &t1) require.Error(t, err) data = json.RawMessage(`"2023-05-06T10:23:15.123456789Z"`) - err = unpopulateTimeRFC3339(data, "test", &t1) + err = unpopulateDateTimeRFC3339(data, "test", &t1) require.NoError(t, err) tt2 := time.Date(2023, 5, 6, 10, 23, 15, 123456789, time.UTC) require.Equal(t, &tt2, t1) From fbe326d1b5540b7b20586a216eaba00d394eb125 Mon Sep 17 00:00:00 2001 From: Peng Jiahui <46921893+Alancere@users.noreply.github.com> Date: Wed, 10 Jan 2024 11:22:55 +0800 Subject: [PATCH 25/32] fix generator tool (#22205) * fix generator tool * gofmt * fix * goimports --- .../generator/cmd/v2/common/fileProcessor.go | 19 ++++++++++++++++--- .../generator/cmd/v2/common/generation.go | 13 +++++++++---- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/eng/tools/generator/cmd/v2/common/fileProcessor.go b/eng/tools/generator/cmd/v2/common/fileProcessor.go index 36b11832125a..a97df16f2a61 100644 --- a/eng/tools/generator/cmd/v2/common/fileProcessor.go +++ b/eng/tools/generator/cmd/v2/common/fileProcessor.go @@ -5,6 +5,7 @@ package common import ( "bytes" + "errors" "fmt" "io/fs" "io/ioutil" @@ -543,11 +544,9 @@ func replaceModuleImport(path, rpName, namespaceName, previousVersion, currentVe if err != nil { return err } - if info.IsDir() { return nil } - suffix := false for i := 0; i < len(suffixes) && !suffix; i++ { suffix = strings.HasSuffix(info.Name(), suffixes[i]) @@ -566,11 +565,25 @@ func replaceModuleImport(path, rpName, namespaceName, previousVersion, currentVe } } } - return nil }) } +func getModuleVersion(autorestPath string) (*semver.Version, error) { + data, err := os.ReadFile(autorestPath) + if err != nil { + return nil, err + } + + for _, line := range strings.Split(string(data), "\n") { + if strings.HasPrefix(line, autorest_md_module_version_prefix) { + return semver.NewVersion(strings.TrimSpace(line[len(autorest_md_module_version_prefix):])) + } + } + + return nil, errors.New("module-version does not exist in autorest.md") +} + func existSuffixFile(path, suffix string) bool { existed := false diff --git a/eng/tools/generator/cmd/v2/common/generation.go b/eng/tools/generator/cmd/v2/common/generation.go index fed4c0eeb4ff..ac4ecee01d0f 100644 --- a/eng/tools/generator/cmd/v2/common/generation.go +++ b/eng/tools/generator/cmd/v2/common/generation.go @@ -306,23 +306,28 @@ func (ctx *GenerateContext) GenerateForSingleRPNamespace(generateParam *Generate return nil, err } + oldModuleVersion, err := getModuleVersion(filepath.Join(packagePath, "autorest.md")) + if err != nil { + return nil, err + } + log.Printf("Replace version in autorest.md and constants...") if err = ReplaceVersion(packagePath, version.String()); err != nil { return nil, err } - if _, err := os.Stat(filepath.Join(packagePath, "fake")); !os.IsNotExist(err) && changelog.HasBreakingChanges() { + if _, err := os.Stat(filepath.Join(packagePath, "fake")); !os.IsNotExist(err) && oldModuleVersion.Major() != version.Major() { log.Printf("Replace fake module v2+...") - if err = replaceModuleImport(packagePath, generateParam.RPName, generateParam.NamespaceName, previousVersion, version.String(), + if err = replaceModuleImport(packagePath, generateParam.RPName, generateParam.NamespaceName, oldModuleVersion.String(), version.String(), "fake", ".go"); err != nil { return nil, err } } // When sdk has major version bump, the live test needs to update the module referenced in the code. - if changelog.HasBreakingChanges() && existSuffixFile(packagePath, "_live_test.go") { + if oldModuleVersion.Major() != version.Major() && existSuffixFile(packagePath, "_live_test.go") { log.Printf("Replace live test module v2+...") - if err = replaceModuleImport(packagePath, generateParam.RPName, generateParam.NamespaceName, previousVersion, version.String(), + if err = replaceModuleImport(packagePath, generateParam.RPName, generateParam.NamespaceName, oldModuleVersion.String(), version.String(), "", "_live_test.go"); err != nil { return nil, err } From 326412546f4a9f4463dd21ece480797e3d450de2 Mon Sep 17 00:00:00 2001 From: tanyasethi-msft Date: Wed, 10 Jan 2024 12:33:32 +0530 Subject: [PATCH 26/32] azdatalake preview stg82 --- sdk/storage/azdatalake/CHANGELOG.md | 8 +++----- sdk/storage/azdatalake/go.mod | 2 +- sdk/storage/azdatalake/go.sum | 4 ++-- sdk/storage/azdatalake/internal/exported/version.go | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/sdk/storage/azdatalake/CHANGELOG.md b/sdk/storage/azdatalake/CHANGELOG.md index 40d907997e00..3a8572fe917e 100644 --- a/sdk/storage/azdatalake/CHANGELOG.md +++ b/sdk/storage/azdatalake/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 1.0.1 (Unreleased) +## 1.1.0-beta.1 (2024-01-10) ### Features Added * Encryption Scope For SAS @@ -8,14 +8,12 @@ * Create SubDirectory Client * Service Version upgrade to 2021-06-08 -### Breaking Changes - ### Bugs Fixed * Block `SharedKeyCredential` authentication mode for non TLS protected endpoints. Fixes [#21841](https://github.com/Azure/azure-sdk-for-go/issues/21841). ### Other Changes -* Updated version of azblob to 1.2.1 +* Updated version of azblob to `1.3.0-beta.1` * Updated azcore version to `1.9.1` and azidentity version to `1.4.0`. ## 1.0.0 (2023-10-18) @@ -28,4 +26,4 @@ ### Features Added -* This is the initial preview release of the `azdatalake` library \ No newline at end of file +* This is the initial preview release of the `azdatalake` library diff --git a/sdk/storage/azdatalake/go.mod b/sdk/storage/azdatalake/go.mod index 00da39c2ff63..8f932dde60df 100644 --- a/sdk/storage/azdatalake/go.mod +++ b/sdk/storage/azdatalake/go.mod @@ -6,7 +6,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 - github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.1 + github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.0-beta.1 github.com/stretchr/testify v1.8.4 ) diff --git a/sdk/storage/azdatalake/go.sum b/sdk/storage/azdatalake/go.sum index 8b9bf9c44f9e..55adef4e4463 100644 --- a/sdk/storage/azdatalake/go.sum +++ b/sdk/storage/azdatalake/go.sum @@ -5,8 +5,8 @@ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 h1:6oNBlSdi1QqM1PNW7FPA6xOGA5UNsXnkaYZz9vdPGhA= github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.5.0 h1:AifHbc4mg0x9zW52WOpKbsHaDKuRhlI7TVl47thgQ70= -github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.1 h1:AMf7YbZOZIW5b66cXNHMWWT/zkjhz5+a+k/3x40EO7E= -github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.1/go.mod h1:uwfk06ZBcvL/g4VHNjurPfVln9NMbsk2XIZxJ+hu81k= +github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.0-beta.1 h1:tAJ+HBDRqjXv0TC2qVCk/FWezBU8OKifQ19cUeNXM9M= +github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.0-beta.1/go.mod h1:uwfk06ZBcvL/g4VHNjurPfVln9NMbsk2XIZxJ+hu81k= github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/sdk/storage/azdatalake/internal/exported/version.go b/sdk/storage/azdatalake/internal/exported/version.go index 504e59cc444c..65cddb2cbbc3 100644 --- a/sdk/storage/azdatalake/internal/exported/version.go +++ b/sdk/storage/azdatalake/internal/exported/version.go @@ -8,5 +8,5 @@ package exported const ( ModuleName = "azdatalake" - ModuleVersion = "v1.0.1" + ModuleVersion = "v1.1.0-beta.1" ) From 467afcf6ee732ad401e8d2a155ddaf9e7046f12b Mon Sep 17 00:00:00 2001 From: tanyasethi-msft <124860586+tanyasethi-msft@users.noreply.github.com> Date: Wed, 10 Jan 2024 21:45:02 +0530 Subject: [PATCH 27/32] azdatalake preview stg82 (#22227) --- sdk/storage/azdatalake/CHANGELOG.md | 8 +++----- sdk/storage/azdatalake/go.mod | 2 +- sdk/storage/azdatalake/go.sum | 4 ++-- sdk/storage/azdatalake/internal/exported/version.go | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/sdk/storage/azdatalake/CHANGELOG.md b/sdk/storage/azdatalake/CHANGELOG.md index 40d907997e00..3a8572fe917e 100644 --- a/sdk/storage/azdatalake/CHANGELOG.md +++ b/sdk/storage/azdatalake/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 1.0.1 (Unreleased) +## 1.1.0-beta.1 (2024-01-10) ### Features Added * Encryption Scope For SAS @@ -8,14 +8,12 @@ * Create SubDirectory Client * Service Version upgrade to 2021-06-08 -### Breaking Changes - ### Bugs Fixed * Block `SharedKeyCredential` authentication mode for non TLS protected endpoints. Fixes [#21841](https://github.com/Azure/azure-sdk-for-go/issues/21841). ### Other Changes -* Updated version of azblob to 1.2.1 +* Updated version of azblob to `1.3.0-beta.1` * Updated azcore version to `1.9.1` and azidentity version to `1.4.0`. ## 1.0.0 (2023-10-18) @@ -28,4 +26,4 @@ ### Features Added -* This is the initial preview release of the `azdatalake` library \ No newline at end of file +* This is the initial preview release of the `azdatalake` library diff --git a/sdk/storage/azdatalake/go.mod b/sdk/storage/azdatalake/go.mod index 00da39c2ff63..8f932dde60df 100644 --- a/sdk/storage/azdatalake/go.mod +++ b/sdk/storage/azdatalake/go.mod @@ -6,7 +6,7 @@ require ( github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 - github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.1 + github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.0-beta.1 github.com/stretchr/testify v1.8.4 ) diff --git a/sdk/storage/azdatalake/go.sum b/sdk/storage/azdatalake/go.sum index 8b9bf9c44f9e..55adef4e4463 100644 --- a/sdk/storage/azdatalake/go.sum +++ b/sdk/storage/azdatalake/go.sum @@ -5,8 +5,8 @@ github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 h1:6oNBlSdi1QqM1PNW7FPA6xOGA5UNsXnkaYZz9vdPGhA= github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/storage/armstorage v1.5.0 h1:AifHbc4mg0x9zW52WOpKbsHaDKuRhlI7TVl47thgQ70= -github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.1 h1:AMf7YbZOZIW5b66cXNHMWWT/zkjhz5+a+k/3x40EO7E= -github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.1/go.mod h1:uwfk06ZBcvL/g4VHNjurPfVln9NMbsk2XIZxJ+hu81k= +github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.0-beta.1 h1:tAJ+HBDRqjXv0TC2qVCk/FWezBU8OKifQ19cUeNXM9M= +github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.3.0-beta.1/go.mod h1:uwfk06ZBcvL/g4VHNjurPfVln9NMbsk2XIZxJ+hu81k= github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= diff --git a/sdk/storage/azdatalake/internal/exported/version.go b/sdk/storage/azdatalake/internal/exported/version.go index 504e59cc444c..65cddb2cbbc3 100644 --- a/sdk/storage/azdatalake/internal/exported/version.go +++ b/sdk/storage/azdatalake/internal/exported/version.go @@ -8,5 +8,5 @@ package exported const ( ModuleName = "azdatalake" - ModuleVersion = "v1.0.1" + ModuleVersion = "v1.1.0-beta.1" ) From 4b274bc2ce1ac01ac21ab96469ece71e1e62cc75 Mon Sep 17 00:00:00 2001 From: Charles Lowell <10964656+chlowell@users.noreply.github.com> Date: Wed, 10 Jan 2024 12:36:28 -0800 Subject: [PATCH 28/32] Rename azidentity/cache pipeline (#22231) --- sdk/azidentity/cache/{ci.yml => ci.azidentity.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sdk/azidentity/cache/{ci.yml => ci.azidentity.yml} (100%) diff --git a/sdk/azidentity/cache/ci.yml b/sdk/azidentity/cache/ci.azidentity.yml similarity index 100% rename from sdk/azidentity/cache/ci.yml rename to sdk/azidentity/cache/ci.azidentity.yml From c99ab585ac31c09abcde06a0efbf3c1196e08456 Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Wed, 10 Jan 2024 19:04:40 -0500 Subject: [PATCH 29/32] Handle errors in mod tidy script (#22234) --- eng/scripts/modtidy.ps1 | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/eng/scripts/modtidy.ps1 b/eng/scripts/modtidy.ps1 index 3acfc655796c..0358f0742ceb 100644 --- a/eng/scripts/modtidy.ps1 +++ b/eng/scripts/modtidy.ps1 @@ -4,12 +4,20 @@ Param( $modFiles = Get-ChildItem -Path $searchPath -Include "go.mod" -Recurse -$modFiles | ForEach-Object -Parallel { - Push-Location $_.Directory +$tidyErrors = $modFiles | ForEach-Object -Parallel { + Set-Location $_.Directory Write-Host (Get-Location) - go mod tidy - Pop-Location + $output = go mod tidy 2>&1 if ($LASTEXITCODE) { - exit 1 + return @{ Directory = $_.Directory; Output = $output } } } + +if ($tidyErrors) { + Write-Error "Encountered the following tidy failures:" -ErrorAction 'Continue' + foreach ($err in $tidyErrors) { + Write-Host "=== $($err.Directory) ===" + $err.Output + } + exit 1 +} From 1ae96982eefc909e32e02e9f757ce87c04bbfbf6 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Thu, 11 Jan 2024 12:43:23 -0800 Subject: [PATCH 30/32] Sync eng/common directory with azure-sdk-tools for PR 7445 (#22233) * Add package filter parameter to select recursively found packages in release * Handle empty value for packageFilter --------- Co-authored-by: Ben Broderick Phillips --- .../templates/steps/create-tags-and-git-release.yml | 4 +++- eng/common/scripts/create-tags-and-git-release.ps1 | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/eng/common/pipelines/templates/steps/create-tags-and-git-release.yml b/eng/common/pipelines/templates/steps/create-tags-and-git-release.yml index 5da9c29f55a9..ed7c2e420208 100644 --- a/eng/common/pipelines/templates/steps/create-tags-and-git-release.yml +++ b/eng/common/pipelines/templates/steps/create-tags-and-git-release.yml @@ -1,6 +1,7 @@ parameters: ArtifactLocation: 'not-specified' PackageRepository: 'not-specified' + PackageFilter: '' ReleaseSha: 'not-specified' RepoId: $(Build.Repository.Name) WorkingDirectory: '' @@ -14,10 +15,11 @@ steps: arguments: > -artifactLocation ${{ parameters.ArtifactLocation }} -packageRepository ${{ parameters.PackageRepository }} + -packageFilter "${{ parameters.PackageFilter }}" -releaseSha ${{ parameters.ReleaseSha }} -repoId ${{ parameters.RepoId }} -workingDirectory '${{ parameters.WorkingDirectory }}' pwsh: true timeoutInMinutes: 5 env: - GH_TOKEN: $(azuresdk-github-pat) \ No newline at end of file + GH_TOKEN: $(azuresdk-github-pat) diff --git a/eng/common/scripts/create-tags-and-git-release.ps1 b/eng/common/scripts/create-tags-and-git-release.ps1 index 07d8cd0ed5bc..172c3cf1ce98 100644 --- a/eng/common/scripts/create-tags-and-git-release.ps1 +++ b/eng/common/scripts/create-tags-and-git-release.ps1 @@ -7,6 +7,7 @@ param ( $artifactLocation, # the root of the artifact folder. DevOps $(System.ArtifactsDirectory) $workingDirectory, # directory that package artifacts will be extracted into for examination (if necessary) $packageRepository, # used to indicate destination against which we will check the existing version. + $packageFilter, # valid options: PyPI, Nuget, NPM, Maven, C, CPP # used by CreateTags $releaseSha, # the SHA for the artifacts. DevOps: $(Release.Artifacts..SourceVersion) or $(Build.SourceVersion) @@ -26,6 +27,11 @@ Write-Host "Using API URL $apiUrl" # VERIFY PACKAGES $pkgList = VerifyPackages -artifactLocation $artifactLocation -workingDirectory $workingDirectory -apiUrl $apiUrl -releaseSha $releaseSha -continueOnError $continueOnError +if ($packageFilter) { + Write-Host "Filtering discovered packages to '$packageFilter'" + [array]$pkgList = $pkgList | Where-Object { $_.PackageId -like $packageFilter } +} + if ($pkgList) { Write-Host "Given the visible artifacts, github releases will be created for the following:" From 0677fb4194a1dbb1b8589046250e4e6ddd3b4d3b Mon Sep 17 00:00:00 2001 From: Ben Broderick Phillips Date: Thu, 11 Jan 2024 15:46:11 -0500 Subject: [PATCH 31/32] Use package filter to prevent recursive package publish (#22232) --- eng/pipelines/templates/jobs/archetype-go-release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/eng/pipelines/templates/jobs/archetype-go-release.yml b/eng/pipelines/templates/jobs/archetype-go-release.yml index 2ee96efb34ce..4af652604bb8 100644 --- a/eng/pipelines/templates/jobs/archetype-go-release.yml +++ b/eng/pipelines/templates/jobs/archetype-go-release.yml @@ -74,10 +74,11 @@ stages: - template: /eng/common/pipelines/templates/steps/create-tags-and-git-release.yml parameters: ArtifactLocation: $(Build.SourcesDirectory)/sdk/${{ parameters.ServiceDirectory }} + PackageFilter: sdk/${{ parameters.ServiceDirectory }} ReleaseSha: $(Build.SourceVersion) RepoId: Azure/azure-sdk-for-go WorkingDirectory: $(System.DefaultWorkingDirectory) - + - ${{ if not(and(startsWith(parameters.ServiceDirectory, 'resourcemanager'), ne(parameters.ServiceDirectory, 'resourcemanager/internal'))) }}: - deployment: UpdatePackageVersion displayName: "Update Package Version" From cef53c7521e50f982853cc71065c81f99904aec5 Mon Sep 17 00:00:00 2001 From: tanyasethi-msft Date: Fri, 12 Jan 2024 19:45:07 +0530 Subject: [PATCH 32/32] append with flush --- sdk/storage/azdatalake/assets.json | 2 +- sdk/storage/azdatalake/file/client_test.go | 34 ++++++++++++++++++++++ sdk/storage/azdatalake/file/models.go | 3 ++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/sdk/storage/azdatalake/assets.json b/sdk/storage/azdatalake/assets.json index 626d6568abd4..81645a340794 100644 --- a/sdk/storage/azdatalake/assets.json +++ b/sdk/storage/azdatalake/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/storage/azdatalake", - "Tag": "go/storage/azdatalake_3ae5e1441b" + "Tag": "go/storage/azdatalake_7a31b2404b" } diff --git a/sdk/storage/azdatalake/file/client_test.go b/sdk/storage/azdatalake/file/client_test.go index cf738b6587f2..227587944351 100644 --- a/sdk/storage/azdatalake/file/client_test.go +++ b/sdk/storage/azdatalake/file/client_test.go @@ -3419,6 +3419,40 @@ func (s *RecordedTestSuite) TestDownloadDataContentMD5() { _require.Equal(resp1.ContentMD5, mdf[:]) } +func (s *RecordedTestSuite) TestFileAppendWithFlushOption() { + _require := require.New(s.T()) + testName := s.T().Name() + + filesystemName := testcommon.GenerateFileSystemName(testName) + fsClient, err := testcommon.GetFileSystemClient(filesystemName, s.T(), testcommon.TestAccountDatalake, nil) + _require.NoError(err) + defer testcommon.DeleteFileSystem(context.Background(), _require, fsClient) + + _, err = fsClient.Create(context.Background(), nil) + _require.NoError(err) + + srcFileName := "src" + testcommon.GenerateFileName(testName) + + srcFClient, err := testcommon.GetFileClient(filesystemName, srcFileName, s.T(), testcommon.TestAccountDatalake, nil) + _require.NoError(err) + + resp, err := srcFClient.Create(context.Background(), nil) + _require.NoError(err) + _require.NotNil(resp) + + contentSize := 1024 * 8 // 8KB + rsc, _ := testcommon.GenerateData(contentSize) + opts := &file.AppendDataOptions{ + Flush: to.Ptr(true), + } + _, err = srcFClient.AppendData(context.Background(), 0, rsc, opts) + _require.NoError(err) + + gResp2, err := srcFClient.GetProperties(context.Background(), nil) + _require.NoError(err) + _require.Equal(*gResp2.ContentLength, int64(contentSize)) +} + func (s *RecordedTestSuite) TestFileAppendAndFlushData() { _require := require.New(s.T()) testName := s.T().Name() diff --git a/sdk/storage/azdatalake/file/models.go b/sdk/storage/azdatalake/file/models.go index 27fa5e163166..7ffba3b11a31 100644 --- a/sdk/storage/azdatalake/file/models.go +++ b/sdk/storage/azdatalake/file/models.go @@ -243,6 +243,8 @@ type AppendDataOptions struct { LeaseAccessConditions *LeaseAccessConditions // CPKInfo contains optional parameters to perform encryption using customer-provided key. CPKInfo *CPKInfo + //Flush Optional. If true, the file will be flushed after append. + Flush *bool } func (o *AppendDataOptions) format(offset int64, body io.ReadSeekCloser) (*generated.PathClientAppendDataOptions, *generated.LeaseAccessConditions, *generated.CPKInfo, error) { @@ -280,6 +282,7 @@ func (o *AppendDataOptions) format(offset int64, body io.ReadSeekCloser) (*gener cpkInfoOpts.EncryptionKeySHA256 = o.CPKInfo.EncryptionKeySHA256 cpkInfoOpts.EncryptionAlgorithm = o.CPKInfo.EncryptionAlgorithm } + appendDataOptions.Flush = o.Flush } if o != nil && o.TransactionalValidation != nil { _, err = o.TransactionalValidation.Apply(body, appendDataOptions)