diff --git a/go.mod b/go.mod index aebc901f990c1..0b07abf7ca119 100644 --- a/go.mod +++ b/go.mod @@ -15,10 +15,10 @@ require ( github.com/gofrs/uuid v4.4.0+incompatible github.com/golang-jwt/jwt/v4 v4.5.0 github.com/google/go-cmp v0.5.9 - github.com/google/uuid v1.3.1 - github.com/hashicorp/go-azure-helpers v0.66.1 + github.com/google/uuid v1.4.0 + github.com/hashicorp/go-azure-helpers v0.66.2 github.com/hashicorp/go-azure-sdk/resource-manager v0.20240201.1064937 - github.com/hashicorp/go-azure-sdk/sdk v0.20240201.1064937 + github.com/hashicorp/go-azure-sdk/sdk v0.20240219.1162257-0.20240220115734-eeb1a5d96f9a github.com/hashicorp/go-hclog v1.5.0 github.com/hashicorp/go-multierror v1.1.1 github.com/hashicorp/go-uuid v1.0.3 @@ -29,7 +29,7 @@ require ( github.com/mitchellh/mapstructure v1.5.0 github.com/rickb777/date v1.12.5-0.20200422084442-6300e543c4d9 github.com/sergi/go-diff v1.2.0 - github.com/tombuildsstuff/giovanni v0.20.0 + github.com/tombuildsstuff/giovanni v0.23.1-0.20240220123934-c9b0ac79492b github.com/tombuildsstuff/kermit v0.20240122.1123108 golang.org/x/crypto v0.18.0 golang.org/x/tools v0.13.0 diff --git a/go.sum b/go.sum index de4c36122168f..ec8cf76a41282 100644 --- a/go.sum +++ b/go.sum @@ -1,36 +1,23 @@ dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk= dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk= -github.com/Azure/azure-sdk-for-go v45.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= -github.com/Azure/azure-sdk-for-go v56.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/azure-sdk-for-go v66.0.0+incompatible h1:bmmC38SlE8/E81nNADlgmVGurPWMHDX2YNXVQMrBpEE= github.com/Azure/azure-sdk-for-go v66.0.0+incompatible/go.mod h1:9XXNKU+eRnpl9moKnB4QOLf1HestfXbmab5FXxiDBjc= github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= github.com/Azure/go-autorest v14.2.0+incompatible/go.mod h1:r+4oMnoxhatjLLJ6zxSWATqVooLgysK6ZNox3g/xq24= -github.com/Azure/go-autorest/autorest v0.11.3/go.mod h1:JFgpikqFJ/MleTTxwepExTKnFUKKszPS8UavbQYUMuw= -github.com/Azure/go-autorest/autorest v0.11.19/go.mod h1:dSiJPy22c3u0OtOKDNttNgqpNFY/GeWa7GH/Pz56QRA= github.com/Azure/go-autorest/autorest v0.11.29 h1:I4+HL/JDvErx2LjyzaVxllw2lRDB5/BT2Bm4g20iqYw= github.com/Azure/go-autorest/autorest v0.11.29/go.mod h1:ZtEzC4Jy2JDrZLxvWs8LrBWEBycl1hbT1eknI8MtfAs= -github.com/Azure/go-autorest/autorest/adal v0.9.0/go.mod h1:/c022QCutn2P7uY+/oQWWNcK9YU+MH96NgK+jErpbcg= -github.com/Azure/go-autorest/autorest/adal v0.9.5/go.mod h1:B7KF7jKIeC9Mct5spmyCB/A8CG/sEz1vwIRGv/bbw7A= -github.com/Azure/go-autorest/autorest/adal v0.9.13/go.mod h1:W/MM4U6nLxnIskrw4UwWzlHfGjwUS50aOsc/I3yuU8M= -github.com/Azure/go-autorest/autorest/adal v0.9.14/go.mod h1:W/MM4U6nLxnIskrw4UwWzlHfGjwUS50aOsc/I3yuU8M= github.com/Azure/go-autorest/autorest/adal v0.9.22/go.mod h1:XuAbAEUv2Tta//+voMI038TrJBqjKam0me7qR+L8Cmk= github.com/Azure/go-autorest/autorest/adal v0.9.23 h1:Yepx8CvFxwNKpH6ja7RZ+sKX+DWYNldbLiALMC3BTz8= github.com/Azure/go-autorest/autorest/adal v0.9.23/go.mod h1:5pcMqFkdPhviJdlEy3kC/v1ZLnQl0MH6XA5YCcMhy4c= -github.com/Azure/go-autorest/autorest/azure/cli v0.4.0/go.mod h1:JljT387FplPzBA31vUcvsetLKF3pec5bdAxjVU4kI2s= -github.com/Azure/go-autorest/autorest/azure/cli v0.4.2/go.mod h1:7qkJkT+j6b+hIpzMOwPChJhTqS8VbsqqgULzMNRugoM= github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw= github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74= -github.com/Azure/go-autorest/autorest/mocks v0.4.0/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k= github.com/Azure/go-autorest/autorest/mocks v0.4.2 h1:PGN4EDXnuQbojHbU0UWoNvmu9AGVwYHG9/fkDYhtAfw= github.com/Azure/go-autorest/autorest/mocks v0.4.2/go.mod h1:Vy7OitM9Kei0i1Oj+LvyAWMXJHeKH1MVlzFugfVrmyU= github.com/Azure/go-autorest/autorest/to v0.4.0 h1:oXVqrxakqqV1UZdSazDOPOLvOIz+XA683u8EctwboHk= github.com/Azure/go-autorest/autorest/to v0.4.0/go.mod h1:fE8iZBn7LQR7zH/9XU2NcPR4o9jEImooCeWJcYV/zLE= -github.com/Azure/go-autorest/autorest/validation v0.3.0/go.mod h1:yhLgjC0Wda5DYXl6JAsWyUe4KVNffhoDhG0zVzUMo3E= github.com/Azure/go-autorest/autorest/validation v0.3.1 h1:AgyqjAd94fwNAoTjl/WQXg4VvFeRFpO+UhNyRXqF1ac= github.com/Azure/go-autorest/autorest/validation v0.3.1/go.mod h1:yhLgjC0Wda5DYXl6JAsWyUe4KVNffhoDhG0zVzUMo3E= -github.com/Azure/go-autorest/logger v0.2.0/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= github.com/Azure/go-autorest/logger v0.2.1 h1:IG7i4p/mDa2Ce4TRyAO8IHnVhAVF3RFU+ZtXWSmf4Tg= github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8= github.com/Azure/go-autorest/tracing v0.6.0 h1:TYi4+3m5t6K48TGI9AUdb+IzbnSxvnvUMfuitfgcfuo= @@ -67,16 +54,11 @@ github.com/dave/jennifer v1.6.0/go.mod h1:AxTG893FiZKqxy3FP1kL80VMshSMuz2G+Egvsz github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= -github.com/dimchansky/utfbom v1.1.0/go.mod h1:rO41eb7gLfo8SF1jd9F8HplJm1Fewwi4mQvIirEdv+8= -github.com/dimchansky/utfbom v1.1.1/go.mod h1:SxdoEBH5qIqFocHMyGOXVAybYJdr71b1Q/j0mACtrfE= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= -github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= -github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 h1:+zs/tPmkDkHx3U66DAb0lQFJrpS6731Oaa12ikc+DiI= github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376/go.mod h1:an3vInlBmSxCcxctByoQdvwPiA7DTK7jaaFDBTtu0ic= @@ -104,21 +86,19 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -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/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= +github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= github.com/hashicorp/errwrap v0.0.0-20180715044906-d6c0cd880357/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-azure-helpers v0.12.0/go.mod h1:Zc3v4DNeX6PDdy7NljlYpnrdac1++qNW0I4U+ofGwpg= -github.com/hashicorp/go-azure-helpers v0.66.1 h1:SokAckK9hvQ9PZO2TmZY/CGru8KWJ4A7hcRUggHMEus= -github.com/hashicorp/go-azure-helpers v0.66.1/go.mod h1:kJxXrFtJKJdOEqvad8pllAe7dhP4DbN8J6sqFZe47+4= +github.com/hashicorp/go-azure-helpers v0.66.2 h1:+Pzuo7pdKl0hBXXr5ymmhs4Q40tHAo2nAvHq4WgSjx8= +github.com/hashicorp/go-azure-helpers v0.66.2/go.mod h1:kJxXrFtJKJdOEqvad8pllAe7dhP4DbN8J6sqFZe47+4= github.com/hashicorp/go-azure-sdk/resource-manager v0.20240201.1064937 h1:0Qsxoi+3HFoZfWfcXFUKlWbbk2SiYdbb+FyRrMcrY1c= github.com/hashicorp/go-azure-sdk/resource-manager v0.20240201.1064937/go.mod h1:tWvx1elhgqkBLrnieHoGYzw253uFkybKTbXLfSMeJy8= -github.com/hashicorp/go-azure-sdk/sdk v0.20240201.1064937 h1:lb3ePovn8wlLdemYrT4MJFrWuzXKHiwDXvdcpeWlqPw= -github.com/hashicorp/go-azure-sdk/sdk v0.20240201.1064937/go.mod h1:6jgkzx26qtPndLSW5u7pKIw4m3iiFiLnHlp7yDQ2Crc= +github.com/hashicorp/go-azure-sdk/sdk v0.20240219.1162257-0.20240220115734-eeb1a5d96f9a h1:9Qg8M1Yp3WGmJw0FyAeg/4VXmp0m+6kfSJ//etdAfLk= +github.com/hashicorp/go-azure-sdk/sdk v0.20240219.1162257-0.20240220115734-eeb1a5d96f9a/go.mod h1:IKIPyL+hfFWBHABKT0NOWlIEzlusiUBG0SxIfaiv278= github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= github.com/hashicorp/go-checkpoint v0.5.0/go.mod h1:7nfLNL10NsxqO4iWuW6tWW0HjZuDrwkBuEQsVcpCOgg= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -130,7 +110,6 @@ github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrj github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= github.com/hashicorp/go-multierror v0.0.0-20180717150148-3d5d8f294aa0/go.mod h1:JMRHfdO9jKNzS/+BTlxCjKNQHg/jZAft8U7LloJvN7I= -github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-plugin v1.5.1 h1:oGm7cWBaYIp3lJpx1RUEfLWophprE2EV/KUeqBYo+6k= @@ -200,7 +179,6 @@ github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/goveralls v0.0.2/go.mod h1:8d1ZMHsd7fW6IRPKQh46F2WRpyib5/X4FOpevwGNQEw= github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU= github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= @@ -244,10 +222,11 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/tombuildsstuff/giovanni v0.20.0 h1:IM/I/iNWMXnPYwcSq8uxV7TKDlv7Nejq0bRK9i6O/C0= -github.com/tombuildsstuff/giovanni v0.20.0/go.mod h1:66KVLYma2whJhEdxPSPL3GQHkulhK+C5CluKfHGfPF4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/tombuildsstuff/giovanni v0.23.1-0.20240220123934-c9b0ac79492b h1:PFG9h3AislUPMnmxGXfGH9KhPNTpuVTxIerP09ml17g= +github.com/tombuildsstuff/giovanni v0.23.1-0.20240220123934-c9b0ac79492b/go.mod h1:YCAs90Jk6DT00i45SWNfhxVGFf2xFM9J6Af+K5+0fFU= github.com/tombuildsstuff/kermit v0.20240122.1123108 h1:icQaxsv/ANv/KC4Sr0V1trrWA/XIL+3QAVBDpiSTgj8= github.com/tombuildsstuff/kermit v0.20240122.1123108/go.mod h1:T3YBVFhRV4qA7SbnRaNE6eapIMpKDA9rG/V7Ocsjlno= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= @@ -267,9 +246,6 @@ github.com/zclconf/go-cty v1.14.0/go.mod h1:VvMs5i0vgZdhYawQNq5kePSpLAoz8u1xvZgr golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= diff --git a/vendor/github.com/google/uuid/CHANGELOG.md b/vendor/github.com/google/uuid/CHANGELOG.md index 2bd78667afbb3..7ed347d3ad737 100644 --- a/vendor/github.com/google/uuid/CHANGELOG.md +++ b/vendor/github.com/google/uuid/CHANGELOG.md @@ -1,5 +1,16 @@ # Changelog +## [1.4.0](https://github.com/google/uuid/compare/v1.3.1...v1.4.0) (2023-10-26) + + +### Features + +* UUIDs slice type with Strings() convenience method ([#133](https://github.com/google/uuid/issues/133)) ([cd5fbbd](https://github.com/google/uuid/commit/cd5fbbdd02f3e3467ac18940e07e062be1f864b4)) + +### Fixes + +* Clarify that Parse's job is to parse but not necessarily validate strings. (Documents current behavior) + ## [1.3.1](https://github.com/google/uuid/compare/v1.3.0...v1.3.1) (2023-08-18) diff --git a/vendor/github.com/google/uuid/CONTRIBUTING.md b/vendor/github.com/google/uuid/CONTRIBUTING.md index 5566888726d98..a502fdc515ac9 100644 --- a/vendor/github.com/google/uuid/CONTRIBUTING.md +++ b/vendor/github.com/google/uuid/CONTRIBUTING.md @@ -11,7 +11,7 @@ please explain why in the pull request description. ### Releasing -Commits that would precipitate a SemVer change, as desrcibed in the Conventional +Commits that would precipitate a SemVer change, as described in the Conventional Commits Specification, will trigger [`release-please`](https://github.com/google-github-actions/release-please-action) to create a release candidate pull request. Once submitted, `release-please` will create a release. diff --git a/vendor/github.com/google/uuid/uuid.go b/vendor/github.com/google/uuid/uuid.go index a56138cc4bd04..dc75f7d990919 100644 --- a/vendor/github.com/google/uuid/uuid.go +++ b/vendor/github.com/google/uuid/uuid.go @@ -56,11 +56,15 @@ func IsInvalidLengthError(err error) bool { return ok } -// Parse decodes s into a UUID or returns an error. Both the standard UUID -// forms of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and -// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx are decoded as well as the -// Microsoft encoding {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} and the raw hex -// encoding: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. +// Parse decodes s into a UUID or returns an error if it cannot be parsed. Both +// the standard UUID forms defined in RFC 4122 +// (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx and +// urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx) are decoded. In addition, +// Parse accepts non-standard strings such as the raw hex encoding +// xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx and 38 byte "Microsoft style" encodings, +// e.g. {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}. Only the middle 36 bytes are +// examined in the latter case. Parse should not be used to validate strings as +// it parses non-standard encodings as indicated above. func Parse(s string) (UUID, error) { var uuid UUID switch len(s) { @@ -294,3 +298,15 @@ func DisableRandPool() { poolMu.Lock() poolPos = randPoolSize } + +// UUIDs is a slice of UUID types. +type UUIDs []UUID + +// Strings returns a string slice containing the string form of each UUID in uuids. +func (uuids UUIDs) Strings() []string { + var uuidStrs = make([]string, len(uuids)) + for i, uuid := range uuids { + uuidStrs[i] = uuid.String() + } + return uuidStrs +} diff --git a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/fleet.go b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/kubernetes_fleet.go similarity index 60% rename from vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/fleet.go rename to vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/kubernetes_fleet.go index 8fb9b75366077..e0699d355e529 100644 --- a/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/fleet.go +++ b/vendor/github.com/hashicorp/go-azure-helpers/resourcemanager/commonids/kubernetes_fleet.go @@ -10,33 +10,33 @@ import ( "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" ) -var _ resourceids.ResourceId = &FleetId{} +var _ resourceids.ResourceId = &KubernetesFleetId{} -// FleetId is a struct representing the Resource ID for a Fleet -type FleetId struct { +// KubernetesFleetId is a struct representing the Resource ID for a KubernetesFleet +type KubernetesFleetId struct { SubscriptionId string ResourceGroupName string FleetName string } -// NewFleetID returns a new FleetId struct -func NewFleetID(subscriptionId string, resourceGroupName string, fleetName string) FleetId { - return FleetId{ +// NewKubernetesFleetID returns a new KubernetesFleetId struct +func NewKubernetesFleetID(subscriptionId string, resourceGroupName string, fleetName string) KubernetesFleetId { + return KubernetesFleetId{ SubscriptionId: subscriptionId, ResourceGroupName: resourceGroupName, FleetName: fleetName, } } -// ParseFleetID parses 'input' into a FleetId -func ParseFleetID(input string) (*FleetId, error) { - parser := resourceids.NewParserFromResourceIdType(&FleetId{}) +// ParseKubernetesFleetID parses 'input' into a KubernetesFleetId +func ParseKubernetesFleetID(input string) (*KubernetesFleetId, error) { + parser := resourceids.NewParserFromResourceIdType(&KubernetesFleetId{}) parsed, err := parser.Parse(input, false) if err != nil { return nil, fmt.Errorf("parsing %q: %+v", input, err) } - id := FleetId{} + id := KubernetesFleetId{} if err := id.FromParseResult(*parsed); err != nil { return nil, err } @@ -44,16 +44,16 @@ func ParseFleetID(input string) (*FleetId, error) { return &id, nil } -// ParseFleetIDInsensitively parses 'input' case-insensitively into a FleetId +// ParseKubernetesFleetIDInsensitively parses 'input' case-insensitively into a KubernetesFleetId // note: this method should only be used for API response data and not user input -func ParseFleetIDInsensitively(input string) (*FleetId, error) { - parser := resourceids.NewParserFromResourceIdType(&FleetId{}) +func ParseKubernetesFleetIDInsensitively(input string) (*KubernetesFleetId, error) { + parser := resourceids.NewParserFromResourceIdType(&KubernetesFleetId{}) parsed, err := parser.Parse(input, true) if err != nil { return nil, fmt.Errorf("parsing %q: %+v", input, err) } - id := FleetId{} + id := KubernetesFleetId{} if err = id.FromParseResult(*parsed); err != nil { return nil, err } @@ -61,7 +61,7 @@ func ParseFleetIDInsensitively(input string) (*FleetId, error) { return &id, nil } -func (id *FleetId) FromParseResult(input resourceids.ParseResult) error { +func (id *KubernetesFleetId) FromParseResult(input resourceids.ParseResult) error { var ok bool if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { @@ -79,29 +79,29 @@ func (id *FleetId) FromParseResult(input resourceids.ParseResult) error { return nil } -// ValidateFleetID checks that 'input' can be parsed as a Fleet ID -func ValidateFleetID(input interface{}, key string) (warnings []string, errors []error) { +// ValidateKubernetesFleetID checks that 'input' can be parsed as a KubernetesFleet ID +func ValidateKubernetesFleetID(input interface{}, key string) (warnings []string, errors []error) { v, ok := input.(string) if !ok { errors = append(errors, fmt.Errorf("expected %q to be a string", key)) return } - if _, err := ParseFleetID(v); err != nil { + if _, err := ParseKubernetesFleetID(v); err != nil { errors = append(errors, err) } return } -// ID returns the formatted Fleet ID -func (id FleetId) ID() string { +// ID returns the formatted KubernetesFleet ID +func (id KubernetesFleetId) ID() string { fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.ContainerService/fleets/%s" return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.FleetName) } -// Segments returns a slice of Resource ID Segments which comprise this Fleet ID -func (id FleetId) Segments() []resourceids.Segment { +// Segments returns a slice of Resource ID Segments which comprise this KubernetesFleet ID +func (id KubernetesFleetId) Segments() []resourceids.Segment { return []resourceids.Segment{ resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), @@ -109,17 +109,17 @@ func (id FleetId) Segments() []resourceids.Segment { resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), resourceids.StaticSegment("staticProviders", "providers", "providers"), resourceids.ResourceProviderSegment("staticMicrosoftContainerService", "Microsoft.ContainerService", "Microsoft.ContainerService"), - resourceids.StaticSegment("staticFleets", "fleets", "fleets"), + resourceids.StaticSegment("staticKubernetesFleets", "fleets", "fleets"), resourceids.UserSpecifiedSegment("fleetName", "fleetValue"), } } -// String returns a human-readable description of this Fleet ID -func (id FleetId) String() string { +// String returns a human-readable description of this KubernetesFleet ID +func (id KubernetesFleetId) String() string { components := []string{ fmt.Sprintf("Subscription: %q", id.SubscriptionId), fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), - fmt.Sprintf("Fleet Name: %q", id.FleetName), + fmt.Sprintf("KubernetesFleet Name: %q", id.FleetName), } - return fmt.Sprintf("Fleet (%s)", strings.Join(components, "\n")) + return fmt.Sprintf("KubernetesFleet (%s)", strings.Join(components, "\n")) } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/client.go b/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/client.go index 5dc6879f87cd0..ee26b40a0b202 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/client.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/client.go @@ -91,39 +91,43 @@ type Request struct { func (r *Request) Marshal(payload interface{}) error { contentType := strings.ToLower(r.Header.Get("Content-Type")) - if strings.Contains(contentType, "application/json") { + switch { + case strings.Contains(contentType, "application/json"): body, err := json.Marshal(payload) if err == nil { r.ContentLength = int64(len(body)) r.Body = io.NopCloser(bytes.NewReader(body)) } + return nil - } - if strings.Contains(contentType, "application/xml") || strings.Contains(contentType, "text/xml") { + case strings.Contains(contentType, "application/xml") || strings.Contains(contentType, "text/xml"): body, err := xml.Marshal(payload) if err == nil { r.ContentLength = int64(len(body)) r.Body = io.NopCloser(bytes.NewReader(body)) } + return nil } - if strings.Contains(contentType, "application/octet-stream") || strings.Contains(contentType, "text/powershell") { - switch v := payload.(type) { - case *[]byte: + switch v := payload.(type) { + case *[]byte: + if v == nil { + r.ContentLength = int64(len([]byte{})) + r.Body = io.NopCloser(bytes.NewReader([]byte{})) + } else { r.ContentLength = int64(len(*v)) r.Body = io.NopCloser(bytes.NewReader(*v)) - case []byte: - r.ContentLength = int64(len(v)) - r.Body = io.NopCloser(bytes.NewReader(v)) - default: - return fmt.Errorf("internal-error: `payload` must be []byte or *[]byte but got type %T", payload) } - return nil + case []byte: + r.ContentLength = int64(len(v)) + r.Body = io.NopCloser(bytes.NewReader(v)) + default: + return fmt.Errorf("internal-error: `payload` must be []byte or *[]byte but got type %T", payload) } - return fmt.Errorf("internal-error: unimplemented marshal function for content type %q", contentType) + return nil } // Execute invokes the Execute method for the Request's Client @@ -173,12 +177,14 @@ func (r *Response) Unmarshal(model interface{}) error { contentType = strings.ToLower(r.Request.Header.Get("Content-Type")) } } - // the maintenance API returns a 200 for a delete with no content-type and no content length so we should skip - // trying to unmarshal this + + // Some APIs (e.g. Maintenance) return 200 without a body, don't unmarshal these if r.ContentLength == 0 && (r.Body == nil || r.Body == http.NoBody) { return nil } - if strings.Contains(contentType, "application/json") { + + switch { + case strings.Contains(contentType, "application/json"): // Read the response body and close it respBody, err := io.ReadAll(r.Body) if err != nil { @@ -189,6 +195,11 @@ func (r *Response) Unmarshal(model interface{}) error { // Trim away a BOM if present respBody = bytes.TrimPrefix(respBody, []byte("\xef\xbb\xbf")) + // In some cases the respBody is empty, but not nil, so don't attempt to unmarshal this + if len(respBody) == 0 { + return nil + } + // Unmarshal into provided model if err := json.Unmarshal(respBody, model); err != nil { return fmt.Errorf("unmarshaling response body: %+v", err) @@ -196,10 +207,10 @@ func (r *Response) Unmarshal(model interface{}) error { // Reassign the response body as downstream code may expect it r.Body = io.NopCloser(bytes.NewBuffer(respBody)) + return nil - } - if strings.Contains(contentType, "application/xml") || strings.Contains(contentType, "text/xml") { + case strings.Contains(contentType, "application/xml") || strings.Contains(contentType, "text/xml"): // Read the response body and close it respBody, err := io.ReadAll(r.Body) if err != nil { @@ -210,6 +221,11 @@ func (r *Response) Unmarshal(model interface{}) error { // Trim away a BOM if present respBody = bytes.TrimPrefix(respBody, []byte("\xef\xbb\xbf")) + // In some cases the respBody is empty, but not nil, so don't attempt to unmarshal this + if len(respBody) == 0 { + return nil + } + // Unmarshal into provided model if err := xml.Unmarshal(respBody, model); err != nil { return err @@ -217,13 +233,13 @@ func (r *Response) Unmarshal(model interface{}) error { // Reassign the response body as downstream code may expect it r.Body = io.NopCloser(bytes.NewBuffer(respBody)) + return nil - } - if strings.Contains(contentType, "application/octet-stream") || strings.Contains(contentType, "text/powershell") { - ptr, ok := model.(**[]byte) + case strings.Contains(contentType, "application/octet-stream") || strings.Contains(contentType, "text/powershell"): + ptr, ok := model.(*[]byte) if !ok || ptr == nil { - return fmt.Errorf("internal-error: `model` must be a non-nil `**[]byte` but got %+v", model) + return fmt.Errorf("internal-error: `model` must be a non-nil `*[]byte` but got %[1]T: %+[1]v", model) } // Read the response body and close it @@ -233,14 +249,17 @@ func (r *Response) Unmarshal(model interface{}) error { } r.Body.Close() - // Trim away a BOM if present - respBody = bytes.TrimPrefix(respBody, []byte("\xef\xbb\xbf")) + if strings.HasPrefix(contentType, "text/") { + // Trim away a BOM if present + respBody = bytes.TrimPrefix(respBody, []byte("\xef\xbb\xbf")) + } // copy the byte stream across - *ptr = &respBody + *ptr = respBody // Reassign the response body as downstream code may expect it r.Body = io.NopCloser(bytes.NewBuffer(respBody)) + return nil } @@ -289,6 +308,49 @@ func NewClient(baseUri string, serviceName, apiVersion string) *Client { } } +// SetAuthorizer configures the request authorizer for the client +func (c *Client) SetAuthorizer(authorizer auth.Authorizer) { + c.Authorizer = authorizer +} + +// SetUserAgent configures the user agent to be included in requests +func (c *Client) SetUserAgent(userAgent string) { + c.UserAgent = userAgent +} + +// GetUserAgent retrieves the configured user agent for the client +func (c *Client) GetUserAgent() string { + return c.UserAgent +} + +// AppendRequestMiddleware appends a request middleware function for the client +func (c *Client) AppendRequestMiddleware(f RequestMiddleware) { + if c.RequestMiddlewares == nil { + m := make([]RequestMiddleware, 0) + c.RequestMiddlewares = &m + } + *c.RequestMiddlewares = append(*c.RequestMiddlewares, f) +} + +// ClearRequestMiddlewares removes all request middleware functions for the client +func (c *Client) ClearRequestMiddlewares() { + c.RequestMiddlewares = nil +} + +// AppendResponseMiddleware appends a response middleware function for the client +func (c *Client) AppendResponseMiddleware(f ResponseMiddleware) { + if c.ResponseMiddlewares == nil { + m := make([]ResponseMiddleware, 0) + c.ResponseMiddlewares = &m + } + *c.ResponseMiddlewares = append(*c.ResponseMiddlewares, f) +} + +// ClearResponseMiddlewares removes all response middleware functions for the client +func (c *Client) ClearResponseMiddlewares() { + c.ResponseMiddlewares = nil +} + // NewRequest configures a new *Request func (c *Client) NewRequest(ctx context.Context, input RequestOptions) (*Request, error) { req := (&http.Request{}).WithContext(ctx) @@ -321,6 +383,7 @@ func (c *Client) NewRequest(ctx context.Context, input RequestOptions) (*Request Client: c, Request: req, Pager: input.Pager, + RetryFunc: input.RetryFunc, ValidStatusCodes: input.ExpectedStatusCodes, } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/client.go b/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/client.go new file mode 100644 index 0000000000000..5e0dd27d9f070 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/client.go @@ -0,0 +1,27 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package dataplane + +import ( + "github.com/hashicorp/go-azure-sdk/sdk/client" +) + +var _ client.BaseClient = &Client{} + +type Client struct { + *client.Client + + // ApiVersion specifies the version of the API being used, which (by design) will be consistent across a client + // as we intentionally split out multiple API Versions into different clients, rather than using composite API + // Versions/packages which can cause confusion about which version is being used. + ApiVersion string +} + +func NewDataPlaneClient(baseUri string, serviceName, apiVersion string) *Client { + client := &Client{ + Client: client.NewClient(baseUri, serviceName, apiVersion), + ApiVersion: apiVersion, + } + return client +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/storage/client.go b/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/storage/client.go new file mode 100644 index 0000000000000..27dedf17c000e --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/storage/client.go @@ -0,0 +1,73 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package storage + +import ( + "context" + "fmt" + "net/url" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/dataplane" +) + +var _ client.BaseClient = &Client{} + +var storageDefaultRetryFunctions = []client.RequestRetryFunc{ + // TODO: stuff n tings +} + +type Client struct { + *dataplane.Client +} + +func NewStorageClient(baseUri string, componentName, apiVersion string) (*Client, error) { + // NOTE: both the domain name _and_ the domain format can change entirely depending on the type of storage account being used + // when provisioned in an edge zone, and when AzureDNSZone is used, as such we require the baseUri is provided here + return &Client{ + Client: dataplane.NewDataPlaneClient(baseUri, fmt.Sprintf("storage/%s", componentName), apiVersion), + }, nil +} + +func (c *Client) NewRequest(ctx context.Context, input client.RequestOptions) (*client.Request, error) { + // TODO move these validations to base client method + if _, ok := ctx.Deadline(); !ok { + return nil, fmt.Errorf("internal-error: the context used must have a deadline attached for polling purposes, but got no deadline") + } + if err := input.Validate(); err != nil { + return nil, fmt.Errorf("internal-error: pre-validating request payload: %+v", err) + } + + req, err := c.Client.Client.NewRequest(ctx, input) + if err != nil { + return nil, fmt.Errorf("building %s request: %+v", input.HttpMethod, err) + } + + req.Client = c + req.Header.Add("x-ms-version", c.Client.ApiVersion) + + query := url.Values{} + if input.OptionsObject != nil { + if h := input.OptionsObject.ToHeaders(); h != nil { + for k, v := range h.Headers() { + req.Header[k] = v + } + } + + if q := input.OptionsObject.ToQuery(); q != nil { + query = q.Values() + } + + if o := input.OptionsObject.ToOData(); o != nil { + req.Header = o.AppendHeaders(req.Header) + query = o.AppendValues(query) + } + } + + req.URL.RawQuery = query.Encode() + req.RetryFunc = client.RequestRetryAny(append(storageDefaultRetryFunctions, input.RetryFunc)...) + req.ValidStatusCodes = input.ExpectedStatusCodes + + return req, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/interface.go b/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/interface.go index da302e24added..5886a19ff574a 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/interface.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/interface.go @@ -7,6 +7,7 @@ import ( "context" "net/http" + "github.com/hashicorp/go-azure-sdk/sdk/auth" "github.com/hashicorp/go-azure-sdk/sdk/odata" ) @@ -19,6 +20,27 @@ type BaseClient interface { // NewRequest constructs a *Request that can be passed to Execute or ExecutePaged NewRequest(ctx context.Context, input RequestOptions) (*Request, error) + + // SetAuthorizer configures the request authorizer for the client + SetAuthorizer(auth.Authorizer) + + // SetUserAgent configures the user agent to be included in requests + SetUserAgent(string) + + // GetUserAgent retrieves the configured user agent for the client + GetUserAgent() string + + // AppendRequestMiddleware appends a request middleware function for the client + AppendRequestMiddleware(RequestMiddleware) + + // ClearRequestMiddlewares removes all request middleware functions for the client + ClearRequestMiddlewares() + + // AppendResponseMiddleware appends a response middleware function for the client + AppendResponseMiddleware(ResponseMiddleware) + + // ClearResponseMiddlewares removes all response middleware functions for the client + ClearResponseMiddlewares() } // RequestRetryFunc is a function that determines whether an HTTP request has failed due to eventual consistency and should be retried diff --git a/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/request_options.go b/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/request_options.go index 402b497c0b0c8..d76a028b4f250 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/request_options.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/request_options.go @@ -28,6 +28,9 @@ type RequestOptions struct { // Path is the absolute URI for this request, with a leading slash. Path string + + // RetryFunc is an optional function to determine whether a request should be automatically retried + RetryFunc RequestRetryFunc } func (ro RequestOptions) Validate() error { diff --git a/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager/client.go b/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager/client.go index 104b4c002f2ad..8c9b67a9c4fe6 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager/client.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager/client.go @@ -86,7 +86,7 @@ func (c *Client) NewRequest(ctx context.Context, input client.RequestOptions) (* req.URL.RawQuery = query.Encode() req.Pager = input.Pager - req.RetryFunc = client.RequestRetryAny(defaultRetryFunctions...) + req.RetryFunc = client.RequestRetryAny(append(defaultRetryFunctions, input.RetryFunc)...) req.ValidStatusCodes = input.ExpectedStatusCodes return req, nil diff --git a/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager/poller_lro.go b/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager/poller_lro.go index 348e7f80b7c95..3876b7b11a7e8 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager/poller_lro.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager/poller_lro.go @@ -164,45 +164,72 @@ func (p *longRunningOperationPoller) Poll(ctx context.Context) (result *pollers. // whilst the standard set above should be sufficient, some APIs differ from the spec and should be documented below: // Dashboard@2022-08-01 returns `Accepted` rather than `InProgress` during creation "Accepted": pollers.PollingStatusInProgress, + // EventGrid@2022-06-15 returns `Active` rather than `InProgress` during creation "Active": pollers.PollingStatusInProgress, + // NetAppVolumeReplication @ 2023-05-01 returns `AuthorizeReplication` during authorizing replication "AuthorizeReplication": pollers.PollingStatusInProgress, + // NetAppVolumeReplication @ 2023-05-01 returns `BreakReplication` during breaking replication "BreakReplication": pollers.PollingStatusInProgress, + // Mysql @ 2022-01-01 returns `CancelInProgress` during Update "CancelInProgress": pollers.PollingStatusInProgress, + // CostManagement@2021-10-01 returns `Completed` rather than `Succeeded`: https://github.com/Azure/azure-sdk-for-go/issues/20342 "Completed": pollers.PollingStatusSucceeded, + + // ServiceFabricManaged @ 2021-05-01 (NodeTypes CreateOrUpdate) returns `Created` rather than `InProgress` during Creation + "Created": pollers.PollingStatusInProgress, + // ContainerRegistry@2019-06-01-preview returns `Creating` rather than `InProgress` during creation "Creating": pollers.PollingStatusInProgress, - // SignalR@2022-02-01 returns `Running` rather than `InProgress` during creation - "Running": pollers.PollingStatusInProgress, - // KubernetesConfiguration@2022-11-01 returns `Updating` rather than `InProgress` during update - "Updating": pollers.PollingStatusInProgress, - // StorageSync@2020-03-01 returns `validateInput`, `newPrivateDnsEntries`, `finishNewStorageSyncService` rather than `InProgress` during creation/update - // See: https://github.com/hashicorp/go-azure-sdk/issues/565 - "validateInput": pollers.PollingStatusInProgress, - "newPrivateDnsEntries": pollers.PollingStatusInProgress, + + // StorageSync@2020-03-01 returns `finishNewStorageSyncService` rather than `InProgress` during creation/update (https://github.com/hashicorp/go-azure-sdk/issues/565) + "finishNewStorageSyncService": pollers.PollingStatusInProgress, + + // StorageSync@2020-03-01 returns `newManagedIdentityCredentialStep` rather than `InProgress` during creation/update (https://github.com/hashicorp/go-azure-sdk/issues/565) "newManagedIdentityCredentialStep": pollers.PollingStatusInProgress, - "finishNewStorageSyncService": pollers.PollingStatusInProgress, - // StorageSync@2020-03-01 (CloudEndpoints) returns `newReplicaGroup` rather than `InProgress` during creation/update - // See: https://github.com/hashicorp/go-azure-sdk/issues/565 + + // StorageSync@2020-03-01 returns `newPrivateDnsEntries` rather than `InProgress` during creation/update (https://github.com/hashicorp/go-azure-sdk/issues/565) + "newPrivateDnsEntries": pollers.PollingStatusInProgress, + + // StorageSync@2020-03-01 (CloudEndpoints) returns `newReplicaGroup` rather than `InProgress` during creation/update (https://github.com/hashicorp/go-azure-sdk/issues/565) "newReplicaGroup": pollers.PollingStatusInProgress, - // SAPVirtualInstance @ 2023-04-01 returns `Preparing System Configuration` during Creation - "Preparing System Configuration": pollers.PollingStatusInProgress, + + // NetApp @ 2023-05-01 (Volume Update) returns `Patching` during Update + "Patching": pollers.PollingStatusInProgress, + // AnalysisServices @ 2017-08-01 (Servers Suspend) returns `Pausing` during update "Pausing": pollers.PollingStatusInProgress, + + // SAPVirtualInstance @ 2023-04-01 returns `Preparing System Configuration` during Creation + "Preparing System Configuration": pollers.PollingStatusInProgress, + // AnalysisServices @ 2017-08-01 (Servers) returns `Provisioning` during Creation "Provisioning": pollers.PollingStatusInProgress, + // Resources @ 2020-10-01 (DeploymentScripts) returns `ProvisioningResources` during Creation "ProvisioningResources": pollers.PollingStatusInProgress, + // AnalysisServices @ 2017-08-01 (Servers Resume) returns `Resuming` during Update "Resuming": pollers.PollingStatusInProgress, + + // SignalR@2022-02-01 returns `Running` rather than `InProgress` during creation + "Running": pollers.PollingStatusInProgress, + // AnalysisServices @ 2017-08-01 (Servers Suspend) returns `Scaling` during Update "Scaling": pollers.PollingStatusInProgress, + + // KubernetesConfiguration@2022-11-01 returns `Updating` rather than `InProgress` during update + "Updating": pollers.PollingStatusInProgress, + // HealthBot @ 2022-08-08 (HealthBots CreateOrUpdate) returns `Working` during Creation "Working": pollers.PollingStatusInProgress, + + // StorageSync@2020-03-01 returns `validateInput` rather than `InProgress` during creation/update (https://github.com/hashicorp/go-azure-sdk/issues/565) + "validateInput": pollers.PollingStatusInProgress, } for k, v := range statuses { if strings.EqualFold(string(op.Properties.ProvisioningState), string(k)) { diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts/client.go deleted file mode 100644 index 0162ebbb0c331..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts/client.go +++ /dev/null @@ -1,25 +0,0 @@ -package accounts - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Client is the base client for Blob Storage Blobs. -type Client struct { - autorest.Client - BaseURI string -} - -// New creates an instance of the Client client. -func New() Client { - return NewWithEnvironment(azure.PublicCloud) -} - -// NewWithBaseURI creates an instance of the Client client. -func NewWithEnvironment(environment azure.Environment) Client { - return Client{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: environment.StorageEndpointSuffix, - } -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts/get_service_properties.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts/get_service_properties.go deleted file mode 100644 index e622fff3ba463..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts/get_service_properties.go +++ /dev/null @@ -1,84 +0,0 @@ -package accounts - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type GetServicePropertiesResult struct { - autorest.Response - - ContentType string - StorageServiceProperties *StorageServiceProperties -} - -// GetServicePropertiesPreparer prepares the GetServiceProperties request. -func (client Client) GetServicePropertiesPreparer(ctx context.Context, accountName string) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "restype": "service", - "comp": "properties", - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithHeaders(headers), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -func (client Client) GetServicePropertiesSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -func (client Client) GetServicePropertiesResponder(resp *http.Response) (result GetServicePropertiesResult, err error) { - if resp != nil && resp.Header != nil { - result.ContentType = resp.Header.Get("Content-Type") - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingXML(&result.StorageServiceProperties), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -func (client Client) GetServiceProperties(ctx context.Context, accountName string) (result GetServicePropertiesResult, err error) { - if accountName == "" { - return result, validation.NewError("accounts.Client", "GetServiceProperties", "`accountName` cannot be an empty string.") - } - - req, err := client.GetServicePropertiesPreparer(ctx, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "accounts.Client", "GetServiceProperties", nil, "Failure preparing request") - return - } - - resp, err := client.GetServicePropertiesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "accounts.Client", "GetServiceProperties", resp, "Failure sending request") - return - } - - result, err = client.GetServicePropertiesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "accounts.Client", "GetServiceProperties", resp, "Failure responding to request") - return - } - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts/set_service_properties.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts/set_service_properties.go deleted file mode 100644 index 17b7bcc7e7637..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts/set_service_properties.go +++ /dev/null @@ -1,77 +0,0 @@ -package accounts - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// SetServicePropertiesSender sends the SetServiceProperties request. The method will close the -// http.Response Body if it receives an error. -func (client Client) SetServicePropertiesSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// SetServicePropertiesPreparer prepares the SetServiceProperties request. -func (client Client) SetServicePropertiesPreparer(ctx context.Context, accountName string, input StorageServiceProperties) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "restype": "service", - "comp": "properties", - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithHeaders(headers), - autorest.WithXML(input), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SetServicePropertiesResponder handles the response to the SetServiceProperties request. The method always -// closes the http.Response Body. -func (client Client) SetServicePropertiesResponder(resp *http.Response) (result SetServicePropertiesResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} - -func (client Client) SetServiceProperties(ctx context.Context, accountName string, input StorageServiceProperties) (result SetServicePropertiesResult, err error) { - if accountName == "" { - return result, validation.NewError("accounts.Client", "SetServiceProperties", "`accountName` cannot be an empty string.") - } - - req, err := client.SetServicePropertiesPreparer(ctx, accountName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "accounts.Client", "SetServiceProperties", nil, "Failure preparing request") - return - } - - resp, err := client.SetServicePropertiesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "accounts.Client", "SetServiceProperties", resp, "Failure sending request") - return - } - - result, err = client.SetServicePropertiesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "accounts.Client", "SetServiceProperties", resp, "Failure responding to request") - return - } - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts/version.go deleted file mode 100644 index 3d6d011470037..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts/version.go +++ /dev/null @@ -1,14 +0,0 @@ -package accounts - -import ( - "fmt" - - "github.com/tombuildsstuff/giovanni/version" -) - -// APIVersion is the version of the API used for all Storage API Operations -const APIVersion = "2020-08-04" - -func UserAgent() string { - return fmt.Sprintf("tombuildsstuff/giovanni/%s storage/%s", version.Number, APIVersion) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/api.go deleted file mode 100644 index 7e4f6494c2d10..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/api.go +++ /dev/null @@ -1,45 +0,0 @@ -package blobs - -import ( - "context" - "os" - "time" - - "github.com/Azure/go-autorest/autorest" -) - -type StorageBlob interface { - AppendBlock(ctx context.Context, accountName, containerName, blobName string, input AppendBlockInput) (result AppendBlockResult, err error) - Copy(ctx context.Context, accountName, containerName, blobName string, input CopyInput) (result CopyResult, err error) - AbortCopy(ctx context.Context, accountName, containerName, blobName string, input AbortCopyInput) (result autorest.Response, err error) - CopyAndWait(ctx context.Context, accountName, containerName, blobName string, input CopyInput, pollingInterval time.Duration) error - Delete(ctx context.Context, accountName, containerName, blobName string, input DeleteInput) (result autorest.Response, err error) - DeleteSnapshot(ctx context.Context, accountName, containerName, blobName string, input DeleteSnapshotInput) (result autorest.Response, err error) - DeleteSnapshots(ctx context.Context, accountName, containerName, blobName string, input DeleteSnapshotsInput) (result autorest.Response, err error) - Get(ctx context.Context, accountName, containerName, blobName string, input GetInput) (result GetResult, err error) - GetBlockList(ctx context.Context, accountName, containerName, blobName string, input GetBlockListInput) (result GetBlockListResult, err error) - GetPageRanges(ctx context.Context, accountName, containerName, blobName string, input GetPageRangesInput) (result GetPageRangesResult, err error) - IncrementalCopyBlob(ctx context.Context, accountName, containerName, blobName string, input IncrementalCopyBlobInput) (result autorest.Response, err error) - AcquireLease(ctx context.Context, accountName, containerName, blobName string, input AcquireLeaseInput) (result AcquireLeaseResult, err error) - BreakLease(ctx context.Context, accountName, containerName, blobName string, input BreakLeaseInput) (result autorest.Response, err error) - ChangeLease(ctx context.Context, accountName, containerName, blobName string, input ChangeLeaseInput) (result ChangeLeaseResponse, err error) - ReleaseLease(ctx context.Context, accountName, containerName, blobName, leaseID string) (result autorest.Response, err error) - RenewLease(ctx context.Context, accountName, containerName, blobName, leaseID string) (result autorest.Response, err error) - SetMetaData(ctx context.Context, accountName, containerName, blobName string, input SetMetaDataInput) (result autorest.Response, err error) - GetProperties(ctx context.Context, accountName, containerName, blobName string, input GetPropertiesInput) (result GetPropertiesResult, err error) - SetProperties(ctx context.Context, accountName, containerName, blobName string, input SetPropertiesInput) (result SetPropertiesResult, err error) - PutAppendBlob(ctx context.Context, accountName, containerName, blobName string, input PutAppendBlobInput) (result autorest.Response, err error) - PutBlock(ctx context.Context, accountName, containerName, blobName string, input PutBlockInput) (result PutBlockResult, err error) - PutBlockBlob(ctx context.Context, accountName, containerName, blobName string, input PutBlockBlobInput) (result autorest.Response, err error) - PutBlockBlobFromFile(ctx context.Context, accountName, containerName, blobName string, file *os.File, input PutBlockBlobInput) error - PutBlockList(ctx context.Context, accountName, containerName, blobName string, input PutBlockListInput) (result PutBlockListResult, err error) - PutBlockFromURL(ctx context.Context, accountName, containerName, blobName string, input PutBlockFromURLInput) (result PutBlockFromURLResult, err error) - PutPageBlob(ctx context.Context, accountName, containerName, blobName string, input PutPageBlobInput) (result autorest.Response, err error) - PutPageClear(ctx context.Context, accountName, containerName, blobName string, input PutPageClearInput) (result autorest.Response, err error) - PutPageUpdate(ctx context.Context, accountName, containerName, blobName string, input PutPageUpdateInput) (result PutPageUpdateResult, err error) - GetResourceID(accountName, containerName, blobName string) string - SetTier(ctx context.Context, accountName, containerName, blobName string, tier AccessTier) (result autorest.Response, err error) - Snapshot(ctx context.Context, accountName, containerName, blobName string, input SnapshotInput) (result SnapshotResult, err error) - GetSnapshotProperties(ctx context.Context, accountName, containerName, blobName string, input GetSnapshotPropertiesInput) (result GetPropertiesResult, err error) - Undelete(ctx context.Context, accountName, containerName, blobName string) (result autorest.Response, err error) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/append_block.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/append_block.go deleted file mode 100644 index b7705c202518a..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/append_block.go +++ /dev/null @@ -1,180 +0,0 @@ -package blobs - -import ( - "context" - "fmt" - "net/http" - "strconv" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type AppendBlockInput struct { - - // A number indicating the byte offset to compare. - // Append Block will succeed only if the append position is equal to this number. - // If it is not, the request will fail with an AppendPositionConditionNotMet - // error (HTTP status code 412 – Precondition Failed) - BlobConditionAppendPosition *int64 - - // The max length in bytes permitted for the append blob. - // If the Append Block operation would cause the blob to exceed that limit or if the blob size - // is already greater than the value specified in this header, the request will fail with - // an MaxBlobSizeConditionNotMet error (HTTP status code 412 – Precondition Failed). - BlobConditionMaxSize *int64 - - // The Bytes which should be appended to the end of this Append Blob. - // This can either be nil, which creates an empty blob, or a byte array - Content *[]byte - - // An MD5 hash of the block content. - // This hash is used to verify the integrity of the block during transport. - // When this header is specified, the storage service compares the hash of the content - // that has arrived with this header value. - // - // Note that this MD5 hash is not stored with the blob. - // If the two hashes do not match, the operation will fail with error code 400 (Bad Request). - ContentMD5 *string - - // Required if the blob has an active lease. - // To perform this operation on a blob with an active lease, specify the valid lease ID for this header. - LeaseID *string -} - -type AppendBlockResult struct { - autorest.Response - - BlobAppendOffset string - BlobCommittedBlockCount int64 - ContentMD5 string - ETag string - LastModified string -} - -// AppendBlock commits a new block of data to the end of an existing append blob. -func (client Client) AppendBlock(ctx context.Context, accountName, containerName, blobName string, input AppendBlockInput) (result AppendBlockResult, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "AppendBlock", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "AppendBlock", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "AppendBlock", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "AppendBlock", "`blobName` cannot be an empty string.") - } - if input.Content != nil && len(*input.Content) > (4*1024*1024) { - return result, validation.NewError("files.Client", "PutByteRange", "`input.Content` must be at most 4MB.") - } - - req, err := client.AppendBlockPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "AppendBlock", nil, "Failure preparing request") - return - } - - resp, err := client.AppendBlockSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "AppendBlock", resp, "Failure sending request") - return - } - - result, err = client.AppendBlockResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "AppendBlock", resp, "Failure responding to request") - return - } - - return -} - -// AppendBlockPreparer prepares the AppendBlock request. -func (client Client) AppendBlockPreparer(ctx context.Context, accountName, containerName, blobName string, input AppendBlockInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "appendblock"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - if input.BlobConditionAppendPosition != nil { - headers["x-ms-blob-condition-appendpos"] = *input.BlobConditionAppendPosition - } - if input.BlobConditionMaxSize != nil { - headers["x-ms-blob-condition-maxsize"] = *input.BlobConditionMaxSize - } - if input.ContentMD5 != nil { - headers["x-ms-blob-content-md5"] = *input.ContentMD5 - } - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - if input.Content != nil { - headers["Content-Length"] = int(len(*input.Content)) - } - - decorators := []autorest.PrepareDecorator{ - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers), - } - - if input.Content != nil { - decorators = append(decorators, autorest.WithBytes(input.Content)) - } - - preparer := autorest.CreatePreparer(decorators...) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// AppendBlockSender sends the AppendBlock request. The method will close the -// http.Response Body if it receives an error. -func (client Client) AppendBlockSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// AppendBlockResponder handles the response to the AppendBlock request. The method always -// closes the http.Response Body. -func (client Client) AppendBlockResponder(resp *http.Response) (result AppendBlockResult, err error) { - if resp != nil && resp.Header != nil { - result.BlobAppendOffset = resp.Header.Get("x-ms-blob-append-offset") - result.ContentMD5 = resp.Header.Get("ETag") - result.ETag = resp.Header.Get("ETag") - result.LastModified = resp.Header.Get("Last-Modified") - - if v := resp.Header.Get("x-ms-blob-committed-block-count"); v != "" { - i, innerErr := strconv.Atoi(v) - if innerErr != nil { - err = fmt.Errorf("Error parsing %q as an integer: %s", v, innerErr) - return - } - - result.BlobCommittedBlockCount = int64(i) - } - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/client.go deleted file mode 100644 index db20391922bb8..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/client.go +++ /dev/null @@ -1,25 +0,0 @@ -package blobs - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Client is the base client for Blob Storage Blobs. -type Client struct { - autorest.Client - BaseURI string -} - -// New creates an instance of the Client client. -func New() Client { - return NewWithEnvironment(azure.PublicCloud) -} - -// NewWithBaseURI creates an instance of the Client client. -func NewWithEnvironment(environment azure.Environment) Client { - return Client{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: environment.StorageEndpointSuffix, - } -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/copy_abort.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/copy_abort.go deleted file mode 100644 index a992ff199bb12..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/copy_abort.go +++ /dev/null @@ -1,110 +0,0 @@ -package blobs - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type AbortCopyInput struct { - // The Copy ID which should be aborted - CopyID string - - // The ID of the Lease - // This must be specified if a Lease is present on the Blob, else a 403 is returned - LeaseID *string -} - -// AbortCopy aborts a pending Copy Blob operation, and leaves a destination blob with zero length and full metadata. -func (client Client) AbortCopy(ctx context.Context, accountName, containerName, blobName string, input AbortCopyInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "AbortCopy", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "AbortCopy", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "AbortCopy", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "AbortCopy", "`blobName` cannot be an empty string.") - } - if input.CopyID == "" { - return result, validation.NewError("blobs.Client", "AbortCopy", "`input.CopyID` cannot be an empty string.") - } - - req, err := client.AbortCopyPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "AbortCopy", nil, "Failure preparing request") - return - } - - resp, err := client.AbortCopySender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "AbortCopy", resp, "Failure sending request") - return - } - - result, err = client.AbortCopyResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "AbortCopy", resp, "Failure responding to request") - return - } - - return -} - -// AbortCopyPreparer prepares the AbortCopy request. -func (client Client) AbortCopyPreparer(ctx context.Context, accountName, containerName, blobName string, input AbortCopyInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "copy"), - "copyid": autorest.Encode("query", input.CopyID), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-copy-action": "abort", - } - - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// AbortCopySender sends the AbortCopy request. The method will close the -// http.Response Body if it receives an error. -func (client Client) AbortCopySender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// AbortCopyResponder handles the response to the AbortCopy request. The method always -// closes the http.Response Body. -func (client Client) AbortCopyResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/copy_and_wait.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/copy_and_wait.go deleted file mode 100644 index a1e7fa453dc0c..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/copy_and_wait.go +++ /dev/null @@ -1,41 +0,0 @@ -package blobs - -import ( - "context" - "fmt" - "time" -) - -// CopyAndWait copies a blob to a destination within the storage account and waits for it to finish copying. -func (client Client) CopyAndWait(ctx context.Context, accountName, containerName, blobName string, input CopyInput, pollingInterval time.Duration) error { - if _, err := client.Copy(ctx, accountName, containerName, blobName, input); err != nil { - return fmt.Errorf("Error copying: %s", err) - } - - for true { - getInput := GetPropertiesInput{ - LeaseID: input.LeaseID, - } - getResult, err := client.GetProperties(ctx, accountName, containerName, blobName, getInput) - if err != nil { - return fmt.Errorf("") - } - - switch getResult.CopyStatus { - case Aborted: - return fmt.Errorf("Copy was aborted: %s", getResult.CopyStatusDescription) - - case Failed: - return fmt.Errorf("Copy failed: %s", getResult.CopyStatusDescription) - - case Success: - return nil - - case Pending: - time.Sleep(pollingInterval) - continue - } - } - - return fmt.Errorf("Unexpected error waiting for the copy to complete") -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/delete.go deleted file mode 100644 index c1c642d7d781d..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/delete.go +++ /dev/null @@ -1,105 +0,0 @@ -package blobs - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type DeleteInput struct { - // Should any Snapshots for this Blob also be deleted? - // If the Blob has Snapshots and this is set to False a 409 Conflict will be returned - DeleteSnapshots bool - - // The ID of the Lease - // This must be specified if a Lease is present on the Blob, else a 403 is returned - LeaseID *string -} - -// Delete marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection. -func (client Client) Delete(ctx context.Context, accountName, containerName, blobName string, input DeleteInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "Delete", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "Delete", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "Delete", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "Delete", "`blobName` cannot be an empty string.") - } - - req, err := client.DeletePreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client Client) DeletePreparer(ctx context.Context, accountName, containerName, blobName string, input DeleteInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - - if input.DeleteSnapshots { - headers["x-ms-delete-snapshots"] = "include" - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client Client) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/delete_snapshot.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/delete_snapshot.go deleted file mode 100644 index 18c3d4cffe3f4..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/delete_snapshot.go +++ /dev/null @@ -1,108 +0,0 @@ -package blobs - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type DeleteSnapshotInput struct { - // The ID of the Lease - // This must be specified if a Lease is present on the Blob, else a 403 is returned - LeaseID *string - - // The DateTime of the Snapshot which should be marked for Deletion - SnapshotDateTime string -} - -// DeleteSnapshot marks a single Snapshot of a Blob for Deletion based on it's DateTime, which will be deleted during the next Garbage Collection cycle. -func (client Client) DeleteSnapshot(ctx context.Context, accountName, containerName, blobName string, input DeleteSnapshotInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "DeleteSnapshot", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "DeleteSnapshot", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "DeleteSnapshot", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "DeleteSnapshot", "`blobName` cannot be an empty string.") - } - if input.SnapshotDateTime == "" { - return result, validation.NewError("blobs.Client", "DeleteSnapshot", "`input.SnapshotDateTime` cannot be an empty string.") - } - - req, err := client.DeleteSnapshotPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "DeleteSnapshot", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSnapshotSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "DeleteSnapshot", resp, "Failure sending request") - return - } - - result, err = client.DeleteSnapshotResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "DeleteSnapshot", resp, "Failure responding to request") - return - } - - return -} - -// DeleteSnapshotPreparer prepares the DeleteSnapshot request. -func (client Client) DeleteSnapshotPreparer(ctx context.Context, accountName, containerName, blobName string, input DeleteSnapshotInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "snapshot": autorest.Encode("query", input.SnapshotDateTime), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSnapshotSender sends the DeleteSnapshot request. The method will close the -// http.Response Body if it receives an error. -func (client Client) DeleteSnapshotSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteSnapshotResponder handles the response to the DeleteSnapshot request. The method always -// closes the http.Response Body. -func (client Client) DeleteSnapshotResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/delete_snapshots.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/delete_snapshots.go deleted file mode 100644 index e7e2b664d74d2..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/delete_snapshots.go +++ /dev/null @@ -1,99 +0,0 @@ -package blobs - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type DeleteSnapshotsInput struct { - // The ID of the Lease - // This must be specified if a Lease is present on the Blob, else a 403 is returned - LeaseID *string -} - -// DeleteSnapshots marks all Snapshots of a Blob for Deletion, which will be deleted during the next Garbage Collection Cycle. -func (client Client) DeleteSnapshots(ctx context.Context, accountName, containerName, blobName string, input DeleteSnapshotsInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "DeleteSnapshots", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "DeleteSnapshots", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "DeleteSnapshots", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "DeleteSnapshots", "`blobName` cannot be an empty string.") - } - - req, err := client.DeleteSnapshotsPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "DeleteSnapshots", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSnapshotsSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "DeleteSnapshots", resp, "Failure sending request") - return - } - - result, err = client.DeleteSnapshotsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "DeleteSnapshots", resp, "Failure responding to request") - return - } - - return -} - -// DeleteSnapshotsPreparer prepares the DeleteSnapshots request. -func (client Client) DeleteSnapshotsPreparer(ctx context.Context, accountName, containerName, blobName string, input DeleteSnapshotsInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - // only delete the snapshots but leave the blob as-is - "x-ms-delete-snapshots": "only", - } - - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSnapshotsSender sends the DeleteSnapshots request. The method will close the -// http.Response Body if it receives an error. -func (client Client) DeleteSnapshotsSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteSnapshotsResponder handles the response to the DeleteSnapshots request. The method always -// closes the http.Response Body. -func (client Client) DeleteSnapshotsResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/get.go deleted file mode 100644 index 7e0d6ee9fbd5a..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/get.go +++ /dev/null @@ -1,116 +0,0 @@ -package blobs - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type GetInput struct { - LeaseID *string - StartByte *int64 - EndByte *int64 -} - -type GetResult struct { - autorest.Response - - Contents []byte -} - -// Get reads or downloads a blob from the system, including its metadata and properties. -func (client Client) Get(ctx context.Context, accountName, containerName, blobName string, input GetInput) (result GetResult, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "Get", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "Get", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "Get", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "Get", "`blobName` cannot be an empty string.") - } - if input.LeaseID != nil && *input.LeaseID == "" { - return result, validation.NewError("blobs.Client", "Get", "`input.LeaseID` should either be specified or nil, not an empty string.") - } - if (input.StartByte != nil && input.EndByte == nil) || input.StartByte == nil && input.EndByte != nil { - return result, validation.NewError("blobs.Client", "Get", "`input.StartByte` and `input.EndByte` must both be specified, or both be nil.") - } - - req, err := client.GetPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client Client) GetPreparer(ctx context.Context, accountName, containerName, blobName string, input GetInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - if input.StartByte != nil && input.EndByte != nil { - headers["x-ms-range"] = fmt.Sprintf("bytes=%d-%d", *input.StartByte, *input.EndByte) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client Client) GetResponder(resp *http.Response) (result GetResult, err error) { - if resp != nil && int(resp.ContentLength) > 0 { - result.Contents = make([]byte, resp.ContentLength) - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusPartialContent), - autorest.ByUnmarshallingBytes(&result.Contents), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/get_block_list.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/get_block_list.go deleted file mode 100644 index 9f8120c6c8c37..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/get_block_list.go +++ /dev/null @@ -1,140 +0,0 @@ -package blobs - -import ( - "context" - "fmt" - "net/http" - "strconv" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type GetBlockListInput struct { - BlockListType BlockListType - LeaseID *string -} - -type GetBlockListResult struct { - autorest.Response - - // The size of the blob in bytes - ContentLength *int64 - - // The Content Type of the blob - ContentType string - - // The ETag associated with this blob - ETag string - - // A list of blocks which have been committed - CommittedBlocks CommittedBlocks `xml:"CommittedBlocks,omitempty"` - - // A list of blocks which have not yet been committed - UncommittedBlocks UncommittedBlocks `xml:"UncommittedBlocks,omitempty"` -} - -// GetBlockList retrieves the list of blocks that have been uploaded as part of a block blob. -func (client Client) GetBlockList(ctx context.Context, accountName, containerName, blobName string, input GetBlockListInput) (result GetBlockListResult, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "GetBlockList", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "GetBlockList", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "GetBlockList", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "GetBlockList", "`blobName` cannot be an empty string.") - } - - req, err := client.GetBlockListPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "GetBlockList", nil, "Failure preparing request") - return - } - - resp, err := client.GetBlockListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "GetBlockList", resp, "Failure sending request") - return - } - - result, err = client.GetBlockListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "GetBlockList", resp, "Failure responding to request") - return - } - - return -} - -// GetBlockListPreparer prepares the GetBlockList request. -func (client Client) GetBlockListPreparer(ctx context.Context, accountName, containerName, blobName string, input GetBlockListInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "blocklisttype": autorest.Encode("query", string(input.BlockListType)), - "comp": autorest.Encode("query", "blocklist"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithHeaders(headers), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetBlockListSender sends the GetBlockList request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetBlockListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetBlockListResponder handles the response to the GetBlockList request. The method always -// closes the http.Response Body. -func (client Client) GetBlockListResponder(resp *http.Response) (result GetBlockListResult, err error) { - if resp != nil && resp.Header != nil { - result.ContentType = resp.Header.Get("Content-Type") - result.ETag = resp.Header.Get("ETag") - - if v := resp.Header.Get("x-ms-blob-content-length"); v != "" { - i, innerErr := strconv.Atoi(v) - if innerErr != nil { - err = fmt.Errorf("Error parsing %q as an integer: %s", v, innerErr) - return - } - - i64 := int64(i) - result.ContentLength = &i64 - } - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingXML(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/get_page_ranges.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/get_page_ranges.go deleted file mode 100644 index 37abf631a28ad..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/get_page_ranges.go +++ /dev/null @@ -1,152 +0,0 @@ -package blobs - -import ( - "context" - "fmt" - "net/http" - "strconv" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type GetPageRangesInput struct { - LeaseID *string - - StartByte *int64 - EndByte *int64 -} - -type GetPageRangesResult struct { - autorest.Response - - // The size of the blob in bytes - ContentLength *int64 - - // The Content Type of the blob - ContentType string - - // The ETag associated with this blob - ETag string - - PageRanges []PageRange `xml:"PageRange"` -} - -type PageRange struct { - // The start byte offset for this range, inclusive - Start int64 `xml:"Start"` - - // The end byte offset for this range, inclusive - End int64 `xml:"End"` -} - -// GetPageRanges returns the list of valid page ranges for a page blob or snapshot of a page blob. -func (client Client) GetPageRanges(ctx context.Context, accountName, containerName, blobName string, input GetPageRangesInput) (result GetPageRangesResult, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "GetPageRanges", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "GetPageRanges", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "GetPageRanges", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "GetPageRanges", "`blobName` cannot be an empty string.") - } - if (input.StartByte != nil && input.EndByte == nil) || input.StartByte == nil && input.EndByte != nil { - return result, validation.NewError("blobs.Client", "GetPageRanges", "`input.StartByte` and `input.EndByte` must both be specified, or both be nil.") - } - - req, err := client.GetPageRangesPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "GetPageRanges", nil, "Failure preparing request") - return - } - - resp, err := client.GetPageRangesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "GetPageRanges", resp, "Failure sending request") - return - } - - result, err = client.GetPageRangesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "GetPageRanges", resp, "Failure responding to request") - return - } - - return -} - -// GetPageRangesPreparer prepares the GetPageRanges request. -func (client Client) GetPageRangesPreparer(ctx context.Context, accountName, containerName, blobName string, input GetPageRangesInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "pagelist"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - - if input.StartByte != nil && input.EndByte != nil { - headers["x-ms-range"] = fmt.Sprintf("bytes=%d-%d", *input.StartByte, *input.EndByte) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithHeaders(headers), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetPageRangesSender sends the GetPageRanges request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetPageRangesSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetPageRangesResponder handles the response to the GetPageRanges request. The method always -// closes the http.Response Body. -func (client Client) GetPageRangesResponder(resp *http.Response) (result GetPageRangesResult, err error) { - if resp != nil && resp.Header != nil { - result.ContentType = resp.Header.Get("Content-Type") - result.ETag = resp.Header.Get("ETag") - - if v := resp.Header.Get("x-ms-blob-content-length"); v != "" { - i, innerErr := strconv.Atoi(v) - if innerErr != nil { - err = fmt.Errorf("Error parsing %q as an integer: %s", v, innerErr) - return - } - - i64 := int64(i) - result.ContentLength = &i64 - } - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingXML(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/incremental_copy_blob.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/incremental_copy_blob.go deleted file mode 100644 index 7fb7e6b55489f..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/incremental_copy_blob.go +++ /dev/null @@ -1,120 +0,0 @@ -package blobs - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type IncrementalCopyBlobInput struct { - CopySource string - IfModifiedSince *string - IfUnmodifiedSince *string - IfMatch *string - IfNoneMatch *string -} - -// IncrementalCopyBlob copies a snapshot of the source page blob to a destination page blob. -// The snapshot is copied such that only the differential changes between the previously copied -// snapshot are transferred to the destination. -// The copied snapshots are complete copies of the original snapshot and can be read or copied from as usual. -func (client Client) IncrementalCopyBlob(ctx context.Context, accountName, containerName, blobName string, input IncrementalCopyBlobInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "IncrementalCopyBlob", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "IncrementalCopyBlob", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "IncrementalCopyBlob", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "IncrementalCopyBlob", "`blobName` cannot be an empty string.") - } - if input.CopySource == "" { - return result, validation.NewError("blobs.Client", "IncrementalCopyBlob", "`input.CopySource` cannot be an empty string.") - } - - req, err := client.IncrementalCopyBlobPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "IncrementalCopyBlob", nil, "Failure preparing request") - return - } - - resp, err := client.IncrementalCopyBlobSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "IncrementalCopyBlob", resp, "Failure sending request") - return - } - - result, err = client.IncrementalCopyBlobResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "IncrementalCopyBlob", resp, "Failure responding to request") - return - } - - return -} - -// IncrementalCopyBlobPreparer prepares the IncrementalCopyBlob request. -func (client Client) IncrementalCopyBlobPreparer(ctx context.Context, accountName, containerName, blobName string, input IncrementalCopyBlobInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "incrementalcopy"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-copy-source": input.CopySource, - } - - if input.IfModifiedSince != nil { - headers["If-Modified-Since"] = *input.IfModifiedSince - } - if input.IfUnmodifiedSince != nil { - headers["If-Unmodified-Since"] = *input.IfUnmodifiedSince - } - if input.IfMatch != nil { - headers["If-Match"] = *input.IfMatch - } - if input.IfNoneMatch != nil { - headers["If-None-Match"] = *input.IfNoneMatch - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// IncrementalCopyBlobSender sends the IncrementalCopyBlob request. The method will close the -// http.Response Body if it receives an error. -func (client Client) IncrementalCopyBlobSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// IncrementalCopyBlobResponder handles the response to the IncrementalCopyBlob request. The method always -// closes the http.Response Body. -func (client Client) IncrementalCopyBlobResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/lease_acquire.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/lease_acquire.go deleted file mode 100644 index c4b49d73ae714..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/lease_acquire.go +++ /dev/null @@ -1,135 +0,0 @@ -package blobs - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type AcquireLeaseInput struct { - // The ID of the existing Lease, if leased - LeaseID *string - - // 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 - LeaseDuration int - - // The Proposed new ID for the Lease - ProposedLeaseID *string -} - -type AcquireLeaseResult struct { - autorest.Response - - LeaseID string -} - -// AcquireLease establishes and manages a lock on a blob for write and delete operations. -func (client Client) AcquireLease(ctx context.Context, accountName, containerName, blobName string, input AcquireLeaseInput) (result AcquireLeaseResult, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "AcquireLease", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "AcquireLease", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "AcquireLease", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "AcquireLease", "`blobName` cannot be an empty string.") - } - if input.LeaseID != nil && *input.LeaseID == "" { - return result, validation.NewError("blobs.Client", "AcquireLease", "`input.LeaseID` cannot be an empty string, if specified.") - } - if input.ProposedLeaseID != nil && *input.ProposedLeaseID == "" { - return result, validation.NewError("blobs.Client", "AcquireLease", "`input.ProposedLeaseID` cannot be an empty string, if specified.") - } - // An infinite lease duration is -1 seconds. A non-infinite lease can be between 15 and 60 seconds - if input.LeaseDuration != -1 && (input.LeaseDuration <= 15 || input.LeaseDuration >= 60) { - return result, validation.NewError("blobs.Client", "AcquireLease", "`input.LeaseDuration` must be -1 (infinite), or between 15 and 60 seconds.") - } - - req, err := client.AcquireLeasePreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "AcquireLease", nil, "Failure preparing request") - return - } - - resp, err := client.AcquireLeaseSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "AcquireLease", resp, "Failure sending request") - return - } - - result, err = client.AcquireLeaseResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "AcquireLease", resp, "Failure responding to request") - return - } - - return -} - -// AcquireLeasePreparer prepares the AcquireLease request. -func (client Client) AcquireLeasePreparer(ctx context.Context, accountName, containerName, blobName string, input AcquireLeaseInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "lease"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-lease-action": "acquire", - "x-ms-lease-duration": input.LeaseDuration, - } - - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - - if input.ProposedLeaseID != nil { - headers["x-ms-proposed-lease-id"] = *input.ProposedLeaseID - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithHeaders(headers), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// AcquireLeaseSender sends the AcquireLease request. The method will close the -// http.Response Body if it receives an error. -func (client Client) AcquireLeaseSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// AcquireLeaseResponder handles the response to the AcquireLease request. The method always -// closes the http.Response Body. -func (client Client) AcquireLeaseResponder(resp *http.Response) (result AcquireLeaseResult, err error) { - if resp != nil && resp.Header != nil { - result.LeaseID = resp.Header.Get("x-ms-lease-id") - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/lease_break.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/lease_break.go deleted file mode 100644 index d5642045d20df..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/lease_break.go +++ /dev/null @@ -1,124 +0,0 @@ -package blobs - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type BreakLeaseInput 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 *int - - LeaseID string -} - -type BreakLeaseResponse struct { - autorest.Response - - // Approximate time remaining in the lease period, in seconds. - // If the break is immediate, 0 is returned. - LeaseTime int -} - -// BreakLease breaks an existing lock on a blob using the LeaseID. -func (client Client) BreakLease(ctx context.Context, accountName, containerName, blobName string, input BreakLeaseInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "BreakLease", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "BreakLease", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "BreakLease", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "BreakLease", "`blobName` cannot be an empty string.") - } - if input.LeaseID == "" { - return result, validation.NewError("blobs.Client", "BreakLease", "`input.LeaseID` cannot be an empty string.") - } - - req, err := client.BreakLeasePreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "BreakLease", nil, "Failure preparing request") - return - } - - resp, err := client.BreakLeaseSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "BreakLease", resp, "Failure sending request") - return - } - - result, err = client.BreakLeaseResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "BreakLease", resp, "Failure responding to request") - return - } - - return -} - -// BreakLeasePreparer prepares the BreakLease request. -func (client Client) BreakLeasePreparer(ctx context.Context, accountName, containerName, blobName string, input BreakLeaseInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "lease"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-lease-action": "break", - "x-ms-lease-id": input.LeaseID, - } - - if input.BreakPeriod != nil { - headers["x-ms-lease-break-period"] = *input.BreakPeriod - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithHeaders(headers), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// BreakLeaseSender sends the BreakLease request. The method will close the -// http.Response Body if it receives an error. -func (client Client) BreakLeaseSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// BreakLeaseResponder handles the response to the BreakLease request. The method always -// closes the http.Response Body. -func (client Client) BreakLeaseResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/lease_change.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/lease_change.go deleted file mode 100644 index c57f9db875b0f..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/lease_change.go +++ /dev/null @@ -1,117 +0,0 @@ -package blobs - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type ChangeLeaseInput struct { - ExistingLeaseID string - ProposedLeaseID string -} - -type ChangeLeaseResponse struct { - autorest.Response - - LeaseID string -} - -// ChangeLease changes an existing lock on a blob for another lock. -func (client Client) ChangeLease(ctx context.Context, accountName, containerName, blobName string, input ChangeLeaseInput) (result ChangeLeaseResponse, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "ChangeLease", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "ChangeLease", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "ChangeLease", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "ChangeLease", "`blobName` cannot be an empty string.") - } - if input.ExistingLeaseID == "" { - return result, validation.NewError("blobs.Client", "ChangeLease", "`input.ExistingLeaseID` cannot be an empty string.") - } - if input.ProposedLeaseID == "" { - return result, validation.NewError("blobs.Client", "ChangeLease", "`input.ProposedLeaseID` cannot be an empty string.") - } - - req, err := client.ChangeLeasePreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "ChangeLease", nil, "Failure preparing request") - return - } - - resp, err := client.ChangeLeaseSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "ChangeLease", resp, "Failure sending request") - return - } - - result, err = client.ChangeLeaseResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "ChangeLease", resp, "Failure responding to request") - return - } - - return -} - -// ChangeLeasePreparer prepares the ChangeLease request. -func (client Client) ChangeLeasePreparer(ctx context.Context, accountName, containerName, blobName string, input ChangeLeaseInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "lease"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-lease-action": "change", - "x-ms-lease-id": input.ExistingLeaseID, - "x-ms-proposed-lease-id": input.ProposedLeaseID, - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithHeaders(headers), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ChangeLeaseSender sends the ChangeLease request. The method will close the -// http.Response Body if it receives an error. -func (client Client) ChangeLeaseSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ChangeLeaseResponder handles the response to the ChangeLease request. The method always -// closes the http.Response Body. -func (client Client) ChangeLeaseResponder(resp *http.Response) (result ChangeLeaseResponse, err error) { - if resp != nil && resp.Header != nil { - result.LeaseID = resp.Header.Get("x-ms-lease-id") - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/lease_release.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/lease_release.go deleted file mode 100644 index 0226cdf375525..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/lease_release.go +++ /dev/null @@ -1,98 +0,0 @@ -package blobs - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// ReleaseLease releases a lock based on the Lease ID. -func (client Client) ReleaseLease(ctx context.Context, accountName, containerName, blobName, leaseID string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "ReleaseLease", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "ReleaseLease", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "ReleaseLease", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "ReleaseLease", "`blobName` cannot be an empty string.") - } - if leaseID == "" { - return result, validation.NewError("blobs.Client", "ReleaseLease", "`leaseID` cannot be an empty string.") - } - - req, err := client.ReleaseLeasePreparer(ctx, accountName, containerName, blobName, leaseID) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "ReleaseLease", nil, "Failure preparing request") - return - } - - resp, err := client.ReleaseLeaseSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "ReleaseLease", resp, "Failure sending request") - return - } - - result, err = client.ReleaseLeaseResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "ReleaseLease", resp, "Failure responding to request") - return - } - - return -} - -// ReleaseLeasePreparer prepares the ReleaseLease request. -func (client Client) ReleaseLeasePreparer(ctx context.Context, accountName, containerName, blobName, leaseID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "lease"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-lease-action": "release", - "x-ms-lease-id": leaseID, - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithHeaders(headers), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ReleaseLeaseSender sends the ReleaseLease request. The method will close the -// http.Response Body if it receives an error. -func (client Client) ReleaseLeaseSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ReleaseLeaseResponder handles the response to the ReleaseLease request. The method always -// closes the http.Response Body. -func (client Client) ReleaseLeaseResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/lease_renew.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/lease_renew.go deleted file mode 100644 index 69c495bd98985..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/lease_renew.go +++ /dev/null @@ -1,97 +0,0 @@ -package blobs - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -func (client Client) RenewLease(ctx context.Context, accountName, containerName, blobName, leaseID string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "RenewLease", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "RenewLease", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "RenewLease", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "RenewLease", "`blobName` cannot be an empty string.") - } - if leaseID == "" { - return result, validation.NewError("blobs.Client", "RenewLease", "`leaseID` cannot be an empty string.") - } - - req, err := client.RenewLeasePreparer(ctx, accountName, containerName, blobName, leaseID) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "RenewLease", nil, "Failure preparing request") - return - } - - resp, err := client.RenewLeaseSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "RenewLease", resp, "Failure sending request") - return - } - - result, err = client.RenewLeaseResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "RenewLease", resp, "Failure responding to request") - return - } - - return -} - -// RenewLeasePreparer prepares the RenewLease request. -func (client Client) RenewLeasePreparer(ctx context.Context, accountName, containerName, blobName, leaseID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "lease"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-lease-action": "renew", - "x-ms-lease-id": leaseID, - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithHeaders(headers), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// RenewLeaseSender sends the RenewLease request. The method will close the -// http.Response Body if it receives an error. -func (client Client) RenewLeaseSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// RenewLeaseResponder handles the response to the RenewLease request. The method always -// closes the http.Response Body. -func (client Client) RenewLeaseResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/metadata_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/metadata_set.go deleted file mode 100644 index ec69152a5f983..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/metadata_set.go +++ /dev/null @@ -1,113 +0,0 @@ -package blobs - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type SetMetaDataInput struct { - // The ID of the Lease - // This must be specified if a Lease is present on the Blob, else a 403 is returned - LeaseID *string - - // Any metadata which should be added to this blob - MetaData map[string]string -} - -// SetMetaData marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection. -func (client Client) SetMetaData(ctx context.Context, accountName, containerName, blobName string, input SetMetaDataInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "GetProperties", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "GetProperties", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "GetProperties", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "GetProperties", "`blobName` cannot be an empty string.") - } - if err := metadata.Validate(input.MetaData); err != nil { - return result, validation.NewError("blobs.Client", "GetProperties", fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) - } - - req, err := client.SetMetaDataPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "SetMetaData", nil, "Failure preparing request") - return - } - - resp, err := client.SetMetaDataSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "SetMetaData", resp, "Failure sending request") - return - } - - result, err = client.SetMetaDataResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "SetMetaData", resp, "Failure responding to request") - return - } - - return -} - -// SetMetaDataPreparer prepares the SetMetaData request. -func (client Client) SetMetaDataPreparer(ctx context.Context, accountName, containerName, blobName string, input SetMetaDataInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "metadata"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - - headers = metadata.SetIntoHeaders(headers, input.MetaData) - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithHeaders(headers), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SetMetaDataSender sends the SetMetaData request. The method will close the -// http.Response Body if it receives an error. -func (client Client) SetMetaDataSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// SetMetaDataResponder handles the response to the SetMetaData request. The method always -// closes the http.Response Body. -func (client Client) SetMetaDataResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/properties_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/properties_set.go deleted file mode 100644 index a8c0ed8cba95f..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/properties_set.go +++ /dev/null @@ -1,156 +0,0 @@ -package blobs - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type SetPropertiesInput struct { - CacheControl *string - ContentType *string - ContentMD5 *string - ContentEncoding *string - ContentLanguage *string - LeaseID *string - ContentDisposition *string - ContentLength *int64 - SequenceNumberAction *SequenceNumberAction - BlobSequenceNumber *string -} - -type SetPropertiesResult struct { - autorest.Response - - BlobSequenceNumber string - Etag string -} - -// SetProperties sets system properties on the blob. -func (client Client) SetProperties(ctx context.Context, accountName, containerName, blobName string, input SetPropertiesInput) (result SetPropertiesResult, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "SetProperties", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "SetProperties", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "SetProperties", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "SetProperties", "`blobName` cannot be an empty string.") - } - - req, err := client.SetPropertiesPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "SetProperties", nil, "Failure preparing request") - return - } - - resp, err := client.SetPropertiesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "SetProperties", resp, "Failure sending request") - return - } - - result, err = client.SetPropertiesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "SetProperties", resp, "Failure responding to request") - return - } - - return -} - -type SequenceNumberAction string - -var ( - Increment SequenceNumberAction = "increment" - Max SequenceNumberAction = "max" - Update SequenceNumberAction = "update" -) - -// SetPropertiesPreparer prepares the SetProperties request. -func (client Client) SetPropertiesPreparer(ctx context.Context, accountName, containerName, blobName string, input SetPropertiesInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "properties"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - if input.CacheControl != nil { - headers["x-ms-blob-cache-control"] = *input.CacheControl - } - if input.ContentDisposition != nil { - headers["x-ms-blob-content-disposition"] = *input.ContentDisposition - } - if input.ContentEncoding != nil { - headers["x-ms-blob-content-encoding"] = *input.ContentEncoding - } - if input.ContentLanguage != nil { - headers["x-ms-blob-content-language"] = *input.ContentLanguage - } - if input.ContentMD5 != nil { - headers["x-ms-blob-content-md5"] = *input.ContentMD5 - } - if input.ContentType != nil { - headers["x-ms-blob-content-type"] = *input.ContentType - } - if input.ContentLength != nil { - headers["x-ms-blob-content-length"] = *input.ContentLength - } - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - if input.SequenceNumberAction != nil { - headers["x-ms-sequence-number-action"] = string(*input.SequenceNumberAction) - } - if input.BlobSequenceNumber != nil { - headers["x-ms-blob-sequence-number"] = *input.BlobSequenceNumber - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithHeaders(headers), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SetPropertiesSender sends the SetProperties request. The method will close the -// http.Response Body if it receives an error. -func (client Client) SetPropertiesSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// SetPropertiesResponder handles the response to the SetProperties request. The method always -// closes the http.Response Body. -func (client Client) SetPropertiesResponder(resp *http.Response) (result SetPropertiesResult, err error) { - if resp != nil && resp.Header != nil { - result.BlobSequenceNumber = resp.Header.Get("x-ms-blob-sequence-number") - result.Etag = resp.Header.Get("Etag") - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_append_blob.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_append_blob.go deleted file mode 100644 index ef2c5025d606b..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_append_blob.go +++ /dev/null @@ -1,134 +0,0 @@ -package blobs - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type PutAppendBlobInput struct { - CacheControl *string - ContentDisposition *string - ContentEncoding *string - ContentLanguage *string - ContentMD5 *string - ContentType *string - LeaseID *string - MetaData map[string]string -} - -// PutAppendBlob is a wrapper around the Put API call (with a stricter input object) -// which creates a new append blob, or updates the content of an existing blob. -func (client Client) PutAppendBlob(ctx context.Context, accountName, containerName, blobName string, input PutAppendBlobInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "PutAppendBlob", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "PutAppendBlob", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "PutAppendBlob", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "PutAppendBlob", "`blobName` cannot be an empty string.") - } - if err := metadata.Validate(input.MetaData); err != nil { - return result, validation.NewError("blobs.Client", "PutAppendBlob", fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) - } - - req, err := client.PutAppendBlobPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "PutAppendBlob", nil, "Failure preparing request") - return - } - - resp, err := client.PutAppendBlobSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "PutAppendBlob", resp, "Failure sending request") - return - } - - result, err = client.PutAppendBlobResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "PutAppendBlob", resp, "Failure responding to request") - return - } - - return -} - -// PutAppendBlobPreparer prepares the PutAppendBlob request. -func (client Client) PutAppendBlobPreparer(ctx context.Context, accountName, containerName, blobName string, input PutAppendBlobInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - headers := map[string]interface{}{ - "x-ms-blob-type": string(AppendBlob), - "x-ms-version": APIVersion, - - // For a page blob or an append blob, the value of this header must be set to zero, - // as Put Blob is used only to initialize the blob - "Content-Length": 0, - } - - if input.CacheControl != nil { - headers["x-ms-blob-cache-control"] = *input.CacheControl - } - if input.ContentDisposition != nil { - headers["x-ms-blob-content-disposition"] = *input.ContentDisposition - } - if input.ContentEncoding != nil { - headers["x-ms-blob-content-encoding"] = *input.ContentEncoding - } - if input.ContentLanguage != nil { - headers["x-ms-blob-content-language"] = *input.ContentLanguage - } - if input.ContentMD5 != nil { - headers["x-ms-blob-content-md5"] = *input.ContentMD5 - } - if input.ContentType != nil { - headers["x-ms-blob-content-type"] = *input.ContentType - } - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - - headers = metadata.SetIntoHeaders(headers, input.MetaData) - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// PutAppendBlobSender sends the PutAppendBlob request. The method will close the -// http.Response Body if it receives an error. -func (client Client) PutAppendBlobSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// PutAppendBlobResponder handles the response to the PutAppendBlob request. The method always -// closes the http.Response Body. -func (client Client) PutAppendBlobResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_block.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_block.go deleted file mode 100644 index 6d41bda13b558..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_block.go +++ /dev/null @@ -1,126 +0,0 @@ -package blobs - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type PutBlockInput struct { - BlockID string - Content []byte - ContentMD5 *string - LeaseID *string -} - -type PutBlockResult struct { - autorest.Response - - ContentMD5 string -} - -// PutBlock creates a new block to be committed as part of a blob. -func (client Client) PutBlock(ctx context.Context, accountName, containerName, blobName string, input PutBlockInput) (result PutBlockResult, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "PutBlock", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "PutBlock", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "PutBlock", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "PutBlock", "`blobName` cannot be an empty string.") - } - if input.BlockID == "" { - return result, validation.NewError("blobs.Client", "PutBlock", "`input.BlockID` cannot be an empty string.") - } - if len(input.Content) == 0 { - return result, validation.NewError("blobs.Client", "PutBlock", "`input.Content` cannot be empty.") - } - - req, err := client.PutBlockPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "PutBlock", nil, "Failure preparing request") - return - } - - resp, err := client.PutBlockSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "PutBlock", resp, "Failure sending request") - return - } - - result, err = client.PutBlockResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "PutBlock", resp, "Failure responding to request") - return - } - - return -} - -// PutBlockPreparer prepares the PutBlock request. -func (client Client) PutBlockPreparer(ctx context.Context, accountName, containerName, blobName string, input PutBlockInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "block"), - "blockid": autorest.Encode("query", input.BlockID), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "Content-Length": int(len(input.Content)), - } - - if input.ContentMD5 != nil { - headers["x-ms-blob-content-md5"] = *input.ContentMD5 - } - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers), - autorest.WithBytes(&input.Content)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// PutBlockSender sends the PutBlock request. The method will close the -// http.Response Body if it receives an error. -func (client Client) PutBlockSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// PutBlockResponder handles the response to the PutBlock request. The method always -// closes the http.Response Body. -func (client Client) PutBlockResponder(resp *http.Response) (result PutBlockResult, err error) { - if resp != nil && resp.Header != nil { - result.ContentMD5 = resp.Header.Get("Content-MD5") - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_block_blob.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_block_blob.go deleted file mode 100644 index f5c1a971b306e..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_block_blob.go +++ /dev/null @@ -1,144 +0,0 @@ -package blobs - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type PutBlockBlobInput struct { - CacheControl *string - Content *[]byte - ContentDisposition *string - ContentEncoding *string - ContentLanguage *string - ContentMD5 *string - ContentType *string - LeaseID *string - MetaData map[string]string -} - -// PutBlockBlob is a wrapper around the Put API call (with a stricter input object) -// which creates a new block append blob, or updates the content of an existing block blob. -func (client Client) PutBlockBlob(ctx context.Context, accountName, containerName, blobName string, input PutBlockBlobInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "PutBlockBlob", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "PutBlockBlob", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "PutBlockBlob", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "PutBlockBlob", "`blobName` cannot be an empty string.") - } - if input.Content != nil && len(*input.Content) == 0 { - return result, validation.NewError("blobs.Client", "PutBlockBlob", "`input.Content` must either be nil or not empty.") - } - if err := metadata.Validate(input.MetaData); err != nil { - return result, validation.NewError("blobs.Client", "PutBlockBlob", fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) - } - - req, err := client.PutBlockBlobPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "PutBlockBlob", nil, "Failure preparing request") - return - } - - resp, err := client.PutBlockBlobSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "PutBlockBlob", resp, "Failure sending request") - return - } - - result, err = client.PutBlockBlobResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "PutBlockBlob", resp, "Failure responding to request") - return - } - - return -} - -// PutBlockBlobPreparer prepares the PutBlockBlob request. -func (client Client) PutBlockBlobPreparer(ctx context.Context, accountName, containerName, blobName string, input PutBlockBlobInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - headers := map[string]interface{}{ - "x-ms-blob-type": string(BlockBlob), - "x-ms-version": APIVersion, - } - - if input.CacheControl != nil { - headers["x-ms-blob-cache-control"] = *input.CacheControl - } - if input.ContentDisposition != nil { - headers["x-ms-blob-content-disposition"] = *input.ContentDisposition - } - if input.ContentEncoding != nil { - headers["x-ms-blob-content-encoding"] = *input.ContentEncoding - } - if input.ContentLanguage != nil { - headers["x-ms-blob-content-language"] = *input.ContentLanguage - } - if input.ContentMD5 != nil { - headers["x-ms-blob-content-md5"] = *input.ContentMD5 - } - if input.ContentType != nil { - headers["x-ms-blob-content-type"] = *input.ContentType - } - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - if input.Content != nil { - headers["Content-Length"] = int(len(*input.Content)) - } - - headers = metadata.SetIntoHeaders(headers, input.MetaData) - - decorators := []autorest.PrepareDecorator{ - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithHeaders(headers), - } - - if input.Content != nil { - decorators = append(decorators, autorest.WithBytes(input.Content)) - } - - preparer := autorest.CreatePreparer(decorators...) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// PutBlockBlobSender sends the PutBlockBlob request. The method will close the -// http.Response Body if it receives an error. -func (client Client) PutBlockBlobSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// PutBlockBlobResponder handles the response to the PutBlockBlob request. The method always -// closes the http.Response Body. -func (client Client) PutBlockBlobResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_block_list.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_block_list.go deleted file mode 100644 index f80524790be59..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_block_list.go +++ /dev/null @@ -1,157 +0,0 @@ -package blobs - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type BlockList struct { - CommittedBlockIDs []BlockID `xml:"Committed,omitempty"` - UncommittedBlockIDs []BlockID `xml:"Uncommitted,omitempty"` - LatestBlockIDs []BlockID `xml:"Latest,omitempty"` -} - -type BlockID struct { - Value string `xml:",chardata"` -} - -type PutBlockListInput struct { - BlockList BlockList - CacheControl *string - ContentDisposition *string - ContentEncoding *string - ContentLanguage *string - ContentMD5 *string - ContentType *string - MetaData map[string]string - LeaseID *string -} - -type PutBlockListResult struct { - autorest.Response - - ContentMD5 string - ETag string - LastModified string -} - -// PutBlockList writes a blob by specifying the list of block IDs that make up the blob. -// In order to be written as part of a blob, a block must have been successfully written -// to the server in a prior Put Block operation. -func (client Client) PutBlockList(ctx context.Context, accountName, containerName, blobName string, input PutBlockListInput) (result PutBlockListResult, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "PutBlockList", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "PutBlockList", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "PutBlockList", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "PutBlockList", "`blobName` cannot be an empty string.") - } - - req, err := client.PutBlockListPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "PutBlockList", nil, "Failure preparing request") - return - } - - resp, err := client.PutBlockListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "PutBlockList", resp, "Failure sending request") - return - } - - result, err = client.PutBlockListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "PutBlockList", resp, "Failure responding to request") - return - } - - return -} - -// PutBlockListPreparer prepares the PutBlockList request. -func (client Client) PutBlockListPreparer(ctx context.Context, accountName, containerName, blobName string, input PutBlockListInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "blocklist"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - if input.CacheControl != nil { - headers["x-ms-blob-cache-control"] = *input.CacheControl - } - if input.ContentDisposition != nil { - headers["x-ms-blob-content-disposition"] = *input.ContentDisposition - } - if input.ContentEncoding != nil { - headers["x-ms-blob-content-encoding"] = *input.ContentEncoding - } - if input.ContentLanguage != nil { - headers["x-ms-blob-content-language"] = *input.ContentLanguage - } - if input.ContentMD5 != nil { - headers["x-ms-blob-content-md5"] = *input.ContentMD5 - } - if input.ContentType != nil { - headers["x-ms-blob-content-type"] = *input.ContentType - } - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - - headers = metadata.SetIntoHeaders(headers, input.MetaData) - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers), - autorest.WithXML(input.BlockList)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// PutBlockListSender sends the PutBlockList request. The method will close the -// http.Response Body if it receives an error. -func (client Client) PutBlockListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// PutBlockListResponder handles the response to the PutBlockList request. The method always -// closes the http.Response Body. -func (client Client) PutBlockListResponder(resp *http.Response) (result PutBlockListResult, err error) { - if resp != nil && resp.Header != nil { - result.ContentMD5 = resp.Header.Get("Content-MD5") - result.ETag = resp.Header.Get("ETag") - result.LastModified = resp.Header.Get("Last-Modified") - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_block_url.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_block_url.go deleted file mode 100644 index 95ad974698bdd..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_block_url.go +++ /dev/null @@ -1,129 +0,0 @@ -package blobs - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type PutBlockFromURLInput struct { - BlockID string - CopySource string - - ContentMD5 *string - LeaseID *string - Range *string -} - -type PutBlockFromURLResult struct { - autorest.Response - ContentMD5 string -} - -// PutBlockFromURL creates a new block to be committed as part of a blob where the contents are read from a URL -func (client Client) PutBlockFromURL(ctx context.Context, accountName, containerName, blobName string, input PutBlockFromURLInput) (result PutBlockFromURLResult, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "PutBlockFromURL", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "PutBlockFromURL", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "PutBlockFromURL", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "PutBlockFromURL", "`blobName` cannot be an empty string.") - } - if input.BlockID == "" { - return result, validation.NewError("blobs.Client", "PutBlockFromURL", "`input.BlockID` cannot be an empty string.") - } - if input.CopySource == "" { - return result, validation.NewError("blobs.Client", "PutBlockFromURL", "`input.CopySource` cannot be an empty string.") - } - - req, err := client.PutBlockFromURLPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "PutBlockFromURL", nil, "Failure preparing request") - return - } - - resp, err := client.PutBlockFromURLSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "PutBlockFromURL", resp, "Failure sending request") - return - } - - result, err = client.PutBlockFromURLResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "PutBlockFromURL", resp, "Failure responding to request") - return - } - - return -} - -// PutBlockFromURLPreparer prepares the PutBlockFromURL request. -func (client Client) PutBlockFromURLPreparer(ctx context.Context, accountName, containerName, blobName string, input PutBlockFromURLInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "block"), - "blockid": autorest.Encode("query", input.BlockID), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-copy-source": input.CopySource, - } - - if input.ContentMD5 != nil { - headers["x-ms-source-content-md5"] = *input.ContentMD5 - } - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - if input.Range != nil { - headers["x-ms-source-range"] = *input.Range - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// PutBlockFromURLSender sends the PutBlockFromURL request. The method will close the -// http.Response Body if it receives an error. -func (client Client) PutBlockFromURLSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// PutBlockFromURLResponder handles the response to the PutBlockFromURL request. The method always -// closes the http.Response Body. -func (client Client) PutBlockFromURLResponder(resp *http.Response) (result PutBlockFromURLResult, err error) { - if resp != nil && resp.Header != nil { - result.ContentMD5 = resp.Header.Get("Content-MD5") - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_page_blob.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_page_blob.go deleted file mode 100644 index 4cfba95ae37b7..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_page_blob.go +++ /dev/null @@ -1,148 +0,0 @@ -package blobs - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type PutPageBlobInput struct { - CacheControl *string - ContentDisposition *string - ContentEncoding *string - ContentLanguage *string - ContentMD5 *string - ContentType *string - LeaseID *string - MetaData map[string]string - - BlobContentLengthBytes int64 - BlobSequenceNumber *int64 - AccessTier *AccessTier -} - -// PutPageBlob is a wrapper around the Put API call (with a stricter input object) -// which creates a new block blob, or updates the content of an existing page blob. -func (client Client) PutPageBlob(ctx context.Context, accountName, containerName, blobName string, input PutPageBlobInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "PutPageBlob", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "PutPageBlob", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "PutPageBlob", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "PutPageBlob", "`blobName` cannot be an empty string.") - } - if input.BlobContentLengthBytes == 0 || input.BlobContentLengthBytes%512 != 0 { - return result, validation.NewError("blobs.Client", "PutPageBlob", "`input.BlobContentLengthBytes` must be aligned to a 512-byte boundary.") - } - - req, err := client.PutPageBlobPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "PutPageBlob", nil, "Failure preparing request") - return - } - - resp, err := client.PutPageBlobSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "PutPageBlob", resp, "Failure sending request") - return - } - - result, err = client.PutPageBlobResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "PutPageBlob", resp, "Failure responding to request") - return - } - - return -} - -// PutPageBlobPreparer prepares the PutPageBlob request. -func (client Client) PutPageBlobPreparer(ctx context.Context, accountName, containerName, blobName string, input PutPageBlobInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - headers := map[string]interface{}{ - "x-ms-blob-type": string(PageBlob), - "x-ms-version": APIVersion, - - // For a page blob or an page blob, the value of this header must be set to zero, - // as Put Blob is used only to initialize the blob - "Content-Length": 0, - - // This header specifies the maximum size for the page blob, up to 8 TB. - // The page blob size must be aligned to a 512-byte boundary. - "x-ms-blob-content-length": input.BlobContentLengthBytes, - } - - if input.AccessTier != nil { - headers["x-ms-access-tier"] = string(*input.AccessTier) - } - if input.BlobSequenceNumber != nil { - headers["x-ms-blob-sequence-number"] = *input.BlobSequenceNumber - } - - if input.CacheControl != nil { - headers["x-ms-blob-cache-control"] = *input.CacheControl - } - if input.ContentDisposition != nil { - headers["x-ms-blob-content-disposition"] = *input.ContentDisposition - } - if input.ContentEncoding != nil { - headers["x-ms-blob-content-encoding"] = *input.ContentEncoding - } - if input.ContentLanguage != nil { - headers["x-ms-blob-content-language"] = *input.ContentLanguage - } - if input.ContentMD5 != nil { - headers["x-ms-blob-content-md5"] = *input.ContentMD5 - } - if input.ContentType != nil { - headers["x-ms-blob-content-type"] = *input.ContentType - } - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - - headers = metadata.SetIntoHeaders(headers, input.MetaData) - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// PutPageBlobSender sends the PutPageBlob request. The method will close the -// http.Response Body if it receives an error. -func (client Client) PutPageBlobSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// PutPageBlobResponder handles the response to the PutPageBlob request. The method always -// closes the http.Response Body. -func (client Client) PutPageBlobResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_page_clear.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_page_clear.go deleted file mode 100644 index 59feaa5d93d06..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_page_clear.go +++ /dev/null @@ -1,113 +0,0 @@ -package blobs - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type PutPageClearInput struct { - StartByte int64 - EndByte int64 - - LeaseID *string -} - -// PutPageClear clears a range of pages within a page blob. -func (client Client) PutPageClear(ctx context.Context, accountName, containerName, blobName string, input PutPageClearInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "PutPageClear", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "PutPageClear", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "PutPageClear", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "PutPageClear", "`blobName` cannot be an empty string.") - } - if input.StartByte < 0 { - return result, validation.NewError("blobs.Client", "PutPageClear", "`input.StartByte` must be greater than or equal to 0.") - } - if input.EndByte <= 0 { - return result, validation.NewError("blobs.Client", "PutPageClear", "`input.EndByte` must be greater than 0.") - } - - req, err := client.PutPageClearPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "PutPageClear", nil, "Failure preparing request") - return - } - - resp, err := client.PutPageClearSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "PutPageClear", resp, "Failure sending request") - return - } - - result, err = client.PutPageClearResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "PutPageClear", resp, "Failure responding to request") - return - } - - return -} - -// PutPageClearPreparer prepares the PutPageClear request. -func (client Client) PutPageClearPreparer(ctx context.Context, accountName, containerName, blobName string, input PutPageClearInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "page"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-page-write": "clear", - "x-ms-range": fmt.Sprintf("bytes=%d-%d", input.StartByte, input.EndByte), - } - - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// PutPageClearSender sends the PutPageClear request. The method will close the -// http.Response Body if it receives an error. -func (client Client) PutPageClearSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// PutPageClearResponder handles the response to the PutPageClear request. The method always -// closes the http.Response Body. -func (client Client) PutPageClearResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_page_update.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_page_update.go deleted file mode 100644 index 3799381e55250..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_page_update.go +++ /dev/null @@ -1,164 +0,0 @@ -package blobs - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type PutPageUpdateInput struct { - StartByte int64 - EndByte int64 - Content []byte - - IfSequenceNumberEQ *string - IfSequenceNumberLE *string - IfSequenceNumberLT *string - IfModifiedSince *string - IfUnmodifiedSince *string - IfMatch *string - IfNoneMatch *string - LeaseID *string -} - -type PutPageUpdateResult struct { - autorest.Response - - BlobSequenceNumber string - ContentMD5 string - LastModified string -} - -// PutPageUpdate writes a range of pages to a page blob. -func (client Client) PutPageUpdate(ctx context.Context, accountName, containerName, blobName string, input PutPageUpdateInput) (result PutPageUpdateResult, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "PutPageUpdate", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "PutPageUpdate", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "PutPageUpdate", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "PutPageUpdate", "`blobName` cannot be an empty string.") - } - if input.StartByte < 0 { - return result, validation.NewError("blobs.Client", "PutPageUpdate", "`input.StartByte` must be greater than or equal to 0.") - } - if input.EndByte <= 0 { - return result, validation.NewError("blobs.Client", "PutPageUpdate", "`input.EndByte` must be greater than 0.") - } - - expectedSize := (input.EndByte - input.StartByte) + 1 - actualSize := int64(len(input.Content)) - if expectedSize != actualSize { - return result, validation.NewError("blobs.Client", "PutPageUpdate", fmt.Sprintf("Content Size was defined as %d but got %d.", expectedSize, actualSize)) - } - - req, err := client.PutPageUpdatePreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "PutPageUpdate", nil, "Failure preparing request") - return - } - - resp, err := client.PutPageUpdateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "PutPageUpdate", resp, "Failure sending request") - return - } - - result, err = client.PutPageUpdateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "PutPageUpdate", resp, "Failure responding to request") - return - } - - return -} - -// PutPageUpdatePreparer prepares the PutPageUpdate request. -func (client Client) PutPageUpdatePreparer(ctx context.Context, accountName, containerName, blobName string, input PutPageUpdateInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "page"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-page-write": "update", - "x-ms-range": fmt.Sprintf("bytes=%d-%d", input.StartByte, input.EndByte), - "Content-Length": int(len(input.Content)), - } - - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - if input.IfSequenceNumberEQ != nil { - headers["x-ms-if-sequence-number-eq"] = *input.IfSequenceNumberEQ - } - if input.IfSequenceNumberLE != nil { - headers["x-ms-if-sequence-number-le"] = *input.IfSequenceNumberLE - } - if input.IfSequenceNumberLT != nil { - headers["x-ms-if-sequence-number-lt"] = *input.IfSequenceNumberLT - } - if input.IfModifiedSince != nil { - headers["If-Modified-Since"] = *input.IfModifiedSince - } - if input.IfUnmodifiedSince != nil { - headers["If-Unmodified-Since"] = *input.IfUnmodifiedSince - } - if input.IfMatch != nil { - headers["If-Match"] = *input.IfMatch - } - if input.IfNoneMatch != nil { - headers["If-None-Match"] = *input.IfNoneMatch - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers), - autorest.WithBytes(&input.Content)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// PutPageUpdateSender sends the PutPageUpdate request. The method will close the -// http.Response Body if it receives an error. -func (client Client) PutPageUpdateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// PutPageUpdateResponder handles the response to the PutPageUpdate request. The method always -// closes the http.Response Body. -func (client Client) PutPageUpdateResponder(resp *http.Response) (result PutPageUpdateResult, err error) { - if resp != nil && resp.Header != nil { - result.BlobSequenceNumber = resp.Header.Get("x-ms-blob-sequence-number") - result.ContentMD5 = resp.Header.Get("Content-MD5") - result.LastModified = resp.Header.Get("Last-Modified") - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/resource_id.go deleted file mode 100644 index 4057cf275676f..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/resource_id.go +++ /dev/null @@ -1,56 +0,0 @@ -package blobs - -import ( - "fmt" - "net/url" - "strings" - - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// GetResourceID returns the Resource ID for the given Blob -// This can be useful when, for example, you're using this as a unique identifier -func (client Client) GetResourceID(accountName, containerName, blobName string) string { - domain := endpoints.GetBlobEndpoint(client.BaseURI, accountName) - return fmt.Sprintf("%s/%s/%s", domain, containerName, blobName) -} - -type ResourceID struct { - AccountName string - ContainerName string - BlobName string -} - -// ParseResourceID parses the Resource ID and returns an object which can be used -// to interact with the Blob Resource -func ParseResourceID(id string) (*ResourceID, error) { - // example: https://foo.blob.core.windows.net/Bar/example.vhd - if id == "" { - return nil, fmt.Errorf("`id` was empty") - } - - uri, err := url.Parse(id) - if err != nil { - return nil, fmt.Errorf("Error parsing ID as a URL: %s", err) - } - - accountName, err := endpoints.GetAccountNameFromEndpoint(uri.Host) - if err != nil { - return nil, fmt.Errorf("Error parsing Account Name: %s", err) - } - - path := strings.TrimPrefix(uri.Path, "/") - segments := strings.Split(path, "/") - if len(segments) == 0 { - return nil, fmt.Errorf("Expected the path to contain segments but got none") - } - - containerName := segments[0] - blobName := strings.TrimPrefix(path, containerName) - blobName = strings.TrimPrefix(blobName, "/") - return &ResourceID{ - AccountName: *accountName, - ContainerName: containerName, - BlobName: blobName, - }, nil -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/set_tier.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/set_tier.go deleted file mode 100644 index dd0f0b8782b10..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/set_tier.go +++ /dev/null @@ -1,93 +0,0 @@ -package blobs - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// SetTier sets the tier on a blob. -func (client Client) SetTier(ctx context.Context, accountName, containerName, blobName string, tier AccessTier) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "SetTier", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "SetTier", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "SetTier", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "SetTier", "`blobName` cannot be an empty string.") - } - - req, err := client.SetTierPreparer(ctx, accountName, containerName, blobName, tier) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "SetTier", nil, "Failure preparing request") - return - } - - resp, err := client.SetTierSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "SetTier", resp, "Failure sending request") - return - } - - result, err = client.SetTierResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "SetTier", resp, "Failure responding to request") - return - } - - return -} - -// SetTierPreparer prepares the SetTier request. -func (client Client) SetTierPreparer(ctx context.Context, accountName, containerName, blobName string, tier AccessTier) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("path", "tier"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-access-tier": string(tier), - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SetTierSender sends the SetTier request. The method will close the -// http.Response Body if it receives an error. -func (client Client) SetTierSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// SetTierResponder handles the response to the SetTier request. The method always -// closes the http.Response Body. -func (client Client) SetTierResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/snapshot.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/snapshot.go deleted file mode 100644 index 180070b29469d..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/snapshot.go +++ /dev/null @@ -1,163 +0,0 @@ -package blobs - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type SnapshotInput struct { - // The ID of the Lease - // This must be specified if a Lease is present on the Blob, else a 403 is returned - LeaseID *string - - // MetaData is a user-defined name-value pair associated with the blob. - // If no name-value pairs are specified, the operation will copy the base blob metadata to the snapshot. - // If one or more name-value pairs are specified, the snapshot is created with the specified metadata, - // and metadata is not copied from the base blob. - MetaData map[string]string - - // A DateTime value which will only snapshot the blob if it has been modified since the specified date/time - // If the base blob has not been modified, the Blob service returns status code 412 (Precondition Failed). - IfModifiedSince *string - - // A DateTime value which will only snapshot the blob if it has not been modified since the specified date/time - // If the base blob has been modified, the Blob service returns status code 412 (Precondition Failed). - IfUnmodifiedSince *string - - // An ETag value to snapshot the blob only if its ETag value matches the value specified. - // If the values do not match, the Blob service returns status code 412 (Precondition Failed). - IfMatch *string - - // An ETag value for this conditional header to snapshot the blob only if its ETag value - // does not match the value specified. - // If the values are identical, the Blob service returns status code 412 (Precondition Failed). - IfNoneMatch *string -} - -type SnapshotResult struct { - autorest.Response - - // The ETag of the snapshot - ETag string - - // A DateTime value that uniquely identifies the snapshot. - // The value of this header indicates the snapshot version, - // and may be used in subsequent requests to access the snapshot. - SnapshotDateTime string -} - -// Snapshot captures a Snapshot of a given Blob -func (client Client) Snapshot(ctx context.Context, accountName, containerName, blobName string, input SnapshotInput) (result SnapshotResult, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "Snapshot", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "Snapshot", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "Snapshot", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "Snapshot", "`blobName` cannot be an empty string.") - } - if err := metadata.Validate(input.MetaData); err != nil { - return result, validation.NewError("blobs.Client", "Snapshot", fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) - } - - req, err := client.SnapshotPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "Snapshot", nil, "Failure preparing request") - return - } - - resp, err := client.SnapshotSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "Snapshot", resp, "Failure sending request") - return - } - - result, err = client.SnapshotResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "Snapshot", resp, "Failure responding to request") - return - } - - return -} - -// SnapshotPreparer prepares the Snapshot request. -func (client Client) SnapshotPreparer(ctx context.Context, accountName, containerName, blobName string, input SnapshotInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "snapshot"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - - if input.IfModifiedSince != nil { - headers["If-Modified-Since"] = *input.IfModifiedSince - } - if input.IfUnmodifiedSince != nil { - headers["If-Unmodified-Since"] = *input.IfUnmodifiedSince - } - if input.IfMatch != nil { - headers["If-Match"] = *input.IfMatch - } - if input.IfNoneMatch != nil { - headers["If-None-Match"] = *input.IfNoneMatch - } - - headers = metadata.SetIntoHeaders(headers, input.MetaData) - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SnapshotSender sends the Snapshot request. The method will close the -// http.Response Body if it receives an error. -func (client Client) SnapshotSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// SnapshotResponder handles the response to the Snapshot request. The method always -// closes the http.Response Body. -func (client Client) SnapshotResponder(resp *http.Response) (result SnapshotResult, err error) { - if resp != nil && resp.Header != nil { - result.ETag = resp.Header.Get("ETag") - result.SnapshotDateTime = resp.Header.Get("x-ms-snapshot") - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/snapshot_get_properties.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/snapshot_get_properties.go deleted file mode 100644 index fe1be63ab216a..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/snapshot_get_properties.go +++ /dev/null @@ -1,90 +0,0 @@ -package blobs - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type GetSnapshotPropertiesInput struct { - // The ID of the Lease - // This must be specified if a Lease is present on the Blob, else a 403 is returned - LeaseID *string - - // The ID of the Snapshot which should be retrieved - SnapshotID string -} - -// GetSnapshotProperties returns all user-defined metadata, standard HTTP properties, and system properties for -// the specified snapshot of a blob -func (client Client) GetSnapshotProperties(ctx context.Context, accountName, containerName, blobName string, input GetSnapshotPropertiesInput) (result GetPropertiesResult, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "GetSnapshotProperties", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "GetSnapshotProperties", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "GetSnapshotProperties", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "GetSnapshotProperties", "`blobName` cannot be an empty string.") - } - if input.SnapshotID == "" { - return result, validation.NewError("blobs.Client", "GetSnapshotProperties", "`input.SnapshotID` cannot be an empty string.") - } - - req, err := client.GetSnapshotPropertiesPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "GetSnapshotProperties", nil, "Failure preparing request") - return - } - - // we re-use the GetProperties methods since this is otherwise the same - resp, err := client.GetPropertiesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "GetSnapshotProperties", resp, "Failure sending request") - return - } - - result, err = client.GetPropertiesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "GetSnapshotProperties", resp, "Failure responding to request") - return - } - - return -} - -// GetSnapshotPreparer prepares the GetSnapshot request. -func (client Client) GetSnapshotPropertiesPreparer(ctx context.Context, accountName, containerName, blobName string, input GetSnapshotPropertiesInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "snapshot": autorest.Encode("query", input.SnapshotID), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID - } - - preparer := autorest.CreatePreparer( - autorest.AsHead(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithHeaders(headers), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/undelete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/undelete.go deleted file mode 100644 index 9be2f81a66f21..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/undelete.go +++ /dev/null @@ -1,92 +0,0 @@ -package blobs - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// Undelete restores the contents and metadata of soft deleted blob and any associated soft deleted snapshots. -func (client Client) Undelete(ctx context.Context, accountName, containerName, blobName string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "Undelete", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("blobs.Client", "Undelete", "`containerName` cannot be an empty string.") - } - if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "Undelete", "`containerName` must be a lower-cased string.") - } - if blobName == "" { - return result, validation.NewError("blobs.Client", "Undelete", "`blobName` cannot be an empty string.") - } - - req, err := client.UndeletePreparer(ctx, accountName, containerName, blobName) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "Undelete", nil, "Failure preparing request") - return - } - - resp, err := client.UndeleteSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "Undelete", resp, "Failure sending request") - return - } - - result, err = client.UndeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "Undelete", resp, "Failure responding to request") - return - } - - return -} - -// UndeletePreparer prepares the Undelete request. -func (client Client) UndeletePreparer(ctx context.Context, accountName, containerName, blobName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("path", "undelete"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// UndeleteSender sends the Undelete request. The method will close the -// http.Response Body if it receives an error. -func (client Client) UndeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// UndeleteResponder handles the response to the Undelete request. The method always -// closes the http.Response Body. -func (client Client) UndeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/version.go deleted file mode 100644 index b6d69e2233b5a..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/version.go +++ /dev/null @@ -1,14 +0,0 @@ -package blobs - -import ( - "fmt" - - "github.com/tombuildsstuff/giovanni/version" -) - -// APIVersion is the version of the API used for all Storage API Operations -const APIVersion = "2020-08-04" - -func UserAgent() string { - return fmt.Sprintf("tombuildsstuff/giovanni/%s storage/%s", version.Number, APIVersion) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/api.go deleted file mode 100644 index 622f2b00eed7f..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/api.go +++ /dev/null @@ -1,25 +0,0 @@ -package containers - -import ( - "context" - - "github.com/Azure/go-autorest/autorest" -) - -type StorageContainer interface { - Create(ctx context.Context, accountName, containerName string, input CreateInput) (result CreateResponse, err error) - Delete(ctx context.Context, accountName, containerName string) (result autorest.Response, err error) - GetProperties(ctx context.Context, accountName, containerName string) (ContainerProperties, error) - GetPropertiesWithLeaseID(ctx context.Context, accountName, containerName, leaseID string) (result ContainerProperties, err error) - AcquireLease(ctx context.Context, accountName, containerName string, input AcquireLeaseInput) (result AcquireLeaseResponse, err error) - BreakLease(ctx context.Context, accountName, containerName string, input BreakLeaseInput) (result BreakLeaseResponse, err error) - ChangeLease(ctx context.Context, accountName, containerName string, input ChangeLeaseInput) (result ChangeLeaseResponse, err error) - ReleaseLease(ctx context.Context, accountName, containerName, leaseID string) (result autorest.Response, err error) - RenewLease(ctx context.Context, accountName, containerName, leaseID string) (result autorest.Response, err error) - ListBlobs(ctx context.Context, accountName, containerName string, input ListBlobsInput) (result ListBlobsResult, err error) - GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, containerName string) string - SetAccessControl(ctx context.Context, accountName, containerName string, level AccessLevel) (autorest.Response, error) - SetAccessControlWithLeaseID(ctx context.Context, accountName, containerName, leaseID string, level AccessLevel) (result autorest.Response, err error) - SetMetaData(ctx context.Context, accountName, containerName string, metaData map[string]string) (autorest.Response, error) - SetMetaDataWithLeaseID(ctx context.Context, accountName, containerName, leaseID string, metaData map[string]string) (result autorest.Response, err error) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/client.go deleted file mode 100644 index 7bf494734484d..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/client.go +++ /dev/null @@ -1,34 +0,0 @@ -package containers - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Client is the base client for Blob Storage Containers. -type Client struct { - autorest.Client - BaseURI string -} - -// New creates an instance of the Client client. -func New() Client { - return NewWithEnvironment(azure.PublicCloud) -} - -// NewWithBaseURI creates an instance of the Client client. -func NewWithEnvironment(environment azure.Environment) Client { - return Client{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: environment.StorageEndpointSuffix, - } -} - -func (client Client) setAccessLevelIntoHeaders(headers map[string]interface{}, level AccessLevel) map[string]interface{} { - // If this header is not included in the request, container data is private to the account owner. - if level != Private { - headers["x-ms-blob-public-access"] = string(level) - } - - return headers -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/create.go deleted file mode 100644 index 84c2887d7d1a7..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/create.go +++ /dev/null @@ -1,123 +0,0 @@ -package containers - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type CreateInput struct { - // Specifies whether data in the container may be accessed publicly and the level of access - AccessLevel AccessLevel - - // A name-value pair to associate with the container as metadata. - MetaData map[string]string -} - -type CreateResponse struct { - autorest.Response - Error *ErrorResponse `xml:"Error"` -} - -// Create creates a new container under the specified account. -// If the container with the same name already exists, the operation fails. -func (client Client) Create(ctx context.Context, accountName, containerName string, input CreateInput) (result CreateResponse, err error) { - if accountName == "" { - return result, validation.NewError("containers.Client", "Create", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("containers.Client", "Create", "`containerName` cannot be an empty string.") - } - if err := metadata.Validate(input.MetaData); err != nil { - return result, validation.NewError("containers.Client", "Create", fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) - } - - req, err := client.CreatePreparer(ctx, accountName, containerName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "Create", nil, "Failure preparing request") - return - } - - resp, err := client.CreateSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containers.Client", "Create", resp, "Failure sending request") - return - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "Create", resp, "Failure responding to request") - return - } - - return -} - -// CreatePreparer prepares the Create request. -func (client Client) CreatePreparer(ctx context.Context, accountName string, containerName string, input CreateInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("path", "container"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - headers = client.setAccessLevelIntoHeaders(headers, input.AccessLevel) - headers = metadata.SetIntoHeaders(headers, input.MetaData) - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateSender sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (client Client) CreateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CreateResponder handles the response to the Create request. The method always -// closes the http.Response Body. -func (client Client) CreateResponder(resp *http.Response) (result CreateResponse, err error) { - successfulStatusCodes := []int{ - http.StatusCreated, - } - if autorest.ResponseHasStatusCode(resp, successfulStatusCodes...) { - // when successful there's no response - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(successfulStatusCodes...), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - } else { - // however when there's an error the error's in the response - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(successfulStatusCodes...), - autorest.ByUnmarshallingXML(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - } - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/delete.go deleted file mode 100644 index 30958295388eb..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/delete.go +++ /dev/null @@ -1,85 +0,0 @@ -package containers - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// Delete marks the specified container for deletion. -// The container and any blobs contained within it are later deleted during garbage collection. -func (client Client) Delete(ctx context.Context, accountName, containerName string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("containers.Client", "Delete", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("containers.Client", "Delete", "`containerName` cannot be an empty string.") - } - - req, err := client.DeletePreparer(ctx, accountName, containerName) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client Client) DeletePreparer(ctx context.Context, accountName string, containerName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("path", "container"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client Client) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/get_properties.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/get_properties.go deleted file mode 100644 index 1e308da67c55c..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/get_properties.go +++ /dev/null @@ -1,124 +0,0 @@ -package containers - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -// GetProperties returns the properties for this Container without a Lease -func (client Client) GetProperties(ctx context.Context, accountName, containerName string) (ContainerProperties, error) { - // If specified, Get Container Properties only succeeds if the container’s lease is active and matches this ID. - // If there is no active lease or the ID does not match, 412 (Precondition Failed) is returned. - return client.GetPropertiesWithLeaseID(ctx, accountName, containerName, "") -} - -// GetPropertiesWithLeaseID returns the properties for this Container using the specified LeaseID -func (client Client) GetPropertiesWithLeaseID(ctx context.Context, accountName, containerName, leaseID string) (result ContainerProperties, err error) { - if accountName == "" { - return result, validation.NewError("containers.Client", "GetPropertiesWithLeaseID", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("containers.Client", "GetPropertiesWithLeaseID", "`containerName` cannot be an empty string.") - } - - req, err := client.GetPropertiesWithLeaseIDPreparer(ctx, accountName, containerName, leaseID) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "GetProperties", nil, "Failure preparing request") - return - } - - resp, err := client.GetPropertiesWithLeaseIDSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containers.Client", "GetProperties", resp, "Failure sending request") - return - } - - result, err = client.GetPropertiesWithLeaseIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "GetProperties", resp, "Failure responding to request") - return - } - - return -} - -// GetPropertiesWithLeaseIDPreparer prepares the GetPropertiesWithLeaseID request. -func (client Client) GetPropertiesWithLeaseIDPreparer(ctx context.Context, accountName, containerName, leaseID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("path", "container"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - // If specified, Get Container Properties only succeeds if the container’s lease is active and matches this ID. - // If there is no active lease or the ID does not match, 412 (Precondition Failed) is returned. - if leaseID != "" { - headers["x-ms-lease-id"] = leaseID - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetPropertiesWithLeaseIDSender sends the GetPropertiesWithLeaseID request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetPropertiesWithLeaseIDSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetPropertiesWithLeaseIDResponder handles the response to the GetPropertiesWithLeaseID request. The method always -// closes the http.Response Body. -func (client Client) GetPropertiesWithLeaseIDResponder(resp *http.Response) (result ContainerProperties, err error) { - if resp != nil { - result.LeaseStatus = LeaseStatus(resp.Header.Get("x-ms-lease-status")) - result.LeaseState = LeaseState(resp.Header.Get("x-ms-lease-state")) - if result.LeaseStatus == Locked { - duration := LeaseDuration(resp.Header.Get("x-ms-lease-duration")) - result.LeaseDuration = &duration - } - - // If this header is not returned in the response, the container is private to the account owner. - accessLevel := resp.Header.Get("x-ms-blob-public-access") - if accessLevel != "" { - result.AccessLevel = AccessLevel(accessLevel) - } else { - result.AccessLevel = Private - } - - // we can't necessarily use strconv.ParseBool here since this could be nil (only in some API versions) - result.HasImmutabilityPolicy = strings.EqualFold(resp.Header.Get("x-ms-has-immutability-policy"), "true") - result.HasLegalHold = strings.EqualFold(resp.Header.Get("x-ms-has-legal-hold"), "true") - - result.MetaData = metadata.ParseFromHeaders(resp.Header) - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/lease_acquire.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/lease_acquire.go deleted file mode 100644 index 061c863c43f95..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/lease_acquire.go +++ /dev/null @@ -1,115 +0,0 @@ -package containers - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type AcquireLeaseInput struct { - // 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 - LeaseDuration int - - ProposedLeaseID string -} - -type AcquireLeaseResponse struct { - autorest.Response - - LeaseID string -} - -// AcquireLease establishes and manages a lock on a container for delete operations. -func (client Client) AcquireLease(ctx context.Context, accountName, containerName string, input AcquireLeaseInput) (result AcquireLeaseResponse, err error) { - if accountName == "" { - return result, validation.NewError("containers.Client", "AcquireLease", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("containers.Client", "AcquireLease", "`containerName` cannot be an empty string.") - } - // An infinite lease duration is -1 seconds. A non-infinite lease can be between 15 and 60 seconds - if input.LeaseDuration != -1 && (input.LeaseDuration <= 15 || input.LeaseDuration >= 60) { - return result, validation.NewError("containers.Client", "AcquireLease", "`input.LeaseDuration` must be -1 (infinite), or between 15 and 60 seconds.") - } - - req, err := client.AcquireLeasePreparer(ctx, accountName, containerName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "AcquireLease", nil, "Failure preparing request") - return - } - - resp, err := client.AcquireLeaseSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containers.Client", "AcquireLease", resp, "Failure sending request") - return - } - - result, err = client.AcquireLeaseResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "AcquireLease", resp, "Failure responding to request") - return - } - - return -} - -// AcquireLeasePreparer prepares the AcquireLease request. -func (client Client) AcquireLeasePreparer(ctx context.Context, accountName string, containerName string, input AcquireLeaseInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("path", "container"), - "comp": autorest.Encode("path", "lease"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-lease-action": "acquire", - "x-ms-lease-duration": input.LeaseDuration, - } - - if input.ProposedLeaseID != "" { - headers["x-ms-proposed-lease-id"] = input.ProposedLeaseID - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// AcquireLeaseSender sends the AcquireLease request. The method will close the -// http.Response Body if it receives an error. -func (client Client) AcquireLeaseSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// AcquireLeaseResponder handles the response to the AcquireLease request. The method always -// closes the http.Response Body. -func (client Client) AcquireLeaseResponder(resp *http.Response) (result AcquireLeaseResponse, err error) { - if resp != nil { - result.LeaseID = resp.Header.Get("x-ms-lease-id") - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/lease_break.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/lease_break.go deleted file mode 100644 index 08acfb7a31164..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/lease_break.go +++ /dev/null @@ -1,129 +0,0 @@ -package containers - -import ( - "context" - "net/http" - "strconv" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type BreakLeaseInput 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 *int - - LeaseID string -} - -type BreakLeaseResponse struct { - autorest.Response - - // Approximate time remaining in the lease period, in seconds. - // If the break is immediate, 0 is returned. - LeaseTime int -} - -// BreakLease breaks a lock based on it's Lease ID -func (client Client) BreakLease(ctx context.Context, accountName, containerName string, input BreakLeaseInput) (result BreakLeaseResponse, err error) { - if accountName == "" { - return result, validation.NewError("containers.Client", "BreakLease", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("containers.Client", "BreakLease", "`containerName` cannot be an empty string.") - } - if input.LeaseID == "" { - return result, validation.NewError("containers.Client", "BreakLease", "`input.LeaseID` cannot be an empty string.") - } - - req, err := client.BreakLeasePreparer(ctx, accountName, containerName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "BreakLease", nil, "Failure preparing request") - return - } - - resp, err := client.BreakLeaseSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containers.Client", "BreakLease", resp, "Failure sending request") - return - } - - result, err = client.BreakLeaseResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "BreakLease", resp, "Failure responding to request") - return - } - - return -} - -// BreakLeasePreparer prepares the BreakLease request. -func (client Client) BreakLeasePreparer(ctx context.Context, accountName string, containerName string, input BreakLeaseInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("path", "container"), - "comp": autorest.Encode("path", "lease"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-lease-action": "break", - "x-ms-lease-id": input.LeaseID, - } - - if input.BreakPeriod != nil { - headers["x-ms-lease-break-period"] = *input.BreakPeriod - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// BreakLeaseSender sends the BreakLease request. The method will close the -// http.Response Body if it receives an error. -func (client Client) BreakLeaseSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// BreakLeaseResponder handles the response to the BreakLease request. The method always -// closes the http.Response Body. -func (client Client) BreakLeaseResponder(resp *http.Response) (result BreakLeaseResponse, err error) { - if resp != nil { - leaseRaw := resp.Header.Get("x-ms-lease-time") - if leaseRaw != "" { - i, err := strconv.Atoi(leaseRaw) - if err == nil { - result.LeaseTime = i - } - } - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/lease_change.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/lease_change.go deleted file mode 100644 index dfbcb132dae3d..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/lease_change.go +++ /dev/null @@ -1,111 +0,0 @@ -package containers - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type ChangeLeaseInput struct { - ExistingLeaseID string - ProposedLeaseID string -} - -type ChangeLeaseResponse struct { - autorest.Response - - LeaseID string -} - -// ChangeLease changes the lock from one Lease ID to another Lease ID -func (client Client) ChangeLease(ctx context.Context, accountName, containerName string, input ChangeLeaseInput) (result ChangeLeaseResponse, err error) { - if accountName == "" { - return result, validation.NewError("containers.Client", "ChangeLease", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("containers.Client", "ChangeLease", "`containerName` cannot be an empty string.") - } - if input.ExistingLeaseID == "" { - return result, validation.NewError("containers.Client", "ChangeLease", "`input.ExistingLeaseID` cannot be an empty string.") - } - if input.ProposedLeaseID == "" { - return result, validation.NewError("containers.Client", "ChangeLease", "`input.ProposedLeaseID` cannot be an empty string.") - } - - req, err := client.ChangeLeasePreparer(ctx, accountName, containerName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "ChangeLease", nil, "Failure preparing request") - return - } - - resp, err := client.ChangeLeaseSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containers.Client", "ChangeLease", resp, "Failure sending request") - return - } - - result, err = client.ChangeLeaseResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "ChangeLease", resp, "Failure responding to request") - return - } - - return -} - -// ChangeLeasePreparer prepares the ChangeLease request. -func (client Client) ChangeLeasePreparer(ctx context.Context, accountName string, containerName string, input ChangeLeaseInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("path", "container"), - "comp": autorest.Encode("path", "lease"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-lease-action": "change", - "x-ms-lease-id": input.ExistingLeaseID, - "x-ms-proposed-lease-id": input.ProposedLeaseID, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ChangeLeaseSender sends the ChangeLease request. The method will close the -// http.Response Body if it receives an error. -func (client Client) ChangeLeaseSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ChangeLeaseResponder handles the response to the ChangeLease request. The method always -// closes the http.Response Body. -func (client Client) ChangeLeaseResponder(resp *http.Response) (result ChangeLeaseResponse, err error) { - if resp != nil { - result.LeaseID = resp.Header.Get("x-ms-lease-id") - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/lease_release.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/lease_release.go deleted file mode 100644 index fafcf98f1e67c..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/lease_release.go +++ /dev/null @@ -1,92 +0,0 @@ -package containers - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// ReleaseLease releases the lock based on the Lease ID -func (client Client) ReleaseLease(ctx context.Context, accountName, containerName, leaseID string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("containers.Client", "ReleaseLease", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("containers.Client", "ReleaseLease", "`containerName` cannot be an empty string.") - } - if leaseID == "" { - return result, validation.NewError("containers.Client", "ReleaseLease", "`leaseID` cannot be an empty string.") - } - - req, err := client.ReleaseLeasePreparer(ctx, accountName, containerName, leaseID) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "ReleaseLease", nil, "Failure preparing request") - return - } - - resp, err := client.ReleaseLeaseSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containers.Client", "ReleaseLease", resp, "Failure sending request") - return - } - - result, err = client.ReleaseLeaseResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "ReleaseLease", resp, "Failure responding to request") - return - } - - return -} - -// ReleaseLeasePreparer prepares the ReleaseLease request. -func (client Client) ReleaseLeasePreparer(ctx context.Context, accountName string, containerName string, leaseID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("path", "container"), - "comp": autorest.Encode("path", "lease"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-lease-action": "release", - "x-ms-lease-id": leaseID, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ReleaseLeaseSender sends the ReleaseLease request. The method will close the -// http.Response Body if it receives an error. -func (client Client) ReleaseLeaseSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ReleaseLeaseResponder handles the response to the ReleaseLease request. The method always -// closes the http.Response Body. -func (client Client) ReleaseLeaseResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/lease_renew.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/lease_renew.go deleted file mode 100644 index cab50bff9d21d..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/lease_renew.go +++ /dev/null @@ -1,92 +0,0 @@ -package containers - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// RenewLease renews the lock based on the Lease ID -func (client Client) RenewLease(ctx context.Context, accountName, containerName, leaseID string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("containers.Client", "RenewLease", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("containers.Client", "RenewLease", "`containerName` cannot be an empty string.") - } - if leaseID == "" { - return result, validation.NewError("containers.Client", "RenewLease", "`leaseID` cannot be an empty string.") - } - - req, err := client.RenewLeasePreparer(ctx, accountName, containerName, leaseID) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "RenewLease", nil, "Failure preparing request") - return - } - - resp, err := client.RenewLeaseSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containers.Client", "RenewLease", resp, "Failure sending request") - return - } - - result, err = client.RenewLeaseResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "RenewLease", resp, "Failure responding to request") - return - } - - return -} - -// RenewLeasePreparer prepares the RenewLease request. -func (client Client) RenewLeasePreparer(ctx context.Context, accountName string, containerName string, leaseID string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("path", "container"), - "comp": autorest.Encode("path", "lease"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-lease-action": "renew", - "x-ms-lease-id": leaseID, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// RenewLeaseSender sends the RenewLease request. The method will close the -// http.Response Body if it receives an error. -func (client Client) RenewLeaseSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// RenewLeaseResponder handles the response to the RenewLease request. The method always -// closes the http.Response Body. -func (client Client) RenewLeaseResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/list_blobs.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/list_blobs.go deleted file mode 100644 index 82797d091d367..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/list_blobs.go +++ /dev/null @@ -1,179 +0,0 @@ -package containers - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type ListBlobsInput struct { - Delimiter *string - Include *[]Dataset - Marker *string - MaxResults *int - Prefix *string -} - -type ListBlobsResult struct { - autorest.Response - - Delimiter string `xml:"Delimiter"` - Marker string `xml:"Marker"` - MaxResults int `xml:"MaxResults"` - NextMarker *string `xml:"NextMarker,omitempty"` - Prefix string `xml:"Prefix"` - Blobs Blobs `xml:"Blobs"` -} - -type Blobs struct { - Blobs []BlobDetails `xml:"Blob"` - BlobPrefix *BlobPrefix `xml:"BlobPrefix"` -} - -type BlobDetails struct { - Name string `xml:"Name"` - Deleted bool `xml:"Deleted,omitempty"` - MetaData map[string]interface{} `map:"Metadata,omitempty"` - Properties *BlobProperties `xml:"Properties,omitempty"` - Snapshot *string `xml:"Snapshot,omitempty"` -} - -type BlobProperties struct { - AccessTier *string `xml:"AccessTier,omitempty"` - AccessTierInferred *bool `xml:"AccessTierInferred,omitempty"` - AccessTierChangeTime *string `xml:"AccessTierChangeTime,omitempty"` - BlobType *string `xml:"BlobType,omitempty"` - BlobSequenceNumber *string `xml:"x-ms-blob-sequence-number,omitempty"` - CacheControl *string `xml:"Cache-Control,omitempty"` - ContentEncoding *string `xml:"ContentEncoding,omitempty"` - ContentLanguage *string `xml:"Content-Language,omitempty"` - ContentLength *int64 `xml:"Content-Length,omitempty"` - ContentMD5 *string `xml:"Content-MD5,omitempty"` - ContentType *string `xml:"Content-Type,omitempty"` - CopyCompletionTime *string `xml:"CopyCompletionTime,omitempty"` - CopyId *string `xml:"CopyId,omitempty"` - CopyStatus *string `xml:"CopyStatus,omitempty"` - CopySource *string `xml:"CopySource,omitempty"` - CopyProgress *string `xml:"CopyProgress,omitempty"` - CopyStatusDescription *string `xml:"CopyStatusDescription,omitempty"` - CreationTime *string `xml:"CreationTime,omitempty"` - ETag *string `xml:"Etag,omitempty"` - DeletedTime *string `xml:"DeletedTime,omitempty"` - IncrementalCopy *bool `xml:"IncrementalCopy,omitempty"` - LastModified *string `xml:"Last-Modified,omitempty"` - LeaseDuration *string `xml:"LeaseDuration,omitempty"` - LeaseState *string `xml:"LeaseState,omitempty"` - LeaseStatus *string `xml:"LeaseStatus,omitempty"` - RemainingRetentionDays *string `xml:"RemainingRetentionDays,omitempty"` - ServerEncrypted *bool `xml:"ServerEncrypted,omitempty"` -} - -type BlobPrefix struct { - Name string `xml:"Name"` -} - -// ListBlobs lists the blobs matching the specified query within the specified Container -func (client Client) ListBlobs(ctx context.Context, accountName, containerName string, input ListBlobsInput) (result ListBlobsResult, err error) { - if accountName == "" { - return result, validation.NewError("containers.Client", "ListBlobs", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("containers.Client", "ListBlobs", "`containerName` cannot be an empty string.") - } - if input.MaxResults != nil && (*input.MaxResults <= 0 || *input.MaxResults > 5000) { - return result, validation.NewError("containers.Client", "ListBlobs", "`input.MaxResults` can either be nil or between 0 and 5000.") - } - - req, err := client.ListBlobsPreparer(ctx, accountName, containerName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "ListBlobs", nil, "Failure preparing request") - return - } - - resp, err := client.ListBlobsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containers.Client", "ListBlobs", resp, "Failure sending request") - return - } - - result, err = client.ListBlobsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "ListBlobs", resp, "Failure responding to request") - return - } - - return -} - -// ListBlobsPreparer prepares the ListBlobs request. -func (client Client) ListBlobsPreparer(ctx context.Context, accountName, containerName string, input ListBlobsInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "list"), - "restype": autorest.Encode("query", "container"), - } - - if input.Delimiter != nil { - queryParameters["delimiter"] = autorest.Encode("query", *input.Delimiter) - } - if input.Include != nil { - vals := make([]string, 0) - for _, v := range *input.Include { - vals = append(vals, string(v)) - } - include := strings.Join(vals, ",") - queryParameters["include"] = autorest.Encode("query", include) - } - if input.Marker != nil { - queryParameters["marker"] = autorest.Encode("query", *input.Marker) - } - if input.MaxResults != nil { - queryParameters["maxresults"] = autorest.Encode("query", *input.MaxResults) - } - if input.Prefix != nil { - queryParameters["prefix"] = autorest.Encode("query", *input.Prefix) - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListBlobsSender sends the ListBlobs request. The method will close the -// http.Response Body if it receives an error. -func (client Client) ListBlobsSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListBlobsResponder handles the response to the ListBlobs request. The method always -// closes the http.Response Body. -func (client Client) ListBlobsResponder(resp *http.Response) (result ListBlobsResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingXML(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/resource_id.go deleted file mode 100644 index d35674a7868da..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/resource_id.go +++ /dev/null @@ -1,53 +0,0 @@ -package containers - -import ( - "fmt" - "net/url" - "strings" - - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// GetResourceID returns the Resource ID for the given Container -// This can be useful when, for example, you're using this as a unique identifier -func (client Client) GetResourceID(accountName, containerName string) string { - domain := endpoints.GetBlobEndpoint(client.BaseURI, accountName) - return fmt.Sprintf("%s/%s", domain, containerName) -} - -// GetResourceManagerResourceID returns the Resource Manager specific -// ResourceID for a specific Storage Container -func (client Client) GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, containerName string) string { - fmtStr := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s/blobServices/default/containers/%s" - return fmt.Sprintf(fmtStr, subscriptionID, resourceGroup, accountName, containerName) -} - -type ResourceID struct { - AccountName string - ContainerName string -} - -// ParseResourceID parses the Resource ID and returns an object which can be used -// to interact with the Container Resource -func ParseResourceID(id string) (*ResourceID, error) { - // example: https://foo.blob.core.windows.net/Bar - if id == "" { - return nil, fmt.Errorf("`id` was empty") - } - - uri, err := url.Parse(id) - if err != nil { - return nil, fmt.Errorf("Error parsing ID as a URL: %s", err) - } - - accountName, err := endpoints.GetAccountNameFromEndpoint(uri.Host) - if err != nil { - return nil, fmt.Errorf("Error parsing Account Name: %s", err) - } - - containerName := strings.TrimPrefix(uri.Path, "/") - return &ResourceID{ - AccountName: *accountName, - ContainerName: containerName, - }, nil -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/set_acl.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/set_acl.go deleted file mode 100644 index fcf4e1056fa43..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/set_acl.go +++ /dev/null @@ -1,100 +0,0 @@ -package containers - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// SetAccessControl sets the Access Control for a Container without a Lease ID -func (client Client) SetAccessControl(ctx context.Context, accountName, containerName string, level AccessLevel) (autorest.Response, error) { - return client.SetAccessControlWithLeaseID(ctx, accountName, containerName, "", level) -} - -// SetAccessControlWithLeaseID sets the Access Control for a Container using the specified Lease ID -func (client Client) SetAccessControlWithLeaseID(ctx context.Context, accountName, containerName, leaseID string, level AccessLevel) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("containers.Client", "SetAccessControl", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("containers.Client", "SetAccessControl", "`containerName` cannot be an empty string.") - } - - req, err := client.SetAccessControlWithLeaseIDPreparer(ctx, accountName, containerName, leaseID, level) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "SetAccessControl", nil, "Failure preparing request") - return - } - - resp, err := client.SetAccessControlWithLeaseIDSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containers.Client", "SetAccessControl", resp, "Failure sending request") - return - } - - result, err = client.SetAccessControlWithLeaseIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "SetAccessControl", resp, "Failure responding to request") - return - } - - return -} - -// SetAccessControlWithLeaseIDPreparer prepares the SetAccessControlWithLeaseID request. -func (client Client) SetAccessControlWithLeaseIDPreparer(ctx context.Context, accountName, containerName, leaseID string, level AccessLevel) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("path", "acl"), - "restype": autorest.Encode("path", "container"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - headers = client.setAccessLevelIntoHeaders(headers, level) - - // If specified, Get Container Properties only succeeds if the container’s lease is active and matches this ID. - // If there is no active lease or the ID does not match, 412 (Precondition Failed) is returned. - if leaseID != "" { - headers["x-ms-lease-id"] = leaseID - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SetAccessControlWithLeaseIDSender sends the SetAccessControlWithLeaseID request. The method will close the -// http.Response Body if it receives an error. -func (client Client) SetAccessControlWithLeaseIDSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// SetAccessControlWithLeaseIDResponder handles the response to the SetAccessControlWithLeaseID request. The method always -// closes the http.Response Body. -func (client Client) SetAccessControlWithLeaseIDResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/set_metadata.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/set_metadata.go deleted file mode 100644 index fb9e07fdefa92..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/set_metadata.go +++ /dev/null @@ -1,105 +0,0 @@ -package containers - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -// SetMetaData sets the specified MetaData on the Container without a Lease ID -func (client Client) SetMetaData(ctx context.Context, accountName, containerName string, metaData map[string]string) (autorest.Response, error) { - return client.SetMetaDataWithLeaseID(ctx, accountName, containerName, "", metaData) -} - -// SetMetaDataWithLeaseID sets the specified MetaData on the Container using the specified Lease ID -func (client Client) SetMetaDataWithLeaseID(ctx context.Context, accountName, containerName, leaseID string, metaData map[string]string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("containers.Client", "SetMetaData", "`accountName` cannot be an empty string.") - } - if containerName == "" { - return result, validation.NewError("containers.Client", "SetMetaData", "`containerName` cannot be an empty string.") - } - if err := metadata.Validate(metaData); err != nil { - return result, validation.NewError("containers.Client", "SetMetaData", fmt.Sprintf("`metaData` is not valid: %s.", err)) - } - - req, err := client.SetMetaDataWithLeaseIDPreparer(ctx, accountName, containerName, leaseID, metaData) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "SetMetaData", nil, "Failure preparing request") - return - } - - resp, err := client.SetMetaDataWithLeaseIDSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containers.Client", "SetMetaData", resp, "Failure sending request") - return - } - - result, err = client.SetMetaDataWithLeaseIDResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containers.Client", "SetMetaData", resp, "Failure responding to request") - return - } - - return -} - -// SetMetaDataWithLeaseIDPreparer prepares the SetMetaDataWithLeaseID request. -func (client Client) SetMetaDataWithLeaseIDPreparer(ctx context.Context, accountName, containerName, leaseID string, metaData map[string]string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("path", "metadata"), - "restype": autorest.Encode("path", "container"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - headers = metadata.SetIntoHeaders(headers, metaData) - - // If specified, Get Container Properties only succeeds if the container’s lease is active and matches this ID. - // If there is no active lease or the ID does not match, 412 (Precondition Failed) is returned. - if leaseID != "" { - headers["x-ms-lease-id"] = leaseID - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SetMetaDataWithLeaseIDSender sends the SetMetaDataWithLeaseID request. The method will close the -// http.Response Body if it receives an error. -func (client Client) SetMetaDataWithLeaseIDSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// SetMetaDataWithLeaseIDResponder handles the response to the SetMetaDataWithLeaseID request. The method always -// closes the http.Response Body. -func (client Client) SetMetaDataWithLeaseIDResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/version.go deleted file mode 100644 index d3138cb35875d..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/version.go +++ /dev/null @@ -1,14 +0,0 @@ -package containers - -import ( - "fmt" - - "github.com/tombuildsstuff/giovanni/version" -) - -// APIVersion is the version of the API used for all Storage API Operations -const APIVersion = "2020-08-04" - -func UserAgent() string { - return fmt.Sprintf("tombuildsstuff/giovanni/%s storage/%s", version.Number, APIVersion) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/README.md b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/README.md deleted file mode 100644 index be6fb76139d53..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/README.md +++ /dev/null @@ -1,84 +0,0 @@ -## Data Lake Storage Gen2 File Systems SDK for API version 2020-08-04 - -This package allows you to interact with the Data Lake Storage Gen2 File Systems API - -### Supported Authorizers - -* Azure Active Directory (for the Resource Endpoint `https://storage.azure.com`) - -### Example Usage - -```go -package main - -import ( - "context" - "fmt" - "os" - "time" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/adal" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/hashicorp/go-azure-helpers/authentication" - "github.com/hashicorp/go-azure-helpers/sender" - "github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems" -) - -func Example() error { - accountName := "storageaccount1" - fileSystemName := "filesystem1" - - builder := &authentication.Builder{ - SubscriptionID: os.Getenv("ARM_SUBSCRIPTION_ID"), - ClientID: os.Getenv("ARM_CLIENT_ID"), - ClientSecret: os.Getenv("ARM_CLIENT_SECRET"), - TenantID: os.Getenv("ARM_TENANT_ID"), - Environment: os.Getenv("ARM_ENVIRONMENT"), - - // Feature Toggles - SupportsClientSecretAuth: true, - } - - c, err := builder.Build() - if err != nil { - return fmt.Errorf("Error building AzureRM Client: %s", err) - } - - env, err := authentication.DetermineEnvironment(c.Environment) - if err != nil { - return err - } - - oauthConfig, err := adal.NewOAuthConfig(env.ActiveDirectoryEndpoint, c.TenantID) - if err != nil { - return err - } - - // OAuthConfigForTenant returns a pointer, which can be nil. - if oauthConfig == nil { - return fmt.Errorf("Unable to configure OAuthConfig for tenant %s", c.TenantID) - } - - sender := sender.BuildSender("AzureRM") - ctx := context.Background() - - storageAuth, err := config.GetAuthorizationToken(sender, oauthConfig, "https://storage.azure.com/") - if err != nil { - return fmt.Errorf("Error retrieving Authorization Token") - } - - - fileSystemsClient := filesystems.NewWithEnvironment(env) - fileSystemsClient.Client.Authorizer = storageAuth - - input := filesystems.CreateInput{ - Properties: map[string]string{}, - } - if _, err = fileSystemsClient.Create(ctx, accountName, fileSystemName, input); err != nil { - return fmt.Errorf("Error creating: %s", err) - } - - return nil -} -``` \ No newline at end of file diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/client.go deleted file mode 100644 index 91d3fe1cf45e8..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/client.go +++ /dev/null @@ -1,25 +0,0 @@ -package filesystems - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Client is the base client for Data Lake Storage FileSystem -type Client struct { - autorest.Client - BaseURI string -} - -// New creates an instance of the Data Lake Storage FileSystem client. -func New() Client { - return NewWithEnvironment(azure.PublicCloud) -} - -// NewWithEnvironment creates an instance of the Data Lake Storage FileSystem client. -func NewWithEnvironment(environment azure.Environment) Client { - return Client{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: environment.StorageEndpointSuffix, - } -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/create.go deleted file mode 100644 index 4217cb80af0e6..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/create.go +++ /dev/null @@ -1,94 +0,0 @@ -package filesystems - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type CreateInput struct { - // A map of base64-encoded strings to store as user-defined properties with the File System - // Note that items may only contain ASCII characters in the ISO-8859-1 character set. - // This automatically gets converted to a comma-separated list of name and - // value pairs before sending to the API - Properties map[string]string -} - -// Create creates a Data Lake Store Gen2 FileSystem within a Storage Account -func (client Client) Create(ctx context.Context, accountName string, fileSystemName string, input CreateInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("datalakestore.Client", "Create", "`accountName` cannot be an empty string.") - } - if fileSystemName == "" { - return result, validation.NewError("datalakestore.Client", "Create", "`fileSystemName` cannot be an empty string.") - } - - req, err := client.CreatePreparer(ctx, accountName, fileSystemName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "datalakestore.Client", "Create", nil, "Failure preparing request") - return - } - - resp, err := client.CreateSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "datalakestore.Client", "Create", resp, "Failure sending request") - return - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "datalakestore.Client", "Create", resp, "Failure responding to request") - } - - return -} - -// CreatePreparer prepares the Create request. -func (client Client) CreatePreparer(ctx context.Context, accountName string, fileSystemName string, input CreateInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "fileSystemName": autorest.Encode("path", fileSystemName), - } - - queryParameters := map[string]interface{}{ - "resource": autorest.Encode("query", "filesystem"), - } - - headers := map[string]interface{}{ - "x-ms-properties": buildProperties(input.Properties), - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetDataLakeStoreEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{fileSystemName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateSender sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (client Client) CreateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CreateResponder handles the response to the Create request. The method always -// closes the http.Response Body. -func (client Client) CreateResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/delete.go deleted file mode 100644 index fabc589da9400..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/delete.go +++ /dev/null @@ -1,85 +0,0 @@ -package filesystems - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// Delete deletes a Data Lake Store Gen2 FileSystem within a Storage Account -func (client Client) Delete(ctx context.Context, accountName string, fileSystemName string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("datalakestore.Client", "Delete", "`accountName` cannot be an empty string.") - } - if fileSystemName == "" { - return result, validation.NewError("datalakestore.Client", "Delete", "`fileSystemName` cannot be an empty string.") - } - - req, err := client.DeletePreparer(ctx, accountName, fileSystemName) - if err != nil { - err = autorest.NewErrorWithError(err, "datalakestore.Client", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "datalakestore.Client", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "datalakestore.Client", "Delete", resp, "Failure responding to request") - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client Client) DeletePreparer(ctx context.Context, accountName string, fileSystemName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "fileSystemName": autorest.Encode("path", fileSystemName), - } - - queryParameters := map[string]interface{}{ - "resource": autorest.Encode("query", "filesystem"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(endpoints.GetDataLakeStoreEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{fileSystemName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client Client) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/properties_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/properties_get.go deleted file mode 100644 index 0b96c95edd524..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/properties_get.go +++ /dev/null @@ -1,112 +0,0 @@ -package filesystems - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type GetPropertiesResponse struct { - autorest.Response - - // A map of base64-encoded strings to store as user-defined properties with the File System - // Note that items may only contain ASCII characters in the ISO-8859-1 character set. - // This automatically gets converted to a comma-separated list of name and - // value pairs before sending to the API - Properties map[string]string - - // Is Hierarchical Namespace Enabled? - NamespaceEnabled bool -} - -// GetProperties gets the properties for a Data Lake Store Gen2 FileSystem within a Storage Account -func (client Client) GetProperties(ctx context.Context, accountName string, fileSystemName string) (result GetPropertiesResponse, err error) { - if accountName == "" { - return result, validation.NewError("datalakestore.Client", "GetProperties", "`accountName` cannot be an empty string.") - } - if fileSystemName == "" { - return result, validation.NewError("datalakestore.Client", "GetProperties", "`fileSystemName` cannot be an empty string.") - } - - req, err := client.GetPropertiesPreparer(ctx, accountName, fileSystemName) - if err != nil { - err = autorest.NewErrorWithError(err, "datalakestore.Client", "GetProperties", nil, "Failure preparing request") - return - } - - resp, err := client.GetPropertiesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "datalakestore.Client", "GetProperties", resp, "Failure sending request") - return - } - - result, err = client.GetPropertiesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "datalakestore.Client", "GetProperties", resp, "Failure responding to request") - } - - return -} - -// GetPropertiesPreparer prepares the GetProperties request. -func (client Client) GetPropertiesPreparer(ctx context.Context, accountName string, fileSystemName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "fileSystemName": autorest.Encode("path", fileSystemName), - } - - queryParameters := map[string]interface{}{ - "resource": autorest.Encode("query", "filesystem"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsHead(), - autorest.WithBaseURL(endpoints.GetDataLakeStoreEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{fileSystemName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetPropertiesSender sends the GetProperties request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetPropertiesSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetPropertiesResponder handles the response to the GetProperties request. The method always -// closes the http.Response Body. -func (client Client) GetPropertiesResponder(resp *http.Response) (result GetPropertiesResponse, err error) { - if resp != nil && resp.Header != nil { - - propertiesRaw := resp.Header.Get("x-ms-properties") - var properties *map[string]string - properties, err = parseProperties(propertiesRaw) - if err != nil { - return - } - - result.Properties = *properties - result.NamespaceEnabled = strings.EqualFold(resp.Header.Get("x-ms-namespace-enabled"), "tru") - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/properties_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/properties_set.go deleted file mode 100644 index dde02a4455b9e..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/properties_set.go +++ /dev/null @@ -1,109 +0,0 @@ -package filesystems - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type SetPropertiesInput struct { - // A map of base64-encoded strings to store as user-defined properties with the File System - // Note that items may only contain ASCII characters in the ISO-8859-1 character set. - // This automatically gets converted to a comma-separated list of name and - // value pairs before sending to the API - Properties map[string]string - - // Optional - A date and time value. - // Specify this header to perform the operation only if the resource has been modified since the specified date and time. - IfModifiedSince *string - - // Optional - A date and time value. - // Specify this header to perform the operation only if the resource has not been modified since the specified date and time. - IfUnmodifiedSince *string -} - -// SetProperties sets the Properties for a Data Lake Store Gen2 FileSystem within a Storage Account -func (client Client) SetProperties(ctx context.Context, accountName string, fileSystemName string, input SetPropertiesInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("datalakestore.Client", "SetProperties", "`accountName` cannot be an empty string.") - } - if fileSystemName == "" { - return result, validation.NewError("datalakestore.Client", "SetProperties", "`fileSystemName` cannot be an empty string.") - } - - req, err := client.SetPropertiesPreparer(ctx, accountName, fileSystemName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "datalakestore.Client", "SetProperties", nil, "Failure preparing request") - return - } - - resp, err := client.SetPropertiesSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "datalakestore.Client", "SetProperties", resp, "Failure sending request") - return - } - - result, err = client.SetPropertiesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "datalakestore.Client", "SetProperties", resp, "Failure responding to request") - } - - return -} - -// SetPropertiesPreparer prepares the SetProperties request. -func (client Client) SetPropertiesPreparer(ctx context.Context, accountName string, fileSystemName string, input SetPropertiesInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "fileSystemName": autorest.Encode("path", fileSystemName), - } - - queryParameters := map[string]interface{}{ - "resource": autorest.Encode("query", "filesystem"), - } - - headers := map[string]interface{}{ - "x-ms-properties": buildProperties(input.Properties), - "x-ms-version": APIVersion, - } - - if input.IfModifiedSince != nil { - headers["If-Modified-Since"] = *input.IfModifiedSince - } - if input.IfUnmodifiedSince != nil { - headers["If-Unmodified-Since"] = *input.IfUnmodifiedSince - } - - preparer := autorest.CreatePreparer( - autorest.AsPatch(), - autorest.WithBaseURL(endpoints.GetDataLakeStoreEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{fileSystemName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SetPropertiesSender sends the SetProperties request. The method will close the -// http.Response Body if it receives an error. -func (client Client) SetPropertiesSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// SetPropertiesResponder handles the response to the SetProperties request. The method always -// closes the http.Response Body. -func (client Client) SetPropertiesResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/resource_id.go deleted file mode 100644 index 34797b20b7a9d..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/resource_id.go +++ /dev/null @@ -1,46 +0,0 @@ -package filesystems - -import ( - "fmt" - "net/url" - "strings" - - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// GetResourceID returns the Resource ID for the given Data Lake Storage FileSystem -// This can be useful when, for example, you're using this as a unique identifier -func (client Client) GetResourceID(accountName, shareName string) string { - domain := endpoints.GetDataLakeStoreEndpoint(client.BaseURI, accountName) - return fmt.Sprintf("%s/%s", domain, shareName) -} - -type ResourceID struct { - AccountName string - DirectoryName string -} - -// ParseResourceID parses the specified Resource ID and returns an object -// which can be used to interact with the Data Lake Storage FileSystem API's -func ParseResourceID(id string) (*ResourceID, error) { - // example: https://foo.dfs.core.windows.net/Bar - if id == "" { - return nil, fmt.Errorf("`id` was empty") - } - - uri, err := url.Parse(id) - if err != nil { - return nil, fmt.Errorf("Error parsing ID as a URL: %s", err) - } - - accountName, err := endpoints.GetAccountNameFromEndpoint(uri.Host) - if err != nil { - return nil, fmt.Errorf("Error parsing Account Name: %s", err) - } - - directoryName := strings.TrimPrefix(uri.Path, "/") - return &ResourceID{ - AccountName: *accountName, - DirectoryName: directoryName, - }, nil -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/version.go deleted file mode 100644 index 7447ea9ade09a..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/version.go +++ /dev/null @@ -1,14 +0,0 @@ -package filesystems - -import ( - "fmt" - - "github.com/tombuildsstuff/giovanni/version" -) - -// APIVersion is the version of the API used for all Storage API Operations -const APIVersion = "2020-08-04" - -func UserAgent() string { - return fmt.Sprintf("tombuildsstuff/giovanni/%s storage/%s", version.Number, APIVersion) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/client.go deleted file mode 100644 index 3fb087bf8c8d1..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/client.go +++ /dev/null @@ -1,25 +0,0 @@ -package paths - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Client is the base client for Data Lake Storage Path -type Client struct { - autorest.Client - BaseURI string -} - -// New creates an instance of the Data Lake Storage Path client. -func New() Client { - return NewWithEnvironment(azure.PublicCloud) -} - -// NewWithEnvironment creates an instance of the Data Lake Storage Path client. -func NewWithEnvironment(environment azure.Environment) Client { - return Client{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: environment.StorageEndpointSuffix, - } -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/create.go deleted file mode 100644 index 600bd75a9a871..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/create.go +++ /dev/null @@ -1,95 +0,0 @@ -package paths - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type PathResource string - -const PathResourceFile PathResource = "file" -const PathResourceDirectory PathResource = "directory" - -type CreateInput struct { - Resource PathResource -} - -// Create creates a Data Lake Store Gen2 Path within a Storage Account -func (client Client) Create(ctx context.Context, accountName string, fileSystemName string, path string, input CreateInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("datalakestore.Client", "Create", "`accountName` cannot be an empty string.") - } - if fileSystemName == "" { - return result, validation.NewError("datalakestore.Client", "Create", "`fileSystemName` cannot be an empty string.") - } - - req, err := client.CreatePreparer(ctx, accountName, fileSystemName, path, input) - if err != nil { - err = autorest.NewErrorWithError(err, "datalakestore.Client", "Create", nil, "Failure preparing request") - return - } - - resp, err := client.CreateSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "datalakestore.Client", "Create", resp, "Failure sending request") - return - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "datalakestore.Client", "Create", resp, "Failure responding to request") - } - - return -} - -// CreatePreparer prepares the Create request. -func (client Client) CreatePreparer(ctx context.Context, accountName string, fileSystemName string, path string, input CreateInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "fileSystemName": autorest.Encode("path", fileSystemName), - "path": autorest.Encode("path", path), - } - - queryParameters := map[string]interface{}{ - "resource": autorest.Encode("query", input.Resource), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetDataLakeStoreEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{fileSystemName}/{path}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateSender sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (client Client) CreateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CreateResponder handles the response to the Create request. The method always -// closes the http.Response Body. -func (client Client) CreateResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/delete.go deleted file mode 100644 index 078be57915af5..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/delete.go +++ /dev/null @@ -1,81 +0,0 @@ -package paths - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// Delete deletes a Data Lake Store Gen2 FileSystem within a Storage Account -func (client Client) Delete(ctx context.Context, accountName string, fileSystemName string, path string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("datalakestore.Client", "Delete", "`accountName` cannot be an empty string.") - } - if fileSystemName == "" { - return result, validation.NewError("datalakestore.Client", "Delete", "`fileSystemName` cannot be an empty string.") - } - - req, err := client.DeletePreparer(ctx, accountName, fileSystemName, path) - if err != nil { - err = autorest.NewErrorWithError(err, "datalakestore.Client", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "datalakestore.Client", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "datalakestore.Client", "Delete", resp, "Failure responding to request") - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client Client) DeletePreparer(ctx context.Context, accountName string, fileSystemName string, path string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "fileSystemName": autorest.Encode("path", fileSystemName), - "path": autorest.Encode("path", path), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(endpoints.GetDataLakeStoreEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{fileSystemName}/{path}", pathParameters), - autorest.WithHeaders(headers)) - - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client Client) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/properties_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/properties_get.go deleted file mode 100644 index 263dc53ed95ba..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/properties_get.go +++ /dev/null @@ -1,134 +0,0 @@ -package paths - -import ( - "context" - "net/http" - "time" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type GetPropertiesResponse struct { - autorest.Response - - ETag string - LastModified time.Time - // ResourceType is only returned for GetPropertiesActionGetStatus requests - ResourceType PathResource - Owner string - Group string - // ACL is only returned for GetPropertiesActionGetAccessControl requests - ACL string -} - -type GetPropertiesAction string - -const ( - GetPropertiesActionGetStatus GetPropertiesAction = "getStatus" - GetPropertiesActionGetAccessControl GetPropertiesAction = "getAccessControl" -) - -// GetProperties gets the properties for a Data Lake Store Gen2 Path in a FileSystem within a Storage Account -func (client Client) GetProperties(ctx context.Context, accountName string, fileSystemName string, path string, action GetPropertiesAction) (result GetPropertiesResponse, err error) { - if accountName == "" { - return result, validation.NewError("datalakestore.Client", "GetProperties", "`accountName` cannot be an empty string.") - } - if fileSystemName == "" { - return result, validation.NewError("datalakestore.Client", "GetProperties", "`fileSystemName` cannot be an empty string.") - } - - req, err := client.GetPropertiesPreparer(ctx, accountName, fileSystemName, path, action) - if err != nil { - err = autorest.NewErrorWithError(err, "datalakestore.Client", "GetProperties", nil, "Failure preparing request") - return - } - - resp, err := client.GetPropertiesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "datalakestore.Client", "GetProperties", resp, "Failure sending request") - return - } - - result, err = client.GetPropertiesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "datalakestore.Client", "GetProperties", resp, "Failure responding to request") - } - - return -} - -// GetPropertiesPreparer prepares the GetProperties request. -func (client Client) GetPropertiesPreparer(ctx context.Context, accountName string, fileSystemName string, path string, action GetPropertiesAction) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "fileSystemName": autorest.Encode("path", fileSystemName), - "path": autorest.Encode("path", path), - } - - queryParameters := map[string]interface{}{ - "action": autorest.Encode("query", string(action)), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsHead(), - autorest.WithBaseURL(endpoints.GetDataLakeStoreEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{fileSystemName}/{path}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetPropertiesSender sends the GetProperties request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetPropertiesSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetPropertiesResponder handles the response to the GetProperties request. The method always -// closes the http.Response Body. -func (client Client) GetPropertiesResponder(resp *http.Response) (result GetPropertiesResponse, err error) { - result = GetPropertiesResponse{} - if resp != nil && resp.Header != nil { - - resourceTypeRaw := resp.Header.Get("x-ms-resource-type") - var resourceType PathResource - if resourceTypeRaw != "" { - resourceType, err = parsePathResource(resourceTypeRaw) - if err != nil { - return GetPropertiesResponse{}, err - } - result.ResourceType = resourceType - } - result.ETag = resp.Header.Get("ETag") - - if lastModifiedRaw := resp.Header.Get("Last-Modified"); lastModifiedRaw != "" { - lastModified, err := time.Parse(time.RFC1123, lastModifiedRaw) - if err != nil { - return GetPropertiesResponse{}, err - } - result.LastModified = lastModified - } - - result.Owner = resp.Header.Get("x-ms-owner") - result.Group = resp.Header.Get("x-ms-group") - result.ACL = resp.Header.Get("x-ms-acl") - } - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return result, err -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/properties_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/properties_set.go deleted file mode 100644 index 7c0d677647d04..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/properties_set.go +++ /dev/null @@ -1,116 +0,0 @@ -package paths - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type SetAccessControlInput struct { - Owner *string - Group *string - ACL *string - - // Optional - A date and time value. - // Specify this header to perform the operation only if the resource has been modified since the specified date and time. - IfModifiedSince *string - - // Optional - A date and time value. - // Specify this header to perform the operation only if the resource has not been modified since the specified date and time. - IfUnmodifiedSince *string -} - -// SetProperties sets the access control properties for a Data Lake Store Gen2 Path within a Storage Account File System -func (client Client) SetAccessControl(ctx context.Context, accountName string, fileSystemName string, path string, input SetAccessControlInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("datalakestore.Client", "SetAccessControl", "`accountName` cannot be an empty string.") - } - if fileSystemName == "" { - return result, validation.NewError("datalakestore.Client", "SetAccessControl", "`fileSystemName` cannot be an empty string.") - } - - req, err := client.SetAccessControlPreparer(ctx, accountName, fileSystemName, path, input) - if err != nil { - err = autorest.NewErrorWithError(err, "datalakestore.Client", "SetAccessControl", nil, "Failure preparing request") - return - } - - resp, err := client.SetAccessControlSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "datalakestore.Client", "SetAccessControl", resp, "Failure sending request") - return - } - - result, err = client.SetAccessControlResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "datalakestore.Client", "SetAccessControl", resp, "Failure responding to request") - } - - return -} - -// SetAccessControlPreparer prepares the SetAccessControl request. -func (client Client) SetAccessControlPreparer(ctx context.Context, accountName string, fileSystemName string, path string, input SetAccessControlInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "fileSystemName": autorest.Encode("path", fileSystemName), - "path": autorest.Encode("path", path), - } - - queryParameters := map[string]interface{}{ - "action": autorest.Encode("query", "setAccessControl"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - if input.Owner != nil { - headers["x-ms-owner"] = *input.Owner - } - if input.Group != nil { - headers["x-ms-group"] = *input.Group - } - if input.ACL != nil { - headers["x-ms-acl"] = *input.ACL - } - - if input.IfModifiedSince != nil { - headers["If-Modified-Since"] = *input.IfModifiedSince - } - if input.IfUnmodifiedSince != nil { - headers["If-Unmodified-Since"] = *input.IfUnmodifiedSince - } - - preparer := autorest.CreatePreparer( - autorest.AsPatch(), - autorest.WithBaseURL(endpoints.GetDataLakeStoreEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{fileSystemName}/{path}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SetAccessControlSender sends the SetAccessControl request. The method will close the -// http.Response Body if it receives an error. -func (client Client) SetAccessControlSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// SetAccessControlResponder handles the response to the SetAccessControl request. The method always -// closes the http.Response Body. -func (client Client) SetAccessControlResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/resource_id.go deleted file mode 100644 index c328418770670..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/resource_id.go +++ /dev/null @@ -1,57 +0,0 @@ -package paths - -import ( - "fmt" - "net/url" - "strings" - - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// GetResourceID returns the Resource ID for the given Data Lake Storage FileSystem -// This can be useful when, for example, you're using this as a unique identifier -func (client Client) GetResourceID(accountName, fileSystemName, path string) string { - domain := endpoints.GetDataLakeStoreEndpoint(client.BaseURI, accountName) - return fmt.Sprintf("%s/%s/%s", domain, fileSystemName, path) -} - -type ResourceID struct { - AccountName string - FileSystemName string - Path string -} - -// ParseResourceID parses the specified Resource ID and returns an object -// which can be used to interact with the Data Lake Storage FileSystem API's -func ParseResourceID(id string) (*ResourceID, error) { - // example: https://foo.dfs.core.windows.net/Bar - if id == "" { - return nil, fmt.Errorf("`id` was empty") - } - - uri, err := url.Parse(id) - if err != nil { - return nil, fmt.Errorf("Error parsing ID as a URL: %s", err) - } - - accountName, err := endpoints.GetAccountNameFromEndpoint(uri.Host) - if err != nil { - return nil, fmt.Errorf("Error parsing Account Name: %s", err) - } - - fileSystemAndPath := strings.TrimPrefix(uri.Path, "/") - separatorIndex := strings.Index(fileSystemAndPath, "/") - var fileSystem, path string - if separatorIndex < 0 { - fileSystem = fileSystemAndPath - path = "" - } else { - fileSystem = fileSystemAndPath[0:separatorIndex] - path = fileSystemAndPath[separatorIndex+1:] - } - return &ResourceID{ - AccountName: *accountName, - FileSystemName: fileSystem, - Path: path, - }, nil -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/version.go deleted file mode 100644 index 3ca5674ec31ed..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/version.go +++ /dev/null @@ -1,14 +0,0 @@ -package paths - -import ( - "fmt" - - "github.com/tombuildsstuff/giovanni/version" -) - -// APIVersion is the version of the API used for all Storage API Operations -const APIVersion = "2020-08-04" - -func UserAgent() string { - return fmt.Sprintf("tombuildsstuff/giovanni/%s storage/%s", version.Number, APIVersion) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/README.md b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/README.md deleted file mode 100644 index 25474c8bc44d3..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/README.md +++ /dev/null @@ -1,48 +0,0 @@ -## File Storage Directories SDK for API version 2020-08-04 - -This package allows you to interact with the Directories File Storage API - -### Supported Authorizers - -* Azure Active Directory (for the Resource Endpoint `https://storage.azure.com`) -* SharedKeyLite (Blob, File & Queue) - -### Limitations - -* At this time the headers `x-ms-file-permission` and `x-ms-file-attributes` are hard-coded (to `inherit` and `None`, respectively). - -### Example Usage - -```go -package main - -import ( - "context" - "fmt" - "time" - - "github.com/Azure/go-autorest/autorest" - "github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories" -) - -func Example() error { - accountName := "storageaccount1" - storageAccountKey := "ABC123...." - shareName := "myshare" - directoryName := "myfiles" - - storageAuth := autorest.NewSharedKeyLiteAuthorizer(accountName, storageAccountKey) - directoriesClient := directories.New() - directoriesClient.Client.Authorizer = storageAuth - - ctx := context.TODO() - metadata := map[string]string{ - "hello": "world", - } - if _, err := directoriesClient.Create(ctx, accountName, shareName, directoryName, metadata); err != nil { - return fmt.Errorf("Error creating Directory: %s", err) - } - - return nil -} -``` \ No newline at end of file diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/api.go deleted file mode 100644 index 2699e668022d2..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/api.go +++ /dev/null @@ -1,16 +0,0 @@ -package directories - -import ( - "context" - - "github.com/Azure/go-autorest/autorest" -) - -type StorageDirectory interface { - Delete(ctx context.Context, accountName, shareName, path string) (result autorest.Response, err error) - GetMetaData(ctx context.Context, accountName, shareName, path string) (result GetMetaDataResult, err error) - SetMetaData(ctx context.Context, accountName, shareName, path string, metaData map[string]string) (result autorest.Response, err error) - Create(ctx context.Context, accountName, shareName, path string, input CreateDirectoryInput) (result autorest.Response, err error) - GetResourceID(accountName, shareName, directoryName string) string - Get(ctx context.Context, accountName, shareName, path string) (result GetResult, err error) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/client.go deleted file mode 100644 index bf2d315a524df..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/client.go +++ /dev/null @@ -1,25 +0,0 @@ -package directories - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Client is the base client for File Storage Shares. -type Client struct { - autorest.Client - BaseURI string -} - -// New creates an instance of the Client client. -func New() Client { - return NewWithEnvironment(azure.PublicCloud) -} - -// NewWithEnvironment creates an instance of the Client client. -func NewWithEnvironment(environment azure.Environment) Client { - return Client{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: environment.StorageEndpointSuffix, - } -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/create.go deleted file mode 100644 index 37298319be858..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/create.go +++ /dev/null @@ -1,131 +0,0 @@ -package directories - -import ( - "context" - "fmt" - "net/http" - "strings" - "time" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type CreateDirectoryInput struct { - // The time at which this file was created at - if omitted, this'll be set to "now" - // This maps to the `x-ms-file-creation-time` field. - // ... Yes I know it says File not Directory, I didn't design the API. - CreatedAt *time.Time - - // The time at which this file was last modified - if omitted, this'll be set to "now" - // This maps to the `x-ms-file-last-write-time` field. - // ... Yes I know it says File not Directory, I didn't design the API. - LastModified *time.Time - - // MetaData is a mapping of key value pairs which should be assigned to this directory - MetaData map[string]string -} - -// Create creates a new directory under the specified share or parent directory. -func (client Client) Create(ctx context.Context, accountName, shareName, path string, input CreateDirectoryInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("directories.Client", "Create", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("directories.Client", "Create", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("directories.Client", "Create", "`shareName` must be a lower-cased string.") - } - if path == "" { - return result, validation.NewError("directories.Client", "Create", "`path` cannot be an empty string.") - } - if err := metadata.Validate(input.MetaData); err != nil { - return result, validation.NewError("directories.Client", "Create", fmt.Sprintf("`metadata` is not valid: %s.", err)) - } - - req, err := client.CreatePreparer(ctx, accountName, shareName, path, input) - if err != nil { - err = autorest.NewErrorWithError(err, "directories.Client", "Create", nil, "Failure preparing request") - return - } - - resp, err := client.CreateSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "directories.Client", "Create", resp, "Failure sending request") - return - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "directories.Client", "Create", resp, "Failure responding to request") - return - } - - return -} - -// CreatePreparer prepares the Create request. -func (client Client) CreatePreparer(ctx context.Context, accountName, shareName, path string, input CreateDirectoryInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - "directory": autorest.Encode("path", path), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("query", "directory"), - } - - var coalesceDate = func(input *time.Time, defaultVal string) string { - if input == nil { - return defaultVal - } - - return input.Format(time.RFC1123) - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - - // ... Yes I know these say File not Directory, I didn't design the API. - "x-ms-file-permission": "inherit", // TODO: expose this in future - "x-ms-file-attributes": "None", // TODO: expose this in future - "x-ms-file-creation-time": coalesceDate(input.CreatedAt, "now"), - "x-ms-file-last-write-time": coalesceDate(input.LastModified, "now"), - } - - headers = metadata.SetIntoHeaders(headers, input.MetaData) - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}/{directory}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateSender sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (client Client) CreateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CreateResponder handles the response to the Create request. The method always -// closes the http.Response Body. -func (client Client) CreateResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/delete.go deleted file mode 100644 index 9443c25929834..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/delete.go +++ /dev/null @@ -1,95 +0,0 @@ -package directories - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// Delete removes the specified empty directory -// Note that the directory must be empty before it can be deleted. -func (client Client) Delete(ctx context.Context, accountName, shareName, path string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("directories.Client", "Delete", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("directories.Client", "Delete", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("directories.Client", "Delete", "`shareName` must be a lower-cased string.") - } - if path == "" { - return result, validation.NewError("directories.Client", "Delete", "`path` cannot be an empty string.") - } - - req, err := client.DeletePreparer(ctx, accountName, shareName, path) - if err != nil { - err = autorest.NewErrorWithError(err, "directories.Client", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "directories.Client", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "directories.Client", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client Client) DeletePreparer(ctx context.Context, accountName, shareName, path string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - "directory": autorest.Encode("path", path), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("query", "directory"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}/{directory}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client Client) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/get.go deleted file mode 100644 index 817d680b3fca1..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/get.go +++ /dev/null @@ -1,112 +0,0 @@ -package directories - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type GetResult struct { - autorest.Response - - // A set of name-value pairs that contain metadata for the directory. - MetaData map[string]string - - // The value of this header is set to true if the directory metadata is completely - // encrypted using the specified algorithm. Otherwise, the value is set to false. - DirectoryMetaDataEncrypted bool -} - -// Get returns all system properties for the specified directory, -// and can also be used to check the existence of a directory. -func (client Client) Get(ctx context.Context, accountName, shareName, path string) (result GetResult, err error) { - if accountName == "" { - return result, validation.NewError("directories.Client", "Get", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("directories.Client", "Get", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("directories.Client", "Get", "`shareName` must be a lower-cased string.") - } - if path == "" { - return result, validation.NewError("directories.Client", "Get", "`path` cannot be an empty string.") - } - - req, err := client.GetPreparer(ctx, accountName, shareName, path) - if err != nil { - err = autorest.NewErrorWithError(err, "directories.Client", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "directories.Client", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "directories.Client", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client Client) GetPreparer(ctx context.Context, accountName, shareName, path string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - "directory": autorest.Encode("path", path), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("query", "directory"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}/{directory}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client Client) GetResponder(resp *http.Response) (result GetResult, err error) { - if resp != nil && resp.Header != nil { - result.MetaData = metadata.ParseFromHeaders(resp.Header) - result.DirectoryMetaDataEncrypted = strings.EqualFold(resp.Header.Get("x-ms-server-encrypted"), "true") - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/metadata_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/metadata_get.go deleted file mode 100644 index 173716de7400d..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/metadata_get.go +++ /dev/null @@ -1,106 +0,0 @@ -package directories - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type GetMetaDataResult struct { - autorest.Response - - MetaData map[string]string -} - -// GetMetaData returns all user-defined metadata for the specified directory -func (client Client) GetMetaData(ctx context.Context, accountName, shareName, path string) (result GetMetaDataResult, err error) { - if accountName == "" { - return result, validation.NewError("directories.Client", "GetMetaData", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("directories.Client", "GetMetaData", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("directories.Client", "GetMetaData", "`shareName` must be a lower-cased string.") - } - if path == "" { - return result, validation.NewError("directories.Client", "GetMetaData", "`path` cannot be an empty string.") - } - - req, err := client.GetMetaDataPreparer(ctx, accountName, shareName, path) - if err != nil { - err = autorest.NewErrorWithError(err, "directories.Client", "GetMetaData", nil, "Failure preparing request") - return - } - - resp, err := client.GetMetaDataSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "directories.Client", "GetMetaData", resp, "Failure sending request") - return - } - - result, err = client.GetMetaDataResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "directories.Client", "GetMetaData", resp, "Failure responding to request") - return - } - - return -} - -// GetMetaDataPreparer prepares the GetMetaData request. -func (client Client) GetMetaDataPreparer(ctx context.Context, accountName, shareName, path string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - "directory": autorest.Encode("path", path), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("query", "directory"), - "comp": autorest.Encode("query", "metadata"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}/{directory}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetMetaDataSender sends the GetMetaData request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetMetaDataSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetMetaDataResponder handles the response to the GetMetaData request. The method always -// closes the http.Response Body. -func (client Client) GetMetaDataResponder(resp *http.Response) (result GetMetaDataResult, err error) { - if resp != nil && resp.Header != nil { - result.MetaData = metadata.ParseFromHeaders(resp.Header) - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/metadata_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/metadata_set.go deleted file mode 100644 index cb133127da009..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/metadata_set.go +++ /dev/null @@ -1,102 +0,0 @@ -package directories - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -// SetMetaData updates user defined metadata for the specified directory -func (client Client) SetMetaData(ctx context.Context, accountName, shareName, path string, metaData map[string]string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("directories.Client", "SetMetaData", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("directories.Client", "SetMetaData", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("directories.Client", "SetMetaData", "`shareName` must be a lower-cased string.") - } - if path == "" { - return result, validation.NewError("directories.Client", "SetMetaData", "`path` cannot be an empty string.") - } - if err := metadata.Validate(metaData); err != nil { - return result, validation.NewError("directories.Client", "SetMetaData", fmt.Sprintf("`metaData` is not valid: %s.", err)) - } - - req, err := client.SetMetaDataPreparer(ctx, accountName, shareName, path, metaData) - if err != nil { - err = autorest.NewErrorWithError(err, "directories.Client", "SetMetaData", nil, "Failure preparing request") - return - } - - resp, err := client.SetMetaDataSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "directories.Client", "SetMetaData", resp, "Failure sending request") - return - } - - result, err = client.SetMetaDataResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "directories.Client", "SetMetaData", resp, "Failure responding to request") - return - } - - return -} - -// SetMetaDataPreparer prepares the SetMetaData request. -func (client Client) SetMetaDataPreparer(ctx context.Context, accountName, shareName, path string, metaData map[string]string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - "directory": autorest.Encode("path", path), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("query", "directory"), - "comp": autorest.Encode("query", "metadata"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - headers = metadata.SetIntoHeaders(headers, metaData) - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}/{directory}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SetMetaDataSender sends the SetMetaData request. The method will close the -// http.Response Body if it receives an error. -func (client Client) SetMetaDataSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// SetMetaDataResponder handles the response to the SetMetaData request. The method always -// closes the http.Response Body. -func (client Client) SetMetaDataResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/resource_id.go deleted file mode 100644 index 712ed3a00c397..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/resource_id.go +++ /dev/null @@ -1,56 +0,0 @@ -package directories - -import ( - "fmt" - "net/url" - "strings" - - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// GetResourceID returns the Resource ID for the given Directory -// This can be useful when, for example, you're using this as a unique identifier -func (client Client) GetResourceID(accountName, shareName, directoryName string) string { - domain := endpoints.GetFileEndpoint(client.BaseURI, accountName) - return fmt.Sprintf("%s/%s/%s", domain, shareName, directoryName) -} - -type ResourceID struct { - AccountName string - DirectoryName string - ShareName string -} - -// ParseResourceID parses the Resource ID into an Object -// which can be used to interact with the Directory within the File Share -func ParseResourceID(id string) (*ResourceID, error) { - // example: https://foo.file.core.windows.net/Bar/Folder - if id == "" { - return nil, fmt.Errorf("`id` was empty") - } - - uri, err := url.Parse(id) - if err != nil { - return nil, fmt.Errorf("Error parsing ID as a URL: %s", err) - } - - accountName, err := endpoints.GetAccountNameFromEndpoint(uri.Host) - if err != nil { - return nil, fmt.Errorf("Error parsing Account Name: %s", err) - } - - path := strings.TrimPrefix(uri.Path, "/") - segments := strings.Split(path, "/") - if len(segments) == 0 { - return nil, fmt.Errorf("Expected the path to contain segments but got none") - } - - shareName := segments[0] - directoryName := strings.TrimPrefix(path, shareName) - directoryName = strings.TrimPrefix(directoryName, "/") - return &ResourceID{ - AccountName: *accountName, - ShareName: shareName, - DirectoryName: directoryName, - }, nil -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/version.go deleted file mode 100644 index 8446be29ebb20..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories/version.go +++ /dev/null @@ -1,14 +0,0 @@ -package directories - -import ( - "fmt" - - "github.com/tombuildsstuff/giovanni/version" -) - -// APIVersion is the version of the API used for all Storage API Operations -const APIVersion = "2020-08-04" - -func UserAgent() string { - return fmt.Sprintf("tombuildsstuff/giovanni/%s storage/%s", version.Number, APIVersion) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/api.go deleted file mode 100644 index 96a0491e70da0..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/api.go +++ /dev/null @@ -1,28 +0,0 @@ -package files - -import ( - "context" - "os" - "time" - - "github.com/Azure/go-autorest/autorest" -) - -type StorageFile interface { - PutByteRange(ctx context.Context, accountName, shareName, path, fileName string, input PutByteRangeInput) (result autorest.Response, err error) - GetByteRange(ctx context.Context, accountName, shareName, path, fileName string, input GetByteRangeInput) (result GetByteRangeResult, err error) - ClearByteRange(ctx context.Context, accountName, shareName, path, fileName string, input ClearByteRangeInput) (result autorest.Response, err error) - SetProperties(ctx context.Context, accountName, shareName, path, fileName string, input SetPropertiesInput) (result autorest.Response, err error) - PutFile(ctx context.Context, accountName, shareName, path, fileName string, file *os.File, parallelism int) error - Copy(ctx context.Context, accountName, shareName, path, fileName string, input CopyInput) (result CopyResult, err error) - SetMetaData(ctx context.Context, accountName, shareName, path, fileName string, metaData map[string]string) (result autorest.Response, err error) - GetMetaData(ctx context.Context, accountName, shareName, path, fileName string) (result GetMetaDataResult, err error) - AbortCopy(ctx context.Context, accountName, shareName, path, fileName, copyID string) (result autorest.Response, err error) - GetFile(ctx context.Context, accountName, shareName, path, fileName string, parallelism int) (result autorest.Response, outputBytes []byte, err error) - GetResourceID(accountName, shareName, directoryName, filePath string) string - ListRanges(ctx context.Context, accountName, shareName, path, fileName string) (result ListRangesResult, err error) - GetProperties(ctx context.Context, accountName, shareName, path, fileName string) (result GetResult, err error) - Delete(ctx context.Context, accountName, shareName, path, fileName string) (result autorest.Response, err error) - Create(ctx context.Context, accountName, shareName, path, fileName string, input CreateInput) (result autorest.Response, err error) - CopyAndWait(ctx context.Context, accountName, shareName, path, fileName string, input CopyInput, pollDuration time.Duration) (result CopyResult, err error) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/client.go deleted file mode 100644 index ecca81586b5a7..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/client.go +++ /dev/null @@ -1,25 +0,0 @@ -package files - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Client is the base client for File Storage Shares. -type Client struct { - autorest.Client - BaseURI string -} - -// New creates an instance of the Client client. -func New() Client { - return NewWithEnvironment(azure.PublicCloud) -} - -// NewWithEnvironment creates an instance of the Client client. -func NewWithEnvironment(environment azure.Environment) Client { - return Client{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: environment.StorageEndpointSuffix, - } -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/copy.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/copy.go deleted file mode 100644 index 31768b3d52b7f..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/copy.go +++ /dev/null @@ -1,132 +0,0 @@ -package files - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type CopyInput struct { - // 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 account, then you must authenticate the source file or blob using a - // shared access signature. If the source is a public blob, no authentication is required to perform the copy - // operation. A file in a share snapshot can also be specified as a copy source. - CopySource string - - MetaData map[string]string -} - -type CopyResult struct { - autorest.Response - - // The CopyID, which can be passed to AbortCopy to abort the copy. - CopyID string - - // Either `success` or `pending` - CopySuccess string -} - -// Copy copies a blob or file to a destination file within the storage account asynchronously. -func (client Client) Copy(ctx context.Context, accountName, shareName, path, fileName string, input CopyInput) (result CopyResult, err error) { - if accountName == "" { - return result, validation.NewError("files.Client", "Copy", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("files.Client", "Copy", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("files.Client", "Copy", "`shareName` must be a lower-cased string.") - } - if fileName == "" { - return result, validation.NewError("files.Client", "Copy", "`fileName` cannot be an empty string.") - } - if input.CopySource == "" { - return result, validation.NewError("files.Client", "Copy", "`input.CopySource` cannot be an empty string.") - } - if err := metadata.Validate(input.MetaData); err != nil { - return result, validation.NewError("files.Client", "Copy", fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) - } - - req, err := client.CopyPreparer(ctx, accountName, shareName, path, fileName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "Copy", nil, "Failure preparing request") - return - } - - resp, err := client.CopySender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "files.Client", "Copy", resp, "Failure sending request") - return - } - - result, err = client.CopyResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "Copy", resp, "Failure responding to request") - return - } - - return -} - -// CopyPreparer prepares the Copy request. -func (client Client) CopyPreparer(ctx context.Context, accountName, shareName, path, fileName string, input CopyInput) (*http.Request, error) { - if path != "" { - path = fmt.Sprintf("%s/", path) - } - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - "directory": autorest.Encode("path", path), - "fileName": autorest.Encode("path", fileName), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-copy-source": input.CopySource, - } - - headers = metadata.SetIntoHeaders(headers, input.MetaData) - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}/{directory}{fileName}", pathParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CopySender sends the Copy request. The method will close the -// http.Response Body if it receives an error. -func (client Client) CopySender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CopyResponder handles the response to the Copy request. The method always -// closes the http.Response Body. -func (client Client) CopyResponder(resp *http.Response) (result CopyResult, err error) { - if resp != nil && resp.Header != nil { - result.CopyID = resp.Header.Get("x-ms-copy-id") - result.CopySuccess = resp.Header.Get("x-ms-copy-status") - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/copy_abort.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/copy_abort.go deleted file mode 100644 index 2f0913185888b..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/copy_abort.go +++ /dev/null @@ -1,104 +0,0 @@ -package files - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// AbortCopy aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata -func (client Client) AbortCopy(ctx context.Context, accountName, shareName, path, fileName, copyID string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("files.Client", "AbortCopy", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("files.Client", "AbortCopy", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("files.Client", "AbortCopy", "`shareName` must be a lower-cased string.") - } - if fileName == "" { - return result, validation.NewError("files.Client", "AbortCopy", "`fileName` cannot be an empty string.") - } - if copyID == "" { - return result, validation.NewError("files.Client", "AbortCopy", "`copyID` cannot be an empty string.") - } - - req, err := client.AbortCopyPreparer(ctx, accountName, shareName, path, fileName, copyID) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "AbortCopy", nil, "Failure preparing request") - return - } - - resp, err := client.AbortCopySender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "files.Client", "AbortCopy", resp, "Failure sending request") - return - } - - result, err = client.AbortCopyResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "AbortCopy", resp, "Failure responding to request") - return - } - - return -} - -// AbortCopyPreparer prepares the AbortCopy request. -func (client Client) AbortCopyPreparer(ctx context.Context, accountName, shareName, path, fileName, copyID string) (*http.Request, error) { - if path != "" { - path = fmt.Sprintf("%s/", path) - } - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - "directory": autorest.Encode("path", path), - "fileName": autorest.Encode("path", fileName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "copy"), - "copyid": autorest.Encode("query", copyID), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-copy-action": "abort", - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}/{directory}{fileName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// AbortCopySender sends the AbortCopy request. The method will close the -// http.Response Body if it receives an error. -func (client Client) AbortCopySender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// AbortCopyResponder handles the response to the AbortCopy request. The method always -// closes the http.Response Body. -func (client Client) AbortCopyResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/copy_wait.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/copy_wait.go deleted file mode 100644 index e6a646b1017be..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/copy_wait.go +++ /dev/null @@ -1,55 +0,0 @@ -package files - -import ( - "context" - "fmt" - "strings" - "time" - - "github.com/Azure/go-autorest/autorest" -) - -type CopyAndWaitResult struct { - autorest.Response - - CopyID string -} - -const DefaultCopyPollDuration = 15 * time.Second - -// CopyAndWait is a convenience method which doesn't exist in the API, which copies the file and then waits for the copy to complete -func (client Client) CopyAndWait(ctx context.Context, accountName, shareName, path, fileName string, input CopyInput, pollDuration time.Duration) (result CopyResult, err error) { - copy, e := client.Copy(ctx, accountName, shareName, path, fileName, input) - if err != nil { - result.Response = copy.Response - err = fmt.Errorf("Error copying: %s", e) - return - } - - result.CopyID = copy.CopyID - - // since the API doesn't return a LRO, this is a hack which also polls every 10s, but should be sufficient - for true { - props, e := client.GetProperties(ctx, accountName, shareName, path, fileName) - if e != nil { - result.Response = copy.Response - err = fmt.Errorf("Error waiting for copy: %s", e) - return - } - - switch strings.ToLower(props.CopyStatus) { - case "pending": - time.Sleep(pollDuration) - continue - - case "success": - return - - default: - err = fmt.Errorf("Unexpected CopyState %q", e) - return - } - } - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/create.go deleted file mode 100644 index d2b4ff358120e..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/create.go +++ /dev/null @@ -1,169 +0,0 @@ -package files - -import ( - "context" - "fmt" - "net/http" - "strings" - "time" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type CreateInput struct { - // This header specifies the maximum size for the file, up to 1 TiB. - ContentLength int64 - - // The MIME content type of the file - // If not specified, the default type is application/octet-stream. - ContentType *string - - // Specifies which content encodings have been applied to the file. - // This value is returned to the client when the Get File operation is performed - // on the file resource and can be used to decode file content. - ContentEncoding *string - - // Specifies the natural languages used by this resource. - ContentLanguage *string - - // The File service stores this value but does not use or modify it. - CacheControl *string - - // Sets the file's MD5 hash. - ContentMD5 *string - - // Sets the file’s Content-Disposition header. - ContentDisposition *string - - // The time at which this file was created at - if omitted, this'll be set to "now" - // This maps to the `x-ms-file-creation-time` field. - CreatedAt *time.Time - - // The time at which this file was last modified - if omitted, this'll be set to "now" - // This maps to the `x-ms-file-last-write-time` field. - LastModified *time.Time - - // MetaData is a mapping of key value pairs which should be assigned to this file - MetaData map[string]string -} - -// Create creates a new file or replaces a file. -func (client Client) Create(ctx context.Context, accountName, shareName, path, fileName string, input CreateInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("files.Client", "Create", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("files.Client", "Create", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("files.Client", "Create", "`shareName` must be a lower-cased string.") - } - if fileName == "" { - return result, validation.NewError("files.Client", "Create", "`fileName` cannot be an empty string.") - } - if err := metadata.Validate(input.MetaData); err != nil { - return result, validation.NewError("files.Client", "Create", "`input.MetaData` cannot be an empty string.") - } - - req, err := client.CreatePreparer(ctx, accountName, shareName, path, fileName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "Create", nil, "Failure preparing request") - return - } - - resp, err := client.CreateSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "files.Client", "Create", resp, "Failure sending request") - return - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "Create", resp, "Failure responding to request") - return - } - - return -} - -// CreatePreparer prepares the Create request. -func (client Client) CreatePreparer(ctx context.Context, accountName, shareName, path, fileName string, input CreateInput) (*http.Request, error) { - if path != "" { - path = fmt.Sprintf("%s/", path) - } - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - "directory": autorest.Encode("path", path), - "fileName": autorest.Encode("path", fileName), - } - - var coalesceDate = func(input *time.Time, defaultVal string) string { - if input == nil { - return defaultVal - } - - return input.Format(time.RFC1123) - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-content-length": input.ContentLength, - "x-ms-type": "file", - - "x-ms-file-permission": "inherit", // TODO: expose this in future - "x-ms-file-attributes": "None", // TODO: expose this in future - "x-ms-file-creation-time": coalesceDate(input.CreatedAt, "now"), - "x-ms-file-last-write-time": coalesceDate(input.LastModified, "now"), - } - - if input.ContentDisposition != nil { - headers["x-ms-content-disposition"] = *input.ContentDisposition - } - - if input.ContentEncoding != nil { - headers["x-ms-content-encoding"] = *input.ContentEncoding - } - - if input.ContentMD5 != nil { - headers["x-ms-content-md5"] = *input.ContentMD5 - } - - if input.ContentType != nil { - headers["x-ms-content-type"] = *input.ContentType - } - - headers = metadata.SetIntoHeaders(headers, input.MetaData) - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}/{directory}{fileName}", pathParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateSender sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (client Client) CreateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CreateResponder handles the response to the Create request. The method always -// closes the http.Response Body. -func (client Client) CreateResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/delete.go deleted file mode 100644 index 5debd767d1fdb..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/delete.go +++ /dev/null @@ -1,94 +0,0 @@ -package files - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// Delete immediately deletes the file from the File Share. -func (client Client) Delete(ctx context.Context, accountName, shareName, path, fileName string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("files.Client", "Delete", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("files.Client", "Delete", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("files.Client", "Delete", "`shareName` must be a lower-cased string.") - } - if fileName == "" { - return result, validation.NewError("files.Client", "Delete", "`fileName` cannot be an empty string.") - } - - req, err := client.DeletePreparer(ctx, accountName, shareName, path, fileName) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "files.Client", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client Client) DeletePreparer(ctx context.Context, accountName, shareName, path, fileName string) (*http.Request, error) { - if path != "" { - path = fmt.Sprintf("%s/", path) - } - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - "directory": autorest.Encode("path", path), - "fileName": autorest.Encode("path", fileName), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}/{directory}{fileName}", pathParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client Client) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/metadata_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/metadata_get.go deleted file mode 100644 index fd62f90aec8fc..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/metadata_get.go +++ /dev/null @@ -1,111 +0,0 @@ -package files - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type GetMetaDataResult struct { - autorest.Response - - MetaData map[string]string -} - -// GetMetaData returns the MetaData for the specified File. -func (client Client) GetMetaData(ctx context.Context, accountName, shareName, path, fileName string) (result GetMetaDataResult, err error) { - if accountName == "" { - return result, validation.NewError("files.Client", "GetMetaData", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("files.Client", "GetMetaData", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("files.Client", "GetMetaData", "`shareName` must be a lower-cased string.") - } - if fileName == "" { - return result, validation.NewError("files.Client", "GetMetaData", "`fileName` cannot be an empty string.") - } - - req, err := client.GetMetaDataPreparer(ctx, accountName, shareName, path, fileName) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "GetMetaData", nil, "Failure preparing request") - return - } - - resp, err := client.GetMetaDataSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "files.Client", "GetMetaData", resp, "Failure sending request") - return - } - - result, err = client.GetMetaDataResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "GetMetaData", resp, "Failure responding to request") - return - } - - return -} - -// GetMetaDataPreparer prepares the GetMetaData request. -func (client Client) GetMetaDataPreparer(ctx context.Context, accountName, shareName, path, fileName string) (*http.Request, error) { - if path != "" { - path = fmt.Sprintf("%s/", path) - } - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - "directory": autorest.Encode("path", path), - "fileName": autorest.Encode("path", fileName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "metadata"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}/{directory}{fileName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetMetaDataSender sends the GetMetaData request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetMetaDataSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetMetaDataResponder handles the response to the GetMetaData request. The method always -// closes the http.Response Body. -func (client Client) GetMetaDataResponder(resp *http.Response) (result GetMetaDataResult, err error) { - if resp != nil && resp.Header != nil { - result.MetaData = metadata.ParseFromHeaders(resp.Header) - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - //metadata.ByParsingFromHeaders(&result.MetaData), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/metadata_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/metadata_set.go deleted file mode 100644 index 41e3ffcb8ff9c..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/metadata_set.go +++ /dev/null @@ -1,105 +0,0 @@ -package files - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -// SetMetaData updates the specified File to have the specified MetaData. -func (client Client) SetMetaData(ctx context.Context, accountName, shareName, path, fileName string, metaData map[string]string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("files.Client", "SetMetaData", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("files.Client", "SetMetaData", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("files.Client", "SetMetaData", "`shareName` must be a lower-cased string.") - } - if fileName == "" { - return result, validation.NewError("files.Client", "SetMetaData", "`fileName` cannot be an empty string.") - } - if err := metadata.Validate(metaData); err != nil { - return result, validation.NewError("files.Client", "SetMetaData", fmt.Sprintf("`metaData` is not valid: %s.", err)) - } - - req, err := client.SetMetaDataPreparer(ctx, accountName, shareName, path, fileName, metaData) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "SetMetaData", nil, "Failure preparing request") - return - } - - resp, err := client.SetMetaDataSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "files.Client", "SetMetaData", resp, "Failure sending request") - return - } - - result, err = client.SetMetaDataResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "SetMetaData", resp, "Failure responding to request") - return - } - - return -} - -// SetMetaDataPreparer prepares the SetMetaData request. -func (client Client) SetMetaDataPreparer(ctx context.Context, accountName, shareName, path, fileName string, metaData map[string]string) (*http.Request, error) { - if path != "" { - path = fmt.Sprintf("%s/", path) - } - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - "directory": autorest.Encode("path", path), - "fileName": autorest.Encode("path", fileName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "metadata"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - headers = metadata.SetIntoHeaders(headers, metaData) - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}/{directory}{fileName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SetMetaDataSender sends the SetMetaData request. The method will close the -// http.Response Body if it receives an error. -func (client Client) SetMetaDataSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// SetMetaDataResponder handles the response to the SetMetaData request. The method always -// closes the http.Response Body. -func (client Client) SetMetaDataResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/properties_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/properties_get.go deleted file mode 100644 index 0300b1ce5ec67..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/properties_get.go +++ /dev/null @@ -1,144 +0,0 @@ -package files - -import ( - "context" - "fmt" - "net/http" - "strconv" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type GetResult struct { - autorest.Response - - CacheControl string - ContentDisposition string - ContentEncoding string - ContentLanguage string - ContentLength *int64 - ContentMD5 string - ContentType string - CopyID string - CopyStatus string - CopySource string - CopyProgress string - CopyStatusDescription string - CopyCompletionTime string - Encrypted bool - - MetaData map[string]string -} - -// GetProperties returns the Properties for the specified file -func (client Client) GetProperties(ctx context.Context, accountName, shareName, path, fileName string) (result GetResult, err error) { - if accountName == "" { - return result, validation.NewError("files.Client", "GetProperties", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("files.Client", "GetProperties", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("files.Client", "GetProperties", "`shareName` must be a lower-cased string.") - } - if fileName == "" { - return result, validation.NewError("files.Client", "GetProperties", "`fileName` cannot be an empty string.") - } - - req, err := client.GetPropertiesPreparer(ctx, accountName, shareName, path, fileName) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "GetProperties", nil, "Failure preparing request") - return - } - - resp, err := client.GetPropertiesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "files.Client", "GetProperties", resp, "Failure sending request") - return - } - - result, err = client.GetPropertiesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "GetProperties", resp, "Failure responding to request") - return - } - - return -} - -// GetPropertiesPreparer prepares the GetProperties request. -func (client Client) GetPropertiesPreparer(ctx context.Context, accountName, shareName, path, fileName string) (*http.Request, error) { - if path != "" { - path = fmt.Sprintf("%s/", path) - } - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - "directory": autorest.Encode("path", path), - "fileName": autorest.Encode("path", fileName), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsHead(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}/{directory}{fileName}", pathParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetPropertiesSender sends the GetProperties request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetPropertiesSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetPropertiesResponder handles the response to the GetProperties request. The method always -// closes the http.Response Body. -func (client Client) GetPropertiesResponder(resp *http.Response) (result GetResult, err error) { - if resp != nil && resp.Header != nil { - result.CacheControl = resp.Header.Get("Cache-Control") - result.ContentDisposition = resp.Header.Get("Content-Disposition") - result.ContentEncoding = resp.Header.Get("Content-Encoding") - result.ContentLanguage = resp.Header.Get("Content-Language") - result.ContentMD5 = resp.Header.Get("Content-MD5") - result.ContentType = resp.Header.Get("Content-Type") - result.CopyID = resp.Header.Get("x-ms-copy-id") - result.CopyProgress = resp.Header.Get("x-ms-copy-progress") - result.CopySource = resp.Header.Get("x-ms-copy-source") - result.CopyStatus = resp.Header.Get("x-ms-copy-status") - result.CopyStatusDescription = resp.Header.Get("x-ms-copy-status-description") - result.CopyCompletionTime = resp.Header.Get("x-ms-copy-completion-time") - result.Encrypted = strings.EqualFold(resp.Header.Get("x-ms-server-encrypted"), "true") - result.MetaData = metadata.ParseFromHeaders(resp.Header) - - contentLengthRaw := resp.Header.Get("Content-Length") - if contentLengthRaw != "" { - contentLength, err := strconv.Atoi(contentLengthRaw) - if err != nil { - return result, fmt.Errorf("Error parsing %q for Content-Length as an integer: %s", contentLengthRaw, err) - } - contentLengthI64 := int64(contentLength) - result.ContentLength = &contentLengthI64 - } - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/properties_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/properties_set.go deleted file mode 100644 index 521b1bba7be70..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/properties_set.go +++ /dev/null @@ -1,186 +0,0 @@ -package files - -import ( - "context" - "fmt" - "net/http" - "strings" - "time" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type SetPropertiesInput struct { - // 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. - ContentLength int64 - - // Modifies the cache control string for the file. - // If this property is not specified on the request, then the property will be cleared for the file. - // Subsequent calls to Get File Properties will not return this property, - // unless it is explicitly set on the file again. - ContentControl *string - - // Sets the file’s Content-Disposition header. - // If this property is not specified on the request, then the property will be cleared for the file. - // Subsequent calls to Get File Properties will not return this property, - // unless it is explicitly set on the file again. - ContentDisposition *string - - // Sets the file's content encoding. - // If this property is not specified on the request, then the property will be cleared for the file. - // Subsequent calls to Get File Properties will not return this property, - // unless it is explicitly set on the file again. - ContentEncoding *string - - // Sets the file's content language. - // If this property is not specified on the request, then the property will be cleared for the file. - // Subsequent calls to Get File Properties will not return this property, - // unless it is explicitly set on the file again. - ContentLanguage *string - - // Sets the file's MD5 hash. - // If this property is not specified on the request, then the property will be cleared for the file. - // Subsequent calls to Get File Properties will not return this property, - // unless it is explicitly set on the file again. - ContentMD5 *string - - // Sets the file's content type. - // If this property is not specified on the request, then the property will be cleared for the file. - // Subsequent calls to Get File Properties will not return this property, - // unless it is explicitly set on the file again. - ContentType *string - - // The time at which this file was created at - if omitted, this'll be set to "now" - // This maps to the `x-ms-file-creation-time` field. - CreatedAt *time.Time - - // The time at which this file was last modified - if omitted, this'll be set to "now" - // This maps to the `x-ms-file-last-write-time` field. - LastModified *time.Time - - // MetaData is a mapping of key value pairs which should be assigned to this file - MetaData map[string]string -} - -// SetProperties sets the specified properties on the specified File -func (client Client) SetProperties(ctx context.Context, accountName, shareName, path, fileName string, input SetPropertiesInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("files.Client", "SetProperties", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("files.Client", "SetProperties", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("files.Client", "SetProperties", "`shareName` must be a lower-cased string.") - } - if fileName == "" { - return result, validation.NewError("files.Client", "SetProperties", "`fileName` cannot be an empty string.") - } - - req, err := client.SetPropertiesPreparer(ctx, accountName, shareName, path, fileName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "SetProperties", nil, "Failure preparing request") - return - } - - resp, err := client.SetPropertiesSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "files.Client", "SetProperties", resp, "Failure sending request") - return - } - - result, err = client.SetPropertiesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "SetProperties", resp, "Failure responding to request") - return - } - - return -} - -// SetPropertiesPreparer prepares the SetProperties request. -func (client Client) SetPropertiesPreparer(ctx context.Context, accountName, shareName, path, fileName string, input SetPropertiesInput) (*http.Request, error) { - if path != "" { - path = fmt.Sprintf("%s/", path) - } - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - "directory": autorest.Encode("path", path), - "fileName": autorest.Encode("path", fileName), - } - - var coalesceDate = func(input *time.Time, defaultVal string) string { - if input == nil { - return defaultVal - } - - return input.Format(time.RFC1123) - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-type": "file", - - "x-ms-content-length": input.ContentLength, - "x-ms-file-permission": "inherit", // TODO: expose this in future - "x-ms-file-attributes": "None", // TODO: expose this in future - "x-ms-file-creation-time": coalesceDate(input.CreatedAt, "now"), - "x-ms-file-last-write-time": coalesceDate(input.LastModified, "now"), - } - - if input.ContentControl != nil { - headers["x-ms-cache-control"] = *input.ContentControl - } - if input.ContentDisposition != nil { - headers["x-ms-content-disposition"] = *input.ContentDisposition - } - if input.ContentEncoding != nil { - headers["x-ms-content-encoding"] = *input.ContentEncoding - } - if input.ContentLanguage != nil { - headers["x-ms-content-language"] = *input.ContentLanguage - } - if input.ContentMD5 != nil { - headers["x-ms-content-md5"] = *input.ContentMD5 - } - if input.ContentType != nil { - headers["x-ms-content-type"] = *input.ContentType - } - - headers = metadata.SetIntoHeaders(headers, input.MetaData) - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}/{directory}{fileName}", pathParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SetPropertiesSender sends the SetProperties request. The method will close the -// http.Response Body if it receives an error. -func (client Client) SetPropertiesSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// SetPropertiesResponder handles the response to the SetProperties request. The method always -// closes the http.Response Body. -func (client Client) SetPropertiesResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/range_clear.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/range_clear.go deleted file mode 100644 index 5d8145fae4229..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/range_clear.go +++ /dev/null @@ -1,112 +0,0 @@ -package files - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type ClearByteRangeInput struct { - StartBytes int64 - EndBytes int64 -} - -// ClearByteRange clears the specified Byte Range from within the specified File -func (client Client) ClearByteRange(ctx context.Context, accountName, shareName, path, fileName string, input ClearByteRangeInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("files.Client", "ClearByteRange", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("files.Client", "ClearByteRange", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("files.Client", "ClearByteRange", "`shareName` must be a lower-cased string.") - } - if fileName == "" { - return result, validation.NewError("files.Client", "ClearByteRange", "`fileName` cannot be an empty string.") - } - if input.StartBytes < 0 { - return result, validation.NewError("files.Client", "ClearByteRange", "`input.StartBytes` must be greater or equal to 0.") - } - if input.EndBytes <= 0 { - return result, validation.NewError("files.Client", "ClearByteRange", "`input.EndBytes` must be greater than 0.") - } - - req, err := client.ClearByteRangePreparer(ctx, accountName, shareName, path, fileName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "ClearByteRange", nil, "Failure preparing request") - return - } - - resp, err := client.ClearByteRangeSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "files.Client", "ClearByteRange", resp, "Failure sending request") - return - } - - result, err = client.ClearByteRangeResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "ClearByteRange", resp, "Failure responding to request") - return - } - - return -} - -// ClearByteRangePreparer prepares the ClearByteRange request. -func (client Client) ClearByteRangePreparer(ctx context.Context, accountName, shareName, path, fileName string, input ClearByteRangeInput) (*http.Request, error) { - if path != "" { - path = fmt.Sprintf("%s/", path) - } - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - "directory": autorest.Encode("path", path), - "fileName": autorest.Encode("path", fileName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "range"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-write": "clear", - "x-ms-range": fmt.Sprintf("bytes=%d-%d", input.StartBytes, input.EndBytes), - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}/{directory}{fileName}", pathParameters), - autorest.WithHeaders(headers), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ClearByteRangeSender sends the ClearByteRange request. The method will close the -// http.Response Body if it receives an error. -func (client Client) ClearByteRangeSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ClearByteRangeResponder handles the response to the ClearByteRange request. The method always -// closes the http.Response Body. -func (client Client) ClearByteRangeResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/range_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/range_get.go deleted file mode 100644 index 733d3f525105f..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/range_get.go +++ /dev/null @@ -1,121 +0,0 @@ -package files - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type GetByteRangeInput struct { - StartBytes int64 - EndBytes int64 -} - -type GetByteRangeResult struct { - autorest.Response - - Contents []byte -} - -// GetByteRange returns the specified Byte Range from the specified File. -func (client Client) GetByteRange(ctx context.Context, accountName, shareName, path, fileName string, input GetByteRangeInput) (result GetByteRangeResult, err error) { - if accountName == "" { - return result, validation.NewError("files.Client", "GetByteRange", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("files.Client", "GetByteRange", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("files.Client", "GetByteRange", "`shareName` must be a lower-cased string.") - } - if fileName == "" { - return result, validation.NewError("files.Client", "GetByteRange", "`fileName` cannot be an empty string.") - } - if input.StartBytes < 0 { - return result, validation.NewError("files.Client", "GetByteRange", "`input.StartBytes` must be greater or equal to 0.") - } - if input.EndBytes <= 0 { - return result, validation.NewError("files.Client", "GetByteRange", "`input.EndBytes` must be greater than 0.") - } - expectedBytes := input.EndBytes - input.StartBytes - if expectedBytes < (4 * 1024) { - return result, validation.NewError("files.Client", "GetByteRange", "Requested Byte Range must be at least 4KB.") - } - if expectedBytes > (4 * 1024 * 1024) { - return result, validation.NewError("files.Client", "GetByteRange", "Requested Byte Range must be at most 4MB.") - } - - req, err := client.GetByteRangePreparer(ctx, accountName, shareName, path, fileName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "GetByteRange", nil, "Failure preparing request") - return - } - - resp, err := client.GetByteRangeSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "files.Client", "GetByteRange", resp, "Failure sending request") - return - } - - result, err = client.GetByteRangeResponder(resp, expectedBytes) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "GetByteRange", resp, "Failure responding to request") - return - } - - return -} - -// GetByteRangePreparer prepares the GetByteRange request. -func (client Client) GetByteRangePreparer(ctx context.Context, accountName, shareName, path, fileName string, input GetByteRangeInput) (*http.Request, error) { - if path != "" { - path = fmt.Sprintf("%s/", path) - } - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - "directory": autorest.Encode("path", path), - "fileName": autorest.Encode("path", fileName), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-range": fmt.Sprintf("bytes=%d-%d", input.StartBytes, input.EndBytes-1), - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}/{directory}{fileName}", pathParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetByteRangeSender sends the GetByteRange request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetByteRangeSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetByteRangeResponder handles the response to the GetByteRange request. The method always -// closes the http.Response Body. -func (client Client) GetByteRangeResponder(resp *http.Response, length int64) (result GetByteRangeResult, err error) { - result.Contents = make([]byte, length) - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusPartialContent), - autorest.ByUnmarshallingBytes(&result.Contents), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/range_put.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/range_put.go deleted file mode 100644 index 20e4d398d5906..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/range_put.go +++ /dev/null @@ -1,127 +0,0 @@ -package files - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type PutByteRangeInput struct { - StartBytes int64 - EndBytes int64 - - // Content is the File Contents for the specified range - // which can be at most 4MB - Content []byte -} - -// PutByteRange puts the specified Byte Range in the specified File. -func (client Client) PutByteRange(ctx context.Context, accountName, shareName, path, fileName string, input PutByteRangeInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("files.Client", "PutByteRange", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("files.Client", "PutByteRange", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("files.Client", "PutByteRange", "`shareName` must be a lower-cased string.") - } - if fileName == "" { - return result, validation.NewError("files.Client", "PutByteRange", "`fileName` cannot be an empty string.") - } - if input.StartBytes < 0 { - return result, validation.NewError("files.Client", "PutByteRange", "`input.StartBytes` must be greater or equal to 0.") - } - if input.EndBytes <= 0 { - return result, validation.NewError("files.Client", "PutByteRange", "`input.EndBytes` must be greater than 0.") - } - - expectedBytes := input.EndBytes - input.StartBytes - actualBytes := len(input.Content) - if expectedBytes != int64(actualBytes) { - return result, validation.NewError("files.Client", "PutByteRange", fmt.Sprintf("The specified byte-range (%d) didn't match the content size (%d).", expectedBytes, actualBytes)) - } - - if expectedBytes > (4 * 1024 * 1024) { - return result, validation.NewError("files.Client", "PutByteRange", "Specified Byte Range must be at most 4MB.") - } - - req, err := client.PutByteRangePreparer(ctx, accountName, shareName, path, fileName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "PutByteRange", nil, "Failure preparing request") - return - } - - resp, err := client.PutByteRangeSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "files.Client", "PutByteRange", resp, "Failure sending request") - return - } - - result, err = client.PutByteRangeResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "PutByteRange", resp, "Failure responding to request") - return - } - - return -} - -// PutByteRangePreparer prepares the PutByteRange request. -func (client Client) PutByteRangePreparer(ctx context.Context, accountName, shareName, path, fileName string, input PutByteRangeInput) (*http.Request, error) { - if path != "" { - path = fmt.Sprintf("%s/", path) - } - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - "directory": autorest.Encode("path", path), - "fileName": autorest.Encode("path", fileName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "range"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-write": "update", - "x-ms-range": fmt.Sprintf("bytes=%d-%d", input.StartBytes, input.EndBytes-1), - "Content-Length": int(len(input.Content)), - } - - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}/{directory}{fileName}", pathParameters), - autorest.WithHeaders(headers), - autorest.WithQueryParameters(queryParameters), - autorest.WithBytes(&input.Content)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// PutByteRangeSender sends the PutByteRange request. The method will close the -// http.Response Body if it receives an error. -func (client Client) PutByteRangeSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// PutByteRangeResponder handles the response to the PutByteRange request. The method always -// closes the http.Response Body. -func (client Client) PutByteRangeResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/ranges_list.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/ranges_list.go deleted file mode 100644 index ea309f97ddb2e..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/ranges_list.go +++ /dev/null @@ -1,114 +0,0 @@ -package files - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type ListRangesResult struct { - autorest.Response - - Ranges []Range `xml:"Range"` -} - -type Range struct { - Start string `xml:"Start"` - End string `xml:"End"` -} - -// ListRanges returns the list of valid ranges for the specified File. -func (client Client) ListRanges(ctx context.Context, accountName, shareName, path, fileName string) (result ListRangesResult, err error) { - if accountName == "" { - return result, validation.NewError("files.Client", "ListRanges", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("files.Client", "ListRanges", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("files.Client", "ListRanges", "`shareName` must be a lower-cased string.") - } - if path == "" { - return result, validation.NewError("files.Client", "ListRanges", "`path` cannot be an empty string.") - } - if fileName == "" { - return result, validation.NewError("files.Client", "ListRanges", "`fileName` cannot be an empty string.") - } - - req, err := client.ListRangesPreparer(ctx, accountName, shareName, path, fileName) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "ListRanges", nil, "Failure preparing request") - return - } - - resp, err := client.ListRangesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "files.Client", "ListRanges", resp, "Failure sending request") - return - } - - result, err = client.ListRangesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "files.Client", "ListRanges", resp, "Failure responding to request") - return - } - - return -} - -// ListRangesPreparer prepares the ListRanges request. -func (client Client) ListRangesPreparer(ctx context.Context, accountName, shareName, path, fileName string) (*http.Request, error) { - if path != "" { - path = fmt.Sprintf("%s/", path) - } - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - "directory": autorest.Encode("path", path), - "fileName": autorest.Encode("path", fileName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "rangelist"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}/{directory}{fileName}", pathParameters), - autorest.WithHeaders(headers), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListRangesSender sends the ListRanges request. The method will close the -// http.Response Body if it receives an error. -func (client Client) ListRangesSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListRangesResponder handles the response to the ListRanges request. The method always -// closes the http.Response Body. -func (client Client) ListRangesResponder(resp *http.Response) (result ListRangesResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingXML(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/resource_id.go deleted file mode 100644 index f18e702e81d95..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/resource_id.go +++ /dev/null @@ -1,64 +0,0 @@ -package files - -import ( - "fmt" - "net/url" - "strings" - - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// GetResourceID returns the Resource ID for the given File -// This can be useful when, for example, you're using this as a unique identifier -func (client Client) GetResourceID(accountName, shareName, directoryName, filePath string) string { - domain := endpoints.GetFileEndpoint(client.BaseURI, accountName) - return fmt.Sprintf("%s/%s/%s/%s", domain, shareName, directoryName, filePath) -} - -type ResourceID struct { - AccountName string - DirectoryName string - FileName string - ShareName string -} - -// ParseResourceID parses the specified Resource ID and returns an object -// which can be used to interact with Files within a Storage Share. -func ParseResourceID(id string) (*ResourceID, error) { - // example: https://account1.file.core.chinacloudapi.cn/share1/directory1/file1.txt - // example: https://account1.file.core.chinacloudapi.cn/share1/directory1/directory2/file1.txt - - if id == "" { - return nil, fmt.Errorf("`id` was empty") - } - - uri, err := url.Parse(id) - if err != nil { - return nil, fmt.Errorf("Error parsing ID as a URL: %s", err) - } - - accountName, err := endpoints.GetAccountNameFromEndpoint(uri.Host) - if err != nil { - return nil, fmt.Errorf("Error parsing Account Name: %s", err) - } - - path := strings.TrimPrefix(uri.Path, "/") - segments := strings.Split(path, "/") - if len(segments) == 0 { - return nil, fmt.Errorf("Expected the path to contain segments but got none") - } - - shareName := segments[0] - fileName := segments[len(segments)-1] - - directoryName := strings.TrimPrefix(path, shareName) - directoryName = strings.TrimPrefix(directoryName, "/") - directoryName = strings.TrimSuffix(directoryName, fileName) - directoryName = strings.TrimSuffix(directoryName, "/") - return &ResourceID{ - AccountName: *accountName, - ShareName: shareName, - DirectoryName: directoryName, - FileName: fileName, - }, nil -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/version.go deleted file mode 100644 index 7c82310337037..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/version.go +++ /dev/null @@ -1,14 +0,0 @@ -package files - -import ( - "fmt" - - "github.com/tombuildsstuff/giovanni/version" -) - -// APIVersion is the version of the API used for all Storage API Operations -const APIVersion = "2020-08-04" - -func UserAgent() string { - return fmt.Sprintf("tombuildsstuff/giovanni/%s storage/%s", version.Number, APIVersion) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/README.md b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/README.md deleted file mode 100644 index ecc0f13ae9bb1..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/README.md +++ /dev/null @@ -1,43 +0,0 @@ -## File Storage Shares SDK for API version 2020-08-04 - -This package allows you to interact with the Shares File Storage API - -### Supported Authorizers - -* Azure Active Directory (for the Resource Endpoint `https://storage.azure.com`) -* SharedKeyLite (Blob, File & Queue) - -### Example Usage - -```go -package main - -import ( - "context" - "fmt" - "time" - - "github.com/Azure/go-autorest/autorest" - "github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares" -) - -func Example() error { - accountName := "storageaccount1" - storageAccountKey := "ABC123...." - shareName := "myshare" - - storageAuth := autorest.NewSharedKeyLiteAuthorizer(accountName, storageAccountKey) - sharesClient := shares.New() - sharesClient.Client.Authorizer = storageAuth - - ctx := context.TODO() - input := shares.CreateInput{ - QuotaInGB: 2, - } - if _, err := sharesClient.Create(ctx, accountName, shareName, input); err != nil { - return fmt.Errorf("Error creating Share: %s", err) - } - - return nil -} -``` \ No newline at end of file diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/acl_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/acl_get.go deleted file mode 100644 index ea6ff4c2dd264..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/acl_get.go +++ /dev/null @@ -1,98 +0,0 @@ -package shares - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type GetACLResult struct { - autorest.Response - - SignedIdentifiers []SignedIdentifier `xml:"SignedIdentifier"` -} - -// GetACL get the Access Control List for the specified Storage Share -func (client Client) GetACL(ctx context.Context, accountName, shareName string) (result GetACLResult, err error) { - if accountName == "" { - return result, validation.NewError("shares.Client", "GetACL", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("shares.Client", "GetACL", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("shares.Client", "GetACL", "`shareName` must be a lower-cased string.") - } - - req, err := client.GetACLPreparer(ctx, accountName, shareName) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "GetACL", nil, "Failure preparing request") - return - } - - resp, err := client.GetACLSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "shares.Client", "GetACL", resp, "Failure sending request") - return - } - - result, err = client.GetACLResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "GetACL", resp, "Failure responding to request") - return - } - - return -} - -// GetACLPreparer prepares the GetACL request. -func (client Client) GetACLPreparer(ctx context.Context, accountName, shareName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("query", "share"), - "comp": autorest.Encode("query", "acl"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetACLSender sends the GetACL request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetACLSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetACLResponder handles the response to the GetACL request. The method always -// closes the http.Response Body. -func (client Client) GetACLResponder(resp *http.Response) (result GetACLResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingXML(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/acl_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/acl_set.go deleted file mode 100644 index 18d1788a2ee44..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/acl_set.go +++ /dev/null @@ -1,103 +0,0 @@ -package shares - -import ( - "context" - "encoding/xml" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type setAcl struct { - SignedIdentifiers []SignedIdentifier `xml:"SignedIdentifier"` - - XMLName xml.Name `xml:"SignedIdentifiers"` -} - -// SetACL sets the specified Access Control List on the specified Storage Share -func (client Client) SetACL(ctx context.Context, accountName, shareName string, acls []SignedIdentifier) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("shares.Client", "SetACL", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("shares.Client", "SetACL", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("shares.Client", "SetACL", "`shareName` must be a lower-cased string.") - } - - req, err := client.SetACLPreparer(ctx, accountName, shareName, acls) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "SetACL", nil, "Failure preparing request") - return - } - - resp, err := client.SetACLSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "shares.Client", "SetACL", resp, "Failure sending request") - return - } - - result, err = client.SetACLResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "SetACL", resp, "Failure responding to request") - return - } - - return -} - -// SetACLPreparer prepares the SetACL request. -func (client Client) SetACLPreparer(ctx context.Context, accountName, shareName string, acls []SignedIdentifier) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("query", "share"), - "comp": autorest.Encode("query", "acl"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - input := setAcl{ - SignedIdentifiers: acls, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers), - autorest.WithXML(&input)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SetACLSender sends the SetACL request. The method will close the -// http.Response Body if it receives an error. -func (client Client) SetACLSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// SetACLResponder handles the response to the SetACL request. The method always -// closes the http.Response Body. -func (client Client) SetACLResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/api.go deleted file mode 100644 index 91645912dfb6e..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/api.go +++ /dev/null @@ -1,24 +0,0 @@ -package shares - -import ( - "context" - - "github.com/Azure/go-autorest/autorest" -) - -type StorageShare interface { - SetACL(ctx context.Context, accountName, shareName string, acls []SignedIdentifier) (result autorest.Response, err error) - GetSnapshot(ctx context.Context, accountName, shareName, snapshotShare string) (result GetSnapshotPropertiesResult, err error) - GetStats(ctx context.Context, accountName, shareName string) (result GetStatsResult, err error) - GetACL(ctx context.Context, accountName, shareName string) (result GetACLResult, err error) - SetMetaData(ctx context.Context, accountName, shareName string, metaData map[string]string) (result autorest.Response, err error) - GetMetaData(ctx context.Context, accountName, shareName string) (result GetMetaDataResult, err error) - SetProperties(ctx context.Context, accountName, shareName string, properties ShareProperties) (result autorest.Response, err error) - DeleteSnapshot(ctx context.Context, accountName, shareName string, shareSnapshot string) (result autorest.Response, err error) - CreateSnapshot(ctx context.Context, accountName, shareName string, input CreateSnapshotInput) (result CreateSnapshotResult, err error) - GetResourceID(accountName, shareName string) string - GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, shareName string) string - GetProperties(ctx context.Context, accountName, shareName string) (result GetPropertiesResult, err error) - Delete(ctx context.Context, accountName, shareName string, deleteSnapshots bool) (result autorest.Response, err error) - Create(ctx context.Context, accountName, shareName string, input CreateInput) (result autorest.Response, err error) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/client.go deleted file mode 100644 index 4f3a6f9f99d0e..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/client.go +++ /dev/null @@ -1,25 +0,0 @@ -package shares - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Client is the base client for File Storage Shares. -type Client struct { - autorest.Client - BaseURI string -} - -// New creates an instance of the Client client. -func New() Client { - return NewWithEnvironment(azure.PublicCloud) -} - -// NewWithEnvironment creates an instance of the Client client. -func NewWithEnvironment(environment azure.Environment) Client { - return Client{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: environment.StorageEndpointSuffix, - } -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/create.go deleted file mode 100644 index 10a1148f0368f..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/create.go +++ /dev/null @@ -1,134 +0,0 @@ -package shares - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type AccessTier string - -const ( - TransactionOptimizedAccessTier AccessTier = "TransactionOptimized" - HotAccessTier AccessTier = "Hot" - CoolAccessTier AccessTier = "Cool" - PremiumAccessTier AccessTier = "Premium" -) - -type CreateInput struct { - // Specifies the maximum size of the share, in gigabytes. - // Must be greater than 0, and less than or equal to 5TB (5120). - QuotaInGB int - - // Specifies the enabled protocols on the share. If not specified, the default is SMB. - EnabledProtocol ShareProtocol - - MetaData map[string]string - - // Specifies the access tier of the share. - AccessTier *AccessTier -} - -// Create creates the specified Storage Share within the specified Storage Account -func (client Client) Create(ctx context.Context, accountName, shareName string, input CreateInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("shares.Client", "Create", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("shares.Client", "Create", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("shares.Client", "Create", "`shareName` must be a lower-cased string.") - } - if input.QuotaInGB <= 0 || input.QuotaInGB > 102400 { - return result, validation.NewError("shares.Client", "Create", "`input.QuotaInGB` must be greater than 0, and less than/equal to 100TB (102400 GB)") - } - if err := metadata.Validate(input.MetaData); err != nil { - return result, validation.NewError("shares.Client", "Create", fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) - } - - req, err := client.CreatePreparer(ctx, accountName, shareName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "Create", nil, "Failure preparing request") - return - } - - resp, err := client.CreateSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "shares.Client", "Create", resp, "Failure sending request") - return - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "Create", resp, "Failure responding to request") - return - } - - return -} - -// CreatePreparer prepares the Create request. -func (client Client) CreatePreparer(ctx context.Context, accountName, shareName string, input CreateInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("path", "share"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-share-quota": input.QuotaInGB, - } - - protocol := SMB - if input.EnabledProtocol != "" { - protocol = input.EnabledProtocol - } - headers["x-ms-enabled-protocols"] = protocol - - if input.AccessTier != nil { - headers["x-ms-access-tier"] = string(*input.AccessTier) - } - - headers = metadata.SetIntoHeaders(headers, input.MetaData) - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateSender sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (client Client) CreateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CreateResponder handles the response to the Create request. The method always -// closes the http.Response Body. -func (client Client) CreateResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/delete.go deleted file mode 100644 index 70ef985d23bba..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/delete.go +++ /dev/null @@ -1,94 +0,0 @@ -package shares - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// Delete deletes the specified Storage Share from within a Storage Account -func (client Client) Delete(ctx context.Context, accountName, shareName string, deleteSnapshots bool) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("shares.Client", "Delete", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("shares.Client", "Delete", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("shares.Client", "Delete", "`shareName` must be a lower-cased string.") - } - - req, err := client.DeletePreparer(ctx, accountName, shareName, deleteSnapshots) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "shares.Client", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client Client) DeletePreparer(ctx context.Context, accountName, shareName string, deleteSnapshots bool) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("path", "share"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - if deleteSnapshots { - headers["x-ms-delete-snapshots"] = "include" - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client Client) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/metadata_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/metadata_get.go deleted file mode 100644 index 9fa4d9f07ed83..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/metadata_get.go +++ /dev/null @@ -1,102 +0,0 @@ -package shares - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type GetMetaDataResult struct { - autorest.Response - - MetaData map[string]string -} - -// GetMetaData returns the MetaData associated with the specified Storage Share -func (client Client) GetMetaData(ctx context.Context, accountName, shareName string) (result GetMetaDataResult, err error) { - if accountName == "" { - return result, validation.NewError("shares.Client", "GetMetaData", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("shares.Client", "GetMetaData", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("shares.Client", "GetMetaData", "`shareName` must be a lower-cased string.") - } - - req, err := client.GetMetaDataPreparer(ctx, accountName, shareName) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "GetMetaData", nil, "Failure preparing request") - return - } - - resp, err := client.GetMetaDataSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "shares.Client", "GetMetaData", resp, "Failure sending request") - return - } - - result, err = client.GetMetaDataResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "GetMetaData", resp, "Failure responding to request") - return - } - - return -} - -// GetMetaDataPreparer prepares the GetMetaData request. -func (client Client) GetMetaDataPreparer(ctx context.Context, accountName, shareName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("query", "share"), - "comp": autorest.Encode("query", "metadata"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetMetaDataSender sends the GetMetaData request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetMetaDataSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetMetaDataResponder handles the response to the GetMetaData request. The method always -// closes the http.Response Body. -func (client Client) GetMetaDataResponder(resp *http.Response) (result GetMetaDataResult, err error) { - if resp.Header != nil { - result.MetaData = metadata.ParseFromHeaders(resp.Header) - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/metadata_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/metadata_set.go deleted file mode 100644 index 7e64e60aca151..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/metadata_set.go +++ /dev/null @@ -1,97 +0,0 @@ -package shares - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -// SetMetaData sets the MetaData on the specified Storage Share -func (client Client) SetMetaData(ctx context.Context, accountName, shareName string, metaData map[string]string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("shares.Client", "SetMetaData", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("shares.Client", "SetMetaData", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("shares.Client", "SetMetaData", "`shareName` must be a lower-cased string.") - } - if err := metadata.Validate(metaData); err != nil { - return result, validation.NewError("shares.Client", "SetMetaData", fmt.Sprintf("`metadata` is not valid: %s.", err)) - } - - req, err := client.SetMetaDataPreparer(ctx, accountName, shareName, metaData) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "SetMetaData", nil, "Failure preparing request") - return - } - - resp, err := client.SetMetaDataSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "shares.Client", "SetMetaData", resp, "Failure sending request") - return - } - - result, err = client.SetMetaDataResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "SetMetaData", resp, "Failure responding to request") - return - } - - return -} - -// SetMetaDataPreparer prepares the SetMetaData request. -func (client Client) SetMetaDataPreparer(ctx context.Context, accountName, shareName string, metaData map[string]string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("query", "share"), - "comp": autorest.Encode("query", "metadata"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - headers = metadata.SetIntoHeaders(headers, metaData) - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SetPropertiesSetMetaDataSender sends the SetMetaData request. The method will close the -// http.Response Body if it receives an error. -func (client Client) SetMetaDataSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// SetMetaDataResponder handles the response to the SetMetaData request. The method always -// closes the http.Response Body. -func (client Client) SetMetaDataResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/properties_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/properties_get.go deleted file mode 100644 index 28e36e6d3eafd..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/properties_get.go +++ /dev/null @@ -1,126 +0,0 @@ -package shares - -import ( - "context" - "fmt" - "net/http" - "strconv" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type GetPropertiesResult struct { - autorest.Response - - MetaData map[string]string - QuotaInGB int - EnabledProtocol ShareProtocol - AccessTier *AccessTier -} - -// GetProperties returns the properties about the specified Storage Share -func (client Client) GetProperties(ctx context.Context, accountName, shareName string) (result GetPropertiesResult, err error) { - if accountName == "" { - return result, validation.NewError("shares.Client", "GetProperties", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("shares.Client", "GetProperties", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("shares.Client", "GetProperties", "`shareName` must be a lower-cased string.") - } - - req, err := client.GetPropertiesPreparer(ctx, accountName, shareName) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "GetProperties", nil, "Failure preparing request") - return - } - - resp, err := client.GetPropertiesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "shares.Client", "GetProperties", resp, "Failure sending request") - return - } - - result, err = client.GetPropertiesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "GetProperties", resp, "Failure responding to request") - return - } - - return -} - -// GetPropertiesPreparer prepares the GetProperties request. -func (client Client) GetPropertiesPreparer(ctx context.Context, accountName, shareName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("query", "share"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetPropertiesSender sends the GetProperties request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetPropertiesSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetPropertiesResponder handles the response to the GetProperties request. The method always -// closes the http.Response Body. -func (client Client) GetPropertiesResponder(resp *http.Response) (result GetPropertiesResult, err error) { - if resp.Header != nil { - result.MetaData = metadata.ParseFromHeaders(resp.Header) - - quotaRaw := resp.Header.Get("x-ms-share-quota") - if quotaRaw != "" { - quota, e := strconv.Atoi(quotaRaw) - if e != nil { - return result, fmt.Errorf("Error converting %q to an integer: %s", quotaRaw, err) - } - result.QuotaInGB = quota - } - - protocol := SMB - if protocolRaw := resp.Header.Get("x-ms-enabled-protocols"); protocolRaw != "" { - protocol = ShareProtocol(protocolRaw) - } - - if accessTierRaw := resp.Header.Get("x-ms-access-tier"); accessTierRaw != "" { - tier := AccessTier(accessTierRaw) - result.AccessTier = &tier - } - result.EnabledProtocol = protocol - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/properties_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/properties_set.go deleted file mode 100644 index 70953c73e1028..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/properties_set.go +++ /dev/null @@ -1,106 +0,0 @@ -package shares - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type ShareProperties struct { - QuotaInGb *int - AccessTier *AccessTier -} - -// SetProperties lets you update the Quota for the specified Storage Share -func (client Client) SetProperties(ctx context.Context, accountName, shareName string, properties ShareProperties) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("shares.Client", "SetProperties", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("shares.Client", "SetProperties", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("shares.Client", "SetProperties", "`shareName` must be a lower-cased string.") - } - if newQuotaGB := properties.QuotaInGb; newQuotaGB != nil && (*newQuotaGB <= 0 || *newQuotaGB > 102400) { - return result, validation.NewError("shares.Client", "SetProperties", "`newQuotaGB` must be greater than 0, and less than/equal to 100TB (102400 GB)") - } - - req, err := client.SetPropertiesPreparer(ctx, accountName, shareName, properties) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "SetProperties", nil, "Failure preparing request") - return - } - - resp, err := client.SetPropertiesSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "shares.Client", "SetProperties", resp, "Failure sending request") - return - } - - result, err = client.SetPropertiesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "SetProperties", resp, "Failure responding to request") - return - } - - return -} - -// SetPropertiesPreparer prepares the SetProperties request. -func (client Client) SetPropertiesPreparer(ctx context.Context, accountName, shareName string, properties ShareProperties) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("query", "share"), - "comp": autorest.Encode("query", "properties"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - if properties.QuotaInGb != nil { - headers["x-ms-share-quota"] = *properties.QuotaInGb - } - - if properties.AccessTier != nil { - headers["x-ms-access-tier"] = string(*properties.AccessTier) - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SetPropertiesSender sends the SetProperties request. The method will close the -// http.Response Body if it receives an error. -func (client Client) SetPropertiesSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// SetPropertiesResponder handles the response to the SetProperties request. The method always -// closes the http.Response Body. -func (client Client) SetPropertiesResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/resource_id.go deleted file mode 100644 index c51d399ca062d..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/resource_id.go +++ /dev/null @@ -1,53 +0,0 @@ -package shares - -import ( - "fmt" - "net/url" - "strings" - - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// GetResourceID returns the Resource ID for the given File Share -// This can be useful when, for example, you're using this as a unique identifier -func (client Client) GetResourceID(accountName, shareName string) string { - domain := endpoints.GetFileEndpoint(client.BaseURI, accountName) - return fmt.Sprintf("%s/%s", domain, shareName) -} - -// GetResourceManagerResourceID returns the Resource Manager specific -// ResourceID for a specific Storage Share -func (client Client) GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, shareName string) string { - fmtStr := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s/fileServices/default/shares/%s" - return fmt.Sprintf(fmtStr, subscriptionID, resourceGroup, accountName, shareName) -} - -type ResourceID struct { - AccountName string - ShareName string -} - -// ParseResourceID parses the specified Resource ID and returns an object -// which can be used to interact with the Storage Shares SDK -func ParseResourceID(id string) (*ResourceID, error) { - // example: https://foo.file.core.windows.net/Bar - if id == "" { - return nil, fmt.Errorf("`id` was empty") - } - - uri, err := url.Parse(id) - if err != nil { - return nil, fmt.Errorf("Error parsing ID as a URL: %s", err) - } - - accountName, err := endpoints.GetAccountNameFromEndpoint(uri.Host) - if err != nil { - return nil, fmt.Errorf("Error parsing Account Name: %s", err) - } - - shareName := strings.TrimPrefix(uri.Path, "/") - return &ResourceID{ - AccountName: *accountName, - ShareName: shareName, - }, nil -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/snapshot_create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/snapshot_create.go deleted file mode 100644 index 0ded38b1975aa..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/snapshot_create.go +++ /dev/null @@ -1,115 +0,0 @@ -package shares - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type CreateSnapshotInput struct { - MetaData map[string]string -} - -type CreateSnapshotResult struct { - autorest.Response - - // This header is a DateTime value that uniquely identifies the share snapshot. - // The value of this header may be used in subsequent requests to access the share snapshot. - // This value is opaque. - SnapshotDateTime string -} - -// CreateSnapshot creates a read-only snapshot of the share -// A share can support creation of 200 share snapshots. Attempting to create more than 200 share snapshots fails with 409 (Conflict). -// Attempting to create a share snapshot while a previous Snapshot Share operation is in progress fails with 409 (Conflict). -func (client Client) CreateSnapshot(ctx context.Context, accountName, shareName string, input CreateSnapshotInput) (result CreateSnapshotResult, err error) { - if accountName == "" { - return result, validation.NewError("shares.Client", "CreateSnapshot", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("shares.Client", "CreateSnapshot", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("shares.Client", "CreateSnapshot", "`shareName` must be a lower-cased string.") - } - if err := metadata.Validate(input.MetaData); err != nil { - return result, validation.NewError("shares.Client", "CreateSnapshot", fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) - } - - req, err := client.CreateSnapshotPreparer(ctx, accountName, shareName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "CreateSnapshot", nil, "Failure preparing request") - return - } - - resp, err := client.CreateSnapshotSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "shares.Client", "CreateSnapshot", resp, "Failure sending request") - return - } - - result, err = client.CreateSnapshotResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "CreateSnapshot", resp, "Failure responding to request") - return - } - - return -} - -// CreateSnapshotPreparer prepares the CreateSnapshot request. -func (client Client) CreateSnapshotPreparer(ctx context.Context, accountName, shareName string, input CreateSnapshotInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "snapshot"), - "restype": autorest.Encode("query", "share"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - headers = metadata.SetIntoHeaders(headers, input.MetaData) - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateSnapshotSender sends the CreateSnapshot request. The method will close the -// http.Response Body if it receives an error. -func (client Client) CreateSnapshotSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CreateSnapshotResponder handles the response to the CreateSnapshot request. The method always -// closes the http.Response Body. -func (client Client) CreateSnapshotResponder(resp *http.Response) (result CreateSnapshotResult, err error) { - result.SnapshotDateTime = resp.Header.Get("x-ms-snapshot") - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/snapshot_delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/snapshot_delete.go deleted file mode 100644 index 1f5d665cb104d..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/snapshot_delete.go +++ /dev/null @@ -1,94 +0,0 @@ -package shares - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// DeleteSnapshot deletes the specified Snapshot of a Storage Share -func (client Client) DeleteSnapshot(ctx context.Context, accountName, shareName string, shareSnapshot string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("shares.Client", "DeleteSnapshot", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("shares.Client", "DeleteSnapshot", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("shares.Client", "DeleteSnapshot", "`shareName` must be a lower-cased string.") - } - if shareSnapshot == "" { - return result, validation.NewError("shares.Client", "DeleteSnapshot", "`shareSnapshot` cannot be an empty string.") - } - - req, err := client.DeleteSnapshotPreparer(ctx, accountName, shareName, shareSnapshot) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "DeleteSnapshot", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSnapshotSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "shares.Client", "DeleteSnapshot", resp, "Failure sending request") - return - } - - result, err = client.DeleteSnapshotResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "DeleteSnapshot", resp, "Failure responding to request") - return - } - - return -} - -// DeleteSnapshotPreparer prepares the DeleteSnapshot request. -func (client Client) DeleteSnapshotPreparer(ctx context.Context, accountName, shareName string, shareSnapshot string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("path", "share"), - "sharesnapshot": autorest.Encode("query", shareSnapshot), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSnapshotSender sends the DeleteSnapshot request. The method will close the -// http.Response Body if it receives an error. -func (client Client) DeleteSnapshotSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteSnapshotResponder handles the response to the DeleteSnapshot request. The method always -// closes the http.Response Body. -func (client Client) DeleteSnapshotResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/snapshot_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/snapshot_get.go deleted file mode 100644 index 2cf5f16f618ea..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/snapshot_get.go +++ /dev/null @@ -1,105 +0,0 @@ -package shares - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type GetSnapshotPropertiesResult struct { - autorest.Response - - MetaData map[string]string -} - -// GetSnapshot gets information about the specified Snapshot of the specified Storage Share -func (client Client) GetSnapshot(ctx context.Context, accountName, shareName, snapshotShare string) (result GetSnapshotPropertiesResult, err error) { - if accountName == "" { - return result, validation.NewError("shares.Client", "GetSnapshot", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("shares.Client", "GetSnapshot", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("shares.Client", "GetSnapshot", "`shareName` must be a lower-cased string.") - } - if snapshotShare == "" { - return result, validation.NewError("shares.Client", "GetSnapshot", "`snapshotShare` cannot be an empty string.") - } - - req, err := client.GetSnapshotPreparer(ctx, accountName, shareName, snapshotShare) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "GetSnapshot", nil, "Failure preparing request") - return - } - - resp, err := client.GetSnapshotSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "shares.Client", "GetSnapshot", resp, "Failure sending request") - return - } - - result, err = client.GetSnapshotResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "GetSnapshot", resp, "Failure responding to request") - return - } - - return -} - -// GetSnapshotPreparer prepares the GetSnapshot request. -func (client Client) GetSnapshotPreparer(ctx context.Context, accountName, shareName, snapshotShare string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("query", "share"), - "snapshot": autorest.Encode("query", snapshotShare), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSnapshotSender sends the GetSnapshot request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetSnapshotSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetSnapshotResponder handles the response to the GetSnapshot request. The method always -// closes the http.Response Body. -func (client Client) GetSnapshotResponder(resp *http.Response) (result GetSnapshotPropertiesResult, err error) { - if resp.Header != nil { - result.MetaData = metadata.ParseFromHeaders(resp.Header) - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/stats.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/stats.go deleted file mode 100644 index 3539eccbcd0e3..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/stats.go +++ /dev/null @@ -1,100 +0,0 @@ -package shares - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type GetStatsResult struct { - autorest.Response - - // The approximate size of the data stored on the share. - // Note that this value may not include all recently created or recently resized files. - ShareUsageBytes int64 `xml:"ShareUsageBytes"` -} - -// GetStats returns information about the specified Storage Share -func (client Client) GetStats(ctx context.Context, accountName, shareName string) (result GetStatsResult, err error) { - if accountName == "" { - return result, validation.NewError("shares.Client", "GetStats", "`accountName` cannot be an empty string.") - } - if shareName == "" { - return result, validation.NewError("shares.Client", "GetStats", "`shareName` cannot be an empty string.") - } - if strings.ToLower(shareName) != shareName { - return result, validation.NewError("shares.Client", "GetStats", "`shareName` must be a lower-cased string.") - } - - req, err := client.GetStatsPreparer(ctx, accountName, shareName) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "GetStats", nil, "Failure preparing request") - return - } - - resp, err := client.GetStatsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "shares.Client", "GetStats", resp, "Failure sending request") - return - } - - result, err = client.GetStatsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "shares.Client", "GetStats", resp, "Failure responding to request") - return - } - - return -} - -// GetStatsPreparer prepares the GetStats request. -func (client Client) GetStatsPreparer(ctx context.Context, accountName, shareName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "shareName": autorest.Encode("path", shareName), - } - - queryParameters := map[string]interface{}{ - "restype": autorest.Encode("query", "share"), - "comp": autorest.Encode("query", "stats"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetFileEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{shareName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetStatsSender sends the GetStats request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetStatsSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetStatsResponder handles the response to the GetStats request. The method always -// closes the http.Response Body. -func (client Client) GetStatsResponder(resp *http.Response) (result GetStatsResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingXML(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/version.go deleted file mode 100644 index 653693959b6f6..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/version.go +++ /dev/null @@ -1,14 +0,0 @@ -package shares - -import ( - "fmt" - - "github.com/tombuildsstuff/giovanni/version" -) - -// APIVersion is the version of the API used for all Storage API Operations -const APIVersion = "2020-08-04" - -func UserAgent() string { - return fmt.Sprintf("tombuildsstuff/giovanni/%s storage/%s", version.Number, APIVersion) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/README.md b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/README.md deleted file mode 100644 index b8b84a3799a8c..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/README.md +++ /dev/null @@ -1,43 +0,0 @@ -## Queue Storage Queues SDK for API version 2020-08-04 - -This package allows you to interact with the Queues Queue Storage API - -### Supported Authorizers - -* Azure Active Directory (for the Resource Endpoint `https://storage.azure.com`) -* SharedKeyLite (Blob, File & Queue) - -### Example Usage - -```go -package main - -import ( - "context" - "fmt" - "time" - - "github.com/Azure/go-autorest/autorest" - "github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues" -) - -func Example() error { - accountName := "storageaccount1" - storageAccountKey := "ABC123...." - queueName := "myqueue" - - storageAuth := autorest.NewSharedKeyLiteAuthorizer(accountName, storageAccountKey) - queuesClient := queues.New() - queuesClient.Client.Authorizer = storageAuth - - ctx := context.TODO() - metadata := map[string]string{ - "hello": "world", - } - if _, err := queuesClient.Create(ctx, accountName, queueName, metadata); err != nil { - return fmt.Errorf("Error creating Queue: %s", err) - } - - return nil -} -``` \ No newline at end of file diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/api.go deleted file mode 100644 index e4c14220b68ca..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/api.go +++ /dev/null @@ -1,17 +0,0 @@ -package queues - -import ( - "context" - - "github.com/Azure/go-autorest/autorest" -) - -type StorageQueue interface { - Delete(ctx context.Context, accountName, queueName string) (result autorest.Response, err error) - GetMetaData(ctx context.Context, accountName, queueName string) (result GetMetaDataResult, err error) - SetMetaData(ctx context.Context, accountName, queueName string, metaData map[string]string) (result autorest.Response, err error) - Create(ctx context.Context, accountName, queueName string, metaData map[string]string) (result autorest.Response, err error) - GetResourceID(accountName, queueName string) string - SetServiceProperties(ctx context.Context, accountName string, properties StorageServiceProperties) (result autorest.Response, err error) - GetServiceProperties(ctx context.Context, accountName string) (result StorageServicePropertiesResponse, err error) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/client.go deleted file mode 100644 index 2f8008582b939..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/client.go +++ /dev/null @@ -1,25 +0,0 @@ -package queues - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Client is the base client for Queue Storage Shares. -type Client struct { - autorest.Client - BaseURI string -} - -// New creates an instance of the Client client. -func New() Client { - return NewWithEnvironment(azure.PublicCloud) -} - -// NewWithEnvironment creates an instance of the Client client. -func NewWithEnvironment(environment azure.Environment) Client { - return Client{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: environment.StorageEndpointSuffix, - } -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/create.go deleted file mode 100644 index f18910a88d9e1..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/create.go +++ /dev/null @@ -1,92 +0,0 @@ -package queues - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -// Create creates the specified Queue within the specified Storage Account -func (client Client) Create(ctx context.Context, accountName, queueName string, metaData map[string]string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("queues.Client", "Create", "`accountName` cannot be an empty string.") - } - if queueName == "" { - return result, validation.NewError("queues.Client", "Create", "`queueName` cannot be an empty string.") - } - if strings.ToLower(queueName) != queueName { - return result, validation.NewError("queues.Client", "Create", "`queueName` must be a lower-cased string.") - } - if err := metadata.Validate(metaData); err != nil { - return result, validation.NewError("queues.Client", "Create", fmt.Sprintf("`metadata` is not valid: %s.", err)) - } - - req, err := client.CreatePreparer(ctx, accountName, queueName, metaData) - if err != nil { - err = autorest.NewErrorWithError(err, "queues.Client", "Create", nil, "Failure preparing request") - return - } - - resp, err := client.CreateSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "queues.Client", "Create", resp, "Failure sending request") - return - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "queues.Client", "Create", resp, "Failure responding to request") - return - } - - return -} - -// CreatePreparer prepares the Create request. -func (client Client) CreatePreparer(ctx context.Context, accountName string, queueName string, metaData map[string]string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "queueName": autorest.Encode("path", queueName), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - headers = metadata.SetIntoHeaders(headers, metaData) - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetQueueEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{queueName}", pathParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateSender sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (client Client) CreateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CreateResponder handles the response to the Create request. The method always -// closes the http.Response Body. -func (client Client) CreateResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusCreated), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/delete.go deleted file mode 100644 index 5f705959c4467..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/delete.go +++ /dev/null @@ -1,85 +0,0 @@ -package queues - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// Delete deletes the specified Queue within the specified Storage Account -func (client Client) Delete(ctx context.Context, accountName, queueName string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("queues.Client", "Delete", "`accountName` cannot be an empty string.") - } - if queueName == "" { - return result, validation.NewError("queues.Client", "Delete", "`queueName` cannot be an empty string.") - } - if strings.ToLower(queueName) != queueName { - return result, validation.NewError("queues.Client", "Delete", "`queueName` must be a lower-cased string.") - } - - req, err := client.DeletePreparer(ctx, accountName, queueName) - if err != nil { - err = autorest.NewErrorWithError(err, "queues.Client", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "queues.Client", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "queues.Client", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client Client) DeletePreparer(ctx context.Context, accountName string, queueName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "queueName": autorest.Encode("path", queueName), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsDelete(), - autorest.WithBaseURL(endpoints.GetQueueEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{queueName}", pathParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client Client) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/metadata_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/metadata_get.go deleted file mode 100644 index 9c230b613ad34..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/metadata_get.go +++ /dev/null @@ -1,101 +0,0 @@ -package queues - -import ( - "context" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -type GetMetaDataResult struct { - autorest.Response - - MetaData map[string]string -} - -// GetMetaData returns the metadata for this Queue -func (client Client) GetMetaData(ctx context.Context, accountName, queueName string) (result GetMetaDataResult, err error) { - if accountName == "" { - return result, validation.NewError("queues.Client", "GetMetaData", "`accountName` cannot be an empty string.") - } - if queueName == "" { - return result, validation.NewError("queues.Client", "GetMetaData", "`queueName` cannot be an empty string.") - } - if strings.ToLower(queueName) != queueName { - return result, validation.NewError("queues.Client", "GetMetaData", "`queueName` must be a lower-cased string.") - } - - req, err := client.GetMetaDataPreparer(ctx, accountName, queueName) - if err != nil { - err = autorest.NewErrorWithError(err, "queues.Client", "GetMetaData", nil, "Failure preparing request") - return - } - - resp, err := client.GetMetaDataSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "queues.Client", "GetMetaData", resp, "Failure sending request") - return - } - - result, err = client.GetMetaDataResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "queues.Client", "GetMetaData", resp, "Failure responding to request") - return - } - - return -} - -// GetMetaDataPreparer prepares the GetMetaData request. -func (client Client) GetMetaDataPreparer(ctx context.Context, accountName, queueName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "queueName": autorest.Encode("path", queueName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("path", "metadata"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetQueueEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{queueName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetMetaDataSender sends the GetMetaData request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetMetaDataSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetMetaDataResponder handles the response to the GetMetaData request. The method always -// closes the http.Response Body. -func (client Client) GetMetaDataResponder(resp *http.Response) (result GetMetaDataResult, err error) { - if resp != nil { - result.MetaData = metadata.ParseFromHeaders(resp.Header) - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/metadata_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/metadata_set.go deleted file mode 100644 index 51154a5c4334f..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/metadata_set.go +++ /dev/null @@ -1,97 +0,0 @@ -package queues - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" - "github.com/tombuildsstuff/giovanni/storage/internal/metadata" -) - -// SetMetaData returns the metadata for this Queue -func (client Client) SetMetaData(ctx context.Context, accountName, queueName string, metaData map[string]string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("queues.Client", "SetMetaData", "`accountName` cannot be an empty string.") - } - if queueName == "" { - return result, validation.NewError("queues.Client", "SetMetaData", "`queueName` cannot be an empty string.") - } - if strings.ToLower(queueName) != queueName { - return result, validation.NewError("queues.Client", "SetMetaData", "`queueName` must be a lower-cased string.") - } - if err := metadata.Validate(metaData); err != nil { - return result, validation.NewError("queues.Client", "SetMetaData", fmt.Sprintf("`metadata` is not valid: %s.", err)) - } - - req, err := client.SetMetaDataPreparer(ctx, accountName, queueName, metaData) - if err != nil { - err = autorest.NewErrorWithError(err, "queues.Client", "SetMetaData", nil, "Failure preparing request") - return - } - - resp, err := client.SetMetaDataSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "queues.Client", "SetMetaData", resp, "Failure sending request") - return - } - - result, err = client.SetMetaDataResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "queues.Client", "SetMetaData", resp, "Failure responding to request") - return - } - - return -} - -// SetMetaDataPreparer prepares the SetMetaData request. -func (client Client) SetMetaDataPreparer(ctx context.Context, accountName, queueName string, metaData map[string]string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "queueName": autorest.Encode("path", queueName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("path", "metadata"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - headers = metadata.SetIntoHeaders(headers, metaData) - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetQueueEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{queueName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SetMetaDataSender sends the SetMetaData request. The method will close the -// http.Response Body if it receives an error. -func (client Client) SetMetaDataSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// SetMetaDataResponder handles the response to the SetMetaData request. The method always -// closes the http.Response Body. -func (client Client) SetMetaDataResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/properties_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/properties_get.go deleted file mode 100644 index a0e51ad34354a..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/properties_get.go +++ /dev/null @@ -1,86 +0,0 @@ -package queues - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type StorageServicePropertiesResponse struct { - StorageServiceProperties - autorest.Response -} - -// SetServiceProperties gets the properties for this queue -func (client Client) GetServiceProperties(ctx context.Context, accountName string) (result StorageServicePropertiesResponse, err error) { - if accountName == "" { - return result, validation.NewError("queues.Client", "GetServiceProperties", "`accountName` cannot be an empty string.") - } - - req, err := client.GetServicePropertiesPreparer(ctx, accountName) - if err != nil { - err = autorest.NewErrorWithError(err, "queues.Client", "GetServiceProperties", nil, "Failure preparing request") - return - } - - resp, err := client.GetServicePropertiesSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "queues.Client", "GetServiceProperties", resp, "Failure sending request") - return - } - - result, err = client.GetServicePropertiesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "queues.Client", "GetServiceProperties", resp, "Failure responding to request") - return - } - - return -} - -// GetServicePropertiesPreparer prepares the GetServiceProperties request. -func (client Client) GetServicePropertiesPreparer(ctx context.Context, accountName string) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("path", "properties"), - "restype": autorest.Encode("path", "service"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetQueueEndpoint(client.BaseURI, accountName)), - autorest.WithPath("/"), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetServicePropertiesSender sends the GetServiceProperties request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetServicePropertiesSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetServicePropertiesResponder handles the response to the GetServiceProperties request. The method always -// closes the http.Response Body. -func (client Client) GetServicePropertiesResponder(resp *http.Response) (result StorageServicePropertiesResponse, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingXML(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/properties_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/properties_set.go deleted file mode 100644 index 33dd40b3da1f4..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/properties_set.go +++ /dev/null @@ -1,81 +0,0 @@ -package queues - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// SetServiceProperties sets the properties for this queue -func (client Client) SetServiceProperties(ctx context.Context, accountName string, properties StorageServiceProperties) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("queues.Client", "SetServiceProperties", "`accountName` cannot be an empty string.") - } - - req, err := client.SetServicePropertiesPreparer(ctx, accountName, properties) - if err != nil { - err = autorest.NewErrorWithError(err, "queues.Client", "SetServiceProperties", nil, "Failure preparing request") - return - } - - resp, err := client.SetServicePropertiesSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "queues.Client", "SetServiceProperties", resp, "Failure sending request") - return - } - - result, err = client.SetServicePropertiesResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "queues.Client", "SetServiceProperties", resp, "Failure responding to request") - return - } - - return -} - -// SetServicePropertiesPreparer prepares the SetServiceProperties request. -func (client Client) SetServicePropertiesPreparer(ctx context.Context, accountName string, properties StorageServiceProperties) (*http.Request, error) { - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("path", "properties"), - "restype": autorest.Encode("path", "service"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetQueueEndpoint(client.BaseURI, accountName)), - autorest.WithPath("/"), - autorest.WithQueryParameters(queryParameters), - autorest.WithXML(properties), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SetServicePropertiesSender sends the SetServiceProperties request. The method will close the -// http.Response Body if it receives an error. -func (client Client) SetServicePropertiesSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// SetServicePropertiesResponder handles the response to the SetServiceProperties request. The method always -// closes the http.Response Body. -func (client Client) SetServicePropertiesResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/resource_id.go deleted file mode 100644 index 912923abca0d0..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/resource_id.go +++ /dev/null @@ -1,46 +0,0 @@ -package queues - -import ( - "fmt" - "net/url" - "strings" - - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// GetResourceID returns the Resource ID for the given Queue -// This can be useful when, for example, you're using this as a unique identifier -func (client Client) GetResourceID(accountName, queueName string) string { - domain := endpoints.GetQueueEndpoint(client.BaseURI, accountName) - return fmt.Sprintf("%s/%s", domain, queueName) -} - -type ResourceID struct { - AccountName string - QueueName string -} - -// ParseResourceID parses the Resource ID and returns an Object which -// can be used to interact with a Queue within a Storage Account -func ParseResourceID(id string) (*ResourceID, error) { - // example: https://foo.queue.core.windows.net/Bar - if id == "" { - return nil, fmt.Errorf("`id` was empty") - } - - uri, err := url.Parse(id) - if err != nil { - return nil, fmt.Errorf("Error parsing ID as a URL: %s", err) - } - - accountName, err := endpoints.GetAccountNameFromEndpoint(uri.Host) - if err != nil { - return nil, fmt.Errorf("Error parsing Account Name: %s", err) - } - - queueName := strings.TrimPrefix(uri.Path, "/") - return &ResourceID{ - AccountName: *accountName, - QueueName: queueName, - }, nil -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/version.go deleted file mode 100644 index 9d3e68949fec4..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/version.go +++ /dev/null @@ -1,14 +0,0 @@ -package queues - -import ( - "fmt" - - "github.com/tombuildsstuff/giovanni/version" -) - -// APIVersion is the version of the API used for all Storage API Operations -const APIVersion = "2020-08-04" - -func UserAgent() string { - return fmt.Sprintf("tombuildsstuff/giovanni/%s storage/%s", version.Number, APIVersion) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/README.md b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/README.md deleted file mode 100644 index e59b5a28335a4..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/README.md +++ /dev/null @@ -1,48 +0,0 @@ -## Table Storage Entities SDK for API version 2020-08-04 - -This package allows you to interact with the Entities Table Storage API - -### Supported Authorizers - -* SharedKeyLite (Table) - -### Example Usage - -```go -package main - -import ( - "context" - "fmt" - "time" - - "github.com/Azure/go-autorest/autorest" - "github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities" -) - -func Example() error { - accountName := "storageaccount1" - storageAccountKey := "ABC123...." - tableName := "mytable" - - storageAuth := autorest.NewSharedKeyLiteTableAuthorizer(accountName, storageAccountKey) - entitiesClient := entities.New() - entitiesClient.Client.Authorizer = storageAuth - - ctx := context.TODO() - input := entities.InsertEntityInput{ - PartitionKey: "abc", - RowKey: "123", - MetaDataLevel: entities.NoMetaData, - Entity: map[string]interface{}{ - "title": "Don't Kill My Vibe", - "artist": "Sigrid", - }, - } - if _, err := entitiesClient.Insert(ctx, accountName, tableName, input); err != nil { - return fmt.Errorf("Error creating Entity: %s", err) - } - - return nil -} -``` \ No newline at end of file diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/api.go deleted file mode 100644 index d4d20a7234577..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/api.go +++ /dev/null @@ -1,17 +0,0 @@ -package entities - -import ( - "context" - - "github.com/Azure/go-autorest/autorest" -) - -type StorageTableEntity interface { - Delete(ctx context.Context, accountName, tableName string, input DeleteEntityInput) (result autorest.Response, err error) - Insert(ctx context.Context, accountName, tableName string, input InsertEntityInput) (result autorest.Response, err error) - InsertOrReplace(ctx context.Context, accountName, tableName string, input InsertOrReplaceEntityInput) (result autorest.Response, err error) - InsertOrMerge(ctx context.Context, accountName, tableName string, input InsertOrMergeEntityInput) (result autorest.Response, err error) - Query(ctx context.Context, accountName, tableName string, input QueryEntitiesInput) (result QueryEntitiesResult, err error) - Get(ctx context.Context, accountName, tableName string, input GetEntityInput) (result GetEntityResult, err error) - GetResourceID(accountName, tableName, partitionKey, rowKey string) string -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/client.go deleted file mode 100644 index 17e9d759fb9e6..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/client.go +++ /dev/null @@ -1,25 +0,0 @@ -package entities - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Client is the base client for Table Storage Shares. -type Client struct { - autorest.Client - BaseURI string -} - -// New creates an instance of the Client client. -func New() Client { - return NewWithEnvironment(azure.PublicCloud) -} - -// NewWithEnvironment creates an instance of the Client client. -func NewWithEnvironment(environment azure.Environment) Client { - return Client{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: environment.StorageEndpointSuffix, - } -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/delete.go deleted file mode 100644 index 83e9188e5e9ea..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/delete.go +++ /dev/null @@ -1,99 +0,0 @@ -package entities - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type DeleteEntityInput struct { - // When inserting an entity into a table, you must specify values for the PartitionKey and RowKey system properties. - // Together, these properties form the primary key and must be unique within the table. - // Both the PartitionKey and RowKey values must be string values; each key value may be up to 64 KB in size. - // If you are using an integer value for the key value, you should convert the integer to a fixed-width string, - // because they are canonically sorted. For example, you should convert the value 1 to 0000001 to ensure proper sorting. - RowKey string - PartitionKey string -} - -// Delete deletes an existing entity in a table. -func (client Client) Delete(ctx context.Context, accountName, tableName string, input DeleteEntityInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("entities.Client", "Delete", "`accountName` cannot be an empty string.") - } - if tableName == "" { - return result, validation.NewError("entities.Client", "Delete", "`tableName` cannot be an empty string.") - } - if input.PartitionKey == "" { - return result, validation.NewError("entities.Client", "Delete", "`input.PartitionKey` cannot be an empty string.") - } - if input.RowKey == "" { - return result, validation.NewError("entities.Client", "Delete", "`input.RowKey` cannot be an empty string.") - } - - req, err := client.DeletePreparer(ctx, accountName, tableName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "entities.Client", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "entities.Client", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "entities.Client", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client Client) DeletePreparer(ctx context.Context, accountName, tableName string, input DeleteEntityInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "tableName": autorest.Encode("path", tableName), - "partitionKey": autorest.Encode("path", input.PartitionKey), - "rowKey": autorest.Encode("path", input.RowKey), - } - - headers := map[string]interface{}{ - // TODO: support for eTags - "If-Match": "*", - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(endpoints.GetTableEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{tableName}(PartitionKey='{partitionKey}', RowKey='{rowKey}')", pathParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client Client) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/get.go deleted file mode 100644 index bdb40180b54d0..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/get.go +++ /dev/null @@ -1,108 +0,0 @@ -package entities - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type GetEntityInput struct { - PartitionKey string - RowKey string - - // The Level of MetaData which should be returned - MetaDataLevel MetaDataLevel -} - -type GetEntityResult struct { - autorest.Response - - Entity map[string]interface{} -} - -// Get queries entities in a table and includes the $filter and $select options. -func (client Client) Get(ctx context.Context, accountName, tableName string, input GetEntityInput) (result GetEntityResult, err error) { - if accountName == "" { - return result, validation.NewError("entities.Client", "Get", "`accountName` cannot be an empty string.") - } - if tableName == "" { - return result, validation.NewError("entities.Client", "Get", "`tableName` cannot be an empty string.") - } - if input.PartitionKey == "" { - return result, validation.NewError("entities.Client", "Get", "`input.PartitionKey` cannot be an empty string.") - } - if input.RowKey == "" { - return result, validation.NewError("entities.Client", "Get", "`input.RowKey` cannot be an empty string.") - } - - req, err := client.GetPreparer(ctx, accountName, tableName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "entities.Client", "Get", nil, "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "entities.Client", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "entities.Client", "Get", resp, "Failure responding to request") - return - } - - return -} - -// GetPreparer prepares the Get request. -func (client Client) GetPreparer(ctx context.Context, accountName, tableName string, input GetEntityInput) (*http.Request, error) { - - pathParameters := map[string]interface{}{ - "tableName": autorest.Encode("path", tableName), - "partitionKey": autorest.Encode("path", input.PartitionKey), - "rowKey": autorest.Encode("path", input.RowKey), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "Accept": fmt.Sprintf("application/json;odata=%s", input.MetaDataLevel), - "DataServiceVersion": "3.0;NetFx", - "MaxDataServiceVersion": "3.0;NetFx", - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetTableEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{tableName}(PartitionKey='{partitionKey}',RowKey='{rowKey}')", pathParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetSender sends the Get request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client Client) GetResponder(resp *http.Response) (result GetEntityResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result.Entity), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/insert.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/insert.go deleted file mode 100644 index 92b05cef54990..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/insert.go +++ /dev/null @@ -1,112 +0,0 @@ -package entities - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type InsertEntityInput struct { - // The level of MetaData provided for this Entity - MetaDataLevel MetaDataLevel - - // The Entity which should be inserted, by default all values are strings - // To explicitly type a property, specify the appropriate OData data type by setting - // the m:type attribute within the property definition - Entity map[string]interface{} - - // When inserting an entity into a table, you must specify values for the PartitionKey and RowKey system properties. - // Together, these properties form the primary key and must be unique within the table. - // Both the PartitionKey and RowKey values must be string values; each key value may be up to 64 KB in size. - // If you are using an integer value for the key value, you should convert the integer to a fixed-width string, - // because they are canonically sorted. For example, you should convert the value 1 to 0000001 to ensure proper sorting. - RowKey string - PartitionKey string -} - -// Insert inserts a new entity into a table. -func (client Client) Insert(ctx context.Context, accountName, tableName string, input InsertEntityInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("entities.Client", "Insert", "`accountName` cannot be an empty string.") - } - if tableName == "" { - return result, validation.NewError("entities.Client", "Insert", "`tableName` cannot be an empty string.") - } - if input.PartitionKey == "" { - return result, validation.NewError("entities.Client", "Insert", "`input.PartitionKey` cannot be an empty string.") - } - if input.RowKey == "" { - return result, validation.NewError("entities.Client", "Insert", "`input.RowKey` cannot be an empty string.") - } - - req, err := client.InsertPreparer(ctx, accountName, tableName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "entities.Client", "Insert", nil, "Failure preparing request") - return - } - - resp, err := client.InsertSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "entities.Client", "Insert", resp, "Failure sending request") - return - } - - result, err = client.InsertResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "entities.Client", "Insert", resp, "Failure responding to request") - return - } - - return -} - -// InsertPreparer prepares the Insert request. -func (client Client) InsertPreparer(ctx context.Context, accountName, tableName string, input InsertEntityInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "tableName": autorest.Encode("path", tableName), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "Accept": fmt.Sprintf("application/json;odata=%s", input.MetaDataLevel), - "Prefer": "return-no-content", - } - - input.Entity["PartitionKey"] = input.PartitionKey - input.Entity["RowKey"] = input.RowKey - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json"), - autorest.AsPost(), - autorest.WithBaseURL(endpoints.GetTableEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{tableName}", pathParameters), - autorest.WithJSON(input.Entity), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// InsertSender sends the Insert request. The method will close the -// http.Response Body if it receives an error. -func (client Client) InsertSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// InsertResponder handles the response to the Insert request. The method always -// closes the http.Response Body. -func (client Client) InsertResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/insert_or_merge.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/insert_or_merge.go deleted file mode 100644 index 1fb4ed3df164d..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/insert_or_merge.go +++ /dev/null @@ -1,108 +0,0 @@ -package entities - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type InsertOrMergeEntityInput struct { - // The Entity which should be inserted, by default all values are strings - // To explicitly type a property, specify the appropriate OData data type by setting - // the m:type attribute within the property definition - Entity map[string]interface{} - - // When inserting an entity into a table, you must specify values for the PartitionKey and RowKey system properties. - // Together, these properties form the primary key and must be unique within the table. - // Both the PartitionKey and RowKey values must be string values; each key value may be up to 64 KB in size. - // If you are using an integer value for the key value, you should convert the integer to a fixed-width string, - // because they are canonically sorted. For example, you should convert the value 1 to 0000001 to ensure proper sorting. - RowKey string - PartitionKey string -} - -// InsertOrMerge updates an existing entity or inserts a new entity if it does not exist in the table. -// Because this operation can insert or update an entity, it is also known as an upsert operation. -func (client Client) InsertOrMerge(ctx context.Context, accountName, tableName string, input InsertOrMergeEntityInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("entities.Client", "InsertOrMerge", "`accountName` cannot be an empty string.") - } - if tableName == "" { - return result, validation.NewError("entities.Client", "InsertOrMerge", "`tableName` cannot be an empty string.") - } - if input.PartitionKey == "" { - return result, validation.NewError("entities.Client", "InsertOrMerge", "`input.PartitionKey` cannot be an empty string.") - } - if input.RowKey == "" { - return result, validation.NewError("entities.Client", "InsertOrMerge", "`input.RowKey` cannot be an empty string.") - } - - req, err := client.InsertOrMergePreparer(ctx, accountName, tableName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "entities.Client", "InsertOrMerge", nil, "Failure preparing request") - return - } - - resp, err := client.InsertOrMergeSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "entities.Client", "InsertOrMerge", resp, "Failure sending request") - return - } - - result, err = client.InsertOrMergeResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "entities.Client", "InsertOrMerge", resp, "Failure responding to request") - return - } - - return -} - -// InsertOrMergePreparer prepares the InsertOrMerge request. -func (client Client) InsertOrMergePreparer(ctx context.Context, accountName, tableName string, input InsertOrMergeEntityInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "tableName": autorest.Encode("path", tableName), - "partitionKey": autorest.Encode("path", input.PartitionKey), - "rowKey": autorest.Encode("path", input.RowKey), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "Accept": "application/json", - "Prefer": "return-no-content", - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json"), - autorest.AsMerge(), - autorest.WithBaseURL(endpoints.GetTableEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{tableName}(PartitionKey='{partitionKey}', RowKey='{rowKey}')", pathParameters), - autorest.WithJSON(input.Entity), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// InsertOrMergeSender sends the InsertOrMerge request. The method will close the -// http.Response Body if it receives an error. -func (client Client) InsertOrMergeSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// InsertOrMergeResponder handles the response to the InsertOrMerge request. The method always -// closes the http.Response Body. -func (client Client) InsertOrMergeResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/insert_or_replace.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/insert_or_replace.go deleted file mode 100644 index 036ba5de5fe7f..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/insert_or_replace.go +++ /dev/null @@ -1,108 +0,0 @@ -package entities - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type InsertOrReplaceEntityInput struct { - // The Entity which should be inserted, by default all values are strings - // To explicitly type a property, specify the appropriate OData data type by setting - // the m:type attribute within the property definition - Entity map[string]interface{} - - // When inserting an entity into a table, you must specify values for the PartitionKey and RowKey system properties. - // Together, these properties form the primary key and must be unique within the table. - // Both the PartitionKey and RowKey values must be string values; each key value may be up to 64 KB in size. - // If you are using an integer value for the key value, you should convert the integer to a fixed-width string, - // because they are canonically sorted. For example, you should convert the value 1 to 0000001 to ensure proper sorting. - RowKey string - PartitionKey string -} - -// InsertOrReplace replaces an existing entity or inserts a new entity if it does not exist in the table. -// Because this operation can insert or update an entity, it is also known as an upsert operation. -func (client Client) InsertOrReplace(ctx context.Context, accountName, tableName string, input InsertOrReplaceEntityInput) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("entities.Client", "InsertOrReplace", "`accountName` cannot be an empty string.") - } - if tableName == "" { - return result, validation.NewError("entities.Client", "InsertOrReplace", "`tableName` cannot be an empty string.") - } - if input.PartitionKey == "" { - return result, validation.NewError("entities.Client", "InsertOrReplace", "`input.PartitionKey` cannot be an empty string.") - } - if input.RowKey == "" { - return result, validation.NewError("entities.Client", "InsertOrReplace", "`input.RowKey` cannot be an empty string.") - } - - req, err := client.InsertOrReplacePreparer(ctx, accountName, tableName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "entities.Client", "InsertOrReplace", nil, "Failure preparing request") - return - } - - resp, err := client.InsertOrReplaceSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "entities.Client", "InsertOrReplace", resp, "Failure sending request") - return - } - - result, err = client.InsertOrReplaceResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "entities.Client", "InsertOrReplace", resp, "Failure responding to request") - return - } - - return -} - -// InsertOrReplacePreparer prepares the InsertOrReplace request. -func (client Client) InsertOrReplacePreparer(ctx context.Context, accountName, tableName string, input InsertOrReplaceEntityInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "tableName": autorest.Encode("path", tableName), - "partitionKey": autorest.Encode("path", input.PartitionKey), - "rowKey": autorest.Encode("path", input.RowKey), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "Accept": "application/json", - "Prefer": "return-no-content", - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json"), - autorest.AsMerge(), - autorest.WithBaseURL(endpoints.GetTableEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{tableName}(PartitionKey='{partitionKey}', RowKey='{rowKey}')", pathParameters), - autorest.WithJSON(input.Entity), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// InsertOrReplaceSender sends the InsertOrReplace request. The method will close the -// http.Response Body if it receives an error. -func (client Client) InsertOrReplaceSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// InsertOrReplaceResponder handles the response to the InsertOrReplace request. The method always -// closes the http.Response Body. -func (client Client) InsertOrReplaceResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/query.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/query.go deleted file mode 100644 index c1ba3706be7d3..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/query.go +++ /dev/null @@ -1,162 +0,0 @@ -package entities - -import ( - "context" - "fmt" - "net/http" - "strings" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type QueryEntitiesInput struct { - // An optional OData filter - Filter *string - - // An optional comma-separated - PropertyNamesToSelect *[]string - - // An optional OData top - Top *int - - PartitionKey string - RowKey string - - // The Level of MetaData which should be returned - MetaDataLevel MetaDataLevel - - // The Next Partition Key used to load data from a previous point - NextPartitionKey *string - - // The Next Row Key used to load data from a previous point - NextRowKey *string -} - -type QueryEntitiesResult struct { - autorest.Response - - NextPartitionKey string - NextRowKey string - - MetaData string `json:"odata.metadata,omitempty"` - Entities []map[string]interface{} `json:"value"` -} - -// Query queries entities in a table and includes the $filter and $select options. -func (client Client) Query(ctx context.Context, accountName, tableName string, input QueryEntitiesInput) (result QueryEntitiesResult, err error) { - if accountName == "" { - return result, validation.NewError("entities.Client", "Query", "`accountName` cannot be an empty string.") - } - if tableName == "" { - return result, validation.NewError("entities.Client", "Query", "`tableName` cannot be an empty string.") - } - - req, err := client.QueryPreparer(ctx, accountName, tableName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "entities.Client", "Query", nil, "Failure preparing request") - return - } - - resp, err := client.QuerySender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "entities.Client", "Query", resp, "Failure sending request") - return - } - - result, err = client.QueryResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "entities.Client", "Query", resp, "Failure responding to request") - return - } - - return -} - -// QueryPreparer prepares the Query request. -func (client Client) QueryPreparer(ctx context.Context, accountName, tableName string, input QueryEntitiesInput) (*http.Request, error) { - - pathParameters := map[string]interface{}{ - "tableName": autorest.Encode("path", tableName), - "additionalParameters": "", - } - - //PartitionKey='',RowKey='' - additionalParams := make([]string, 0) - if input.PartitionKey != "" { - additionalParams = append(additionalParams, fmt.Sprintf("PartitionKey='%s'", input.PartitionKey)) - } - if input.RowKey != "" { - additionalParams = append(additionalParams, fmt.Sprintf("RowKey='%s'", input.RowKey)) - } - if len(additionalParams) > 0 { - pathParameters["additionalParameters"] = autorest.Encode("path", strings.Join(additionalParams, ",")) - } - - queryParameters := map[string]interface{}{} - - if input.Filter != nil { - queryParameters["$filter"] = autorest.Encode("query", *input.Filter) - } - - if input.PropertyNamesToSelect != nil { - queryParameters["$select"] = autorest.Encode("query", strings.Join(*input.PropertyNamesToSelect, ",")) - } - - if input.Top != nil { - queryParameters["$top"] = autorest.Encode("query", *input.Top) - } - - if input.NextPartitionKey != nil { - queryParameters["NextPartitionKey"] = *input.NextPartitionKey - } - - if input.NextRowKey != nil { - queryParameters["NextRowKey"] = *input.NextRowKey - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "Accept": fmt.Sprintf("application/json;odata=%s", input.MetaDataLevel), - "DataServiceVersion": "3.0;NetFx", - "MaxDataServiceVersion": "3.0;NetFx", - } - - // GET /myaccount/Customers()?$filter=(Rating%20ge%203)%20and%20(Rating%20le%206)&$select=PartitionKey,RowKey,Address,CustomerSince - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetTableEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{tableName}({additionalParameters})", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// QuerySender sends the Query request. The method will close the -// http.Response Body if it receives an error. -func (client Client) QuerySender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// QueryResponder handles the response to the Query request. The method always -// closes the http.Response Body. -func (client Client) QueryResponder(resp *http.Response) (result QueryEntitiesResult, err error) { - if resp != nil && resp.Header != nil { - result.NextPartitionKey = resp.Header.Get("x-ms-continuation-NextPartitionKey") - result.NextRowKey = resp.Header.Get("x-ms-continuation-NextRowKey") - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/resource_id.go deleted file mode 100644 index 249671dc91bfe..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/resource_id.go +++ /dev/null @@ -1,91 +0,0 @@ -package entities - -import ( - "fmt" - "net/url" - "strings" - - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// GetResourceID returns the Resource ID for the given Entity -// This can be useful when, for example, you're using this as a unique identifier -func (client Client) GetResourceID(accountName, tableName, partitionKey, rowKey string) string { - domain := endpoints.GetTableEndpoint(client.BaseURI, accountName) - return fmt.Sprintf("%s/%s(PartitionKey='%s',RowKey='%s')", domain, tableName, partitionKey, rowKey) -} - -type ResourceID struct { - AccountName string - TableName string - PartitionKey string - RowKey string -} - -// ParseResourceID parses the specified Resource ID and returns an object which -// can be used to look up the specified Entity within the specified Table -func ParseResourceID(id string) (*ResourceID, error) { - // example: https://account1.table.core.chinacloudapi.cn/table1(PartitionKey='partition1',RowKey='row1') - if id == "" { - return nil, fmt.Errorf("`id` was empty") - } - - uri, err := url.Parse(id) - if err != nil { - return nil, fmt.Errorf("Error parsing ID as a URL: %s", err) - } - - accountName, err := endpoints.GetAccountNameFromEndpoint(uri.Host) - if err != nil { - return nil, fmt.Errorf("Error parsing Account Name: %s", err) - } - - // assume there a `Table('')` - path := strings.TrimPrefix(uri.Path, "/") - if !strings.Contains(uri.Path, "(") || !strings.HasSuffix(uri.Path, ")") { - return nil, fmt.Errorf("Expected the Table Name to be in the format `tables(PartitionKey='',RowKey='')` but got %q", path) - } - - // NOTE: honestly this could probably be a RegEx, but this seemed like the simplest way to - // allow these two fields to be specified in either order - indexOfBracket := strings.IndexByte(path, '(') - tableName := path[0:indexOfBracket] - - // trim off the brackets - temp := strings.TrimPrefix(path, fmt.Sprintf("%s(", tableName)) - temp = strings.TrimSuffix(temp, ")") - - dictionary := strings.Split(temp, ",") - partitionKey := "" - rowKey := "" - for _, v := range dictionary { - split := strings.Split(v, "=") - if len(split) != 2 { - return nil, fmt.Errorf("Expected 2 segments but got %d for %q", len(split), v) - } - - key := split[0] - value := strings.TrimSuffix(strings.TrimPrefix(split[1], "'"), "'") - if strings.EqualFold(key, "PartitionKey") { - partitionKey = value - } else if strings.EqualFold(key, "RowKey") { - rowKey = value - } else { - return nil, fmt.Errorf("Unexpected Key %q", key) - } - } - - if partitionKey == "" { - return nil, fmt.Errorf("Expected a PartitionKey but didn't get one") - } - if rowKey == "" { - return nil, fmt.Errorf("Expected a RowKey but didn't get one") - } - - return &ResourceID{ - AccountName: *accountName, - TableName: tableName, - PartitionKey: partitionKey, - RowKey: rowKey, - }, nil -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/version.go deleted file mode 100644 index 6270953c7923a..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/version.go +++ /dev/null @@ -1,14 +0,0 @@ -package entities - -import ( - "fmt" - - "github.com/tombuildsstuff/giovanni/version" -) - -// APIVersion is the version of the API used for all Storage API Operations -const APIVersion = "2020-08-04" - -func UserAgent() string { - return fmt.Sprintf("tombuildsstuff/giovanni/%s storage/%s", version.Number, APIVersion) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/README.md b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/README.md deleted file mode 100644 index 40ec34959a79c..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/README.md +++ /dev/null @@ -1,39 +0,0 @@ -## Table Storage Tables SDK for API version 2020-08-04 - -This package allows you to interact with the Tables Table Storage API - -### Supported Authorizers - -* SharedKeyLite (Table) - -### Example Usage - -```go -package main - -import ( - "context" - "fmt" - "time" - - "github.com/Azure/go-autorest/autorest" - "github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables" -) - -func Example() error { - accountName := "storageaccount1" - storageAccountKey := "ABC123...." - tableName := "mytable" - - storageAuth := autorest.NewSharedKeyLiteTableAuthorizer(accountName, storageAccountKey) - tablesClient := tables.New() - tablesClient.Client.Authorizer = storageAuth - - ctx := context.TODO() - if _, err := tablesClient.Insert(ctx, accountName, tableName); err != nil { - return fmt.Errorf("Error creating Table: %s", err) - } - - return nil -} -``` \ No newline at end of file diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/acl_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/acl_get.go deleted file mode 100644 index 0ef00006530fd..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/acl_get.go +++ /dev/null @@ -1,93 +0,0 @@ -package tables - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type GetACLResult struct { - autorest.Response - - SignedIdentifiers []SignedIdentifier `xml:"SignedIdentifier"` -} - -// GetACL returns the Access Control List for the specified Table -func (client Client) GetACL(ctx context.Context, accountName, tableName string) (result GetACLResult, err error) { - if accountName == "" { - return result, validation.NewError("tables.Client", "GetACL", "`accountName` cannot be an empty string.") - } - if tableName == "" { - return result, validation.NewError("tables.Client", "GetACL", "`tableName` cannot be an empty string.") - } - - req, err := client.GetACLPreparer(ctx, accountName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "tables.Client", "GetACL", nil, "Failure preparing request") - return - } - - resp, err := client.GetACLSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "tables.Client", "GetACL", resp, "Failure sending request") - return - } - - result, err = client.GetACLResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "tables.Client", "GetACL", resp, "Failure responding to request") - return - } - - return -} - -// GetACLPreparer prepares the GetACL request. -func (client Client) GetACLPreparer(ctx context.Context, accountName, tableName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "tableName": autorest.Encode("path", tableName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "acl"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetTableEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{tableName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// GetACLSender sends the GetACL request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetACLSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// GetACLResponder handles the response to the GetACL request. The method always -// closes the http.Response Body. -func (client Client) GetACLResponder(resp *http.Response) (result GetACLResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingXML(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/acl_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/acl_set.go deleted file mode 100644 index c26bffc834d18..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/acl_set.go +++ /dev/null @@ -1,98 +0,0 @@ -package tables - -import ( - "context" - "encoding/xml" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type setAcl struct { - SignedIdentifiers []SignedIdentifier `xml:"SignedIdentifier"` - - XMLName xml.Name `xml:"SignedIdentifiers"` -} - -// SetACL sets the specified Access Control List for the specified Table -func (client Client) SetACL(ctx context.Context, accountName, tableName string, acls []SignedIdentifier) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("tables.Client", "SetACL", "`accountName` cannot be an empty string.") - } - if tableName == "" { - return result, validation.NewError("tables.Client", "SetACL", "`tableName` cannot be an empty string.") - } - - req, err := client.SetACLPreparer(ctx, accountName, tableName, acls) - if err != nil { - err = autorest.NewErrorWithError(err, "tables.Client", "SetACL", nil, "Failure preparing request") - return - } - - resp, err := client.SetACLSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "tables.Client", "SetACL", resp, "Failure sending request") - return - } - - result, err = client.SetACLResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "tables.Client", "SetACL", resp, "Failure responding to request") - return - } - - return -} - -// SetACLPreparer prepares the SetACL request. -func (client Client) SetACLPreparer(ctx context.Context, accountName, tableName string, acls []SignedIdentifier) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "tableName": autorest.Encode("path", tableName), - } - - queryParameters := map[string]interface{}{ - "comp": autorest.Encode("query", "acl"), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } - - input := setAcl{ - SignedIdentifiers: acls, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/xml; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetTableEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{tableName}", pathParameters), - autorest.WithQueryParameters(queryParameters), - autorest.WithHeaders(headers), - autorest.WithXML(&input)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// SetACLSender sends the SetACL request. The method will close the -// http.Response Body if it receives an error. -func (client Client) SetACLSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// SetACLResponder handles the response to the SetACL request. The method always -// closes the http.Response Body. -func (client Client) SetACLResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/api.go deleted file mode 100644 index d869819ff21ed..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/api.go +++ /dev/null @@ -1,17 +0,0 @@ -package tables - -import ( - "context" - - "github.com/Azure/go-autorest/autorest" -) - -type StorageTable interface { - Delete(ctx context.Context, accountName, tableName string) (result autorest.Response, err error) - Exists(ctx context.Context, accountName, tableName string) (result autorest.Response, err error) - GetACL(ctx context.Context, accountName, tableName string) (result GetACLResult, err error) - Create(ctx context.Context, accountName, tableName string) (result autorest.Response, err error) - GetResourceID(accountName, tableName string) string - Query(ctx context.Context, accountName string, metaDataLevel MetaDataLevel) (result GetResult, err error) - SetACL(ctx context.Context, accountName, tableName string, acls []SignedIdentifier) (result autorest.Response, err error) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/client.go deleted file mode 100644 index 56724b9202c97..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/client.go +++ /dev/null @@ -1,25 +0,0 @@ -package tables - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" -) - -// Client is the base client for Table Storage Shares. -type Client struct { - autorest.Client - BaseURI string -} - -// New creates an instance of the Client client. -func New() Client { - return NewWithEnvironment(azure.PublicCloud) -} - -// NewWithEnvironment creates an instance of the Client client. -func NewWithEnvironment(environment azure.Environment) Client { - return Client{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: environment.StorageEndpointSuffix, - } -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/create.go deleted file mode 100644 index 561f57460dafc..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/create.go +++ /dev/null @@ -1,90 +0,0 @@ -package tables - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type createTableRequest struct { - TableName string `json:"TableName"` -} - -// Create creates a new table in the storage account. -func (client Client) Create(ctx context.Context, accountName, tableName string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("tables.Client", "Create", "`accountName` cannot be an empty string.") - } - if tableName == "" { - return result, validation.NewError("tables.Client", "Create", "`tableName` cannot be an empty string.") - } - - req, err := client.CreatePreparer(ctx, accountName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "tables.Client", "Create", nil, "Failure preparing request") - return - } - - resp, err := client.CreateSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "tables.Client", "Create", resp, "Failure sending request") - return - } - - result, err = client.CreateResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "tables.Client", "Create", resp, "Failure responding to request") - return - } - - return -} - -// CreatePreparer prepares the Create request. -func (client Client) CreatePreparer(ctx context.Context, accountName, tableName string) (*http.Request, error) { - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - // NOTE: we could support returning metadata here, but it doesn't appear to be directly useful - // vs making a request using the Get methods as-necessary? - "Accept": "application/json;odata=nometadata", - "Prefer": "return-no-content", - } - - body := createTableRequest{ - TableName: tableName, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json"), - autorest.AsPost(), - autorest.WithBaseURL(endpoints.GetTableEndpoint(client.BaseURI, accountName)), - autorest.WithPath("/Tables"), - autorest.WithJSON(body), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// CreateSender sends the Create request. The method will close the -// http.Response Body if it receives an error. -func (client Client) CreateSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// CreateResponder handles the response to the Create request. The method always -// closes the http.Response Body. -func (client Client) CreateResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/delete.go deleted file mode 100644 index 5b5ec86d9ca9c..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/delete.go +++ /dev/null @@ -1,79 +0,0 @@ -package tables - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// Delete deletes the specified table and any data it contains. -func (client Client) Delete(ctx context.Context, accountName, tableName string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("tables.Client", "Delete", "`accountName` cannot be an empty string.") - } - if tableName == "" { - return result, validation.NewError("tables.Client", "Delete", "`tableName` cannot be an empty string.") - } - - req, err := client.DeletePreparer(ctx, accountName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "tables.Client", "Delete", nil, "Failure preparing request") - return - } - - resp, err := client.DeleteSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "tables.Client", "Delete", resp, "Failure sending request") - return - } - - result, err = client.DeleteResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "tables.Client", "Delete", resp, "Failure responding to request") - return - } - - return -} - -// DeletePreparer prepares the Delete request. -func (client Client) DeletePreparer(ctx context.Context, accountName, tableName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "tableName": autorest.Encode("path", tableName), - } - - // NOTE: whilst the API documentation says that API Version is Optional - // apparently specifying it causes an "invalid content type" to always be returned - // as such we omit it here :shrug: - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(endpoints.GetTableEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/Tables('{tableName}')", pathParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// DeleteSender sends the Delete request. The method will close the -// http.Response Body if it receives an error. -func (client Client) DeleteSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client Client) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusNoContent), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/exists.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/exists.go deleted file mode 100644 index 6abe4f0bbd425..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/exists.go +++ /dev/null @@ -1,86 +0,0 @@ -package tables - -import ( - "context" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// Exists checks that the specified table exists -func (client Client) Exists(ctx context.Context, accountName, tableName string) (result autorest.Response, err error) { - if accountName == "" { - return result, validation.NewError("tables.Client", "Exists", "`accountName` cannot be an empty string.") - } - if tableName == "" { - return result, validation.NewError("tables.Client", "Exists", "`tableName` cannot be an empty string.") - } - - req, err := client.ExistsPreparer(ctx, accountName, tableName) - if err != nil { - err = autorest.NewErrorWithError(err, "tables.Client", "Exists", nil, "Failure preparing request") - return - } - - resp, err := client.ExistsSender(req) - if err != nil { - result = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "tables.Client", "Exists", resp, "Failure sending request") - return - } - - result, err = client.ExistsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "tables.Client", "Exists", resp, "Failure responding to request") - return - } - - return -} - -// ExistsPreparer prepares the Exists request. -func (client Client) ExistsPreparer(ctx context.Context, accountName, tableName string) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "tableName": autorest.Encode("path", tableName), - } - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "Accept": "application/json;odata=nometadata", - } - - // NOTE: whilst the API documentation says that API Version is Optional - // apparently specifying it causes an "invalid content type" to always be returned - // as such we omit it here :shrug: - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.AsContentType("application/json"), - autorest.WithBaseURL(endpoints.GetTableEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/Tables('{tableName}')", pathParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ExistsSender sends the Exists request. The method will close the -// http.Response Body if it receives an error. -func (client Client) ExistsSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ExistsResponder handles the response to the Exists request. The method always -// closes the http.Response Body. -func (client Client) ExistsResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/query.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/query.go deleted file mode 100644 index 475370f0cbd5e..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/query.go +++ /dev/null @@ -1,87 +0,0 @@ -package tables - -import ( - "context" - "fmt" - "net/http" - - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -type GetResult struct { - autorest.Response - - MetaData string `json:"odata.metadata,omitempty"` - Tables []GetResultItem `json:"value"` -} - -// Query returns a list of tables under the specified account. -func (client Client) Query(ctx context.Context, accountName string, metaDataLevel MetaDataLevel) (result GetResult, err error) { - if accountName == "" { - return result, validation.NewError("tables.Client", "Query", "`accountName` cannot be an empty string.") - } - - req, err := client.QueryPreparer(ctx, accountName, metaDataLevel) - if err != nil { - err = autorest.NewErrorWithError(err, "tables.Client", "Query", nil, "Failure preparing request") - return - } - - resp, err := client.QuerySender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "tables.Client", "Query", resp, "Failure sending request") - return - } - - result, err = client.QueryResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "tables.Client", "Query", resp, "Failure responding to request") - return - } - - return -} - -// QueryPreparer prepares the Query request. -func (client Client) QueryPreparer(ctx context.Context, accountName string, metaDataLevel MetaDataLevel) (*http.Request, error) { - // NOTE: whilst this supports ContinuationTokens and 'Top' - // it appears that 'Skip' returns a '501 Not Implemented' - // as such, we intentionally don't support those right now - - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "Accept": fmt.Sprintf("application/json;odata=%s", metaDataLevel), - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(endpoints.GetTableEndpoint(client.BaseURI, accountName)), - autorest.WithPath("/Tables"), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// QuerySender sends the Query request. The method will close the -// http.Response Body if it receives an error. -func (client Client) QuerySender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// QueryResponder handles the response to the Query request. The method always -// closes the http.Response Body. -func (client Client) QueryResponder(resp *http.Response) (result GetResult, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - - return -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/resource_id.go deleted file mode 100644 index 4ceae10150e0c..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/resource_id.go +++ /dev/null @@ -1,54 +0,0 @@ -package tables - -import ( - "fmt" - "net/url" - "strings" - - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" -) - -// GetResourceID returns the Resource ID for the given Table -// This can be useful when, for example, you're using this as a unique identifier -func (client Client) GetResourceID(accountName, tableName string) string { - domain := endpoints.GetTableEndpoint(client.BaseURI, accountName) - return fmt.Sprintf("%s/Tables('%s')", domain, tableName) -} - -type ResourceID struct { - AccountName string - TableName string -} - -// ParseResourceID parses the Resource ID and returns an object which -// can be used to interact with the Table within the specified Storage Account -func ParseResourceID(id string) (*ResourceID, error) { - // example: https://foo.table.core.windows.net/Table('foo') - if id == "" { - return nil, fmt.Errorf("`id` was empty") - } - - uri, err := url.Parse(id) - if err != nil { - return nil, fmt.Errorf("Error parsing ID as a URL: %s", err) - } - - accountName, err := endpoints.GetAccountNameFromEndpoint(uri.Host) - if err != nil { - return nil, fmt.Errorf("Error parsing Account Name: %s", err) - } - - // assume there a `Table('')` - path := strings.TrimPrefix(uri.Path, "/") - if !strings.HasPrefix(path, "Tables('") || !strings.HasSuffix(path, "')") { - return nil, fmt.Errorf("Expected the Table Name to be in the format `Tables('name')` but got %q", path) - } - - // strip off the `Table('')` - tableName := strings.TrimPrefix(uri.Path, "/Tables('") - tableName = strings.TrimSuffix(tableName, "')") - return &ResourceID{ - AccountName: *accountName, - TableName: tableName, - }, nil -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/version.go deleted file mode 100644 index 05a61a8a7c9d2..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/version.go +++ /dev/null @@ -1,14 +0,0 @@ -package tables - -import ( - "fmt" - - "github.com/tombuildsstuff/giovanni/version" -) - -// APIVersion is the version of the API used for all Storage API Operations -const APIVersion = "2020-08-04" - -func UserAgent() string { - return fmt.Sprintf("tombuildsstuff/giovanni/%s storage/%s", version.Number, APIVersion) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts/README.md b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/README.md similarity index 87% rename from vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts/README.md rename to vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/README.md index 5fa24a74e9bb7..01fdc3f22ded5 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts/README.md +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/README.md @@ -1,4 +1,4 @@ -## Blob Storage Account SDK for API version 2020-08-04 +## Blob Storage Account SDK for API version 2023-11-03 This package allows you to interact with the Accounts Blob Storage API @@ -16,8 +16,7 @@ import ( "fmt" "time" - "github.com/Azure/go-autorest/autorest" - "github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts" ) func Example() error { diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/client.go new file mode 100644 index 0000000000000..df5fa1d722ea2 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/client.go @@ -0,0 +1,22 @@ +package accounts + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/storage" +) + +// Client is the base client for Blob Storage Blobs. +type Client struct { + Client *storage.Client +} + +func NewWithBaseUri(baseUri string) (*Client, error) { + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) + if err != nil { + return nil, fmt.Errorf("building base client: %+v", err) + } + return &Client{ + Client: baseClient, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/get_service_properties.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/get_service_properties.go new file mode 100644 index 0000000000000..fce040b887a2a --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/get_service_properties.go @@ -0,0 +1,54 @@ +package accounts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" +) + +type GetServicePropertiesResult struct { + StorageServiceProperties + HttpResponse *http.Response +} + +func (c Client) GetServiceProperties(ctx context.Context, accountName string) (result GetServicePropertiesResult, err error) { + if accountName == "" { + return result, fmt.Errorf("`accountName` cannot be an empty string") + } + + opts := client.RequestOptions{ + ContentType: "text/xml", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: servicePropertiesOptions{}, + Path: "/", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts/models.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/models.go similarity index 97% rename from vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts/models.go rename to vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/models.go index 3a2891439beeb..c36d45ecb8c54 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts/models.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/models.go @@ -1,11 +1,5 @@ package accounts -import "github.com/Azure/go-autorest/autorest" - -type SetServicePropertiesResult struct { - autorest.Response -} - type StorageServiceProperties struct { // Cors - Specifies CORS rules for the Blob service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Blob service. Cors *CorsRules `xml:"Cors,omitempty"` diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/resource_id.go new file mode 100644 index 0000000000000..e6c6303f9f79b --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/resource_id.go @@ -0,0 +1,155 @@ +package accounts + +import ( + "fmt" + "net/url" + "strings" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +type SubDomainType string + +const ( + BlobSubDomainType SubDomainType = "blob" + DataLakeStoreSubDomainType SubDomainType = "dfs" + FileSubDomainType SubDomainType = "file" + QueueSubDomainType SubDomainType = "queue" + TableSubDomainType SubDomainType = "table" +) + +func PossibleValuesForSubDomainType() []SubDomainType { + return []SubDomainType{ + BlobSubDomainType, + DataLakeStoreSubDomainType, + FileSubDomainType, + QueueSubDomainType, + TableSubDomainType, + } +} + +// TODO: update this to implement `resourceids.ResourceId` once +// https://github.com/hashicorp/go-azure-helpers/issues/187 is fixed +var _ resourceids.Id = AccountId{} + +type AccountId struct { + AccountName string + ZoneName *string + SubDomainType SubDomainType + DomainSuffix string + IsEdgeZone bool +} + +func (a AccountId) ID() string { + components := []string{ + a.AccountName, + } + if a.IsEdgeZone { + // Storage Accounts hosted in an Edge Zone + // `{accountname}.{component}.{edgezone}.edgestorage.azure.net` + components = append(components, string(a.SubDomainType)) + if a.ZoneName != nil { + components = append(components, *a.ZoneName) + } + } else { + // Storage Accounts using a DNS Zone + // `{accountname}.{dnszone}.{component}.storage.azure.net` + // or a Regular Storage Account + // `{accountname}.{component}.core.windows.net` + if a.ZoneName != nil { + components = append(components, *a.ZoneName) + } + components = append(components, string(a.SubDomainType)) + } + components = append(components, a.DomainSuffix) + return fmt.Sprintf("https://%s", strings.Join(components, ".")) +} + +func (a AccountId) String() string { + components := []string{ + fmt.Sprintf("IsEdgeZone %t", a.IsEdgeZone), + fmt.Sprintf("ZoneName %q", pointer.From(a.ZoneName)), + fmt.Sprintf("Subdomain Type %q", string(a.SubDomainType)), + fmt.Sprintf("DomainSuffix %q", a.DomainSuffix), + } + return fmt.Sprintf("Account %q (%s)", a.AccountName, strings.Join(components, " / ")) +} + +func ParseAccountID(input, domainSuffix string) (*AccountId, error) { + uri, err := url.Parse(input) + if err != nil { + return nil, fmt.Errorf("parsing %q as a URL: %s", input, err) + } + + if !strings.HasSuffix(uri.Host, domainSuffix) { + return nil, fmt.Errorf("expected the account %q to use a domain suffix of %q", uri.Host, domainSuffix) + } + + // There's 3 different types of Storage Account ID: + // 1. Regular ol' Storage Accounts + // `{name}.{component}.core.windows.net` (e.g. `example1.blob.core.windows.net`) + // 2. Storage Accounts using a DNS Zone + // `{accountname}.{dnszone}.{component}.storage.azure.net` + // 3. Storage Accounts hosted in an Edge Zone + // `{accountname}.{component}.{edgezone}.edgestorage.azure.net` + // since both `dnszone` and `edgezone` are the only two identifiers, we need to check if `domainSuffix` includes `edge` + // to know how to treat these + + hostName := strings.TrimSuffix(uri.Host, fmt.Sprintf(".%s", domainSuffix)) + components := strings.Split(hostName, ".") + accountId := AccountId{ + DomainSuffix: domainSuffix, + IsEdgeZone: strings.Contains(strings.ToLower(domainSuffix), "edge"), + } + + if len(components) == 2 { + // this will be a regular Storage Account (e.g. `example1.blob.core.windows.net`) + accountId.AccountName = components[0] + subDomainType, err := parseSubDomainType(components[1]) + if err != nil { + return nil, err + } + accountId.SubDomainType = *subDomainType + return &accountId, nil + } + + if len(components) == 3 { + // This can either be a Zone'd Storage Account or a Storage Account within an Edge Zone + accountName := "" + subDomainTypeRaw := "" + zone := "" + if accountId.IsEdgeZone { + // `{accountname}.{component}.{edgezone}.edgestorage.azure.net` + accountName = components[0] + subDomainTypeRaw = components[1] + zone = components[2] + } else { + // `{accountname}.{dnszone}.{component}.storage.azure.net` + accountName = components[0] + zone = components[1] + subDomainTypeRaw = components[2] + } + + accountId.AccountName = accountName + subDomainType, err := parseSubDomainType(subDomainTypeRaw) + if err != nil { + return nil, err + } + accountId.SubDomainType = *subDomainType + accountId.ZoneName = pointer.To(zone) + return &accountId, nil + } + + return nil, fmt.Errorf("unknown storage account domain type %q", input) +} + +func parseSubDomainType(input string) (*SubDomainType, error) { + for _, k := range PossibleValuesForSubDomainType() { + if strings.EqualFold(input, string(k)) { + return pointer.To(k), nil + } + } + + return nil, fmt.Errorf("expected the subdomain type to be one of [%+v] but got %q", PossibleValuesForSubDomainType(), input) +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/service_properties_shared.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/service_properties_shared.go new file mode 100644 index 0000000000000..3019155f9183c --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/service_properties_shared.go @@ -0,0 +1,26 @@ +package accounts + +import ( + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +var _ client.Options = servicePropertiesOptions{} + +type servicePropertiesOptions struct { +} + +func (servicePropertiesOptions) ToHeaders() *client.Headers { + return nil +} + +func (servicePropertiesOptions) ToOData() *odata.Query { + return nil +} + +func (servicePropertiesOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "properties") + out.Append("restype", "service") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/set_service_properties.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/set_service_properties.go new file mode 100644 index 0000000000000..5252dc021eda2 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/set_service_properties.go @@ -0,0 +1,52 @@ +package accounts + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" +) + +type SetServicePropertiesResult struct { + HttpResponse *http.Response +} + +func (c Client) SetServiceProperties(ctx context.Context, accountName string, input StorageServiceProperties) (result SetServicePropertiesResult, err error) { + if accountName == "" { + return result, fmt.Errorf("`accountName` cannot be an empty string") + } + + opts := client.RequestOptions{ + ContentType: "text/xml", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPut, + OptionsObject: servicePropertiesOptions{}, + Path: "/", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + if err = req.Marshal(&input); err != nil { + err = fmt.Errorf("marshaling request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/version.go new file mode 100644 index 0000000000000..427d66da7364d --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts/version.go @@ -0,0 +1,4 @@ +package accounts + +const apiVersion = "2023-11-03" +const componentName = "blob/accounts" diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/README.md b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/README.md similarity index 51% rename from vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/README.md rename to vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/README.md index 19218cf9fd85a..0b26e1cd140f3 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/README.md +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/README.md @@ -1,4 +1,4 @@ -## Blob Storage Blobs SDK for API version 2020-08-04 +## Blob Storage Blobs SDK for API version 2023-11-03 This package allows you to interact with the Blobs Blob Storage API @@ -17,26 +17,34 @@ import ( "fmt" "time" - "github.com/Azure/go-autorest/autorest" - "github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs" + "github.com/hashicorp/go-azure-sdk/sdk/auth" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs" ) func Example() error { accountName := "storageaccount1" storageAccountKey := "ABC123...." containerName := "mycontainer" + domainSuffix := "core.windows.net" fileName := "example-large-file.iso" - - storageAuth := autorest.NewSharedKeyLiteAuthorizer(accountName, storageAccountKey) - blobClient := blobs.New() - blobClient.Client.Authorizer = storageAuth + + blobClient, err := blobs.NewWithBaseUri(fmt.Sprintf("https://%s.blob.%s", accountName, domainSuffix)) + if err != nil { + return fmt.Errorf("building client for environment: %v", err) + } + + auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey) + if err != nil { + return fmt.Errorf("building SharedKey authorizer: %+v", err) + } + blobClient.Client.SetAuthorizer(auth) ctx := context.TODO() copyInput := blobs.CopyInput{ CopySource: "http://releases.ubuntu.com/14.04/ubuntu-14.04.6-desktop-amd64.iso", } refreshInterval := 5 * time.Second - if err := blobClient.CopyAndWait(ctx, accountName, containerName, fileName, copyInput, refreshInterval); err != nil { + if err := blobClient.CopyAndWait(ctx, containerName, fileName, copyInput, refreshInterval); err != nil { return fmt.Errorf("Error copying: %s", err) } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/api.go new file mode 100644 index 0000000000000..1672408250397 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/api.go @@ -0,0 +1,41 @@ +package blobs + +import ( + "context" + "os" +) + +type StorageBlob interface { + AppendBlock(ctx context.Context, containerName string, blobName string, input AppendBlockInput) (AppendBlockResponse, error) + Copy(ctx context.Context, containerName string, blobName string, input CopyInput) (CopyResponse, error) + AbortCopy(ctx context.Context, containerName string, blobName string, input AbortCopyInput) (CopyAbortResponse, error) + CopyAndWait(ctx context.Context, containerName string, blobName string, input CopyInput) error + Delete(ctx context.Context, containerName string, blobName string, input DeleteInput) (DeleteResponse, error) + DeleteSnapshot(ctx context.Context, containerName string, blobName string, input DeleteSnapshotInput) (DeleteSnapshotResponse, error) + DeleteSnapshots(ctx context.Context, containerName string, blobName string, input DeleteSnapshotsInput) (DeleteSnapshotsResponse, error) + Get(ctx context.Context, containerName string, blobName string, input GetInput) (GetResponse, error) + GetBlockList(ctx context.Context, containerName string, blobName string, input GetBlockListInput) (GetBlockListResponse, error) + GetPageRanges(ctx context.Context, containerName, blobName string, input GetPageRangesInput) (GetPageRangesResponse, error) + IncrementalCopyBlob(ctx context.Context, containerName string, blobName string, input IncrementalCopyBlobInput) (IncrementalCopyBlob, error) + AcquireLease(ctx context.Context, containerName string, blobName string, input AcquireLeaseInput) (AcquireLeaseResponse, error) + BreakLease(ctx context.Context, containerName string, blobName string, input BreakLeaseInput) (BreakLeaseResponse, error) + ChangeLease(ctx context.Context, containerName string, blobName string, input ChangeLeaseInput) (ChangeLeaseResponse, error) + ReleaseLease(ctx context.Context, containerName string, blobName string, input ReleaseLeaseInput) (ReleaseLeaseResponse, error) + RenewLease(ctx context.Context, containerName string, blobName string, input RenewLeaseInput) (RenewLeaseResponse, error) + SetMetaData(ctx context.Context, containerName string, blobName string, input SetMetaDataInput) (SetMetaDataResponse, error) + GetProperties(ctx context.Context, containerName string, blobName string, input GetPropertiesInput) (GetPropertiesResponse, error) + SetProperties(ctx context.Context, containerName string, blobName string, input SetPropertiesInput) (SetPropertiesResponse, error) + PutAppendBlob(ctx context.Context, containerName string, blobName string, input PutAppendBlobInput) (PutAppendBlobResponse, error) + PutBlock(ctx context.Context, containerName string, blobName string, input PutBlockInput) (PutBlockResponse, error) + PutBlockBlob(ctx context.Context, containerName string, blobName string, input PutBlockBlobInput) (PutBlockBlobResponse, error) + PutBlockBlobFromFile(ctx context.Context, containerName string, blobName string, file *os.File, input PutBlockBlobInput) error + PutBlockList(ctx context.Context, containerName string, blobName string, input PutBlockListInput) (PutBlockListResponse, error) + PutBlockFromURL(ctx context.Context, containerName string, blobName string, input PutBlockFromURLInput) (PutBlockFromURLResponse, error) + PutPageBlob(ctx context.Context, containerName string, blobName string, input PutPageBlobInput) (PutPageBlobResponse, error) + PutPageClear(ctx context.Context, containerName string, blobName string, input PutPageClearInput) (PutPageClearResponse, error) + PutPageUpdate(ctx context.Context, containerName string, blobName string, input PutPageUpdateInput) (PutPageUpdateResponse, error) + SetTier(ctx context.Context, containerName string, blobName string, input SetTierInput) (SetTierResponse, error) + Snapshot(ctx context.Context, containerName string, blobName string, input SnapshotInput) (SnapshotResponse, error) + GetSnapshotProperties(ctx context.Context, containerName string, blobName string, input GetSnapshotPropertiesInput) (GetPropertiesResponse, error) + Undelete(ctx context.Context, containerName string, blobName string) (UndeleteResponse, error) +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/append_block.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/append_block.go new file mode 100644 index 0000000000000..b82558f937d39 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/append_block.go @@ -0,0 +1,167 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strconv" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type AppendBlockInput struct { + // A number indicating the byte offset to compare. + // Append Block will succeed only if the append position is equal to this number. + // If it is not, the request will fail with an AppendPositionConditionNotMet + // error (HTTP status code 412 – Precondition Failed) + BlobConditionAppendPosition *int64 + + // The max length in bytes permitted for the append blob. + // If the Append Block operation would cause the blob to exceed that limit or if the blob size + // is already greater than the value specified in this header, the request will fail with + // an MaxBlobSizeConditionNotMet error (HTTP status code 412 – Precondition Failed). + BlobConditionMaxSize *int64 + + // The Bytes which should be appended to the end of this Append Blob. + // This can either be nil, which creates an empty blob, or a byte array + Content *[]byte + + // An MD5 hash of the block content. + // This hash is used to verify the integrity of the block during transport. + // When this header is specified, the storage service compares the hash of the content + // that has arrived with this header value. + // + // Note that this MD5 hash is not stored with the blob. + // If the two hashes do not match, the operation will fail with error code 400 (Bad Request). + ContentMD5 *string + + // Required if the blob has an active lease. + // To perform this operation on a blob with an active lease, specify the valid lease ID for this header. + LeaseID *string + + // The encryption scope to set for the request content. + EncryptionScope *string +} + +type AppendBlockResponse struct { + HttpResponse *http.Response + + BlobAppendOffset string + BlobCommittedBlockCount int64 + ContentMD5 string + ETag string + LastModified string +} + +// AppendBlock commits a new block of data to the end of an existing append blob. +func (c Client) AppendBlock(ctx context.Context, containerName, blobName string, input AppendBlockInput) (result AppendBlockResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if input.Content != nil && len(*input.Content) > (4*1024*1024) { + err = fmt.Errorf("`input.Content` must be at most 4MB") + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: appendBlockOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + err = req.Marshal(input.Content) + if err != nil { + err = fmt.Errorf("marshalling request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.BlobAppendOffset = resp.Header.Get("x-ms-blob-append-offset") + result.ContentMD5 = resp.Header.Get("Content-MD5") + result.ETag = resp.Header.Get("ETag") + result.LastModified = resp.Header.Get("Last-Modified") + + if v := resp.Header.Get("x-ms-blob-committed-block-count"); v != "" { + i, innerErr := strconv.Atoi(v) + if innerErr != nil { + err = fmt.Errorf("parsing `x-ms-blob-committed-block-count` header value %q: %+v", v, innerErr) + return + } + result.BlobCommittedBlockCount = int64(i) + } + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type appendBlockOptions struct { + input AppendBlockInput +} + +func (a appendBlockOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + if a.input.BlobConditionAppendPosition != nil { + headers.Append("x-ms-blob-condition-appendpos", strconv.Itoa(int(*a.input.BlobConditionAppendPosition))) + } + if a.input.BlobConditionMaxSize != nil { + headers.Append("x-ms-blob-condition-maxsize", strconv.Itoa(int(*a.input.BlobConditionMaxSize))) + } + if a.input.ContentMD5 != nil { + headers.Append("x-ms-blob-content-md5", *a.input.ContentMD5) + } + if a.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *a.input.LeaseID) + } + if a.input.EncryptionScope != nil { + headers.Append("x-ms-encryption-scope", *a.input.EncryptionScope) + } + if a.input.Content != nil { + headers.Append("Content-Length", strconv.Itoa(len(*a.input.Content))) + } + return headers +} + +func (a appendBlockOptions) ToOData() *odata.Query { + return nil +} + +func (a appendBlockOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "appendblock") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/client.go new file mode 100644 index 0000000000000..4bb762b5d18c5 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/client.go @@ -0,0 +1,22 @@ +package blobs + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/storage" +) + +// Client is the base client for Blob Storage Blobs. +type Client struct { + Client *storage.Client +} + +func NewWithBaseUri(baseUri string) (*Client, error) { + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) + if err != nil { + return nil, fmt.Errorf("building base client: %+v", err) + } + return &Client{ + Client: baseClient, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/copy.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy.go similarity index 57% rename from vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/copy.go rename to vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy.go index febaab5f9a910..68bf1d816a99d 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/copy.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy.go @@ -2,13 +2,12 @@ package blobs import ( "context" + "fmt" "net/http" "strings" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" "github.com/tombuildsstuff/giovanni/storage/internal/metadata" ) @@ -104,132 +103,136 @@ type CopyInput struct { // If the source blob has been modified, the Blob service returns status code 412 (Precondition Failed). // This header cannot be specified if the source is an Azure File. SourceIfUnmodifiedSince *string + + // The encryption scope to set for the request content. + EncryptionScope *string } -type CopyResult struct { - autorest.Response +type CopyResponse struct { + HttpResponse *http.Response CopyID string CopyStatus string } // Copy copies a blob to a destination within the storage account asynchronously. -func (client Client) Copy(ctx context.Context, accountName, containerName, blobName string, input CopyInput) (result CopyResult, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "Copy", "`accountName` cannot be an empty string.") - } +func (c Client) Copy(ctx context.Context, containerName, blobName string, input CopyInput) (result CopyResponse, err error) { if containerName == "" { - return result, validation.NewError("blobs.Client", "Copy", "`containerName` cannot be an empty string.") + return result, fmt.Errorf("`containerName` cannot be an empty string") } + if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "Copy", "`containerName` must be a lower-cased string.") + return result, fmt.Errorf("`containerName` must be a lower-cased string") } + if blobName == "" { - return result, validation.NewError("blobs.Client", "Copy", "`blobName` cannot be an empty string.") + return result, fmt.Errorf("`blobName` cannot be an empty string") } + if input.CopySource == "" { - return result, validation.NewError("blobs.Client", "Copy", "`input.CopySource` cannot be an empty string.") + return result, fmt.Errorf("`input.CopySource` cannot be an empty string") } - req, err := client.CopyPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "Copy", nil, "Failure preparing request") - return + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPut, + OptionsObject: copyOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), } - resp, err := client.CopySender(req) + req, err := c.Client.NewRequest(ctx, opts) if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "Copy", resp, "Failure sending request") + err = fmt.Errorf("building request: %+v", err) return } - result, err = client.CopyResponder(resp) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.CopyID = resp.Header.Get("x-ms-copy-id") + result.CopyStatus = resp.Header.Get("x-ms-copy-status") + } + } if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "Copy", resp, "Failure responding to request") + err = fmt.Errorf("executing request: %+v", err) return } return } -// CopyPreparer prepares the Copy request. -func (client Client) CopyPreparer(ctx context.Context, accountName, containerName, blobName string, input CopyInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } +type copyOptions struct { + input CopyInput +} + +func (c copyOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("x-ms-copy-source", c.input.CopySource) - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - "x-ms-copy-source": autorest.Encode("header", input.CopySource), + if c.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *c.input.LeaseID) } - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID + if c.input.SourceLeaseID != nil { + headers.Append("x-ms-source-lease-id", *c.input.SourceLeaseID) } - if input.SourceLeaseID != nil { - headers["x-ms-source-lease-id"] = *input.SourceLeaseID + + if c.input.AccessTier != nil { + headers.Append("x-ms-access-tier", string(*c.input.AccessTier)) } - if input.AccessTier != nil { - headers["x-ms-access-tier"] = string(*input.AccessTier) + + if c.input.IfMatch != nil { + headers.Append("If-Match", *c.input.IfMatch) } - if input.IfMatch != nil { - headers["If-Match"] = *input.IfMatch + if c.input.IfNoneMatch != nil { + headers.Append("If-None-Match", *c.input.IfNoneMatch) } - if input.IfNoneMatch != nil { - headers["If-None-Match"] = *input.IfNoneMatch + + if c.input.IfUnmodifiedSince != nil { + headers.Append("If-Unmodified-Since", *c.input.IfUnmodifiedSince) } - if input.IfUnmodifiedSince != nil { - headers["If-Unmodified-Since"] = *input.IfUnmodifiedSince + + if c.input.IfModifiedSince != nil { + headers.Append("If-Modified-Since", *c.input.IfModifiedSince) } - if input.IfModifiedSince != nil { - headers["If-Modified-Since"] = *input.IfModifiedSince + + if c.input.SourceIfMatch != nil { + headers.Append("x-ms-source-if-match", *c.input.SourceIfMatch) } - if input.SourceIfMatch != nil { - headers["x-ms-source-if-match"] = *input.SourceIfMatch + if c.input.SourceIfNoneMatch != nil { + headers.Append("x-ms-source-if-none-match", *c.input.SourceIfNoneMatch) } - if input.SourceIfNoneMatch != nil { - headers["x-ms-source-if-none-match"] = *input.SourceIfNoneMatch + + if c.input.SourceIfModifiedSince != nil { + headers.Append("x-ms-source-if-modified-since", *c.input.SourceIfModifiedSince) } - if input.SourceIfModifiedSince != nil { - headers["x-ms-source-if-modified-since"] = *input.SourceIfModifiedSince + + if c.input.SourceIfUnmodifiedSince != nil { + headers.Append("x-ms-source-if-unmodified-since", *c.input.SourceIfUnmodifiedSince) } - if input.SourceIfUnmodifiedSince != nil { - headers["x-ms-source-if-unmodified-since"] = *input.SourceIfUnmodifiedSince + + if c.input.EncryptionScope != nil { + headers.Append("x-ms-encryption-scope", *c.input.EncryptionScope) } - headers = metadata.SetIntoHeaders(headers, input.MetaData) + headers.Merge(metadata.SetMetaDataHeaders(c.input.MetaData)) - preparer := autorest.CreatePreparer( - autorest.AsPut(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) + return headers } -// CopySender sends the Copy request. The method will close the -// http.Response Body if it receives an error. -func (client Client) CopySender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) +func (c copyOptions) ToOData() *odata.Query { + return nil } -// CopyResponder handles the response to the Copy request. The method always -// closes the http.Response Body. -func (client Client) CopyResponder(resp *http.Response) (result CopyResult, err error) { - if resp != nil && resp.Header != nil { - result.CopyID = resp.Header.Get("x-ms-copy-id") - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusAccepted), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return +func (c copyOptions) ToQuery() *client.QueryParams { + return nil } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy_abort.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy_abort.go new file mode 100644 index 0000000000000..5d9469a5097c9 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy_abort.go @@ -0,0 +1,101 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type AbortCopyInput struct { + // The Copy ID which should be aborted + CopyID string + + // The ID of the Lease + // This must be specified if a Lease is present on the Blob, else a 403 is returned + LeaseID *string +} + +type CopyAbortResponse struct { + HttpResponse *http.Response +} + +// AbortCopy aborts a pending Copy Blob operation, and leaves a destination blob with zero length and full metadata. +func (c Client) AbortCopy(ctx context.Context, containerName, blobName string, input AbortCopyInput) (result CopyAbortResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if input.CopyID == "" { + err = fmt.Errorf("`input.CopyID` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPut, + OptionsObject: copyAbortOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type copyAbortOptions struct { + input AbortCopyInput +} + +func (c copyAbortOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("x-ms-copy-action", "abort") + if c.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *c.input.LeaseID) + } + + return headers +} + +func (c copyAbortOptions) ToOData() *odata.Query { + return nil +} + +func (c copyAbortOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "copy") + out.Append("copyid", c.input.CopyID) + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy_and_wait.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy_and_wait.go new file mode 100644 index 0000000000000..5ec7c239fe321 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy_and_wait.go @@ -0,0 +1,28 @@ +package blobs + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" +) + +// CopyAndWait copies a blob to a destination within the storage account and waits for it to finish copying. +func (c Client) CopyAndWait(ctx context.Context, containerName, blobName string, input CopyInput) error { + if _, err := c.Copy(ctx, containerName, blobName, input); err != nil { + return fmt.Errorf("error copying: %s", err) + } + + getInput := GetPropertiesInput{ + LeaseID: input.LeaseID, + } + + pollerType := NewCopyAndWaitPoller(&c, containerName, blobName, getInput) + poller := pollers.NewPoller(pollerType, 10*time.Second, pollers.DefaultNumberOfDroppedConnectionsToAllow) + if err := poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("waiting for file to copy: %+v", err) + } + + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy_and_wait_poller.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy_and_wait_poller.go new file mode 100644 index 0000000000000..313f4863206e1 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/copy_and_wait_poller.go @@ -0,0 +1,48 @@ +package blobs + +import ( + "context" + "fmt" + "strings" + "time" + + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" +) + +var _ pollers.PollerType = ©AndWaitPoller{} + +func NewCopyAndWaitPoller(client *Client, containerName, blobName string, getPropertiesInput GetPropertiesInput) *copyAndWaitPoller { + return ©AndWaitPoller{ + client: client, + containerName: containerName, + blobName: blobName, + getPropertiesInput: getPropertiesInput, + } +} + +type copyAndWaitPoller struct { + client *Client + containerName string + blobName string + getPropertiesInput GetPropertiesInput +} + +func (p *copyAndWaitPoller) Poll(ctx context.Context) (*pollers.PollResult, error) { + props, err := p.client.GetProperties(ctx, p.containerName, p.blobName, p.getPropertiesInput) + if err != nil { + return nil, fmt.Errorf("retrieving properties (container: %s blob: %s) : %+v", p.containerName, p.blobName, err) + } + + if strings.EqualFold(string(props.CopyStatus), string(Success)) { + return &pollers.PollResult{ + Status: pollers.PollingStatusSucceeded, + PollInterval: 10 * time.Second, + }, nil + } + + // Processing + return &pollers.PollResult{ + Status: pollers.PollingStatusInProgress, + PollInterval: 10 * time.Second, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete.go new file mode 100644 index 0000000000000..80c1e43323893 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete.go @@ -0,0 +1,95 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type DeleteInput struct { + // Should any Snapshots for this Blob also be deleted? + // If the Blob has Snapshots and this is set to False a 409 Conflict will be returned + DeleteSnapshots bool + + // The ID of the Lease + // This must be specified if a Lease is present on the Blob, else a 403 is returned + LeaseID *string +} + +type DeleteResponse struct { + HttpResponse *http.Response +} + +// Delete marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection. +func (c Client) Delete(ctx context.Context, containerName, blobName string, input DeleteInput) (result DeleteResponse, err error) { + if containerName == "" { + return result, fmt.Errorf("`containerName` cannot be an empty string") + } + + if strings.ToLower(containerName) != containerName { + return result, fmt.Errorf("`containerName` must be a lower-cased string") + } + + if blobName == "" { + return result, fmt.Errorf("`blobName` cannot be an empty string") + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodDelete, + OptionsObject: deleteOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type deleteOptions struct { + input DeleteInput +} + +func (d deleteOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + if d.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *d.input.LeaseID) + } + + if d.input.DeleteSnapshots { + headers.Append("x-ms-delete-snapshots", "include") + } + + return headers +} + +func (d deleteOptions) ToOData() *odata.Query { + return nil +} + +func (d deleteOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete_snapshot.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete_snapshot.go new file mode 100644 index 0000000000000..e5cfa3c8f0b6d --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete_snapshot.go @@ -0,0 +1,99 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type DeleteSnapshotInput struct { + // The ID of the Lease + // This must be specified if a Lease is present on the Blob, else a 403 is returned + LeaseID *string + + // The DateTime of the Snapshot which should be marked for Deletion + SnapshotDateTime string +} + +type DeleteSnapshotResponse struct { + HttpResponse *http.Response +} + +// DeleteSnapshot marks a single Snapshot of a Blob for Deletion based on it's DateTime, which will be deleted during the next Garbage Collection cycle. +func (c Client) DeleteSnapshot(ctx context.Context, containerName, blobName string, input DeleteSnapshotInput) (result DeleteSnapshotResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if input.SnapshotDateTime == "" { + err = fmt.Errorf("`input.SnapshotDateTime` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodDelete, + OptionsObject: deleteSnapshotOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type deleteSnapshotOptions struct { + input DeleteSnapshotInput +} + +func (d deleteSnapshotOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + if d.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *d.input.LeaseID) + } + + return headers +} + +func (d deleteSnapshotOptions) ToOData() *odata.Query { + return nil +} + +func (d deleteSnapshotOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("snapshot", d.input.SnapshotDateTime) + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete_snapshots.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete_snapshots.go new file mode 100644 index 0000000000000..dd0ce7be20fc0 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/delete_snapshots.go @@ -0,0 +1,90 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type DeleteSnapshotsInput struct { + // The ID of the Lease + // This must be specified if a Lease is present on the Blob, else a 403 is returned + LeaseID *string +} + +type DeleteSnapshotsResponse struct { + HttpResponse *http.Response +} + +// DeleteSnapshots marks all Snapshots of a Blob for Deletion, which will be deleted during the next Garbage Collection Cycle. +func (c Client) DeleteSnapshots(ctx context.Context, containerName, blobName string, input DeleteSnapshotsInput) (result DeleteSnapshotsResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodDelete, + OptionsObject: deleteSnapshotsOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type deleteSnapshotsOptions struct { + input DeleteSnapshotsInput +} + +func (d deleteSnapshotsOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("x-ms-delete-snapshots", "only") + + if d.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *d.input.LeaseID) + } + return headers +} + +func (d deleteSnapshotsOptions) ToOData() *odata.Query { + return nil +} + +func (d deleteSnapshotsOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get.go new file mode 100644 index 0000000000000..5829324459f5f --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get.go @@ -0,0 +1,104 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type GetInput struct { + LeaseID *string + StartByte *int64 + EndByte *int64 +} + +type GetResponse struct { + HttpResponse *http.Response + + Contents *[]byte +} + +// Get reads or downloads a blob from the system, including its metadata and properties. +func (c Client) Get(ctx context.Context, containerName, blobName string, input GetInput) (result GetResponse, err error) { + if containerName == "" { + return result, fmt.Errorf("`containerName` cannot be an empty string") + } + + if strings.ToLower(containerName) != containerName { + return result, fmt.Errorf("`containerName` must be a lower-cased string") + } + + if blobName == "" { + return result, fmt.Errorf("`blobName` cannot be an empty string") + } + + if input.LeaseID != nil && *input.LeaseID == "" { + return result, fmt.Errorf("`input.LeaseID` should either be specified or nil, not an empty string") + } + + if (input.StartByte != nil && input.EndByte == nil) || input.StartByte == nil && input.EndByte != nil { + return result, fmt.Errorf("`input.StartByte` and `input.EndByte` must both be specified, or both be nil") + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusOK, + http.StatusPartialContent, + }, + HttpMethod: http.MethodGet, + OptionsObject: getOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.Contents = &[]byte{} + result.HttpResponse = resp.Response + + err = resp.Unmarshal(result.Contents) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type getOptions struct { + input GetInput +} + +func (g getOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + if g.input.StartByte != nil && g.input.EndByte != nil { + headers.Append("x-ms-range", fmt.Sprintf("bytes=%d-%d", *g.input.StartByte, *g.input.EndByte)) + } + return headers + +} + +func (g getOptions) ToOData() *odata.Query { + return nil +} + +func (g getOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get_block_list.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get_block_list.go new file mode 100644 index 0000000000000..b7c4037d88f01 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get_block_list.go @@ -0,0 +1,125 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strconv" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type GetBlockListInput struct { + BlockListType BlockListType + LeaseID *string +} + +type GetBlockListResponse struct { + HttpResponse *http.Response + + // The size of the blob in bytes + BlobContentLength *int64 + + // The Content Type of the blob + ContentType string + + // The ETag associated with this blob + ETag string + + // A list of blocks which have been committed + CommittedBlocks CommittedBlocks `xml:"CommittedBlocks,omitempty"` + + // A list of blocks which have not yet been committed + UncommittedBlocks UncommittedBlocks `xml:"UncommittedBlocks,omitempty"` +} + +// GetBlockList retrieves the list of blocks that have been uploaded as part of a block blob. +func (c Client) GetBlockList(ctx context.Context, containerName, blobName string, input GetBlockListInput) (result GetBlockListResponse, err error) { + if containerName == "" { + return result, fmt.Errorf("`containerName` cannot be an empty string") + } + + if strings.ToLower(containerName) != containerName { + return result, fmt.Errorf("`containerName` must be a lower-cased string") + } + + if blobName == "" { + return result, fmt.Errorf("`blobName` cannot be an empty string") + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: getBlockListOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.ContentType = resp.Header.Get("Content-Type") + result.ETag = resp.Header.Get("ETag") + + if v := resp.Header.Get("x-ms-blob-content-length"); v != "" { + i, innerErr := strconv.Atoi(v) + if innerErr != nil { + err = fmt.Errorf("parsing `x-ms-blob-content-length` header value %q: %s", v, innerErr) + return + } + + i64 := int64(i) + result.BlobContentLength = &i64 + } + } + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type getBlockListOptions struct { + input GetBlockListInput +} + +func (g getBlockListOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + if g.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *g.input.LeaseID) + } + return headers +} + +func (g getBlockListOptions) ToOData() *odata.Query { + return nil +} + +func (g getBlockListOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("blocklisttype", string(g.input.BlockListType)) + out.Append("comp", "blocklist") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get_page_ranges.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get_page_ranges.go new file mode 100644 index 0000000000000..fe83294cc0b38 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/get_page_ranges.go @@ -0,0 +1,140 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strconv" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type GetPageRangesInput struct { + LeaseID *string + + StartByte *int64 + EndByte *int64 +} + +type GetPageRangesResponse struct { + HttpResponse *http.Response + + // The size of the blob in bytes + ContentLength *int64 + + // The Content Type of the blob + ContentType string + + // The ETag associated with this blob + ETag string + + PageRanges []PageRange `xml:"PageRange"` +} + +type PageRange struct { + // The start byte offset for this range, inclusive + Start int64 `xml:"Start"` + + // The end byte offset for this range, inclusive + End int64 `xml:"End"` +} + +// GetPageRanges returns the list of valid page ranges for a page blob or snapshot of a page blob. +func (c Client) GetPageRanges(ctx context.Context, containerName, blobName string, input GetPageRangesInput) (result GetPageRangesResponse, err error) { + if containerName == "" { + return result, fmt.Errorf("`containerName` cannot be an empty string") + } + + if strings.ToLower(containerName) != containerName { + return result, fmt.Errorf("`containerName` must be a lower-cased string") + } + + if blobName == "" { + return result, fmt.Errorf("`blobName` cannot be an empty string") + } + + if (input.StartByte != nil && input.EndByte == nil) || (input.StartByte == nil && input.EndByte != nil) { + return result, fmt.Errorf("`input.StartByte` and `input.EndByte` must both be specified, or both be nil") + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: getPageRangesOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.ContentType = resp.Header.Get("Content-Type") + result.ETag = resp.Header.Get("ETag") + + if v := resp.Header.Get("x-ms-blob-content-length"); v != "" { + i, innerErr := strconv.Atoi(v) + if innerErr != nil { + err = fmt.Errorf("parsing `x-ms-blob-content-length` header value %q: %+v", v, innerErr) + return + } + + i64 := int64(i) + result.ContentLength = &i64 + } + } + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type getPageRangesOptions struct { + input GetPageRangesInput +} + +func (g getPageRangesOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + if g.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *g.input.LeaseID) + } + + if g.input.StartByte != nil && g.input.EndByte != nil { + headers.Append("x-ms-range", fmt.Sprintf("bytes=%d-%d", *g.input.StartByte, *g.input.EndByte)) + } + + return headers +} + +func (g getPageRangesOptions) ToOData() *odata.Query { + return nil +} + +func (g getPageRangesOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "pagelist") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/incremental_copy_blob.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/incremental_copy_blob.go new file mode 100644 index 0000000000000..0423c0f99e22c --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/incremental_copy_blob.go @@ -0,0 +1,112 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type IncrementalCopyBlobInput struct { + CopySource string + IfModifiedSince *string + IfUnmodifiedSince *string + IfMatch *string + IfNoneMatch *string +} + +type IncrementalCopyBlob struct { + HttpResponse *http.Response +} + +// IncrementalCopyBlob copies a snapshot of the source page blob to a destination page blob. +// The snapshot is copied such that only the differential changes between the previously copied +// snapshot are transferred to the destination. +// The copied snapshots are complete copies of the original snapshot and can be read or copied from as usual. +func (c Client) IncrementalCopyBlob(ctx context.Context, containerName, blobName string, input IncrementalCopyBlobInput) (result IncrementalCopyBlob, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if input.CopySource == "" { + err = fmt.Errorf("`input.CopySource` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPut, + OptionsObject: incrementalCopyBlobOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type incrementalCopyBlobOptions struct { + input IncrementalCopyBlobInput +} + +func (i incrementalCopyBlobOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + headers.Append("x-ms-copy-source", i.input.CopySource) + + if i.input.IfModifiedSince != nil { + headers.Append("If-Modified-Since", *i.input.IfModifiedSince) + } + if i.input.IfUnmodifiedSince != nil { + headers.Append("If-Unmodified-Since", *i.input.IfUnmodifiedSince) + } + if i.input.IfMatch != nil { + headers.Append("If-Match", *i.input.IfMatch) + } + if i.input.IfNoneMatch != nil { + headers.Append("If-None-Match", *i.input.IfNoneMatch) + } + return headers +} + +func (i incrementalCopyBlobOptions) ToOData() *odata.Query { + return nil +} + +func (i incrementalCopyBlobOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "incrementalcopy") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_acquire.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_acquire.go new file mode 100644 index 0000000000000..d4477564eaccd --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_acquire.go @@ -0,0 +1,127 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strconv" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type AcquireLeaseInput struct { + // The ID of the existing Lease, if leased + LeaseID *string + + // 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 + LeaseDuration int + + // The Proposed new ID for the Lease + ProposedLeaseID *string +} + +type AcquireLeaseResponse struct { + HttpResponse *http.Response + + LeaseID string +} + +// AcquireLease establishes and manages a lock on a blob for write and delete operations. +func (c Client) AcquireLease(ctx context.Context, containerName, blobName string, input AcquireLeaseInput) (result AcquireLeaseResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if input.LeaseID != nil && *input.LeaseID == "" { + err = fmt.Errorf("`input.LeaseID` cannot be an empty string, if specified") + return + } + + if input.ProposedLeaseID != nil && *input.ProposedLeaseID == "" { + err = fmt.Errorf("`input.ProposedLeaseID` cannot be an empty string, if specified") + return + } + // An infinite lease duration is -1 seconds. A non-infinite lease can be between 15 and 60 seconds + if input.LeaseDuration != -1 && (input.LeaseDuration <= 15 || input.LeaseDuration >= 60) { + err = fmt.Errorf("`input.LeaseDuration` must be -1 (infinite), or between 15 and 60 seconds") + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: acquireLeaseOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.LeaseID = resp.Header.Get("x-ms-lease-id") + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type acquireLeaseOptions struct { + input AcquireLeaseInput +} + +func (a acquireLeaseOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + headers.Append("x-ms-lease-action", "acquire") + headers.Append("x-ms-lease-duration", strconv.Itoa(a.input.LeaseDuration)) + + if a.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *a.input.LeaseID) + } + + if a.input.ProposedLeaseID != nil { + headers.Append("x-ms-proposed-lease-id", *a.input.ProposedLeaseID) + } + + return headers +} + +func (a acquireLeaseOptions) ToOData() *odata.Query { + return nil +} + +func (a acquireLeaseOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "lease") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_break.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_break.go new file mode 100644 index 0000000000000..74e689106694b --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_break.go @@ -0,0 +1,113 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strconv" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type BreakLeaseInput 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 *int + + LeaseID string +} + +type BreakLeaseResponse struct { + HttpResponse *http.Response + + // Approximate time remaining in the lease period, in seconds. + // If the break is immediate, 0 is returned. + LeaseTime int +} + +// BreakLease breaks an existing lock on a blob using the LeaseID. +func (c Client) BreakLease(ctx context.Context, containerName, blobName string, input BreakLeaseInput) (result BreakLeaseResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if input.LeaseID == "" { + err = fmt.Errorf("`input.LeaseID` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPut, + OptionsObject: breakLeaseOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type breakLeaseOptions struct { + input BreakLeaseInput +} + +func (b breakLeaseOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + headers.Append("x-ms-lease-action", "break") + headers.Append("x-ms-lease-id", b.input.LeaseID) + + if b.input.BreakPeriod != nil { + headers.Append("x-ms-lease-break-period", strconv.Itoa(*b.input.BreakPeriod)) + } + + return headers +} + +func (b breakLeaseOptions) ToOData() *odata.Query { + return nil +} + +func (b breakLeaseOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "lease") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_change.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_change.go new file mode 100644 index 0000000000000..f983d1dd9c6c9 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_change.go @@ -0,0 +1,105 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type ChangeLeaseInput struct { + ExistingLeaseID string + ProposedLeaseID string +} + +type ChangeLeaseResponse struct { + HttpResponse *http.Response + + LeaseID string +} + +// ChangeLease changes an existing lock on a blob for another lock. +func (c Client) ChangeLease(ctx context.Context, containerName, blobName string, input ChangeLeaseInput) (result ChangeLeaseResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if input.ExistingLeaseID == "" { + err = fmt.Errorf("`input.ExistingLeaseID` cannot be an empty string") + return + } + + if input.ProposedLeaseID == "" { + err = fmt.Errorf("`input.ProposedLeaseID` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: changeLeaseOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.LeaseID = resp.Header.Get("x-ms-lease-id") + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type changeLeaseOptions struct { + input ChangeLeaseInput +} + +func (c changeLeaseOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("x-ms-lease-action", "change") + headers.Append("x-ms-lease-id", c.input.ExistingLeaseID) + headers.Append("x-ms-proposed-lease-id", c.input.ProposedLeaseID) + return headers +} + +func (c changeLeaseOptions) ToOData() *odata.Query { + return nil +} + +func (c changeLeaseOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "lease") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_release.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_release.go new file mode 100644 index 0000000000000..2101828b24e10 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_release.go @@ -0,0 +1,92 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type ReleaseLeaseResponse struct { + HttpResponse *http.Response +} + +type ReleaseLeaseInput struct { + LeaseID string +} + +// ReleaseLease releases a lock based on the Lease ID. +func (c Client) ReleaseLease(ctx context.Context, containerName, blobName string, input ReleaseLeaseInput) (result ReleaseLeaseResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if input.LeaseID == "" { + err = fmt.Errorf("`input.LeaseID` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: releaseLeaseOptions{ + leaseID: input.LeaseID, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type releaseLeaseOptions struct { + leaseID string +} + +func (r releaseLeaseOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("x-ms-lease-action", "release") + headers.Append("x-ms-lease-id", r.leaseID) + return headers +} + +func (r releaseLeaseOptions) ToOData() *odata.Query { + return nil +} + +func (r releaseLeaseOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "lease") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_renew.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_renew.go new file mode 100644 index 0000000000000..e43a12d96ea93 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/lease_renew.go @@ -0,0 +1,91 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type RenewLeaseResponse struct { + HttpResponse *http.Response +} + +type RenewLeaseInput struct { + LeaseID string +} + +func (c Client) RenewLease(ctx context.Context, containerName, blobName string, input RenewLeaseInput) (result RenewLeaseResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if input.LeaseID == "" { + err = fmt.Errorf("`input.LeaseID` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: renewLeaseOptions{ + leaseID: input.LeaseID, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type renewLeaseOptions struct { + leaseID string +} + +func (r renewLeaseOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("x-ms-lease-action", "renew") + headers.Append("x-ms-lease-id", r.leaseID) + return headers +} + +func (r renewLeaseOptions) ToOData() *odata.Query { + return nil +} + +func (r renewLeaseOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "lease") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/metadata_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/metadata_set.go new file mode 100644 index 0000000000000..ce6c047d02560 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/metadata_set.go @@ -0,0 +1,100 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type SetMetaDataInput struct { + // The ID of the Lease + // This must be specified if a Lease is present on the Blob, else a 403 is returned + LeaseID *string + + // Any metadata which should be added to this blob + MetaData map[string]string +} + +type SetMetaDataResponse struct { + HttpResponse *http.Response +} + +// SetMetaData marks the specified blob or snapshot for deletion. The blob is later deleted during garbage collection. +func (c Client) SetMetaData(ctx context.Context, containerName, blobName string, input SetMetaDataInput) (result SetMetaDataResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf(fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: setMetadataOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type setMetadataOptions struct { + input SetMetaDataInput +} + +func (s setMetadataOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + if s.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *s.input.LeaseID) + } + headers.Merge(metadata.SetMetaDataHeaders(s.input.MetaData)) + return headers +} + +func (s setMetadataOptions) ToOData() *odata.Query { + return nil +} + +func (s setMetadataOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "metadata") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/models.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/models.go similarity index 100% rename from vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/models.go rename to vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/models.go diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/properties_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/properties_get.go similarity index 55% rename from vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/properties_get.go rename to vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/properties_get.go index 5640687d6d929..3edfa89008458 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/properties_get.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/properties_get.go @@ -7,10 +7,8 @@ import ( "strconv" "strings" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "github.com/Azure/go-autorest/autorest/validation" - "github.com/tombuildsstuff/giovanni/storage/internal/endpoints" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" "github.com/tombuildsstuff/giovanni/storage/internal/metadata" ) @@ -20,8 +18,8 @@ type GetPropertiesInput struct { LeaseID *string } -type GetPropertiesResult struct { - autorest.Response +type GetPropertiesResponse struct { + HttpResponse *http.Response // The tier of page blob on a premium storage account or tier of block blob on blob storage or general purpose v2 account. AccessTier AccessTier @@ -160,151 +158,138 @@ type GetPropertiesResult struct { // Is the Storage Account encrypted using server-side encryption? This should always return true ServerEncrypted bool + + // The encryption scope for the request content. + EncryptionScope string } // GetProperties returns all user-defined metadata, standard HTTP properties, and system properties for the blob -func (client Client) GetProperties(ctx context.Context, accountName, containerName, blobName string, input GetPropertiesInput) (result GetPropertiesResult, err error) { - if accountName == "" { - return result, validation.NewError("blobs.Client", "GetProperties", "`accountName` cannot be an empty string.") - } +func (c Client) GetProperties(ctx context.Context, containerName, blobName string, input GetPropertiesInput) (result GetPropertiesResponse, err error) { if containerName == "" { - return result, validation.NewError("blobs.Client", "GetProperties", "`containerName` cannot be an empty string.") + err = fmt.Errorf("`containerName` cannot be an empty string") + return } if strings.ToLower(containerName) != containerName { - return result, validation.NewError("blobs.Client", "GetProperties", "`containerName` must be a lower-cased string.") + err = fmt.Errorf("`containerName` must be a lower-cased string") + return } if blobName == "" { - return result, validation.NewError("blobs.Client", "GetProperties", "`blobName` cannot be an empty string.") + err = fmt.Errorf("`blobName` cannot be an empty string") + return } - req, err := client.GetPropertiesPreparer(ctx, accountName, containerName, blobName, input) - if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "GetProperties", nil, "Failure preparing request") - return + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + OptionsObject: getPropertiesOptions{ + leaseID: input.LeaseID, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), } - resp, err := client.GetPropertiesSender(req) + req, err := c.Client.NewRequest(ctx, opts) if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "blobs.Client", "GetProperties", resp, "Failure sending request") + err = fmt.Errorf("building request: %+v", err) return } - result, err = client.GetPropertiesResponder(resp) + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.AccessTier = AccessTier(resp.Header.Get("x-ms-access-tier")) + result.AccessTierChangeTime = resp.Header.Get("x-ms-access-tier-change-time") + result.ArchiveStatus = ArchiveStatus(resp.Header.Get("x-ms-archive-status")) + result.BlobCommittedBlockCount = resp.Header.Get("x-ms-blob-committed-block-count") + result.BlobSequenceNumber = resp.Header.Get("x-ms-blob-sequence-number") + result.BlobType = BlobType(resp.Header.Get("x-ms-blob-type")) + result.CacheControl = resp.Header.Get("Cache-Control") + result.ContentDisposition = resp.Header.Get("Content-Disposition") + result.ContentEncoding = resp.Header.Get("Content-Encoding") + result.ContentLanguage = resp.Header.Get("Content-Language") + result.ContentMD5 = resp.Header.Get("Content-MD5") + result.ContentType = resp.Header.Get("Content-Type") + result.CopyCompletionTime = resp.Header.Get("x-ms-copy-completion-time") + result.CopyDestinationSnapshot = resp.Header.Get("x-ms-copy-destination-snapshot") + result.CopyID = resp.Header.Get("x-ms-copy-id") + result.CopyProgress = resp.Header.Get("x-ms-copy-progress") + result.CopySource = resp.Header.Get("x-ms-copy-source") + result.CopyStatus = CopyStatus(resp.Header.Get("x-ms-copy-status")) + result.CopyStatusDescription = resp.Header.Get("x-ms-copy-status-description") + result.CreationTime = resp.Header.Get("x-ms-creation-time") + result.ETag = resp.Header.Get("Etag") + result.LastModified = resp.Header.Get("Last-Modified") + result.LeaseDuration = LeaseDuration(resp.Header.Get("x-ms-lease-duration")) + result.LeaseState = LeaseState(resp.Header.Get("x-ms-lease-state")) + result.LeaseStatus = LeaseStatus(resp.Header.Get("x-ms-lease-status")) + result.EncryptionScope = resp.Header.Get("x-ms-encryption-scope") + result.MetaData = metadata.ParseFromHeaders(resp.Header) + + if v := resp.Header.Get("x-ms-access-tier-inferred"); v != "" { + b, innerErr := strconv.ParseBool(v) + if innerErr != nil { + err = fmt.Errorf("parsing `x-ms-access-tier-inferred` header value %q: %s", v, innerErr) + return + } + result.AccessTierInferred = b + } + + if v := resp.Header.Get("Content-Length"); v != "" { + i, innerErr := strconv.Atoi(v) + if innerErr != nil { + err = fmt.Errorf("parsing `Content-Length` header value %q: %s", v, innerErr) + } + result.ContentLength = int64(i) + } + + if v := resp.Header.Get("x-ms-incremental-copy"); v != "" { + b, innerErr := strconv.ParseBool(v) + if innerErr != nil { + err = fmt.Errorf("parsing `x-ms-incremental-copy` header value %q: %s", v, innerErr) + return + } + result.IncrementalCopy = b + } + + if v := resp.Header.Get("x-ms-server-encrypted"); v != "" { + b, innerErr := strconv.ParseBool(v) + if innerErr != nil { + err = fmt.Errorf("parsing `x-ms-server-encrypted` header value %q: %s", v, innerErr) + return + } + result.ServerEncrypted = b + } + } + } if err != nil { - err = autorest.NewErrorWithError(err, "blobs.Client", "GetProperties", resp, "Failure responding to request") + err = fmt.Errorf("executing request: %+v", err) return } return } -// GetPropertiesPreparer prepares the GetProperties request. -func (client Client) GetPropertiesPreparer(ctx context.Context, accountName, containerName, blobName string, input GetPropertiesInput) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerName": autorest.Encode("path", containerName), - "blobName": autorest.Encode("path", blobName), - } +type getPropertiesOptions struct { + leaseID *string +} - headers := map[string]interface{}{ - "x-ms-version": APIVersion, - } +func (g getPropertiesOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} - if input.LeaseID != nil { - headers["x-ms-lease-id"] = *input.LeaseID + if g.leaseID != nil { + headers.Append("x-ms-lease-id", *g.leaseID) } - - preparer := autorest.CreatePreparer( - autorest.AsHead(), - autorest.WithBaseURL(endpoints.GetBlobEndpoint(client.BaseURI, accountName)), - autorest.WithPathParameters("/{containerName}/{blobName}", pathParameters), - autorest.WithHeaders(headers)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) + return headers } -// GetPropertiesSender sends the GetProperties request. The method will close the -// http.Response Body if it receives an error. -func (client Client) GetPropertiesSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) +func (g getPropertiesOptions) ToOData() *odata.Query { + return nil } -// GetPropertiesResponder handles the response to the GetProperties request. The method always -// closes the http.Response Body. -func (client Client) GetPropertiesResponder(resp *http.Response) (result GetPropertiesResult, err error) { - if resp != nil && resp.Header != nil { - result.AccessTier = AccessTier(resp.Header.Get("x-ms-access-tier")) - result.AccessTierChangeTime = resp.Header.Get(" x-ms-access-tier-change-time") - result.ArchiveStatus = ArchiveStatus(resp.Header.Get(" x-ms-archive-status")) - result.BlobCommittedBlockCount = resp.Header.Get("x-ms-blob-committed-block-count") - result.BlobSequenceNumber = resp.Header.Get("x-ms-blob-sequence-number") - result.BlobType = BlobType(resp.Header.Get("x-ms-blob-type")) - result.CacheControl = resp.Header.Get("Cache-Control") - result.ContentDisposition = resp.Header.Get("Content-Disposition") - result.ContentEncoding = resp.Header.Get("Content-Encoding") - result.ContentLanguage = resp.Header.Get("Content-Language") - result.ContentMD5 = resp.Header.Get("Content-MD5") - result.ContentType = resp.Header.Get("Content-Type") - result.CopyCompletionTime = resp.Header.Get("x-ms-copy-completion-time") - result.CopyDestinationSnapshot = resp.Header.Get("x-ms-copy-destination-snapshot") - result.CopyID = resp.Header.Get("x-ms-copy-id") - result.CopyProgress = resp.Header.Get("x-ms-copy-progress") - result.CopySource = resp.Header.Get("x-ms-copy-source") - result.CopyStatus = CopyStatus(resp.Header.Get("x-ms-copy-status")) - result.CopyStatusDescription = resp.Header.Get("x-ms-copy-status-description") - result.CreationTime = resp.Header.Get("x-ms-creation-time") - result.ETag = resp.Header.Get("Etag") - result.LastModified = resp.Header.Get("Last-Modified") - result.LeaseDuration = LeaseDuration(resp.Header.Get("x-ms-lease-duration")) - result.LeaseState = LeaseState(resp.Header.Get("x-ms-lease-state")) - result.LeaseStatus = LeaseStatus(resp.Header.Get("x-ms-lease-status")) - result.MetaData = metadata.ParseFromHeaders(resp.Header) - - if v := resp.Header.Get("x-ms-access-tier-inferred"); v != "" { - b, innerErr := strconv.ParseBool(v) - if innerErr != nil { - err = fmt.Errorf("Error parsing %q as a bool: %s", v, innerErr) - return - } - - result.AccessTierInferred = b - } - - if v := resp.Header.Get("Content-Length"); v != "" { - i, innerErr := strconv.Atoi(v) - if innerErr != nil { - err = fmt.Errorf("Error parsing %q as an integer: %s", v, innerErr) - } - - result.ContentLength = int64(i) - } - - if v := resp.Header.Get("x-ms-incremental-copy"); v != "" { - b, innerErr := strconv.ParseBool(v) - if innerErr != nil { - err = fmt.Errorf("Error parsing %q as a bool: %s", v, innerErr) - return - } - - result.IncrementalCopy = b - } - - if v := resp.Header.Get("x-ms-server-encrypted"); v != "" { - b, innerErr := strconv.ParseBool(v) - if innerErr != nil { - err = fmt.Errorf("Error parsing %q as a bool: %s", v, innerErr) - return - } - - result.IncrementalCopy = b - } - } - - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return +func (g getPropertiesOptions) ToQuery() *client.QueryParams { + return nil } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/properties_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/properties_set.go new file mode 100644 index 0000000000000..73b417f045401 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/properties_set.go @@ -0,0 +1,135 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strconv" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type SetPropertiesInput struct { + CacheControl *string + ContentType *string + ContentMD5 *string + ContentEncoding *string + ContentLanguage *string + LeaseID *string + ContentDisposition *string + ContentLength *int64 + SequenceNumberAction *SequenceNumberAction + BlobSequenceNumber *string +} + +type SetPropertiesResponse struct { + HttpResponse *http.Response + + BlobSequenceNumber string + Etag string +} + +// SetProperties sets system properties on the blob. +func (c Client) SetProperties(ctx context.Context, containerName, blobName string, input SetPropertiesInput) (result SetPropertiesResponse, err error) { + if containerName == "" { + return result, fmt.Errorf("`containerName` cannot be an empty string") + } + + if strings.ToLower(containerName) != containerName { + return result, fmt.Errorf("`containerName` must be a lower-cased string") + } + + if blobName == "" { + return result, fmt.Errorf("`blobName` cannot be an empty string") + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: setPropertiesOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type SequenceNumberAction string + +var ( + Increment SequenceNumberAction = "increment" + Max SequenceNumberAction = "max" + Update SequenceNumberAction = "update" +) + +type setPropertiesOptions struct { + input SetPropertiesInput +} + +func (s setPropertiesOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + if s.input.CacheControl != nil { + headers.Append("x-ms-blob-cache-control", *s.input.CacheControl) + } + if s.input.ContentDisposition != nil { + headers.Append("x-ms-blob-content-disposition", *s.input.ContentDisposition) + } + if s.input.ContentEncoding != nil { + headers.Append("x-ms-blob-content-encoding", *s.input.ContentEncoding) + } + if s.input.ContentLanguage != nil { + headers.Append("x-ms-blob-content-language", *s.input.ContentLanguage) + } + if s.input.ContentMD5 != nil { + headers.Append("x-ms-blob-content-md5", *s.input.ContentMD5) + } + if s.input.ContentType != nil { + headers.Append("x-ms-blob-content-type", *s.input.ContentType) + } + if s.input.ContentLength != nil { + headers.Append("x-ms-blob-content-length", strconv.Itoa(int(*s.input.ContentLength))) + } + if s.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *s.input.LeaseID) + } + if s.input.SequenceNumberAction != nil { + headers.Append("x-ms-sequence-number-action", string(*s.input.SequenceNumberAction)) + } + if s.input.BlobSequenceNumber != nil { + headers.Append("x-ms-blob-sequence-number", *s.input.BlobSequenceNumber) + } + + return headers +} + +func (s setPropertiesOptions) ToOData() *odata.Query { + return nil +} + +func (s setPropertiesOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "properties") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_append_blob.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_append_blob.go new file mode 100644 index 0000000000000..8cc53001882f3 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_append_blob.go @@ -0,0 +1,128 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type PutAppendBlobInput struct { + CacheControl *string + ContentDisposition *string + ContentEncoding *string + ContentLanguage *string + ContentMD5 *string + ContentType *string + LeaseID *string + EncryptionScope *string + MetaData map[string]string +} + +type PutAppendBlobResponse struct { + HttpResponse *http.Response +} + +// PutAppendBlob is a wrapper around the Put API call (with a stricter input object) +// which creates a new append blob, or updates the content of an existing blob. +func (c Client) PutAppendBlob(ctx context.Context, containerName, blobName string, input PutAppendBlobInput) (result PutAppendBlobResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf(fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: putAppendBlobOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type putAppendBlobOptions struct { + input PutAppendBlobInput +} + +func (p putAppendBlobOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + headers.Append("x-ms-blob-type", string(AppendBlob)) + headers.Append("Content-Length", "0") + + if p.input.CacheControl != nil { + headers.Append("x-ms-blob-cache-control", *p.input.CacheControl) + } + if p.input.ContentDisposition != nil { + headers.Append("x-ms-blob-content-disposition", *p.input.ContentDisposition) + } + if p.input.ContentEncoding != nil { + headers.Append("x-ms-blob-content-encoding", *p.input.ContentEncoding) + } + if p.input.ContentLanguage != nil { + headers.Append("x-ms-blob-content-language", *p.input.ContentLanguage) + } + if p.input.ContentMD5 != nil { + headers.Append("x-ms-blob-content-md5", *p.input.ContentMD5) + } + if p.input.ContentType != nil { + headers.Append("x-ms-blob-content-type", *p.input.ContentType) + } + if p.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *p.input.LeaseID) + } + if p.input.EncryptionScope != nil { + headers.Append("x-ms-encryption-scope", *p.input.EncryptionScope) + } + + headers.Merge(metadata.SetMetaDataHeaders(p.input.MetaData)) + return headers +} + +func (p putAppendBlobOptions) ToOData() *odata.Query { + return nil +} + +func (p putAppendBlobOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block.go new file mode 100644 index 0000000000000..f261ddec31408 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block.go @@ -0,0 +1,119 @@ +package blobs + +import ( + "bytes" + "context" + "fmt" + "io" + "net/http" + "strconv" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type PutBlockInput struct { + BlockID string + Content []byte + ContentMD5 *string + LeaseID *string + EncryptionScope *string +} + +type PutBlockResponse struct { + HttpResponse *http.Response + ContentMD5 string +} + +// PutBlock creates a new block to be committed as part of a blob. +func (c Client) PutBlock(ctx context.Context, containerName, blobName string, input PutBlockInput) (result PutBlockResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if input.BlockID == "" { + err = fmt.Errorf("`input.BlockID` cannot be an empty string") + return + } + + if len(input.Content) == 0 { + err = fmt.Errorf("`input.Content` cannot be empty") + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: putBlockOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + req.ContentLength = int64(len(input.Content)) + req.Body = io.NopCloser(bytes.NewReader(input.Content)) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type putBlockOptions struct { + input PutBlockInput +} + +func (p putBlockOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("Content-Length", strconv.Itoa(len(p.input.Content))) + + if p.input.ContentMD5 != nil { + headers.Append("x-ms-blob-content-md5", *p.input.ContentMD5) + } + if p.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *p.input.LeaseID) + } + if p.input.EncryptionScope != nil { + headers.Append("x-ms-encryption-scope", *p.input.EncryptionScope) + } + + return headers +} + +func (p putBlockOptions) ToOData() *odata.Query { + return nil +} + +func (p putBlockOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "block") + out.Append("blockid", p.input.BlockID) + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_blob.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_blob.go new file mode 100644 index 0000000000000..d5d677393c9ed --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_blob.go @@ -0,0 +1,147 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strconv" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type PutBlockBlobInput struct { + CacheControl *string + Content *[]byte + ContentDisposition *string + ContentEncoding *string + ContentLanguage *string + ContentMD5 *string + ContentType *string + LeaseID *string + EncryptionScope *string + MetaData map[string]string +} + +type PutBlockBlobResponse struct { + HttpResponse *http.Response +} + +// PutBlockBlob is a wrapper around the Put API call (with a stricter input object) +// which creates a new block append blob, or updates the content of an existing block blob. +func (c Client) PutBlockBlob(ctx context.Context, containerName, blobName string, input PutBlockBlobInput) (result PutBlockBlobResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if input.Content != nil && len(*input.Content) == 0 { + err = fmt.Errorf("`input.Content` must either be nil or not empty") + return + } + + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf(fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: putBlockBlobOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + if input.ContentType != nil { + opts.ContentType = *input.ContentType + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + err = req.Marshal(input.Content) + if err != nil { + err = fmt.Errorf("marshalling request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type putBlockBlobOptions struct { + input PutBlockBlobInput +} + +func (p putBlockBlobOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("x-ms-blob-type", string(BlockBlob)) + + if p.input.CacheControl != nil { + headers.Append("x-ms-blob-cache-control", *p.input.CacheControl) + } + if p.input.ContentDisposition != nil { + headers.Append("x-ms-blob-content-disposition", *p.input.ContentDisposition) + } + if p.input.ContentEncoding != nil { + headers.Append("x-ms-blob-content-encoding", *p.input.ContentEncoding) + } + if p.input.ContentLanguage != nil { + headers.Append("x-ms-blob-content-language", *p.input.ContentLanguage) + } + if p.input.ContentMD5 != nil { + headers.Append("x-ms-blob-content-md5", *p.input.ContentMD5) + } + if p.input.ContentType != nil { + headers.Append("x-ms-blob-content-type", *p.input.ContentType) + } + if p.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *p.input.LeaseID) + } + if p.input.EncryptionScope != nil { + headers.Append("x-ms-encryption-scope", *p.input.EncryptionScope) + } + if p.input.Content != nil { + headers.Append("Content-Length", strconv.Itoa(len(*p.input.Content))) + } + + headers.Merge(metadata.SetMetaDataHeaders(p.input.MetaData)) + + return headers +} + +func (p putBlockBlobOptions) ToOData() *odata.Query { + return nil +} + +func (p putBlockBlobOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_block_blob_file.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_blob_file.go similarity index 50% rename from vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_block_blob_file.go rename to vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_blob_file.go index b7499498aeca2..f5f21b0736edf 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs/put_block_blob_file.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_blob_file.go @@ -8,10 +8,10 @@ import ( ) // PutBlockBlobFromFile is a helper method which takes a file, and automatically chunks it up, rather than having to do this yourself -func (client Client) PutBlockBlobFromFile(ctx context.Context, accountName, containerName, blobName string, file *os.File, input PutBlockBlobInput) error { +func (c Client) PutBlockBlobFromFile(ctx context.Context, containerName, blobName string, file *os.File, input PutBlockBlobInput) error { fileInfo, err := file.Stat() if err != nil { - return fmt.Errorf("Error loading file info: %s", err) + return fmt.Errorf("loading file info: %s", err) } fileSize := fileInfo.Size() @@ -20,14 +20,14 @@ func (client Client) PutBlockBlobFromFile(ctx context.Context, accountName, cont _, err = file.ReadAt(bytes, 0) if err != nil { if err != io.EOF { - return fmt.Errorf("Error reading bytes: %s", err) + return fmt.Errorf("reading bytes: %s", err) } } input.Content = &bytes - if _, err = client.PutBlockBlob(ctx, accountName, containerName, blobName, input); err != nil { - return fmt.Errorf("Error putting bytes: %s", err) + if _, err = c.PutBlockBlob(ctx, containerName, blobName, input); err != nil { + return fmt.Errorf("putting bytes: %s", err) } return nil diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_list.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_list.go new file mode 100644 index 0000000000000..a600fdbe369a2 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_list.go @@ -0,0 +1,151 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type BlockList struct { + CommittedBlockIDs []BlockID `xml:"Committed,omitempty"` + UncommittedBlockIDs []BlockID `xml:"Uncommitted,omitempty"` + LatestBlockIDs []BlockID `xml:"Latest,omitempty"` +} + +type BlockID struct { + Value string `xml:",chardata"` +} + +type PutBlockListInput struct { + BlockList BlockList + CacheControl *string + ContentDisposition *string + ContentEncoding *string + ContentLanguage *string + ContentMD5 *string + ContentType *string + LeaseID *string + EncryptionScope *string + MetaData map[string]string +} + +type PutBlockListResponse struct { + HttpResponse *http.Response + + ContentMD5 string + ETag string + LastModified string +} + +// PutBlockList writes a blob by specifying the list of block IDs that make up the blob. +// In order to be written as part of a blob, a block must have been successfully written +// to the server in a prior Put Block operation. +func (c Client) PutBlockList(ctx context.Context, containerName, blobName string, input PutBlockListInput) (result PutBlockListResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: putBlockListOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + err = req.Marshal(&input.BlockList) + if err != nil { + err = fmt.Errorf("marshalling request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.ContentMD5 = resp.Header.Get("Content-MD5") + result.ETag = resp.Header.Get("ETag") + result.LastModified = resp.Header.Get("Last-Modified") + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type putBlockListOptions struct { + input PutBlockListInput +} + +func (p putBlockListOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + if p.input.CacheControl != nil { + headers.Append("x-ms-blob-cache-control", *p.input.CacheControl) + } + if p.input.ContentDisposition != nil { + headers.Append("x-ms-blob-content-disposition", *p.input.ContentDisposition) + } + if p.input.ContentEncoding != nil { + headers.Append("x-ms-blob-content-encoding", *p.input.ContentEncoding) + } + if p.input.ContentLanguage != nil { + headers.Append("x-ms-blob-content-language", *p.input.ContentLanguage) + } + if p.input.ContentMD5 != nil { + headers.Append("x-ms-blob-content-md5", *p.input.ContentMD5) + } + if p.input.ContentType != nil { + headers.Append("x-ms-blob-content-type", *p.input.ContentType) + } + if p.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *p.input.LeaseID) + } + if p.input.EncryptionScope != nil { + headers.Append("x-ms-encryption-scope", *p.input.EncryptionScope) + } + + headers.Merge(metadata.SetMetaDataHeaders(p.input.MetaData)) + + return headers +} + +func (p putBlockListOptions) ToOData() *odata.Query { + return nil +} + +func (p putBlockListOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "blocklist") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_url.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_url.go new file mode 100644 index 0000000000000..088742367bea0 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_block_url.go @@ -0,0 +1,122 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type PutBlockFromURLInput struct { + BlockID string + CopySource string + + ContentMD5 *string + LeaseID *string + Range *string + EncryptionScope *string +} + +type PutBlockFromURLResponse struct { + ContentMD5 string + HttpResponse *http.Response +} + +// PutBlockFromURL creates a new block to be committed as part of a blob where the contents are read from a URL +func (c Client) PutBlockFromURL(ctx context.Context, containerName, blobName string, input PutBlockFromURLInput) (result PutBlockFromURLResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if input.BlockID == "" { + err = fmt.Errorf("`input.BlockID` cannot be an empty string") + return + } + + if input.CopySource == "" { + err = fmt.Errorf("`input.CopySource` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: putBlockUrlOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.ContentMD5 = resp.Header.Get("Content-MD5") + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type putBlockUrlOptions struct { + input PutBlockFromURLInput +} + +func (p putBlockUrlOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + headers.Append("x-ms-copy-source", p.input.CopySource) + + if p.input.ContentMD5 != nil { + headers.Append("x-ms-source-content-md5", *p.input.ContentMD5) + } + if p.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *p.input.LeaseID) + } + if p.input.Range != nil { + headers.Append("x-ms-source-range", *p.input.Range) + } + if p.input.EncryptionScope != nil { + headers.Append("x-ms-encryption-scope", *p.input.EncryptionScope) + } + return headers +} + +func (p putBlockUrlOptions) ToOData() *odata.Query { + return nil +} + +func (p putBlockUrlOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "block") + out.Append("blockid", p.input.BlockID) + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_blob.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_blob.go new file mode 100644 index 0000000000000..74bfc6b2b2601 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_blob.go @@ -0,0 +1,155 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strconv" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type PutPageBlobInput struct { + CacheControl *string + ContentDisposition *string + ContentEncoding *string + ContentLanguage *string + ContentMD5 *string + ContentType *string + LeaseID *string + EncryptionScope *string + MetaData map[string]string + + BlobContentLengthBytes int64 + BlobSequenceNumber *int64 + AccessTier *AccessTier +} + +type PutPageBlobResponse struct { + HttpResponse *http.Response +} + +// PutPageBlob is a wrapper around the Put API call (with a stricter input object) +// which creates a new block blob, or updates the content of an existing page blob. +func (c Client) PutPageBlob(ctx context.Context, containerName, blobName string, input PutPageBlobInput) (result PutPageBlobResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if input.BlobContentLengthBytes == 0 || input.BlobContentLengthBytes%512 != 0 { + err = fmt.Errorf("`input.BlobContentLengthBytes` must be aligned to a 512-byte boundary") + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: putPageBlobOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type putPageBlobOptions struct { + input PutPageBlobInput +} + +func (p putPageBlobOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + headers.Append("x-ms-blob-type", string(PageBlob)) + + // For a page blob or an page blob, the value of this header must be set to zero, + // as Put Blob is used only to initialize the blob + headers.Append("Content-Length", "0") + + // This header specifies the maximum size for the page blob, up to 8 TB. + // The page blob size must be aligned to a 512-byte boundary. + headers.Append("x-ms-blob-content-length", strconv.Itoa(int(p.input.BlobContentLengthBytes))) + + if p.input.AccessTier != nil { + headers.Append("x-ms-access-tier", string(*p.input.AccessTier)) + } + + if p.input.BlobSequenceNumber != nil { + headers.Append("x-ms-blob-sequence-number", strconv.Itoa(int(*p.input.BlobSequenceNumber))) + } + + if p.input.CacheControl != nil { + headers.Append("x-ms-blob-cache-control", *p.input.CacheControl) + } + + if p.input.ContentDisposition != nil { + headers.Append("x-ms-blob-content-disposition", *p.input.ContentDisposition) + } + + if p.input.ContentEncoding != nil { + headers.Append("x-ms-blob-content-encoding", *p.input.ContentEncoding) + } + + if p.input.ContentLanguage != nil { + headers.Append("x-ms-blob-content-language", *p.input.ContentLanguage) + } + + if p.input.ContentMD5 != nil { + headers.Append("x-ms-blob-content-md5", *p.input.ContentMD5) + } + + if p.input.ContentType != nil { + headers.Append("x-ms-blob-content-type", *p.input.ContentType) + } + + if p.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *p.input.LeaseID) + } + + if p.input.EncryptionScope != nil { + headers.Append("x-ms-encryption-scope", *p.input.EncryptionScope) + } + + headers.Merge(metadata.SetMetaDataHeaders(p.input.MetaData)) + return headers +} + +func (p putPageBlobOptions) ToOData() *odata.Query { + return nil +} + +func (p putPageBlobOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_clear.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_clear.go new file mode 100644 index 0000000000000..45e0499e431d1 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_clear.go @@ -0,0 +1,110 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type PutPageClearInput struct { + StartByte int64 + EndByte int64 + + LeaseID *string + EncryptionScope *string +} + +type PutPageClearResponse struct { + HttpResponse *http.Response +} + +// PutPageClear clears a range of pages within a page blob. +func (c Client) PutPageClear(ctx context.Context, containerName, blobName string, input PutPageClearInput) (result PutPageClearResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if input.StartByte < 0 { + err = fmt.Errorf("`input.StartByte` must be greater than or equal to 0") + return + } + + if input.EndByte <= 0 { + err = fmt.Errorf("`input.EndByte` must be greater than 0") + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: putPageClearOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type putPageClearOptions struct { + input PutPageClearInput +} + +func (p putPageClearOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + headers.Append("x-ms-page-write", "clear") + headers.Append("x-ms-range", fmt.Sprintf("bytes=%d-%d", p.input.StartByte, p.input.EndByte)) + + if p.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *p.input.LeaseID) + } + if p.input.EncryptionScope != nil { + headers.Append("x-ms-encryption-scope", *p.input.EncryptionScope) + } + + return headers +} + +func (p putPageClearOptions) ToOData() *odata.Query { + return nil +} + +func (p putPageClearOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "page") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_update.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_update.go new file mode 100644 index 0000000000000..ab5f258373e37 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/put_page_update.go @@ -0,0 +1,171 @@ +package blobs + +import ( + "bytes" + "context" + "fmt" + "io" + "net/http" + "strconv" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type PutPageUpdateInput struct { + StartByte int64 + EndByte int64 + Content []byte + + IfSequenceNumberEQ *string + IfSequenceNumberLE *string + IfSequenceNumberLT *string + IfModifiedSince *string + IfUnmodifiedSince *string + IfMatch *string + IfNoneMatch *string + LeaseID *string + EncryptionScope *string +} + +type PutPageUpdateResponse struct { + HttpResponse *http.Response + + BlobSequenceNumber string + ContentMD5 string + LastModified string +} + +// PutPageUpdate writes a range of pages to a page blob. +func (c Client) PutPageUpdate(ctx context.Context, containerName, blobName string, input PutPageUpdateInput) (result PutPageUpdateResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if input.StartByte < 0 { + err = fmt.Errorf("`input.StartByte` must be greater than or equal to 0") + return + } + + if input.EndByte <= 0 { + err = fmt.Errorf("`input.EndByte` must be greater than 0") + return + } + + expectedSize := (input.EndByte - input.StartByte) + 1 + actualSize := int64(len(input.Content)) + if expectedSize != actualSize { + err = fmt.Errorf(fmt.Sprintf("Content Size was defined as %d but got %d.", expectedSize, actualSize)) + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: putPageUpdateOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + // this is needed to avoid `Content-Length: 0` in the request + req.Body = io.NopCloser(bytes.NewReader(input.Content)) + req.ContentLength = int64(len(input.Content)) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.BlobSequenceNumber = resp.Header.Get("x-ms-blob-sequence-number") + result.ContentMD5 = resp.Header.Get("Content-MD5") + result.LastModified = resp.Header.Get("Last-Modified") + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type putPageUpdateOptions struct { + input PutPageUpdateInput +} + +func (p putPageUpdateOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("x-ms-page-write", "update") + headers.Append("x-ms-range", fmt.Sprintf("bytes=%d-%d", p.input.StartByte, p.input.EndByte)) + headers.Append("Content-Length", strconv.Itoa(len(p.input.Content))) + + if p.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *p.input.LeaseID) + } + + if p.input.EncryptionScope != nil { + headers.Append("x-ms-encryption-scope", *p.input.EncryptionScope) + } + + if p.input.IfSequenceNumberEQ != nil { + headers.Append("x-ms-if-sequence-number-eq", *p.input.IfSequenceNumberEQ) + } + + if p.input.IfSequenceNumberLE != nil { + headers.Append("x-ms-if-sequence-number-le", *p.input.IfSequenceNumberLE) + } + + if p.input.IfSequenceNumberLT != nil { + headers.Append("x-ms-if-sequence-number-lt", *p.input.IfSequenceNumberLT) + } + + if p.input.IfModifiedSince != nil { + headers.Append("If-Modified-Since", *p.input.IfModifiedSince) + } + + if p.input.IfUnmodifiedSince != nil { + headers.Append("If-Unmodified-Since", *p.input.IfUnmodifiedSince) + } + + if p.input.IfMatch != nil { + headers.Append("If-Match", *p.input.IfMatch) + } + + if p.input.IfNoneMatch != nil { + headers.Append("If-None-Match", *p.input.IfNoneMatch) + } + + return headers +} + +func (p putPageUpdateOptions) ToOData() *odata.Query { + return nil +} + +func (p putPageUpdateOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "page") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/resource_id.go new file mode 100644 index 0000000000000..95b78f5ca780f --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/resource_id.go @@ -0,0 +1,83 @@ +package blobs + +import ( + "fmt" + "net/url" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts" +) + +// TODO: update this to implement `resourceids.ResourceId` once +// https://github.com/hashicorp/go-azure-helpers/issues/187 is fixed +var _ resourceids.Id = BlobId{} + +type BlobId struct { + // AccountId specifies the ID of the Storage Account where this Blob exists. + AccountId accounts.AccountId + + // ContainerName specifies the name of the Container within this Storage Account where this + // Blob exists. + ContainerName string + + // BlobName specifies the name of this Blob. + BlobName string +} + +func NewBlobID(accountId accounts.AccountId, containerName, blobName string) BlobId { + return BlobId{ + AccountId: accountId, + ContainerName: containerName, + BlobName: blobName, + } +} + +func (b BlobId) ID() string { + return fmt.Sprintf("%s/%s/%s", b.AccountId.ID(), b.ContainerName, b.BlobName) +} + +func (b BlobId) String() string { + components := []string{ + fmt.Sprintf("Account %q", b.AccountId.String()), + fmt.Sprintf("Container Name %q", b.ContainerName), + } + return fmt.Sprintf("Blob %q (%s)", b.BlobName, strings.Join(components, " / ")) +} + +// ParseBlobID parses `input` into a Blob ID using a known `domainSuffix` +func ParseBlobID(input, domainSuffix string) (*BlobId, error) { + // example: https://foo.blob.core.windows.net/Bar/example.vhd + if input == "" { + return nil, fmt.Errorf("`input` was empty") + } + + account, err := accounts.ParseAccountID(input, domainSuffix) + if err != nil { + return nil, fmt.Errorf("parsing account %q: %+v", input, err) + } + + if account.SubDomainType != accounts.BlobSubDomainType { + return nil, fmt.Errorf("expected the subdomain type to be %q but got %q", string(accounts.BlobSubDomainType), string(account.SubDomainType)) + } + + uri, err := url.Parse(input) + if err != nil { + return nil, fmt.Errorf("parsing %q as a uri: %+v", input, err) + } + + path := strings.TrimPrefix(uri.Path, "/") + segments := strings.Split(path, "/") + if len(segments) != 2 { + return nil, fmt.Errorf("expected the path to contain 2 segments but got %d", len(segments)) + } + + containerName := segments[0] + blobName := strings.TrimPrefix(path, containerName) + blobName = strings.TrimPrefix(blobName, "/") + return &BlobId{ + AccountId: *account, + ContainerName: containerName, + BlobName: blobName, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/set_tier.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/set_tier.go new file mode 100644 index 0000000000000..66b9d64884ae4 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/set_tier.go @@ -0,0 +1,87 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type SetTierInput struct { + Tier AccessTier +} + +type SetTierResponse struct { + HttpResponse *http.Response +} + +// SetTier sets the tier on a blob. +func (c Client) SetTier(ctx context.Context, containerName, blobName string, input SetTierInput) (result SetTierResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusOK, + http.StatusAccepted, + }, + HttpMethod: http.MethodPut, + OptionsObject: setTierOptions{ + tier: input.Tier, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type setTierOptions struct { + tier AccessTier +} + +func (s setTierOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("x-ms-access-tier", string(s.tier)) + return headers +} + +func (s setTierOptions) ToOData() *odata.Query { + return nil +} + +func (s setTierOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "tier") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/snapshot.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/snapshot.go new file mode 100644 index 0000000000000..ebbcb2011220b --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/snapshot.go @@ -0,0 +1,158 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type SnapshotInput struct { + // The ID of the Lease + // This must be specified if a Lease is present on the Blob, else a 403 is returned + LeaseID *string + + // The encryption scope to set for the request content. + EncryptionScope *string + + // MetaData is a user-defined name-value pair associated with the blob. + // If no name-value pairs are specified, the operation will copy the base blob metadata to the snapshot. + // If one or more name-value pairs are specified, the snapshot is created with the specified metadata, + // and metadata is not copied from the base blob. + MetaData map[string]string + + // A DateTime value which will only snapshot the blob if it has been modified since the specified date/time + // If the base blob has not been modified, the Blob service returns status code 412 (Precondition Failed). + IfModifiedSince *string + + // A DateTime value which will only snapshot the blob if it has not been modified since the specified date/time + // If the base blob has been modified, the Blob service returns status code 412 (Precondition Failed). + IfUnmodifiedSince *string + + // An ETag value to snapshot the blob only if its ETag value matches the value specified. + // If the values do not match, the Blob service returns status code 412 (Precondition Failed). + IfMatch *string + + // An ETag value for this conditional header to snapshot the blob only if its ETag value + // does not match the value specified. + // If the values are identical, the Blob service returns status code 412 (Precondition Failed). + IfNoneMatch *string +} + +type SnapshotResponse struct { + HttpResponse *http.Response + + // The ETag of the snapshot + ETag string + + // A DateTime value that uniquely identifies the snapshot. + // The value of this header indicates the snapshot version, + // and may be used in subsequent requests to access the snapshot. + SnapshotDateTime string +} + +// Snapshot captures a Snapshot of a given Blob +func (c Client) Snapshot(ctx context.Context, containerName, blobName string, input SnapshotInput) (result SnapshotResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf(fmt.Sprintf("`input.MetaData` is not valid: %s.", err)) + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: snapshotOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.ETag = resp.Header.Get("ETag") + result.SnapshotDateTime = resp.Header.Get("x-ms-snapshot") + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type snapshotOptions struct { + input SnapshotInput +} + +func (s snapshotOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + if s.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *s.input.LeaseID) + } + + if s.input.EncryptionScope != nil { + headers.Append("x-ms-encryption-scope", *s.input.EncryptionScope) + } + + if s.input.IfModifiedSince != nil { + headers.Append("If-Modified-Since", *s.input.IfModifiedSince) + } + + if s.input.IfUnmodifiedSince != nil { + headers.Append("If-Unmodified-Since", *s.input.IfUnmodifiedSince) + } + + if s.input.IfMatch != nil { + headers.Append("If-Match", *s.input.IfMatch) + } + + if s.input.IfNoneMatch != nil { + headers.Append("If-None-Match", *s.input.IfNoneMatch) + } + + headers.Merge(metadata.SetMetaDataHeaders(s.input.MetaData)) + return headers +} + +func (s snapshotOptions) ToOData() *odata.Query { + return nil +} + +func (s snapshotOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "snapshot") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/snapshot_get_properties.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/snapshot_get_properties.go new file mode 100644 index 0000000000000..09e53cf43f19f --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/snapshot_get_properties.go @@ -0,0 +1,168 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strconv" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type GetSnapshotPropertiesInput struct { + // The ID of the Lease + // This must be specified if a Lease is present on the Blob, else a 403 is returned + LeaseID *string + + // The ID of the Snapshot which should be retrieved + SnapshotID string +} + +// GetSnapshotProperties returns all user-defined metadata, standard HTTP properties, and system properties for +// the specified snapshot of a blob +func (c Client) GetSnapshotProperties(ctx context.Context, containerName, blobName string, input GetSnapshotPropertiesInput) (result GetPropertiesResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + if input.SnapshotID == "" { + err = fmt.Errorf("`input.SnapshotID` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + OptionsObject: snapshotGetPropertiesOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.AccessTier = AccessTier(resp.Header.Get("x-ms-access-tier")) + result.AccessTierChangeTime = resp.Header.Get("x-ms-access-tier-change-time") + result.ArchiveStatus = ArchiveStatus(resp.Header.Get("x-ms-archive-status")) + result.BlobCommittedBlockCount = resp.Header.Get("x-ms-blob-committed-block-count") + result.BlobSequenceNumber = resp.Header.Get("x-ms-blob-sequence-number") + result.BlobType = BlobType(resp.Header.Get("x-ms-blob-type")) + result.CacheControl = resp.Header.Get("Cache-Control") + result.ContentDisposition = resp.Header.Get("Content-Disposition") + result.ContentEncoding = resp.Header.Get("Content-Encoding") + result.ContentLanguage = resp.Header.Get("Content-Language") + result.ContentMD5 = resp.Header.Get("Content-MD5") + result.ContentType = resp.Header.Get("Content-Type") + result.CopyCompletionTime = resp.Header.Get("x-ms-copy-completion-time") + result.CopyDestinationSnapshot = resp.Header.Get("x-ms-copy-destination-snapshot") + result.CopyID = resp.Header.Get("x-ms-copy-id") + result.CopyProgress = resp.Header.Get("x-ms-copy-progress") + result.CopySource = resp.Header.Get("x-ms-copy-source") + result.CopyStatus = CopyStatus(resp.Header.Get("x-ms-copy-status")) + result.CopyStatusDescription = resp.Header.Get("x-ms-copy-status-description") + result.CreationTime = resp.Header.Get("x-ms-creation-time") + result.ETag = resp.Header.Get("Etag") + result.LastModified = resp.Header.Get("Last-Modified") + result.LeaseDuration = LeaseDuration(resp.Header.Get("x-ms-lease-duration")) + result.LeaseState = LeaseState(resp.Header.Get("x-ms-lease-state")) + result.LeaseStatus = LeaseStatus(resp.Header.Get("x-ms-lease-status")) + result.MetaData = metadata.ParseFromHeaders(resp.Header) + + if v := resp.Header.Get("Content-Length"); v != "" { + i, innerErr := strconv.Atoi(v) + if innerErr != nil { + err = fmt.Errorf("parsing `Content-Length` header value %q: %+v", v, innerErr) + } + + result.ContentLength = int64(i) + } + + if v := resp.Header.Get("x-ms-access-tier-inferred"); v != "" { + b, innerErr := strconv.ParseBool(v) + if innerErr != nil { + err = fmt.Errorf("parsing `x-ms-access-tier-inferred` header value %q: %+v", v, innerErr) + return + } + + result.AccessTierInferred = b + } + + if v := resp.Header.Get("x-ms-incremental-copy"); v != "" { + b, innerErr := strconv.ParseBool(v) + if innerErr != nil { + err = fmt.Errorf("parsing `x-ms-incremental-copy` header value %q: %+v", v, innerErr) + return + } + + result.IncrementalCopy = b + } + + if v := resp.Header.Get("x-ms-server-encrypted"); v != "" { + b, innerErr := strconv.ParseBool(v) + if innerErr != nil { + err = fmt.Errorf("parsing `\"x-ms-server-encrypted` header value %q: %+v", v, innerErr) + return + } + + result.ServerEncrypted = b + } + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + if result.HttpResponse != nil { + } + + return +} + +type snapshotGetPropertiesOptions struct { + input GetSnapshotPropertiesInput +} + +func (s snapshotGetPropertiesOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + if s.input.LeaseID != nil { + headers.Append("x-ms-lease-id", *s.input.LeaseID) + } + return headers +} + +func (s snapshotGetPropertiesOptions) ToOData() *odata.Query { + return nil +} + +func (s snapshotGetPropertiesOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("snapshot", s.input.SnapshotID) + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/undelete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/undelete.go new file mode 100644 index 0000000000000..149971fc1035e --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/undelete.go @@ -0,0 +1,76 @@ +package blobs + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type UndeleteResponse struct { + HttpResponse *http.Response +} + +// Undelete restores the contents and metadata of soft deleted blob and any associated soft deleted snapshots. +func (c Client) Undelete(ctx context.Context, containerName, blobName string) (result UndeleteResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + if strings.ToLower(containerName) != containerName { + err = fmt.Errorf("`containerName` must be a lower-cased string") + return + } + + if blobName == "" { + err = fmt.Errorf("`blobName` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: undeleteOptions{}, + Path: fmt.Sprintf("/%s/%s", containerName, blobName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type undeleteOptions struct{} + +func (u undeleteOptions) ToHeaders() *client.Headers { + return nil +} + +func (u undeleteOptions) ToOData() *odata.Query { + return nil +} + +func (u undeleteOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "undelete") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/version.go new file mode 100644 index 0000000000000..da934d3c1001f --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs/version.go @@ -0,0 +1,5 @@ +package blobs + +// APIVersion is the version of the API used for all Storage API Operations +const apiVersion = "2023-11-03" +const componentName = "blob/blobs" diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/README.md b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/README.md similarity index 50% rename from vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/README.md rename to vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/README.md index 9d375483ee8ef..6283cd7f71135 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/README.md +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/README.md @@ -1,4 +1,4 @@ -## Blob Storage Container SDK for API version 2020-08-04 +## Blob Storage Container SDK for API version 2023-11-03 This package allows you to interact with the Containers Blob Storage API @@ -17,26 +17,33 @@ package main import ( "context" "fmt" - "time" - - "github.com/Azure/go-autorest/autorest" - "github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers" + + "github.com/hashicorp/go-azure-sdk/sdk/auth" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers" ) func Example() error { accountName := "storageaccount1" storageAccountKey := "ABC123...." containerName := "mycontainer" - - storageAuth := autorest.NewSharedKeyLiteAuthorizer(accountName, storageAccountKey) - containersClient := containers.New() - containersClient.Client.Authorizer = storageAuth + domainSuffix := "core.windows.net" + + containersClient, err := containers.NewWithBaseUri(fmt.Sprintf("https://%s.blob.%s", accountName, domainSuffix)) + if err != nil { + return fmt.Errorf("building client for environment: %+v", err) + } + + auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey) + if err != nil { + return fmt.Errorf("building SharedKey authorizer: %+v", err) + } + containersClient.Client.SetAuthorizer(auth) ctx := context.TODO() createInput := containers.CreateInput{ AccessLevel: containers.Private, } - if _, err := containersClient.Create(ctx, accountName, containerName, createInput); err != nil { + if _, err := containersClient.Create(ctx, containerName, createInput); err != nil { return fmt.Errorf("Error creating Container: %s", err) } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/api.go new file mode 100644 index 0000000000000..0c6b65a274b53 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/api.go @@ -0,0 +1,20 @@ +package containers + +import ( + "context" +) + +type StorageContainer interface { + Create(ctx context.Context, containerName string, input CreateInput) (CreateResponse, error) + Delete(ctx context.Context, containerName string) (DeleteResponse, error) + GetProperties(ctx context.Context, containerName string, input GetPropertiesInput) (GetPropertiesResponse, error) + AcquireLease(ctx context.Context, containerName string, input AcquireLeaseInput) (AcquireLeaseResponse, error) + BreakLease(ctx context.Context, containerName string, input BreakLeaseInput) (BreakLeaseResponse, error) + ChangeLease(ctx context.Context, containerName string, input ChangeLeaseInput) (ChangeLeaseResponse, error) + ReleaseLease(ctx context.Context, containerName string, input ReleaseLeaseInput) (ReleaseLeaseResponse, error) + RenewLease(ctx context.Context, containerName string, input RenewLeaseInput) (RenewLeaseResponse, error) + ListBlobs(ctx context.Context, containerName string, input ListBlobsInput) (ListBlobsResponse, error) + GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, containerName string) string + SetAccessControl(ctx context.Context, containerName string, input SetAccessControlInput) (SetAccessControlResponse, error) + SetMetaData(ctx context.Context, containerName string, metaData SetMetaDataInput) (SetMetaDataResponse, error) +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/client.go new file mode 100644 index 0000000000000..ae8c43a21d22e --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/client.go @@ -0,0 +1,22 @@ +package containers + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/storage" +) + +// Client is the base client for Blob Storage Containers. +type Client struct { + Client *storage.Client +} + +func NewWithBaseUri(baseUri string) (*Client, error) { + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) + if err != nil { + return nil, fmt.Errorf("building base client: %+v", err) + } + return &Client{ + Client: baseClient, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/create.go new file mode 100644 index 0000000000000..05f898bd5fbd2 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/create.go @@ -0,0 +1,134 @@ +package containers + +import ( + "bytes" + "context" + "encoding/xml" + "fmt" + "io" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type CreateInput struct { + // Specifies whether data in the container may be accessed publicly and the level of access + AccessLevel AccessLevel + + // The encryption scope to set as the default on the container. + DefaultEncryptionScope string + + // Setting this to ture indicates that every blob that's uploaded to this container uses the default encryption scope. + EncryptionScopeOverrideDisabled bool + + // A name-value pair to associate with the container as metadata. + MetaData map[string]string +} + +type CreateResponse struct { + HttpResponse *http.Response +} + +// Create creates a new container under the specified account. +// If the container with the same name already exists, the operation fails. +func (c Client) Create(ctx context.Context, containerName string, input CreateInput) (result CreateResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf("`input.MetaData` is not valid: %+v", err) + return + } + + // Retry the container creation if a conflicting container is still in the process of being deleted + retryFunc := func(resp *http.Response, _ *odata.OData) (bool, error) { + if resp != nil { + if resp.StatusCode == http.StatusConflict { + // TODO: move this error response parsing to a common helper function + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return false, fmt.Errorf("could not parse response body") + } + resp.Body.Close() + respBody = bytes.TrimPrefix(respBody, []byte("\xef\xbb\xbf")) + res := ErrorResponse{} + if err = xml.Unmarshal(respBody, &res); err != nil { + return false, err + } + resp.Body = io.NopCloser(bytes.NewBuffer(respBody)) + if res.Code != nil { + return strings.Contains(*res.Code, "ContainerBeingDeleted"), nil + } + } + } + return false, nil + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: createOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s", containerName), + RetryFunc: retryFunc, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +var _ client.Options = createOptions{} + +type createOptions struct { + input CreateInput +} + +func (o createOptions) ToHeaders() *client.Headers { + headers := containerOptions{ + metaData: o.input.MetaData, + }.ToHeaders() + + // If this header is not included in the request, container data is private to the account owner. + if o.input.AccessLevel != Private { + headers.Append("x-ms-blob-public-access", string(o.input.AccessLevel)) + } + + if o.input.DefaultEncryptionScope != "" { + // These two headers must be used together. + headers.Append("x-ms-default-encryption-scope", o.input.DefaultEncryptionScope) + headers.Append("x-ms-deny-encryption-scope-override", fmt.Sprintf("%t", o.input.EncryptionScopeOverrideDisabled)) + } + + return headers +} + +func (createOptions) ToOData() *odata.Query { + return nil +} + +func (createOptions) ToQuery() *client.QueryParams { + return containerOptions{}.ToQuery() +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/delete.go new file mode 100644 index 0000000000000..d654e4aba8a75 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/delete.go @@ -0,0 +1,50 @@ +package containers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" +) + +type DeleteResponse struct { + HttpResponse *http.Response +} + +// Delete marks the specified container for deletion. +// The container and any blobs contained within it are later deleted during garbage collection. +func (c Client) Delete(ctx context.Context, containerName string) (result DeleteResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodDelete, + OptionsObject: containerOptions{}, + Path: fmt.Sprintf("/%s", containerName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/get_properties.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/get_properties.go new file mode 100644 index 0000000000000..ca97cf83a7f95 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/get_properties.go @@ -0,0 +1,110 @@ +package containers + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type GetPropertiesInput struct { + LeaseId string +} + +type GetPropertiesResponse struct { + ContainerProperties + HttpResponse *http.Response +} + +// GetProperties returns the properties for this Container without a Lease +func (c Client) GetProperties(ctx context.Context, containerName string, input GetPropertiesInput) (result GetPropertiesResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: getPropertiesOptions{ + leaseId: input.LeaseId, + }, + Path: fmt.Sprintf("/%s", containerName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.DefaultEncryptionScope = resp.Header.Get("x-ms-default-encryption-scope") + result.LeaseStatus = LeaseStatus(resp.Header.Get("x-ms-lease-status")) + result.LeaseState = LeaseState(resp.Header.Get("x-ms-lease-state")) + if result.LeaseStatus == Locked { + duration := LeaseDuration(resp.Header.Get("x-ms-lease-duration")) + result.LeaseDuration = &duration + } + + // If this header is not returned in the response, the container is private to the account owner. + accessLevel := resp.Header.Get("x-ms-blob-public-access") + if accessLevel != "" { + result.AccessLevel = AccessLevel(accessLevel) + } else { + result.AccessLevel = Private + } + + // we can't necessarily use strconv.ParseBool here since this could be nil (only in some API versions) + result.EncryptionScopeOverrideDisabled = strings.EqualFold(resp.Header.Get("x-ms-deny-encryption-scope-override"), "true") + result.HasImmutabilityPolicy = strings.EqualFold(resp.Header.Get("x-ms-has-immutability-policy"), "true") + result.HasLegalHold = strings.EqualFold(resp.Header.Get("x-ms-has-legal-hold"), "true") + + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +var _ client.Options = getPropertiesOptions{} + +type getPropertiesOptions struct { + leaseId string +} + +func (o getPropertiesOptions) ToHeaders() *client.Headers { + headers := containerOptions{}.ToHeaders() + + // If specified, Get Container Properties only succeeds if the container’s lease is active and matches this ID. + // If there is no active lease or the ID does not match, 412 (Precondition Failed) is returned. + if o.leaseId != "" { + headers.Append("x-ms-lease-id", o.leaseId) + } + + return headers +} + +func (getPropertiesOptions) ToOData() *odata.Query { + return nil +} + +func (getPropertiesOptions) ToQuery() *client.QueryParams { + return containerOptions{}.ToQuery() +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_acquire.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_acquire.go new file mode 100644 index 0000000000000..a863c14982476 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_acquire.go @@ -0,0 +1,103 @@ +package containers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type AcquireLeaseInput struct { + // 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 + LeaseDuration int + + ProposedLeaseID string +} + +type AcquireLeaseResponse struct { + AcquireLeaseModel + HttpResponse *http.Response +} + +type AcquireLeaseModel struct { + LeaseID string +} + +// AcquireLease establishes and manages a lock on a container for delete operations. +func (c Client) AcquireLease(ctx context.Context, containerName string, input AcquireLeaseInput) (result AcquireLeaseResponse, err error) { + if containerName == "" { + return result, fmt.Errorf("`containerName` cannot be an empty string") + } + // An infinite lease duration is -1 seconds. A non-infinite lease can be between 15 and 60 seconds + if input.LeaseDuration != -1 && (input.LeaseDuration <= 15 || input.LeaseDuration >= 60) { + return result, fmt.Errorf("`input.LeaseDuration` must be -1 (infinite), or between 15 and 60 seconds") + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: acquireLeaseOptions{ + leaseDuration: input.LeaseDuration, + proposedLeaseId: input.ProposedLeaseID, + }, + Path: fmt.Sprintf("/%s", containerName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.LeaseID = resp.Header.Get("x-ms-lease-id") + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +var _ client.Options = acquireLeaseOptions{} + +type acquireLeaseOptions struct { + leaseDuration int + proposedLeaseId string +} + +func (o acquireLeaseOptions) ToHeaders() *client.Headers { + headers := containerOptions{}.ToHeaders() + + headers.Append("x-ms-lease-action", "acquire") + headers.Append("x-ms-lease-duration", fmt.Sprintf("%d", o.leaseDuration)) + + if o.proposedLeaseId != "" { + headers.Append("x-ms-proposed-lease-id", o.proposedLeaseId) + } + + return headers +} + +func (o acquireLeaseOptions) ToOData() *odata.Query { + return nil +} + +func (o acquireLeaseOptions) ToQuery() *client.QueryParams { + query := containerOptions{}.ToQuery() + query.Append("comp", "lease") + return query +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_break.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_break.go new file mode 100644 index 0000000000000..b141e2582f007 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_break.go @@ -0,0 +1,114 @@ +package containers + +import ( + "context" + "fmt" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "net/http" + "strconv" +) + +type BreakLeaseInput 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 *int + + LeaseID string +} + +type BreakLeaseResponse struct { + BreakLeaseModel + HttpResponse *http.Response +} + +type BreakLeaseModel struct { + // Approximate time remaining in the lease period, in seconds. + // If the break is immediate, 0 is returned. + LeaseTime int +} + +// BreakLease breaks a lock based on it's Lease ID +func (c Client) BreakLease(ctx context.Context, containerName string, input BreakLeaseInput) (result BreakLeaseResponse, err error) { + if containerName == "" { + return result, fmt.Errorf("`containerName` cannot be an empty string") + } + if input.LeaseID == "" { + return result, fmt.Errorf("`input.LeaseID` cannot be an empty string") + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPut, + OptionsObject: breakLeaseOptions{ + breakPeriod: input.BreakPeriod, + leaseId: input.LeaseID, + }, + Path: fmt.Sprintf("/%s", containerName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + if leaseTimeRaw := resp.Header.Get("x-ms-lease-time"); leaseTimeRaw != "" { + if leaseTime, err := strconv.Atoi(leaseTimeRaw); err == nil { + result.LeaseTime = leaseTime + } + } + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +var _ client.Options = breakLeaseOptions{} + +type breakLeaseOptions struct { + breakPeriod *int + leaseId string +} + +func (o breakLeaseOptions) ToHeaders() *client.Headers { + headers := containerOptions{}.ToHeaders() + + headers.Append("x-ms-lease-action", "break") + headers.Append("x-ms-lease-id", o.leaseId) + + if o.breakPeriod != nil { + headers.Append("x-ms-lease-break-period", fmt.Sprintf("%d", *o.breakPeriod)) + } + + return headers +} + +func (o breakLeaseOptions) ToOData() *odata.Query { + return nil +} + +func (o breakLeaseOptions) ToQuery() *client.QueryParams { + query := containerOptions{}.ToQuery() + query.Append("comp", "lease") + return query +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_change.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_change.go new file mode 100644 index 0000000000000..1c1d7321066d4 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_change.go @@ -0,0 +1,102 @@ +package containers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type ChangeLeaseInput struct { + ExistingLeaseID string + ProposedLeaseID string +} + +type ChangeLeaseResponse struct { + ChangeLeaseModel + HttpResponse *http.Response +} + +type ChangeLeaseModel struct { + LeaseID string +} + +// ChangeLease changes the lock from one Lease ID to another Lease ID +func (c Client) ChangeLease(ctx context.Context, containerName string, input ChangeLeaseInput) (result ChangeLeaseResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + if input.ExistingLeaseID == "" { + err = fmt.Errorf("`input.ExistingLeaseID` cannot be an empty string") + return + } + if input.ProposedLeaseID == "" { + err = fmt.Errorf("`input.ProposedLeaseID` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: changeLeaseOptions{ + existingLeaseId: input.ExistingLeaseID, + proposedLeaseId: input.ProposedLeaseID, + }, + Path: fmt.Sprintf("/%s", containerName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.LeaseID = resp.Header.Get("x-ms-lease-id") + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +var _ client.Options = changeLeaseOptions{} + +type changeLeaseOptions struct { + existingLeaseId string + proposedLeaseId string +} + +func (o changeLeaseOptions) ToHeaders() *client.Headers { + headers := containerOptions{}.ToHeaders() + + headers.Append("x-ms-lease-action", "change") + headers.Append("x-ms-lease-id", o.existingLeaseId) + headers.Append("x-ms-proposed-lease-id", o.proposedLeaseId) + + return headers +} + +func (o changeLeaseOptions) ToOData() *odata.Query { + return nil +} + +func (o changeLeaseOptions) ToQuery() *client.QueryParams { + query := containerOptions{}.ToQuery() + query.Append("comp", "lease") + return query +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_release.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_release.go new file mode 100644 index 0000000000000..cdff4e2cf9ce8 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_release.go @@ -0,0 +1,85 @@ +package containers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type ReleaseLeaseInput struct { + LeaseId string +} + +type ReleaseLeaseResponse struct { + HttpResponse *http.Response +} + +// ReleaseLease releases the lock based on the Lease ID +func (c Client) ReleaseLease(ctx context.Context, containerName string, input ReleaseLeaseInput) (result ReleaseLeaseResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + if input.LeaseId == "" { + err = fmt.Errorf("`input.LeaseId` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: releaseLeaseOptions{ + leaseId: input.LeaseId, + }, + Path: fmt.Sprintf("/%s", containerName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +var _ client.Options = releaseLeaseOptions{} + +type releaseLeaseOptions struct { + leaseId string +} + +func (o releaseLeaseOptions) ToHeaders() *client.Headers { + headers := containerOptions{}.ToHeaders() + + headers.Append("x-ms-lease-action", "release") + headers.Append("x-ms-lease-id", o.leaseId) + + return headers +} + +func (o releaseLeaseOptions) ToOData() *odata.Query { + return nil +} + +func (o releaseLeaseOptions) ToQuery() *client.QueryParams { + query := containerOptions{}.ToQuery() + query.Append("comp", "lease") + return query +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_renew.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_renew.go new file mode 100644 index 0000000000000..38c948689996b --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/lease_renew.go @@ -0,0 +1,85 @@ +package containers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type RenewLeaseInput struct { + LeaseId string +} + +type RenewLeaseResponse struct { + HttpResponse *http.Response +} + +// RenewLease renews the lock based on the Lease ID +func (c Client) RenewLease(ctx context.Context, containerName string, input RenewLeaseInput) (result RenewLeaseResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + if input.LeaseId == "" { + err = fmt.Errorf("`input.LeaseId` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: renewLeaseOptions{ + leaseId: input.LeaseId, + }, + Path: fmt.Sprintf("/%s", containerName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +var _ client.Options = renewLeaseOptions{} + +type renewLeaseOptions struct { + leaseId string +} + +func (o renewLeaseOptions) ToHeaders() *client.Headers { + headers := containerOptions{}.ToHeaders() + + headers.Append("x-ms-lease-action", "renew") + headers.Append("x-ms-lease-id", o.leaseId) + + return headers +} + +func (o renewLeaseOptions) ToOData() *odata.Query { + return nil +} + +func (o renewLeaseOptions) ToQuery() *client.QueryParams { + query := containerOptions{}.ToQuery() + query.Append("comp", "lease") + return query +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/list_blobs.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/list_blobs.go new file mode 100644 index 0000000000000..86ddc7c0a9df0 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/list_blobs.go @@ -0,0 +1,177 @@ +package containers + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type ListBlobsInput struct { + Delimiter *string + Include *[]Dataset + Marker *string + MaxResults *int + Prefix *string +} + +type ListBlobsResponse struct { + ListBlobsResult + + HttpResponse *http.Response +} + +type ListBlobsResult struct { + Delimiter string `xml:"Delimiter"` + Marker string `xml:"Marker"` + MaxResults int `xml:"MaxResults"` + NextMarker *string `xml:"NextMarker,omitempty"` + Prefix string `xml:"Prefix"` + Blobs Blobs `xml:"Blobs"` +} + +type Blobs struct { + Blobs []BlobDetails `xml:"Blob"` + BlobPrefix *BlobPrefix `xml:"BlobPrefix"` +} + +type BlobDetails struct { + Name string `xml:"Name"` + Deleted bool `xml:"Deleted,omitempty"` + MetaData map[string]interface{} `map:"Metadata,omitempty"` + Properties *BlobProperties `xml:"Properties,omitempty"` + Snapshot *string `xml:"Snapshot,omitempty"` +} + +type BlobProperties struct { + AccessTier *string `xml:"AccessTier,omitempty"` + AccessTierInferred *bool `xml:"AccessTierInferred,omitempty"` + AccessTierChangeTime *string `xml:"AccessTierChangeTime,omitempty"` + BlobType *string `xml:"BlobType,omitempty"` + BlobSequenceNumber *string `xml:"x-ms-blob-sequence-number,omitempty"` + CacheControl *string `xml:"Cache-Control,omitempty"` + ContentEncoding *string `xml:"ContentEncoding,omitempty"` + ContentLanguage *string `xml:"Content-Language,omitempty"` + ContentLength *int64 `xml:"Content-Length,omitempty"` + ContentMD5 *string `xml:"Content-MD5,omitempty"` + ContentType *string `xml:"Content-Type,omitempty"` + CopyCompletionTime *string `xml:"CopyCompletionTime,omitempty"` + CopyId *string `xml:"CopyId,omitempty"` + CopyStatus *string `xml:"CopyStatus,omitempty"` + CopySource *string `xml:"CopySource,omitempty"` + CopyProgress *string `xml:"CopyProgress,omitempty"` + CopyStatusDescription *string `xml:"CopyStatusDescription,omitempty"` + CreationTime *string `xml:"CreationTime,omitempty"` + ETag *string `xml:"Etag,omitempty"` + DeletedTime *string `xml:"DeletedTime,omitempty"` + IncrementalCopy *bool `xml:"IncrementalCopy,omitempty"` + LastModified *string `xml:"Last-Modified,omitempty"` + LeaseDuration *string `xml:"LeaseDuration,omitempty"` + LeaseState *string `xml:"LeaseState,omitempty"` + LeaseStatus *string `xml:"LeaseStatus,omitempty"` + RemainingRetentionDays *string `xml:"RemainingRetentionDays,omitempty"` + ServerEncrypted *bool `xml:"ServerEncrypted,omitempty"` +} + +type BlobPrefix struct { + Name string `xml:"Name"` +} + +// ListBlobs lists the blobs matching the specified query within the specified Container +func (c Client) ListBlobs(ctx context.Context, containerName string, input ListBlobsInput) (result ListBlobsResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + if input.MaxResults != nil && (*input.MaxResults <= 0 || *input.MaxResults > 5000) { + err = fmt.Errorf("`input.MaxResults` can either be nil or between 0 and 5000") + return + } + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: listBlobsOptions{ + delimiter: input.Delimiter, + include: input.Include, + marker: input.Marker, + maxResults: input.MaxResults, + prefix: input.Prefix, + }, + Path: fmt.Sprintf("/%s", containerName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +var _ client.Options = listBlobsOptions{} + +type listBlobsOptions struct { + delimiter *string + include *[]Dataset + marker *string + maxResults *int + prefix *string +} + +func (o listBlobsOptions) ToHeaders() *client.Headers { + return nil +} + +func (o listBlobsOptions) ToOData() *odata.Query { + return nil +} + +func (o listBlobsOptions) ToQuery() *client.QueryParams { + query := containerOptions{}.ToQuery() + query.Append("comp", "list") + + if o.delimiter != nil { + query.Append("delimiter", *o.delimiter) + } + if o.include != nil { + vals := make([]string, 0) + for _, v := range *o.include { + vals = append(vals, string(v)) + } + include := strings.Join(vals, ",") + query.Append("include", include) + } + if o.marker != nil { + query.Append("marker", *o.marker) + } + if o.maxResults != nil { + query.Append("maxresults", fmt.Sprintf("%d", *o.maxResults)) + } + if o.prefix != nil { + query.Append("prefix", *o.prefix) + } + return query +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/models.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/models.go similarity index 74% rename from vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/models.go rename to vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/models.go index adba36818aa10..94c3b86b29162 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers/models.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/models.go @@ -1,6 +1,6 @@ package containers -import "github.com/Azure/go-autorest/autorest" +import "encoding/xml" type AccessLevel string @@ -21,15 +21,15 @@ var ( ) type ContainerProperties struct { - autorest.Response - - AccessLevel AccessLevel - LeaseStatus LeaseStatus - LeaseState LeaseState - LeaseDuration *LeaseDuration - MetaData map[string]string - HasImmutabilityPolicy bool - HasLegalHold bool + AccessLevel AccessLevel + DefaultEncryptionScope string + EncryptionScopeOverrideDisabled bool + LeaseStatus LeaseStatus + LeaseState LeaseState + LeaseDuration *LeaseDuration + MetaData map[string]string + HasImmutabilityPolicy bool + HasLegalHold bool } type Dataset string @@ -43,8 +43,9 @@ var ( ) type ErrorResponse struct { - Code *string `xml:"Code"` - Message *string `xml:"Message"` + XMLName xml.Name `xml:"Error"` + Code *string `xml:"Code"` + Message *string `xml:"Message"` } type LeaseDuration string diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/options.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/options.go new file mode 100644 index 0000000000000..73fadf16ae8fe --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/options.go @@ -0,0 +1,35 @@ +package containers + +import ( + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +var _ client.Options = containerOptions{} + +type containerOptions struct { + metaData map[string]string +} + +func (o containerOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + metaDataHeaders := make(map[string]interface{}) + metadata.SetIntoHeaders(metaDataHeaders, o.metaData) + for k, v := range metaDataHeaders { + headers.Append(k, v.(string)) + } + + return headers +} + +func (containerOptions) ToOData() *odata.Query { + return nil +} + +func (containerOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("restype", "container") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/resource_id.go new file mode 100644 index 0000000000000..691360246ed83 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/resource_id.go @@ -0,0 +1,81 @@ +package containers + +import ( + "fmt" + "net/url" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts" +) + +// GetResourceManagerResourceID returns the Resource Manager specific +// ResourceID for a specific Storage Container +func (c Client) GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, containerName string) string { + fmtStr := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s/blobServices/default/containers/%s" + return fmt.Sprintf(fmtStr, subscriptionID, resourceGroup, accountName, containerName) +} + +// TODO: update this to implement `resourceids.ResourceId` once +// https://github.com/hashicorp/go-azure-helpers/issues/187 is fixed +var _ resourceids.Id = ContainerId{} + +type ContainerId struct { + // AccountId specifies the ID of the Storage Account where this Container exists. + AccountId accounts.AccountId + + // ContainerName specifies the name of this Container. + ContainerName string +} + +func NewContainerID(accountId accounts.AccountId, containerName string) ContainerId { + return ContainerId{ + AccountId: accountId, + ContainerName: containerName, + } +} + +func (b ContainerId) ID() string { + return fmt.Sprintf("%s/%s", b.AccountId.ID(), b.ContainerName) +} + +func (b ContainerId) String() string { + components := []string{ + fmt.Sprintf("Account %q", b.AccountId.String()), + } + return fmt.Sprintf("Container %q (%s)", b.ContainerName, strings.Join(components, " / ")) +} + +// ParseContainerID parses `input` into a Container ID using a known `domainSuffix` +func ParseContainerID(input, domainSuffix string) (*ContainerId, error) { + // example: https://foo.blob.core.windows.net/Bar + if input == "" { + return nil, fmt.Errorf("`input` was empty") + } + + account, err := accounts.ParseAccountID(input, domainSuffix) + if err != nil { + return nil, fmt.Errorf("parsing account %q: %+v", input, err) + } + + if account.SubDomainType != accounts.BlobSubDomainType { + return nil, fmt.Errorf("expected the subdomain type to be %q but got %q", string(accounts.BlobSubDomainType), string(account.SubDomainType)) + } + + uri, err := url.Parse(input) + if err != nil { + return nil, fmt.Errorf("parsing %q as a uri: %+v", input, err) + } + + path := strings.TrimPrefix(uri.Path, "/") + segments := strings.Split(path, "/") + if len(segments) != 1 { + return nil, fmt.Errorf("expected the path to contain 1 segment but got %d", len(segments)) + } + + containerName := strings.TrimPrefix(uri.Path, "/") + return &ContainerId{ + AccountId: *account, + ContainerName: containerName, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/set_acl.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/set_acl.go new file mode 100644 index 0000000000000..280ad4e391ff1 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/set_acl.go @@ -0,0 +1,93 @@ +package containers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type SetAccessControlInput struct { + AccessLevel AccessLevel + LeaseId string +} + +type SetAccessControlResponse struct { + HttpResponse *http.Response +} + +// SetAccessControl sets the Access Control for a Container without a Lease ID +// NOTE: The SetAccessControl operation only supports Shared Key authorization. +func (c Client) SetAccessControl(ctx context.Context, containerName string, input SetAccessControlInput) (result SetAccessControlResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: setAccessControlListOptions{ + accessLevel: input.AccessLevel, + leaseId: input.LeaseId, + }, + Path: fmt.Sprintf("/%s", containerName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +var _ client.Options = setAccessControlListOptions{} + +type setAccessControlListOptions struct { + accessLevel AccessLevel + leaseId string +} + +func (o setAccessControlListOptions) ToHeaders() *client.Headers { + headers := containerOptions{}.ToHeaders() + + // If this header is not included in the request, container data is private to the account owner. + if o.accessLevel != Private { + headers.Append("x-ms-blob-public-access", string(o.accessLevel)) + } + + // If specified, Get Container Properties only succeeds if the container’s lease is active and matches this ID. + // If there is no active lease or the ID does not match, 412 (Precondition Failed) is returned. + if o.leaseId != "" { + headers.Append("x-ms-lease-id", o.leaseId) + } + + return headers +} + +func (o setAccessControlListOptions) ToOData() *odata.Query { + return nil +} + +func (o setAccessControlListOptions) ToQuery() *client.QueryParams { + query := containerOptions{}.ToQuery() + query.Append("comp", "acl") + return query +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/set_metadata.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/set_metadata.go new file mode 100644 index 0000000000000..3f8bb07e2819f --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/set_metadata.go @@ -0,0 +1,94 @@ +package containers + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type SetMetaDataInput struct { + MetaData map[string]string + LeaseId string +} + +type SetMetaDataResponse struct { + HttpResponse *http.Response +} + +// SetMetaData sets the specified MetaData on the Container without a Lease ID +func (c Client) SetMetaData(ctx context.Context, containerName string, input SetMetaDataInput) (result SetMetaDataResponse, err error) { + if containerName == "" { + err = fmt.Errorf("`containerName` cannot be an empty string") + return + } + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf("`input.MetaData` is not valid: %s", err) + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: setMetaDataOptions{ + metaData: input.MetaData, + leaseId: input.LeaseId, + }, + Path: fmt.Sprintf("/%s", containerName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +var _ client.Options = setMetaDataOptions{} + +type setMetaDataOptions struct { + metaData map[string]string + leaseId string +} + +func (o setMetaDataOptions) ToHeaders() *client.Headers { + headers := containerOptions{ + metaData: o.metaData, + }.ToHeaders() + + // If specified, Get Container Properties only succeeds if the container’s lease is active and matches this ID. + // If there is no active lease or the ID does not match, 412 (Precondition Failed) is returned. + if o.leaseId != "" { + headers.Append("x-ms-lease-id", o.leaseId) + } + + return headers +} + +func (o setMetaDataOptions) ToOData() *odata.Query { + return nil +} + +func (o setMetaDataOptions) ToQuery() *client.QueryParams { + query := containerOptions{}.ToQuery() + query.Append("comp", "metadata") + return query +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/version.go new file mode 100644 index 0000000000000..1806c68f41431 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers/version.go @@ -0,0 +1,4 @@ +package containers + +const apiVersion = "2023-11-03" +const componentName = "blob/containers" diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/README.md b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/README.md new file mode 100644 index 0000000000000..ac35149dab397 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/README.md @@ -0,0 +1,53 @@ +## Data Lake Storage Gen2 File Systems SDK for API version 2023-11-03 + +This package allows you to interact with the Data Lake Storage Gen2 File Systems API + +### Supported Authorizers + +* Azure Active Directory (for the Resource Endpoint `https://storage.azure.com`) + +### Example Usage + +```go +package main + +import ( + "context" + "fmt" + + "github.com/hashicorp/go-azure-helpers/authentication" + "github.com/hashicorp/go-azure-helpers/sender" + "github.com/hashicorp/go-azure-sdk/sdk/auth" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems" +) + +func Example() error { + accountName := "storageaccount1" + fileSystemName := "filesystem1" + storageAccountKey := "ABC123...." + domainSuffix := "core.windows.net" + + + auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey) + if err != nil { + return fmt.Errorf("building SharedKey authorizer: %+v", err) + } + + fileSystemsClient, err := filesystems.NewWithBaseUri(fmt.Sprintf("https://%s.dfs.%s", accountName, domainSuffix)) + if err != nil { + return fmt.Errorf("building client for environment: %+v", err) + } + fileSystemsClient.Client.SetAuthorizer(auth) + + input := filesystems.CreateInput{ + Properties: map[string]string{}, + } + + ctx := context.Background() + if _, err = fileSystemsClient.Create(ctx, fileSystemName, input); err != nil { + return fmt.Errorf("Error creating: %s", err) + } + + return nil +} +``` \ No newline at end of file diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/client.go new file mode 100644 index 0000000000000..a1217334bdcca --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/client.go @@ -0,0 +1,23 @@ +package filesystems + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/storage" +) + +// Client is the base client for Data Lake Store Filesystems. +type Client struct { + Client *storage.Client +} + +func NewWithBaseUri(baseUri string) (*Client, error) { + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) + if err != nil { + return nil, fmt.Errorf("building base client: %+v", err) + } + + return &Client{ + Client: baseClient, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/create.go new file mode 100644 index 0000000000000..5bf1b66b52516 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/create.go @@ -0,0 +1,83 @@ +package filesystems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type CreateInput struct { + // A map of base64-encoded strings to store as user-defined properties with the File System + // Note that items may only contain ASCII characters in the ISO-8859-1 character set. + // This automatically gets converted to a comma-separated list of name and + // value pairs before sending to the API + Properties map[string]string +} + +type CreateResponse struct { + HttpResponse *http.Response +} + +// Create creates a Data Lake Store Gen2 FileSystem within a Storage Account +func (c Client) Create(ctx context.Context, fileSystemName string, input CreateInput) (result CreateResponse, err error) { + if fileSystemName == "" { + err = fmt.Errorf("`fileSystemName` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: createOptions{ + properties: input.Properties, + }, + + Path: fmt.Sprintf("/%s", fileSystemName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type createOptions struct { + properties map[string]string +} + +func (o createOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + props := buildProperties(o.properties) + if props != "" { + headers.Append("x-ms-properties", props) + } + + return headers +} + +func (createOptions) ToOData() *odata.Query { + return nil +} + +func (createOptions) ToQuery() *client.QueryParams { + return fileSystemOptions{}.ToQuery() +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/delete.go new file mode 100644 index 0000000000000..6900f2899d352 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/delete.go @@ -0,0 +1,49 @@ +package filesystems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" +) + +type DeleteResponse struct { + HttpResponse *http.Response +} + +// Delete deletes a Data Lake Store Gen2 FileSystem within a Storage Account +func (c Client) Delete(ctx context.Context, fileSystemName string) (result DeleteResponse, err error) { + if fileSystemName == "" { + err = fmt.Errorf("`fileSystemName` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodDelete, + OptionsObject: fileSystemOptions{}, + Path: fmt.Sprintf("/%s", fileSystemName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/helpers.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/helpers.go similarity index 90% rename from vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/helpers.go rename to vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/helpers.go index 605ed425929df..7822a128154e5 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems/helpers.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/helpers.go @@ -29,7 +29,7 @@ func parseProperties(input string) (*map[string]string, error) { // as such we can't string split on that -_- position := strings.Index(propertyRaw, "=") if position < 0 { - return nil, fmt.Errorf("Expected there to be an equals in the key value pair: %q", propertyRaw) + return nil, fmt.Errorf("expected an equal sign in the key value pair: %q", propertyRaw) } key := propertyRaw[0:position] diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/options.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/options.go new file mode 100644 index 0000000000000..aee33a0c45957 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/options.go @@ -0,0 +1,32 @@ +package filesystems + +import ( + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +var _ client.Options = fileSystemOptions{} + +type fileSystemOptions struct { + properties map[string]string +} + +func (o fileSystemOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + props := buildProperties(o.properties) + if props != "" { + headers.Append("x-ms-properties", props) + } + + return headers +} + +func (fileSystemOptions) ToOData() *odata.Query { + return nil +} + +func (fileSystemOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("resource", "filesystem") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/properties_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/properties_get.go new file mode 100644 index 0000000000000..47f394ab6dd2b --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/properties_get.go @@ -0,0 +1,71 @@ +package filesystems + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" +) + +type GetPropertiesResponse struct { + HttpResponse *http.Response + + // A map of base64-encoded strings to store as user-defined properties with the File System + // Note that items may only contain ASCII characters in the ISO-8859-1 character set. + // This automatically gets converted to a comma-separated list of name and + // value pairs before sending to the API + Properties map[string]string + + // Is Hierarchical Namespace Enabled? + NamespaceEnabled bool +} + +// GetProperties gets the properties for a Data Lake Store Gen2 FileSystem within a Storage Account +func (c Client) GetProperties(ctx context.Context, fileSystemName string) (result GetPropertiesResponse, err error) { + if fileSystemName == "" { + err = fmt.Errorf("`fileSystemName` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + OptionsObject: fileSystemOptions{}, + Path: fmt.Sprintf("/%s", fileSystemName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + propertiesRaw := resp.Header.Get("x-ms-properties") + var properties *map[string]string + properties, err = parseProperties(propertiesRaw) + if err != nil { + return + } + + result.Properties = *properties + result.NamespaceEnabled = strings.EqualFold(resp.Header.Get("x-ms-namespace-enabled"), "true") + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/properties_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/properties_set.go new file mode 100644 index 0000000000000..775807aeb338d --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/properties_set.go @@ -0,0 +1,103 @@ +package filesystems + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type SetPropertiesInput struct { + // A map of base64-encoded strings to store as user-defined properties with the File System + // Note that items may only contain ASCII characters in the ISO-8859-1 character set. + // This automatically gets converted to a comma-separated list of name and + // value pairs before sending to the API + Properties map[string]string + + // Optional - A date and time value. + // Specify this header to perform the operation only if the resource has been modified since the specified date and time. + IfModifiedSince *string + + // Optional - A date and time value. + // Specify this header to perform the operation only if the resource has not been modified since the specified date and time. + IfUnmodifiedSince *string +} + +type SetPropertiesResponse struct { + HttpResponse *http.Response +} + +// SetProperties sets the Properties for a Data Lake Store Gen2 FileSystem within a Storage Account +func (c Client) SetProperties(ctx context.Context, fileSystemName string, input SetPropertiesInput) (result SetPropertiesResponse, err error) { + if fileSystemName == "" { + err = fmt.Errorf("`fileSystemName` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + OptionsObject: setPropertiesOptions{ + properties: input.Properties, + ifUnmodifiedSince: input.IfUnmodifiedSince, + ifModifiedSince: input.IfModifiedSince, + }, + + Path: fmt.Sprintf("/%s", fileSystemName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type setPropertiesOptions struct { + properties map[string]string + ifModifiedSince *string + ifUnmodifiedSince *string +} + +func (o setPropertiesOptions) ToHeaders() *client.Headers { + + headers := &client.Headers{} + props := buildProperties(o.properties) + if props != "" { + headers.Append("x-ms-properties", props) + } + + if o.ifModifiedSince != nil { + headers.Append("If-Modified-Since", *o.ifModifiedSince) + } + if o.ifUnmodifiedSince != nil { + headers.Append("If-Unmodified-Since", *o.ifUnmodifiedSince) + } + + return headers +} + +func (setPropertiesOptions) ToOData() *odata.Query { + return nil +} + +func (setPropertiesOptions) ToQuery() *client.QueryParams { + return fileSystemOptions{}.ToQuery() +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/resource_id.go new file mode 100644 index 0000000000000..60670df684a14 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/resource_id.go @@ -0,0 +1,81 @@ +package filesystems + +import ( + "fmt" + "net/url" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts" +) + +// GetResourceManagerResourceID returns the Resource Manager specific +// ResourceID for a specific Data Lake FileSystem +func (c Client) GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, fileSystemName string) string { + fmtStr := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s/blobServices/default/containers/%s" + return fmt.Sprintf(fmtStr, subscriptionID, resourceGroup, accountName, fileSystemName) +} + +// TODO: update this to implement `resourceids.ResourceId` once +// https://github.com/hashicorp/go-azure-helpers/issues/187 is fixed +var _ resourceids.Id = FileSystemId{} + +type FileSystemId struct { + // AccountId specifies the ID of the Storage Account where this Data Lake FileSystem exists. + AccountId accounts.AccountId + + // FileSystemName specifies the name of this Data Lake FileSystem. + FileSystemName string +} + +func NewFileSystemID(accountId accounts.AccountId, fileSystemName string) FileSystemId { + return FileSystemId{ + AccountId: accountId, + FileSystemName: fileSystemName, + } +} + +func (b FileSystemId) ID() string { + return fmt.Sprintf("%s/%s", b.AccountId.ID(), b.FileSystemName) +} + +func (b FileSystemId) String() string { + components := []string{ + fmt.Sprintf("Account %q", b.AccountId.String()), + } + return fmt.Sprintf("File System %q (%s)", b.FileSystemName, strings.Join(components, " / ")) +} + +// ParseFileSystemID parses `input` into a File System ID using a known `domainSuffix` +func ParseFileSystemID(input, domainSuffix string) (*FileSystemId, error) { + // example: https://foo.dfs.core.windows.net/Bar + if input == "" { + return nil, fmt.Errorf("`input` was empty") + } + + account, err := accounts.ParseAccountID(input, domainSuffix) + if err != nil { + return nil, fmt.Errorf("parsing account %q: %+v", input, err) + } + + if account.SubDomainType != accounts.DataLakeStoreSubDomainType { + return nil, fmt.Errorf("expected the subdomain type to be %q but got %q", string(accounts.DataLakeStoreSubDomainType), string(account.SubDomainType)) + } + + uri, err := url.Parse(input) + if err != nil { + return nil, fmt.Errorf("parsing %q as a uri: %+v", input, err) + } + + path := strings.TrimPrefix(uri.Path, "/") + segments := strings.Split(path, "/") + if len(segments) != 1 { + return nil, fmt.Errorf("expected the path to contain 1 segment but got %d", len(segments)) + } + + fileSystemName := segments[0] + return &FileSystemId{ + AccountId: *account, + FileSystemName: fileSystemName, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/version.go new file mode 100644 index 0000000000000..954c9cac5a64f --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems/version.go @@ -0,0 +1,4 @@ +package filesystems + +const apiVersion = "2023-11-03" +const componentName = "datalakestore/filesystems" diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/client.go new file mode 100644 index 0000000000000..e0cb42776bf59 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/client.go @@ -0,0 +1,22 @@ +package paths + +import ( + "fmt" + "github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/storage" +) + +// Client is the base client for Data Lake Storage Path +type Client struct { + Client *storage.Client +} + +func NewWithBaseUri(baseUri string) (*Client, error) { + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) + if err != nil { + return nil, fmt.Errorf("building base client: %+v", err) + } + + return &Client{ + Client: baseClient, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/create.go new file mode 100644 index 0000000000000..8db9b66413eba --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/create.go @@ -0,0 +1,77 @@ +package paths + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type PathResource string + +const PathResourceFile PathResource = "file" +const PathResourceDirectory PathResource = "directory" + +type CreateInput struct { + Resource PathResource +} + +type CreateResponse struct { + HttpResponse *http.Response +} + +// Create creates a Data Lake Store Gen2 Path within a Storage Account +func (c Client) Create(ctx context.Context, fileSystemName string, path string, input CreateInput) (result CreateResponse, err error) { + + if fileSystemName == "" { + return result, fmt.Errorf("`fileSystemName` cannot be an empty string") + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: CreateInput{ + Resource: input.Resource, + }, + + Path: fmt.Sprintf("/%s/%s", fileSystemName, path), + } + + req, err := c.Client.NewRequest(ctx, opts) + + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return result, err + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return result, err + } + + return +} + +func (c CreateInput) ToHeaders() *client.Headers { + return nil +} + +func (c CreateInput) ToOData() *odata.Query { + return nil +} + +func (c CreateInput) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("resource", string(c.Resource)) + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/delete.go new file mode 100644 index 0000000000000..990be5157dc9e --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/delete.go @@ -0,0 +1,48 @@ +package paths + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" +) + +type DeleteResponse struct { + HttpResponse *http.Response +} + +// Delete deletes a Data Lake Store Gen2 FileSystem within a Storage Account +func (c Client) Delete(ctx context.Context, fileSystemName string, path string) (result DeleteResponse, err error) { + + if fileSystemName == "" { + return result, fmt.Errorf("`fileSystemName` cannot be an empty string") + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: nil, + Path: fmt.Sprintf("/%s/%s", fileSystemName, path), + } + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/helpers.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/helpers.go similarity index 77% rename from vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/helpers.go rename to vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/helpers.go index e6ef6f4bfb9f3..08d893c2b81d7 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths/helpers.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/helpers.go @@ -11,5 +11,5 @@ func parsePathResource(input string) (PathResource, error) { case "directory": return PathResourceDirectory, nil } - return "", fmt.Errorf("Unhandled path resource type %q", input) + return "", fmt.Errorf("unhandled path resource type %q", input) } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/properties_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/properties_get.go new file mode 100644 index 0000000000000..f5dcb782a5a40 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/properties_get.go @@ -0,0 +1,109 @@ +package paths + +import ( + "context" + "fmt" + "net/http" + "time" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type GetPropertiesResponse struct { + HttpResponse *http.Response + + ETag string + LastModified time.Time + // ResourceType is only returned for GetPropertiesActionGetStatus requests + ResourceType PathResource + Owner string + Group string + // ACL is only returned for GetPropertiesActionGetAccessControl requests + ACL string +} + +type GetPropertiesInput struct { + Action GetPropertiesAction +} + +type GetPropertiesAction string + +const ( + GetPropertiesActionGetStatus GetPropertiesAction = "getStatus" + GetPropertiesActionGetAccessControl GetPropertiesAction = "getAccessControl" +) + +// GetProperties gets the properties for a Data Lake Store Gen2 Path in a FileSystem within a Storage Account +func (c Client) GetProperties(ctx context.Context, fileSystemName string, path string, input GetPropertiesInput) (result GetPropertiesResponse, err error) { + if fileSystemName == "" { + err = fmt.Errorf("`fileSystemName` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + OptionsObject: getPropertyOptions{ + action: input.Action, + }, + Path: fmt.Sprintf("/%s/%s", fileSystemName, path), + } + + req, err := c.Client.NewRequest(ctx, opts) + + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return result, err + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.ResourceType = PathResource(resp.Header.Get("x-ms-resource-type")) + result.ETag = resp.Header.Get("ETag") + + if lastModifiedRaw := resp.Header.Get("Last-Modified"); lastModifiedRaw != "" { + lastModified, err := time.Parse(time.RFC1123, lastModifiedRaw) + if err != nil { + return GetPropertiesResponse{}, err + } + result.LastModified = lastModified + } + + result.Owner = resp.Header.Get("x-ms-owner") + result.Group = resp.Header.Get("x-ms-group") + result.ACL = resp.Header.Get("x-ms-acl") + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return result, err + } + + return +} + +type getPropertyOptions struct { + action GetPropertiesAction +} + +func (g getPropertyOptions) ToHeaders() *client.Headers { + return nil +} + +func (g getPropertyOptions) ToOData() *odata.Query { + return nil +} + +func (g getPropertyOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("action", string(g.action)) + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/properties_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/properties_set.go new file mode 100644 index 0000000000000..826e0ef46ce92 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/properties_set.go @@ -0,0 +1,107 @@ +package paths + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type SetAccessControlInput struct { + Owner *string + Group *string + ACL *string + + // Optional - A date and time value. + // Specify this header to perform the operation only if the resource has been modified since the specified date and time. + IfModifiedSince *string + + // Optional - A date and time value. + // Specify this header to perform the operation only if the resource has not been modified since the specified date and time. + IfUnmodifiedSince *string +} + +type SetPropertiesResponse struct { + HttpResponse *http.Response +} + +// SetProperties sets the access control properties for a Data Lake Store Gen2 Path within a Storage Account File System +func (c Client) SetAccessControl(ctx context.Context, fileSystemName string, path string, input SetAccessControlInput) (result SetPropertiesResponse, err error) { + if fileSystemName == "" { + err = fmt.Errorf("`fileSystemName` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + OptionsObject: setPropertyOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", fileSystemName, path), + } + + req, err := c.Client.NewRequest(ctx, opts) + + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return result, err + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return result, err + } + + return +} + +type setPropertyOptions struct { + input SetAccessControlInput +} + +func (s setPropertyOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + if s.input.ACL != nil { + headers.Append("x-ms-acl", *s.input.ACL) + } + + if s.input.Owner != nil { + headers.Append("x-ms-owner", *s.input.Owner) + } + + if s.input.Group != nil { + headers.Append("x-ms-group", *s.input.Group) + } + + if s.input.IfModifiedSince != nil { + headers.Append("If-Modified-Since", *s.input.IfModifiedSince) + } + + if s.input.IfUnmodifiedSince != nil { + headers.Append("If-Unmodified-Since", *s.input.IfUnmodifiedSince) + } + + return headers +} + +func (s setPropertyOptions) ToOData() *odata.Query { + return nil +} + +func (s setPropertyOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("action", "setAccessControl") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/resource_id.go new file mode 100644 index 0000000000000..58570e6abd354 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/resource_id.go @@ -0,0 +1,80 @@ +package paths + +import ( + "fmt" + "net/url" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts" +) + +// TODO: update this to implement `resourceids.ResourceId` once +// https://github.com/hashicorp/go-azure-helpers/issues/187 is fixed +var _ resourceids.Id = PathId{} + +type PathId struct { + // AccountId specifies the ID of the Storage Account where this path exists. + AccountId accounts.AccountId + + // FileSystemName specifies the name of the Data Lake FileSystem where this Path exists. + FileSystemName string + + // Path specifies the path in question. + Path string +} + +func NewPathID(accountId accounts.AccountId, fileSystemName, path string) PathId { + return PathId{ + AccountId: accountId, + FileSystemName: fileSystemName, + Path: path, + } +} + +func (b PathId) ID() string { + return fmt.Sprintf("%s/%s/%s", b.AccountId.ID(), b.FileSystemName, b.Path) +} + +func (b PathId) String() string { + components := []string{ + fmt.Sprintf("File System %q", b.FileSystemName), + fmt.Sprintf("Account %q", b.AccountId.String()), + } + return fmt.Sprintf("Path %q (%s)", b.Path, strings.Join(components, " / ")) +} + +// ParsePathID parses `input` into a Path ID using a known `domainSuffix` +func ParsePathID(input, domainSuffix string) (*PathId, error) { + // example: https://foo.dfs.core.windows.net/Bar/some/path + if input == "" { + return nil, fmt.Errorf("`input` was empty") + } + + account, err := accounts.ParseAccountID(input, domainSuffix) + if err != nil { + return nil, fmt.Errorf("parsing account %q: %+v", input, err) + } + + if account.SubDomainType != accounts.DataLakeStoreSubDomainType { + return nil, fmt.Errorf("expected the subdomain type to be %q but got %q", string(accounts.DataLakeStoreSubDomainType), string(account.SubDomainType)) + } + + uri, err := url.Parse(input) + if err != nil { + return nil, fmt.Errorf("parsing %q as a uri: %+v", input, err) + } + + uriPath := strings.TrimPrefix(uri.Path, "/") + segments := strings.Split(uriPath, "/") + if len(segments) < 2 { + return nil, fmt.Errorf("expected the path to contain at least 2 segments but got %d", len(segments)) + } + fileSystemName := segments[0] + path := strings.Join(segments[1:], "/") + return &PathId{ + AccountId: *account, + FileSystemName: fileSystemName, + Path: path, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/version.go new file mode 100644 index 0000000000000..70c22f9a4ac06 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths/version.go @@ -0,0 +1,4 @@ +package paths + +const apiVersion = "2023-11-03" +const componentName = "datalakestore/paths" diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/README.md b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/README.md new file mode 100644 index 0000000000000..d81f7b0c581a7 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/README.md @@ -0,0 +1,59 @@ +## File Storage Directories SDK for API version 2023-11-03 + +This package allows you to interact with the Directories File Storage API + +### Supported Authorizers + +* Azure Active Directory (for the Resource Endpoint `https://storage.azure.com`) +* SharedKeyLite (Blob, File & Queue) + +### Limitations + +* At this time the headers `x-ms-file-permission` and `x-ms-file-attributes` are hard-coded (to `inherit` and `None`, respectively). + +### Example Usage + +```go +package main + +import ( + "context" + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/auth" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories" +) + +func Example() error { + accountName := "storageaccount1" + storageAccountKey := "ABC123...." + shareName := "myshare" + directoryName := "myfiles" + domainSuffix := "core.windows.net" + + auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey) + if err != nil { + return fmt.Errorf("building SharedKey authorizer: %+v", err) + } + + directoriesClient, err := directories.NewWithBaseUri(fmt.Sprintf("https://%s.dfs.%s", accountName, domainSuffix)) + if err != nil { + return fmt.Errorf("building client for environment: %+v", err) + } + directoriesClient.Client.SetAuthorizer(auth) + + ctx := context.TODO() + metadata := map[string]string{ + "hello": "world", + } + + input := directories.CreateDirectoryInput{ + MetaData: metadata, + } + if _, err := directoriesClient.Create(ctx, shareName, directoryName, input); err != nil { + return fmt.Errorf("Error creating Directory: %s", err) + } + + return nil +} +``` \ No newline at end of file diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/api.go new file mode 100644 index 0000000000000..e46265705c074 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/api.go @@ -0,0 +1,13 @@ +package directories + +import ( + "context" +) + +type StorageDirectory interface { + Delete(ctx context.Context, shareName, path string) (resp DeleteResponse, err error) + GetMetaData(ctx context.Context, shareName, path string) (resp GetMetaDataResponse, err error) + SetMetaData(ctx context.Context, shareName, path string, input SetMetaDataInput) (resp SetMetaDataResponse, err error) + Create(ctx context.Context, shareName, path string, input CreateDirectoryInput) (resp CreateDirectoryResponse, err error) + Get(ctx context.Context, shareName, path string) (resp GetResponse, err error) +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/client.go new file mode 100644 index 0000000000000..7b327f0b618d7 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/client.go @@ -0,0 +1,22 @@ +package directories + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/storage" +) + +// Client is the base client for File Storage Shares. +type Client struct { + Client *storage.Client +} + +func NewWithBaseUri(baseUri string) (*Client, error) { + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) + if err != nil { + return nil, fmt.Errorf("building base client: %+v", err) + } + return &Client{ + Client: baseClient, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/create.go new file mode 100644 index 0000000000000..fdca3cf3f9a94 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/create.go @@ -0,0 +1,123 @@ +package directories + +import ( + "context" + "fmt" + "net/http" + "strings" + "time" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type CreateDirectoryInput struct { + // The time at which this file was created at - if omitted, this'll be set to "now" + // This maps to the `x-ms-file-creation-time` field. + // ... Yes I know it says File not Directory, I didn't design the API. + CreatedAt *time.Time + + // The time at which this file was last modified - if omitted, this'll be set to "now" + // This maps to the `x-ms-file-last-write-time` field. + // ... Yes I know it says File not Directory, I didn't design the API. + LastModified *time.Time + + // MetaData is a mapping of key value pairs which should be assigned to this directory + MetaData map[string]string +} + +type CreateDirectoryResponse struct { + HttpResponse *http.Response +} + +// Create creates a new directory under the specified share or parent directory. +func (c Client) Create(ctx context.Context, shareName, path string, input CreateDirectoryInput) (result CreateDirectoryResponse, err error) { + + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf("`input.MetaData` is not valid: %s", err) + return + } + + if path == "" { + err = fmt.Errorf("`path` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: CreateOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s", shareName, path), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type CreateOptions struct { + input CreateDirectoryInput +} + +func (c CreateOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + if len(c.input.MetaData) > 0 { + headers.Merge(metadata.SetMetaDataHeaders(c.input.MetaData)) + } + + var coalesceDate = func(input *time.Time, defaultVal string) string { + if input == nil { + return defaultVal + } + return input.Format(time.RFC1123) + } + + // ... Yes I know these say File not Directory, I didn't design the API. + headers.Append("x-ms-file-permission", "inherit") // TODO: expose this in future + headers.Append("x-ms-file-attributes", "None") // TODO: expose this in future + headers.Append("x-ms-file-creation-time", coalesceDate(c.input.CreatedAt, "now")) + headers.Append("x-ms-file-last-write-time", coalesceDate(c.input.LastModified, "now")) + + return headers +} + +func (c CreateOptions) ToOData() *odata.Query { + return nil +} + +func (c CreateOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("restype", "directory") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/delete.go new file mode 100644 index 0000000000000..35b7298307ae1 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/delete.go @@ -0,0 +1,62 @@ +package directories + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" +) + +type DeleteResponse struct { + HttpResponse *http.Response +} + +// Delete removes the specified empty directory +// Note that the directory must be empty before it can be deleted. +func (c Client) Delete(ctx context.Context, shareName, path string) (result DeleteResponse, err error) { + + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if path == "" { + err = fmt.Errorf("`path` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodDelete, + OptionsObject: directoriesOptions{}, + Path: fmt.Sprintf("/%s/%s", shareName, path), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/get.go new file mode 100644 index 0000000000000..2aeb03186f084 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/get.go @@ -0,0 +1,74 @@ +package directories + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type GetResponse struct { + HttpResponse *http.Response + + // A set of name-value pairs that contain metadata for the directory. + MetaData map[string]string + + // The value of this header is set to true if the directory metadata is completely + // encrypted using the specified algorithm. Otherwise, the value is set to false. + DirectoryMetaDataEncrypted bool +} + +// Get returns all system properties for the specified directory, +// and can also be used to check the existence of a directory. +func (c Client) Get(ctx context.Context, shareName, path string) (result GetResponse, err error) { + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if path == "" { + err = fmt.Errorf("`path` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: directoriesOptions{}, + Path: fmt.Sprintf("/%s/%s", shareName, path), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.DirectoryMetaDataEncrypted = strings.EqualFold(resp.Header.Get("x-ms-server-encrypted"), "true") + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/metadata_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/metadata_get.go new file mode 100644 index 0000000000000..cfefeb5d5726f --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/metadata_get.go @@ -0,0 +1,85 @@ +package directories + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type GetMetaDataResponse struct { + HttpResponse *http.Response + + MetaData map[string]string +} + +// GetMetaData returns all user-defined metadata for the specified directory +func (c Client) GetMetaData(ctx context.Context, shareName, path string) (result GetMetaDataResponse, err error) { + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if path == "" { + err = fmt.Errorf("`path` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: GetMetaDataOptions{}, + Path: fmt.Sprintf("/%s/%s", shareName, path), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type GetMetaDataOptions struct{} + +func (g GetMetaDataOptions) ToHeaders() *client.Headers { + return nil +} + +func (g GetMetaDataOptions) ToOData() *odata.Query { + return nil +} + +func (g GetMetaDataOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("restype", "directory") + out.Append("comp", "metadata") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/metadata_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/metadata_set.go new file mode 100644 index 0000000000000..8aa9097d3ef90 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/metadata_set.go @@ -0,0 +1,98 @@ +package directories + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type SetMetaDataResponse struct { + HttpResponse *http.Response +} + +type SetMetaDataInput struct { + MetaData map[string]string +} + +// SetMetaData updates user defined metadata for the specified directory +func (c Client) SetMetaData(ctx context.Context, shareName, path string, input SetMetaDataInput) (result SetMetaDataResponse, err error) { + + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf("`metadata` is not valid: %s", err) + return + } + + if path == "" { + err = fmt.Errorf("`path` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: SetMetaDataOptions{ + metaData: input.MetaData, + }, + Path: fmt.Sprintf("/%s/%s", shareName, path), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type SetMetaDataOptions struct { + metaData map[string]string +} + +func (s SetMetaDataOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + if len(s.metaData) > 0 { + headers.Merge(metadata.SetMetaDataHeaders(s.metaData)) + } + return headers +} + +func (s SetMetaDataOptions) ToOData() *odata.Query { + return nil +} + +func (s SetMetaDataOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("restype", "directory") + out.Append("comp", "metadata") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/options.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/options.go new file mode 100644 index 0000000000000..9b324d54fbed1 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/options.go @@ -0,0 +1,24 @@ +package directories + +import ( + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +var _ client.Options = directoriesOptions{} + +type directoriesOptions struct{} + +func (o directoriesOptions) ToHeaders() *client.Headers { + return &client.Headers{} +} + +func (directoriesOptions) ToOData() *odata.Query { + return nil +} + +func (directoriesOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("restype", "directory") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/resource_id.go new file mode 100644 index 0000000000000..b49c41ade78b3 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/resource_id.go @@ -0,0 +1,80 @@ +package directories + +import ( + "fmt" + "net/url" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts" +) + +// TODO: update this to implement `resourceids.ResourceId` once +// https://github.com/hashicorp/go-azure-helpers/issues/187 is fixed +var _ resourceids.Id = DirectoryId{} + +type DirectoryId struct { + // AccountId specifies the ID of the Storage Account where this Directory exists. + AccountId accounts.AccountId + + // ShareName specifies the name of the File Share containing this Directory. + ShareName string + + // DirectoryPath specifies the path representing this Directory. + DirectoryPath string +} + +func NewDirectoryID(accountId accounts.AccountId, shareName, directoryPath string) DirectoryId { + return DirectoryId{ + AccountId: accountId, + ShareName: shareName, + DirectoryPath: directoryPath, + } +} + +func (b DirectoryId) ID() string { + return fmt.Sprintf("%s/%s/%s", b.AccountId.ID(), b.ShareName, b.DirectoryPath) +} + +func (b DirectoryId) String() string { + components := []string{ + fmt.Sprintf("Share Name %q", b.ShareName), + fmt.Sprintf("Account %q", b.AccountId.String()), + } + return fmt.Sprintf("Directory Path %q (%s)", b.DirectoryPath, strings.Join(components, " / ")) +} + +// ParseDirectoryID parses `input` into a Directory ID using a known `domainSuffix` +func ParseDirectoryID(input, domainSuffix string) (*DirectoryId, error) { + // example: https://foo.file.core.windows.net/Bar/some/directory + if input == "" { + return nil, fmt.Errorf("`input` was empty") + } + + account, err := accounts.ParseAccountID(input, domainSuffix) + if err != nil { + return nil, fmt.Errorf("parsing account %q: %+v", input, err) + } + + if account.SubDomainType != accounts.FileSubDomainType { + return nil, fmt.Errorf("expected the subdomain type to be %q but got %q", string(accounts.FileSubDomainType), string(account.SubDomainType)) + } + + uri, err := url.Parse(input) + if err != nil { + return nil, fmt.Errorf("parsing %q as a uri: %+v", input, err) + } + + path := strings.TrimPrefix(uri.Path, "/") + segments := strings.Split(path, "/") + if len(segments) < 2 { + return nil, fmt.Errorf("expected the path to contain at least 2 segments but got %d", len(segments)) + } + shareName := segments[0] + directoryPath := strings.Join(segments[1:], "/") + return &DirectoryId{ + AccountId: *account, + ShareName: shareName, + DirectoryPath: directoryPath, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/version.go new file mode 100644 index 0000000000000..785860cbd0920 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories/version.go @@ -0,0 +1,5 @@ +package directories + +// APIVersion is the version of the API used for all Storage API Operations +const apiVersion = "2023-11-03" +const componentName = "file/directories" diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/README.md b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/README.md similarity index 52% rename from vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/README.md rename to vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/README.md index 6ce6bbb13f96a..0ac6146b88cc0 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/README.md +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/README.md @@ -1,4 +1,4 @@ -## File Storage Files SDK for API version 2020-08-04 +## File Storage Files SDK for API version 2023-11-03 This package allows you to interact with the Files File Storage API @@ -19,10 +19,9 @@ package main import ( "context" "fmt" - "time" - - "github.com/Azure/go-autorest/autorest" - "github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files" + + "github.com/hashicorp/go-azure-sdk/sdk/auth" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files" ) func Example() error { @@ -31,14 +30,22 @@ func Example() error { shareName := "myshare" directoryName := "myfiles" fileName := "example.txt" - - storageAuth := autorest.NewSharedKeyLiteAuthorizer(accountName, storageAccountKey) - filesClient := files.New() - filesClient.Client.Authorizer = storageAuth + domainSuffix := "core.windows.net" + + auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey) + if err != nil { + return fmt.Errorf("building SharedKey authorizer: %+v", err) + } + + filesClient, err := files.NewWithBaseUri(fmt.Sprintf("https://%s.file.%s", accountName, domainSuffix)) + if err != nil { + return fmt.Errorf("building client for environment: %+v", err) + } + filesClient.Client.SetAuthorizer(auth) ctx := context.TODO() input := files.CreateInput{} - if _, err := filesClient.Create(ctx, accountName, shareName, directoryName, fileName, input); err != nil { + if _, err := filesClient.Create(ctx, shareName, directoryName, fileName, input); err != nil { return fmt.Errorf("Error creating File: %s", err) } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/api.go new file mode 100644 index 0000000000000..f28a708ded3af --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/api.go @@ -0,0 +1,24 @@ +package files + +import ( + "context" + "os" +) + +type StorageFile interface { + PutByteRange(ctx context.Context, shareName string, path string, fileName string, input PutByteRangeInput) (PutRangeResponse, error) + GetByteRange(ctx context.Context, shareName string, path string, fileName string, input GetByteRangeInput) (GetByteRangeResponse, error) + ClearByteRange(ctx context.Context, shareName string, path string, fileName string, input ClearByteRangeInput) (ClearByteRangeResponse, error) + SetProperties(ctx context.Context, shareName string, path string, fileName string, input SetPropertiesInput) (SetPropertiesResponse, error) + PutFile(ctx context.Context, shareName string, path string, fileName string, file *os.File, parallelism int) error + Copy(ctx context.Context, shareName, path, fileName string, input CopyInput) (CopyResponse, error) + SetMetaData(ctx context.Context, shareName string, path string, fileName string, input SetMetaDataInput) (SetMetaDataResponse, error) + GetMetaData(ctx context.Context, shareName string, path string, fileName string) (GetMetaDataResponse, error) + AbortCopy(ctx context.Context, shareName string, path string, fileName string, input CopyAbortInput) (CopyAbortResponse, error) + GetFile(ctx context.Context, shareName string, path string, fileName string, input GetFileInput) (GetFileResponse, error) + ListRanges(ctx context.Context, shareName, path, fileName string) (ListRangesResponse, error) + GetProperties(ctx context.Context, shareName string, path string, fileName string) (GetResponse, error) + Delete(ctx context.Context, shareName string, path string, fileName string) (DeleteResponse, error) + Create(ctx context.Context, shareName string, path string, fileName string, input CreateInput) (CreateResponse, error) + CopyAndWait(ctx context.Context, shareName, path, fileName string, input CopyInput) (CopyResponse, error) +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/client.go new file mode 100644 index 0000000000000..cee19a3791c24 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/client.go @@ -0,0 +1,22 @@ +package files + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/storage" +) + +// Client is the base client for File Storage Shares. +type Client struct { + Client *storage.Client +} + +func NewWithBaseUri(baseUri string) (*Client, error) { + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) + if err != nil { + return nil, fmt.Errorf("building base client: %+v", err) + } + return &Client{ + Client: baseClient, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy.go new file mode 100644 index 0000000000000..d8351395df861 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy.go @@ -0,0 +1,124 @@ +package files + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type CopyInput struct { + // 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 account, then you must authenticate the source file or blob using a + // shared access signature. If the source is a public blob, no authentication is required to perform the copy + // operation. A file in a share snapshot can also be specified as a copy source. + CopySource string + + MetaData map[string]string +} + +type CopyResponse struct { + HttpResponse *http.Response + + // The CopyID, which can be passed to AbortCopy to abort the copy. + CopyID string + + // Either `success` or `pending` + CopySuccess string +} + +// Copy copies a blob or file to a destination file within the storage account asynchronously. +func (c Client) Copy(ctx context.Context, shareName, path, fileName string, input CopyInput) (result CopyResponse, err error) { + + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if fileName == "" { + err = fmt.Errorf("`fileName` cannot be an empty string") + return + } + + if input.CopySource == "" { + err = fmt.Errorf("`input.CopySource` cannot be an empty string") + return + } + + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf("`input.MetaData` is not valid: %s", err) + return + } + + if path != "" { + path = fmt.Sprintf("%s/", path) + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPut, + OptionsObject: CopyOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s%s", shareName, path, fileName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.CopyID = resp.Header.Get("x-ms-copy-id") + result.CopySuccess = resp.Header.Get("x-ms-copy-status") + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type CopyOptions struct { + input CopyInput +} + +func (c CopyOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + if len(c.input.MetaData) > 0 { + headers.Merge(metadata.SetMetaDataHeaders(c.input.MetaData)) + } + headers.Append("x-ms-copy-source", c.input.CopySource) + return headers +} + +func (c CopyOptions) ToOData() *odata.Query { + return nil +} + +func (c CopyOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy_abort.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy_abort.go new file mode 100644 index 0000000000000..191929b8dab52 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy_abort.go @@ -0,0 +1,98 @@ +package files + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type CopyAbortInput struct { + copyID string +} + +type CopyAbortResponse struct { + HttpResponse *http.Response +} + +// AbortCopy aborts a pending Copy File operation, and leaves a destination file with zero length and full metadata +func (c Client) AbortCopy(ctx context.Context, shareName, path, fileName string, input CopyAbortInput) (result CopyAbortResponse, err error) { + + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if fileName == "" { + err = fmt.Errorf("`fileName` cannot be an empty string") + return + } + + if input.copyID == "" { + err = fmt.Errorf("`copyID` cannot be an empty string") + return + } + + if path != "" { + path = fmt.Sprintf("%s/", path) + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPut, + OptionsObject: CopyAbortOptions{ + copyId: input.copyID, + }, + Path: fmt.Sprintf("/%s/%s%s", shareName, path, fileName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type CopyAbortOptions struct { + copyId string +} + +func (c CopyAbortOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("x-ms-copy-action", "abort") + return headers +} + +func (c CopyAbortOptions) ToOData() *odata.Query { + return nil +} + +func (c CopyAbortOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "copy") + out.Append("copyid", c.copyId) + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy_and_wait_poller.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy_and_wait_poller.go new file mode 100644 index 0000000000000..9d6e8afcfcfb6 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy_and_wait_poller.go @@ -0,0 +1,48 @@ +package files + +import ( + "context" + "fmt" + "strings" + "time" + + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" +) + +var _ pollers.PollerType = ©AndWaitPoller{} + +func NewCopyAndWaitPoller(client *Client, shareName, path, fileName string) *copyAndWaitPoller { + return ©AndWaitPoller{ + client: client, + shareName: shareName, + path: path, + fileName: fileName, + } +} + +type copyAndWaitPoller struct { + client *Client + shareName string + path string + fileName string +} + +func (p *copyAndWaitPoller) Poll(ctx context.Context) (*pollers.PollResult, error) { + props, err := p.client.GetProperties(ctx, p.shareName, p.path, p.fileName) + if err != nil { + return nil, fmt.Errorf("retrieving copy (shareName: %s path: %s fileName: %s) : %+v", p.shareName, p.path, p.fileName, err) + } + + if strings.EqualFold(props.CopyStatus, "success") { + return &pollers.PollResult{ + Status: pollers.PollingStatusSucceeded, + PollInterval: 10 * time.Second, + }, nil + } + + // Processing + return &pollers.PollResult{ + Status: pollers.PollingStatusInProgress, + PollInterval: 10 * time.Second, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy_wait.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy_wait.go new file mode 100644 index 0000000000000..9223f54331ae4 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/copy_wait.go @@ -0,0 +1,29 @@ +package files + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" +) + +// CopyAndWait is a convenience method which doesn't exist in the API, which copies the file and then waits for the copy to complete +func (c Client) CopyAndWait(ctx context.Context, shareName, path, fileName string, input CopyInput) (result CopyResponse, err error) { + fileCopy, e := c.Copy(ctx, shareName, path, fileName, input) + if err != nil { + result.HttpResponse = fileCopy.HttpResponse + err = fmt.Errorf("copying: %s", e) + return + } + + result.CopyID = fileCopy.CopyID + + pollerType := NewCopyAndWaitPoller(&c, shareName, path, fileName) + poller := pollers.NewPoller(pollerType, 10*time.Second, pollers.DefaultNumberOfDroppedConnectionsToAllow) + if err = poller.PollUntilDone(ctx); err != nil { + return result, fmt.Errorf("waiting for file to copy: %+v", err) + } + + return +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/create.go new file mode 100644 index 0000000000000..5fb8e97d2e8b3 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/create.go @@ -0,0 +1,166 @@ +package files + +import ( + "context" + "fmt" + "net/http" + "strconv" + "strings" + "time" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type CreateInput struct { + // This header specifies the maximum size for the file, up to 1 TiB. + ContentLength int64 + + // The MIME content type of the file + // If not specified, the default type is application/octet-stream. + ContentType *string + + // Specifies which content encodings have been applied to the file. + // This value is returned to the client when the Get File operation is performed + // on the file resource and can be used to decode file content. + ContentEncoding *string + + // Specifies the natural languages used by this resource. + ContentLanguage *string + + // The File service stores this value but does not use or modify it. + CacheControl *string + + // Sets the file's MD5 hash. + ContentMD5 *string + + // Sets the file’s Content-Disposition header. + ContentDisposition *string + + // The time at which this file was created at - if omitted, this'll be set to "now" + // This maps to the `x-ms-file-creation-time` field. + CreatedAt *time.Time + + // The time at which this file was last modified - if omitted, this'll be set to "now" + // This maps to the `x-ms-file-last-write-time` field. + LastModified *time.Time + + // MetaData is a mapping of key value pairs which should be assigned to this file + MetaData map[string]string +} + +type CreateResponse struct { + HttpResponse *http.Response +} + +// Create creates a new file or replaces a file. +func (c Client) Create(ctx context.Context, shareName, path, fileName string, input CreateInput) (result CreateResponse, err error) { + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if fileName == "" { + err = fmt.Errorf("`fileName` cannot be an empty string") + return + } + + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf("`input.MetaData` is not valid: %s", err) + return + } + + if path != "" { + path = fmt.Sprintf("%s/", path) + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: CreateOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s%s", shareName, path, fileName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type CreateOptions struct { + input CreateInput +} + +func (c CreateOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + var coalesceDate = func(input *time.Time, defaultVal string) string { + if input == nil { + return defaultVal + } + + return input.Format(time.RFC1123) + } + + if len(c.input.MetaData) > 0 { + headers.Merge(metadata.SetMetaDataHeaders(c.input.MetaData)) + } + + headers.Append("x-ms-content-length", strconv.Itoa(int(c.input.ContentLength))) + headers.Append("x-ms-type", "file") + + headers.Append("x-ms-file-permission", "inherit") // TODO: expose this in future + headers.Append("x-ms-file-attributes", "None") // TODO: expose this in future + headers.Append("x-ms-file-creation-time", coalesceDate(c.input.CreatedAt, "now")) + headers.Append("x-ms-file-last-write-time", coalesceDate(c.input.LastModified, "now")) + + if c.input.ContentDisposition != nil { + headers.Append("x-ms-content-disposition", *c.input.ContentDisposition) + } + + if c.input.ContentEncoding != nil { + headers.Append("x-ms-content-encoding", *c.input.ContentEncoding) + } + + if c.input.ContentMD5 != nil { + headers.Append("x-ms-content-md5", *c.input.ContentMD5) + } + + if c.input.ContentType != nil { + headers.Append("x-ms-content-type", *c.input.ContentType) + } + + return headers +} + +func (c CreateOptions) ToOData() *odata.Query { + return nil +} + +func (c CreateOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/delete.go new file mode 100644 index 0000000000000..f3841fa0427d8 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/delete.go @@ -0,0 +1,65 @@ +package files + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" +) + +type DeleteResponse struct { + HttpResponse *http.Response +} + +// Delete immediately deletes the file from the File Share. +func (c Client) Delete(ctx context.Context, shareName, path, fileName string) (result DeleteResponse, err error) { + + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if fileName == "" { + err = fmt.Errorf("`fileName` cannot be an empty string") + return + } + + if path != "" { + path = fmt.Sprintf("/%s/", path) + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodDelete, + OptionsObject: nil, + Path: fmt.Sprintf("%s/%s%s", shareName, path, fileName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/metadata_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/metadata_get.go new file mode 100644 index 0000000000000..a4d1cc9ef5328 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/metadata_get.go @@ -0,0 +1,88 @@ +package files + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type GetMetaDataResponse struct { + HttpResponse *http.Response + + MetaData map[string]string +} + +// GetMetaData returns the MetaData for the specified File. +func (c Client) GetMetaData(ctx context.Context, shareName, path, fileName string) (result GetMetaDataResponse, err error) { + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if fileName == "" { + err = fmt.Errorf("`fileName` cannot be an empty string") + return + } + + if path != "" { + path = fmt.Sprintf("%s/", path) + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: GetMetadataOptions{}, + Path: fmt.Sprintf("/%s/%s%s", shareName, path, fileName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type GetMetadataOptions struct{} + +func (m GetMetadataOptions) ToHeaders() *client.Headers { + return nil +} + +func (m GetMetadataOptions) ToOData() *odata.Query { + return nil +} + +func (m GetMetadataOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "metadata") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/metadata_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/metadata_set.go new file mode 100644 index 0000000000000..3a51a1086bfd9 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/metadata_set.go @@ -0,0 +1,100 @@ +package files + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type SetMetaDataResponse struct { + HttpResponse *http.Response +} + +type SetMetaDataInput struct { + MetaData map[string]string +} + +// SetMetaData updates the specified File to have the specified MetaData. +func (c Client) SetMetaData(ctx context.Context, shareName, path, fileName string, input SetMetaDataInput) (result SetMetaDataResponse, err error) { + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if fileName == "" { + err = fmt.Errorf("`fileName` cannot be an empty string") + return + } + + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf("`input.MetaData` is not valid: %s", err) + return + } + + if path != "" { + path = fmt.Sprintf("/%s/", path) + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: SetMetaDataOptions{ + metaData: input.MetaData, + }, + Path: fmt.Sprintf("%s/%s%s", shareName, path, fileName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type SetMetaDataOptions struct { + metaData map[string]string +} + +func (s SetMetaDataOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + if len(s.metaData) > 0 { + headers.Merge(metadata.SetMetaDataHeaders(s.metaData)) + } + return headers +} + +func (s SetMetaDataOptions) ToOData() *odata.Query { + return nil +} + +func (s SetMetaDataOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "metadata") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/properties_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/properties_get.go new file mode 100644 index 0000000000000..2ea1f633efe83 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/properties_get.go @@ -0,0 +1,112 @@ +package files + +import ( + "context" + "fmt" + "net/http" + "strconv" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type GetResponse struct { + HttpResponse *http.Response + + CacheControl string + ContentDisposition string + ContentEncoding string + ContentLanguage string + ContentLength *int64 + ContentMD5 string + ContentType string + CopyID string + CopyStatus string + CopySource string + CopyProgress string + CopyStatusDescription string + CopyCompletionTime string + Encrypted bool + + MetaData map[string]string +} + +// GetProperties returns the Properties for the specified file +func (c Client) GetProperties(ctx context.Context, shareName, path, fileName string) (result GetResponse, err error) { + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if fileName == "" { + err = fmt.Errorf("`fileName` cannot be an empty string") + return + } + + if path != "" { + path = fmt.Sprintf("/%s/", path) + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodHead, + OptionsObject: nil, + Path: fmt.Sprintf("%s/%s%s", shareName, path, fileName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.CacheControl = resp.Header.Get("Cache-Control") + result.ContentDisposition = resp.Header.Get("Content-Disposition") + result.ContentEncoding = resp.Header.Get("Content-Encoding") + result.ContentLanguage = resp.Header.Get("Content-Language") + result.ContentMD5 = resp.Header.Get("Content-MD5") + result.ContentType = resp.Header.Get("Content-Type") + result.CopyCompletionTime = resp.Header.Get("x-ms-copy-completion-time") + result.CopyID = resp.Header.Get("x-ms-copy-id") + result.CopyProgress = resp.Header.Get("x-ms-copy-progress") + result.CopySource = resp.Header.Get("x-ms-copy-source") + result.CopyStatus = resp.Header.Get("x-ms-copy-status") + result.CopyStatusDescription = resp.Header.Get("x-ms-copy-status-description") + result.Encrypted = strings.EqualFold(resp.Header.Get("x-ms-server-encrypted"), "true") + result.MetaData = metadata.ParseFromHeaders(resp.Header) + + contentLengthRaw := resp.Header.Get("Content-Length") + if contentLengthRaw != "" { + var contentLength int + contentLength, err = strconv.Atoi(contentLengthRaw) + if err != nil { + err = fmt.Errorf("parsing `Content-Length` header value %q: %s", contentLengthRaw, err) + return + } + contentLengthI64 := int64(contentLength) + result.ContentLength = &contentLengthI64 + } + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/properties_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/properties_set.go new file mode 100644 index 0000000000000..83bd84118eb5e --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/properties_set.go @@ -0,0 +1,180 @@ +package files + +import ( + "context" + "fmt" + "net/http" + "strconv" + "strings" + "time" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type SetPropertiesInput struct { + // 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. + ContentLength int64 + + // Modifies the cache control string for the file. + // If this property is not specified on the request, then the property will be cleared for the file. + // Subsequent calls to Get File Properties will not return this property, + // unless it is explicitly set on the file again. + ContentControl *string + + // Sets the file’s Content-Disposition header. + // If this property is not specified on the request, then the property will be cleared for the file. + // Subsequent calls to Get File Properties will not return this property, + // unless it is explicitly set on the file again. + ContentDisposition *string + + // Sets the file's content encoding. + // If this property is not specified on the request, then the property will be cleared for the file. + // Subsequent calls to Get File Properties will not return this property, + // unless it is explicitly set on the file again. + ContentEncoding *string + + // Sets the file's content language. + // If this property is not specified on the request, then the property will be cleared for the file. + // Subsequent calls to Get File Properties will not return this property, + // unless it is explicitly set on the file again. + ContentLanguage *string + + // Sets the file's MD5 hash. + // If this property is not specified on the request, then the property will be cleared for the file. + // Subsequent calls to Get File Properties will not return this property, + // unless it is explicitly set on the file again. + ContentMD5 *string + + // Sets the file's content type. + // If this property is not specified on the request, then the property will be cleared for the file. + // Subsequent calls to Get File Properties will not return this property, + // unless it is explicitly set on the file again. + ContentType *string + + // The time at which this file was created at - if omitted, this'll be set to "now" + // This maps to the `x-ms-file-creation-time` field. + CreatedAt *time.Time + + // The time at which this file was last modified - if omitted, this'll be set to "now" + // This maps to the `x-ms-file-last-write-time` field. + LastModified *time.Time + + // MetaData is a mapping of key value pairs which should be assigned to this file + MetaData map[string]string +} + +type SetPropertiesResponse struct { + HttpResponse *http.Response +} + +// SetProperties sets the specified properties on the specified File +func (c Client) SetProperties(ctx context.Context, shareName, path, fileName string, input SetPropertiesInput) (result SetPropertiesResponse, err error) { + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if fileName == "" { + err = fmt.Errorf("`fileName` cannot be an empty string") + return + } + + if path != "" { + path = fmt.Sprintf("/%s/", path) + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: SetPropertiesOptions{ + input: input, + }, + Path: fmt.Sprintf("%s/%s%s", shareName, path, fileName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type SetPropertiesOptions struct { + input SetPropertiesInput +} + +func (s SetPropertiesOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + var coalesceDate = func(input *time.Time, defaultVal string) string { + if input == nil { + return defaultVal + } + + return input.Format(time.RFC1123) + } + + headers.Append("x-ms-type", "file") + + headers.Append("x-ms-content-length", strconv.Itoa(int(s.input.ContentLength))) + headers.Append("x-ms-file-permission", "inherit") // TODO: expose this in future + headers.Append("x-ms-file-attributes", "None") // TODO: expose this in future + headers.Append("x-ms-file-creation-time", coalesceDate(s.input.CreatedAt, "now")) + headers.Append("x-ms-file-last-write-time", coalesceDate(s.input.LastModified, "now")) + + if s.input.ContentControl != nil { + headers.Append("x-ms-cache-control", *s.input.ContentControl) + } + if s.input.ContentDisposition != nil { + headers.Append("x-ms-content-disposition", *s.input.ContentDisposition) + } + if s.input.ContentEncoding != nil { + headers.Append("x-ms-content-encoding", *s.input.ContentEncoding) + } + if s.input.ContentLanguage != nil { + headers.Append("x-ms-content-language", *s.input.ContentLanguage) + } + if s.input.ContentMD5 != nil { + headers.Append("x-ms-content-md5", *s.input.ContentMD5) + } + if s.input.ContentType != nil { + headers.Append("x-ms-content-type", *s.input.ContentType) + } + + if len(s.input.MetaData) > 0 { + headers.Merge(metadata.SetMetaDataHeaders(s.input.MetaData)) + } + + return headers +} + +func (s SetPropertiesOptions) ToOData() *odata.Query { + return nil +} + +func (s SetPropertiesOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_clear.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_clear.go new file mode 100644 index 0000000000000..0a1e8149ed730 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_clear.go @@ -0,0 +1,104 @@ +package files + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type ClearByteRangeInput struct { + StartBytes int64 + EndBytes int64 +} + +type ClearByteRangeResponse struct { + HttpResponse *http.Response +} + +// ClearByteRange clears the specified Byte Range from within the specified File +func (c Client) ClearByteRange(ctx context.Context, shareName, path, fileName string, input ClearByteRangeInput) (result ClearByteRangeResponse, err error) { + + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if fileName == "" { + err = fmt.Errorf("`fileName` cannot be an empty string") + return + } + + if input.StartBytes < 0 { + err = fmt.Errorf("`input.StartBytes` must be greater or equal to 0") + return + } + + if input.EndBytes <= 0 { + err = fmt.Errorf("`input.EndBytes` must be greater than 0") + return + } + + if path != "" { + path = fmt.Sprintf("%s/", path) + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: ClearByteRangeOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s%s", shareName, path, fileName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type ClearByteRangeOptions struct { + input ClearByteRangeInput +} + +func (c ClearByteRangeOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("x-ms-write", "clear") + headers.Append("x-ms-range", fmt.Sprintf("bytes=%d-%d", c.input.StartBytes, c.input.EndBytes)) + return headers +} + +func (c ClearByteRangeOptions) ToOData() *odata.Query { + return nil +} + +func (c ClearByteRangeOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "range") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_get.go new file mode 100644 index 0000000000000..f8b40b87d1a70 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_get.go @@ -0,0 +1,119 @@ +package files + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type GetByteRangeInput struct { + StartBytes int64 + EndBytes int64 +} + +type GetByteRangeResponse struct { + HttpResponse *http.Response + Contents *[]byte +} + +// GetByteRange returns the specified Byte Range from the specified File. +func (c Client) GetByteRange(ctx context.Context, shareName, path, fileName string, input GetByteRangeInput) (result GetByteRangeResponse, err error) { + + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if fileName == "" { + err = fmt.Errorf("`fileName` cannot be an empty string") + return + } + + if input.StartBytes < 0 { + err = fmt.Errorf("`input.StartBytes` must be greater or equal to 0") + return + } + + if input.EndBytes <= 0 { + err = fmt.Errorf("`input.EndBytes` must be greater than 0") + return + } + + expectedBytes := input.EndBytes - input.StartBytes + if expectedBytes < (4 * 1024) { + err = fmt.Errorf("requested Byte Range must be at least 4KB") + return + } + if expectedBytes > (4 * 1024 * 1024) { + err = fmt.Errorf("requested Byte Range must be at most 4MB") + return + } + + if path != "" { + path = fmt.Sprintf("%s/", path) + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusOK, + http.StatusPartialContent, + }, + HttpMethod: http.MethodGet, + OptionsObject: GetByteRangeOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s/%s%s", shareName, path, fileName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.Contents = &[]byte{} + result.HttpResponse = resp.Response + + err = resp.Unmarshal(result.Contents) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type GetByteRangeOptions struct { + input GetByteRangeInput +} + +func (g GetByteRangeOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("x-ms-range", fmt.Sprintf("bytes=%d-%d", g.input.StartBytes, g.input.EndBytes-1)) + return headers +} + +func (g GetByteRangeOptions) ToOData() *odata.Query { + return nil +} + +func (g GetByteRangeOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/range_get_file.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_get_file.go similarity index 65% rename from vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/range_get_file.go rename to vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_get_file.go index 9e5be17f85fc1..e923eb31f3b0f 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/range_get_file.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_get_file.go @@ -5,38 +5,47 @@ import ( "fmt" "log" "math" + "net/http" "runtime" "sync" - - "github.com/Azure/go-autorest/autorest" ) +type GetFileInput struct { + Parallelism int +} + +type GetFileResponse struct { + HttpResponse *http.Response + OutputBytes *[]byte +} + // GetFile is a helper method to download a file by chunking it automatically -func (client Client) GetFile(ctx context.Context, accountName, shareName, path, fileName string, parallelism int) (result autorest.Response, outputBytes []byte, err error) { +func (c Client) GetFile(ctx context.Context, shareName, path, fileName string, input GetFileInput) (result GetFileResponse, err error) { // first look up the file and check out how many bytes it is - file, e := client.GetProperties(ctx, accountName, shareName, path, fileName) + file, e := c.GetProperties(ctx, shareName, path, fileName) if err != nil { - result = file.Response + result.HttpResponse = file.HttpResponse err = e return } if file.ContentLength == nil { - err = fmt.Errorf("Content-Length was nil!") + err = fmt.Errorf("Content-Length was nil") return } - length := int64(*file.ContentLength) + result.HttpResponse = file.HttpResponse + length := *file.ContentLength chunkSize := int64(4 * 1024 * 1024) // 4MB if chunkSize > length { chunkSize = length } - // then split that up into chunks and retrieve it retrieve it into the 'results' set + // then split that up into chunks and retrieve it into the 'results' set chunks := int(math.Ceil(float64(length) / float64(chunkSize))) - workerCount := parallelism * runtime.NumCPU() + workerCount := input.Parallelism * runtime.NumCPU() if workerCount > chunks { workerCount = chunks } @@ -57,7 +66,7 @@ func (client Client) GetFile(ctx context.Context, accountName, shareName, path, fileSize: length, } - result, err := client.downloadFileChunk(ctx, accountName, shareName, path, fileName, dfci) + result, err := c.downloadFileChunk(ctx, shareName, path, fileName, dfci) if err != nil { errors <- err waitGroup.Done() @@ -81,10 +90,10 @@ func (client Client) GetFile(ctx context.Context, accountName, shareName, path, // then finally put it all together, in order and return it output := make([]byte, length) for _, v := range results { - copy(output[v.startBytes:v.endBytes], v.bytes) + copy(output[v.startBytes:v.endBytes], *v.bytes) } - outputBytes = output + *result.OutputBytes = output return } @@ -97,10 +106,10 @@ type downloadFileChunkInput struct { type downloadFileChunkResult struct { startBytes int64 endBytes int64 - bytes []byte + bytes *[]byte } -func (client Client) downloadFileChunk(ctx context.Context, accountName, shareName, path, fileName string, input downloadFileChunkInput) (*downloadFileChunkResult, error) { +func (c Client) downloadFileChunk(ctx context.Context, shareName, path, fileName string, input downloadFileChunkInput) (*downloadFileChunkResult, error) { startBytes := input.chunkSize * int64(input.thisChunk) endBytes := startBytes + input.chunkSize @@ -114,9 +123,9 @@ func (client Client) downloadFileChunk(ctx context.Context, accountName, shareNa StartBytes: startBytes, EndBytes: endBytes, } - result, err := client.GetByteRange(ctx, accountName, shareName, path, fileName, getInput) + result, err := c.GetByteRange(ctx, shareName, path, fileName, getInput) if err != nil { - return nil, fmt.Errorf("Error putting bytes: %s", err) + return nil, fmt.Errorf("error putting bytes: %s", err) } output := downloadFileChunkResult{ diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_put.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_put.go new file mode 100644 index 0000000000000..58e6f9bb0cff9 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_put.go @@ -0,0 +1,124 @@ +package files + +import ( + "bytes" + "context" + "fmt" + "io" + "net/http" + "strconv" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type PutByteRangeInput struct { + StartBytes int64 + EndBytes int64 + + // Content is the File Contents for the specified range + // which can be at most 4MB + Content []byte +} + +type PutRangeResponse struct { + HttpResponse *http.Response +} + +// PutByteRange puts the specified Byte Range in the specified File. +func (c Client) PutByteRange(ctx context.Context, shareName, path, fileName string, input PutByteRangeInput) (result PutRangeResponse, err error) { + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if fileName == "" { + err = fmt.Errorf("`fileName` cannot be an empty string") + return + } + + if input.StartBytes < 0 { + err = fmt.Errorf("`input.StartBytes` must be greater or equal to 0") + return + } + if input.EndBytes <= 0 { + err = fmt.Errorf("`input.EndBytes` must be greater than 0") + return + } + + expectedBytes := input.EndBytes - input.StartBytes + actualBytes := len(input.Content) + if expectedBytes != int64(actualBytes) { + err = fmt.Errorf(fmt.Sprintf("The specified byte-range (%d) didn't match the content size (%d).", expectedBytes, actualBytes)) + return + } + + if expectedBytes > (4 * 1024 * 1024) { + err = fmt.Errorf("specified Byte Range must be at most 4MB") + return + } + + if path != "" { + path = fmt.Sprintf("/%s/", path) + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: PutRangeOptions{ + input: input, + }, + Path: fmt.Sprintf("%s/%s%s", shareName, path, fileName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + req.Body = io.NopCloser(bytes.NewReader(input.Content)) + req.ContentLength = int64(len(input.Content)) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type PutRangeOptions struct { + input PutByteRangeInput +} + +func (p PutRangeOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("x-ms-write", "update") + headers.Append("x-ms-range", fmt.Sprintf("bytes=%d-%d", p.input.StartBytes, p.input.EndBytes-1)) + headers.Append("Content-Length", strconv.Itoa(len(p.input.Content))) + return headers +} + +func (p PutRangeOptions) ToOData() *odata.Query { + return nil +} + +func (p PutRangeOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "range") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/range_put_file.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_put_file.go similarity index 70% rename from vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/range_put_file.go rename to vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_put_file.go index a74845dd61ca5..660122c1aa8f8 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files/range_put_file.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/range_put_file.go @@ -8,15 +8,16 @@ import ( "math" "os" "sync" - - "github.com/Azure/go-autorest/autorest" ) // PutFile is a helper method which takes a file, and automatically chunks it up, rather than having to do this yourself -func (client Client) PutFile(ctx context.Context, accountName, shareName, path, fileName string, file *os.File, parallelism int) error { +func (c Client) PutFile(ctx context.Context, shareName, path, fileName string, file *os.File, parallelism int) error { fileInfo, err := file.Stat() if err != nil { - return fmt.Errorf("Error loading file info: %s", err) + return fmt.Errorf("error loading file info: %s", err) + } + if fileInfo.Size() == 0 { + return fmt.Errorf("file is empty which is not supported") } fileSize := fileInfo.Size() @@ -48,7 +49,7 @@ func (client Client) PutFile(ctx context.Context, accountName, shareName, path, fileSize: fileSize, } - _, err := client.uploadChunk(ctx, accountName, shareName, path, fileName, uci, file) + _, err := c.uploadChunk(ctx, shareName, path, fileName, uci, file) if err != nil { errors <- err } @@ -65,7 +66,7 @@ func (client Client) PutFile(ctx context.Context, accountName, shareName, path, // TODO: we should switch to hashicorp/multi-error here if len(errors) > 0 { - return fmt.Errorf("Error uploading file: %s", <-errors) + return fmt.Errorf("uploading file: %s", <-errors) } return nil @@ -77,7 +78,7 @@ type uploadChunkInput struct { fileSize int64 } -func (client Client) uploadChunk(ctx context.Context, accountName, shareName, path, fileName string, input uploadChunkInput, file *os.File) (result autorest.Response, err error) { +func (c Client) uploadChunk(ctx context.Context, shareName, path, fileName string, input uploadChunkInput, file *os.File) (result PutRangeResponse, err error) { startBytes := int64(input.chunkSize * input.thisChunk) endBytes := startBytes + int64(input.chunkSize) @@ -93,7 +94,7 @@ func (client Client) uploadChunk(ctx context.Context, accountName, shareName, pa _, err = file.ReadAt(bytes, startBytes) if err != nil { if err != io.EOF { - return result, fmt.Errorf("Error reading bytes: %s", err) + return result, fmt.Errorf("reading bytes: %s", err) } } @@ -102,9 +103,9 @@ func (client Client) uploadChunk(ctx context.Context, accountName, shareName, pa EndBytes: endBytes, Content: bytes, } - result, err = client.PutByteRange(ctx, accountName, shareName, path, fileName, putBytesInput) + result, err = c.PutByteRange(ctx, shareName, path, fileName, putBytesInput) if err != nil { - return result, fmt.Errorf("Error putting bytes: %s", err) + return result, fmt.Errorf("putting bytes: %s", err) } return diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/ranges_list.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/ranges_list.go new file mode 100644 index 0000000000000..0b89e6c1a1102 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/ranges_list.go @@ -0,0 +1,99 @@ +package files + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type ListRangesResponse struct { + HttpResponse *http.Response + + Ranges []Range `xml:"Range"` +} + +type Range struct { + Start string `xml:"Start"` + End string `xml:"End"` +} + +// ListRanges returns the list of valid ranges for the specified File. +func (c Client) ListRanges(ctx context.Context, shareName, path, fileName string) (result ListRangesResponse, err error) { + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if path == "" { + err = fmt.Errorf("`path` cannot be an empty string") + return + } + + if fileName == "" { + err = fmt.Errorf("`fileName` cannot be an empty string") + return + } + + if path != "" { + path = fmt.Sprintf("%s/", path) + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: ListRangeOptions{}, + Path: fmt.Sprintf("/%s/%s%s", shareName, path, fileName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type ListRangeOptions struct{} + +func (l ListRangeOptions) ToHeaders() *client.Headers { + return nil +} + +func (l ListRangeOptions) ToOData() *odata.Query { + return nil +} + +func (l ListRangeOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "rangelist") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/resource_id.go new file mode 100644 index 0000000000000..492889780e31d --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/resource_id.go @@ -0,0 +1,87 @@ +package files + +import ( + "fmt" + "net/url" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts" +) + +// TODO: update this to implement `resourceids.ResourceId` once +// https://github.com/hashicorp/go-azure-helpers/issues/187 is fixed +var _ resourceids.Id = FileId{} + +type FileId struct { + // AccountId specifies the ID of the Storage Account where this File exists. + AccountId accounts.AccountId + + // ShareName specifies the name of the File Share containing this File. + ShareName string + + // DirectoryPath specifies the path representing the Directory where this File exists. + DirectoryPath string + + // FileName specifies the name of the File. + FileName string +} + +func NewFileID(accountId accounts.AccountId, shareName, directoryPath, fileName string) FileId { + return FileId{ + AccountId: accountId, + ShareName: shareName, + DirectoryPath: directoryPath, + FileName: fileName, + } +} + +func (b FileId) ID() string { + return fmt.Sprintf("%s/%s/%s/%s", b.AccountId.ID(), b.ShareName, b.DirectoryPath, b.FileName) +} + +func (b FileId) String() string { + components := []string{ + fmt.Sprintf("Directory Path %q", b.DirectoryPath), + fmt.Sprintf("Share Name %q", b.ShareName), + fmt.Sprintf("Account %q", b.AccountId.String()), + } + return fmt.Sprintf("File %q (%s)", b.FileName, strings.Join(components, " / ")) +} + +// ParseFileID parses `input` into a File ID using a known `domainSuffix` +func ParseFileID(input, domainSuffix string) (*FileId, error) { + // example: https://foo.file.core.windows.net/Bar/some/directory/some-file.txt + if input == "" { + return nil, fmt.Errorf("`input` was empty") + } + + account, err := accounts.ParseAccountID(input, domainSuffix) + if err != nil { + return nil, fmt.Errorf("parsing account %q: %+v", input, err) + } + + if account.SubDomainType != accounts.FileSubDomainType { + return nil, fmt.Errorf("expected the subdomain type to be %q but got %q", string(accounts.FileSubDomainType), string(account.SubDomainType)) + } + + uri, err := url.Parse(input) + if err != nil { + return nil, fmt.Errorf("parsing %q as a uri: %+v", input, err) + } + + path := strings.TrimPrefix(uri.Path, "/") + segments := strings.Split(path, "/") + if len(segments) < 3 { + return nil, fmt.Errorf("expected the path to contain at least 3 segments but got %d", len(segments)) + } + shareName := segments[0] + directoryPath := strings.Join(segments[1:len(segments)-1], "/") + fileName := segments[len(segments)-1] + return &FileId{ + AccountId: *account, + ShareName: shareName, + DirectoryPath: directoryPath, + FileName: fileName, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/version.go new file mode 100644 index 0000000000000..1d4bc38bea91a --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files/version.go @@ -0,0 +1,4 @@ +package files + +const apiVersion = "2023-11-03" +const componentName = "file/files" diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/README.md b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/README.md new file mode 100644 index 0000000000000..5ec0fb4f8fc08 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/README.md @@ -0,0 +1,50 @@ +## File Storage Shares SDK for API version 2023-11-03 + +This package allows you to interact with the Shares File Storage API + +### Supported Authorizers + +* Azure Active Directory (for the Resource Endpoint `https://storage.azure.com`) +* SharedKeyLite (Blob, File & Queue) + +### Example Usage + +```go +package main + +import ( + "context" + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/auth" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares" +) + +func Example() error { + accountName := "storageaccount1" + storageAccountKey := "ABC123...." + shareName := "myshare" + domainSuffix := "core.windows.net" + + auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey) + if err != nil { + return fmt.Errorf("building SharedKey authorizer: %+v", err) + } + + sharesClient, err := shares.NewWithBaseUri(fmt.Sprintf("https://%s.file.%s", accountName, domainSuffix)) + if err != nil { + return fmt.Errorf("building SharedKey authorizer: %+v", err) + } + sharesClient.Client.SetAuthorizer(auth) + + ctx := context.TODO() + input := shares.CreateInput{ + QuotaInGB: 2, + } + if _, err := sharesClient.Create(ctx, shareName, input); err != nil { + return fmt.Errorf("Error creating Share: %s", err) + } + + return nil +} +``` \ No newline at end of file diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/acl_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/acl_get.go new file mode 100644 index 0000000000000..8add483a5e3ef --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/acl_get.go @@ -0,0 +1,81 @@ +package shares + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type GetACLResult struct { + HttpResponse *http.Response + + SignedIdentifiers []SignedIdentifier `xml:"SignedIdentifier"` +} + +// GetACL get the Access Control List for the specified Storage Share +func (c Client) GetACL(ctx context.Context, shareName string) (result GetACLResult, err error) { + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: getAclOptions{}, + Path: fmt.Sprintf("/%s", shareName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type getAclOptions struct { +} + +func (g getAclOptions) ToHeaders() *client.Headers { + return nil +} + +func (g getAclOptions) ToOData() *odata.Query { + return nil +} + +func (g getAclOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("restype", "share") + out.Append("comp", "acl") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/acl_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/acl_set.go new file mode 100644 index 0000000000000..216d714eb2ac6 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/acl_set.go @@ -0,0 +1,95 @@ +package shares + +import ( + "bytes" + "context" + "encoding/xml" + "fmt" + "io" + "net/http" + "strconv" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type SetAclResponse struct { + HttpResponse *http.Response +} + +type SetAclInput struct { + SignedIdentifiers []SignedIdentifier `xml:"SignedIdentifier"` + XMLName xml.Name `xml:"SignedIdentifiers"` +} + +// SetACL sets the specified Access Control List on the specified Storage Share +func (c Client) SetACL(ctx context.Context, shareName string, input SetAclInput) (result SetAclResponse, err error) { + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: setAclOptions{}, + Path: fmt.Sprintf("/%s", shareName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + b, err := xml.Marshal(&input) + if err != nil { + err = fmt.Errorf("marshalling input: %+v", err) + return + } + withHeader := xml.Header + string(b) + bytesWithHeader := []byte(withHeader) + req.ContentLength = int64(len(bytesWithHeader)) + req.Header.Set("Content-Length", strconv.Itoa(len(bytesWithHeader))) + req.Body = io.NopCloser(bytes.NewReader(bytesWithHeader)) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type setAclOptions struct { + SignedIdentifiers []SignedIdentifier `xml:"SignedIdentifier"` +} + +func (s setAclOptions) ToHeaders() *client.Headers { + return nil +} + +func (s setAclOptions) ToOData() *odata.Query { + return nil +} + +func (s setAclOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("restype", "share") + out.Append("comp", "acl") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/api.go new file mode 100644 index 0000000000000..553fb4899e469 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/api.go @@ -0,0 +1,21 @@ +package shares + +import ( + "context" +) + +type StorageShare interface { + SetACL(ctx context.Context, shareName string, input SetAclInput) (SetAclResponse, error) + GetSnapshot(ctx context.Context, shareName string, input GetSnapshotPropertiesInput) (GetSnapshotPropertiesResponse, error) + GetStats(ctx context.Context, shareName string) (GetStatsResponse, error) + GetACL(ctx context.Context, shareName string) (GetACLResult, error) + SetMetaData(ctx context.Context, shareName string, input SetMetaDataInput) (SetMetaDataResponse, error) + GetMetaData(ctx context.Context, shareName string) (GetMetaDataResponse, error) + SetProperties(ctx context.Context, shareName string, properties ShareProperties) (SetPropertiesResponse, error) + DeleteSnapshot(ctx context.Context, accountName string, shareName string, shareSnapshot string) (DeleteSnapshotResponse, error) + CreateSnapshot(ctx context.Context, shareName string, input CreateSnapshotInput) (CreateSnapshotResponse, error) + GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, shareName string) string + GetProperties(ctx context.Context, shareName string) (GetPropertiesResult, error) + Delete(ctx context.Context, shareName string, input DeleteInput) (DeleteResponse, error) + Create(ctx context.Context, shareName string, input CreateInput) (CreateResponse, error) +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/client.go new file mode 100644 index 0000000000000..7d6516f76ed85 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/client.go @@ -0,0 +1,22 @@ +package shares + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/storage" +) + +// Client is the base client for File Storage Shares. +type Client struct { + Client *storage.Client +} + +func NewWithBaseUri(baseUri string) (*Client, error) { + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) + if err != nil { + return nil, fmt.Errorf("building base client: %+v", err) + } + return &Client{ + Client: baseClient, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/create.go new file mode 100644 index 0000000000000..32075f0fad3ba --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/create.go @@ -0,0 +1,157 @@ +package shares + +import ( + "bytes" + "context" + "encoding/xml" + "fmt" + "io" + "net/http" + "strconv" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type AccessTier string + +const ( + TransactionOptimizedAccessTier AccessTier = "TransactionOptimized" + HotAccessTier AccessTier = "Hot" + CoolAccessTier AccessTier = "Cool" + PremiumAccessTier AccessTier = "Premium" +) + +type CreateInput struct { + // Specifies the maximum size of the share, in gigabytes. + // Must be greater than 0, and less than or equal to 5TB (5120). + QuotaInGB int + + // Specifies the enabled protocols on the share. If not specified, the default is SMB. + EnabledProtocol ShareProtocol + + MetaData map[string]string + + // Specifies the access tier of the share. + AccessTier *AccessTier +} + +type CreateResponse struct { + HttpResponse *http.Response +} + +// Create creates the specified Storage Share within the specified Storage Account +func (c Client) Create(ctx context.Context, shareName string, input CreateInput) (result CreateResponse, err error) { + + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if input.QuotaInGB <= 0 || input.QuotaInGB > 102400 { + err = fmt.Errorf("`input.QuotaInGB` must be greater than 0, and less than/equal to 100TB (102400 GB)") + return + } + + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf("`input.MetaData` is not valid: %s", err) + return + } + + // Retry the share creation if a conflicting share is still in the process of being deleted + retryFunc := func(resp *http.Response, _ *odata.OData) (bool, error) { + if resp != nil { + if resp.StatusCode == http.StatusConflict { + // TODO: move this error response parsing to a common helper function + respBody, err := io.ReadAll(resp.Body) + if err != nil { + return false, fmt.Errorf("could not parse response body") + } + resp.Body.Close() + respBody = bytes.TrimPrefix(respBody, []byte("\xef\xbb\xbf")) + res := ErrorResponse{} + if err = xml.Unmarshal(respBody, &res); err != nil { + return false, err + } + resp.Body = io.NopCloser(bytes.NewBuffer(respBody)) + if res.Code != nil { + return strings.Contains(*res.Code, "ShareBeingDeleted"), nil + } + } + } + return false, nil + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: CreateOptions{ + input: input, + }, + Path: fmt.Sprintf("/%s", shareName), + RetryFunc: retryFunc, + } + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type CreateOptions struct { + input CreateInput +} + +func (c CreateOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + if len(c.input.MetaData) > 0 { + headers.Merge(metadata.SetMetaDataHeaders(c.input.MetaData)) + } + + protocol := SMB + if c.input.EnabledProtocol != "" { + protocol = c.input.EnabledProtocol + } + headers.Append("x-ms-enabled-protocols", string(protocol)) + + if c.input.AccessTier != nil { + headers.Append("x-ms-access-tier", string(*c.input.AccessTier)) + } + + headers.Append("x-ms-share-quota", strconv.Itoa(c.input.QuotaInGB)) + + return headers +} + +func (c CreateOptions) ToOData() *odata.Query { + return nil +} + +func (c CreateOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("restype", "share") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/delete.go new file mode 100644 index 0000000000000..84667f68a3efa --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/delete.go @@ -0,0 +1,83 @@ +package shares + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type DeleteResponse struct { + HttpResponse *http.Response +} + +type DeleteInput struct { + DeleteSnapshots bool +} + +// Delete deletes the specified Storage Share from within a Storage Account +func (c Client) Delete(ctx context.Context, shareName string, input DeleteInput) (result DeleteResponse, err error) { + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodDelete, + OptionsObject: DeleteOptions{ + deleteSnapshots: input.DeleteSnapshots, + }, + Path: fmt.Sprintf("/%s", shareName), + } + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type DeleteOptions struct { + deleteSnapshots bool +} + +func (d DeleteOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + if d.deleteSnapshots { + headers.Append("x-ms-delete-snapshots", "include") + } + return headers +} + +func (d DeleteOptions) ToOData() *odata.Query { + return nil +} + +func (d DeleteOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("restype", "share") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/metadata_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/metadata_get.go new file mode 100644 index 0000000000000..eeb8b4d1e7dcf --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/metadata_get.go @@ -0,0 +1,77 @@ +package shares + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type GetMetaDataResponse struct { + HttpResponse *http.Response + + MetaData map[string]string +} + +// GetMetaData returns the MetaData associated with the specified Storage Share +func (c Client) GetMetaData(ctx context.Context, shareName string) (result GetMetaDataResponse, err error) { + if shareName == "" { + return result, fmt.Errorf("`shareName` cannot be an empty string") + } + if strings.ToLower(shareName) != shareName { + return result, fmt.Errorf("`shareName` must be a lower-cased string") + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: GetMetaDataOptions{}, + Path: fmt.Sprintf("/%s", shareName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type GetMetaDataOptions struct{} + +func (g GetMetaDataOptions) ToHeaders() *client.Headers { + return nil +} + +func (g GetMetaDataOptions) ToOData() *odata.Query { + return nil +} + +func (g GetMetaDataOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("restype", "share") + out.Append("comp", "metadata") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/metadata_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/metadata_set.go new file mode 100644 index 0000000000000..55bf1d4bedfce --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/metadata_set.go @@ -0,0 +1,89 @@ +package shares + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type SetMetaDataResponse struct { + HttpResponse *http.Response +} + +type SetMetaDataInput struct { + MetaData map[string]string +} + +// SetMetaData sets the MetaData on the specified Storage Share +func (c Client) SetMetaData(ctx context.Context, shareName string, input SetMetaDataInput) (result SetMetaDataResponse, err error) { + + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf("`metadata` is not valid: %+v", err) + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: SetMetaDataOptions{ + metaData: input.MetaData, + }, + Path: fmt.Sprintf("/%s", shareName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type SetMetaDataOptions struct { + metaData map[string]string +} + +func (s SetMetaDataOptions) ToHeaders() *client.Headers { + headers := metadata.SetMetaDataHeaders(s.metaData) + return &headers +} + +func (s SetMetaDataOptions) ToOData() *odata.Query { + return nil +} + +func (s SetMetaDataOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("restype", "share") + out.Append("comp", "metadata") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/models.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/models.go similarity index 78% rename from vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/models.go rename to vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/models.go index 32727164cc835..61c3be66ae478 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares/models.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/models.go @@ -1,5 +1,7 @@ package shares +import "encoding/xml" + type SignedIdentifier struct { Id string `xml:"Id"` AccessPolicy AccessPolicy `xml:"AccessPolicy"` @@ -20,3 +22,9 @@ const ( // NFS indicates the share can be accessed by NFSv4.1. A premium account is required for this option. NFS ShareProtocol = "NFS" ) + +type ErrorResponse struct { + XMLName xml.Name `xml:"Error"` + Code *string `xml:"Code"` + Message *string `xml:"Message"` +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/options.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/options.go new file mode 100644 index 0000000000000..e2c1d5c9b4cd9 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/options.go @@ -0,0 +1,24 @@ +package shares + +import ( + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +var _ client.Options = sharesOptions{} + +type sharesOptions struct{} + +func (o sharesOptions) ToHeaders() *client.Headers { + return &client.Headers{} +} + +func (sharesOptions) ToOData() *odata.Query { + return nil +} + +func (sharesOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("restype", "share") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/properties_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/properties_get.go new file mode 100644 index 0000000000000..fb153628fd092 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/properties_get.go @@ -0,0 +1,87 @@ +package shares + +import ( + "context" + "fmt" + "net/http" + "strconv" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type GetPropertiesResult struct { + HttpResponse *http.Response + + MetaData map[string]string + QuotaInGB int + EnabledProtocol ShareProtocol + AccessTier *AccessTier +} + +// GetProperties returns the properties about the specified Storage Share +func (c Client) GetProperties(ctx context.Context, shareName string) (result GetPropertiesResult, err error) { + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: sharesOptions{}, + Path: fmt.Sprintf("/%s", shareName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.MetaData = metadata.ParseFromHeaders(resp.Header) + + quotaRaw := resp.Header.Get("x-ms-share-quota") + if quotaRaw != "" { + quota, e := strconv.Atoi(quotaRaw) + if e != nil { + err = fmt.Errorf("error converting %q to an integer: %s", quotaRaw, err) + return + } + result.QuotaInGB = quota + } + + protocol := SMB + if protocolRaw := resp.Header.Get("x-ms-enabled-protocols"); protocolRaw != "" { + protocol = ShareProtocol(protocolRaw) + } + + if accessTierRaw := resp.Header.Get("x-ms-access-tier"); accessTierRaw != "" { + tier := AccessTier(accessTierRaw) + result.AccessTier = &tier + } + result.EnabledProtocol = protocol + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/properties_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/properties_set.go new file mode 100644 index 0000000000000..f80df4fdce1c6 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/properties_set.go @@ -0,0 +1,94 @@ +package shares + +import ( + "context" + "fmt" + "net/http" + "strconv" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type ShareProperties struct { + QuotaInGb *int + AccessTier *AccessTier +} + +type SetPropertiesResponse struct { + HttpResponse *http.Response +} + +// SetProperties lets you update the Quota for the specified Storage Share +func (c Client) SetProperties(ctx context.Context, shareName string, properties ShareProperties) (result SetPropertiesResponse, err error) { + + if shareName == "" { + return result, fmt.Errorf("`shareName` cannot be an empty string") + } + + if strings.ToLower(shareName) != shareName { + return result, fmt.Errorf("`shareName` must be a lower-cased string") + } + + if newQuotaGB := properties.QuotaInGb; newQuotaGB != nil && (*newQuotaGB <= 0 || *newQuotaGB > 102400) { + return result, fmt.Errorf("`newQuotaGB` must be greater than 0, and less than/equal to 100TB (102400 GB)") + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPut, + OptionsObject: SetPropertiesOptions{ + input: properties, + }, + Path: fmt.Sprintf("/%s", shareName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type SetPropertiesOptions struct { + input ShareProperties +} + +func (s SetPropertiesOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + if s.input.QuotaInGb != nil { + headers.Append("x-ms-share-quota", strconv.Itoa(*s.input.QuotaInGb)) + } + + if s.input.AccessTier != nil { + headers.Append("x-ms-access-tier", string(*s.input.AccessTier)) + } + return headers +} + +func (s SetPropertiesOptions) ToOData() *odata.Query { + return nil +} + +func (s SetPropertiesOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("restype", "share") + out.Append("comp", "properties") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/resource_id.go new file mode 100644 index 0000000000000..c46092b4400f7 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/resource_id.go @@ -0,0 +1,81 @@ +package shares + +import ( + "fmt" + "net/url" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts" +) + +// GetResourceManagerResourceID returns the Resource Manager specific +// ResourceID for a specific Storage Share +func (c Client) GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, shareName string) string { + fmtStr := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s/fileServices/default/shares/%s" + return fmt.Sprintf(fmtStr, subscriptionID, resourceGroup, accountName, shareName) +} + +// TODO: update this to implement `resourceids.ResourceId` once +// https://github.com/hashicorp/go-azure-helpers/issues/187 is fixed +var _ resourceids.Id = ShareId{} + +type ShareId struct { + // AccountId specifies the ID of the Storage Account where this File Share exists. + AccountId accounts.AccountId + + // ShareName specifies the name of this File Share. + ShareName string +} + +func NewShareID(accountId accounts.AccountId, shareName string) ShareId { + return ShareId{ + AccountId: accountId, + ShareName: shareName, + } +} + +func (b ShareId) ID() string { + return fmt.Sprintf("%s/%s", b.AccountId.ID(), b.ShareName) +} + +func (b ShareId) String() string { + components := []string{ + fmt.Sprintf("Account %q", b.AccountId.String()), + } + return fmt.Sprintf("File Share %q (%s)", b.ShareName, strings.Join(components, " / ")) +} + +// ParseShareID parses `input` into a Share ID using a known `domainSuffix` +func ParseShareID(input, domainSuffix string) (*ShareId, error) { + // example: https://foo.file.core.windows.net/Bar + if input == "" { + return nil, fmt.Errorf("`input` was empty") + } + + account, err := accounts.ParseAccountID(input, domainSuffix) + if err != nil { + return nil, fmt.Errorf("parsing account %q: %+v", input, err) + } + + if account.SubDomainType != accounts.FileSubDomainType { + return nil, fmt.Errorf("expected the subdomain type to be %q but got %q", string(accounts.FileSubDomainType), string(account.SubDomainType)) + } + + uri, err := url.Parse(input) + if err != nil { + return nil, fmt.Errorf("parsing %q as a uri: %+v", input, err) + } + + path := strings.TrimPrefix(uri.Path, "/") + segments := strings.Split(path, "/") + if len(segments) == 0 { + return nil, fmt.Errorf("Expected the path to contain segments but got none") + } + + shareName := strings.TrimPrefix(uri.Path, "/") + return &ShareId{ + AccountId: *account, + ShareName: shareName, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_create.go new file mode 100644 index 0000000000000..d4dff0328043f --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_create.go @@ -0,0 +1,100 @@ +package shares + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type CreateSnapshotInput struct { + MetaData map[string]string +} + +type CreateSnapshotResponse struct { + HttpResponse *http.Response + + // This header is a DateTime value that uniquely identifies the share snapshot. + // The value of this header may be used in subsequent requests to access the share snapshot. + // This value is opaque. + SnapshotDateTime string +} + +// CreateSnapshot creates a read-only snapshot of the share +// A share can support creation of 200 share snapshots. Attempting to create more than 200 share snapshots fails with 409 (Conflict). +// Attempting to create a share snapshot while a previous Snapshot Share operation is in progress fails with 409 (Conflict). +func (c Client) CreateSnapshot(ctx context.Context, shareName string, input CreateSnapshotInput) (result CreateSnapshotResponse, err error) { + + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if err = metadata.Validate(input.MetaData); err != nil { + err = fmt.Errorf("`input.MetaData` is not valid: %+v", err) + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: snapShotCreateOptions{ + metaData: input.MetaData, + }, + Path: fmt.Sprintf("/%s", shareName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.SnapshotDateTime = resp.Header.Get("x-ms-snapshot") + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type snapShotCreateOptions struct { + metaData map[string]string +} + +func (s snapShotCreateOptions) ToHeaders() *client.Headers { + headers := metadata.SetMetaDataHeaders(s.metaData) + return &headers +} + +func (s snapShotCreateOptions) ToOData() *odata.Query { + return nil +} + +func (s snapShotCreateOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("restype", "share") + out.Append("comp", "snapshot") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_delete.go new file mode 100644 index 0000000000000..64dd532068a03 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_delete.go @@ -0,0 +1,80 @@ +package shares + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type DeleteSnapshotResponse struct { + HttpResponse *http.Response +} + +// DeleteSnapshot deletes the specified Snapshot of a Storage Share +func (c Client) DeleteSnapshot(ctx context.Context, accountName, shareName string, shareSnapshot string) (result DeleteSnapshotResponse, err error) { + + if shareName == "" { + return result, fmt.Errorf("`shareName` cannot be an empty string") + } + + if strings.ToLower(shareName) != shareName { + return result, fmt.Errorf("`shareName` must be a lower-cased string") + } + + if shareSnapshot == "" { + return result, fmt.Errorf("`shareSnapshot` cannot be an empty string") + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodDelete, + OptionsObject: snapShotDeleteOptions{ + shareSnapShot: shareSnapshot, + }, + Path: fmt.Sprintf("/%s", shareName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type snapShotDeleteOptions struct { + shareSnapShot string +} + +func (s snapShotDeleteOptions) ToHeaders() *client.Headers { + return nil +} + +func (s snapShotDeleteOptions) ToOData() *odata.Query { + return nil +} + +func (s snapShotDeleteOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("restype", "share") + out.Append("sharesnapshot", s.shareSnapShot) + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_get.go new file mode 100644 index 0000000000000..e4aee485b0163 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/snapshot_get.go @@ -0,0 +1,93 @@ +package shares + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type GetSnapshotPropertiesResponse struct { + HttpResponse *http.Response + + MetaData map[string]string +} + +type GetSnapshotPropertiesInput struct { + snapshotShare string +} + +// GetSnapshot gets information about the specified Snapshot of the specified Storage Share +func (c Client) GetSnapshot(ctx context.Context, shareName string, input GetSnapshotPropertiesInput) (result GetSnapshotPropertiesResponse, err error) { + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + if input.snapshotShare == "" { + err = fmt.Errorf("`snapshotShare` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: snapShotGetOptions{ + snapshotShare: input.snapshotShare, + }, + Path: fmt.Sprintf("/%s", shareName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type snapShotGetOptions struct { + snapshotShare string +} + +func (s snapShotGetOptions) ToHeaders() *client.Headers { + return nil +} + +func (s snapShotGetOptions) ToOData() *odata.Query { + return nil +} + +func (s snapShotGetOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("restype", "share") + out.Append("snapshot", s.snapshotShare) + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/stats.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/stats.go new file mode 100644 index 0000000000000..d375d837ed7e8 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/stats.go @@ -0,0 +1,83 @@ +package shares + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type GetStatsResponse struct { + HttpResponse *http.Response + + // The approximate size of the data stored on the share. + // Note that this value may not include all recently created or recently resized files. + ShareUsageBytes int64 `xml:"ShareUsageBytes"` +} + +// GetStats returns information about the specified Storage Share +func (c Client) GetStats(ctx context.Context, shareName string) (result GetStatsResponse, err error) { + if shareName == "" { + err = fmt.Errorf("`shareName` cannot be an empty string") + return + } + + if strings.ToLower(shareName) != shareName { + err = fmt.Errorf("`shareName` must be a lower-cased string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: statsOptions{}, + Path: shareName, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type statsOptions struct{} + +func (s statsOptions) ToHeaders() *client.Headers { + return nil +} + +func (s statsOptions) ToOData() *odata.Query { + return nil +} + +func (s statsOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("restype", "share") + out.Append("comp", "stats") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/version.go new file mode 100644 index 0000000000000..6f62a9bdaf858 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares/version.go @@ -0,0 +1,4 @@ +package shares + +const apiVersion = "2023-11-03" +const componentName = "file/shares" diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/README.md b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/README.md new file mode 100644 index 0000000000000..745cc6d70ca51 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/README.md @@ -0,0 +1,53 @@ +## Queue Storage Queues SDK for API version 2023-11-03 + +This package allows you to interact with the Queues Queue Storage API + +### Supported Authorizers + +* Azure Active Directory (for the Resource Endpoint `https://storage.azure.com`) +* SharedKeyLite (Blob, File & Queue) + +### Example Usage + +```go +package main + +import ( + "context" + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/auth" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues" +) + +func Example() error { + accountName := "storageaccount1" + storageAccountKey := "ABC123...." + queueName := "myqueue" + domainSuffix := "core.windows.net" + + auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKey) + if err != nil { + return fmt.Errorf("building SharedKey authorizer: %+v", err) + } + + queuesClient, err := queues.NewWithBaseUri(fmt.Sprintf("https://%s.queue.%s", accountName, domainSuffix)) + if err != nil { + return fmt.Errorf("building client for environment: %+v", err) + } + queuesClient.Client.SetAuthorizer(auth) + + ctx := context.TODO() + metadata := map[string]string{ + "hello": "world", + } + input := queues.CreateInput{ + Metadata: metadata, + } + if _, err := queuesClient.Create(ctx, queueName, input); err != nil { + return fmt.Errorf("Error creating Queue: %s", err) + } + + return nil +} +``` \ No newline at end of file diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/api.go new file mode 100644 index 0000000000000..e051453e47f09 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/api.go @@ -0,0 +1,15 @@ +package queues + +import ( + "context" +) + +type StorageQueue interface { + Delete(ctx context.Context, queueName string) (DeleteResponse, error) + GetMetaData(ctx context.Context, queueName string) (GetMetaDataResponse, error) + SetMetaData(ctx context.Context, queueName string, input SetMetaDataInput) (SetMetaDataResponse, error) + Create(ctx context.Context, queueName string, input CreateInput) (CreateResponse, error) + GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, queueName string) string + SetServiceProperties(ctx context.Context, input SetStorageServicePropertiesInput) (SetStorageServicePropertiesResponse, error) + GetServiceProperties(ctx context.Context) (GetStorageServicePropertiesResponse, error) +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/client.go new file mode 100644 index 0000000000000..4497f0eb748c3 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/client.go @@ -0,0 +1,24 @@ +package queues + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/storage" +) + +// Client is the base client for Queue Storage Shares. + +// Client is the base client for Messages. +type Client struct { + Client *storage.Client +} + +func NewWithBaseUri(baseUri string) (*Client, error) { + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) + if err != nil { + return nil, fmt.Errorf("building base client: %+v", err) + } + return &Client{ + Client: baseClient, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/create.go new file mode 100644 index 0000000000000..f548088ce288f --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/create.go @@ -0,0 +1,87 @@ +package queues + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type CreateInput struct { + MetaData map[string]string +} + +type CreateResponse struct { + HttpResponse *http.Response +} + +// Create creates the specified Queue within the specified Storage Account +func (c Client) Create(ctx context.Context, queueName string, input CreateInput) (result CreateResponse, err error) { + + if queueName == "" { + return result, fmt.Errorf("`queueName` cannot be an empty string") + } + + if strings.ToLower(queueName) != queueName { + return result, fmt.Errorf("`queueName` must be a lower-cased string") + } + + if err := metadata.Validate(input.MetaData); err != nil { + return result, fmt.Errorf("`metadata` is not valid: %s", err) + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + }, + HttpMethod: http.MethodPut, + OptionsObject: createOptions{ + metadata: input.MetaData, + }, + Path: fmt.Sprintf("/%s", queueName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type createOptions struct { + metadata map[string]string +} + +func (c createOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + + if len(c.metadata) > 0 { + headers.Merge(metadata.SetMetaDataHeaders(c.metadata)) + } + return headers +} + +func (c createOptions) ToOData() *odata.Query { + return nil +} + +func (c createOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/delete.go new file mode 100644 index 0000000000000..e8d7babb12fe1 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/delete.go @@ -0,0 +1,54 @@ +package queues + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" +) + +type DeleteResponse struct { + HttpResponse *http.Response +} + +// Delete deletes the specified Queue within the specified Storage Account +func (c Client) Delete(ctx context.Context, queueName string) (result DeleteResponse, err error) { + + if queueName == "" { + return result, fmt.Errorf("`queueName` cannot be an empty string") + } + + if strings.ToLower(queueName) != queueName { + return result, fmt.Errorf("`queueName` must be a lower-cased string") + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + OptionsObject: nil, + Path: fmt.Sprintf("/%s", queueName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/metadata_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/metadata_get.go new file mode 100644 index 0000000000000..c8a259f451ba6 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/metadata_get.go @@ -0,0 +1,84 @@ +package queues + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type GetMetaDataResponse struct { + HttpResponse *http.Response + + MetaData map[string]string +} + +// GetMetaData returns the metadata for this Queue +func (c Client) GetMetaData(ctx context.Context, queueName string) (result GetMetaDataResponse, err error) { + + if queueName == "" { + return result, fmt.Errorf("`queueName` cannot be an empty string") + } + + if strings.ToLower(queueName) != queueName { + return result, fmt.Errorf("`queueName` must be a lower-cased string") + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: getMetaDataOptions{}, + Path: fmt.Sprintf("/%s", queueName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + if resp.Header != nil { + result.MetaData = metadata.ParseFromHeaders(resp.Header) + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + if result.HttpResponse != nil { + if result.HttpResponse.Header != nil { + result.MetaData = metadata.ParseFromHeaders(result.HttpResponse.Header) + } + } + + return +} + +type getMetaDataOptions struct{} + +func (g getMetaDataOptions) ToHeaders() *client.Headers { + return nil +} + +func (g getMetaDataOptions) ToOData() *odata.Query { + return nil +} + +func (g getMetaDataOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "metadata") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/metadata_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/metadata_set.go new file mode 100644 index 0000000000000..6ab770de1f52b --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/metadata_set.go @@ -0,0 +1,86 @@ +package queues + +import ( + "context" + "fmt" + "net/http" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" + "github.com/tombuildsstuff/giovanni/storage/internal/metadata" +) + +type SetMetaDataResponse struct { + HttpResponse *http.Response +} + +type SetMetaDataInput struct { + MetaData map[string]string +} + +// SetMetaData returns the metadata for this Queue +func (c Client) SetMetaData(ctx context.Context, queueName string, input SetMetaDataInput) (result SetMetaDataResponse, err error) { + + if queueName == "" { + return result, fmt.Errorf("`queueName` cannot be an empty string") + } + + if strings.ToLower(queueName) != queueName { + return result, fmt.Errorf("`queueName` must be a lower-cased string") + } + + if err := metadata.Validate(input.MetaData); err != nil { + return result, fmt.Errorf("`metadata` is not valid: %+v", err) + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPut, + OptionsObject: setMetaDataOptions{ + metadata: input.MetaData, + }, + Path: fmt.Sprintf("/%s", queueName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type setMetaDataOptions struct { + metadata map[string]string +} + +func (s setMetaDataOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Merge(metadata.SetMetaDataHeaders(s.metadata)) + return headers +} + +func (s setMetaDataOptions) ToOData() *odata.Query { + return nil +} + +func (s setMetaDataOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "metadata") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/models.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/models.go similarity index 96% rename from vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/models.go rename to vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/models.go index 2195244fa44be..fbbbce9634c46 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues/models.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/models.go @@ -36,7 +36,7 @@ type Cors struct { type CorsRule struct { AllowedOrigins string `xml:"AllowedOrigins"` AllowedMethods string `xml:"AllowedMethods"` - AllowedHeaders string `xml:"AllowedHeaders` + AllowedHeaders string `xml:"AllowedHeaders"` ExposedHeaders string `xml:"ExposedHeaders"` MaxAgeInSeconds int `xml:"MaxAgeInSeconds"` } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/properties_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/properties_get.go new file mode 100644 index 0000000000000..0647f26d1b8f3 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/properties_get.go @@ -0,0 +1,70 @@ +package queues + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type GetStorageServicePropertiesResponse struct { + StorageServiceProperties + HttpResponse *http.Response +} + +// GetServiceProperties gets the properties for this queue +func (c Client) GetServiceProperties(ctx context.Context) (result GetStorageServicePropertiesResponse, err error) { + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: getStorageServicePropertiesOptions{}, + Path: "/", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type getStorageServicePropertiesOptions struct{} + +func (g getStorageServicePropertiesOptions) ToHeaders() *client.Headers { + return nil +} + +func (g getStorageServicePropertiesOptions) ToOData() *odata.Query { + return nil +} + +func (g getStorageServicePropertiesOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "properties") + out.Append("restype", "service") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/properties_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/properties_set.go new file mode 100644 index 0000000000000..d80b6728b3986 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/properties_set.go @@ -0,0 +1,80 @@ +package queues + +import ( + "bytes" + "context" + "encoding/xml" + "fmt" + "io" + "net/http" + "strconv" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type SetStorageServicePropertiesResponse struct { + HttpResponse *http.Response +} + +type SetStorageServicePropertiesInput struct { + Properties StorageServiceProperties +} + +// SetServiceProperties sets the properties for this queue +func (c Client) SetServiceProperties(ctx context.Context, input SetStorageServicePropertiesInput) (result SetStorageServicePropertiesResponse, err error) { + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPut, + OptionsObject: setStorageServicePropertiesOptions{}, + Path: "/", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + marshalledProps, err := xml.Marshal(&input.Properties) + if err != nil { + return result, fmt.Errorf("marshalling request: %+v", err) + } + body := xml.Header + string(marshalledProps) + req.Body = io.NopCloser(bytes.NewReader([]byte(body))) + req.ContentLength = int64(len(body)) + req.Header.Set("Content-Length", strconv.Itoa(len(body))) + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type setStorageServicePropertiesOptions struct{} + +func (s setStorageServicePropertiesOptions) ToHeaders() *client.Headers { + return nil +} + +func (s setStorageServicePropertiesOptions) ToOData() *odata.Query { + return nil +} + +func (s setStorageServicePropertiesOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("restype", "service") + out.Append("comp", "properties") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/resource_id.go new file mode 100644 index 0000000000000..8acd0bb0ae74f --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/resource_id.go @@ -0,0 +1,81 @@ +package queues + +import ( + "fmt" + "net/url" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts" +) + +// GetResourceManagerResourceID returns the Resource Manager ID for the given Queue +// This can be useful when, for example, you're using this as a unique identifier +func (c Client) GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, queueName string) string { + fmtStr := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s/queueServices/default/queues/%s" + return fmt.Sprintf(fmtStr, subscriptionID, resourceGroup, accountName, queueName) +} + +// TODO: update this to implement `resourceids.ResourceId` once +// https://github.com/hashicorp/go-azure-helpers/issues/187 is fixed +var _ resourceids.Id = QueueId{} + +type QueueId struct { + // AccountId specifies the ID of the Storage Account where this Queue exists. + AccountId accounts.AccountId + + // QueueName specifies the name of this Queue. + QueueName string +} + +func NewQueueID(accountId accounts.AccountId, queueName string) QueueId { + return QueueId{ + AccountId: accountId, + QueueName: queueName, + } +} + +func (b QueueId) ID() string { + return fmt.Sprintf("%s/%s", b.AccountId.ID(), b.QueueName) +} + +func (b QueueId) String() string { + components := []string{ + fmt.Sprintf("Account %q", b.AccountId.String()), + } + return fmt.Sprintf("Queue %q (%s)", b.QueueName, strings.Join(components, " / ")) +} + +// ParseQueueID parses `input` into a Queue ID using a known `domainSuffix` +func ParseQueueID(input, domainSuffix string) (*QueueId, error) { + // example: https://foo.queue.core.windows.net/Bar + if input == "" { + return nil, fmt.Errorf("`input` was empty") + } + + account, err := accounts.ParseAccountID(input, domainSuffix) + if err != nil { + return nil, fmt.Errorf("parsing account %q: %+v", input, err) + } + + if account.SubDomainType != accounts.QueueSubDomainType { + return nil, fmt.Errorf("expected the subdomain type to be %q but got %q", string(accounts.QueueSubDomainType), string(account.SubDomainType)) + } + + uri, err := url.Parse(input) + if err != nil { + return nil, fmt.Errorf("parsing %q as a uri: %+v", input, err) + } + + path := strings.TrimPrefix(uri.Path, "/") + segments := strings.Split(path, "/") + if len(segments) != 1 { + return nil, fmt.Errorf("expected the path to contain 1 segment but got %d", len(segments)) + } + + queueName := strings.TrimPrefix(uri.Path, "/") + return &QueueId{ + AccountId: *account, + QueueName: queueName, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/version.go new file mode 100644 index 0000000000000..c22267eb6e7dc --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues/version.go @@ -0,0 +1,5 @@ +package queues + +// APIVersion is the version of the API used for all Storage API Operations +const apiVersion = "2023-11-03" +const componentName = "queue/queues" diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/README.md b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/README.md new file mode 100644 index 0000000000000..06b519b894231 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/README.md @@ -0,0 +1,55 @@ +## Table Storage Entities SDK for API version 2023-11-03 + +This package allows you to interact with the Entities Table Storage API + +### Supported Authorizers + +* SharedKeyLite (Table) + +### Example Usage + +```go +package main + +import ( + "context" + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/auth" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities" +) + +func Example() error { + accountName := "storageaccount1" + storageAccountKey := "ABC123...." + tableName := "mytable" + domainSuffix := "core.windows.net" + + auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKeyTable) + if err != nil { + return fmt.Errorf("building SharedKey authorizer: %+v", err) + } + + entitiesClient, err := entities.NewWithBaseUri(fmt.Sprintf("https://%s.table.%s", accountName, domainSuffix)) + if err != nil { + return fmt.Errorf("building client for environment: %+v", err) + } + entitiesClient.Client.SetAuthorizer(auth) + + ctx := context.TODO() + input := entities.InsertEntityInput{ + PartitionKey: "abc", + RowKey: "123", + MetaDataLevel: entities.NoMetaData, + Entity: map[string]interface{}{ + "title": "Don't Kill My Vibe", + "artist": "Sigrid", + }, + } + if _, err := entitiesClient.Insert(ctx, tableName, input); err != nil { + return fmt.Errorf("Error creating Entity: %s", err) + } + + return nil +} +``` \ No newline at end of file diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/api.go new file mode 100644 index 0000000000000..bb0e9809e3c9d --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/api.go @@ -0,0 +1,14 @@ +package entities + +import ( + "context" +) + +type StorageTableEntity interface { + Delete(ctx context.Context, tableName string, input DeleteEntityInput) (resp DeleteEntityResponse, err error) + Insert(ctx context.Context, tableName string, input InsertEntityInput) (resp InsertResponse, err error) + InsertOrReplace(ctx context.Context, tableName string, input InsertOrReplaceEntityInput) (resp InsertOrReplaceResponse, err error) + InsertOrMerge(ctx context.Context, tableName string, input InsertOrMergeEntityInput) (resp InsertOrMergeResponse, err error) + Query(ctx context.Context, tableName string, input QueryEntitiesInput) (resp QueryEntitiesResponse, err error) + Get(ctx context.Context, tableName string, input GetEntityInput) (resp GetEntityResponse, err error) +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/client.go new file mode 100644 index 0000000000000..e190af69d108c --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/client.go @@ -0,0 +1,23 @@ +package entities + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/storage" +) + +// Client is the base client for Table Storage Shares. +type Client struct { + Client *storage.Client +} + +func NewWithBaseUri(baseUri string) (*Client, error) { + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) + if err != nil { + return nil, fmt.Errorf("building base client: %+v", err) + } + + return &Client{ + Client: baseClient, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/delete.go new file mode 100644 index 0000000000000..61e7c712ac5e8 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/delete.go @@ -0,0 +1,84 @@ +package entities + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type DeleteEntityInput struct { + // When inserting an entity into a table, you must specify values for the PartitionKey and RowKey system properties. + // Together, these properties form the primary key and must be unique within the table. + // Both the PartitionKey and RowKey values must be string values; each key value may be up to 64 KB in size. + // If you are using an integer value for the key value, you should convert the integer to a fixed-width string, + // because they are canonically sorted. For example, you should convert the value 1 to 0000001 to ensure proper sorting. + RowKey string + PartitionKey string +} + +type DeleteEntityResponse struct { + HttpResponse *http.Response +} + +// Delete deletes an existing entity in a table. +func (c Client) Delete(ctx context.Context, tableName string, input DeleteEntityInput) (result DeleteEntityResponse, err error) { + + if tableName == "" { + return result, fmt.Errorf("`tableName` cannot be an empty string") + } + + if input.PartitionKey == "" { + return result, fmt.Errorf("`input.PartitionKey` cannot be an empty string") + } + + if input.RowKey == "" { + return result, fmt.Errorf("`input.RowKey` cannot be an empty string") + } + + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + OptionsObject: deleteEntitiesOptions{}, + Path: fmt.Sprintf("/%s(PartitionKey='%s', RowKey='%s')", tableName, input.PartitionKey, input.RowKey), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + return +} + +type deleteEntitiesOptions struct{} + +func (d deleteEntitiesOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("Accept", "application/json") + headers.Append("If-Match", "*") + return headers +} + +func (d deleteEntitiesOptions) ToOData() *odata.Query { + return nil +} + +func (d deleteEntitiesOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/get.go new file mode 100644 index 0000000000000..daf428acdffa2 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/get.go @@ -0,0 +1,94 @@ +package entities + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type GetEntityInput struct { + PartitionKey string + RowKey string + + // The Level of MetaData which should be returned + MetaDataLevel MetaDataLevel +} + +type GetEntityResponse struct { + HttpResponse *http.Response + + Entity map[string]interface{} +} + +// Get queries entities in a table and includes the $filter and $select options. +func (c Client) Get(ctx context.Context, tableName string, input GetEntityInput) (result GetEntityResponse, err error) { + if tableName == "" { + return result, fmt.Errorf("`tableName` cannot be an empty string") + } + + if input.PartitionKey == "" { + return result, fmt.Errorf("`input.PartitionKey` cannot be an empty string") + } + + if input.RowKey == "" { + return result, fmt.Errorf("`input.RowKey` cannot be an empty string") + } + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: getEntitiesOptions{ + MetaDataLevel: input.MetaDataLevel, + }, + Path: fmt.Sprintf("/%s(PartitionKey='%s', RowKey='%s')", tableName, input.PartitionKey, input.RowKey), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result.Entity) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type getEntitiesOptions struct { + MetaDataLevel MetaDataLevel +} + +func (g getEntitiesOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("Accept", fmt.Sprintf("application/json;odata=%s", g.MetaDataLevel)) + headers.Append("DataServiceVersion", "3.0;NetFx") + headers.Append("MaxDataServiceVersion", "3.0;NetFx") + return headers +} + +func (g getEntitiesOptions) ToOData() *odata.Query { + return nil +} + +func (g getEntitiesOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert.go new file mode 100644 index 0000000000000..1996ba8b9cef2 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert.go @@ -0,0 +1,104 @@ +package entities + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type InsertEntityInput struct { + // The level of MetaData provided for this Entity + MetaDataLevel MetaDataLevel + + // The Entity which should be inserted, by default all values are strings + // To explicitly type a property, specify the appropriate OData data type by setting + // the m:type attribute within the property definition + Entity map[string]interface{} + + // When inserting an entity into a table, you must specify values for the PartitionKey and RowKey system properties. + // Together, these properties form the primary key and must be unique within the table. + // Both the PartitionKey and RowKey values must be string values; each key value may be up to 64 KB in size. + // If you are using an integer value for the key value, you should convert the integer to a fixed-width string, + // because they are canonically sorted. For example, you should convert the value 1 to 0000001 to ensure proper sorting. + RowKey string + PartitionKey string +} + +type InsertResponse struct { + HttpResponse *http.Response +} + +// Insert inserts a new entity into a table. +func (c Client) Insert(ctx context.Context, tableName string, input InsertEntityInput) (result InsertResponse, err error) { + if tableName == "" { + return result, fmt.Errorf("`tableName` cannot be an empty string") + } + + if input.PartitionKey == "" { + return result, fmt.Errorf("`input.PartitionKey` cannot be an empty string") + } + + if input.RowKey == "" { + return result, fmt.Errorf("`input.RowKey` cannot be an empty string") + } + + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + OptionsObject: insertOptions{ + MetaDataLevel: input.MetaDataLevel, + }, + Path: fmt.Sprintf("/%s", tableName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + input.Entity["PartitionKey"] = input.PartitionKey + input.Entity["RowKey"] = input.RowKey + + err = req.Marshal(&input.Entity) + if err != nil { + return result, fmt.Errorf("marshalling request: %+v", err) + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type insertOptions struct { + MetaDataLevel MetaDataLevel +} + +func (i insertOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("Accept", fmt.Sprintf("application/json;odata=%s", i.MetaDataLevel)) + headers.Append("Prefer", "return-no-content") + return headers +} + +func (i insertOptions) ToOData() *odata.Query { + return nil +} + +func (i insertOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert_or_merge.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert_or_merge.go new file mode 100644 index 0000000000000..8ec8191f6ea53 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert_or_merge.go @@ -0,0 +1,98 @@ +package entities + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type InsertOrMergeEntityInput struct { + // The Entity which should be inserted, by default all values are strings + // To explicitly type a property, specify the appropriate OData data type by setting + // the m:type attribute within the property definition + Entity map[string]interface{} + + // When inserting an entity into a table, you must specify values for the PartitionKey and RowKey system properties. + // Together, these properties form the primary key and must be unique within the table. + // Both the PartitionKey and RowKey values must be string values; each key value may be up to 64 KB in size. + // If you are using an integer value for the key value, you should convert the integer to a fixed-width string, + // because they are canonically sorted. For example, you should convert the value 1 to 0000001 to ensure proper sorting. + RowKey string + PartitionKey string +} + +type InsertOrMergeResponse struct { + HttpResponse *http.Response +} + +// InsertOrMerge updates an existing entity or inserts a new entity if it does not exist in the table. +// Because this operation can insert or update an entity, it is also known as an upsert operation. +func (c Client) InsertOrMerge(ctx context.Context, tableName string, input InsertOrMergeEntityInput) (result InsertOrMergeResponse, err error) { + if tableName == "" { + return result, fmt.Errorf("`tableName` cannot be an empty string") + } + + if input.PartitionKey == "" { + return result, fmt.Errorf("`input.PartitionKey` cannot be an empty string") + } + + if input.RowKey == "" { + return result, fmt.Errorf("`input.RowKey` cannot be an empty string") + } + + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: "MERGE", + OptionsObject: insertOrMergeOptions{}, + Path: fmt.Sprintf("/%s(PartitionKey='%s', RowKey='%s')", tableName, input.PartitionKey, input.RowKey), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + input.Entity["PartitionKey"] = input.PartitionKey + input.Entity["RowKey"] = input.RowKey + + err = req.Marshal(&input.Entity) + if err != nil { + return result, fmt.Errorf("marshalling request: %+v", err) + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type insertOrMergeOptions struct{} + +func (i insertOrMergeOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("Accept", "application/json") + headers.Append("Prefer", "return-no-content") + return headers +} + +func (i insertOrMergeOptions) ToOData() *odata.Query { + return nil +} + +func (i insertOrMergeOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert_or_replace.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert_or_replace.go new file mode 100644 index 0000000000000..269437c06caec --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/insert_or_replace.go @@ -0,0 +1,98 @@ +package entities + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type InsertOrReplaceEntityInput struct { + // The Entity which should be inserted, by default all values are strings + // To explicitly type a property, specify the appropriate OData data type by setting + // the m:type attribute within the property definition + Entity map[string]interface{} + + // When inserting an entity into a table, you must specify values for the PartitionKey and RowKey system properties. + // Together, these properties form the primary key and must be unique within the table. + // Both the PartitionKey and RowKey values must be string values; each key value may be up to 64 KB in size. + // If you are using an integer value for the key value, you should convert the integer to a fixed-width string, + // because they are canonically sorted. For example, you should convert the value 1 to 0000001 to ensure proper sorting. + RowKey string + PartitionKey string +} + +type InsertOrReplaceResponse struct { + HttpResponse *http.Response +} + +// InsertOrReplace replaces an existing entity or inserts a new entity if it does not exist in the table. +// Because this operation can insert or update an entity, it is also known as an upsert operation. +func (c Client) InsertOrReplace(ctx context.Context, tableName string, input InsertOrReplaceEntityInput) (result InsertOrReplaceResponse, err error) { + if tableName == "" { + return result, fmt.Errorf("`tableName` cannot be an empty string") + } + + if input.PartitionKey == "" { + return result, fmt.Errorf("`input.PartitionKey` cannot be an empty string") + } + + if input.RowKey == "" { + return result, fmt.Errorf("`input.RowKey` cannot be an empty string") + } + + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: "MERGE", + OptionsObject: insertOrReplaceOptions{}, + Path: fmt.Sprintf("/%s(PartitionKey='%s', RowKey='%s')", tableName, input.PartitionKey, input.RowKey), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + input.Entity["PartitionKey"] = input.PartitionKey + input.Entity["RowKey"] = input.RowKey + + err = req.Marshal(&input.Entity) + if err != nil { + return result, fmt.Errorf("marshalling request: %+v", err) + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type insertOrReplaceOptions struct{} + +func (i insertOrReplaceOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("Accept", "application/json") + headers.Append("Prefer", "return-no-content") + return headers +} + +func (i insertOrReplaceOptions) ToOData() *odata.Query { + return nil +} + +func (i insertOrReplaceOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/models.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/models.go similarity index 100% rename from vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities/models.go rename to vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/models.go diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/query.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/query.go new file mode 100644 index 0000000000000..57b411a55bf6d --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/query.go @@ -0,0 +1,143 @@ +package entities + +import ( + "context" + "fmt" + "net/http" + "strconv" + "strings" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type QueryEntitiesInput struct { + // An optional OData filter + Filter *string + + // An optional comma-separated + PropertyNamesToSelect *[]string + + // An optional OData top + Top *int + + PartitionKey string + RowKey string + + // The Level of MetaData which should be returned + MetaDataLevel MetaDataLevel + + // The Next Partition Key used to load data from a previous point + NextPartitionKey *string + + // The Next Row Key used to load data from a previous point + NextRowKey *string +} + +type QueryEntitiesResponse struct { + HttpResponse *http.Response + + NextPartitionKey string + NextRowKey string + + MetaData string `json:"odata.metadata,omitempty"` + Entities []map[string]interface{} `json:"value"` +} + +// Query queries entities in a table and includes the $filter and $select options. +func (c Client) Query(ctx context.Context, tableName string, input QueryEntitiesInput) (result QueryEntitiesResponse, err error) { + if tableName == "" { + return result, fmt.Errorf("`tableName` cannot be an empty string") + } + + additionalParameters := make([]string, 0) + if input.PartitionKey != "" { + additionalParameters = append(additionalParameters, "PartitionKey='%s'", input.PartitionKey) + } + + if input.RowKey != "" { + additionalParameters = append(additionalParameters, "RowKey='%s'", input.RowKey) + } + + path := fmt.Sprintf("/%s", tableName) + if len(additionalParameters) > 0 { + path += fmt.Sprintf("(%s)", strings.Join(additionalParameters, ",")) + } + + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: queryOptions{ + input: input, + }, + Path: path, + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type queryOptions struct { + input QueryEntitiesInput +} + +func (q queryOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("Accept", fmt.Sprintf("application/json;odata=%s", q.input.MetaDataLevel)) + headers.Append("DataServiceVersion", "3.0;NetFx") + headers.Append("MaxDataServiceVersion", "3.0;NetFx") + return headers +} + +func (q queryOptions) ToOData() *odata.Query { + return nil +} + +func (q queryOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + + if q.input.Filter != nil { + out.Append("$filter", *q.input.Filter) + } + + if q.input.PropertyNamesToSelect != nil { + out.Append("$select", strings.Join(*q.input.PropertyNamesToSelect, ",")) + } + + if q.input.Top != nil { + out.Append("$top", strconv.Itoa(*q.input.Top)) + } + + if q.input.NextPartitionKey != nil { + out.Append("NextPartitionKey", *q.input.NextPartitionKey) + } + + if q.input.NextRowKey != nil { + out.Append("NextRowKey", *q.input.NextRowKey) + } + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/resource_id.go new file mode 100644 index 0000000000000..0403b5e640bc1 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/resource_id.go @@ -0,0 +1,122 @@ +package entities + +import ( + "fmt" + "net/url" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts" +) + +// TODO: update this to implement `resourceids.ResourceId` once +// https://github.com/hashicorp/go-azure-helpers/issues/187 is fixed +var _ resourceids.Id = EntityId{} + +type EntityId struct { + // AccountId specifies the ID of the Storage Account where this Entity exists. + AccountId accounts.AccountId + + // TableName specifies the name of the Table where this Entity exists. + TableName string + + // PartitionKey specifies the Partition Key for this Entity. + PartitionKey string + + // RowKey specifies the Row Key for this Entity. + RowKey string +} + +func NewEntityID(accountId accounts.AccountId, tableName, partitionKey, rowKey string) EntityId { + return EntityId{ + AccountId: accountId, + TableName: tableName, + PartitionKey: partitionKey, + RowKey: rowKey, + } +} + +func (b EntityId) ID() string { + return fmt.Sprintf("%s/%s(PartitionKey='%s',RowKey='%s')", b.AccountId.ID(), b.TableName, b.PartitionKey, b.RowKey) +} + +func (b EntityId) String() string { + components := []string{ + fmt.Sprintf("Partition Key %q", b.PartitionKey), + fmt.Sprintf("Row Key %q", b.RowKey), + fmt.Sprintf("Table Name %q", b.TableName), + fmt.Sprintf("Account %q", b.AccountId.String()), + } + return fmt.Sprintf("Entity (%s)", strings.Join(components, " / ")) +} + +// ParseEntityID parses `input` into a Entity ID using a known `domainSuffix` +func ParseEntityID(input, domainSuffix string) (*EntityId, error) { + // example: https://foo.table.core.windows.net/Bar1(PartitionKey='partition1',RowKey='row1') + if input == "" { + return nil, fmt.Errorf("`input` was empty") + } + + account, err := accounts.ParseAccountID(input, domainSuffix) + if err != nil { + return nil, fmt.Errorf("parsing account %q: %+v", input, err) + } + + if account.SubDomainType != accounts.TableSubDomainType { + return nil, fmt.Errorf("expected the subdomain type to be %q but got %q", string(accounts.TableSubDomainType), string(account.SubDomainType)) + } + + uri, err := url.Parse(input) + if err != nil { + return nil, fmt.Errorf("parsing %q as a uri: %+v", input, err) + } + + path := strings.TrimPrefix(uri.Path, "/") + segments := strings.Split(path, "/") + if len(segments) != 1 { + return nil, fmt.Errorf("expected the path to contain 1 segment but got %d", len(segments)) + } + + // Tables and Table Entities are similar with table being `table1` and entities + // being `table1(PartitionKey='samplepartition',RowKey='samplerow')` so we need to validate this is a table + key := strings.TrimPrefix(uri.Path, "/") + if !strings.Contains(key, "(") || !strings.HasSuffix(key, ")") { + return nil, fmt.Errorf("expected the path to be an entity name but got a table name %q", key) + } + + indexOfFirstBracket := strings.Index(key, "(") + tableName := key[0:indexOfFirstBracket] + componentString := key[indexOfFirstBracket:] + componentString = strings.TrimPrefix(componentString, "(") + componentString = strings.TrimSuffix(componentString, ")") + components := strings.Split(componentString, ",") + if len(components) != 2 { + return nil, fmt.Errorf("expected the path to be an entity name but got %q", key) + } + + partitionKey := parseValueFromKey(components[0], "PartitionKey") + rowKey := parseValueFromKey(components[1], "RowKey") + return &EntityId{ + AccountId: *account, + TableName: tableName, + PartitionKey: *partitionKey, + RowKey: *rowKey, + }, nil +} + +func parseValueFromKey(input, expectedKey string) *string { + components := strings.Split(input, "=") + if len(components) != 2 { + return nil + } + key := components[0] + value := components[1] + if key != expectedKey { + return nil + } + + // the value is surrounded in single quotes, remove those + value = strings.TrimPrefix(value, "'") + value = strings.TrimSuffix(value, "'") + return &value +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/version.go new file mode 100644 index 0000000000000..5eae649209e31 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities/version.go @@ -0,0 +1,4 @@ +package entities + +const apiVersion = "2023-11-03" +const componentName = "table/entities" diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/README.md b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/README.md new file mode 100644 index 0000000000000..65a459f79dcd5 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/README.md @@ -0,0 +1,45 @@ +## Table Storage Tables SDK for API version 2023-11-03 + +This package allows you to interact with the Tables Table Storage API + +### Supported Authorizers + +* SharedKeyLite (Table) + +### Example Usage + +```go +package main + +import ( + "context" + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/auth" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables" +) + +func Example() error { + accountName := "storageaccount1" + storageAccountKey := "ABC123...." + tableName := "mytable" + domainSuffix := "core.windows.net" + + auth, err := auth.NewSharedKeyAuthorizer(accountName, storageAccountKey, auth.SharedKeyTable) + if err != nil { + return fmt.Errorf("building SharedKey authorizer: %+v", err) + } + tablesClient, err := tables.NewWithBaseUri(fmt.Sprintf("https://%s.table.%s", accountName, domainSuffix)) + if err != nil { + return fmt.Errorf("building client for environment: %+v", err) + } + tablesClient.Client.SetAuthorizer(auth) + + ctx := context.TODO() + if _, err := tablesClient.Create(ctx, tableName); err != nil { + return fmt.Errorf("Error creating Table: %s", err) + } + + return nil +} +``` \ No newline at end of file diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/acl_get.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/acl_get.go new file mode 100644 index 0000000000000..3f2f2a18692f6 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/acl_get.go @@ -0,0 +1,75 @@ +package tables + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type GetACLResponse struct { + HttpResponse *http.Response + + SignedIdentifiers []SignedIdentifier `xml:"SignedIdentifier"` +} + +// GetACL returns the Access Control List for the specified Table +func (c Client) GetACL(ctx context.Context, tableName string) (result GetACLResponse, err error) { + + if tableName == "" { + err = fmt.Errorf("`tableName` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: getAclTableOptions{}, + Path: fmt.Sprintf("/%s", tableName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type getAclTableOptions struct{} + +func (g getAclTableOptions) ToHeaders() *client.Headers { + return nil +} + +func (g getAclTableOptions) ToOData() *odata.Query { + return nil +} + +func (g getAclTableOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "acl") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/acl_set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/acl_set.go new file mode 100644 index 0000000000000..9749bd062c5fa --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/acl_set.go @@ -0,0 +1,79 @@ +package tables + +import ( + "context" + "encoding/xml" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type setAcl struct { + SignedIdentifiers []SignedIdentifier `xml:"SignedIdentifier"` + + XMLName xml.Name `xml:"SignedIdentifiers"` +} + +type SetACLResponse struct { + HttpResponse *http.Response +} + +// SetACL sets the specified Access Control List for the specified Table +func (c Client) SetACL(ctx context.Context, tableName string, acls []SignedIdentifier) (result SetACLResponse, err error) { + if tableName == "" { + err = fmt.Errorf("`tableName` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/xml; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPut, + OptionsObject: setAclTableOptions{}, + Path: fmt.Sprintf("/%s", tableName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + err = req.Marshal(setAcl{SignedIdentifiers: acls}) + if err != nil { + err = fmt.Errorf("marshalling request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type setAclTableOptions struct{} + +func (s setAclTableOptions) ToHeaders() *client.Headers { + return nil +} + +func (s setAclTableOptions) ToOData() *odata.Query { + return nil +} + +func (s setAclTableOptions) ToQuery() *client.QueryParams { + out := &client.QueryParams{} + out.Append("comp", "acl") + return out +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/api.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/api.go new file mode 100644 index 0000000000000..75c1de6214102 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/api.go @@ -0,0 +1,15 @@ +package tables + +import ( + "context" +) + +type StorageTable interface { + Delete(ctx context.Context, tableName string) (resp DeleteTableResponse, err error) + Exists(ctx context.Context, tableName string) (resp TableExistsResponse, err error) + GetACL(ctx context.Context, tableName string) (resp GetACLResponse, err error) + Create(ctx context.Context, tableName string) (resp CreateTableResponse, err error) + GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, tableName string) string + Query(ctx context.Context, input QueryInput) (resp GetResponse, err error) + SetACL(ctx context.Context, tableName string, acls []SignedIdentifier) (resp SetACLResponse, err error) +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/client.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/client.go new file mode 100644 index 0000000000000..49c714dcdd821 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/client.go @@ -0,0 +1,23 @@ +package tables + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/storage" +) + +// Client is the base client for Table Storage Shares. +type Client struct { + Client *storage.Client +} + +func NewWithBaseUri(baseUri string) (*Client, error) { + baseClient, err := storage.NewStorageClient(baseUri, componentName, apiVersion) + if err != nil { + return nil, fmt.Errorf("building base client: %+v", err) + } + + return &Client{ + Client: baseClient, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/create.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/create.go new file mode 100644 index 0000000000000..6adfd5ab5e365 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/create.go @@ -0,0 +1,76 @@ +package tables + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type createTableRequest struct { + TableName string `json:"TableName"` +} + +type CreateTableResponse struct { + HttpResponse *http.Response +} + +// Create creates a new table in the storage account. +func (c Client) Create(ctx context.Context, tableName string) (result CreateTableResponse, err error) { + if tableName == "" { + err = fmt.Errorf("`tableName` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodPost, + OptionsObject: createTableOptions{}, + Path: "/Tables", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + err = req.Marshal(&createTableRequest{TableName: tableName}) + if err != nil { + return result, fmt.Errorf("marshalling request") + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type createTableOptions struct{} + +func (c createTableOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("Accept", "application/json;odata=nometadata") + headers.Append("Prefer", "return-no-content") + return headers +} + +func (c createTableOptions) ToOData() *odata.Query { + return nil +} + +func (c createTableOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/delete.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/delete.go new file mode 100644 index 0000000000000..b1fab65b30c0d --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/delete.go @@ -0,0 +1,67 @@ +package tables + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type DeleteTableResponse struct { + HttpResponse *http.Response +} + +// Delete deletes the specified table and any data it contains. +func (c Client) Delete(ctx context.Context, tableName string) (result DeleteTableResponse, err error) { + if tableName == "" { + err = fmt.Errorf("`tableName` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusNoContent, + }, + HttpMethod: http.MethodDelete, + OptionsObject: deleteOptions{}, + Path: fmt.Sprintf("/Tables('%s')", tableName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type deleteOptions struct { +} + +func (d deleteOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("Accept", "application/json") + return headers +} + +func (d deleteOptions) ToOData() *odata.Query { + return nil +} + +func (d deleteOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/exists.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/exists.go new file mode 100644 index 0000000000000..efd922e2a8cab --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/exists.go @@ -0,0 +1,72 @@ +package tables + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type TableExistsResponse struct { + HttpResponse *http.Response +} + +// Exists checks that the specified table exists +func (c Client) Exists(ctx context.Context, tableName string) (result TableExistsResponse, err error) { + if tableName == "" { + err = fmt.Errorf("`tableName` cannot be an empty string") + return + } + + opts := client.RequestOptions{ + ContentType: "application/json", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: tableExistsOptions{}, + Path: fmt.Sprintf("/Tables('%s')", tableName), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + err = req.Marshal(&createTableRequest{TableName: tableName}) + if err != nil { + err = fmt.Errorf("marshalling request") + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type tableExistsOptions struct{} + +func (t tableExistsOptions) ToHeaders() *client.Headers { + headers := &client.Headers{} + headers.Append("Accept", "application/json;odata=nometadata") + return headers +} + +func (t tableExistsOptions) ToOData() *odata.Query { + return nil +} + +func (t tableExistsOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/models.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/models.go similarity index 100% rename from vendor/github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables/models.go rename to vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/models.go diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/query.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/query.go new file mode 100644 index 0000000000000..4cc07ead352e8 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/query.go @@ -0,0 +1,81 @@ +package tables + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +type GetResponse struct { + HttpResponse *http.Response + + MetaData string `json:"odata.metadata,omitempty"` + Tables []GetResultItem `json:"value"` +} + +type QueryInput struct { + MetaDataLevel MetaDataLevel +} + +// Query returns a list of tables under the specified account. +func (c Client) Query(ctx context.Context, input QueryInput) (result GetResponse, err error) { + + opts := client.RequestOptions{ + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: queryOptions{ + metaDataLevel: input.MetaDataLevel, + }, + Path: "/Tables", + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + err = fmt.Errorf("building request: %+v", err) + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.HttpResponse = resp.Response + + err = resp.Unmarshal(&result) + if err != nil { + err = fmt.Errorf("unmarshalling response: %+v", err) + return + } + } + if err != nil { + err = fmt.Errorf("executing request: %+v", err) + return + } + + return +} + +type queryOptions struct { + metaDataLevel MetaDataLevel +} + +func (q queryOptions) ToHeaders() *client.Headers { + // NOTE: whilst this supports ContinuationTokens and 'Top' + // it appears that 'Skip' returns a '501 Not Implemented' + // as such, we intentionally don't support those right now + headers := &client.Headers{} + headers.Append("Accept", fmt.Sprintf("application/json;odata=%s", q.metaDataLevel)) + return headers +} + +func (q queryOptions) ToOData() *odata.Query { + return nil +} + +func (q queryOptions) ToQuery() *client.QueryParams { + return nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/resource_id.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/resource_id.go new file mode 100644 index 0000000000000..8c5072f0b316a --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/resource_id.go @@ -0,0 +1,86 @@ +package tables + +import ( + "fmt" + "net/url" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" + "github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts" +) + +// GetResourceManagerResourceID returns the Resource ID for the given Table +// This can be useful when, for example, you're using this as a unique identifier +func (c Client) GetResourceManagerResourceID(subscriptionID, resourceGroup, accountName, tableName string) string { + fmtStr := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.Storage/storageAccounts/%s/tableServices/default/tables/%s" + return fmt.Sprintf(fmtStr, subscriptionID, resourceGroup, accountName, tableName) +} + +// TODO: update this to implement `resourceids.ResourceId` once +// https://github.com/hashicorp/go-azure-helpers/issues/187 is fixed +var _ resourceids.Id = TableId{} + +type TableId struct { + // AccountId specifies the ID of the Storage Account where this Table exists. + AccountId accounts.AccountId + + // TableName specifies the name of this Table. + TableName string +} + +func NewTableID(accountId accounts.AccountId, tableName string) TableId { + return TableId{ + AccountId: accountId, + TableName: tableName, + } +} + +func (b TableId) ID() string { + return fmt.Sprintf("%s/%s", b.AccountId.ID(), b.TableName) +} + +func (b TableId) String() string { + components := []string{ + fmt.Sprintf("Account %q", b.AccountId.String()), + } + return fmt.Sprintf("Table %q (%s)", b.TableName, strings.Join(components, " / ")) +} + +// ParseTableID parses `input` into a Table ID using a known `domainSuffix` +func ParseTableID(input, domainSuffix string) (*TableId, error) { + // example: https://foo.table.core.windows.net/Bar + if input == "" { + return nil, fmt.Errorf("`input` was empty") + } + + account, err := accounts.ParseAccountID(input, domainSuffix) + if err != nil { + return nil, fmt.Errorf("parsing account %q: %+v", input, err) + } + + if account.SubDomainType != accounts.TableSubDomainType { + return nil, fmt.Errorf("expected the subdomain type to be %q but got %q", string(accounts.TableSubDomainType), string(account.SubDomainType)) + } + + uri, err := url.Parse(input) + if err != nil { + return nil, fmt.Errorf("parsing %q as a uri: %+v", input, err) + } + + path := strings.TrimPrefix(uri.Path, "/") + segments := strings.Split(path, "/") + if len(segments) != 1 { + return nil, fmt.Errorf("expected the path to contain 1 segment but got %d", len(segments)) + } + + // Tables and Table Entities are similar with table being `table1` and entities + // being `table1(PartitionKey='samplepartition',RowKey='samplerow')` so we need to validate this is a table + tableName := strings.TrimPrefix(uri.Path, "/") + if strings.Contains(tableName, "(") || strings.Contains(tableName, ")") { + return nil, fmt.Errorf("expected the path to a table name and not an entity name but got %q", tableName) + } + return &TableId{ + AccountId: *account, + TableName: tableName, + }, nil +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/version.go b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/version.go new file mode 100644 index 0000000000000..63c317fdfa2c7 --- /dev/null +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables/version.go @@ -0,0 +1,4 @@ +package tables + +const apiVersion = "2023-11-03" +const componentName = "table/tables" diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/internal/endpoints/endpoints.go b/vendor/github.com/tombuildsstuff/giovanni/storage/internal/endpoints/endpoints.go deleted file mode 100644 index 2c58e8f69b032..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/internal/endpoints/endpoints.go +++ /dev/null @@ -1,39 +0,0 @@ -package endpoints - -import ( - "fmt" - "strings" -) - -func GetAccountNameFromEndpoint(endpoint string) (*string, error) { - segments := strings.Split(endpoint, ".") - if len(segments) == 0 { - return nil, fmt.Errorf("The Endpoint contained no segments") - } - return &segments[0], nil -} - -// GetBlobEndpoint returns the endpoint for Blob API Operations on this storage account -func GetBlobEndpoint(baseUri string, accountName string) string { - return fmt.Sprintf("https://%s.blob.%s", accountName, baseUri) -} - -// GetDataLakeStoreEndpoint returns the endpoint for Data Lake Store API Operations on this storage account -func GetDataLakeStoreEndpoint(baseUri string, accountName string) string { - return fmt.Sprintf("https://%s.dfs.%s", accountName, baseUri) -} - -// GetFileEndpoint returns the endpoint for File Share API Operations on this storage account -func GetFileEndpoint(baseUri string, accountName string) string { - return fmt.Sprintf("https://%s.file.%s", accountName, baseUri) -} - -// GetQueueEndpoint returns the endpoint for Queue API Operations on this storage account -func GetQueueEndpoint(baseUri string, accountName string) string { - return fmt.Sprintf("https://%s.queue.%s", accountName, baseUri) -} - -// GetTableEndpoint returns the endpoint for Table API Operations on this storage account -func GetTableEndpoint(baseUri string, accountName string) string { - return fmt.Sprintf("https://%s.table.%s", accountName, baseUri) -} diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/internal/metadata/parse.go b/vendor/github.com/tombuildsstuff/giovanni/storage/internal/metadata/parse.go index 1880d409a7dbc..5f613ab7d15ba 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/internal/metadata/parse.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/internal/metadata/parse.go @@ -5,16 +5,19 @@ import ( "strings" ) -// ParseFromHeaders parses the meta data from the headers +// ParseFromHeaders parses the metadata from the headers func ParseFromHeaders(headers http.Header) map[string]string { metaData := make(map[string]string, 0) + prefix := "x-ms-meta-" for k, v := range headers { key := strings.ToLower(k) - prefix := "x-ms-meta-" if !strings.HasPrefix(key, prefix) { continue } + // TODO: update this to support case-insensitive headers when the base layer is changed to `hashicorp/go-azure-sdk` + // (e.g. trim off the first 10 characters, but this can't be done until the base layer is updated, since + // `Azure/go-autorest` canonicalizes the header keys) key = strings.TrimPrefix(key, prefix) metaData[key] = v[0] } diff --git a/vendor/github.com/tombuildsstuff/giovanni/storage/internal/metadata/set.go b/vendor/github.com/tombuildsstuff/giovanni/storage/internal/metadata/set.go index d88fbd766b639..6006159f78cf0 100644 --- a/vendor/github.com/tombuildsstuff/giovanni/storage/internal/metadata/set.go +++ b/vendor/github.com/tombuildsstuff/giovanni/storage/internal/metadata/set.go @@ -1,6 +1,10 @@ package metadata -import "fmt" +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/sdk/client" +) // SetIntoHeaders sets the provided MetaData into the headers func SetIntoHeaders(headers map[string]interface{}, metaData map[string]string) map[string]interface{} { @@ -11,3 +15,13 @@ func SetIntoHeaders(headers map[string]interface{}, metaData map[string]string) return headers } + +// SetMetaDataHeaders sets the provided MetaData into the headers +func SetMetaDataHeaders(metaData map[string]string) client.Headers { + headers := client.Headers{} + for k, v := range metaData { + key := fmt.Sprintf("x-ms-meta-%s", k) + headers.Append(key, v) + } + return headers +} diff --git a/vendor/github.com/tombuildsstuff/giovanni/version/version.go b/vendor/github.com/tombuildsstuff/giovanni/version/version.go deleted file mode 100644 index 45a0da69aa761..0000000000000 --- a/vendor/github.com/tombuildsstuff/giovanni/version/version.go +++ /dev/null @@ -1,3 +0,0 @@ -package version - -const Number = "v0.17.0" diff --git a/vendor/modules.txt b/vendor/modules.txt index 9990f6994ad0f..2df6c9d0e630a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -127,13 +127,13 @@ github.com/google/go-cmp/cmp/internal/diff github.com/google/go-cmp/cmp/internal/flags github.com/google/go-cmp/cmp/internal/function github.com/google/go-cmp/cmp/internal/value -# github.com/google/uuid v1.3.1 +# github.com/google/uuid v1.4.0 ## explicit github.com/google/uuid # github.com/hashicorp/errwrap v1.1.0 ## explicit github.com/hashicorp/errwrap -# github.com/hashicorp/go-azure-helpers v0.66.1 +# github.com/hashicorp/go-azure-helpers v0.66.2 ## explicit; go 1.21 github.com/hashicorp/go-azure-helpers/authentication github.com/hashicorp/go-azure-helpers/eventhub @@ -1037,12 +1037,14 @@ github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/resourceprovid github.com/hashicorp/go-azure-sdk/resource-manager/web/2023-01-01/webapps github.com/hashicorp/go-azure-sdk/resource-manager/webpubsub/2023-02-01 github.com/hashicorp/go-azure-sdk/resource-manager/webpubsub/2023-02-01/webpubsub -# github.com/hashicorp/go-azure-sdk/sdk v0.20240201.1064937 +# github.com/hashicorp/go-azure-sdk/sdk v0.20240219.1162257-0.20240220115734-eeb1a5d96f9a ## explicit; go 1.21 github.com/hashicorp/go-azure-sdk/sdk/auth github.com/hashicorp/go-azure-sdk/sdk/auth/autorest github.com/hashicorp/go-azure-sdk/sdk/claims github.com/hashicorp/go-azure-sdk/sdk/client +github.com/hashicorp/go-azure-sdk/sdk/client/dataplane +github.com/hashicorp/go-azure-sdk/sdk/client/dataplane/storage github.com/hashicorp/go-azure-sdk/sdk/client/msgraph github.com/hashicorp/go-azure-sdk/sdk/client/pollers github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager @@ -1234,23 +1236,21 @@ github.com/rickb777/plural # github.com/sergi/go-diff v1.2.0 ## explicit; go 1.12 github.com/sergi/go-diff/diffmatchpatch -# github.com/tombuildsstuff/giovanni v0.20.0 -## explicit; go 1.13 -github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/accounts -github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/blobs -github.com/tombuildsstuff/giovanni/storage/2020-08-04/blob/containers -github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/filesystems -github.com/tombuildsstuff/giovanni/storage/2020-08-04/datalakestore/paths -github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/directories -github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/files -github.com/tombuildsstuff/giovanni/storage/2020-08-04/file/shares -github.com/tombuildsstuff/giovanni/storage/2020-08-04/queue/queues -github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/entities -github.com/tombuildsstuff/giovanni/storage/2020-08-04/table/tables +# github.com/tombuildsstuff/giovanni v0.23.1-0.20240220123934-c9b0ac79492b +## explicit; go 1.21 +github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/accounts +github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/blobs +github.com/tombuildsstuff/giovanni/storage/2023-11-03/blob/containers +github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/filesystems +github.com/tombuildsstuff/giovanni/storage/2023-11-03/datalakestore/paths +github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/directories +github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/files +github.com/tombuildsstuff/giovanni/storage/2023-11-03/file/shares +github.com/tombuildsstuff/giovanni/storage/2023-11-03/queue/queues +github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/entities +github.com/tombuildsstuff/giovanni/storage/2023-11-03/table/tables github.com/tombuildsstuff/giovanni/storage/accesscontrol -github.com/tombuildsstuff/giovanni/storage/internal/endpoints github.com/tombuildsstuff/giovanni/storage/internal/metadata -github.com/tombuildsstuff/giovanni/version # github.com/tombuildsstuff/kermit v0.20240122.1123108 ## explicit; go 1.18 github.com/tombuildsstuff/kermit/sdk/appconfiguration/1.0/appconfiguration