From 61759974a883e4121e80600f51a3afbf886fdd9f Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 11 Apr 2022 02:34:36 +0000 Subject: [PATCH] CodeGen from PR 18534 in Azure/azure-rest-api-specs [Hub Generated] Review request for Microsoft.LoadTestService to add version preview/2022-04-15-preview (#18534) * Adds base for updating Microsoft.LoadTestService from version preview/2021-12-01-preview to version 2022-04-15-preview * Updates readme * Updates API version in new specs and examples * v2022-04-01-prev, commiting with existing version * update 2022-04-01-preview spec * update examples in 2022-04-01-preview * updated 2022-04-15-preview spec * updated examples for 2022-04-15-preview * updated markdown files * Deleted 2022-04-01-preview from the public spec * prettify json * updated examples to contain encryption properties --- .../armloadtestservice/CHANGELOG.md | 96 ++++++++ .../armloadtestservice/autorest.md | 6 +- .../loadtestservice/armloadtestservice/go.mod | 9 +- .../loadtestservice/armloadtestservice/go.sum | 43 +--- ...generated_example_loadtests_client_test.go | 160 ------------- ...enerated_example_operations_client_test.go | 40 ---- .../zz_generated_constants.go | 65 +++-- .../zz_generated_loadtests_client.go | 221 ++++++++++------- .../armloadtestservice/zz_generated_models.go | 226 ++++++------------ .../zz_generated_models_serde.go | 151 ++++++++++++ .../zz_generated_operations_client.go | 63 +++-- .../armloadtestservice/zz_generated_pagers.go | 179 -------------- .../zz_generated_pollers.go | 58 ----- .../zz_generated_response_types.go | 96 +------- .../zz_generated_time_rfc3339.go | 4 +- 15 files changed, 546 insertions(+), 871 deletions(-) delete mode 100644 sdk/resourcemanager/loadtestservice/armloadtestservice/ze_generated_example_loadtests_client_test.go delete mode 100644 sdk/resourcemanager/loadtestservice/armloadtestservice/ze_generated_example_operations_client_test.go create mode 100644 sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_models_serde.go delete mode 100644 sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_pagers.go delete mode 100644 sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_pollers.go diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/CHANGELOG.md b/sdk/resourcemanager/loadtestservice/armloadtestservice/CHANGELOG.md index 990471e4dc46..f12c3e59c654 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/CHANGELOG.md +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/CHANGELOG.md @@ -1,5 +1,101 @@ # Release History +## 0.3.0 (2022-04-11) +### Breaking Changes + +- Function `*LoadTestsClient.ListBySubscription` return value(s) have been changed from `(*LoadTestsClientListBySubscriptionPager)` to `(*runtime.Pager[LoadTestsClientListBySubscriptionResponse])` +- Function `NewOperationsClient` return value(s) have been changed from `(*OperationsClient)` to `(*OperationsClient, error)` +- Function `*LoadTestsClient.ListByResourceGroup` return value(s) have been changed from `(*LoadTestsClientListByResourceGroupPager)` to `(*runtime.Pager[LoadTestsClientListByResourceGroupResponse])` +- Function `*OperationsClient.List` return value(s) have been changed from `(*OperationsClientListPager)` to `(*runtime.Pager[OperationsClientListResponse])` +- Function `NewLoadTestsClient` return value(s) have been changed from `(*LoadTestsClient)` to `(*LoadTestsClient, error)` +- Function `*LoadTestsClient.BeginDelete` return value(s) have been changed from `(LoadTestsClientDeletePollerResponse, error)` to `(*armruntime.Poller[LoadTestsClientDeleteResponse], error)` +- Type of `LoadTestResourcePatchRequestBody.Identity` has been changed from `*SystemAssignedServiceIdentity` to `*ManagedServiceIdentity` +- Type of `LoadTestResourcePatchRequestBody.Tags` has been changed from `map[string]interface{}` to `interface{}` +- Type of `LoadTestResource.Identity` has been changed from `*SystemAssignedServiceIdentity` to `*ManagedServiceIdentity` +- Type of `ErrorAdditionalInfo.Info` has been changed from `map[string]interface{}` to `interface{}` +- Const `SystemAssignedServiceIdentityTypeSystemAssigned` has been removed +- Const `SystemAssignedServiceIdentityTypeNone` has been removed +- Function `*LoadTestsClient.Update` has been removed +- Function `*LoadTestsClientDeletePoller.Poll` has been removed +- Function `ActionType.ToPtr` has been removed +- Function `*LoadTestsClient.CreateOrUpdate` has been removed +- Function `*LoadTestsClientListBySubscriptionPager.Err` has been removed +- Function `*OperationsClientListPager.NextPage` has been removed +- Function `*LoadTestsClientListBySubscriptionPager.NextPage` has been removed +- Function `*OperationsClientListPager.Err` has been removed +- Function `CreatedByType.ToPtr` has been removed +- Function `*LoadTestsClientDeletePoller.FinalResponse` has been removed +- Function `*LoadTestsClientDeletePollerResponse.Resume` has been removed +- Function `*LoadTestsClientDeletePoller.Done` has been removed +- Function `*LoadTestsClientListBySubscriptionPager.PageResponse` has been removed +- Function `*OperationsClientListPager.PageResponse` has been removed +- Function `*LoadTestsClientListByResourceGroupPager.NextPage` has been removed +- Function `ResourceState.ToPtr` has been removed +- Function `PossibleSystemAssignedServiceIdentityTypeValues` has been removed +- Function `Origin.ToPtr` has been removed +- Function `LoadTestsClientDeletePollerResponse.PollUntilDone` has been removed +- Function `*LoadTestsClientListByResourceGroupPager.PageResponse` has been removed +- Function `*LoadTestsClientListByResourceGroupPager.Err` has been removed +- Function `SystemAssignedServiceIdentityType.ToPtr` has been removed +- Function `*LoadTestsClientDeletePoller.ResumeToken` has been removed +- Struct `LoadTestsClientCreateOrUpdateOptions` has been removed +- Struct `LoadTestsClientCreateOrUpdateResult` has been removed +- Struct `LoadTestsClientDeletePoller` has been removed +- Struct `LoadTestsClientDeletePollerResponse` has been removed +- Struct `LoadTestsClientGetResult` has been removed +- Struct `LoadTestsClientListByResourceGroupPager` has been removed +- Struct `LoadTestsClientListByResourceGroupResult` has been removed +- Struct `LoadTestsClientListBySubscriptionPager` has been removed +- Struct `LoadTestsClientListBySubscriptionResult` has been removed +- Struct `LoadTestsClientUpdateOptions` has been removed +- Struct `LoadTestsClientUpdateResult` has been removed +- Struct `OperationsClientListPager` has been removed +- Struct `OperationsClientListResult` has been removed +- Struct `SystemAssignedServiceIdentity` has been removed +- Field `LoadTestsClientUpdateResult` of struct `LoadTestsClientUpdateResponse` has been removed +- Field `RawResponse` of struct `LoadTestsClientUpdateResponse` has been removed +- Field `LoadTestsClientListByResourceGroupResult` of struct `LoadTestsClientListByResourceGroupResponse` has been removed +- Field `RawResponse` of struct `LoadTestsClientListByResourceGroupResponse` has been removed +- Field `LoadTestsClientGetResult` of struct `LoadTestsClientGetResponse` has been removed +- Field `RawResponse` of struct `LoadTestsClientGetResponse` has been removed +- Field `OperationsClientListResult` of struct `OperationsClientListResponse` has been removed +- Field `RawResponse` of struct `OperationsClientListResponse` has been removed +- Field `LoadTestsClientCreateOrUpdateResult` of struct `LoadTestsClientCreateOrUpdateResponse` has been removed +- Field `RawResponse` of struct `LoadTestsClientCreateOrUpdateResponse` has been removed +- Field `LoadTestsClientListBySubscriptionResult` of struct `LoadTestsClientListBySubscriptionResponse` has been removed +- Field `RawResponse` of struct `LoadTestsClientListBySubscriptionResponse` has been removed +- Field `RawResponse` of struct `LoadTestsClientDeleteResponse` has been removed + +### Features Added + +- New const `ManagedServiceIdentityTypeSystemAssigned` +- New const `TypeSystemAssigned` +- New const `TypeUserAssigned` +- New const `ManagedServiceIdentityTypeUserAssigned` +- New const `ManagedServiceIdentityTypeNone` +- New const `ManagedServiceIdentityTypeSystemAssignedUserAssigned` +- New function `*LoadTestsClient.BeginCreateOrUpdate(context.Context, string, string, LoadTestResource, *LoadTestsClientBeginCreateOrUpdateOptions) (*armruntime.Poller[LoadTestsClientCreateOrUpdateResponse], error)` +- New function `ManagedServiceIdentity.MarshalJSON() ([]byte, error)` +- New function `PossibleTypeValues() []Type` +- New function `PossibleManagedServiceIdentityTypeValues() []ManagedServiceIdentityType` +- New function `*LoadTestsClient.BeginUpdate(context.Context, string, string, LoadTestResourcePatchRequestBody, *LoadTestsClientBeginUpdateOptions) (*armruntime.Poller[LoadTestsClientUpdateResponse], error)` +- New struct `EncryptionProperties` +- New struct `EncryptionPropertiesIdentity` +- New struct `LoadTestsClientBeginCreateOrUpdateOptions` +- New struct `LoadTestsClientBeginUpdateOptions` +- New struct `ManagedServiceIdentity` +- New struct `UserAssignedIdentity` +- New field `Encryption` in struct `LoadTestProperties` +- New anonymous field `OperationListResult` in struct `OperationsClientListResponse` +- New anonymous field `LoadTestResource` in struct `LoadTestsClientUpdateResponse` +- New anonymous field `LoadTestResourcePageList` in struct `LoadTestsClientListByResourceGroupResponse` +- New anonymous field `LoadTestResource` in struct `LoadTestsClientCreateOrUpdateResponse` +- New anonymous field `LoadTestResourcePageList` in struct `LoadTestsClientListBySubscriptionResponse` +- New field `Encryption` in struct `LoadTestResourcePatchRequestBodyProperties` +- New anonymous field `LoadTestResource` in struct `LoadTestsClientGetResponse` +- New field `ResumeToken` in struct `LoadTestsClientBeginDeleteOptions` + + ## 0.2.1 (2022-02-22) ### Other Changes diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/autorest.md b/sdk/resourcemanager/loadtestservice/armloadtestservice/autorest.md index e2d6156bcbfa..c8d1f518d6a9 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/autorest.md +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/autorest.md @@ -5,9 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/8e4746332979ed6ff3577bdc97dd2065a7577598/specification/loadtestservice/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/8e4746332979ed6ff3577bdc97dd2065a7577598/specification/loadtestservice/resource-manager/readme.go.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/loadtestservice/resource-manager/readme.md +- /mnt/vss/_work/1/s/azure-rest-api-specs/specification/loadtestservice/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.2.1 +module-version: 0.3.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/go.mod b/sdk/resourcemanager/loadtestservice/armloadtestservice/go.mod index 93a9997c1a7b..99919da2cfef 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/go.mod +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/go.mod @@ -1,8 +1,11 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtestservice/armloadtestservice -go 1.16 +go 1.18 + +require github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.0 + github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1 // indirect + golang.org/x/net v0.0.0-20210610132358-84b48f89b13b // indirect + golang.org/x/text v0.3.6 // indirect ) diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/go.sum b/sdk/resourcemanager/loadtestservice/armloadtestservice/go.sum index 2ce51d3b8174..a7eaa30576c1 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/go.sum +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/go.sum @@ -1,26 +1,11 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0 h1:8wVJL0HUP5yDFXvotdewORTw7Yu88JbreWN/mobSvsQ= -github.com/Azure/azure-sdk-for-go/sdk/azcore v0.21.0/go.mod h1:fBF9PQNqB8scdgpZ3ufzaLntG0AG7C1WjPMsiFOmfHM= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.0 h1:bLRntPH25SkY1uZ/YZW+dmxNky9r1fAHvDFrzluo+4Q= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v0.13.0/go.mod h1:TmXReXZ9yPp5D5TBRMTAtyz+UyOl15Py4hL5E5p6igQ= -github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3 h1:E+m3SkZCN0Bf5q7YdTs5lSm2CYY3CK4spn5OmUIiQtk= -github.com/Azure/azure-sdk-for-go/sdk/internal v0.8.3/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0 h1:WVsrXCnHlDDX8ls+tootqRE87/hL9S/g4ewig9RsD/c= -github.com/AzureAD/microsoft-authentication-library-for-go v0.4.0/go.mod h1:Vt9sXTKwMyGcOxSmLDMnGPgqsUg7m8pe215qMLrDXw4= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0 h1:D7l5jspkc4kwBYRWoZE4DQnu6LVpLwDsMZjBKS4wZLQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v0.23.0/go.mod h1:w5pDIZuawUmY3Bj4tVx3Xb8KS96ToB0j315w9rqpAg0= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1 h1:sLZ/Y+P/5RRtsXWylBjB5lkgixYfm0MQPiwrSX//JSo= +github.com/Azure/azure-sdk-for-go/sdk/internal v0.9.1/go.mod h1:KLF4gFr6DcKFZwSuH8w8yEK6DpFl3LP5rhdvAb7Yz5I= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= -github.com/golang-jwt/jwt v3.2.1+incompatible h1:73Z+4BJcrTC+KczS6WvTPvRGOp1WmfEP4Q1lOd9Z/+c= -github.com/golang-jwt/jwt v3.2.1+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= -github.com/montanaflynn/stats v0.6.6/go.mod h1:etXPPgVO6n31NxCd9KQUMvCM+ve0ruNzt6R8Bnaayow= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -28,32 +13,20 @@ github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5Cc github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897 h1:pLI5jrR7OSLijeIDcmRxNmw2api+jEfxLoykJVice/E= -golang.org/x/crypto v0.0.0-20201016220609-9e8e0b390897/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210610132358-84b48f89b13b h1:k+E048sYJHyVnsr1GDrRZWQ32D2C7lWs9JRc0bel53A= golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f h1:OfiFi4JbukWwe3lzw+xunroH1mnC1e2Gy5cxNJApiSY= -golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 h1:id054HUawV2/6IGm2IV8KZQjqtwAOo2CYlOToYqa0d0= -golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/ze_generated_example_loadtests_client_test.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/ze_generated_example_loadtests_client_test.go deleted file mode 100644 index c8bccaf24928..000000000000 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/ze_generated_example_loadtests_client_test.go +++ /dev/null @@ -1,160 +0,0 @@ -//go:build go1.16 -// +build go1.16 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armloadtestservice_test - -import ( - "context" - "log" - - "time" - - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtestservice/armloadtestservice" -) - -// x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_ListBySubscription.json -func ExampleLoadTestsClient_ListBySubscription() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armloadtestservice.NewLoadTestsClient("", cred, nil) - pager := client.ListBySubscription(nil) - for { - nextResult := pager.NextPage(ctx) - if err := pager.Err(); err != nil { - log.Fatalf("failed to advance page: %v", err) - } - if !nextResult { - break - } - for _, v := range pager.PageResponse().Value { - log.Printf("Pager result: %#v\n", v) - } - } -} - -// x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_ListByResourceGroup.json -func ExampleLoadTestsClient_ListByResourceGroup() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armloadtestservice.NewLoadTestsClient("", cred, nil) - pager := client.ListByResourceGroup("", - nil) - for { - nextResult := pager.NextPage(ctx) - if err := pager.Err(); err != nil { - log.Fatalf("failed to advance page: %v", err) - } - if !nextResult { - break - } - for _, v := range pager.PageResponse().Value { - log.Printf("Pager result: %#v\n", v) - } - } -} - -// x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_Get.json -func ExampleLoadTestsClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armloadtestservice.NewLoadTestsClient("", cred, nil) - res, err := client.Get(ctx, - "", - "", - nil) - if err != nil { - log.Fatal(err) - } - log.Printf("Response result: %#v\n", res.LoadTestsClientGetResult) -} - -// x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_CreateOrUpdate.json -func ExampleLoadTestsClient_CreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armloadtestservice.NewLoadTestsClient("", cred, nil) - res, err := client.CreateOrUpdate(ctx, - "", - "", - armloadtestservice.LoadTestResource{ - Location: to.StringPtr(""), - Tags: map[string]*string{ - "Team": to.StringPtr("Dev Exp"), - }, - Properties: &armloadtestservice.LoadTestProperties{ - Description: to.StringPtr(""), - }, - }, - nil) - if err != nil { - log.Fatal(err) - } - log.Printf("Response result: %#v\n", res.LoadTestsClientCreateOrUpdateResult) -} - -// x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_Update.json -func ExampleLoadTestsClient_Update() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armloadtestservice.NewLoadTestsClient("", cred, nil) - res, err := client.Update(ctx, - "", - "", - armloadtestservice.LoadTestResourcePatchRequestBody{ - Properties: &armloadtestservice.LoadTestResourcePatchRequestBodyProperties{ - Description: to.StringPtr(""), - }, - Tags: map[string]interface{}{ - "Division": "LT", - "Team": "Dev Exp", - }, - }, - nil) - if err != nil { - log.Fatal(err) - } - log.Printf("Response result: %#v\n", res.LoadTestsClientUpdateResult) -} - -// x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/LoadTests_Delete.json -func ExampleLoadTestsClient_BeginDelete() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armloadtestservice.NewLoadTestsClient("", cred, nil) - poller, err := client.BeginDelete(ctx, - "", - "", - nil) - if err != nil { - log.Fatal(err) - } - _, err = poller.PollUntilDone(ctx, 30*time.Second) - if err != nil { - log.Fatal(err) - } -} diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/ze_generated_example_operations_client_test.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/ze_generated_example_operations_client_test.go deleted file mode 100644 index 17055bc5ff9b..000000000000 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/ze_generated_example_operations_client_test.go +++ /dev/null @@ -1,40 +0,0 @@ -//go:build go1.16 -// +build go1.16 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armloadtestservice_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtestservice/armloadtestservice" -) - -// x-ms-original-file: specification/loadtestservice/resource-manager/Microsoft.LoadTestService/preview/2021-12-01-preview/examples/Operations_List.json -func ExampleOperationsClient_List() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - client := armloadtestservice.NewOperationsClient(cred, nil) - pager := client.List(nil) - for { - nextResult := pager.NextPage(ctx) - if err := pager.Err(); err != nil { - log.Fatalf("failed to advance page: %v", err) - } - if !nextResult { - break - } - for _, v := range pager.PageResponse().Value { - log.Printf("Pager result: %#v\n", v) - } - } -} diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_constants.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_constants.go index 65b483a8c623..a62a63638527 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_constants.go +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_constants.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//go:build go1.18 +// +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -10,7 +10,7 @@ package armloadtestservice const ( moduleName = "armloadtestservice" - moduleVersion = "v0.2.1" + moduleVersion = "v0.3.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. @@ -27,11 +27,6 @@ func PossibleActionTypeValues() []ActionType { } } -// ToPtr returns a *ActionType pointing to the current value. -func (c ActionType) ToPtr() *ActionType { - return &c -} - // CreatedByType - The type of identity that created the resource. type CreatedByType string @@ -52,9 +47,24 @@ func PossibleCreatedByTypeValues() []CreatedByType { } } -// ToPtr returns a *CreatedByType pointing to the current value. -func (c CreatedByType) ToPtr() *CreatedByType { - return &c +// ManagedServiceIdentityType - Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). +type ManagedServiceIdentityType string + +const ( + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" + ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned,UserAssigned" + ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" +) + +// PossibleManagedServiceIdentityTypeValues returns the possible values for the ManagedServiceIdentityType const type. +func PossibleManagedServiceIdentityTypeValues() []ManagedServiceIdentityType { + return []ManagedServiceIdentityType{ + ManagedServiceIdentityTypeNone, + ManagedServiceIdentityTypeSystemAssigned, + ManagedServiceIdentityTypeSystemAssignedUserAssigned, + ManagedServiceIdentityTypeUserAssigned, + } } // Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default @@ -76,11 +86,6 @@ func PossibleOriginValues() []Origin { } } -// ToPtr returns a *Origin pointing to the current value. -func (c Origin) ToPtr() *Origin { - return &c -} - // ResourceState - Load Test resources provisioning states. type ResourceState string @@ -101,28 +106,18 @@ func PossibleResourceStateValues() []ResourceState { } } -// ToPtr returns a *ResourceState pointing to the current value. -func (c ResourceState) ToPtr() *ResourceState { - return &c -} - -// SystemAssignedServiceIdentityType - Type of managed service identity (either system assigned, or none). -type SystemAssignedServiceIdentityType string +// Type - Managed identity type to use for accessing encryption key Url +type Type string const ( - SystemAssignedServiceIdentityTypeNone SystemAssignedServiceIdentityType = "None" - SystemAssignedServiceIdentityTypeSystemAssigned SystemAssignedServiceIdentityType = "SystemAssigned" + TypeSystemAssigned Type = "SystemAssigned" + TypeUserAssigned Type = "UserAssigned" ) -// PossibleSystemAssignedServiceIdentityTypeValues returns the possible values for the SystemAssignedServiceIdentityType const type. -func PossibleSystemAssignedServiceIdentityTypeValues() []SystemAssignedServiceIdentityType { - return []SystemAssignedServiceIdentityType{ - SystemAssignedServiceIdentityTypeNone, - SystemAssignedServiceIdentityTypeSystemAssigned, +// PossibleTypeValues returns the possible values for the Type const type. +func PossibleTypeValues() []Type { + return []Type{ + TypeSystemAssigned, + TypeUserAssigned, } } - -// ToPtr returns a *SystemAssignedServiceIdentityType pointing to the current value. -func (c SystemAssignedServiceIdentityType) ToPtr() *SystemAssignedServiceIdentityType { - return &c -} diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_loadtests_client.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_loadtests_client.go index 6687c6525425..2bbfe3d697d4 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_loadtests_client.go +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_loadtests_client.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//go:build go1.18 +// +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -14,6 +14,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -33,46 +34,66 @@ type LoadTestsClient struct { // subscriptionID - The ID of the target subscription. // credential - used to authorize requests. Usually a credential from azidentity. // options - pass nil to accept the default values. -func NewLoadTestsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) *LoadTestsClient { - cp := arm.ClientOptions{} - if options != nil { - cp = *options +func NewLoadTestsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LoadTestsClient, error) { + if options == nil { + options = &arm.ClientOptions{} } - if len(cp.Endpoint) == 0 { - cp.Endpoint = arm.AzurePublicCloud + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err } client := &LoadTestsClient{ subscriptionID: subscriptionID, - host: string(cp.Endpoint), - pl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, &cp), + host: ep, + pl: pl, } - return client + return client, nil } -// CreateOrUpdate - Create or update LoadTest resource. +// BeginCreateOrUpdate - Create or update LoadTest resource. // If the operation fails it returns an *azcore.ResponseError type. // resourceGroupName - The name of the resource group. The name is case insensitive. // loadTestName - Load Test name. // loadTestResource - LoadTest resource data -// options - LoadTestsClientCreateOrUpdateOptions contains the optional parameters for the LoadTestsClient.CreateOrUpdate +// options - LoadTestsClientBeginCreateOrUpdateOptions contains the optional parameters for the LoadTestsClient.BeginCreateOrUpdate // method. -func (client *LoadTestsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResource LoadTestResource, options *LoadTestsClientCreateOrUpdateOptions) (LoadTestsClientCreateOrUpdateResponse, error) { +func (client *LoadTestsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResource LoadTestResource, options *LoadTestsClientBeginCreateOrUpdateOptions) (*armruntime.Poller[LoadTestsClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, loadTestName, loadTestResource, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[LoadTestsClientCreateOrUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[LoadTestsClientCreateOrUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// CreateOrUpdate - Create or update LoadTest resource. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *LoadTestsClient) createOrUpdate(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResource LoadTestResource, options *LoadTestsClientBeginCreateOrUpdateOptions) (*http.Response, error) { req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, loadTestName, loadTestResource, options) if err != nil { - return LoadTestsClientCreateOrUpdateResponse{}, err + return nil, err } resp, err := client.pl.Do(req) if err != nil { - return LoadTestsClientCreateOrUpdateResponse{}, err + return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LoadTestsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { + return nil, runtime.NewResponseError(resp) } - return client.createOrUpdateHandleResponse(resp) + return resp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. -func (client *LoadTestsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResource LoadTestResource, options *LoadTestsClientCreateOrUpdateOptions) (*policy.Request, error) { +func (client *LoadTestsClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResource LoadTestResource, options *LoadTestsClientBeginCreateOrUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests/{loadTestName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -91,42 +112,29 @@ func (client *LoadTestsClient) createOrUpdateCreateRequest(ctx context.Context, return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-12-01-preview") + reqQP.Set("api-version", "2022-04-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, runtime.MarshalAsJSON(req, loadTestResource) } -// createOrUpdateHandleResponse handles the CreateOrUpdate response. -func (client *LoadTestsClient) createOrUpdateHandleResponse(resp *http.Response) (LoadTestsClientCreateOrUpdateResponse, error) { - result := LoadTestsClientCreateOrUpdateResponse{RawResponse: resp} - if err := runtime.UnmarshalAsJSON(resp, &result.LoadTestResource); err != nil { - return LoadTestsClientCreateOrUpdateResponse{}, err - } - return result, nil -} - // BeginDelete - Delete a LoadTest resource. // If the operation fails it returns an *azcore.ResponseError type. // resourceGroupName - The name of the resource group. The name is case insensitive. // loadTestName - Load Test name. // options - LoadTestsClientBeginDeleteOptions contains the optional parameters for the LoadTestsClient.BeginDelete method. -func (client *LoadTestsClient) BeginDelete(ctx context.Context, resourceGroupName string, loadTestName string, options *LoadTestsClientBeginDeleteOptions) (LoadTestsClientDeletePollerResponse, error) { - resp, err := client.deleteOperation(ctx, resourceGroupName, loadTestName, options) - if err != nil { - return LoadTestsClientDeletePollerResponse{}, err +func (client *LoadTestsClient) BeginDelete(ctx context.Context, resourceGroupName string, loadTestName string, options *LoadTestsClientBeginDeleteOptions) (*armruntime.Poller[LoadTestsClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, loadTestName, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[LoadTestsClientDeleteResponse]{ + FinalStateVia: armruntime.FinalStateViaLocation, + }) + } else { + return armruntime.NewPollerFromResumeToken[LoadTestsClientDeleteResponse](options.ResumeToken, client.pl, nil) } - result := LoadTestsClientDeletePollerResponse{ - RawResponse: resp, - } - pt, err := armruntime.NewPoller("LoadTestsClient.Delete", "", resp, client.pl) - if err != nil { - return LoadTestsClientDeletePollerResponse{}, err - } - result.Poller = &LoadTestsClientDeletePoller{ - pt: pt, - } - return result, nil } // Delete - Delete a LoadTest resource. @@ -166,7 +174,7 @@ func (client *LoadTestsClient) deleteCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-12-01-preview") + reqQP.Set("api-version", "2022-04-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, nil @@ -212,7 +220,7 @@ func (client *LoadTestsClient) getCreateRequest(ctx context.Context, resourceGro return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-12-01-preview") + reqQP.Set("api-version", "2022-04-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, nil @@ -220,7 +228,7 @@ func (client *LoadTestsClient) getCreateRequest(ctx context.Context, resourceGro // getHandleResponse handles the Get response. func (client *LoadTestsClient) getHandleResponse(resp *http.Response) (LoadTestsClientGetResponse, error) { - result := LoadTestsClientGetResponse{RawResponse: resp} + result := LoadTestsClientGetResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.LoadTestResource); err != nil { return LoadTestsClientGetResponse{}, err } @@ -232,16 +240,32 @@ func (client *LoadTestsClient) getHandleResponse(resp *http.Response) (LoadTests // resourceGroupName - The name of the resource group. The name is case insensitive. // options - LoadTestsClientListByResourceGroupOptions contains the optional parameters for the LoadTestsClient.ListByResourceGroup // method. -func (client *LoadTestsClient) ListByResourceGroup(resourceGroupName string, options *LoadTestsClientListByResourceGroupOptions) *LoadTestsClientListByResourceGroupPager { - return &LoadTestsClientListByResourceGroupPager{ - client: client, - requester: func(ctx context.Context) (*policy.Request, error) { - return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) +func (client *LoadTestsClient) ListByResourceGroup(resourceGroupName string, options *LoadTestsClientListByResourceGroupOptions) *runtime.Pager[LoadTestsClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PageProcessor[LoadTestsClientListByResourceGroupResponse]{ + More: func(page LoadTestsClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 }, - advancer: func(ctx context.Context, resp LoadTestsClientListByResourceGroupResponse) (*policy.Request, error) { - return runtime.NewRequest(ctx, http.MethodGet, *resp.LoadTestResourcePageList.NextLink) + Fetcher: func(ctx context.Context, page *LoadTestsClientListByResourceGroupResponse) (LoadTestsClientListByResourceGroupResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return LoadTestsClientListByResourceGroupResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return LoadTestsClientListByResourceGroupResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return LoadTestsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) + } + return client.listByResourceGroupHandleResponse(resp) }, - } + }) } // listByResourceGroupCreateRequest creates the ListByResourceGroup request. @@ -260,7 +284,7 @@ func (client *LoadTestsClient) listByResourceGroupCreateRequest(ctx context.Cont return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-12-01-preview") + reqQP.Set("api-version", "2022-04-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, nil @@ -268,7 +292,7 @@ func (client *LoadTestsClient) listByResourceGroupCreateRequest(ctx context.Cont // listByResourceGroupHandleResponse handles the ListByResourceGroup response. func (client *LoadTestsClient) listByResourceGroupHandleResponse(resp *http.Response) (LoadTestsClientListByResourceGroupResponse, error) { - result := LoadTestsClientListByResourceGroupResponse{RawResponse: resp} + result := LoadTestsClientListByResourceGroupResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.LoadTestResourcePageList); err != nil { return LoadTestsClientListByResourceGroupResponse{}, err } @@ -279,16 +303,32 @@ func (client *LoadTestsClient) listByResourceGroupHandleResponse(resp *http.Resp // If the operation fails it returns an *azcore.ResponseError type. // options - LoadTestsClientListBySubscriptionOptions contains the optional parameters for the LoadTestsClient.ListBySubscription // method. -func (client *LoadTestsClient) ListBySubscription(options *LoadTestsClientListBySubscriptionOptions) *LoadTestsClientListBySubscriptionPager { - return &LoadTestsClientListBySubscriptionPager{ - client: client, - requester: func(ctx context.Context) (*policy.Request, error) { - return client.listBySubscriptionCreateRequest(ctx, options) +func (client *LoadTestsClient) ListBySubscription(options *LoadTestsClientListBySubscriptionOptions) *runtime.Pager[LoadTestsClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PageProcessor[LoadTestsClientListBySubscriptionResponse]{ + More: func(page LoadTestsClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 }, - advancer: func(ctx context.Context, resp LoadTestsClientListBySubscriptionResponse) (*policy.Request, error) { - return runtime.NewRequest(ctx, http.MethodGet, *resp.LoadTestResourcePageList.NextLink) + Fetcher: func(ctx context.Context, page *LoadTestsClientListBySubscriptionResponse) (LoadTestsClientListBySubscriptionResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listBySubscriptionCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return LoadTestsClientListBySubscriptionResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return LoadTestsClientListBySubscriptionResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return LoadTestsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) + } + return client.listBySubscriptionHandleResponse(resp) }, - } + }) } // listBySubscriptionCreateRequest creates the ListBySubscription request. @@ -303,7 +343,7 @@ func (client *LoadTestsClient) listBySubscriptionCreateRequest(ctx context.Conte return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-12-01-preview") + reqQP.Set("api-version", "2022-04-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, nil @@ -311,36 +351,52 @@ func (client *LoadTestsClient) listBySubscriptionCreateRequest(ctx context.Conte // listBySubscriptionHandleResponse handles the ListBySubscription response. func (client *LoadTestsClient) listBySubscriptionHandleResponse(resp *http.Response) (LoadTestsClientListBySubscriptionResponse, error) { - result := LoadTestsClientListBySubscriptionResponse{RawResponse: resp} + result := LoadTestsClientListBySubscriptionResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.LoadTestResourcePageList); err != nil { return LoadTestsClientListBySubscriptionResponse{}, err } return result, nil } -// Update - Update a loadtest resource. +// BeginUpdate - Update a loadtest resource. // If the operation fails it returns an *azcore.ResponseError type. // resourceGroupName - The name of the resource group. The name is case insensitive. // loadTestName - Load Test name. // loadTestResourcePatchRequestBody - LoadTest resource update data -// options - LoadTestsClientUpdateOptions contains the optional parameters for the LoadTestsClient.Update method. -func (client *LoadTestsClient) Update(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResourcePatchRequestBody LoadTestResourcePatchRequestBody, options *LoadTestsClientUpdateOptions) (LoadTestsClientUpdateResponse, error) { +// options - LoadTestsClientBeginUpdateOptions contains the optional parameters for the LoadTestsClient.BeginUpdate method. +func (client *LoadTestsClient) BeginUpdate(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResourcePatchRequestBody LoadTestResourcePatchRequestBody, options *LoadTestsClientBeginUpdateOptions) (*armruntime.Poller[LoadTestsClientUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.update(ctx, resourceGroupName, loadTestName, loadTestResourcePatchRequestBody, options) + if err != nil { + return nil, err + } + return armruntime.NewPoller(resp, client.pl, &armruntime.NewPollerOptions[LoadTestsClientUpdateResponse]{ + FinalStateVia: armruntime.FinalStateViaAzureAsyncOp, + }) + } else { + return armruntime.NewPollerFromResumeToken[LoadTestsClientUpdateResponse](options.ResumeToken, client.pl, nil) + } +} + +// Update - Update a loadtest resource. +// If the operation fails it returns an *azcore.ResponseError type. +func (client *LoadTestsClient) update(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResourcePatchRequestBody LoadTestResourcePatchRequestBody, options *LoadTestsClientBeginUpdateOptions) (*http.Response, error) { req, err := client.updateCreateRequest(ctx, resourceGroupName, loadTestName, loadTestResourcePatchRequestBody, options) if err != nil { - return LoadTestsClientUpdateResponse{}, err + return nil, err } resp, err := client.pl.Do(req) if err != nil { - return LoadTestsClientUpdateResponse{}, err + return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LoadTestsClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { + return nil, runtime.NewResponseError(resp) } - return client.updateHandleResponse(resp) + return resp, nil } // updateCreateRequest creates the Update request. -func (client *LoadTestsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResourcePatchRequestBody LoadTestResourcePatchRequestBody, options *LoadTestsClientUpdateOptions) (*policy.Request, error) { +func (client *LoadTestsClient) updateCreateRequest(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResourcePatchRequestBody LoadTestResourcePatchRequestBody, options *LoadTestsClientBeginUpdateOptions) (*policy.Request, error) { urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests/{loadTestName}" if client.subscriptionID == "" { return nil, errors.New("parameter client.subscriptionID cannot be empty") @@ -359,17 +415,8 @@ func (client *LoadTestsClient) updateCreateRequest(ctx context.Context, resource return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-12-01-preview") + reqQP.Set("api-version", "2022-04-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, runtime.MarshalAsJSON(req, loadTestResourcePatchRequestBody) } - -// updateHandleResponse handles the Update response. -func (client *LoadTestsClient) updateHandleResponse(resp *http.Response) (LoadTestsClientUpdateResponse, error) { - result := LoadTestsClientUpdateResponse{RawResponse: resp} - if err := runtime.UnmarshalAsJSON(resp, &result.LoadTestResource); err != nil { - return LoadTestsClientUpdateResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_models.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_models.go index e5b3a1ad5b0d..335bd41c1d18 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_models.go +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_models.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//go:build go1.18 +// +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -8,17 +8,33 @@ package armloadtestservice -import ( - "encoding/json" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "reflect" - "time" -) +import "time" + +// EncryptionProperties - Key and identity details for Customer Managed Key encryption of load test resource +type EncryptionProperties struct { + // All identity configuration for Customer-managed key settings defining which identity should be used to auth to Key Vault. + Identity *EncryptionPropertiesIdentity `json:"identity,omitempty"` + + // key encryption key Url, versioned. Ex: https://contosovault.vault.azure.net/keys/contosokek/562a4bb76b524a1493a6afe8e536ee78 + // or https://contosovault.vault.azure.net/keys/contosokek. + KeyURL *string `json:"keyUrl,omitempty"` +} + +// EncryptionPropertiesIdentity - All identity configuration for Customer-managed key settings defining which identity should +// be used to auth to Key Vault. +type EncryptionPropertiesIdentity struct { + // user assigned identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups/ + // /providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId + ResourceID *string `json:"resourceId,omitempty"` + + // Managed identity type to use for accessing encryption key Url + Type *Type `json:"type,omitempty"` +} // ErrorAdditionalInfo - The resource management error additional info. type ErrorAdditionalInfo struct { // READ-ONLY; The additional info. - Info map[string]interface{} `json:"info,omitempty" azure:"ro"` + Info interface{} `json:"info,omitempty" azure:"ro"` // READ-ONLY; The additional info type. Type *string `json:"type,omitempty" azure:"ro"` @@ -42,17 +58,6 @@ type ErrorDetail struct { Target *string `json:"target,omitempty" azure:"ro"` } -// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. -func (e ErrorDetail) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "additionalInfo", e.AdditionalInfo) - populate(objectMap, "code", e.Code) - populate(objectMap, "details", e.Details) - populate(objectMap, "message", e.Message) - populate(objectMap, "target", e.Target) - return json.Marshal(objectMap) -} - // ErrorResponse - Common error response for all Azure Resource Manager APIs to return error details for failed operations. // (This also follows the OData error response format.). type ErrorResponse struct { @@ -65,6 +70,9 @@ type LoadTestProperties struct { // Description of the resource. Description *string `json:"description,omitempty"` + // CMK Encryption property. + Encryption *EncryptionProperties `json:"encryption,omitempty"` + // READ-ONLY; Resource data plane URI. DataPlaneURI *string `json:"dataPlaneURI,omitempty" azure:"ro"` @@ -78,7 +86,7 @@ type LoadTestResource struct { Location *string `json:"location,omitempty"` // The type of identity used for the resource. - Identity *SystemAssignedServiceIdentity `json:"identity,omitempty"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` // Load Test resource properties Properties *LoadTestProperties `json:"properties,omitempty"` @@ -99,20 +107,6 @@ type LoadTestResource struct { Type *string `json:"type,omitempty" azure:"ro"` } -// MarshalJSON implements the json.Marshaller interface for type LoadTestResource. -func (l LoadTestResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", l.ID) - populate(objectMap, "identity", l.Identity) - populate(objectMap, "location", l.Location) - populate(objectMap, "name", l.Name) - populate(objectMap, "properties", l.Properties) - populate(objectMap, "systemData", l.SystemData) - populate(objectMap, "tags", l.Tags) - populate(objectMap, "type", l.Type) - return json.Marshal(objectMap) -} - // LoadTestResourcePageList - List of resources page result. type LoadTestResourcePageList struct { // Link to next page of resources. @@ -122,49 +116,44 @@ type LoadTestResourcePageList struct { Value []*LoadTestResource `json:"value,omitempty"` } -// MarshalJSON implements the json.Marshaller interface for type LoadTestResourcePageList. -func (l LoadTestResourcePageList) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "nextLink", l.NextLink) - populate(objectMap, "value", l.Value) - return json.Marshal(objectMap) -} - // LoadTestResourcePatchRequestBody - LoadTest resource patch request body. type LoadTestResourcePatchRequestBody struct { // The type of identity used for the resource. - Identity *SystemAssignedServiceIdentity `json:"identity,omitempty"` + Identity *ManagedServiceIdentity `json:"identity,omitempty"` // Load Test resource properties Properties *LoadTestResourcePatchRequestBodyProperties `json:"properties,omitempty"` // Resource tags. - Tags map[string]interface{} `json:"tags,omitempty"` -} - -// MarshalJSON implements the json.Marshaller interface for type LoadTestResourcePatchRequestBody. -func (l LoadTestResourcePatchRequestBody) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "identity", l.Identity) - populate(objectMap, "properties", l.Properties) - populate(objectMap, "tags", l.Tags) - return json.Marshal(objectMap) + Tags interface{} `json:"tags,omitempty"` } // LoadTestResourcePatchRequestBodyProperties - Load Test resource properties type LoadTestResourcePatchRequestBodyProperties struct { // Description of the resource. Description *string `json:"description,omitempty"` + + // CMK Encryption property. + Encryption *EncryptionProperties `json:"encryption,omitempty"` +} + +// LoadTestsClientBeginCreateOrUpdateOptions contains the optional parameters for the LoadTestsClient.BeginCreateOrUpdate +// method. +type LoadTestsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } // LoadTestsClientBeginDeleteOptions contains the optional parameters for the LoadTestsClient.BeginDelete method. type LoadTestsClientBeginDeleteOptions struct { - // placeholder for future optional parameters + // Resumes the LRO from the provided token. + ResumeToken string } -// LoadTestsClientCreateOrUpdateOptions contains the optional parameters for the LoadTestsClient.CreateOrUpdate method. -type LoadTestsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters +// LoadTestsClientBeginUpdateOptions contains the optional parameters for the LoadTestsClient.BeginUpdate method. +type LoadTestsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string } // LoadTestsClientGetOptions contains the optional parameters for the LoadTestsClient.Get method. @@ -183,9 +172,24 @@ type LoadTestsClientListBySubscriptionOptions struct { // placeholder for future optional parameters } -// LoadTestsClientUpdateOptions contains the optional parameters for the LoadTestsClient.Update method. -type LoadTestsClientUpdateOptions struct { - // placeholder for future optional parameters +// ManagedServiceIdentity - Managed service identity (system assigned and/or user assigned identities) +type ManagedServiceIdentity struct { + // REQUIRED; Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). + Type *ManagedServiceIdentityType `json:"type,omitempty"` + + // The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM + // resource ids in the form: + // '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. + // The dictionary values can be empty objects ({}) in + // requests. + UserAssignedIdentities map[string]*UserAssignedIdentity `json:"userAssignedIdentities,omitempty"` + + // READ-ONLY; The service principal ID of the system assigned identity. This property will only be provided for a system assigned + // identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + + // READ-ONLY; The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. + TenantID *string `json:"tenantId,omitempty" azure:"ro"` } // Operation - Details of a REST API operation, returned from the Resource Provider Operations API @@ -237,14 +241,6 @@ type OperationListResult struct { Value []*Operation `json:"value,omitempty" azure:"ro"` } -// MarshalJSON implements the json.Marshaller interface for type OperationListResult. -func (o OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "nextLink", o.NextLink) - populate(objectMap, "value", o.Value) - return json.Marshal(objectMap) -} - // OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. type OperationsClientListOptions struct { // placeholder for future optional parameters @@ -265,19 +261,6 @@ type Resource struct { Type *string `json:"type,omitempty" azure:"ro"` } -// SystemAssignedServiceIdentity - Managed service identity (either system assigned, or none) -type SystemAssignedServiceIdentity struct { - // REQUIRED; Type of managed service identity (either system assigned, or none). - Type *SystemAssignedServiceIdentityType `json:"type,omitempty"` - - // READ-ONLY; The service principal ID of the system assigned identity. This property will only be provided for a system assigned - // identity. - PrincipalID *string `json:"principalId,omitempty" azure:"ro"` - - // READ-ONLY; The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. - TenantID *string `json:"tenantId,omitempty" azure:"ro"` -} - // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). @@ -299,53 +282,6 @@ type SystemData struct { LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` } -// MarshalJSON implements the json.Marshaller interface for type SystemData. -func (s SystemData) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) - populate(objectMap, "createdBy", s.CreatedBy) - populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) - populate(objectMap, "lastModifiedBy", s.LastModifiedBy) - populate(objectMap, "lastModifiedByType", s.LastModifiedByType) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. -func (s *SystemData) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return err - } - for key, val := range rawMsg { - var err error - switch key { - case "createdAt": - err = unpopulateTimeRFC3339(val, &s.CreatedAt) - delete(rawMsg, key) - case "createdBy": - err = unpopulate(val, &s.CreatedBy) - delete(rawMsg, key) - case "createdByType": - err = unpopulate(val, &s.CreatedByType) - delete(rawMsg, key) - case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, &s.LastModifiedAt) - delete(rawMsg, key) - case "lastModifiedBy": - err = unpopulate(val, &s.LastModifiedBy) - delete(rawMsg, key) - case "lastModifiedByType": - err = unpopulate(val, &s.LastModifiedByType) - delete(rawMsg, key) - } - if err != nil { - return err - } - } - return nil -} - // TrackedResource - The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' // and a 'location' type TrackedResource struct { @@ -368,31 +304,11 @@ type TrackedResource struct { Type *string `json:"type,omitempty" azure:"ro"` } -// MarshalJSON implements the json.Marshaller interface for type TrackedResource. -func (t TrackedResource) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - populate(objectMap, "id", t.ID) - populate(objectMap, "location", t.Location) - populate(objectMap, "name", t.Name) - populate(objectMap, "systemData", t.SystemData) - populate(objectMap, "tags", t.Tags) - populate(objectMap, "type", t.Type) - return json.Marshal(objectMap) -} - -func populate(m map[string]interface{}, k string, v interface{}) { - if v == nil { - return - } else if azcore.IsNullValue(v) { - m[k] = nil - } else if !reflect.ValueOf(v).IsNil() { - m[k] = v - } -} +// UserAssignedIdentity - User assigned identity properties +type UserAssignedIdentity struct { + // READ-ONLY; The client ID of the assigned identity. + ClientID *string `json:"clientId,omitempty" azure:"ro"` -func unpopulate(data json.RawMessage, v interface{}) error { - if data == nil { - return nil - } - return json.Unmarshal(data, v) + // READ-ONLY; The principal ID of the assigned identity. + PrincipalID *string `json:"principalId,omitempty" azure:"ro"` } diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_models_serde.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_models_serde.go new file mode 100644 index 000000000000..1e5d6768038e --- /dev/null +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_models_serde.go @@ -0,0 +1,151 @@ +//go:build go1.18 +// +build go1.18 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +package armloadtestservice + +import ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type ErrorDetail. +func (e ErrorDetail) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "additionalInfo", e.AdditionalInfo) + populate(objectMap, "code", e.Code) + populate(objectMap, "details", e.Details) + populate(objectMap, "message", e.Message) + populate(objectMap, "target", e.Target) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type LoadTestResource. +func (l LoadTestResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", l.ID) + populate(objectMap, "identity", l.Identity) + populate(objectMap, "location", l.Location) + populate(objectMap, "name", l.Name) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "systemData", l.SystemData) + populate(objectMap, "tags", l.Tags) + populate(objectMap, "type", l.Type) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type LoadTestResourcePageList. +func (l LoadTestResourcePageList) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", l.NextLink) + populate(objectMap, "value", l.Value) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type LoadTestResourcePatchRequestBody. +func (l LoadTestResourcePatchRequestBody) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "identity", l.Identity) + populate(objectMap, "properties", l.Properties) + populate(objectMap, "tags", &l.Tags) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type ManagedServiceIdentity. +func (m ManagedServiceIdentity) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "principalId", m.PrincipalID) + populate(objectMap, "tenantId", m.TenantID) + populate(objectMap, "type", m.Type) + populate(objectMap, "userAssignedIdentities", m.UserAssignedIdentities) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populate(objectMap, "lastModifiedBy", s.LastModifiedBy) + populate(objectMap, "lastModifiedByType", s.LastModifiedByType) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type SystemData. +func (s *SystemData) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return err + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateTimeRFC3339(val, &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateTimeRFC3339(val, &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return err + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type TrackedResource. +func (t TrackedResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + populate(objectMap, "id", t.ID) + populate(objectMap, "location", t.Location) + populate(objectMap, "name", t.Name) + populate(objectMap, "systemData", t.SystemData) + populate(objectMap, "tags", t.Tags) + populate(objectMap, "type", t.Type) + return json.Marshal(objectMap) +} + +func populate(m map[string]interface{}, k string, v interface{}) { + if v == nil { + return + } else if azcore.IsNullValue(v) { + m[k] = nil + } else if !reflect.ValueOf(v).IsNil() { + m[k] = v + } +} + +func unpopulate(data json.RawMessage, v interface{}) error { + if data == nil { + return nil + } + return json.Unmarshal(data, v) +} diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_operations_client.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_operations_client.go index 9aa8b5337ed4..4d480de271a5 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_operations_client.go +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_operations_client.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//go:build go1.18 +// +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -13,6 +13,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore" "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/cloud" "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "net/http" @@ -28,34 +29,54 @@ type OperationsClient struct { // NewOperationsClient creates a new instance of OperationsClient with the specified values. // credential - used to authorize requests. Usually a credential from azidentity. // options - pass nil to accept the default values. -func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) *OperationsClient { - cp := arm.ClientOptions{} - if options != nil { - cp = *options +func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { + if options == nil { + options = &arm.ClientOptions{} } - if len(cp.Endpoint) == 0 { - cp.Endpoint = arm.AzurePublicCloud + ep := cloud.AzurePublicCloud.Services[cloud.ResourceManager].Endpoint + if c, ok := options.Cloud.Services[cloud.ResourceManager]; ok { + ep = c.Endpoint + } + pl, err := armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, options) + if err != nil { + return nil, err } client := &OperationsClient{ - host: string(cp.Endpoint), - pl: armruntime.NewPipeline(moduleName, moduleVersion, credential, runtime.PipelineOptions{}, &cp), + host: ep, + pl: pl, } - return client + return client, nil } // List - Lists all the available API operations for Load Test Resource. // If the operation fails it returns an *azcore.ResponseError type. // options - OperationsClientListOptions contains the optional parameters for the OperationsClient.List method. -func (client *OperationsClient) List(options *OperationsClientListOptions) *OperationsClientListPager { - return &OperationsClientListPager{ - client: client, - requester: func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, options) +func (client *OperationsClient) List(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { + return runtime.NewPager(runtime.PageProcessor[OperationsClientListResponse]{ + More: func(page OperationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 }, - advancer: func(ctx context.Context, resp OperationsClientListResponse) (*policy.Request, error) { - return runtime.NewRequest(ctx, http.MethodGet, *resp.OperationListResult.NextLink) + Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { + var req *policy.Request + var err error + if page == nil { + req, err = client.listCreateRequest(ctx, options) + } else { + req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + } + if err != nil { + return OperationsClientListResponse{}, err + } + resp, err := client.pl.Do(req) + if err != nil { + return OperationsClientListResponse{}, err + } + if !runtime.HasStatusCode(resp, http.StatusOK) { + return OperationsClientListResponse{}, runtime.NewResponseError(resp) + } + return client.listHandleResponse(resp) }, - } + }) } // listCreateRequest creates the List request. @@ -66,7 +87,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2021-12-01-preview") + reqQP.Set("api-version", "2022-04-15-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header.Set("Accept", "application/json") return req, nil @@ -74,7 +95,7 @@ func (client *OperationsClient) listCreateRequest(ctx context.Context, options * // listHandleResponse handles the List response. func (client *OperationsClient) listHandleResponse(resp *http.Response) (OperationsClientListResponse, error) { - result := OperationsClientListResponse{RawResponse: resp} + result := OperationsClientListResponse{} if err := runtime.UnmarshalAsJSON(resp, &result.OperationListResult); err != nil { return OperationsClientListResponse{}, err } diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_pagers.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_pagers.go deleted file mode 100644 index 55a23dcff7a7..000000000000 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_pagers.go +++ /dev/null @@ -1,179 +0,0 @@ -//go:build go1.16 -// +build go1.16 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armloadtestservice - -import ( - "context" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "reflect" -) - -// LoadTestsClientListByResourceGroupPager provides operations for iterating over paged responses. -type LoadTestsClientListByResourceGroupPager struct { - client *LoadTestsClient - current LoadTestsClientListByResourceGroupResponse - err error - requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, LoadTestsClientListByResourceGroupResponse) (*policy.Request, error) -} - -// Err returns the last error encountered while paging. -func (p *LoadTestsClientListByResourceGroupPager) Err() error { - return p.err -} - -// NextPage returns true if the pager advanced to the next page. -// Returns false if there are no more pages or an error occurred. -func (p *LoadTestsClientListByResourceGroupPager) NextPage(ctx context.Context) bool { - var req *policy.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.LoadTestResourcePageList.NextLink == nil || len(*p.current.LoadTestResourcePageList.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.client.pl.Do(req) - if err != nil { - p.err = err - return false - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = runtime.NewResponseError(resp) - return false - } - result, err := p.client.listByResourceGroupHandleResponse(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -// PageResponse returns the current LoadTestsClientListByResourceGroupResponse page. -func (p *LoadTestsClientListByResourceGroupPager) PageResponse() LoadTestsClientListByResourceGroupResponse { - return p.current -} - -// LoadTestsClientListBySubscriptionPager provides operations for iterating over paged responses. -type LoadTestsClientListBySubscriptionPager struct { - client *LoadTestsClient - current LoadTestsClientListBySubscriptionResponse - err error - requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, LoadTestsClientListBySubscriptionResponse) (*policy.Request, error) -} - -// Err returns the last error encountered while paging. -func (p *LoadTestsClientListBySubscriptionPager) Err() error { - return p.err -} - -// NextPage returns true if the pager advanced to the next page. -// Returns false if there are no more pages or an error occurred. -func (p *LoadTestsClientListBySubscriptionPager) NextPage(ctx context.Context) bool { - var req *policy.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.LoadTestResourcePageList.NextLink == nil || len(*p.current.LoadTestResourcePageList.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.client.pl.Do(req) - if err != nil { - p.err = err - return false - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = runtime.NewResponseError(resp) - return false - } - result, err := p.client.listBySubscriptionHandleResponse(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -// PageResponse returns the current LoadTestsClientListBySubscriptionResponse page. -func (p *LoadTestsClientListBySubscriptionPager) PageResponse() LoadTestsClientListBySubscriptionResponse { - return p.current -} - -// OperationsClientListPager provides operations for iterating over paged responses. -type OperationsClientListPager struct { - client *OperationsClient - current OperationsClientListResponse - err error - requester func(context.Context) (*policy.Request, error) - advancer func(context.Context, OperationsClientListResponse) (*policy.Request, error) -} - -// Err returns the last error encountered while paging. -func (p *OperationsClientListPager) Err() error { - return p.err -} - -// NextPage returns true if the pager advanced to the next page. -// Returns false if there are no more pages or an error occurred. -func (p *OperationsClientListPager) NextPage(ctx context.Context) bool { - var req *policy.Request - var err error - if !reflect.ValueOf(p.current).IsZero() { - if p.current.OperationListResult.NextLink == nil || len(*p.current.OperationListResult.NextLink) == 0 { - return false - } - req, err = p.advancer(ctx, p.current) - } else { - req, err = p.requester(ctx) - } - if err != nil { - p.err = err - return false - } - resp, err := p.client.pl.Do(req) - if err != nil { - p.err = err - return false - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - p.err = runtime.NewResponseError(resp) - return false - } - result, err := p.client.listHandleResponse(resp) - if err != nil { - p.err = err - return false - } - p.current = result - return true -} - -// PageResponse returns the current OperationsClientListResponse page. -func (p *OperationsClientListPager) PageResponse() OperationsClientListResponse { - return p.current -} diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_pollers.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_pollers.go deleted file mode 100644 index 05032c08d1d0..000000000000 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_pollers.go +++ /dev/null @@ -1,58 +0,0 @@ -//go:build go1.16 -// +build go1.16 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armloadtestservice - -import ( - "context" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "net/http" -) - -// LoadTestsClientDeletePoller provides polling facilities until the operation reaches a terminal state. -type LoadTestsClientDeletePoller struct { - pt *azcore.Poller -} - -// Done returns true if the LRO has reached a terminal state. -func (p *LoadTestsClientDeletePoller) Done() bool { - return p.pt.Done() -} - -// Poll fetches the latest state of the LRO. It returns an HTTP response or error. -// If the LRO has completed successfully, the poller's state is updated and the HTTP -// response is returned. -// If the LRO has completed with failure or was cancelled, the poller's state is -// updated and the error is returned. -// If the LRO has not reached a terminal state, the poller's state is updated and -// the latest HTTP response is returned. -// If Poll fails, the poller's state is unmodified and the error is returned. -// Calling Poll on an LRO that has reached a terminal state will return the final -// HTTP response or error. -func (p *LoadTestsClientDeletePoller) Poll(ctx context.Context) (*http.Response, error) { - return p.pt.Poll(ctx) -} - -// FinalResponse performs a final GET to the service and returns the final response -// for the polling operation. If there is an error performing the final GET then an error is returned. -// If the final GET succeeded then the final LoadTestsClientDeleteResponse will be returned. -func (p *LoadTestsClientDeletePoller) FinalResponse(ctx context.Context) (LoadTestsClientDeleteResponse, error) { - respType := LoadTestsClientDeleteResponse{} - resp, err := p.pt.FinalResponse(ctx, nil) - if err != nil { - return LoadTestsClientDeleteResponse{}, err - } - respType.RawResponse = resp - return respType, nil -} - -// ResumeToken returns a value representing the poller that can be used to resume -// the LRO at a later time. ResumeTokens are unique per service operation. -func (p *LoadTestsClientDeletePoller) ResumeToken() (string, error) { - return p.pt.ResumeToken() -} diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_response_types.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_response_types.go index f9ccee47bbe8..b75e28844774 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_response_types.go +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_response_types.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//go:build go1.18 +// +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. @@ -8,127 +8,37 @@ package armloadtestservice -import ( - "context" - armruntime "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm/runtime" - "net/http" - "time" -) - // LoadTestsClientCreateOrUpdateResponse contains the response from method LoadTestsClient.CreateOrUpdate. type LoadTestsClientCreateOrUpdateResponse struct { - LoadTestsClientCreateOrUpdateResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// LoadTestsClientCreateOrUpdateResult contains the result from method LoadTestsClient.CreateOrUpdate. -type LoadTestsClientCreateOrUpdateResult struct { LoadTestResource } -// LoadTestsClientDeletePollerResponse contains the response from method LoadTestsClient.Delete. -type LoadTestsClientDeletePollerResponse struct { - // Poller contains an initialized poller. - Poller *LoadTestsClientDeletePoller - - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// PollUntilDone will poll the service endpoint until a terminal state is reached or an error is received. -// freq: the time to wait between intervals in absence of a Retry-After header. Allowed minimum is one second. -// A good starting value is 30 seconds. Note that some resources might benefit from a different value. -func (l LoadTestsClientDeletePollerResponse) PollUntilDone(ctx context.Context, freq time.Duration) (LoadTestsClientDeleteResponse, error) { - respType := LoadTestsClientDeleteResponse{} - resp, err := l.Poller.pt.PollUntilDone(ctx, freq, nil) - if err != nil { - return respType, err - } - respType.RawResponse = resp - return respType, nil -} - -// Resume rehydrates a LoadTestsClientDeletePollerResponse from the provided client and resume token. -func (l *LoadTestsClientDeletePollerResponse) Resume(ctx context.Context, client *LoadTestsClient, token string) error { - pt, err := armruntime.NewPollerFromResumeToken("LoadTestsClient.Delete", token, client.pl) - if err != nil { - return err - } - poller := &LoadTestsClientDeletePoller{ - pt: pt, - } - resp, err := poller.Poll(ctx) - if err != nil { - return err - } - l.Poller = poller - l.RawResponse = resp - return nil -} - // LoadTestsClientDeleteResponse contains the response from method LoadTestsClient.Delete. type LoadTestsClientDeleteResponse struct { - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response + // placeholder for future response values } // LoadTestsClientGetResponse contains the response from method LoadTestsClient.Get. type LoadTestsClientGetResponse struct { - LoadTestsClientGetResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// LoadTestsClientGetResult contains the result from method LoadTestsClient.Get. -type LoadTestsClientGetResult struct { LoadTestResource } // LoadTestsClientListByResourceGroupResponse contains the response from method LoadTestsClient.ListByResourceGroup. type LoadTestsClientListByResourceGroupResponse struct { - LoadTestsClientListByResourceGroupResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// LoadTestsClientListByResourceGroupResult contains the result from method LoadTestsClient.ListByResourceGroup. -type LoadTestsClientListByResourceGroupResult struct { LoadTestResourcePageList } // LoadTestsClientListBySubscriptionResponse contains the response from method LoadTestsClient.ListBySubscription. type LoadTestsClientListBySubscriptionResponse struct { - LoadTestsClientListBySubscriptionResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// LoadTestsClientListBySubscriptionResult contains the result from method LoadTestsClient.ListBySubscription. -type LoadTestsClientListBySubscriptionResult struct { LoadTestResourcePageList } // LoadTestsClientUpdateResponse contains the response from method LoadTestsClient.Update. type LoadTestsClientUpdateResponse struct { - LoadTestsClientUpdateResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// LoadTestsClientUpdateResult contains the result from method LoadTestsClient.Update. -type LoadTestsClientUpdateResult struct { LoadTestResource } // OperationsClientListResponse contains the response from method OperationsClient.List. type OperationsClientListResponse struct { - OperationsClientListResult - // RawResponse contains the underlying HTTP response. - RawResponse *http.Response -} - -// OperationsClientListResult contains the result from method OperationsClient.List. -type OperationsClientListResult struct { OperationListResult } diff --git a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_time_rfc3339.go b/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_time_rfc3339.go index a07b8b5a05a1..5239a628aaf1 100644 --- a/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_time_rfc3339.go +++ b/sdk/resourcemanager/loadtestservice/armloadtestservice/zz_generated_time_rfc3339.go @@ -1,5 +1,5 @@ -//go:build go1.16 -// +build go1.16 +//go:build go1.18 +// +build go1.18 // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information.