diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/CHANGELOG.md b/sdk/resourcemanager/loadtesting/armloadtesting/CHANGELOG.md index 22bec5129b54..f1972da3f8e9 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/CHANGELOG.md +++ b/sdk/resourcemanager/loadtesting/armloadtesting/CHANGELOG.md @@ -1,5 +1,58 @@ # Release History +## 2.0.0-beta.1 (2025-04-29) +### Breaking Changes + +- Enum `ActionType` has been removed +- Enum `Origin` has been removed +- Function `*ClientFactory.NewLoadTestsClient` has been removed +- Function `*ClientFactory.NewOperationsClient` has been removed +- Function `*ClientFactory.NewQuotasClient` has been removed +- Function `NewLoadTestsClient` has been removed +- Function `*LoadTestsClient.BeginCreateOrUpdate` has been removed +- Function `*LoadTestsClient.BeginDelete` has been removed +- Function `*LoadTestsClient.Get` has been removed +- Function `*LoadTestsClient.NewListByResourceGroupPager` has been removed +- Function `*LoadTestsClient.NewListBySubscriptionPager` has been removed +- Function `*LoadTestsClient.NewListOutboundNetworkDependenciesEndpointsPager` has been removed +- Function `*LoadTestsClient.BeginUpdate` has been removed +- Function `NewOperationsClient` has been removed +- Function `*OperationsClient.NewListPager` has been removed +- Function `NewQuotasClient` has been removed +- Function `*QuotasClient.CheckAvailability` has been removed +- Function `*QuotasClient.Get` has been removed +- Function `*QuotasClient.NewListPager` has been removed +- Struct `LoadTestResourcePageList` has been removed +- Struct `LoadTestResourcePatchRequestBody` has been removed +- Struct `LoadTestResourcePatchRequestBodyProperties` has been removed +- Struct `Operation` has been removed +- Struct `OperationDisplay` has been removed +- Struct `OperationListResult` has been removed +- Struct `OutboundEnvironmentEndpointCollection` has been removed +- Struct `QuotaResourceList` has been removed +- Field `ID`, `Name`, `SystemData`, `Type` of struct `QuotaBucketRequest` has been removed + +### Features Added + +- New function `*ClientFactory.NewLoadTestMgmtClient() *LoadTestMgmtClient` +- New function `NewLoadTestMgmtClient(string, azcore.TokenCredential, *arm.ClientOptions) (*LoadTestMgmtClient, error)` +- New function `*LoadTestMgmtClient.CheckAvailabilityQuota(context.Context, string, string, QuotaBucketRequest, *LoadTestMgmtClientCheckAvailabilityQuotaOptions) (LoadTestMgmtClientCheckAvailabilityQuotaResponse, error)` +- New function `*LoadTestMgmtClient.BeginCreateOrUpdateLoadtest(context.Context, string, string, LoadTestResource, *LoadTestMgmtClientBeginCreateOrUpdateLoadtestOptions) (*runtime.Poller[LoadTestMgmtClientCreateOrUpdateLoadtestResponse], error)` +- New function `*LoadTestMgmtClient.BeginDeleteLoadtest(context.Context, string, string, *LoadTestMgmtClientBeginDeleteLoadtestOptions) (*runtime.Poller[LoadTestMgmtClientDeleteLoadtestResponse], error)` +- New function `*LoadTestMgmtClient.GetLoadtest(context.Context, string, string, *LoadTestMgmtClientGetLoadtestOptions) (LoadTestMgmtClientGetLoadtestResponse, error)` +- New function `*LoadTestMgmtClient.GetQuota(context.Context, string, string, *LoadTestMgmtClientGetQuotaOptions) (LoadTestMgmtClientGetQuotaResponse, error)` +- New function `*LoadTestMgmtClient.NewListByResourceGroupPager(string, *LoadTestMgmtClientListByResourceGroupOptions) *runtime.Pager[LoadTestMgmtClientListByResourceGroupResponse]` +- New function `*LoadTestMgmtClient.NewListBySubscriptionPager(*LoadTestMgmtClientListBySubscriptionOptions) *runtime.Pager[LoadTestMgmtClientListBySubscriptionResponse]` +- New function `*LoadTestMgmtClient.NewListQuotaPager(string, *LoadTestMgmtClientListQuotaOptions) *runtime.Pager[LoadTestMgmtClientListQuotaResponse]` +- New function `*LoadTestMgmtClient.NewOutboundNetworkDependenciesEndpointsPager(string, string, *LoadTestMgmtClientOutboundNetworkDependenciesEndpointsOptions) *runtime.Pager[LoadTestMgmtClientOutboundNetworkDependenciesEndpointsResponse]` +- New function `*LoadTestMgmtClient.BeginUpdateLoadtest(context.Context, string, string, LoadTestResourceUpdate, *LoadTestMgmtClientBeginUpdateLoadtestOptions) (*runtime.Poller[LoadTestMgmtClientUpdateLoadtestResponse], error)` +- New struct `LoadTestResourceListResult` +- New struct `LoadTestResourceUpdate` +- New struct `LoadTestResourceUpdateProperties` +- New struct `PagedOutboundEnvironmentEndpoint` +- New struct `QuotaResourceListResult` + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/README.md b/sdk/resourcemanager/loadtesting/armloadtesting/README.md index 21f24b798a92..71c282e0528d 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/README.md +++ b/sdk/resourcemanager/loadtesting/armloadtesting/README.md @@ -18,7 +18,7 @@ This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for ve Install the Azure Load Testing module: ```sh -go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtesting/armloadtesting +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtesting/armloadtesting/v2 ``` ## Authorization @@ -55,7 +55,7 @@ clientFactory, err := armloadtesting.NewClientFactory(, cred, & A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. ```go -client := clientFactory.NewLoadTestsClient() +client := clientFactory.NewLoadTestMgmtClient() ``` ## Fakes diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/autorest.md b/sdk/resourcemanager/loadtesting/armloadtesting/autorest.md deleted file mode 100644 index 2fde958ff520..000000000000 --- a/sdk/resourcemanager/loadtesting/armloadtesting/autorest.md +++ /dev/null @@ -1,14 +0,0 @@ -### AutoRest Configuration - -> see https://aka.ms/autorest - -``` yaml -azure-arm: true -require: -- https://github.com/Azure/azure-rest-api-specs/blob/630ec444f8dd7c09b9cdd5fa99951f8a0d1ad41f/specification/loadtestservice/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/630ec444f8dd7c09b9cdd5fa99951f8a0d1ad41f/specification/loadtestservice/resource-manager/readme.go.md -license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 - -# v1.0.0 and v1.0.1 has been retracted because of mistake. When this RP goes GA, it starts at version v1.0.2 -``` \ No newline at end of file diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/build.go b/sdk/resourcemanager/loadtesting/armloadtesting/build.go deleted file mode 100644 index 7470004fb26c..000000000000 --- a/sdk/resourcemanager/loadtesting/armloadtesting/build.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. - -// This file enables 'go generate' to regenerate this specific SDK -//go:generate pwsh ../../../../eng/scripts/build.ps1 -skipBuild -cleanGenerated -format -tidy -generate -alwaysSetBodyParamRequired -removeUnreferencedTypes resourcemanager/loadtesting/armloadtesting - -package armloadtesting diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/client_factory.go b/sdk/resourcemanager/loadtesting/armloadtesting/client_factory.go index e2eb7f96a538..2da67180b208 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/client_factory.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/client_factory.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armloadtesting @@ -17,40 +13,29 @@ import ( // Don't use this type directly, use NewClientFactory instead. type ClientFactory struct { subscriptionID string - credential azcore.TokenCredential - options *arm.ClientOptions + internal *arm.Client } // NewClientFactory creates a new instance of ClientFactory with the specified values. // The parameter values will be propagated to any client created from this factory. -// - subscriptionID - The ID of the target subscription. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { - _, err := arm.NewClient(moduleName, moduleVersion, credential, options) + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } return &ClientFactory{ - subscriptionID: subscriptionID, credential: credential, - options: options.Clone(), + subscriptionID: subscriptionID, + internal: internal, }, nil } -// NewLoadTestsClient creates a new instance of LoadTestsClient. -func (c *ClientFactory) NewLoadTestsClient() *LoadTestsClient { - subClient, _ := NewLoadTestsClient(c.subscriptionID, c.credential, c.options) - return subClient -} - -// NewOperationsClient creates a new instance of OperationsClient. -func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient -} - -// NewQuotasClient creates a new instance of QuotasClient. -func (c *ClientFactory) NewQuotasClient() *QuotasClient { - subClient, _ := NewQuotasClient(c.subscriptionID, c.credential, c.options) - return subClient +// NewLoadTestMgmtClient creates a new instance of LoadTestMgmtClient. +func (c *ClientFactory) NewLoadTestMgmtClient() *LoadTestMgmtClient { + return &LoadTestMgmtClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } } diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/constants.go b/sdk/resourcemanager/loadtesting/armloadtesting/constants.go index 5b13e215f4cf..e8e1be8bcac9 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/constants.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/constants.go @@ -1,40 +1,26 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armloadtesting const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtesting/armloadtesting" - moduleVersion = "v1.2.0" -) - -// ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. -type ActionType string - -const ( - ActionTypeInternal ActionType = "Internal" + moduleVersion = "v2.0.0-beta.1" ) -// PossibleActionTypeValues returns the possible values for the ActionType const type. -func PossibleActionTypeValues() []ActionType { - return []ActionType{ - ActionTypeInternal, - } -} - -// CreatedByType - The type of identity that created the resource. +// CreatedByType - The kind of entity that created the resource. type CreatedByType string const ( - CreatedByTypeApplication CreatedByType = "Application" - CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeApplication - The entity was created by an application. + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey - The entity was created by a key. + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity - The entity was created by a managed identity. CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" - CreatedByTypeUser CreatedByType = "User" + // CreatedByTypeUser - The entity was created by a user. + CreatedByTypeUser CreatedByType = "User" ) // PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. @@ -51,10 +37,14 @@ func PossibleCreatedByTypeValues() []CreatedByType { type ManagedServiceIdentityType string const ( - ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" - ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" + // ManagedServiceIdentityTypeNone - No managed identity. + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + // ManagedServiceIdentityTypeSystemAssigned - System assigned managed identity. + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" + // ManagedServiceIdentityTypeSystemAssignedUserAssigned - System and user assigned managed identity. ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned,UserAssigned" - ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" + // ManagedServiceIdentityTypeUserAssigned - User assigned managed identity. + ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" ) // PossibleManagedServiceIdentityTypeValues returns the possible values for the ManagedServiceIdentityType const type. @@ -67,32 +57,17 @@ func PossibleManagedServiceIdentityTypeValues() []ManagedServiceIdentityType { } } -// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default -// value is "user,system" -type Origin string - -const ( - OriginSystem Origin = "system" - OriginUser Origin = "user" - OriginUserSystem Origin = "user,system" -) - -// PossibleOriginValues returns the possible values for the Origin const type. -func PossibleOriginValues() []Origin { - return []Origin{ - OriginSystem, - OriginUser, - OriginUserSystem, - } -} - // ResourceState - Resources provisioning states. type ResourceState string const ( - ResourceStateCanceled ResourceState = "Canceled" - ResourceStateDeleted ResourceState = "Deleted" - ResourceStateFailed ResourceState = "Failed" + // ResourceStateCanceled - Resource creation was canceled. + ResourceStateCanceled ResourceState = "Canceled" + // ResourceStateDeleted - Deleted state. + ResourceStateDeleted ResourceState = "Deleted" + // ResourceStateFailed - Resource creation failed. + ResourceStateFailed ResourceState = "Failed" + // ResourceStateSucceeded - Resource has been created. ResourceStateSucceeded ResourceState = "Succeeded" ) @@ -106,12 +81,14 @@ func PossibleResourceStateValues() []ResourceState { } } -// Type - Managed identity type to use for accessing encryption key Url +// Type - Managed identity type to use for accessing encryption key Url. type Type string const ( + // TypeSystemAssigned - System assigned identity. TypeSystemAssigned Type = "SystemAssigned" - TypeUserAssigned Type = "UserAssigned" + // TypeUserAssigned - User assigned identity. + TypeUserAssigned Type = "UserAssigned" ) // PossibleTypeValues returns the possible values for the Type const type. diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/fake/internal.go b/sdk/resourcemanager/loadtesting/armloadtesting/fake/internal.go index 5f75802a569e..7425b6a669e2 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/fake/internal.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/fake/internal.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -14,6 +10,11 @@ import ( "sync" ) +type result struct { + resp *http.Response + err error +} + type nonRetriableError struct { error } diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/fake/loadtestmgmt_server.go b/sdk/resourcemanager/loadtesting/armloadtesting/fake/loadtestmgmt_server.go new file mode 100644 index 000000000000..96345d5a6e93 --- /dev/null +++ b/sdk/resourcemanager/loadtesting/armloadtesting/fake/loadtestmgmt_server.go @@ -0,0 +1,550 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtesting/armloadtesting/v2" + "net/http" + "net/url" + "regexp" +) + +// LoadTestMgmtServer is a fake server for instances of the armloadtesting.LoadTestMgmtClient type. +type LoadTestMgmtServer struct { + // CheckAvailabilityQuota is the fake for method LoadTestMgmtClient.CheckAvailabilityQuota + // HTTP status codes to indicate success: http.StatusOK + CheckAvailabilityQuota func(ctx context.Context, location string, quotaBucketName string, quotaBucketRequest armloadtesting.QuotaBucketRequest, options *armloadtesting.LoadTestMgmtClientCheckAvailabilityQuotaOptions) (resp azfake.Responder[armloadtesting.LoadTestMgmtClientCheckAvailabilityQuotaResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdateLoadtest is the fake for method LoadTestMgmtClient.BeginCreateOrUpdateLoadtest + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdateLoadtest func(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResource armloadtesting.LoadTestResource, options *armloadtesting.LoadTestMgmtClientBeginCreateOrUpdateLoadtestOptions) (resp azfake.PollerResponder[armloadtesting.LoadTestMgmtClientCreateOrUpdateLoadtestResponse], errResp azfake.ErrorResponder) + + // BeginDeleteLoadtest is the fake for method LoadTestMgmtClient.BeginDeleteLoadtest + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDeleteLoadtest func(ctx context.Context, resourceGroupName string, loadTestName string, options *armloadtesting.LoadTestMgmtClientBeginDeleteLoadtestOptions) (resp azfake.PollerResponder[armloadtesting.LoadTestMgmtClientDeleteLoadtestResponse], errResp azfake.ErrorResponder) + + // GetLoadtest is the fake for method LoadTestMgmtClient.GetLoadtest + // HTTP status codes to indicate success: http.StatusOK + GetLoadtest func(ctx context.Context, resourceGroupName string, loadTestName string, options *armloadtesting.LoadTestMgmtClientGetLoadtestOptions) (resp azfake.Responder[armloadtesting.LoadTestMgmtClientGetLoadtestResponse], errResp azfake.ErrorResponder) + + // GetQuota is the fake for method LoadTestMgmtClient.GetQuota + // HTTP status codes to indicate success: http.StatusOK + GetQuota func(ctx context.Context, location string, quotaBucketName string, options *armloadtesting.LoadTestMgmtClientGetQuotaOptions) (resp azfake.Responder[armloadtesting.LoadTestMgmtClientGetQuotaResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method LoadTestMgmtClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armloadtesting.LoadTestMgmtClientListByResourceGroupOptions) (resp azfake.PagerResponder[armloadtesting.LoadTestMgmtClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method LoadTestMgmtClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armloadtesting.LoadTestMgmtClientListBySubscriptionOptions) (resp azfake.PagerResponder[armloadtesting.LoadTestMgmtClientListBySubscriptionResponse]) + + // NewListQuotaPager is the fake for method LoadTestMgmtClient.NewListQuotaPager + // HTTP status codes to indicate success: http.StatusOK + NewListQuotaPager func(location string, options *armloadtesting.LoadTestMgmtClientListQuotaOptions) (resp azfake.PagerResponder[armloadtesting.LoadTestMgmtClientListQuotaResponse]) + + // NewOutboundNetworkDependenciesEndpointsPager is the fake for method LoadTestMgmtClient.NewOutboundNetworkDependenciesEndpointsPager + // HTTP status codes to indicate success: http.StatusOK + NewOutboundNetworkDependenciesEndpointsPager func(resourceGroupName string, loadTestName string, options *armloadtesting.LoadTestMgmtClientOutboundNetworkDependenciesEndpointsOptions) (resp azfake.PagerResponder[armloadtesting.LoadTestMgmtClientOutboundNetworkDependenciesEndpointsResponse]) + + // BeginUpdateLoadtest is the fake for method LoadTestMgmtClient.BeginUpdateLoadtest + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginUpdateLoadtest func(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResourcePatchRequestBody armloadtesting.LoadTestResourceUpdate, options *armloadtesting.LoadTestMgmtClientBeginUpdateLoadtestOptions) (resp azfake.PollerResponder[armloadtesting.LoadTestMgmtClientUpdateLoadtestResponse], errResp azfake.ErrorResponder) +} + +// NewLoadTestMgmtServerTransport creates a new instance of LoadTestMgmtServerTransport with the provided implementation. +// The returned LoadTestMgmtServerTransport instance is connected to an instance of armloadtesting.LoadTestMgmtClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewLoadTestMgmtServerTransport(srv *LoadTestMgmtServer) *LoadTestMgmtServerTransport { + return &LoadTestMgmtServerTransport{ + srv: srv, + beginCreateOrUpdateLoadtest: newTracker[azfake.PollerResponder[armloadtesting.LoadTestMgmtClientCreateOrUpdateLoadtestResponse]](), + beginDeleteLoadtest: newTracker[azfake.PollerResponder[armloadtesting.LoadTestMgmtClientDeleteLoadtestResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armloadtesting.LoadTestMgmtClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armloadtesting.LoadTestMgmtClientListBySubscriptionResponse]](), + newListQuotaPager: newTracker[azfake.PagerResponder[armloadtesting.LoadTestMgmtClientListQuotaResponse]](), + newOutboundNetworkDependenciesEndpointsPager: newTracker[azfake.PagerResponder[armloadtesting.LoadTestMgmtClientOutboundNetworkDependenciesEndpointsResponse]](), + beginUpdateLoadtest: newTracker[azfake.PollerResponder[armloadtesting.LoadTestMgmtClientUpdateLoadtestResponse]](), + } +} + +// LoadTestMgmtServerTransport connects instances of armloadtesting.LoadTestMgmtClient to instances of LoadTestMgmtServer. +// Don't use this type directly, use NewLoadTestMgmtServerTransport instead. +type LoadTestMgmtServerTransport struct { + srv *LoadTestMgmtServer + beginCreateOrUpdateLoadtest *tracker[azfake.PollerResponder[armloadtesting.LoadTestMgmtClientCreateOrUpdateLoadtestResponse]] + beginDeleteLoadtest *tracker[azfake.PollerResponder[armloadtesting.LoadTestMgmtClientDeleteLoadtestResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armloadtesting.LoadTestMgmtClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armloadtesting.LoadTestMgmtClientListBySubscriptionResponse]] + newListQuotaPager *tracker[azfake.PagerResponder[armloadtesting.LoadTestMgmtClientListQuotaResponse]] + newOutboundNetworkDependenciesEndpointsPager *tracker[azfake.PagerResponder[armloadtesting.LoadTestMgmtClientOutboundNetworkDependenciesEndpointsResponse]] + beginUpdateLoadtest *tracker[azfake.PollerResponder[armloadtesting.LoadTestMgmtClientUpdateLoadtestResponse]] +} + +// Do implements the policy.Transporter interface for LoadTestMgmtServerTransport. +func (l *LoadTestMgmtServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return l.dispatchToMethodFake(req, method) +} + +func (l *LoadTestMgmtServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if loadTestMgmtServerTransportInterceptor != nil { + res.resp, res.err, intercepted = loadTestMgmtServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "LoadTestMgmtClient.CheckAvailabilityQuota": + res.resp, res.err = l.dispatchCheckAvailabilityQuota(req) + case "LoadTestMgmtClient.BeginCreateOrUpdateLoadtest": + res.resp, res.err = l.dispatchBeginCreateOrUpdateLoadtest(req) + case "LoadTestMgmtClient.BeginDeleteLoadtest": + res.resp, res.err = l.dispatchBeginDeleteLoadtest(req) + case "LoadTestMgmtClient.GetLoadtest": + res.resp, res.err = l.dispatchGetLoadtest(req) + case "LoadTestMgmtClient.GetQuota": + res.resp, res.err = l.dispatchGetQuota(req) + case "LoadTestMgmtClient.NewListByResourceGroupPager": + res.resp, res.err = l.dispatchNewListByResourceGroupPager(req) + case "LoadTestMgmtClient.NewListBySubscriptionPager": + res.resp, res.err = l.dispatchNewListBySubscriptionPager(req) + case "LoadTestMgmtClient.NewListQuotaPager": + res.resp, res.err = l.dispatchNewListQuotaPager(req) + case "LoadTestMgmtClient.NewOutboundNetworkDependenciesEndpointsPager": + res.resp, res.err = l.dispatchNewOutboundNetworkDependenciesEndpointsPager(req) + case "LoadTestMgmtClient.BeginUpdateLoadtest": + res.resp, res.err = l.dispatchBeginUpdateLoadtest(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (l *LoadTestMgmtServerTransport) dispatchCheckAvailabilityQuota(req *http.Request) (*http.Response, error) { + if l.srv.CheckAvailabilityQuota == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckAvailabilityQuota not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/quotas/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkAvailabilityQuota` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armloadtesting.QuotaBucketRequest](req) + if err != nil { + return nil, err + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + quotaBucketNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("quotaBucketName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.CheckAvailabilityQuota(req.Context(), locationParam, quotaBucketNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CheckQuotaAvailabilityResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (l *LoadTestMgmtServerTransport) dispatchBeginCreateOrUpdateLoadtest(req *http.Request) (*http.Response, error) { + if l.srv.BeginCreateOrUpdateLoadtest == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdateLoadtest not implemented")} + } + beginCreateOrUpdateLoadtest := l.beginCreateOrUpdateLoadtest.get(req) + if beginCreateOrUpdateLoadtest == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/loadTests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armloadtesting.LoadTestResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + loadTestNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadTestName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.BeginCreateOrUpdateLoadtest(req.Context(), resourceGroupNameParam, loadTestNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdateLoadtest = &respr + l.beginCreateOrUpdateLoadtest.add(req, beginCreateOrUpdateLoadtest) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdateLoadtest, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + l.beginCreateOrUpdateLoadtest.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdateLoadtest) { + l.beginCreateOrUpdateLoadtest.remove(req) + } + + return resp, nil +} + +func (l *LoadTestMgmtServerTransport) dispatchBeginDeleteLoadtest(req *http.Request) (*http.Response, error) { + if l.srv.BeginDeleteLoadtest == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDeleteLoadtest not implemented")} + } + beginDeleteLoadtest := l.beginDeleteLoadtest.get(req) + if beginDeleteLoadtest == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/loadTests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + loadTestNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadTestName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.BeginDeleteLoadtest(req.Context(), resourceGroupNameParam, loadTestNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDeleteLoadtest = &respr + l.beginDeleteLoadtest.add(req, beginDeleteLoadtest) + } + + resp, err := server.PollerResponderNext(beginDeleteLoadtest, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + l.beginDeleteLoadtest.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDeleteLoadtest) { + l.beginDeleteLoadtest.remove(req) + } + + return resp, nil +} + +func (l *LoadTestMgmtServerTransport) dispatchGetLoadtest(req *http.Request) (*http.Response, error) { + if l.srv.GetLoadtest == nil { + return nil, &nonRetriableError{errors.New("fake for method GetLoadtest not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/loadTests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + loadTestNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadTestName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.GetLoadtest(req.Context(), resourceGroupNameParam, loadTestNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).LoadTestResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (l *LoadTestMgmtServerTransport) dispatchGetQuota(req *http.Request) (*http.Response, error) { + if l.srv.GetQuota == nil { + return nil, &nonRetriableError{errors.New("fake for method GetQuota not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/quotas/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + quotaBucketNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("quotaBucketName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.GetQuota(req.Context(), locationParam, quotaBucketNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).QuotaResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (l *LoadTestMgmtServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if l.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := l.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/loadTests` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := l.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + l.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armloadtesting.LoadTestMgmtClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + l.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + l.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (l *LoadTestMgmtServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if l.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := l.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/loadTests` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := l.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + l.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armloadtesting.LoadTestMgmtClientListBySubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + l.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + l.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (l *LoadTestMgmtServerTransport) dispatchNewListQuotaPager(req *http.Request) (*http.Response, error) { + if l.srv.NewListQuotaPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListQuotaPager not implemented")} + } + newListQuotaPager := l.newListQuotaPager.get(req) + if newListQuotaPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/quotas` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + resp := l.srv.NewListQuotaPager(locationParam, nil) + newListQuotaPager = &resp + l.newListQuotaPager.add(req, newListQuotaPager) + server.PagerResponderInjectNextLinks(newListQuotaPager, req, func(page *armloadtesting.LoadTestMgmtClientListQuotaResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListQuotaPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + l.newListQuotaPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListQuotaPager) { + l.newListQuotaPager.remove(req) + } + return resp, nil +} + +func (l *LoadTestMgmtServerTransport) dispatchNewOutboundNetworkDependenciesEndpointsPager(req *http.Request) (*http.Response, error) { + if l.srv.NewOutboundNetworkDependenciesEndpointsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewOutboundNetworkDependenciesEndpointsPager not implemented")} + } + newOutboundNetworkDependenciesEndpointsPager := l.newOutboundNetworkDependenciesEndpointsPager.get(req) + if newOutboundNetworkDependenciesEndpointsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/loadTests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/outboundNetworkDependenciesEndpoints` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + loadTestNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadTestName")]) + if err != nil { + return nil, err + } + resp := l.srv.NewOutboundNetworkDependenciesEndpointsPager(resourceGroupNameParam, loadTestNameParam, nil) + newOutboundNetworkDependenciesEndpointsPager = &resp + l.newOutboundNetworkDependenciesEndpointsPager.add(req, newOutboundNetworkDependenciesEndpointsPager) + server.PagerResponderInjectNextLinks(newOutboundNetworkDependenciesEndpointsPager, req, func(page *armloadtesting.LoadTestMgmtClientOutboundNetworkDependenciesEndpointsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newOutboundNetworkDependenciesEndpointsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + l.newOutboundNetworkDependenciesEndpointsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newOutboundNetworkDependenciesEndpointsPager) { + l.newOutboundNetworkDependenciesEndpointsPager.remove(req) + } + return resp, nil +} + +func (l *LoadTestMgmtServerTransport) dispatchBeginUpdateLoadtest(req *http.Request) (*http.Response, error) { + if l.srv.BeginUpdateLoadtest == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdateLoadtest not implemented")} + } + beginUpdateLoadtest := l.beginUpdateLoadtest.get(req) + if beginUpdateLoadtest == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/loadTests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armloadtesting.LoadTestResourceUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + loadTestNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadTestName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.BeginUpdateLoadtest(req.Context(), resourceGroupNameParam, loadTestNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdateLoadtest = &respr + l.beginUpdateLoadtest.add(req, beginUpdateLoadtest) + } + + resp, err := server.PollerResponderNext(beginUpdateLoadtest, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + l.beginUpdateLoadtest.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdateLoadtest) { + l.beginUpdateLoadtest.remove(req) + } + + return resp, nil +} + +// set this to conditionally intercept incoming requests to LoadTestMgmtServerTransport +var loadTestMgmtServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/fake/loadtests_server.go b/sdk/resourcemanager/loadtesting/armloadtesting/fake/loadtests_server.go deleted file mode 100644 index 262e95a6be41..000000000000 --- a/sdk/resourcemanager/loadtesting/armloadtesting/fake/loadtests_server.go +++ /dev/null @@ -1,402 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtesting/armloadtesting" - "net/http" - "net/url" - "regexp" -) - -// LoadTestsServer is a fake server for instances of the armloadtesting.LoadTestsClient type. -type LoadTestsServer struct { - // BeginCreateOrUpdate is the fake for method LoadTestsClient.BeginCreateOrUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated - BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResource armloadtesting.LoadTestResource, options *armloadtesting.LoadTestsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armloadtesting.LoadTestsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) - - // BeginDelete is the fake for method LoadTestsClient.BeginDelete - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent - BeginDelete func(ctx context.Context, resourceGroupName string, loadTestName string, options *armloadtesting.LoadTestsClientBeginDeleteOptions) (resp azfake.PollerResponder[armloadtesting.LoadTestsClientDeleteResponse], errResp azfake.ErrorResponder) - - // Get is the fake for method LoadTestsClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, resourceGroupName string, loadTestName string, options *armloadtesting.LoadTestsClientGetOptions) (resp azfake.Responder[armloadtesting.LoadTestsClientGetResponse], errResp azfake.ErrorResponder) - - // NewListByResourceGroupPager is the fake for method LoadTestsClient.NewListByResourceGroupPager - // HTTP status codes to indicate success: http.StatusOK - NewListByResourceGroupPager func(resourceGroupName string, options *armloadtesting.LoadTestsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armloadtesting.LoadTestsClientListByResourceGroupResponse]) - - // NewListBySubscriptionPager is the fake for method LoadTestsClient.NewListBySubscriptionPager - // HTTP status codes to indicate success: http.StatusOK - NewListBySubscriptionPager func(options *armloadtesting.LoadTestsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armloadtesting.LoadTestsClientListBySubscriptionResponse]) - - // NewListOutboundNetworkDependenciesEndpointsPager is the fake for method LoadTestsClient.NewListOutboundNetworkDependenciesEndpointsPager - // HTTP status codes to indicate success: http.StatusOK - NewListOutboundNetworkDependenciesEndpointsPager func(resourceGroupName string, loadTestName string, options *armloadtesting.LoadTestsClientListOutboundNetworkDependenciesEndpointsOptions) (resp azfake.PagerResponder[armloadtesting.LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse]) - - // BeginUpdate is the fake for method LoadTestsClient.BeginUpdate - // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted - BeginUpdate func(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResourcePatchRequestBody armloadtesting.LoadTestResourcePatchRequestBody, options *armloadtesting.LoadTestsClientBeginUpdateOptions) (resp azfake.PollerResponder[armloadtesting.LoadTestsClientUpdateResponse], errResp azfake.ErrorResponder) -} - -// NewLoadTestsServerTransport creates a new instance of LoadTestsServerTransport with the provided implementation. -// The returned LoadTestsServerTransport instance is connected to an instance of armloadtesting.LoadTestsClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewLoadTestsServerTransport(srv *LoadTestsServer) *LoadTestsServerTransport { - return &LoadTestsServerTransport{ - srv: srv, - beginCreateOrUpdate: newTracker[azfake.PollerResponder[armloadtesting.LoadTestsClientCreateOrUpdateResponse]](), - beginDelete: newTracker[azfake.PollerResponder[armloadtesting.LoadTestsClientDeleteResponse]](), - newListByResourceGroupPager: newTracker[azfake.PagerResponder[armloadtesting.LoadTestsClientListByResourceGroupResponse]](), - newListBySubscriptionPager: newTracker[azfake.PagerResponder[armloadtesting.LoadTestsClientListBySubscriptionResponse]](), - newListOutboundNetworkDependenciesEndpointsPager: newTracker[azfake.PagerResponder[armloadtesting.LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse]](), - beginUpdate: newTracker[azfake.PollerResponder[armloadtesting.LoadTestsClientUpdateResponse]](), - } -} - -// LoadTestsServerTransport connects instances of armloadtesting.LoadTestsClient to instances of LoadTestsServer. -// Don't use this type directly, use NewLoadTestsServerTransport instead. -type LoadTestsServerTransport struct { - srv *LoadTestsServer - beginCreateOrUpdate *tracker[azfake.PollerResponder[armloadtesting.LoadTestsClientCreateOrUpdateResponse]] - beginDelete *tracker[azfake.PollerResponder[armloadtesting.LoadTestsClientDeleteResponse]] - newListByResourceGroupPager *tracker[azfake.PagerResponder[armloadtesting.LoadTestsClientListByResourceGroupResponse]] - newListBySubscriptionPager *tracker[azfake.PagerResponder[armloadtesting.LoadTestsClientListBySubscriptionResponse]] - newListOutboundNetworkDependenciesEndpointsPager *tracker[azfake.PagerResponder[armloadtesting.LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse]] - beginUpdate *tracker[azfake.PollerResponder[armloadtesting.LoadTestsClientUpdateResponse]] -} - -// Do implements the policy.Transporter interface for LoadTestsServerTransport. -func (l *LoadTestsServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - var resp *http.Response - var err error - - switch method { - case "LoadTestsClient.BeginCreateOrUpdate": - resp, err = l.dispatchBeginCreateOrUpdate(req) - case "LoadTestsClient.BeginDelete": - resp, err = l.dispatchBeginDelete(req) - case "LoadTestsClient.Get": - resp, err = l.dispatchGet(req) - case "LoadTestsClient.NewListByResourceGroupPager": - resp, err = l.dispatchNewListByResourceGroupPager(req) - case "LoadTestsClient.NewListBySubscriptionPager": - resp, err = l.dispatchNewListBySubscriptionPager(req) - case "LoadTestsClient.NewListOutboundNetworkDependenciesEndpointsPager": - resp, err = l.dispatchNewListOutboundNetworkDependenciesEndpointsPager(req) - case "LoadTestsClient.BeginUpdate": - resp, err = l.dispatchBeginUpdate(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (l *LoadTestsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { - if l.srv.BeginCreateOrUpdate == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} - } - beginCreateOrUpdate := l.beginCreateOrUpdate.get(req) - if beginCreateOrUpdate == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/loadTests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armloadtesting.LoadTestResource](req) - if err != nil { - return nil, err - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - loadTestNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadTestName")]) - if err != nil { - return nil, err - } - respr, errRespr := l.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, loadTestNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - beginCreateOrUpdate = &respr - l.beginCreateOrUpdate.add(req, beginCreateOrUpdate) - } - - resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) - if err != nil { - return nil, err - } - - if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { - l.beginCreateOrUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} - } - if !server.PollerResponderMore(beginCreateOrUpdate) { - l.beginCreateOrUpdate.remove(req) - } - - return resp, nil -} - -func (l *LoadTestsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { - if l.srv.BeginDelete == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} - } - beginDelete := l.beginDelete.get(req) - if beginDelete == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/loadTests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - loadTestNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadTestName")]) - if err != nil { - return nil, err - } - respr, errRespr := l.srv.BeginDelete(req.Context(), resourceGroupNameParam, loadTestNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - beginDelete = &respr - l.beginDelete.add(req, beginDelete) - } - - resp, err := server.PollerResponderNext(beginDelete, req) - if err != nil { - return nil, err - } - - if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { - l.beginDelete.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} - } - if !server.PollerResponderMore(beginDelete) { - l.beginDelete.remove(req) - } - - return resp, nil -} - -func (l *LoadTestsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if l.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/loadTests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - loadTestNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadTestName")]) - if err != nil { - return nil, err - } - respr, errRespr := l.srv.Get(req.Context(), resourceGroupNameParam, loadTestNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).LoadTestResource, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (l *LoadTestsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { - if l.srv.NewListByResourceGroupPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} - } - newListByResourceGroupPager := l.newListByResourceGroupPager.get(req) - if newListByResourceGroupPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/loadTests` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - resp := l.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) - newListByResourceGroupPager = &resp - l.newListByResourceGroupPager.add(req, newListByResourceGroupPager) - server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armloadtesting.LoadTestsClientListByResourceGroupResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - l.newListByResourceGroupPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListByResourceGroupPager) { - l.newListByResourceGroupPager.remove(req) - } - return resp, nil -} - -func (l *LoadTestsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { - if l.srv.NewListBySubscriptionPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} - } - newListBySubscriptionPager := l.newListBySubscriptionPager.get(req) - if newListBySubscriptionPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/loadTests` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resp := l.srv.NewListBySubscriptionPager(nil) - newListBySubscriptionPager = &resp - l.newListBySubscriptionPager.add(req, newListBySubscriptionPager) - server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armloadtesting.LoadTestsClientListBySubscriptionResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - l.newListBySubscriptionPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListBySubscriptionPager) { - l.newListBySubscriptionPager.remove(req) - } - return resp, nil -} - -func (l *LoadTestsServerTransport) dispatchNewListOutboundNetworkDependenciesEndpointsPager(req *http.Request) (*http.Response, error) { - if l.srv.NewListOutboundNetworkDependenciesEndpointsPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListOutboundNetworkDependenciesEndpointsPager not implemented")} - } - newListOutboundNetworkDependenciesEndpointsPager := l.newListOutboundNetworkDependenciesEndpointsPager.get(req) - if newListOutboundNetworkDependenciesEndpointsPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/loadTests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/outboundNetworkDependenciesEndpoints` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - loadTestNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadTestName")]) - if err != nil { - return nil, err - } - resp := l.srv.NewListOutboundNetworkDependenciesEndpointsPager(resourceGroupNameParam, loadTestNameParam, nil) - newListOutboundNetworkDependenciesEndpointsPager = &resp - l.newListOutboundNetworkDependenciesEndpointsPager.add(req, newListOutboundNetworkDependenciesEndpointsPager) - server.PagerResponderInjectNextLinks(newListOutboundNetworkDependenciesEndpointsPager, req, func(page *armloadtesting.LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListOutboundNetworkDependenciesEndpointsPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - l.newListOutboundNetworkDependenciesEndpointsPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListOutboundNetworkDependenciesEndpointsPager) { - l.newListOutboundNetworkDependenciesEndpointsPager.remove(req) - } - return resp, nil -} - -func (l *LoadTestsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { - if l.srv.BeginUpdate == nil { - return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} - } - beginUpdate := l.beginUpdate.get(req) - if beginUpdate == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/loadTests/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armloadtesting.LoadTestResourcePatchRequestBody](req) - if err != nil { - return nil, err - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - loadTestNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("loadTestName")]) - if err != nil { - return nil, err - } - respr, errRespr := l.srv.BeginUpdate(req.Context(), resourceGroupNameParam, loadTestNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - beginUpdate = &respr - l.beginUpdate.add(req, beginUpdate) - } - - resp, err := server.PollerResponderNext(beginUpdate, req) - if err != nil { - return nil, err - } - - if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { - l.beginUpdate.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} - } - if !server.PollerResponderMore(beginUpdate) { - l.beginUpdate.remove(req) - } - - return resp, nil -} diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/fake/quotas_server.go b/sdk/resourcemanager/loadtesting/armloadtesting/fake/quotas_server.go deleted file mode 100644 index 660c2aa50377..000000000000 --- a/sdk/resourcemanager/loadtesting/armloadtesting/fake/quotas_server.go +++ /dev/null @@ -1,191 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package fake - -import ( - "context" - "errors" - "fmt" - azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtesting/armloadtesting" - "net/http" - "net/url" - "regexp" -) - -// QuotasServer is a fake server for instances of the armloadtesting.QuotasClient type. -type QuotasServer struct { - // CheckAvailability is the fake for method QuotasClient.CheckAvailability - // HTTP status codes to indicate success: http.StatusOK - CheckAvailability func(ctx context.Context, location string, quotaBucketName string, quotaBucketRequest armloadtesting.QuotaBucketRequest, options *armloadtesting.QuotasClientCheckAvailabilityOptions) (resp azfake.Responder[armloadtesting.QuotasClientCheckAvailabilityResponse], errResp azfake.ErrorResponder) - - // Get is the fake for method QuotasClient.Get - // HTTP status codes to indicate success: http.StatusOK - Get func(ctx context.Context, location string, quotaBucketName string, options *armloadtesting.QuotasClientGetOptions) (resp azfake.Responder[armloadtesting.QuotasClientGetResponse], errResp azfake.ErrorResponder) - - // NewListPager is the fake for method QuotasClient.NewListPager - // HTTP status codes to indicate success: http.StatusOK - NewListPager func(location string, options *armloadtesting.QuotasClientListOptions) (resp azfake.PagerResponder[armloadtesting.QuotasClientListResponse]) -} - -// NewQuotasServerTransport creates a new instance of QuotasServerTransport with the provided implementation. -// The returned QuotasServerTransport instance is connected to an instance of armloadtesting.QuotasClient via the -// azcore.ClientOptions.Transporter field in the client's constructor parameters. -func NewQuotasServerTransport(srv *QuotasServer) *QuotasServerTransport { - return &QuotasServerTransport{ - srv: srv, - newListPager: newTracker[azfake.PagerResponder[armloadtesting.QuotasClientListResponse]](), - } -} - -// QuotasServerTransport connects instances of armloadtesting.QuotasClient to instances of QuotasServer. -// Don't use this type directly, use NewQuotasServerTransport instead. -type QuotasServerTransport struct { - srv *QuotasServer - newListPager *tracker[azfake.PagerResponder[armloadtesting.QuotasClientListResponse]] -} - -// Do implements the policy.Transporter interface for QuotasServerTransport. -func (q *QuotasServerTransport) Do(req *http.Request) (*http.Response, error) { - rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) - method, ok := rawMethod.(string) - if !ok { - return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} - } - - var resp *http.Response - var err error - - switch method { - case "QuotasClient.CheckAvailability": - resp, err = q.dispatchCheckAvailability(req) - case "QuotasClient.Get": - resp, err = q.dispatchGet(req) - case "QuotasClient.NewListPager": - resp, err = q.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } - - if err != nil { - return nil, err - } - - return resp, nil -} - -func (q *QuotasServerTransport) dispatchCheckAvailability(req *http.Request) (*http.Response, error) { - if q.srv.CheckAvailability == nil { - return nil, &nonRetriableError{errors.New("fake for method CheckAvailability not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/quotas/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkAvailability` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - body, err := server.UnmarshalRequestAsJSON[armloadtesting.QuotaBucketRequest](req) - if err != nil { - return nil, err - } - locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) - if err != nil { - return nil, err - } - quotaBucketNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("quotaBucketName")]) - if err != nil { - return nil, err - } - respr, errRespr := q.srv.CheckAvailability(req.Context(), locationParam, quotaBucketNameParam, body, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CheckQuotaAvailabilityResponse, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (q *QuotasServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { - if q.srv.Get == nil { - return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/quotas/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) - if err != nil { - return nil, err - } - quotaBucketNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("quotaBucketName")]) - if err != nil { - return nil, err - } - respr, errRespr := q.srv.Get(req.Context(), locationParam, quotaBucketNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).QuotaResource, req) - if err != nil { - return nil, err - } - return resp, nil -} - -func (q *QuotasServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { - if q.srv.NewListPager == nil { - return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} - } - newListPager := q.newListPager.get(req) - if newListPager == nil { - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/quotas` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) - if err != nil { - return nil, err - } - resp := q.srv.NewListPager(locationParam, nil) - newListPager = &resp - q.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armloadtesting.QuotasClientListResponse, createLink func() string) { - page.NextLink = to.Ptr(createLink()) - }) - } - resp, err := server.PagerResponderNext(newListPager, req) - if err != nil { - return nil, err - } - if !contains([]int{http.StatusOK}, resp.StatusCode) { - q.newListPager.remove(req) - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} - } - if !server.PagerResponderMore(newListPager) { - q.newListPager.remove(req) - } - return resp, nil -} diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/fake/server_factory.go b/sdk/resourcemanager/loadtesting/armloadtesting/fake/server_factory.go index d66885eec88a..31e7275d7f60 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/fake/server_factory.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/fake/server_factory.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -19,9 +15,8 @@ import ( // ServerFactory is a fake server for instances of the armloadtesting.ClientFactory type. type ServerFactory struct { - LoadTestsServer LoadTestsServer - OperationsServer OperationsServer - QuotasServer QuotasServer + // LoadTestMgmtServer contains the fakes for client LoadTestMgmtClient + LoadTestMgmtServer LoadTestMgmtServer } // NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. @@ -36,11 +31,9 @@ func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { // ServerFactoryTransport connects instances of armloadtesting.ClientFactory to instances of ServerFactory. // Don't use this type directly, use NewServerFactoryTransport instead. type ServerFactoryTransport struct { - srv *ServerFactory - trMu sync.Mutex - trLoadTestsServer *LoadTestsServerTransport - trOperationsServer *OperationsServerTransport - trQuotasServer *QuotasServerTransport + srv *ServerFactory + trMu sync.Mutex + trLoadTestMgmtServer *LoadTestMgmtServerTransport } // Do implements the policy.Transporter interface for ServerFactoryTransport. @@ -56,15 +49,9 @@ func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { var err error switch client { - case "LoadTestsClient": - initServer(s, &s.trLoadTestsServer, func() *LoadTestsServerTransport { return NewLoadTestsServerTransport(&s.srv.LoadTestsServer) }) - resp, err = s.trLoadTestsServer.Do(req) - case "OperationsClient": - initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) - resp, err = s.trOperationsServer.Do(req) - case "QuotasClient": - initServer(s, &s.trQuotasServer, func() *QuotasServerTransport { return NewQuotasServerTransport(&s.srv.QuotasServer) }) - resp, err = s.trQuotasServer.Do(req) + case "LoadTestMgmtClient": + initServer(s, &s.trLoadTestMgmtServer, func() *LoadTestMgmtServerTransport { return NewLoadTestMgmtServerTransport(&s.srv.LoadTestMgmtServer) }) + resp, err = s.trLoadTestMgmtServer.Do(req) default: err = fmt.Errorf("unhandled client %s", client) } diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/fake/time_rfc3339.go b/sdk/resourcemanager/loadtesting/armloadtesting/fake/time_rfc3339.go index b0535a7b63e6..87ee11e83b32 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/fake/time_rfc3339.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/fake/time_rfc3339.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -19,12 +15,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +40,36 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +80,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +97,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/go.mod b/sdk/resourcemanager/loadtesting/armloadtesting/go.mod index 22ece1426177..fe783f27a7e8 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/go.mod +++ b/sdk/resourcemanager/loadtesting/armloadtesting/go.mod @@ -1,4 +1,4 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtesting/armloadtesting +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtesting/armloadtesting/v2 go 1.23.0 diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/loadtestmgmt_client.go b/sdk/resourcemanager/loadtesting/armloadtesting/loadtestmgmt_client.go new file mode 100644 index 000000000000..1119de8e7748 --- /dev/null +++ b/sdk/resourcemanager/loadtesting/armloadtesting/loadtestmgmt_client.go @@ -0,0 +1,717 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armloadtesting + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// LoadTestMgmtClient contains the methods for the LoadTestMgmt group. +// Don't use this type directly, use NewLoadTestMgmtClient() instead. +type LoadTestMgmtClient struct { + internal *arm.Client + subscriptionID string +} + +// NewLoadTestMgmtClient creates a new instance of LoadTestMgmtClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewLoadTestMgmtClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LoadTestMgmtClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &LoadTestMgmtClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CheckAvailabilityQuota - Check Quota Availability on quota bucket per region per subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-12-01-preview +// - location - The name of the Azure region. +// - quotaBucketName - The quota name. +// - quotaBucketRequest - The content of the action request +// - options - LoadTestMgmtClientCheckAvailabilityQuotaOptions contains the optional parameters for the LoadTestMgmtClient.CheckAvailabilityQuota +// method. +func (client *LoadTestMgmtClient) CheckAvailabilityQuota(ctx context.Context, location string, quotaBucketName string, quotaBucketRequest QuotaBucketRequest, options *LoadTestMgmtClientCheckAvailabilityQuotaOptions) (LoadTestMgmtClientCheckAvailabilityQuotaResponse, error) { + var err error + const operationName = "LoadTestMgmtClient.CheckAvailabilityQuota" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.checkAvailabilityQuotaCreateRequest(ctx, location, quotaBucketName, quotaBucketRequest, options) + if err != nil { + return LoadTestMgmtClientCheckAvailabilityQuotaResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return LoadTestMgmtClientCheckAvailabilityQuotaResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return LoadTestMgmtClientCheckAvailabilityQuotaResponse{}, err + } + resp, err := client.checkAvailabilityQuotaHandleResponse(httpResp) + return resp, err +} + +// checkAvailabilityQuotaCreateRequest creates the CheckAvailabilityQuota request. +func (client *LoadTestMgmtClient) checkAvailabilityQuotaCreateRequest(ctx context.Context, location string, quotaBucketName string, quotaBucketRequest QuotaBucketRequest, _ *LoadTestMgmtClientCheckAvailabilityQuotaOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/locations/{location}/quotas/{quotaBucketName}/checkAvailabilityQuota" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if quotaBucketName == "" { + return nil, errors.New("parameter quotaBucketName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{quotaBucketName}", url.PathEscape(quotaBucketName)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, quotaBucketRequest); err != nil { + return nil, err + } + return req, nil +} + +// checkAvailabilityQuotaHandleResponse handles the CheckAvailabilityQuota response. +func (client *LoadTestMgmtClient) checkAvailabilityQuotaHandleResponse(resp *http.Response) (LoadTestMgmtClientCheckAvailabilityQuotaResponse, error) { + result := LoadTestMgmtClientCheckAvailabilityQuotaResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckQuotaAvailabilityResponse); err != nil { + return LoadTestMgmtClientCheckAvailabilityQuotaResponse{}, err + } + return result, nil +} + +// BeginCreateOrUpdateLoadtest - Create a LoadTestResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - loadTestName - Load Test name +// - loadTestResource - Resource create parameters. +// - options - LoadTestMgmtClientBeginCreateOrUpdateLoadtestOptions contains the optional parameters for the LoadTestMgmtClient.BeginCreateOrUpdateLoadtest +// method. +func (client *LoadTestMgmtClient) BeginCreateOrUpdateLoadtest(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResource LoadTestResource, options *LoadTestMgmtClientBeginCreateOrUpdateLoadtestOptions) (*runtime.Poller[LoadTestMgmtClientCreateOrUpdateLoadtestResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdateLoadtest(ctx, resourceGroupName, loadTestName, loadTestResource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LoadTestMgmtClientCreateOrUpdateLoadtestResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LoadTestMgmtClientCreateOrUpdateLoadtestResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdateLoadtest - Create a LoadTestResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-12-01-preview +func (client *LoadTestMgmtClient) createOrUpdateLoadtest(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResource LoadTestResource, options *LoadTestMgmtClientBeginCreateOrUpdateLoadtestOptions) (*http.Response, error) { + var err error + const operationName = "LoadTestMgmtClient.BeginCreateOrUpdateLoadtest" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateLoadtestCreateRequest(ctx, resourceGroupName, loadTestName, loadTestResource, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateLoadtestCreateRequest creates the CreateOrUpdateLoadtest request. +func (client *LoadTestMgmtClient) createOrUpdateLoadtestCreateRequest(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResource LoadTestResource, _ *LoadTestMgmtClientBeginCreateOrUpdateLoadtestOptions) (*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") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if loadTestName == "" { + return nil, errors.New("parameter loadTestName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loadTestName}", url.PathEscape(loadTestName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, loadTestResource); err != nil { + return nil, err + } + return req, nil +} + +// BeginDeleteLoadtest - Delete a LoadTestResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - loadTestName - Load Test name +// - options - LoadTestMgmtClientBeginDeleteLoadtestOptions contains the optional parameters for the LoadTestMgmtClient.BeginDeleteLoadtest +// method. +func (client *LoadTestMgmtClient) BeginDeleteLoadtest(ctx context.Context, resourceGroupName string, loadTestName string, options *LoadTestMgmtClientBeginDeleteLoadtestOptions) (*runtime.Poller[LoadTestMgmtClientDeleteLoadtestResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteLoadtest(ctx, resourceGroupName, loadTestName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LoadTestMgmtClientDeleteLoadtestResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LoadTestMgmtClientDeleteLoadtestResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// DeleteLoadtest - Delete a LoadTestResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-12-01-preview +func (client *LoadTestMgmtClient) deleteLoadtest(ctx context.Context, resourceGroupName string, loadTestName string, options *LoadTestMgmtClientBeginDeleteLoadtestOptions) (*http.Response, error) { + var err error + const operationName = "LoadTestMgmtClient.BeginDeleteLoadtest" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteLoadtestCreateRequest(ctx, resourceGroupName, loadTestName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteLoadtestCreateRequest creates the DeleteLoadtest request. +func (client *LoadTestMgmtClient) deleteLoadtestCreateRequest(ctx context.Context, resourceGroupName string, loadTestName string, _ *LoadTestMgmtClientBeginDeleteLoadtestOptions) (*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") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if loadTestName == "" { + return nil, errors.New("parameter loadTestName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loadTestName}", url.PathEscape(loadTestName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// GetLoadtest - Get a LoadTestResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - loadTestName - Load Test name +// - options - LoadTestMgmtClientGetLoadtestOptions contains the optional parameters for the LoadTestMgmtClient.GetLoadtest +// method. +func (client *LoadTestMgmtClient) GetLoadtest(ctx context.Context, resourceGroupName string, loadTestName string, options *LoadTestMgmtClientGetLoadtestOptions) (LoadTestMgmtClientGetLoadtestResponse, error) { + var err error + const operationName = "LoadTestMgmtClient.GetLoadtest" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getLoadtestCreateRequest(ctx, resourceGroupName, loadTestName, options) + if err != nil { + return LoadTestMgmtClientGetLoadtestResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return LoadTestMgmtClientGetLoadtestResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return LoadTestMgmtClientGetLoadtestResponse{}, err + } + resp, err := client.getLoadtestHandleResponse(httpResp) + return resp, err +} + +// getLoadtestCreateRequest creates the GetLoadtest request. +func (client *LoadTestMgmtClient) getLoadtestCreateRequest(ctx context.Context, resourceGroupName string, loadTestName string, _ *LoadTestMgmtClientGetLoadtestOptions) (*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") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if loadTestName == "" { + return nil, errors.New("parameter loadTestName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loadTestName}", url.PathEscape(loadTestName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getLoadtestHandleResponse handles the GetLoadtest response. +func (client *LoadTestMgmtClient) getLoadtestHandleResponse(resp *http.Response) (LoadTestMgmtClientGetLoadtestResponse, error) { + result := LoadTestMgmtClientGetLoadtestResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LoadTestResource); err != nil { + return LoadTestMgmtClientGetLoadtestResponse{}, err + } + return result, nil +} + +// GetQuota - Get the available quota for a quota bucket per region per subscription. +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-12-01-preview +// - location - The name of the Azure region. +// - quotaBucketName - The quota name. +// - options - LoadTestMgmtClientGetQuotaOptions contains the optional parameters for the LoadTestMgmtClient.GetQuota method. +func (client *LoadTestMgmtClient) GetQuota(ctx context.Context, location string, quotaBucketName string, options *LoadTestMgmtClientGetQuotaOptions) (LoadTestMgmtClientGetQuotaResponse, error) { + var err error + const operationName = "LoadTestMgmtClient.GetQuota" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getQuotaCreateRequest(ctx, location, quotaBucketName, options) + if err != nil { + return LoadTestMgmtClientGetQuotaResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return LoadTestMgmtClientGetQuotaResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return LoadTestMgmtClientGetQuotaResponse{}, err + } + resp, err := client.getQuotaHandleResponse(httpResp) + return resp, err +} + +// getQuotaCreateRequest creates the GetQuota request. +func (client *LoadTestMgmtClient) getQuotaCreateRequest(ctx context.Context, location string, quotaBucketName string, _ *LoadTestMgmtClientGetQuotaOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/locations/{location}/quotas/{quotaBucketName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + if quotaBucketName == "" { + return nil, errors.New("parameter quotaBucketName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{quotaBucketName}", url.PathEscape(quotaBucketName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getQuotaHandleResponse handles the GetQuota response. +func (client *LoadTestMgmtClient) getQuotaHandleResponse(resp *http.Response) (LoadTestMgmtClientGetQuotaResponse, error) { + result := LoadTestMgmtClientGetQuotaResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.QuotaResource); err != nil { + return LoadTestMgmtClientGetQuotaResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List LoadTestResource resources by resource group +// +// Generated from API version 2024-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - LoadTestMgmtClientListByResourceGroupOptions contains the optional parameters for the LoadTestMgmtClient.NewListByResourceGroupPager +// method. +func (client *LoadTestMgmtClient) NewListByResourceGroupPager(resourceGroupName string, options *LoadTestMgmtClientListByResourceGroupOptions) *runtime.Pager[LoadTestMgmtClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[LoadTestMgmtClientListByResourceGroupResponse]{ + More: func(page LoadTestMgmtClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *LoadTestMgmtClientListByResourceGroupResponse) (LoadTestMgmtClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "LoadTestMgmtClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return LoadTestMgmtClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *LoadTestMgmtClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *LoadTestMgmtClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *LoadTestMgmtClient) listByResourceGroupHandleResponse(resp *http.Response) (LoadTestMgmtClientListByResourceGroupResponse, error) { + result := LoadTestMgmtClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LoadTestResourceListResult); err != nil { + return LoadTestMgmtClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List LoadTestResource resources by subscription ID +// +// Generated from API version 2024-12-01-preview +// - options - LoadTestMgmtClientListBySubscriptionOptions contains the optional parameters for the LoadTestMgmtClient.NewListBySubscriptionPager +// method. +func (client *LoadTestMgmtClient) NewListBySubscriptionPager(options *LoadTestMgmtClientListBySubscriptionOptions) *runtime.Pager[LoadTestMgmtClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[LoadTestMgmtClientListBySubscriptionResponse]{ + More: func(page LoadTestMgmtClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *LoadTestMgmtClientListBySubscriptionResponse) (LoadTestMgmtClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "LoadTestMgmtClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return LoadTestMgmtClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *LoadTestMgmtClient) listBySubscriptionCreateRequest(ctx context.Context, _ *LoadTestMgmtClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/loadTests" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *LoadTestMgmtClient) listBySubscriptionHandleResponse(resp *http.Response) (LoadTestMgmtClientListBySubscriptionResponse, error) { + result := LoadTestMgmtClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.LoadTestResourceListResult); err != nil { + return LoadTestMgmtClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// NewListQuotaPager - List quotas for a given subscription Id. +// +// Generated from API version 2024-12-01-preview +// - location - The name of the Azure region. +// - options - LoadTestMgmtClientListQuotaOptions contains the optional parameters for the LoadTestMgmtClient.NewListQuotaPager +// method. +func (client *LoadTestMgmtClient) NewListQuotaPager(location string, options *LoadTestMgmtClientListQuotaOptions) *runtime.Pager[LoadTestMgmtClientListQuotaResponse] { + return runtime.NewPager(runtime.PagingHandler[LoadTestMgmtClientListQuotaResponse]{ + More: func(page LoadTestMgmtClientListQuotaResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *LoadTestMgmtClientListQuotaResponse) (LoadTestMgmtClientListQuotaResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "LoadTestMgmtClient.NewListQuotaPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listQuotaCreateRequest(ctx, location, options) + }, nil) + if err != nil { + return LoadTestMgmtClientListQuotaResponse{}, err + } + return client.listQuotaHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listQuotaCreateRequest creates the ListQuota request. +func (client *LoadTestMgmtClient) listQuotaCreateRequest(ctx context.Context, location string, _ *LoadTestMgmtClientListQuotaOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/locations/{location}/quotas" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if location == "" { + return nil, errors.New("parameter location cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listQuotaHandleResponse handles the ListQuota response. +func (client *LoadTestMgmtClient) listQuotaHandleResponse(resp *http.Response) (LoadTestMgmtClientListQuotaResponse, error) { + result := LoadTestMgmtClientListQuotaResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.QuotaResourceListResult); err != nil { + return LoadTestMgmtClientListQuotaResponse{}, err + } + return result, nil +} + +// NewOutboundNetworkDependenciesEndpointsPager - Lists the endpoints that agents may call as part of load testing. +// +// Generated from API version 2024-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - loadTestName - Load Test name +// - options - LoadTestMgmtClientOutboundNetworkDependenciesEndpointsOptions contains the optional parameters for the LoadTestMgmtClient.NewOutboundNetworkDependenciesEndpointsPager +// method. +func (client *LoadTestMgmtClient) NewOutboundNetworkDependenciesEndpointsPager(resourceGroupName string, loadTestName string, options *LoadTestMgmtClientOutboundNetworkDependenciesEndpointsOptions) *runtime.Pager[LoadTestMgmtClientOutboundNetworkDependenciesEndpointsResponse] { + return runtime.NewPager(runtime.PagingHandler[LoadTestMgmtClientOutboundNetworkDependenciesEndpointsResponse]{ + More: func(page LoadTestMgmtClientOutboundNetworkDependenciesEndpointsResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *LoadTestMgmtClientOutboundNetworkDependenciesEndpointsResponse) (LoadTestMgmtClientOutboundNetworkDependenciesEndpointsResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "LoadTestMgmtClient.NewOutboundNetworkDependenciesEndpointsPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.outboundNetworkDependenciesEndpointsCreateRequest(ctx, resourceGroupName, loadTestName, options) + }, nil) + if err != nil { + return LoadTestMgmtClientOutboundNetworkDependenciesEndpointsResponse{}, err + } + return client.outboundNetworkDependenciesEndpointsHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// outboundNetworkDependenciesEndpointsCreateRequest creates the OutboundNetworkDependenciesEndpoints request. +func (client *LoadTestMgmtClient) outboundNetworkDependenciesEndpointsCreateRequest(ctx context.Context, resourceGroupName string, loadTestName string, _ *LoadTestMgmtClientOutboundNetworkDependenciesEndpointsOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests/{loadTestName}/outboundNetworkDependenciesEndpoints" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if loadTestName == "" { + return nil, errors.New("parameter loadTestName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loadTestName}", url.PathEscape(loadTestName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// outboundNetworkDependenciesEndpointsHandleResponse handles the OutboundNetworkDependenciesEndpoints response. +func (client *LoadTestMgmtClient) outboundNetworkDependenciesEndpointsHandleResponse(resp *http.Response) (LoadTestMgmtClientOutboundNetworkDependenciesEndpointsResponse, error) { + result := LoadTestMgmtClientOutboundNetworkDependenciesEndpointsResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.PagedOutboundEnvironmentEndpoint); err != nil { + return LoadTestMgmtClientOutboundNetworkDependenciesEndpointsResponse{}, err + } + return result, nil +} + +// BeginUpdateLoadtest - Update a LoadTestResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-12-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - loadTestName - Load Test name +// - loadTestResourcePatchRequestBody - The resource properties to be updated. +// - options - LoadTestMgmtClientBeginUpdateLoadtestOptions contains the optional parameters for the LoadTestMgmtClient.BeginUpdateLoadtest +// method. +func (client *LoadTestMgmtClient) BeginUpdateLoadtest(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResourcePatchRequestBody LoadTestResourceUpdate, options *LoadTestMgmtClientBeginUpdateLoadtestOptions) (*runtime.Poller[LoadTestMgmtClientUpdateLoadtestResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.updateLoadtest(ctx, resourceGroupName, loadTestName, loadTestResourcePatchRequestBody, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LoadTestMgmtClientUpdateLoadtestResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LoadTestMgmtClientUpdateLoadtestResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// UpdateLoadtest - Update a LoadTestResource +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2024-12-01-preview +func (client *LoadTestMgmtClient) updateLoadtest(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResourcePatchRequestBody LoadTestResourceUpdate, options *LoadTestMgmtClientBeginUpdateLoadtestOptions) (*http.Response, error) { + var err error + const operationName = "LoadTestMgmtClient.BeginUpdateLoadtest" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateLoadtestCreateRequest(ctx, resourceGroupName, loadTestName, loadTestResourcePatchRequestBody, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// updateLoadtestCreateRequest creates the UpdateLoadtest request. +func (client *LoadTestMgmtClient) updateLoadtestCreateRequest(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResourcePatchRequestBody LoadTestResourceUpdate, _ *LoadTestMgmtClientBeginUpdateLoadtestOptions) (*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") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if loadTestName == "" { + return nil, errors.New("parameter loadTestName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{loadTestName}", url.PathEscape(loadTestName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2024-12-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, loadTestResourcePatchRequestBody); err != nil { + return nil, err + } + return req, nil +} diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/loadtestmgmt_client_example_test.go b/sdk/resourcemanager/loadtesting/armloadtesting/loadtestmgmt_client_example_test.go new file mode 100644 index 000000000000..8503d2b3a207 --- /dev/null +++ b/sdk/resourcemanager/loadtesting/armloadtesting/loadtestmgmt_client_example_test.go @@ -0,0 +1,553 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armloadtesting_test + +import ( + "context" + "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/loadtesting/armloadtesting/v2" + "log" +) + +// Generated from example definition: 2024-12-01-preview/Quotas_CheckAvailability.json +func ExampleLoadTestMgmtClient_CheckAvailabilityQuota() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armloadtesting.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewLoadTestMgmtClient().CheckAvailabilityQuota(ctx, "westus", "testQuotaBucket", armloadtesting.QuotaBucketRequest{ + Properties: &armloadtesting.QuotaBucketRequestProperties{ + CurrentUsage: to.Ptr[int32](20), + CurrentQuota: to.Ptr[int32](40), + NewQuota: to.Ptr[int32](50), + Dimensions: &armloadtesting.QuotaBucketRequestPropertiesDimensions{ + SubscriptionID: to.Ptr("testsubscriptionId"), + Location: to.Ptr("westus"), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armloadtesting.LoadTestMgmtClientCheckAvailabilityQuotaResponse{ + // CheckQuotaAvailabilityResponse: &armloadtesting.CheckQuotaAvailabilityResponse{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.LoadTestService/locations/westus/quotas/testQuotaBucket"), + // Name: to.Ptr("testQuotaBucket"), + // Type: to.Ptr("Microsoft.LoadTestService/locations/quotas"), + // Properties: &armloadtesting.CheckQuotaAvailabilityResponseProperties{ + // IsAvailable: to.Ptr(false), + // AvailabilityStatus: to.Ptr("The requested quota is currently unavailable. Please request for different quota, or upgrade subscription offer type and try again later."), + // }, + // }, + // } +} + +// Generated from example definition: 2024-12-01-preview/LoadTests_CreateOrUpdate.json +func ExampleLoadTestMgmtClient_BeginCreateOrUpdateLoadtest() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armloadtesting.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewLoadTestMgmtClient().BeginCreateOrUpdateLoadtest(ctx, "dummyrg", "myLoadTest", armloadtesting.LoadTestResource{ + Location: to.Ptr("westus"), + Tags: map[string]*string{ + "Team": to.Ptr("Dev Exp"), + }, + Identity: &armloadtesting.ManagedServiceIdentity{ + Type: to.Ptr(armloadtesting.ManagedServiceIdentityTypeSystemAssignedUserAssigned), + UserAssignedIdentities: map[string]*armloadtesting.UserAssignedIdentity{ + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {}, + }, + }, + Properties: &armloadtesting.LoadTestProperties{ + Description: to.Ptr("This is new load test resource"), + Encryption: &armloadtesting.EncryptionProperties{ + Identity: &armloadtesting.EncryptionPropertiesIdentity{ + Type: to.Ptr(armloadtesting.TypeUserAssigned), + ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"), + }, + KeyURL: to.Ptr("https://dummy.vault.azure.net/keys/dummykey1"), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armloadtesting.LoadTestMgmtClientCreateOrUpdateLoadtestResponse{ + // LoadTestResource: &armloadtesting.LoadTestResource{ + // Location: to.Ptr("westus"), + // Identity: &armloadtesting.ManagedServiceIdentity{ + // Type: to.Ptr(armloadtesting.ManagedServiceIdentityTypeSystemAssignedUserAssigned), + // PrincipalID: to.Ptr("12345678-1234-1234-1234-123456789012"), + // TenantID: to.Ptr("12345678-1234-1234-4321-123456789012"), + // UserAssignedIdentities: map[string]*armloadtesting.UserAssignedIdentity{ + // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armloadtesting.UserAssignedIdentity{ + // PrincipalID: to.Ptr("12345678-1234-4321-1234-123456789012"), + // ClientID: to.Ptr("12345678-4321-1234-1234-123456789012"), + // }, + // }, + // }, + // Properties: &armloadtesting.LoadTestProperties{ + // Description: to.Ptr("This is new load test resource"), + // DataPlaneURI: to.Ptr("https://myLoadTest.00000000-0000-0000-0000-000000000000.cnt-dp.domain.com"), + // ProvisioningState: to.Ptr(armloadtesting.ResourceStateSucceeded), + // Encryption: &armloadtesting.EncryptionProperties{ + // Identity: &armloadtesting.EncryptionPropertiesIdentity{ + // Type: to.Ptr(armloadtesting.TypeUserAssigned), + // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"), + // }, + // KeyURL: to.Ptr("https://dummy.vault.azure.net/keys/dummykey1"), + // }, + // }, + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.LoadTestService/loadTests/myLoadTest"), + // Name: to.Ptr("myLoadTest"), + // Type: to.Ptr("Microsoft.LoadTestService/loadTests"), + // Tags: map[string]*string{ + // "Team": to.Ptr("Dev Exp"), + // }, + // SystemData: &armloadtesting.SystemData{ + // CreatedBy: to.Ptr("userId1001"), + // CreatedByType: to.Ptr(armloadtesting.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-28T12:32:33Z"); return t}()), + // LastModifiedBy: to.Ptr("userId1001"), + // LastModifiedByType: to.Ptr(armloadtesting.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-28T12:32:33Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-12-01-preview/LoadTests_Delete.json +func ExampleLoadTestMgmtClient_BeginDeleteLoadtest() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armloadtesting.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewLoadTestMgmtClient().BeginDeleteLoadtest(ctx, "dummyrg", "myLoadTest", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + _, err = poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } +} + +// Generated from example definition: 2024-12-01-preview/LoadTests_Get.json +func ExampleLoadTestMgmtClient_GetLoadtest() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armloadtesting.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewLoadTestMgmtClient().GetLoadtest(ctx, "dummyrg", "myLoadTest", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armloadtesting.LoadTestMgmtClientGetLoadtestResponse{ + // LoadTestResource: &armloadtesting.LoadTestResource{ + // Location: to.Ptr("westus"), + // Properties: &armloadtesting.LoadTestProperties{ + // Description: to.Ptr("This is new load test resource"), + // DataPlaneURI: to.Ptr("https://myLoadTest.00000000-0000-0000-0000-000000000000.cnt-dp.domain.com"), + // ProvisioningState: to.Ptr(armloadtesting.ResourceStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.LoadTestService/loadTests/myLoadTest"), + // Name: to.Ptr("myLoadTest"), + // Type: to.Ptr("Microsoft.LoadTestService/loadTests"), + // Tags: map[string]*string{ + // "Team": to.Ptr("Dev Exp"), + // }, + // SystemData: &armloadtesting.SystemData{ + // CreatedBy: to.Ptr("userId1001"), + // CreatedByType: to.Ptr(armloadtesting.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-28T12:32:33Z"); return t}()), + // LastModifiedBy: to.Ptr("userId1001"), + // LastModifiedByType: to.Ptr(armloadtesting.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-28T12:32:33Z"); return t}()), + // }, + // }, + // } +} + +// Generated from example definition: 2024-12-01-preview/Quotas_Get.json +func ExampleLoadTestMgmtClient_GetQuota() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armloadtesting.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewLoadTestMgmtClient().GetQuota(ctx, "westus", "testQuotaBucket", nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armloadtesting.LoadTestMgmtClientGetQuotaResponse{ + // QuotaResource: &armloadtesting.QuotaResource{ + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.LoadTestService/locations/westus/quotas/testQuotaBucket"), + // Name: to.Ptr("testQuotaBucket"), + // Type: to.Ptr("Microsoft.LoadTestService/locations/quotas"), + // Properties: &armloadtesting.QuotaResourceProperties{ + // Limit: to.Ptr[int32](50), + // Usage: to.Ptr[int32](20), + // }, + // }, + // } +} + +// Generated from example definition: 2024-12-01-preview/LoadTests_ListByResourceGroup.json +func ExampleLoadTestMgmtClient_NewListByResourceGroupPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armloadtesting.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewLoadTestMgmtClient().NewListByResourceGroupPager("dummyrg", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armloadtesting.LoadTestMgmtClientListByResourceGroupResponse{ + // LoadTestResourceListResult: armloadtesting.LoadTestResourceListResult{ + // Value: []*armloadtesting.LoadTestResource{ + // { + // Location: to.Ptr("westus"), + // Properties: &armloadtesting.LoadTestProperties{ + // Description: to.Ptr("This is new load test resource"), + // DataPlaneURI: to.Ptr("https://myLoadTest.00000000-0000-0000-0000-000000000000.cnt-dp.domain.com"), + // ProvisioningState: to.Ptr(armloadtesting.ResourceStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.LoadTestService/loadTests/myLoadTest"), + // Name: to.Ptr("myLoadTest"), + // Type: to.Ptr("Microsoft.LoadTestService/loadTests"), + // Tags: map[string]*string{ + // "Team": to.Ptr("Dev Exp"), + // }, + // SystemData: &armloadtesting.SystemData{ + // CreatedBy: to.Ptr("userId1001"), + // CreatedByType: to.Ptr(armloadtesting.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-28T12:32:33Z"); return t}()), + // LastModifiedBy: to.Ptr("userId1001"), + // LastModifiedByType: to.Ptr(armloadtesting.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-28T12:32:33Z"); return t}()), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2024-12-01-preview/LoadTests_ListBySubscription.json +func ExampleLoadTestMgmtClient_NewListBySubscriptionPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armloadtesting.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewLoadTestMgmtClient().NewListBySubscriptionPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armloadtesting.LoadTestMgmtClientListBySubscriptionResponse{ + // LoadTestResourceListResult: armloadtesting.LoadTestResourceListResult{ + // Value: []*armloadtesting.LoadTestResource{ + // { + // Location: to.Ptr("westus"), + // Properties: &armloadtesting.LoadTestProperties{ + // Description: to.Ptr("This is new load test resource"), + // DataPlaneURI: to.Ptr("https://myLoadTest.00000000-0000-0000-0000-000000000000.cnt-dp.domain.com"), + // ProvisioningState: to.Ptr(armloadtesting.ResourceStateSucceeded), + // }, + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.LoadTestService/loadTests/myLoadTest"), + // Name: to.Ptr("myLoadTest"), + // Type: to.Ptr("Microsoft.LoadTestService/loadTests"), + // Tags: map[string]*string{ + // "Team": to.Ptr("Dev Exp"), + // }, + // SystemData: &armloadtesting.SystemData{ + // CreatedBy: to.Ptr("userId1001"), + // CreatedByType: to.Ptr(armloadtesting.CreatedByTypeUser), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-28T12:32:33Z"); return t}()), + // LastModifiedBy: to.Ptr("userId1001"), + // LastModifiedByType: to.Ptr(armloadtesting.CreatedByTypeUser), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-28T12:32:33Z"); return t}()), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2024-12-01-preview/Quotas_List.json +func ExampleLoadTestMgmtClient_NewListQuotaPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armloadtesting.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewLoadTestMgmtClient().NewListQuotaPager("westus", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armloadtesting.LoadTestMgmtClientListQuotaResponse{ + // QuotaResourceListResult: armloadtesting.QuotaResourceListResult{ + // Value: []*armloadtesting.QuotaResource{ + // { + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.LoadTestService/locations/westus/quotas/testQuotaBucket"), + // Name: to.Ptr("testQuotaBucket"), + // Type: to.Ptr("Microsoft.LoadTestService/locations/quotas"), + // Properties: &armloadtesting.QuotaResourceProperties{ + // Limit: to.Ptr[int32](50), + // Usage: to.Ptr[int32](20), + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2024-12-01-preview/LoadTests_ListOutboundNetworkDependenciesEndpoints.json +func ExampleLoadTestMgmtClient_NewOutboundNetworkDependenciesEndpointsPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armloadtesting.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewLoadTestMgmtClient().NewOutboundNetworkDependenciesEndpointsPager("default-azureloadtest-japaneast", "sampleloadtest", nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armloadtesting.LoadTestMgmtClientOutboundNetworkDependenciesEndpointsResponse{ + // PagedOutboundEnvironmentEndpoint: armloadtesting.PagedOutboundEnvironmentEndpoint{ + // Value: []*armloadtesting.OutboundEnvironmentEndpoint{ + // { + // Category: to.Ptr("Azure Batch"), + // Endpoints: []*armloadtesting.EndpointDependency{ + // { + // DomainName: to.Ptr("sampleacct.japaneast.batch.azure.com"), + // Description: to.Ptr("Applicable to job manager tasks, tasks that use job scoped authentication, or any task that makes calls to Batch."), + // EndpointDetails: []*armloadtesting.EndpointDetail{ + // { + // Port: to.Ptr[int32](443), + // }, + // }, + // }, + // { + // DomainName: to.Ptr("japaneast.service.batch.azure.com"), + // Description: to.Ptr("Applicable to all Azure Batch pools."), + // EndpointDetails: []*armloadtesting.EndpointDetail{ + // { + // Port: to.Ptr[int32](443), + // }, + // }, + // }, + // }, + // }, + // { + // Category: to.Ptr("Azure Storage"), + // Endpoints: []*armloadtesting.EndpointDependency{ + // { + // DomainName: to.Ptr("autostorageaccountname.blob.core.windows.net"), + // Description: to.Ptr("AutoStorage endpoint for this Batch account. Applicable to all Azure Batch pools under this account."), + // EndpointDetails: []*armloadtesting.EndpointDetail{ + // { + // Port: to.Ptr[int32](443), + // }, + // }, + // }, + // { + // DomainName: to.Ptr("*.blob.core.windows.net"), + // Description: to.Ptr("Applicable to all Azure Batch pools."), + // EndpointDetails: []*armloadtesting.EndpointDetail{ + // { + // Port: to.Ptr[int32](443), + // }, + // }, + // }, + // { + // DomainName: to.Ptr("*.table.core.windows.net"), + // Description: to.Ptr("Applicable to all Azure Batch pools."), + // EndpointDetails: []*armloadtesting.EndpointDetail{ + // { + // Port: to.Ptr[int32](443), + // }, + // }, + // }, + // { + // DomainName: to.Ptr("*.queue.core.windows.net"), + // Description: to.Ptr("Applicable to all Azure Batch pools."), + // EndpointDetails: []*armloadtesting.EndpointDetail{ + // { + // Port: to.Ptr[int32](443), + // }, + // }, + // }, + // }, + // }, + // { + // Category: to.Ptr("Microsoft Package Repository"), + // Endpoints: []*armloadtesting.EndpointDependency{ + // { + // DomainName: to.Ptr("packages.microsoft.com"), + // Description: to.Ptr("Only applicable to pools containing a Mount Configuration. Learn about Mount Configurations in Batch at https://docs.microsoft.com/azure/batch/virtual-file-mount."), + // EndpointDetails: []*armloadtesting.EndpointDetail{ + // { + // Port: to.Ptr[int32](443), + // }, + // }, + // }, + // }, + // }, + // { + // Category: to.Ptr("Azure Key Vault"), + // Endpoints: []*armloadtesting.EndpointDependency{ + // { + // DomainName: to.Ptr("*.vault.azure.net"), + // Description: to.Ptr("Only applicable to pools containing a Disk Encryption Configuration and whose VM size does not support encryption at host. Learn more about disk encryption in Azure Batch at https://docs.microsoft.com/azure/batch/disk-encryption. Learn more about encryption at host and supported VM sizes at https://docs.microsoft.com/azure/virtual-machines/disks-enable-host-based-encryption-portal."), + // EndpointDetails: []*armloadtesting.EndpointDetail{ + // { + // Port: to.Ptr[int32](443), + // }, + // }, + // }, + // }, + // }, + // }, + // }, + // } + } +} + +// Generated from example definition: 2024-12-01-preview/LoadTests_Update.json +func ExampleLoadTestMgmtClient_BeginUpdateLoadtest() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armloadtesting.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + poller, err := clientFactory.NewLoadTestMgmtClient().BeginUpdateLoadtest(ctx, "dummyrg", "myLoadTest", armloadtesting.LoadTestResourceUpdate{ + Tags: map[string]*string{ + "Team": to.Ptr("Dev Exp"), + "Division": to.Ptr("LT"), + }, + Identity: &armloadtesting.ManagedServiceIdentity{ + Type: to.Ptr(armloadtesting.ManagedServiceIdentityTypeSystemAssignedUserAssigned), + UserAssignedIdentities: map[string]*armloadtesting.UserAssignedIdentity{ + "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {}, + }, + }, + Properties: &armloadtesting.LoadTestResourceUpdateProperties{ + Description: to.Ptr("This is new load test resource"), + Encryption: &armloadtesting.EncryptionProperties{ + Identity: &armloadtesting.EncryptionPropertiesIdentity{ + Type: to.Ptr(armloadtesting.TypeSystemAssigned), + ResourceID: nil, + }, + KeyURL: to.Ptr("https://dummy.vault.azure.net/keys/dummykey1"), + }, + }, + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + res, err := poller.PollUntilDone(ctx, nil) + if err != nil { + log.Fatalf("failed to pull the result: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armloadtesting.LoadTestMgmtClientUpdateLoadtestResponse{ + // } +} diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/loadtests_client.go b/sdk/resourcemanager/loadtesting/armloadtesting/loadtests_client.go deleted file mode 100644 index bfd2effb6f4e..000000000000 --- a/sdk/resourcemanager/loadtesting/armloadtesting/loadtests_client.go +++ /dev/null @@ -1,525 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armloadtesting - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// LoadTestsClient contains the methods for the LoadTests group. -// Don't use this type directly, use NewLoadTestsClient() instead. -type LoadTestsClient struct { - internal *arm.Client - subscriptionID string -} - -// NewLoadTestsClient creates a new instance of LoadTestsClient with the specified values. -// - 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, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &LoadTestsClient{ - subscriptionID: subscriptionID, - internal: cl, - } - return client, nil -} - -// BeginCreateOrUpdate - Create or update LoadTest resource. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-12-01 -// - resourceGroupName - The name of the resource group. The name is case insensitive. -// - loadTestName - Load Test name. -// - loadTestResource - LoadTest resource data -// - options - LoadTestsClientBeginCreateOrUpdateOptions contains the optional parameters for the LoadTestsClient.BeginCreateOrUpdate -// method. -func (client *LoadTestsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResource LoadTestResource, options *LoadTestsClientBeginCreateOrUpdateOptions) (*runtime.Poller[LoadTestsClientCreateOrUpdateResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.createOrUpdate(ctx, resourceGroupName, loadTestName, loadTestResource, options) - if err != nil { - return nil, err - } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LoadTestsClientCreateOrUpdateResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - Tracer: client.internal.Tracer(), - }) - return poller, err - } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LoadTestsClientCreateOrUpdateResponse]{ - Tracer: client.internal.Tracer(), - }) - } -} - -// CreateOrUpdate - Create or update LoadTest resource. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-12-01 -func (client *LoadTestsClient) createOrUpdate(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResource LoadTestResource, options *LoadTestsClientBeginCreateOrUpdateOptions) (*http.Response, error) { - var err error - const operationName = "LoadTestsClient.BeginCreateOrUpdate" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, loadTestName, loadTestResource, options) - if err != nil { - return nil, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { - err = runtime.NewResponseError(httpResp) - return nil, err - } - return httpResp, nil -} - -// createOrUpdateCreateRequest creates the CreateOrUpdate request. -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") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if loadTestName == "" { - return nil, errors.New("parameter loadTestName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{loadTestName}", url.PathEscape(loadTestName)) - req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-12-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, loadTestResource); err != nil { - return nil, err - } - return req, nil -} - -// BeginDelete - Delete a LoadTest resource. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-12-01 -// - 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) (*runtime.Poller[LoadTestsClientDeleteResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.deleteOperation(ctx, resourceGroupName, loadTestName, options) - if err != nil { - return nil, err - } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LoadTestsClientDeleteResponse]{ - FinalStateVia: runtime.FinalStateViaLocation, - Tracer: client.internal.Tracer(), - }) - return poller, err - } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LoadTestsClientDeleteResponse]{ - Tracer: client.internal.Tracer(), - }) - } -} - -// Delete - Delete a LoadTest resource. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-12-01 -func (client *LoadTestsClient) deleteOperation(ctx context.Context, resourceGroupName string, loadTestName string, options *LoadTestsClientBeginDeleteOptions) (*http.Response, error) { - var err error - const operationName = "LoadTestsClient.BeginDelete" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.deleteCreateRequest(ctx, resourceGroupName, loadTestName, options) - if err != nil { - return nil, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - err = runtime.NewResponseError(httpResp) - return nil, err - } - return httpResp, nil -} - -// deleteCreateRequest creates the Delete request. -func (client *LoadTestsClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, loadTestName string, options *LoadTestsClientBeginDeleteOptions) (*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") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if loadTestName == "" { - return nil, errors.New("parameter loadTestName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{loadTestName}", url.PathEscape(loadTestName)) - req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-12-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// Get - Get a LoadTest resource. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-12-01 -// - resourceGroupName - The name of the resource group. The name is case insensitive. -// - loadTestName - Load Test name. -// - options - LoadTestsClientGetOptions contains the optional parameters for the LoadTestsClient.Get method. -func (client *LoadTestsClient) Get(ctx context.Context, resourceGroupName string, loadTestName string, options *LoadTestsClientGetOptions) (LoadTestsClientGetResponse, error) { - var err error - const operationName = "LoadTestsClient.Get" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, resourceGroupName, loadTestName, options) - if err != nil { - return LoadTestsClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return LoadTestsClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return LoadTestsClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *LoadTestsClient) getCreateRequest(ctx context.Context, resourceGroupName string, loadTestName string, options *LoadTestsClientGetOptions) (*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") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if loadTestName == "" { - return nil, errors.New("parameter loadTestName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{loadTestName}", url.PathEscape(loadTestName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-12-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *LoadTestsClient) getHandleResponse(resp *http.Response) (LoadTestsClientGetResponse, error) { - result := LoadTestsClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.LoadTestResource); err != nil { - return LoadTestsClientGetResponse{}, err - } - return result, nil -} - -// NewListByResourceGroupPager - Lists loadtest resources in a resource group. -// -// Generated from API version 2022-12-01 -// - resourceGroupName - The name of the resource group. The name is case insensitive. -// - options - LoadTestsClientListByResourceGroupOptions contains the optional parameters for the LoadTestsClient.NewListByResourceGroupPager -// method. -func (client *LoadTestsClient) NewListByResourceGroupPager(resourceGroupName string, options *LoadTestsClientListByResourceGroupOptions) *runtime.Pager[LoadTestsClientListByResourceGroupResponse] { - return runtime.NewPager(runtime.PagingHandler[LoadTestsClientListByResourceGroupResponse]{ - More: func(page LoadTestsClientListByResourceGroupResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *LoadTestsClientListByResourceGroupResponse) (LoadTestsClientListByResourceGroupResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "LoadTestsClient.NewListByResourceGroupPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - }, nil) - if err != nil { - return LoadTestsClientListByResourceGroupResponse{}, err - } - return client.listByResourceGroupHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listByResourceGroupCreateRequest creates the ListByResourceGroup request. -func (client *LoadTestsClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, options *LoadTestsClientListByResourceGroupOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-12-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listByResourceGroupHandleResponse handles the ListByResourceGroup response. -func (client *LoadTestsClient) listByResourceGroupHandleResponse(resp *http.Response) (LoadTestsClientListByResourceGroupResponse, error) { - result := LoadTestsClientListByResourceGroupResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.LoadTestResourcePageList); err != nil { - return LoadTestsClientListByResourceGroupResponse{}, err - } - return result, nil -} - -// NewListBySubscriptionPager - Lists loadtests resources in a subscription. -// -// Generated from API version 2022-12-01 -// - options - LoadTestsClientListBySubscriptionOptions contains the optional parameters for the LoadTestsClient.NewListBySubscriptionPager -// method. -func (client *LoadTestsClient) NewListBySubscriptionPager(options *LoadTestsClientListBySubscriptionOptions) *runtime.Pager[LoadTestsClientListBySubscriptionResponse] { - return runtime.NewPager(runtime.PagingHandler[LoadTestsClientListBySubscriptionResponse]{ - More: func(page LoadTestsClientListBySubscriptionResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *LoadTestsClientListBySubscriptionResponse) (LoadTestsClientListBySubscriptionResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "LoadTestsClient.NewListBySubscriptionPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listBySubscriptionCreateRequest(ctx, options) - }, nil) - if err != nil { - return LoadTestsClientListBySubscriptionResponse{}, err - } - return client.listBySubscriptionHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listBySubscriptionCreateRequest creates the ListBySubscription request. -func (client *LoadTestsClient) listBySubscriptionCreateRequest(ctx context.Context, options *LoadTestsClientListBySubscriptionOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/loadTests" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-12-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listBySubscriptionHandleResponse handles the ListBySubscription response. -func (client *LoadTestsClient) listBySubscriptionHandleResponse(resp *http.Response) (LoadTestsClientListBySubscriptionResponse, error) { - result := LoadTestsClientListBySubscriptionResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.LoadTestResourcePageList); err != nil { - return LoadTestsClientListBySubscriptionResponse{}, err - } - return result, nil -} - -// NewListOutboundNetworkDependenciesEndpointsPager - Lists the endpoints that agents may call as part of load testing. -// -// Generated from API version 2022-12-01 -// - resourceGroupName - The name of the resource group. The name is case insensitive. -// - loadTestName - Load Test name. -// - options - LoadTestsClientListOutboundNetworkDependenciesEndpointsOptions contains the optional parameters for the LoadTestsClient.NewListOutboundNetworkDependenciesEndpointsPager -// method. -func (client *LoadTestsClient) NewListOutboundNetworkDependenciesEndpointsPager(resourceGroupName string, loadTestName string, options *LoadTestsClientListOutboundNetworkDependenciesEndpointsOptions) *runtime.Pager[LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse] { - return runtime.NewPager(runtime.PagingHandler[LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse]{ - More: func(page LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse) (LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "LoadTestsClient.NewListOutboundNetworkDependenciesEndpointsPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listOutboundNetworkDependenciesEndpointsCreateRequest(ctx, resourceGroupName, loadTestName, options) - }, nil) - if err != nil { - return LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse{}, err - } - return client.listOutboundNetworkDependenciesEndpointsHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listOutboundNetworkDependenciesEndpointsCreateRequest creates the ListOutboundNetworkDependenciesEndpoints request. -func (client *LoadTestsClient) listOutboundNetworkDependenciesEndpointsCreateRequest(ctx context.Context, resourceGroupName string, loadTestName string, options *LoadTestsClientListOutboundNetworkDependenciesEndpointsOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/loadTests/{loadTestName}/outboundNetworkDependenciesEndpoints" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if loadTestName == "" { - return nil, errors.New("parameter loadTestName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{loadTestName}", url.PathEscape(loadTestName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-12-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listOutboundNetworkDependenciesEndpointsHandleResponse handles the ListOutboundNetworkDependenciesEndpoints response. -func (client *LoadTestsClient) listOutboundNetworkDependenciesEndpointsHandleResponse(resp *http.Response) (LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse, error) { - result := LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.OutboundEnvironmentEndpointCollection); err != nil { - return LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse{}, err - } - return result, nil -} - -// BeginUpdate - Update a loadtest resource. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-12-01 -// - resourceGroupName - The name of the resource group. The name is case insensitive. -// - loadTestName - Load Test name. -// - loadTestResourcePatchRequestBody - LoadTest resource update data -// - 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) (*runtime.Poller[LoadTestsClientUpdateResponse], error) { - if options == nil || options.ResumeToken == "" { - resp, err := client.update(ctx, resourceGroupName, loadTestName, loadTestResourcePatchRequestBody, options) - if err != nil { - return nil, err - } - poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LoadTestsClientUpdateResponse]{ - FinalStateVia: runtime.FinalStateViaAzureAsyncOp, - Tracer: client.internal.Tracer(), - }) - return poller, err - } else { - return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LoadTestsClientUpdateResponse]{ - Tracer: client.internal.Tracer(), - }) - } -} - -// Update - Update a loadtest resource. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-12-01 -func (client *LoadTestsClient) update(ctx context.Context, resourceGroupName string, loadTestName string, loadTestResourcePatchRequestBody LoadTestResourcePatchRequestBody, options *LoadTestsClientBeginUpdateOptions) (*http.Response, error) { - var err error - const operationName = "LoadTestsClient.BeginUpdate" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.updateCreateRequest(ctx, resourceGroupName, loadTestName, loadTestResourcePatchRequestBody, options) - if err != nil { - return nil, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return nil, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { - err = runtime.NewResponseError(httpResp) - return nil, err - } - return httpResp, nil -} - -// updateCreateRequest creates the Update request. -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") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if resourceGroupName == "" { - return nil, errors.New("parameter resourceGroupName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) - if loadTestName == "" { - return nil, errors.New("parameter loadTestName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{loadTestName}", url.PathEscape(loadTestName)) - req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-12-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, loadTestResourcePatchRequestBody); err != nil { - return nil, err - } - return req, nil -} diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/loadtests_client_example_test.go b/sdk/resourcemanager/loadtesting/armloadtesting/loadtests_client_example_test.go deleted file mode 100644 index 7f3659ec8275..000000000000 --- a/sdk/resourcemanager/loadtesting/armloadtesting/loadtests_client_example_test.go +++ /dev/null @@ -1,459 +0,0 @@ -//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. -// DO NOT EDIT. - -package armloadtesting_test - -import ( - "context" - "log" - - "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/loadtesting/armloadtesting" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/630ec444f8dd7c09b9cdd5fa99951f8a0d1ad41f/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListBySubscription.json -func ExampleLoadTestsClient_NewListBySubscriptionPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armloadtesting.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewLoadTestsClient().NewListBySubscriptionPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.LoadTestResourcePageList = armloadtesting.LoadTestResourcePageList{ - // Value: []*armloadtesting.LoadTestResource{ - // { - // Name: to.Ptr("myLoadTest"), - // Type: to.Ptr("Microsoft.LoadTestService/loadTests"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.LoadTestService/loadTests/myLoadTest"), - // SystemData: &armloadtesting.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-28T12:32:33.000Z"); return t}()), - // CreatedBy: to.Ptr("userId1001"), - // CreatedByType: to.Ptr(armloadtesting.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-28T12:32:33.000Z"); return t}()), - // LastModifiedBy: to.Ptr("userId1001"), - // LastModifiedByType: to.Ptr(armloadtesting.CreatedByTypeUser), - // }, - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // "Team": to.Ptr("Dev Exp"), - // }, - // Properties: &armloadtesting.LoadTestProperties{ - // Description: to.Ptr("This is new load test resource"), - // DataPlaneURI: to.Ptr("https://myLoadTest.00000000-0000-0000-0000-000000000000.cnt-dp.domain.com"), - // ProvisioningState: to.Ptr(armloadtesting.ResourceStateSucceeded), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/630ec444f8dd7c09b9cdd5fa99951f8a0d1ad41f/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListByResourceGroup.json -func ExampleLoadTestsClient_NewListByResourceGroupPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armloadtesting.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewLoadTestsClient().NewListByResourceGroupPager("dummyrg", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.LoadTestResourcePageList = armloadtesting.LoadTestResourcePageList{ - // Value: []*armloadtesting.LoadTestResource{ - // { - // Name: to.Ptr("myLoadTest"), - // Type: to.Ptr("Microsoft.LoadTestService/loadTests"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.LoadTestService/loadTests/myLoadTest"), - // SystemData: &armloadtesting.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-28T12:32:33.000Z"); return t}()), - // CreatedBy: to.Ptr("userId1001"), - // CreatedByType: to.Ptr(armloadtesting.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-28T12:32:33.000Z"); return t}()), - // LastModifiedBy: to.Ptr("userId1001"), - // LastModifiedByType: to.Ptr(armloadtesting.CreatedByTypeUser), - // }, - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // "Team": to.Ptr("Dev Exp"), - // }, - // Properties: &armloadtesting.LoadTestProperties{ - // Description: to.Ptr("This is new load test resource"), - // DataPlaneURI: to.Ptr("https://myLoadTest.00000000-0000-0000-0000-000000000000.cnt-dp.domain.com"), - // ProvisioningState: to.Ptr(armloadtesting.ResourceStateSucceeded), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/630ec444f8dd7c09b9cdd5fa99951f8a0d1ad41f/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/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() - clientFactory, err := armloadtesting.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewLoadTestsClient().Get(ctx, "dummyrg", "myLoadTest", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.LoadTestResource = armloadtesting.LoadTestResource{ - // Name: to.Ptr("myLoadTest"), - // Type: to.Ptr("Microsoft.LoadTestService/loadTests"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.LoadTestService/loadTests/myLoadTest"), - // SystemData: &armloadtesting.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-28T12:32:33.000Z"); return t}()), - // CreatedBy: to.Ptr("userId1001"), - // CreatedByType: to.Ptr(armloadtesting.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-28T12:32:33.000Z"); return t}()), - // LastModifiedBy: to.Ptr("userId1001"), - // LastModifiedByType: to.Ptr(armloadtesting.CreatedByTypeUser), - // }, - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // "Team": to.Ptr("Dev Exp"), - // }, - // Properties: &armloadtesting.LoadTestProperties{ - // Description: to.Ptr("This is new load test resource"), - // DataPlaneURI: to.Ptr("https://myLoadTest.00000000-0000-0000-0000-000000000000.cnt-dp.domain.com"), - // ProvisioningState: to.Ptr(armloadtesting.ResourceStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/630ec444f8dd7c09b9cdd5fa99951f8a0d1ad41f/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_CreateOrUpdate.json -func ExampleLoadTestsClient_BeginCreateOrUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armloadtesting.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewLoadTestsClient().BeginCreateOrUpdate(ctx, "dummyrg", "myLoadTest", armloadtesting.LoadTestResource{ - Location: to.Ptr("westus"), - Tags: map[string]*string{ - "Team": to.Ptr("Dev Exp"), - }, - Identity: &armloadtesting.ManagedServiceIdentity{ - Type: to.Ptr(armloadtesting.ManagedServiceIdentityTypeSystemAssignedUserAssigned), - UserAssignedIdentities: map[string]*armloadtesting.UserAssignedIdentity{ - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {}, - }, - }, - Properties: &armloadtesting.LoadTestProperties{ - Description: to.Ptr("This is new load test resource"), - Encryption: &armloadtesting.EncryptionProperties{ - Identity: &armloadtesting.EncryptionPropertiesIdentity{ - Type: to.Ptr(armloadtesting.TypeUserAssigned), - ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"), - }, - KeyURL: to.Ptr("https://dummy.vault.azure.net/keys/dummykey1"), - }, - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.LoadTestResource = armloadtesting.LoadTestResource{ - // Name: to.Ptr("myLoadTest"), - // Type: to.Ptr("Microsoft.LoadTestService/loadTests"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.LoadTestService/loadTests/myLoadTest"), - // SystemData: &armloadtesting.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-28T12:32:33.000Z"); return t}()), - // CreatedBy: to.Ptr("userId1001"), - // CreatedByType: to.Ptr(armloadtesting.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-28T12:32:33.000Z"); return t}()), - // LastModifiedBy: to.Ptr("userId1001"), - // LastModifiedByType: to.Ptr(armloadtesting.CreatedByTypeUser), - // }, - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // "Team": to.Ptr("Dev Exp"), - // }, - // Identity: &armloadtesting.ManagedServiceIdentity{ - // Type: to.Ptr(armloadtesting.ManagedServiceIdentityTypeSystemAssignedUserAssigned), - // PrincipalID: to.Ptr("12345678-1234-1234-1234-123456789012"), - // TenantID: to.Ptr("12345678-1234-1234-4321-123456789012"), - // UserAssignedIdentities: map[string]*armloadtesting.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armloadtesting.UserAssignedIdentity{ - // ClientID: to.Ptr("12345678-4321-1234-1234-123456789012"), - // PrincipalID: to.Ptr("12345678-1234-4321-1234-123456789012"), - // }, - // }, - // }, - // Properties: &armloadtesting.LoadTestProperties{ - // Description: to.Ptr("This is new load test resource"), - // DataPlaneURI: to.Ptr("https://myLoadTest.00000000-0000-0000-0000-000000000000.cnt-dp.domain.com"), - // Encryption: &armloadtesting.EncryptionProperties{ - // Identity: &armloadtesting.EncryptionPropertiesIdentity{ - // Type: to.Ptr(armloadtesting.TypeUserAssigned), - // ResourceID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1"), - // }, - // KeyURL: to.Ptr("https://dummy.vault.azure.net/keys/dummykey1"), - // }, - // ProvisioningState: to.Ptr(armloadtesting.ResourceStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/630ec444f8dd7c09b9cdd5fa99951f8a0d1ad41f/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_Update.json -func ExampleLoadTestsClient_BeginUpdate() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armloadtesting.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewLoadTestsClient().BeginUpdate(ctx, "dummyrg", "myLoadTest", armloadtesting.LoadTestResourcePatchRequestBody{ - Identity: &armloadtesting.ManagedServiceIdentity{ - Type: to.Ptr(armloadtesting.ManagedServiceIdentityTypeSystemAssignedUserAssigned), - UserAssignedIdentities: map[string]*armloadtesting.UserAssignedIdentity{ - "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": {}, - }, - }, - Properties: &armloadtesting.LoadTestResourcePatchRequestBodyProperties{ - Description: to.Ptr("This is new load test resource"), - Encryption: &armloadtesting.EncryptionProperties{ - Identity: &armloadtesting.EncryptionPropertiesIdentity{ - Type: to.Ptr(armloadtesting.TypeSystemAssigned), - }, - KeyURL: to.Ptr("https://dummy.vault.azure.net/keys/dummykey1"), - }, - }, - Tags: map[string]*string{ - "Division": to.Ptr("LT"), - "Team": to.Ptr("Dev Exp"), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - res, err := poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.LoadTestResource = armloadtesting.LoadTestResource{ - // Name: to.Ptr("myLoadTest"), - // Type: to.Ptr("Microsoft.LoadTestService/loadTests"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.LoadTestService/loadTests/myLoadTest"), - // SystemData: &armloadtesting.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-28T12:32:33.000Z"); return t}()), - // CreatedBy: to.Ptr("userId1001"), - // CreatedByType: to.Ptr(armloadtesting.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-09-28T12:32:33.000Z"); return t}()), - // LastModifiedBy: to.Ptr("userId1001"), - // LastModifiedByType: to.Ptr(armloadtesting.CreatedByTypeUser), - // }, - // Location: to.Ptr("westus"), - // Tags: map[string]*string{ - // "Division": to.Ptr("LT"), - // "Team": to.Ptr("Dev Exp"), - // }, - // Identity: &armloadtesting.ManagedServiceIdentity{ - // Type: to.Ptr(armloadtesting.ManagedServiceIdentityTypeSystemAssignedUserAssigned), - // PrincipalID: to.Ptr("12345678-1234-1234-1234-123456789012"), - // TenantID: to.Ptr("12345678-1234-1234-4321-123456789012"), - // UserAssignedIdentities: map[string]*armloadtesting.UserAssignedIdentity{ - // "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/dummyrg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/id1": &armloadtesting.UserAssignedIdentity{ - // ClientID: to.Ptr("12345678-4321-1234-1234-123456789012"), - // PrincipalID: to.Ptr("12345678-1234-4321-1234-123456789012"), - // }, - // }, - // }, - // Properties: &armloadtesting.LoadTestProperties{ - // Description: to.Ptr("This is new load test resource"), - // DataPlaneURI: to.Ptr("https://myLoadTest.00000000-0000-0000-0000-000000000000.cnt-dp.domain.com"), - // Encryption: &armloadtesting.EncryptionProperties{ - // Identity: &armloadtesting.EncryptionPropertiesIdentity{ - // Type: to.Ptr(armloadtesting.TypeSystemAssigned), - // }, - // KeyURL: to.Ptr("https://dummy.vault.azure.net/keys/dummykey1"), - // }, - // ProvisioningState: to.Ptr(armloadtesting.ResourceStateSucceeded), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/630ec444f8dd7c09b9cdd5fa99951f8a0d1ad41f/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/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() - clientFactory, err := armloadtesting.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - poller, err := clientFactory.NewLoadTestsClient().BeginDelete(ctx, "dummyrg", "myLoadTest", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - _, err = poller.PollUntilDone(ctx, nil) - if err != nil { - log.Fatalf("failed to pull the result: %v", err) - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/630ec444f8dd7c09b9cdd5fa99951f8a0d1ad41f/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/LoadTests_ListOutboundNetworkDependenciesEndpoints.json -func ExampleLoadTestsClient_NewListOutboundNetworkDependenciesEndpointsPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armloadtesting.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewLoadTestsClient().NewListOutboundNetworkDependenciesEndpointsPager("default-azureloadtest-japaneast", "sampleloadtest", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OutboundEnvironmentEndpointCollection = armloadtesting.OutboundEnvironmentEndpointCollection{ - // Value: []*armloadtesting.OutboundEnvironmentEndpoint{ - // { - // Category: to.Ptr("Azure Batch"), - // Endpoints: []*armloadtesting.EndpointDependency{ - // { - // Description: to.Ptr("Applicable to job manager tasks, tasks that use job scoped authentication, or any task that makes calls to Batch."), - // DomainName: to.Ptr("sampleacct.japaneast.batch.azure.com"), - // EndpointDetails: []*armloadtesting.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // }}, - // }, - // { - // Description: to.Ptr("Applicable to all Azure Batch pools."), - // DomainName: to.Ptr("japaneast.service.batch.azure.com"), - // EndpointDetails: []*armloadtesting.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // }}, - // }}, - // }, - // { - // Category: to.Ptr("Azure Storage"), - // Endpoints: []*armloadtesting.EndpointDependency{ - // { - // Description: to.Ptr("AutoStorage endpoint for this Batch account. Applicable to all Azure Batch pools under this account."), - // DomainName: to.Ptr("autostorageaccountname.blob.core.windows.net"), - // EndpointDetails: []*armloadtesting.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // }}, - // }, - // { - // Description: to.Ptr("Applicable to all Azure Batch pools."), - // DomainName: to.Ptr("*.blob.core.windows.net"), - // EndpointDetails: []*armloadtesting.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // }}, - // }, - // { - // Description: to.Ptr("Applicable to all Azure Batch pools."), - // DomainName: to.Ptr("*.table.core.windows.net"), - // EndpointDetails: []*armloadtesting.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // }}, - // }, - // { - // Description: to.Ptr("Applicable to all Azure Batch pools."), - // DomainName: to.Ptr("*.queue.core.windows.net"), - // EndpointDetails: []*armloadtesting.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // }}, - // }}, - // }, - // { - // Category: to.Ptr("Microsoft Package Repository"), - // Endpoints: []*armloadtesting.EndpointDependency{ - // { - // Description: to.Ptr("Only applicable to pools containing a Mount Configuration. Learn about Mount Configurations in Batch at https://docs.microsoft.com/azure/batch/virtual-file-mount."), - // DomainName: to.Ptr("packages.microsoft.com"), - // EndpointDetails: []*armloadtesting.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // }}, - // }}, - // }, - // { - // Category: to.Ptr("Azure Key Vault"), - // Endpoints: []*armloadtesting.EndpointDependency{ - // { - // Description: to.Ptr("Only applicable to pools containing a Disk Encryption Configuration and whose VM size does not support encryption at host. Learn more about disk encryption in Azure Batch at https://docs.microsoft.com/azure/batch/disk-encryption. Learn more about encryption at host and supported VM sizes at https://docs.microsoft.com/azure/virtual-machines/disks-enable-host-based-encryption-portal."), - // DomainName: to.Ptr("*.vault.azure.net"), - // EndpointDetails: []*armloadtesting.EndpointDetail{ - // { - // Port: to.Ptr[int32](443), - // }}, - // }}, - // }}, - // } - } -} diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/loadtestservice_live_test.go b/sdk/resourcemanager/loadtesting/armloadtesting/loadtestservice_live_test.go index a06633fd4629..bd66d26b2f0f 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/loadtestservice_live_test.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/loadtestservice_live_test.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v3/testutil" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtesting/armloadtesting" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtesting/armloadtesting/v2" "github.com/stretchr/testify/suite" ) diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/models.go b/sdk/resourcemanager/loadtesting/armloadtesting/models.go index 1679c6841e69..8ddb1682d851 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/models.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/models.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armloadtesting @@ -18,14 +14,14 @@ type CheckQuotaAvailabilityResponse struct { // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY; The name of the resource + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string + + // READ-ONLY; The name of the resource. Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string } // CheckQuotaAvailabilityResponseProperties - Check quota availability response properties. @@ -37,7 +33,7 @@ type CheckQuotaAvailabilityResponseProperties struct { IsAvailable *bool } -// EncryptionProperties - Key and identity details for Customer Managed Key encryption of load test resource +// 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 @@ -50,22 +46,22 @@ type EncryptionProperties struct { // 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 + // User assigned identity to use for accessing key encryption key Url. Ex: /subscriptions/a0a0a0a0-bbbb-cccd-dddd-e1e1e1e1e1e1/resourceGroups//providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. ResourceID *string - // Managed identity type to use for accessing encryption key Url + // Managed identity type to use for accessing encryption key Url. Type *Type } // EndpointDependency - A domain name and connection details used to access a dependency. type EndpointDependency struct { - // READ-ONLY; Human-readable supplemental information about the dependency and when it is applicable. - Description *string - // READ-ONLY; The domain name of the dependency. Domain names may be fully qualified or may contain a * wildcard. DomainName *string + // READ-ONLY; Human-readable supplemental information about the dependency and when it is applicable. + Description *string + // READ-ONLY; The list of connection details for this endpoint. EndpointDetails []*EndpointDetail } @@ -91,15 +87,18 @@ type LoadTestProperties struct { ProvisioningState *ResourceState } -// LoadTestResource - LoadTest details +// LoadTestResource - LoadTest details. type LoadTestResource struct { // REQUIRED; The geo-location where the resource lives Location *string - // The type of identity used for the resource. + // READ-ONLY; Load Test name + Name *string + + // The managed service identities assigned to this resource. Identity *ManagedServiceIdentity - // Load Test resource properties + // The resource-specific properties for this resource. Properties *LoadTestProperties // Resource tags. @@ -108,9 +107,6 @@ type LoadTestResource struct { // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY; The name of the resource - Name *string - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData @@ -118,29 +114,29 @@ type LoadTestResource struct { Type *string } -// LoadTestResourcePageList - List of resources page result. -type LoadTestResourcePageList struct { - // Link to next page of resources. - NextLink *string - - // List of resources in current page. +// LoadTestResourceListResult - The response of a LoadTestResource list operation. +type LoadTestResourceListResult struct { + // REQUIRED; The LoadTestResource items on this page Value []*LoadTestResource + + // The link to the next page of items + NextLink *string } -// LoadTestResourcePatchRequestBody - LoadTest resource patch request body. -type LoadTestResourcePatchRequestBody struct { - // The type of identity used for the resource. +// LoadTestResourceUpdate - The type used for update operations of the LoadTestResource. +type LoadTestResourceUpdate struct { + // The managed service identities assigned to this resource. Identity *ManagedServiceIdentity - // Load Test resource properties - Properties *LoadTestResourcePatchRequestBodyProperties + // The resource-specific properties for this resource. + Properties *LoadTestResourceUpdateProperties // Resource tags. Tags map[string]*string } -// LoadTestResourcePatchRequestBodyProperties - Load Test resource properties -type LoadTestResourcePatchRequestBodyProperties struct { +// LoadTestResourceUpdateProperties - The updatable properties of the LoadTestResource. +type LoadTestResourceUpdateProperties struct { // Description of the resource. Description *string @@ -150,14 +146,10 @@ type LoadTestResourcePatchRequestBodyProperties struct { // 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). + // REQUIRED; The type of managed identity assigned to this resource. Type *ManagedServiceIdentityType - // 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. + // The identities assigned to this resource by the user. UserAssignedIdentities map[string]*UserAssignedIdentity // READ-ONLY; The service principal ID of the system assigned identity. This property will only be provided for a system assigned @@ -168,55 +160,6 @@ type ManagedServiceIdentity struct { TenantID *string } -// Operation - Details of a REST API operation, returned from the Resource Provider Operations API -type Operation struct { - // Localized display information for this particular operation. - Display *OperationDisplay - - // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - ActionType *ActionType - - // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for ARM/control-plane - // operations. - IsDataAction *bool - - // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", - // "Microsoft.Compute/virtualMachines/capture/action" - Name *string - - // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default - // value is "user,system" - Origin *Origin -} - -// OperationDisplay - Localized display information for this particular operation. -type OperationDisplay struct { - // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. - Description *string - - // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual - // Machine", "Restart Virtual Machine". - Operation *string - - // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft - // Compute". - Provider *string - - // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job - // Schedule Collections". - Resource *string -} - -// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to -// get the next set of results. -type OperationListResult struct { - // READ-ONLY; URL to get the next set of operation list results (if there are any). - NextLink *string - - // READ-ONLY; List of operations supported by the resource provider - Value []*Operation -} - // OutboundEnvironmentEndpoint - A collection of related endpoints from the same service for which the Batch service requires // outbound access. type OutboundEnvironmentEndpoint struct { @@ -227,31 +170,19 @@ type OutboundEnvironmentEndpoint struct { Endpoints []*EndpointDependency } -// OutboundEnvironmentEndpointCollection - Values returned by the List operation. -type OutboundEnvironmentEndpointCollection struct { - // The continuation token. - NextLink *string - - // READ-ONLY; The collection of outbound network dependency endpoints returned by the listing operation. +// PagedOutboundEnvironmentEndpoint - Values returned by the List operation. +type PagedOutboundEnvironmentEndpoint struct { + // REQUIRED; The OutboundEnvironmentEndpoint items on this page Value []*OutboundEnvironmentEndpoint + + // The link to the next page of items + NextLink *string } // QuotaBucketRequest - Request object of new quota for a quota bucket. type QuotaBucketRequest struct { - // New quota request request properties. + // Request object of new quota for a quota bucket. Properties *QuotaBucketRequestProperties - - // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string - - // READ-ONLY; The name of the resource - Name *string - - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData - - // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string } // QuotaBucketRequestProperties - New quota request request properties. @@ -280,15 +211,15 @@ type QuotaBucketRequestPropertiesDimensions struct { // QuotaResource - Quota bucket details object. type QuotaResource struct { - // Quota bucket resource properties. + // The resource-specific properties for this resource. Properties *QuotaResourceProperties + // READ-ONLY; The quota name. + Name *string + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} ID *string - // READ-ONLY; The name of the resource - Name *string - // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. SystemData *SystemData @@ -296,13 +227,13 @@ type QuotaResource struct { Type *string } -// QuotaResourceList - List of quota bucket objects. It contains a URL link to get the next set of results. -type QuotaResourceList struct { - // READ-ONLY; URL to get the next set of quota bucket objects results (if there are any). - NextLink *string - - // READ-ONLY; List of quota bucket objects provided by the loadtestservice. +// QuotaResourceListResult - The response of a QuotaResource list operation. +type QuotaResourceListResult struct { + // REQUIRED; The QuotaResource items on this page Value []*QuotaResource + + // The link to the next page of items + NextLink *string } // QuotaResourceProperties - Quota bucket resource properties. diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/models_serde.go b/sdk/resourcemanager/loadtesting/armloadtesting/models_serde.go index 389f360241ae..dc9843493440 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/models_serde.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/models_serde.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armloadtesting @@ -307,16 +303,16 @@ func (l *LoadTestResource) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type LoadTestResourcePageList. -func (l LoadTestResourcePageList) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type LoadTestResourceListResult. +func (l LoadTestResourceListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "nextLink", l.NextLink) populate(objectMap, "value", l.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type LoadTestResourcePageList. -func (l *LoadTestResourcePageList) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type LoadTestResourceListResult. +func (l *LoadTestResourceListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", l, err) @@ -338,8 +334,8 @@ func (l *LoadTestResourcePageList) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type LoadTestResourcePatchRequestBody. -func (l LoadTestResourcePatchRequestBody) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type LoadTestResourceUpdate. +func (l LoadTestResourceUpdate) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "identity", l.Identity) populate(objectMap, "properties", l.Properties) @@ -347,8 +343,8 @@ func (l LoadTestResourcePatchRequestBody) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type LoadTestResourcePatchRequestBody. -func (l *LoadTestResourcePatchRequestBody) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type LoadTestResourceUpdate. +func (l *LoadTestResourceUpdate) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", l, err) @@ -373,16 +369,16 @@ func (l *LoadTestResourcePatchRequestBody) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type LoadTestResourcePatchRequestBodyProperties. -func (l LoadTestResourcePatchRequestBodyProperties) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type LoadTestResourceUpdateProperties. +func (l LoadTestResourceUpdateProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "description", l.Description) populate(objectMap, "encryption", l.Encryption) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type LoadTestResourcePatchRequestBodyProperties. -func (l *LoadTestResourcePatchRequestBodyProperties) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type LoadTestResourceUpdateProperties. +func (l *LoadTestResourceUpdateProperties) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", l, err) @@ -443,119 +439,6 @@ func (m *ManagedServiceIdentity) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type Operation. -func (o Operation) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "actionType", o.ActionType) - populate(objectMap, "display", o.Display) - populate(objectMap, "isDataAction", o.IsDataAction) - populate(objectMap, "name", o.Name) - populate(objectMap, "origin", o.Origin) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. -func (o *Operation) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "actionType": - err = unpopulate(val, "ActionType", &o.ActionType) - delete(rawMsg, key) - case "display": - err = unpopulate(val, "Display", &o.Display) - delete(rawMsg, key) - case "isDataAction": - err = unpopulate(val, "IsDataAction", &o.IsDataAction) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &o.Name) - delete(rawMsg, key) - case "origin": - err = unpopulate(val, "Origin", &o.Origin) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. -func (o OperationDisplay) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "description", o.Description) - populate(objectMap, "operation", o.Operation) - populate(objectMap, "provider", o.Provider) - populate(objectMap, "resource", o.Resource) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. -func (o *OperationDisplay) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "description": - err = unpopulate(val, "Description", &o.Description) - delete(rawMsg, key) - case "operation": - err = unpopulate(val, "Operation", &o.Operation) - delete(rawMsg, key) - case "provider": - err = unpopulate(val, "Provider", &o.Provider) - delete(rawMsg, key) - case "resource": - err = unpopulate(val, "Resource", &o.Resource) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - } - return nil -} - -// MarshalJSON implements the json.Marshaller interface for type OperationListResult. -func (o OperationListResult) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]any) - populate(objectMap, "nextLink", o.NextLink) - populate(objectMap, "value", o.Value) - return json.Marshal(objectMap) -} - -// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. -func (o *OperationListResult) UnmarshalJSON(data []byte) error { - var rawMsg map[string]json.RawMessage - if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - for key, val := range rawMsg { - var err error - switch key { - case "nextLink": - err = unpopulate(val, "NextLink", &o.NextLink) - delete(rawMsg, key) - case "value": - err = unpopulate(val, "Value", &o.Value) - delete(rawMsg, key) - } - if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) - } - } - return nil -} - // MarshalJSON implements the json.Marshaller interface for type OutboundEnvironmentEndpoint. func (o OutboundEnvironmentEndpoint) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) @@ -587,32 +470,32 @@ func (o *OutboundEnvironmentEndpoint) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type OutboundEnvironmentEndpointCollection. -func (o OutboundEnvironmentEndpointCollection) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type PagedOutboundEnvironmentEndpoint. +func (p PagedOutboundEnvironmentEndpoint) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "nextLink", o.NextLink) - populate(objectMap, "value", o.Value) + populate(objectMap, "nextLink", p.NextLink) + populate(objectMap, "value", p.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type OutboundEnvironmentEndpointCollection. -func (o *OutboundEnvironmentEndpointCollection) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type PagedOutboundEnvironmentEndpoint. +func (p *PagedOutboundEnvironmentEndpoint) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } for key, val := range rawMsg { var err error switch key { case "nextLink": - err = unpopulate(val, "NextLink", &o.NextLink) + err = unpopulate(val, "NextLink", &p.NextLink) delete(rawMsg, key) case "value": - err = unpopulate(val, "Value", &o.Value) + err = unpopulate(val, "Value", &p.Value) delete(rawMsg, key) } if err != nil { - return fmt.Errorf("unmarshalling type %T: %v", o, err) + return fmt.Errorf("unmarshalling type %T: %v", p, err) } } return nil @@ -621,11 +504,7 @@ func (o *OutboundEnvironmentEndpointCollection) UnmarshalJSON(data []byte) error // MarshalJSON implements the json.Marshaller interface for type QuotaBucketRequest. func (q QuotaBucketRequest) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populate(objectMap, "id", q.ID) - populate(objectMap, "name", q.Name) populate(objectMap, "properties", q.Properties) - populate(objectMap, "systemData", q.SystemData) - populate(objectMap, "type", q.Type) return json.Marshal(objectMap) } @@ -638,21 +517,9 @@ func (q *QuotaBucketRequest) UnmarshalJSON(data []byte) error { for key, val := range rawMsg { var err error switch key { - case "id": - err = unpopulate(val, "ID", &q.ID) - delete(rawMsg, key) - case "name": - err = unpopulate(val, "Name", &q.Name) - delete(rawMsg, key) case "properties": err = unpopulate(val, "Properties", &q.Properties) delete(rawMsg, key) - case "systemData": - err = unpopulate(val, "SystemData", &q.SystemData) - delete(rawMsg, key) - case "type": - err = unpopulate(val, "Type", &q.Type) - delete(rawMsg, key) } if err != nil { return fmt.Errorf("unmarshalling type %T: %v", q, err) @@ -774,16 +641,16 @@ func (q *QuotaResource) UnmarshalJSON(data []byte) error { return nil } -// MarshalJSON implements the json.Marshaller interface for type QuotaResourceList. -func (q QuotaResourceList) MarshalJSON() ([]byte, error) { +// MarshalJSON implements the json.Marshaller interface for type QuotaResourceListResult. +func (q QuotaResourceListResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "nextLink", q.NextLink) populate(objectMap, "value", q.Value) return json.Marshal(objectMap) } -// UnmarshalJSON implements the json.Unmarshaller interface for type QuotaResourceList. -func (q *QuotaResourceList) UnmarshalJSON(data []byte) error { +// UnmarshalJSON implements the json.Unmarshaller interface for type QuotaResourceListResult. +func (q *QuotaResourceListResult) UnmarshalJSON(data []byte) error { var rawMsg map[string]json.RawMessage if err := json.Unmarshal(data, &rawMsg); err != nil { return fmt.Errorf("unmarshalling type %T: %v", q, err) @@ -929,7 +796,7 @@ func populate(m map[string]any, k string, v any) { } func unpopulate(data json.RawMessage, fn string, v any) error { - if data == nil { + if data == nil || string(data) == "null" { return nil } if err := json.Unmarshal(data, v); err != nil { diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/operations_client_example_test.go b/sdk/resourcemanager/loadtesting/armloadtesting/operations_client_example_test.go deleted file mode 100644 index b6cd3fdb9fd1..000000000000 --- a/sdk/resourcemanager/loadtesting/armloadtesting/operations_client_example_test.go +++ /dev/null @@ -1,76 +0,0 @@ -//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. -// DO NOT EDIT. - -package armloadtesting_test - -import ( - "context" - "log" - - "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtesting/armloadtesting" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/630ec444f8dd7c09b9cdd5fa99951f8a0d1ad41f/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Operations_List.json -func ExampleOperationsClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armloadtesting.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewOperationsClient().NewListPager(nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.OperationListResult = armloadtesting.OperationListResult{ - // Value: []*armloadtesting.Operation{ - // { - // Name: to.Ptr("Microsoft.LoadTestService/loadTests/Write"), - // Display: &armloadtesting.OperationDisplay{ - // Description: to.Ptr("Set LoadTests"), - // Operation: to.Ptr("Creates or updates the LoadTests"), - // Provider: to.Ptr("Microsoft.LoadTestService"), - // Resource: to.Ptr("loadTests"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("Microsoft.LoadTestService/loadTests/Delete"), - // Display: &armloadtesting.OperationDisplay{ - // Description: to.Ptr("Delete LoadTests"), - // Operation: to.Ptr("Deletes the LoadTests"), - // Provider: to.Ptr("Microsoft.LoadTestService"), - // Resource: to.Ptr("loadTests"), - // }, - // IsDataAction: to.Ptr(false), - // }, - // { - // Name: to.Ptr("Microsoft.LoadTestService/loadTests/Read"), - // Display: &armloadtesting.OperationDisplay{ - // Description: to.Ptr("Read LoadTests"), - // Operation: to.Ptr("Reads the LoadTests"), - // Provider: to.Ptr("Microsoft.LoadTestService"), - // Resource: to.Ptr("loadTests"), - // }, - // IsDataAction: to.Ptr(false), - // }}, - // } - } -} diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/options.go b/sdk/resourcemanager/loadtesting/armloadtesting/options.go index 319a242068ee..b9f963f7eca8 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/options.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/options.go @@ -1,71 +1,65 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armloadtesting -// LoadTestsClientBeginCreateOrUpdateOptions contains the optional parameters for the LoadTestsClient.BeginCreateOrUpdate +// LoadTestMgmtClientBeginCreateOrUpdateLoadtestOptions contains the optional parameters for the LoadTestMgmtClient.BeginCreateOrUpdateLoadtest // method. -type LoadTestsClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. +type LoadTestMgmtClientBeginCreateOrUpdateLoadtestOptions struct { + // Resumes the long-running operation from the provided token. ResumeToken string } -// LoadTestsClientBeginDeleteOptions contains the optional parameters for the LoadTestsClient.BeginDelete method. -type LoadTestsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. +// LoadTestMgmtClientBeginDeleteLoadtestOptions contains the optional parameters for the LoadTestMgmtClient.BeginDeleteLoadtest +// method. +type LoadTestMgmtClientBeginDeleteLoadtestOptions struct { + // Resumes the long-running operation from the provided token. ResumeToken string } -// LoadTestsClientBeginUpdateOptions contains the optional parameters for the LoadTestsClient.BeginUpdate method. -type LoadTestsClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. +// LoadTestMgmtClientBeginUpdateLoadtestOptions contains the optional parameters for the LoadTestMgmtClient.BeginUpdateLoadtest +// method. +type LoadTestMgmtClientBeginUpdateLoadtestOptions struct { + // Resumes the long-running operation from the provided token. ResumeToken string } -// LoadTestsClientGetOptions contains the optional parameters for the LoadTestsClient.Get method. -type LoadTestsClientGetOptions struct { - // placeholder for future optional parameters -} - -// LoadTestsClientListByResourceGroupOptions contains the optional parameters for the LoadTestsClient.NewListByResourceGroupPager +// LoadTestMgmtClientCheckAvailabilityQuotaOptions contains the optional parameters for the LoadTestMgmtClient.CheckAvailabilityQuota // method. -type LoadTestsClientListByResourceGroupOptions struct { +type LoadTestMgmtClientCheckAvailabilityQuotaOptions struct { // placeholder for future optional parameters } -// LoadTestsClientListBySubscriptionOptions contains the optional parameters for the LoadTestsClient.NewListBySubscriptionPager -// method. -type LoadTestsClientListBySubscriptionOptions struct { +// LoadTestMgmtClientGetLoadtestOptions contains the optional parameters for the LoadTestMgmtClient.GetLoadtest method. +type LoadTestMgmtClientGetLoadtestOptions struct { // placeholder for future optional parameters } -// LoadTestsClientListOutboundNetworkDependenciesEndpointsOptions contains the optional parameters for the LoadTestsClient.NewListOutboundNetworkDependenciesEndpointsPager -// method. -type LoadTestsClientListOutboundNetworkDependenciesEndpointsOptions struct { +// LoadTestMgmtClientGetQuotaOptions contains the optional parameters for the LoadTestMgmtClient.GetQuota method. +type LoadTestMgmtClientGetQuotaOptions struct { // placeholder for future optional parameters } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. -type OperationsClientListOptions struct { +// LoadTestMgmtClientListByResourceGroupOptions contains the optional parameters for the LoadTestMgmtClient.NewListByResourceGroupPager +// method. +type LoadTestMgmtClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// QuotasClientCheckAvailabilityOptions contains the optional parameters for the QuotasClient.CheckAvailability method. -type QuotasClientCheckAvailabilityOptions struct { +// LoadTestMgmtClientListBySubscriptionOptions contains the optional parameters for the LoadTestMgmtClient.NewListBySubscriptionPager +// method. +type LoadTestMgmtClientListBySubscriptionOptions struct { // placeholder for future optional parameters } -// QuotasClientGetOptions contains the optional parameters for the QuotasClient.Get method. -type QuotasClientGetOptions struct { +// LoadTestMgmtClientListQuotaOptions contains the optional parameters for the LoadTestMgmtClient.NewListQuotaPager method. +type LoadTestMgmtClientListQuotaOptions struct { // placeholder for future optional parameters } -// QuotasClientListOptions contains the optional parameters for the QuotasClient.NewListPager method. -type QuotasClientListOptions struct { +// LoadTestMgmtClientOutboundNetworkDependenciesEndpointsOptions contains the optional parameters for the LoadTestMgmtClient.NewOutboundNetworkDependenciesEndpointsPager +// method. +type LoadTestMgmtClientOutboundNetworkDependenciesEndpointsOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/quotas_client.go b/sdk/resourcemanager/loadtesting/armloadtesting/quotas_client.go deleted file mode 100644 index 996cc9dd0dbe..000000000000 --- a/sdk/resourcemanager/loadtesting/armloadtesting/quotas_client.go +++ /dev/null @@ -1,236 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armloadtesting - -import ( - "context" - "errors" - "github.com/Azure/azure-sdk-for-go/sdk/azcore" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" - "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "net/http" - "net/url" - "strings" -) - -// QuotasClient contains the methods for the Quotas group. -// Don't use this type directly, use NewQuotasClient() instead. -type QuotasClient struct { - internal *arm.Client - subscriptionID string -} - -// NewQuotasClient creates a new instance of QuotasClient with the specified values. -// - 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 NewQuotasClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*QuotasClient, error) { - cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) - if err != nil { - return nil, err - } - client := &QuotasClient{ - subscriptionID: subscriptionID, - internal: cl, - } - return client, nil -} - -// CheckAvailability - Check Quota Availability on quota bucket per region per subscription. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-12-01 -// - location - The name of Azure region. -// - quotaBucketName - Quota Bucket name. -// - quotaBucketRequest - Quota Bucket Request data -// - options - QuotasClientCheckAvailabilityOptions contains the optional parameters for the QuotasClient.CheckAvailability -// method. -func (client *QuotasClient) CheckAvailability(ctx context.Context, location string, quotaBucketName string, quotaBucketRequest QuotaBucketRequest, options *QuotasClientCheckAvailabilityOptions) (QuotasClientCheckAvailabilityResponse, error) { - var err error - const operationName = "QuotasClient.CheckAvailability" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.checkAvailabilityCreateRequest(ctx, location, quotaBucketName, quotaBucketRequest, options) - if err != nil { - return QuotasClientCheckAvailabilityResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return QuotasClientCheckAvailabilityResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return QuotasClientCheckAvailabilityResponse{}, err - } - resp, err := client.checkAvailabilityHandleResponse(httpResp) - return resp, err -} - -// checkAvailabilityCreateRequest creates the CheckAvailability request. -func (client *QuotasClient) checkAvailabilityCreateRequest(ctx context.Context, location string, quotaBucketName string, quotaBucketRequest QuotaBucketRequest, options *QuotasClientCheckAvailabilityOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/locations/{location}/quotas/{quotaBucketName}/checkAvailability" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if location == "" { - return nil, errors.New("parameter location cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) - if quotaBucketName == "" { - return nil, errors.New("parameter quotaBucketName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{quotaBucketName}", url.PathEscape(quotaBucketName)) - req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-12-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - if err := runtime.MarshalAsJSON(req, quotaBucketRequest); err != nil { - return nil, err - } - return req, nil -} - -// checkAvailabilityHandleResponse handles the CheckAvailability response. -func (client *QuotasClient) checkAvailabilityHandleResponse(resp *http.Response) (QuotasClientCheckAvailabilityResponse, error) { - result := QuotasClientCheckAvailabilityResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.CheckQuotaAvailabilityResponse); err != nil { - return QuotasClientCheckAvailabilityResponse{}, err - } - return result, nil -} - -// Get - Get the available quota for a quota bucket per region per subscription. -// If the operation fails it returns an *azcore.ResponseError type. -// -// Generated from API version 2022-12-01 -// - location - The name of Azure region. -// - quotaBucketName - Quota Bucket name. -// - options - QuotasClientGetOptions contains the optional parameters for the QuotasClient.Get method. -func (client *QuotasClient) Get(ctx context.Context, location string, quotaBucketName string, options *QuotasClientGetOptions) (QuotasClientGetResponse, error) { - var err error - const operationName = "QuotasClient.Get" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.getCreateRequest(ctx, location, quotaBucketName, options) - if err != nil { - return QuotasClientGetResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return QuotasClientGetResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return QuotasClientGetResponse{}, err - } - resp, err := client.getHandleResponse(httpResp) - return resp, err -} - -// getCreateRequest creates the Get request. -func (client *QuotasClient) getCreateRequest(ctx context.Context, location string, quotaBucketName string, options *QuotasClientGetOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/locations/{location}/quotas/{quotaBucketName}" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if location == "" { - return nil, errors.New("parameter location cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) - if quotaBucketName == "" { - return nil, errors.New("parameter quotaBucketName cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{quotaBucketName}", url.PathEscape(quotaBucketName)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-12-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// getHandleResponse handles the Get response. -func (client *QuotasClient) getHandleResponse(resp *http.Response) (QuotasClientGetResponse, error) { - result := QuotasClientGetResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.QuotaResource); err != nil { - return QuotasClientGetResponse{}, err - } - return result, nil -} - -// NewListPager - Lists all the available quota per region per subscription. -// -// Generated from API version 2022-12-01 -// - location - The name of Azure region. -// - options - QuotasClientListOptions contains the optional parameters for the QuotasClient.NewListPager method. -func (client *QuotasClient) NewListPager(location string, options *QuotasClientListOptions) *runtime.Pager[QuotasClientListResponse] { - return runtime.NewPager(runtime.PagingHandler[QuotasClientListResponse]{ - More: func(page QuotasClientListResponse) bool { - return page.NextLink != nil && len(*page.NextLink) > 0 - }, - Fetcher: func(ctx context.Context, page *QuotasClientListResponse) (QuotasClientListResponse, error) { - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "QuotasClient.NewListPager") - nextLink := "" - if page != nil { - nextLink = *page.NextLink - } - resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { - return client.listCreateRequest(ctx, location, options) - }, nil) - if err != nil { - return QuotasClientListResponse{}, err - } - return client.listHandleResponse(resp) - }, - Tracer: client.internal.Tracer(), - }) -} - -// listCreateRequest creates the List request. -func (client *QuotasClient) listCreateRequest(ctx context.Context, location string, options *QuotasClientListOptions) (*policy.Request, error) { - urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/locations/{location}/quotas" - if client.subscriptionID == "" { - return nil, errors.New("parameter client.subscriptionID cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) - if location == "" { - return nil, errors.New("parameter location cannot be empty") - } - urlPath = strings.ReplaceAll(urlPath, "{location}", url.PathEscape(location)) - req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) - if err != nil { - return nil, err - } - reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-12-01") - req.Raw().URL.RawQuery = reqQP.Encode() - req.Raw().Header["Accept"] = []string{"application/json"} - return req, nil -} - -// listHandleResponse handles the List response. -func (client *QuotasClient) listHandleResponse(resp *http.Response) (QuotasClientListResponse, error) { - result := QuotasClientListResponse{} - if err := runtime.UnmarshalAsJSON(resp, &result.QuotaResourceList); err != nil { - return QuotasClientListResponse{}, err - } - return result, nil -} diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/quotas_client_example_test.go b/sdk/resourcemanager/loadtesting/armloadtesting/quotas_client_example_test.go deleted file mode 100644 index 5e1d10b1ad95..000000000000 --- a/sdk/resourcemanager/loadtesting/armloadtesting/quotas_client_example_test.go +++ /dev/null @@ -1,124 +0,0 @@ -//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. -// DO NOT EDIT. - -package armloadtesting_test - -import ( - "context" - "log" - - "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/loadtesting/armloadtesting" -) - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/630ec444f8dd7c09b9cdd5fa99951f8a0d1ad41f/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_List.json -func ExampleQuotasClient_NewListPager() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armloadtesting.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - pager := clientFactory.NewQuotasClient().NewListPager("westus", nil) - for pager.More() { - page, err := pager.NextPage(ctx) - if err != nil { - log.Fatalf("failed to advance page: %v", err) - } - for _, v := range page.Value { - // You could use page here. We use blank identifier for just demo purposes. - _ = v - } - // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // page.QuotaResourceList = armloadtesting.QuotaResourceList{ - // Value: []*armloadtesting.QuotaResource{ - // { - // Name: to.Ptr("testQuotaBucket"), - // Type: to.Ptr("Microsoft.LoadTestService/locations/quotas"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.LoadTestService/locations/westus/quotas/testQuotaBucket"), - // Properties: &armloadtesting.QuotaResourceProperties{ - // Limit: to.Ptr[int32](50), - // Usage: to.Ptr[int32](20), - // }, - // }}, - // } - } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/630ec444f8dd7c09b9cdd5fa99951f8a0d1ad41f/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_Get.json -func ExampleQuotasClient_Get() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armloadtesting.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQuotasClient().Get(ctx, "westus", "testQuotaBucket", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.QuotaResource = armloadtesting.QuotaResource{ - // Name: to.Ptr("testQuotaBucket"), - // Type: to.Ptr("Microsoft.LoadTestService/locations/quotas"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.LoadTestService/locations/westus/quotas/testQuotaBucket"), - // Properties: &armloadtesting.QuotaResourceProperties{ - // Limit: to.Ptr[int32](50), - // Usage: to.Ptr[int32](20), - // }, - // } -} - -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/630ec444f8dd7c09b9cdd5fa99951f8a0d1ad41f/specification/loadtestservice/resource-manager/Microsoft.LoadTestService/stable/2022-12-01/examples/Quotas_CheckAvailability.json -func ExampleQuotasClient_CheckAvailability() { - cred, err := azidentity.NewDefaultAzureCredential(nil) - if err != nil { - log.Fatalf("failed to obtain a credential: %v", err) - } - ctx := context.Background() - clientFactory, err := armloadtesting.NewClientFactory("", cred, nil) - if err != nil { - log.Fatalf("failed to create client: %v", err) - } - res, err := clientFactory.NewQuotasClient().CheckAvailability(ctx, "westus", "testQuotaBucket", armloadtesting.QuotaBucketRequest{ - Properties: &armloadtesting.QuotaBucketRequestProperties{ - CurrentQuota: to.Ptr[int32](40), - CurrentUsage: to.Ptr[int32](20), - Dimensions: &armloadtesting.QuotaBucketRequestPropertiesDimensions{ - Location: to.Ptr("westus"), - SubscriptionID: to.Ptr("testsubscriptionId"), - }, - NewQuota: to.Ptr[int32](50), - }, - }, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) - } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.CheckQuotaAvailabilityResponse = armloadtesting.CheckQuotaAvailabilityResponse{ - // Name: to.Ptr("testQuotaBucket"), - // Type: to.Ptr("Microsoft.LoadTestService/locations/quotas"), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.LoadTestService/locations/westus/quotas/testQuotaBucket"), - // Properties: &armloadtesting.CheckQuotaAvailabilityResponseProperties{ - // AvailabilityStatus: to.Ptr("The requested quota is currently unavailable. Please request for different quota, or upgrade subscription offer type and try again later."), - // IsAvailable: to.Ptr(false), - // }, - // } -} diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/response_types.go b/sdk/resourcemanager/loadtesting/armloadtesting/response_types.go deleted file mode 100644 index bac914afaefd..000000000000 --- a/sdk/resourcemanager/loadtesting/armloadtesting/response_types.go +++ /dev/null @@ -1,74 +0,0 @@ -//go:build go1.18 -// +build go1.18 - -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -package armloadtesting - -// LoadTestsClientCreateOrUpdateResponse contains the response from method LoadTestsClient.BeginCreateOrUpdate. -type LoadTestsClientCreateOrUpdateResponse struct { - // LoadTest details - LoadTestResource -} - -// LoadTestsClientDeleteResponse contains the response from method LoadTestsClient.BeginDelete. -type LoadTestsClientDeleteResponse struct { - // placeholder for future response values -} - -// LoadTestsClientGetResponse contains the response from method LoadTestsClient.Get. -type LoadTestsClientGetResponse struct { - // LoadTest details - LoadTestResource -} - -// LoadTestsClientListByResourceGroupResponse contains the response from method LoadTestsClient.NewListByResourceGroupPager. -type LoadTestsClientListByResourceGroupResponse struct { - // List of resources page result. - LoadTestResourcePageList -} - -// LoadTestsClientListBySubscriptionResponse contains the response from method LoadTestsClient.NewListBySubscriptionPager. -type LoadTestsClientListBySubscriptionResponse struct { - // List of resources page result. - LoadTestResourcePageList -} - -// LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse contains the response from method LoadTestsClient.NewListOutboundNetworkDependenciesEndpointsPager. -type LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse struct { - // Values returned by the List operation. - OutboundEnvironmentEndpointCollection -} - -// LoadTestsClientUpdateResponse contains the response from method LoadTestsClient.BeginUpdate. -type LoadTestsClientUpdateResponse struct { - // LoadTest details - LoadTestResource -} - -// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. -type OperationsClientListResponse struct { - // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. - OperationListResult -} - -// QuotasClientCheckAvailabilityResponse contains the response from method QuotasClient.CheckAvailability. -type QuotasClientCheckAvailabilityResponse struct { - // Check quota availability response object. - CheckQuotaAvailabilityResponse -} - -// QuotasClientGetResponse contains the response from method QuotasClient.Get. -type QuotasClientGetResponse struct { - // Quota bucket details object. - QuotaResource -} - -// QuotasClientListResponse contains the response from method QuotasClient.NewListPager. -type QuotasClientListResponse struct { - // List of quota bucket objects. It contains a URL link to get the next set of results. - QuotaResourceList -} diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/responses.go b/sdk/resourcemanager/loadtesting/armloadtesting/responses.go new file mode 100644 index 000000000000..cab4c637fe01 --- /dev/null +++ b/sdk/resourcemanager/loadtesting/armloadtesting/responses.go @@ -0,0 +1,63 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armloadtesting + +// LoadTestMgmtClientCheckAvailabilityQuotaResponse contains the response from method LoadTestMgmtClient.CheckAvailabilityQuota. +type LoadTestMgmtClientCheckAvailabilityQuotaResponse struct { + // Check quota availability response object. + CheckQuotaAvailabilityResponse +} + +// LoadTestMgmtClientCreateOrUpdateLoadtestResponse contains the response from method LoadTestMgmtClient.BeginCreateOrUpdateLoadtest. +type LoadTestMgmtClientCreateOrUpdateLoadtestResponse struct { + // LoadTest details. + LoadTestResource +} + +// LoadTestMgmtClientDeleteLoadtestResponse contains the response from method LoadTestMgmtClient.BeginDeleteLoadtest. +type LoadTestMgmtClientDeleteLoadtestResponse struct { + // placeholder for future response values +} + +// LoadTestMgmtClientGetLoadtestResponse contains the response from method LoadTestMgmtClient.GetLoadtest. +type LoadTestMgmtClientGetLoadtestResponse struct { + // LoadTest details. + LoadTestResource +} + +// LoadTestMgmtClientGetQuotaResponse contains the response from method LoadTestMgmtClient.GetQuota. +type LoadTestMgmtClientGetQuotaResponse struct { + // Quota bucket details object. + QuotaResource +} + +// LoadTestMgmtClientListByResourceGroupResponse contains the response from method LoadTestMgmtClient.NewListByResourceGroupPager. +type LoadTestMgmtClientListByResourceGroupResponse struct { + // The response of a LoadTestResource list operation. + LoadTestResourceListResult +} + +// LoadTestMgmtClientListBySubscriptionResponse contains the response from method LoadTestMgmtClient.NewListBySubscriptionPager. +type LoadTestMgmtClientListBySubscriptionResponse struct { + // The response of a LoadTestResource list operation. + LoadTestResourceListResult +} + +// LoadTestMgmtClientListQuotaResponse contains the response from method LoadTestMgmtClient.NewListQuotaPager. +type LoadTestMgmtClientListQuotaResponse struct { + // The response of a QuotaResource list operation. + QuotaResourceListResult +} + +// LoadTestMgmtClientOutboundNetworkDependenciesEndpointsResponse contains the response from method LoadTestMgmtClient.NewOutboundNetworkDependenciesEndpointsPager. +type LoadTestMgmtClientOutboundNetworkDependenciesEndpointsResponse struct { + // Values returned by the List operation. + PagedOutboundEnvironmentEndpoint +} + +// LoadTestMgmtClientUpdateLoadtestResponse contains the response from method LoadTestMgmtClient.BeginUpdateLoadtest. +type LoadTestMgmtClientUpdateLoadtestResponse struct { + // placeholder for future response values +} diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/time_rfc3339.go b/sdk/resourcemanager/loadtesting/armloadtesting/time_rfc3339.go index da6dcc2e1872..16b0b1b9271a 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/time_rfc3339.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/time_rfc3339.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package armloadtesting @@ -19,12 +15,16 @@ import ( ) // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. -var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) const ( - utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` - utcDateTime = "2006-01-02T15:04:05.999999999" - dateTimeJSON = `"` + time.RFC3339Nano + `"` + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` ) type dateTimeRFC3339 time.Time @@ -40,17 +40,36 @@ func (t dateTimeRFC3339) MarshalText() ([]byte, error) { } func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcDateTimeJSON - if tzOffsetRegex.Match(data) { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT } return t.Parse(layout, string(data)) } func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { - layout := utcDateTime - if tzOffsetRegex.Match(data) { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT } return t.Parse(layout, string(data)) } @@ -61,6 +80,10 @@ func (t *dateTimeRFC3339) Parse(layout, value string) error { return err } +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return @@ -74,7 +97,7 @@ func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { } func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { - if data == nil || strings.EqualFold(string(data), "null") { + if data == nil || string(data) == "null" { return nil } var aux dateTimeRFC3339 diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/tsp-location.yaml b/sdk/resourcemanager/loadtesting/armloadtesting/tsp-location.yaml new file mode 100644 index 000000000000..d11df680e3bf --- /dev/null +++ b/sdk/resourcemanager/loadtesting/armloadtesting/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/loadtestservice/LoadTestService.Management +commit: 02d891edd0a78d71fdaa969f028261a831432c54 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/resourcemanager/playwright/armplaywright/CHANGELOG.md b/sdk/resourcemanager/playwright/armplaywright/CHANGELOG.md new file mode 100644 index 000000000000..1793cd32b68e --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/CHANGELOG.md @@ -0,0 +1,8 @@ +# Release History + +## 0.1.0 (2025-04-29) +### Other Changes + +The package of `github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/playwright/armplaywright` is using our [next generation design principles](https://azure.github.io/azure-sdk/general_introduction.html). + +To learn more, please refer to our documentation [Quick Start](https://aka.ms/azsdk/go/mgmt). \ No newline at end of file diff --git a/sdk/resourcemanager/playwright/armplaywright/LICENSE.txt b/sdk/resourcemanager/playwright/armplaywright/LICENSE.txt new file mode 100644 index 000000000000..dc0c2ffb3dc1 --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/LICENSE.txt @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Microsoft Corporation. All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. \ No newline at end of file diff --git a/sdk/resourcemanager/playwright/armplaywright/README.md b/sdk/resourcemanager/playwright/armplaywright/README.md new file mode 100644 index 000000000000..66dcbca01f74 --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/README.md @@ -0,0 +1,90 @@ +# Azure Playwright Module for Go + +The `armplaywright` module provides operations for working with Azure Playwright. + +[Source code](https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/resourcemanager/playwright/armplaywright) + +# Getting started + +## Prerequisites + +- an [Azure subscription](https://azure.microsoft.com/free/) +- Go 1.18 or above (You could download and install the latest version of Go from [here](https://go.dev/doc/install). It will replace the existing Go on your machine. If you want to install multiple Go versions on the same machine, you could refer this [doc](https://go.dev/doc/manage-install).) + +## Install the package + +This project uses [Go modules](https://github.com/golang/go/wiki/Modules) for versioning and dependency management. + +Install the Azure Playwright module: + +```sh +go get github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/playwright/armplaywright +``` + +## Authorization + +When creating a client, you will need to provide a credential for authenticating with Azure Playwright. The `azidentity` module provides facilities for various ways of authenticating with Azure including client/secret, certificate, managed identity, and more. + +```go +cred, err := azidentity.NewDefaultAzureCredential(nil) +``` + +For more information on authentication, please see the documentation for `azidentity` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azidentity). + +## Client Factory + +Azure Playwright module consists of one or more clients. We provide a client factory which could be used to create any client in this module. + +```go +clientFactory, err := armplaywright.NewClientFactory(, cred, nil) +``` + +You can use `ClientOptions` in package `github.com/Azure/azure-sdk-for-go/sdk/azcore/arm` to set endpoint to connect with public and sovereign clouds as well as Azure Stack. For more information, please see the documentation for `azcore` at [pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore](https://pkg.go.dev/github.com/Azure/azure-sdk-for-go/sdk/azcore). + +```go +options := arm.ClientOptions { + ClientOptions: azcore.ClientOptions { + Cloud: cloud.AzureChina, + }, +} +clientFactory, err := armplaywright.NewClientFactory(, cred, &options) +``` + +## Clients + +A client groups a set of related APIs, providing access to its functionality. Create one or more clients to access the APIs you require using client factory. + +```go +client := clientFactory.NewWorkspacesClient() +``` + +## Fakes + +The fake package contains types used for constructing in-memory fake servers used in unit tests. +This allows writing tests to cover various success/error conditions without the need for connecting to a live service. + +Please see https://github.com/Azure/azure-sdk-for-go/tree/main/sdk/samples/fakes for details and examples on how to use fakes. + +## Provide Feedback + +If you encounter bugs or have suggestions, please +[open an issue](https://github.com/Azure/azure-sdk-for-go/issues) and assign the `Playwright` label. + +# Contributing + +This project welcomes contributions and suggestions. Most contributions require +you to agree to a Contributor License Agreement (CLA) declaring that you have +the right to, and actually do, grant us the rights to use your contribution. +For details, visit [https://cla.microsoft.com](https://cla.microsoft.com). + +When you submit a pull request, a CLA-bot will automatically determine whether +you need to provide a CLA and decorate the PR appropriately (e.g., label, +comment). Simply follow the instructions provided by the bot. You will only +need to do this once across all repos using our CLA. + +This project has adopted the +[Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). +For more information, see the +[Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) +or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any +additional questions or comments. \ No newline at end of file diff --git a/sdk/resourcemanager/playwright/armplaywright/ci.yml b/sdk/resourcemanager/playwright/armplaywright/ci.yml new file mode 100644 index 000000000000..e1d968c3c61d --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/ci.yml @@ -0,0 +1,27 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. +trigger: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/playwright/armplaywright/ + +pr: + branches: + include: + - main + - feature/* + - hotfix/* + - release/* + paths: + include: + - sdk/resourcemanager/playwright/armplaywright/ + +extends: + template: /eng/pipelines/templates/jobs/archetype-sdk-client.yml + parameters: + ServiceDirectory: 'resourcemanager/playwright/armplaywright' diff --git a/sdk/resourcemanager/playwright/armplaywright/client_factory.go b/sdk/resourcemanager/playwright/armplaywright/client_factory.go new file mode 100644 index 000000000000..d8dd2c1ce13c --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/client_factory.go @@ -0,0 +1,48 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armplaywright + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" +) + +// ClientFactory is a client factory used to create any client in this module. +// Don't use this type directly, use NewClientFactory instead. +type ClientFactory struct { + subscriptionID string + internal *arm.Client +} + +// NewClientFactory creates a new instance of ClientFactory with the specified values. +// The parameter values will be propagated to any client created from this factory. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClientFactory, error) { + internal, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + return &ClientFactory{ + subscriptionID: subscriptionID, + internal: internal, + }, nil +} + +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + return &OperationsClient{ + internal: c.internal, + } +} + +// NewWorkspacesClient creates a new instance of WorkspacesClient. +func (c *ClientFactory) NewWorkspacesClient() *WorkspacesClient { + return &WorkspacesClient{ + subscriptionID: c.subscriptionID, + internal: c.internal, + } +} diff --git a/sdk/resourcemanager/playwright/armplaywright/constants.go b/sdk/resourcemanager/playwright/armplaywright/constants.go new file mode 100644 index 000000000000..1635bd94ab06 --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/constants.go @@ -0,0 +1,137 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armplaywright + +const ( + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/playwright/armplaywright" + moduleVersion = "v0.1.0" +) + +// ActionType - Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. +type ActionType string + +const ( + // ActionTypeInternal - Actions are for internal-only APIs. + ActionTypeInternal ActionType = "Internal" +) + +// PossibleActionTypeValues returns the possible values for the ActionType const type. +func PossibleActionTypeValues() []ActionType { + return []ActionType{ + ActionTypeInternal, + } +} + +// CheckNameAvailabilityReason - Possible reasons for a name not being available. +type CheckNameAvailabilityReason string + +const ( + // CheckNameAvailabilityReasonAlreadyExists - Name already exists. + CheckNameAvailabilityReasonAlreadyExists CheckNameAvailabilityReason = "AlreadyExists" + // CheckNameAvailabilityReasonInvalid - Name is invalid. + CheckNameAvailabilityReasonInvalid CheckNameAvailabilityReason = "Invalid" +) + +// PossibleCheckNameAvailabilityReasonValues returns the possible values for the CheckNameAvailabilityReason const type. +func PossibleCheckNameAvailabilityReasonValues() []CheckNameAvailabilityReason { + return []CheckNameAvailabilityReason{ + CheckNameAvailabilityReasonAlreadyExists, + CheckNameAvailabilityReasonInvalid, + } +} + +// CreatedByType - The kind of entity that created the resource. +type CreatedByType string + +const ( + // CreatedByTypeApplication - The entity was created by an application. + CreatedByTypeApplication CreatedByType = "Application" + // CreatedByTypeKey - The entity was created by a key. + CreatedByTypeKey CreatedByType = "Key" + // CreatedByTypeManagedIdentity - The entity was created by a managed identity. + CreatedByTypeManagedIdentity CreatedByType = "ManagedIdentity" + // CreatedByTypeUser - The entity was created by a user. + CreatedByTypeUser CreatedByType = "User" +) + +// PossibleCreatedByTypeValues returns the possible values for the CreatedByType const type. +func PossibleCreatedByTypeValues() []CreatedByType { + return []CreatedByType{ + CreatedByTypeApplication, + CreatedByTypeKey, + CreatedByTypeManagedIdentity, + CreatedByTypeUser, + } +} + +// EnablementStatus - The enablement status of a feature. +type EnablementStatus string + +const ( + // EnablementStatusDisabled - The feature is Disabled. + EnablementStatusDisabled EnablementStatus = "Disabled" + // EnablementStatusEnabled - The feature is Enabled. + EnablementStatusEnabled EnablementStatus = "Enabled" +) + +// PossibleEnablementStatusValues returns the possible values for the EnablementStatus const type. +func PossibleEnablementStatusValues() []EnablementStatus { + return []EnablementStatus{ + EnablementStatusDisabled, + EnablementStatusEnabled, + } +} + +// Origin - The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default +// value is "user,system" +type Origin string + +const ( + // OriginSystem - Indicates the operation is initiated by a system. + OriginSystem Origin = "system" + // OriginUser - Indicates the operation is initiated by a user. + OriginUser Origin = "user" + // OriginUserSystem - Indicates the operation is initiated by a user or system. + OriginUserSystem Origin = "user,system" +) + +// PossibleOriginValues returns the possible values for the Origin const type. +func PossibleOriginValues() []Origin { + return []Origin{ + OriginSystem, + OriginUser, + OriginUserSystem, + } +} + +// ProvisioningState - The status of the last resource operation. +type ProvisioningState string + +const ( + // ProvisioningStateAccepted - Request accepted for processing.. + ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - Resource creation was canceled. + ProvisioningStateCanceled ProvisioningState = "Canceled" + // ProvisioningStateCreating - Creation in progress.. + ProvisioningStateCreating ProvisioningState = "Creating" + // ProvisioningStateDeleting - Deletion in progress.. + ProvisioningStateDeleting ProvisioningState = "Deleting" + // ProvisioningStateFailed - Resource creation failed. + ProvisioningStateFailed ProvisioningState = "Failed" + // ProvisioningStateSucceeded - Resource has been created. + ProvisioningStateSucceeded ProvisioningState = "Succeeded" +) + +// PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{ + ProvisioningStateAccepted, + ProvisioningStateCanceled, + ProvisioningStateCreating, + ProvisioningStateDeleting, + ProvisioningStateFailed, + ProvisioningStateSucceeded, + } +} diff --git a/sdk/resourcemanager/playwright/armplaywright/fake/internal.go b/sdk/resourcemanager/playwright/armplaywright/fake/internal.go new file mode 100644 index 000000000000..7425b6a669e2 --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/fake/internal.go @@ -0,0 +1,65 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "sync" +) + +type result struct { + resp *http.Response + err error +} + +type nonRetriableError struct { + error +} + +func (nonRetriableError) NonRetriable() { + // marker method +} + +func contains[T comparable](s []T, v T) bool { + for _, vv := range s { + if vv == v { + return true + } + } + return false +} + +func newTracker[T any]() *tracker[T] { + return &tracker[T]{ + items: map[string]*T{}, + } +} + +type tracker[T any] struct { + items map[string]*T + mu sync.Mutex +} + +func (p *tracker[T]) get(req *http.Request) *T { + p.mu.Lock() + defer p.mu.Unlock() + if item, ok := p.items[server.SanitizePagerPollerPath(req.URL.Path)]; ok { + return item + } + return nil +} + +func (p *tracker[T]) add(req *http.Request, item *T) { + p.mu.Lock() + defer p.mu.Unlock() + p.items[server.SanitizePagerPollerPath(req.URL.Path)] = item +} + +func (p *tracker[T]) remove(req *http.Request) { + p.mu.Lock() + defer p.mu.Unlock() + delete(p.items, server.SanitizePagerPollerPath(req.URL.Path)) +} diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/fake/operations_server.go b/sdk/resourcemanager/playwright/armplaywright/fake/operations_server.go similarity index 56% rename from sdk/resourcemanager/loadtesting/armloadtesting/fake/operations_server.go rename to sdk/resourcemanager/playwright/armplaywright/fake/operations_server.go index b697bdd5da9d..6c10e450987b 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/fake/operations_server.go +++ b/sdk/resourcemanager/playwright/armplaywright/fake/operations_server.go @@ -1,10 +1,6 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. package fake @@ -15,32 +11,32 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtesting/armloadtesting" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/playwright/armplaywright" "net/http" ) -// OperationsServer is a fake server for instances of the armloadtesting.OperationsClient type. +// OperationsServer is a fake server for instances of the armplaywright.OperationsClient type. type OperationsServer struct { // NewListPager is the fake for method OperationsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - NewListPager func(options *armloadtesting.OperationsClientListOptions) (resp azfake.PagerResponder[armloadtesting.OperationsClientListResponse]) + NewListPager func(options *armplaywright.OperationsClientListOptions) (resp azfake.PagerResponder[armplaywright.OperationsClientListResponse]) } // NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. -// The returned OperationsServerTransport instance is connected to an instance of armloadtesting.OperationsClient via the +// The returned OperationsServerTransport instance is connected to an instance of armplaywright.OperationsClient via the // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewOperationsServerTransport(srv *OperationsServer) *OperationsServerTransport { return &OperationsServerTransport{ srv: srv, - newListPager: newTracker[azfake.PagerResponder[armloadtesting.OperationsClientListResponse]](), + newListPager: newTracker[azfake.PagerResponder[armplaywright.OperationsClientListResponse]](), } } -// OperationsServerTransport connects instances of armloadtesting.OperationsClient to instances of OperationsServer. +// OperationsServerTransport connects instances of armplaywright.OperationsClient to instances of OperationsServer. // Don't use this type directly, use NewOperationsServerTransport instead. type OperationsServerTransport struct { srv *OperationsServer - newListPager *tracker[azfake.PagerResponder[armloadtesting.OperationsClientListResponse]] + newListPager *tracker[azfake.PagerResponder[armplaywright.OperationsClientListResponse]] } // Do implements the policy.Transporter interface for OperationsServerTransport. @@ -51,21 +47,40 @@ func (o *OperationsServerTransport) Do(req *http.Request) (*http.Response, error return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} } - var resp *http.Response - var err error + return o.dispatchToMethodFake(req, method) +} - switch method { - case "OperationsClient.NewListPager": - resp, err = o.dispatchNewListPager(req) - default: - err = fmt.Errorf("unhandled API %s", method) - } +func (o *OperationsServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) - if err != nil { - return nil, err - } + go func() { + var intercepted bool + var res result + if operationsServerTransportInterceptor != nil { + res.resp, res.err, intercepted = operationsServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "OperationsClient.NewListPager": + res.resp, res.err = o.dispatchNewListPager(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } - return resp, nil + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } } func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { @@ -77,7 +92,7 @@ func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*ht resp := o.srv.NewListPager(nil) newListPager = &resp o.newListPager.add(req, newListPager) - server.PagerResponderInjectNextLinks(newListPager, req, func(page *armloadtesting.OperationsClientListResponse, createLink func() string) { + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armplaywright.OperationsClientListResponse, createLink func() string) { page.NextLink = to.Ptr(createLink()) }) } @@ -94,3 +109,9 @@ func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*ht } return resp, nil } + +// set this to conditionally intercept incoming requests to OperationsServerTransport +var operationsServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/playwright/armplaywright/fake/server_factory.go b/sdk/resourcemanager/playwright/armplaywright/fake/server_factory.go new file mode 100644 index 000000000000..2b2d80502791 --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/fake/server_factory.go @@ -0,0 +1,79 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "errors" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "strings" + "sync" +) + +// ServerFactory is a fake server for instances of the armplaywright.ClientFactory type. +type ServerFactory struct { + // OperationsServer contains the fakes for client OperationsClient + OperationsServer OperationsServer + + // WorkspacesServer contains the fakes for client WorkspacesClient + WorkspacesServer WorkspacesServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armplaywright.ClientFactory via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerFactoryTransport(srv *ServerFactory) *ServerFactoryTransport { + return &ServerFactoryTransport{ + srv: srv, + } +} + +// ServerFactoryTransport connects instances of armplaywright.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trOperationsServer *OperationsServerTransport + trWorkspacesServer *WorkspacesServerTransport +} + +// Do implements the policy.Transporter interface for ServerFactoryTransport. +func (s *ServerFactoryTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + client := method[:strings.Index(method, ".")] + var resp *http.Response + var err error + + switch client { + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "WorkspacesClient": + initServer(s, &s.trWorkspacesServer, func() *WorkspacesServerTransport { return NewWorkspacesServerTransport(&s.srv.WorkspacesServer) }) + resp, err = s.trWorkspacesServer.Do(req) + default: + err = fmt.Errorf("unhandled client %s", client) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func initServer[T any](s *ServerFactoryTransport, dst **T, src func() *T) { + s.trMu.Lock() + if *dst == nil { + *dst = src() + } + s.trMu.Unlock() +} diff --git a/sdk/resourcemanager/playwright/armplaywright/fake/time_rfc3339.go b/sdk/resourcemanager/playwright/armplaywright/fake/time_rfc3339.go new file mode 100644 index 000000000000..87ee11e83b32 --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/fake/time_rfc3339.go @@ -0,0 +1,109 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/playwright/armplaywright/fake/workspaces_server.go b/sdk/resourcemanager/playwright/armplaywright/fake/workspaces_server.go new file mode 100644 index 000000000000..efdb172fbc41 --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/fake/workspaces_server.go @@ -0,0 +1,396 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package fake + +import ( + "context" + "errors" + "fmt" + azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/playwright/armplaywright" + "net/http" + "net/url" + "regexp" +) + +// WorkspacesServer is a fake server for instances of the armplaywright.WorkspacesClient type. +type WorkspacesServer struct { + // CheckNameAvailability is the fake for method WorkspacesClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, body armplaywright.CheckNameAvailabilityRequest, options *armplaywright.WorkspacesClientCheckNameAvailabilityOptions) (resp azfake.Responder[armplaywright.WorkspacesClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method WorkspacesClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, playwrightWorkspaceName string, resource armplaywright.Workspace, options *armplaywright.WorkspacesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armplaywright.WorkspacesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method WorkspacesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, playwrightWorkspaceName string, options *armplaywright.WorkspacesClientBeginDeleteOptions) (resp azfake.PollerResponder[armplaywright.WorkspacesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkspacesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, playwrightWorkspaceName string, options *armplaywright.WorkspacesClientGetOptions) (resp azfake.Responder[armplaywright.WorkspacesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method WorkspacesClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armplaywright.WorkspacesClientListByResourceGroupOptions) (resp azfake.PagerResponder[armplaywright.WorkspacesClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method WorkspacesClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armplaywright.WorkspacesClientListBySubscriptionOptions) (resp azfake.PagerResponder[armplaywright.WorkspacesClientListBySubscriptionResponse]) + + // Update is the fake for method WorkspacesClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, playwrightWorkspaceName string, properties armplaywright.WorkspaceUpdate, options *armplaywright.WorkspacesClientUpdateOptions) (resp azfake.Responder[armplaywright.WorkspacesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewWorkspacesServerTransport creates a new instance of WorkspacesServerTransport with the provided implementation. +// The returned WorkspacesServerTransport instance is connected to an instance of armplaywright.WorkspacesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkspacesServerTransport(srv *WorkspacesServer) *WorkspacesServerTransport { + return &WorkspacesServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armplaywright.WorkspacesClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armplaywright.WorkspacesClientDeleteResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armplaywright.WorkspacesClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armplaywright.WorkspacesClientListBySubscriptionResponse]](), + } +} + +// WorkspacesServerTransport connects instances of armplaywright.WorkspacesClient to instances of WorkspacesServer. +// Don't use this type directly, use NewWorkspacesServerTransport instead. +type WorkspacesServerTransport struct { + srv *WorkspacesServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armplaywright.WorkspacesClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armplaywright.WorkspacesClientDeleteResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armplaywright.WorkspacesClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armplaywright.WorkspacesClientListBySubscriptionResponse]] +} + +// Do implements the policy.Transporter interface for WorkspacesServerTransport. +func (w *WorkspacesServerTransport) Do(req *http.Request) (*http.Response, error) { + rawMethod := req.Context().Value(runtime.CtxAPINameKey{}) + method, ok := rawMethod.(string) + if !ok { + return nil, nonRetriableError{errors.New("unable to dispatch request, missing value for CtxAPINameKey")} + } + + return w.dispatchToMethodFake(req, method) +} + +func (w *WorkspacesServerTransport) dispatchToMethodFake(req *http.Request, method string) (*http.Response, error) { + resultChan := make(chan result) + defer close(resultChan) + + go func() { + var intercepted bool + var res result + if workspacesServerTransportInterceptor != nil { + res.resp, res.err, intercepted = workspacesServerTransportInterceptor.Do(req) + } + if !intercepted { + switch method { + case "WorkspacesClient.CheckNameAvailability": + res.resp, res.err = w.dispatchCheckNameAvailability(req) + case "WorkspacesClient.BeginCreateOrUpdate": + res.resp, res.err = w.dispatchBeginCreateOrUpdate(req) + case "WorkspacesClient.BeginDelete": + res.resp, res.err = w.dispatchBeginDelete(req) + case "WorkspacesClient.Get": + res.resp, res.err = w.dispatchGet(req) + case "WorkspacesClient.NewListByResourceGroupPager": + res.resp, res.err = w.dispatchNewListByResourceGroupPager(req) + case "WorkspacesClient.NewListBySubscriptionPager": + res.resp, res.err = w.dispatchNewListBySubscriptionPager(req) + case "WorkspacesClient.Update": + res.resp, res.err = w.dispatchUpdate(req) + default: + res.err = fmt.Errorf("unhandled API %s", method) + } + + } + select { + case resultChan <- res: + case <-req.Context().Done(): + } + }() + + select { + case <-req.Context().Done(): + return nil, req.Context().Err() + case res := <-resultChan: + return res.resp, res.err + } +} + +func (w *WorkspacesServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if w.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/checkNameAvailability` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armplaywright.CheckNameAvailabilityRequest](req) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.CheckNameAvailability(req.Context(), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CheckNameAvailabilityResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspacesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := w.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/playwrightWorkspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armplaywright.Workspace](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + playwrightWorkspaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("playwrightWorkspaceName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, playwrightWorkspaceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + w.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + w.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + w.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (w *WorkspacesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if w.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := w.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/playwrightWorkspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + playwrightWorkspaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("playwrightWorkspaceName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.BeginDelete(req.Context(), resourceGroupNameParam, playwrightWorkspaceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + w.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + w.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + w.beginDelete.remove(req) + } + + return resp, nil +} + +func (w *WorkspacesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if w.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/playwrightWorkspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + playwrightWorkspaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("playwrightWorkspaceName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, playwrightWorkspaceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Workspace, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkspacesServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := w.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/playwrightWorkspaces` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := w.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + w.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armplaywright.WorkspacesClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + w.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (w *WorkspacesServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := w.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/playwrightWorkspaces` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := w.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + w.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armplaywright.WorkspacesClientListBySubscriptionResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListBySubscriptionPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + w.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (w *WorkspacesServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if w.srv.Update == nil { + return nil, &nonRetriableError{errors.New("fake for method Update not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LoadTestService/playwrightWorkspaces/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armplaywright.WorkspaceUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + playwrightWorkspaceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("playwrightWorkspaceName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, playwrightWorkspaceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Workspace, req) + if err != nil { + return nil, err + } + return resp, nil +} + +// set this to conditionally intercept incoming requests to WorkspacesServerTransport +var workspacesServerTransportInterceptor interface { + // Do returns true if the server transport should use the returned response/error + Do(*http.Request) (*http.Response, error, bool) +} diff --git a/sdk/resourcemanager/playwright/armplaywright/go.mod b/sdk/resourcemanager/playwright/armplaywright/go.mod new file mode 100644 index 000000000000..092bae0469b6 --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/go.mod @@ -0,0 +1,23 @@ +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/playwright/armplaywright + +go 1.23.0 + +toolchain go1.23.8 + +require ( + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 +) + +require ( + github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 // indirect + github.com/golang-jwt/jwt/v5 v5.2.1 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/kylelemons/godebug v1.1.0 // indirect + github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect + golang.org/x/crypto v0.36.0 // indirect + golang.org/x/net v0.37.0 // indirect + golang.org/x/sys v0.31.0 // indirect + golang.org/x/text v0.23.0 // indirect +) diff --git a/sdk/resourcemanager/playwright/armplaywright/go.sum b/sdk/resourcemanager/playwright/armplaywright/go.sum new file mode 100644 index 000000000000..1f92486fbbcf --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/go.sum @@ -0,0 +1,33 @@ +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1 h1:DSDNVxqkoXJiko6x8a90zidoYqnYYa6c1MTzDKzKkTo= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.17.1/go.mod h1:zGqV2R4Cr/k8Uye5w+dgQ06WJtEcbQG/8J7BB6hnCr4= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0 h1:tfLQ34V6F7tVSwoTf/4lH5sE0o6eCJuNDTmH09nDpbc= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.7.0/go.mod h1:9kIvujWAA58nmPmWB1m23fyWic1kYZMxD9CxaWn4Qpg= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0 h1:ywEEhmNahHBihViHepv3xPBn1663uRv2t2q/ESv9seY= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.10.0/go.mod h1:iZDifYGJTIgIIkYRNWPENUnqx6bJ2xnSDFI2tjwZNuY= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2 h1:XHOnouVk1mxXfQidrMEnLlPk9UMeRtyBTnEFtxkV0kU= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.2/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/golang-jwt/jwt/v5 v5.2.1 h1:OuVbFODueb089Lh128TAcimifWaLhJwVflnrgM17wHk= +github.com/golang-jwt/jwt/v5 v5.2.1/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/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/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +golang.org/x/crypto v0.36.0 h1:AnAEvhDddvBdpY+uR+MyHmuZzzNqXSe/GvuDeob5L34= +golang.org/x/crypto v0.36.0/go.mod h1:Y4J0ReaxCR1IMaabaSMugxJES1EpwhBHhv2bDHklZvc= +golang.org/x/net v0.37.0 h1:1zLorHbz+LYj7MQlSf1+2tPIIgibq2eL5xkrGk6f+2c= +golang.org/x/net v0.37.0/go.mod h1:ivrbrMbzFq5J41QOQh0siUuly180yBYtLp+CKbEaFx8= +golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.31.0 h1:ioabZlmFYtWhL+TRYpcnNlLwhyxaM9kWTDEmfnprqik= +golang.org/x/sys v0.31.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k= +golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY= +golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/sdk/resourcemanager/playwright/armplaywright/models.go b/sdk/resourcemanager/playwright/armplaywright/models.go new file mode 100644 index 000000000000..6e6f29d8eef7 --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/models.go @@ -0,0 +1,168 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armplaywright + +import "time" + +// CheckNameAvailabilityRequest - The check availability request body. +type CheckNameAvailabilityRequest struct { + // The name of the resource for which availability needs to be checked. + Name *string + + // The resource type. + Type *string +} + +// CheckNameAvailabilityResponse - The check availability result. +type CheckNameAvailabilityResponse struct { + // Detailed reason why the given name is not available. + Message *string + + // Indicates if the resource name is available. + NameAvailable *bool + + // The reason why the given name is not available. + Reason *CheckNameAvailabilityReason +} + +// Operation - Details of a REST API operation, returned from the Resource Provider Operations API +type Operation struct { + // Localized display information for this particular operation. + Display *OperationDisplay + + // READ-ONLY; Extensible enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. + ActionType *ActionType + + // READ-ONLY; Whether the operation applies to data-plane. This is "true" for data-plane operations and "false" for Azure + // Resource Manager/control-plane operations. + IsDataAction *bool + + // READ-ONLY; The name of the operation, as per Resource-Based Access Control (RBAC). Examples: "Microsoft.Compute/virtualMachines/write", + // "Microsoft.Compute/virtualMachines/capture/action" + Name *string + + // READ-ONLY; The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit logs UX. Default + // value is "user,system" + Origin *Origin +} + +// OperationDisplay - Localized display information for and operation. +type OperationDisplay struct { + // READ-ONLY; The short, localized friendly description of the operation; suitable for tool tips and detailed views. + Description *string + + // READ-ONLY; The concise, localized friendly name for the operation; suitable for dropdowns. E.g. "Create or Update Virtual + // Machine", "Restart Virtual Machine". + Operation *string + + // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft + // Compute". + Provider *string + + // READ-ONLY; The localized friendly name of the resource type related to this operation. E.g. "Virtual Machines" or "Job + // Schedule Collections". + Resource *string +} + +// OperationListResult - A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to +// get the next set of results. +type OperationListResult struct { + // REQUIRED; The Operation items on this page + Value []*Operation + + // The link to the next page of items + NextLink *string +} + +// SystemData - Metadata pertaining to creation and last modification of the resource. +type SystemData struct { + // The timestamp of resource creation (UTC). + CreatedAt *time.Time + + // The identity that created the resource. + CreatedBy *string + + // The type of identity that created the resource. + CreatedByType *CreatedByType + + // The timestamp of resource last modification (UTC) + LastModifiedAt *time.Time + + // The identity that last modified the resource. + LastModifiedBy *string + + // The type of identity that last modified the resource. + LastModifiedByType *CreatedByType +} + +// Workspace - Playwright workspace resource. +type Workspace struct { + // REQUIRED; The geo-location where the resource lives + Location *string + + // The resource-specific properties for this resource. + Properties *WorkspaceProperties + + // Resource tags. + Tags map[string]*string + + // READ-ONLY; The name of the PlaywrightWorkspace + Name *string + + // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} + ID *string + + // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. + SystemData *SystemData + + // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" + Type *string +} + +// WorkspaceListResult - The response of a PlaywrightWorkspace list operation. +type WorkspaceListResult struct { + // REQUIRED; The PlaywrightWorkspace items on this page + Value []*Workspace + + // The link to the next page of items + NextLink *string +} + +// WorkspaceProperties - Playwright workspace resource properties. +type WorkspaceProperties struct { + // When enabled, this feature allows the workspace to use local auth (through service access token) for executing operations. + LocalAuth *EnablementStatus + + // This property sets the connection region for client workers to cloud-hosted browsers. If enabled, workers connect to browsers + // in the closest Azure region, ensuring lower latency. If disabled, workers connect to browsers in the Azure region in which + // the workspace was initially created. + RegionalAffinity *EnablementStatus + + // READ-ONLY; The workspace data plane URI. + DataplaneURI *string + + // READ-ONLY; The status of the last resource operation. + ProvisioningState *ProvisioningState +} + +// WorkspaceUpdate - The type used for update operations of the PlaywrightWorkspace. +type WorkspaceUpdate struct { + // The resource-specific properties for this resource. + Properties *WorkspaceUpdateProperties + + // Resource tags. + Tags map[string]*string +} + +// WorkspaceUpdateProperties - The updatable properties of the PlaywrightWorkspace. +type WorkspaceUpdateProperties struct { + // When enabled, this feature allows the workspace to use local auth (through service access token) for executing operations. + LocalAuth *EnablementStatus + + // This property sets the connection region for client workers to cloud-hosted browsers. If enabled, workers connect to browsers + // in the closest Azure region, ensuring lower latency. If disabled, workers connect to browsers in the Azure region in which + // the workspace was initially created. + RegionalAffinity *EnablementStatus +} diff --git a/sdk/resourcemanager/playwright/armplaywright/models_serde.go b/sdk/resourcemanager/playwright/armplaywright/models_serde.go new file mode 100644 index 000000000000..f30ac289ed81 --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/models_serde.go @@ -0,0 +1,441 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armplaywright + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" +) + +// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityRequest. +func (c CheckNameAvailabilityRequest) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "name", c.Name) + populate(objectMap, "type", c.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityRequest. +func (c *CheckNameAvailabilityRequest) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "name": + err = unpopulate(val, "Name", &c.Name) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &c.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type CheckNameAvailabilityResponse. +func (c CheckNameAvailabilityResponse) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "message", c.Message) + populate(objectMap, "nameAvailable", c.NameAvailable) + populate(objectMap, "reason", c.Reason) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type CheckNameAvailabilityResponse. +func (c *CheckNameAvailabilityResponse) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "message": + err = unpopulate(val, "Message", &c.Message) + delete(rawMsg, key) + case "nameAvailable": + err = unpopulate(val, "NameAvailable", &c.NameAvailable) + delete(rawMsg, key) + case "reason": + err = unpopulate(val, "Reason", &c.Reason) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", c, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Operation. +func (o Operation) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "actionType", o.ActionType) + populate(objectMap, "display", o.Display) + populate(objectMap, "isDataAction", o.IsDataAction) + populate(objectMap, "name", o.Name) + populate(objectMap, "origin", o.Origin) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Operation. +func (o *Operation) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "actionType": + err = unpopulate(val, "ActionType", &o.ActionType) + delete(rawMsg, key) + case "display": + err = unpopulate(val, "Display", &o.Display) + delete(rawMsg, key) + case "isDataAction": + err = unpopulate(val, "IsDataAction", &o.IsDataAction) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &o.Name) + delete(rawMsg, key) + case "origin": + err = unpopulate(val, "Origin", &o.Origin) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationDisplay. +func (o OperationDisplay) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "description", o.Description) + populate(objectMap, "operation", o.Operation) + populate(objectMap, "provider", o.Provider) + populate(objectMap, "resource", o.Resource) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationDisplay. +func (o *OperationDisplay) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "description": + err = unpopulate(val, "Description", &o.Description) + delete(rawMsg, key) + case "operation": + err = unpopulate(val, "Operation", &o.Operation) + delete(rawMsg, key) + case "provider": + err = unpopulate(val, "Provider", &o.Provider) + delete(rawMsg, key) + case "resource": + err = unpopulate(val, "Resource", &o.Resource) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type OperationListResult. +func (o OperationListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", o.NextLink) + populate(objectMap, "value", o.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type OperationListResult. +func (o *OperationListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &o.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &o.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", o, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type SystemData. +func (s SystemData) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populate(objectMap, "createdBy", s.CreatedBy) + populate(objectMap, "createdByType", s.CreatedByType) + populateDateTimeRFC3339(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 fmt.Errorf("unmarshalling type %T: %v", s, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "createdAt": + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + delete(rawMsg, key) + case "createdBy": + err = unpopulate(val, "CreatedBy", &s.CreatedBy) + delete(rawMsg, key) + case "createdByType": + err = unpopulate(val, "CreatedByType", &s.CreatedByType) + delete(rawMsg, key) + case "lastModifiedAt": + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + delete(rawMsg, key) + case "lastModifiedBy": + err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) + delete(rawMsg, key) + case "lastModifiedByType": + err = unpopulate(val, "LastModifiedByType", &s.LastModifiedByType) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", s, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type Workspace. +func (w Workspace) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "id", w.ID) + populate(objectMap, "location", w.Location) + populate(objectMap, "name", w.Name) + populate(objectMap, "properties", w.Properties) + populate(objectMap, "systemData", w.SystemData) + populate(objectMap, "tags", w.Tags) + populate(objectMap, "type", w.Type) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type Workspace. +func (w *Workspace) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "id": + err = unpopulate(val, "ID", &w.ID) + delete(rawMsg, key) + case "location": + err = unpopulate(val, "Location", &w.Location) + delete(rawMsg, key) + case "name": + err = unpopulate(val, "Name", &w.Name) + delete(rawMsg, key) + case "properties": + err = unpopulate(val, "Properties", &w.Properties) + delete(rawMsg, key) + case "systemData": + err = unpopulate(val, "SystemData", &w.SystemData) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &w.Tags) + delete(rawMsg, key) + case "type": + err = unpopulate(val, "Type", &w.Type) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspaceListResult. +func (w WorkspaceListResult) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "nextLink", w.NextLink) + populate(objectMap, "value", w.Value) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkspaceListResult. +func (w *WorkspaceListResult) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "nextLink": + err = unpopulate(val, "NextLink", &w.NextLink) + delete(rawMsg, key) + case "value": + err = unpopulate(val, "Value", &w.Value) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspaceProperties. +func (w WorkspaceProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "dataplaneUri", w.DataplaneURI) + populate(objectMap, "localAuth", w.LocalAuth) + populate(objectMap, "provisioningState", w.ProvisioningState) + populate(objectMap, "regionalAffinity", w.RegionalAffinity) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkspaceProperties. +func (w *WorkspaceProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "dataplaneUri": + err = unpopulate(val, "DataplaneURI", &w.DataplaneURI) + delete(rawMsg, key) + case "localAuth": + err = unpopulate(val, "LocalAuth", &w.LocalAuth) + delete(rawMsg, key) + case "provisioningState": + err = unpopulate(val, "ProvisioningState", &w.ProvisioningState) + delete(rawMsg, key) + case "regionalAffinity": + err = unpopulate(val, "RegionalAffinity", &w.RegionalAffinity) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspaceUpdate. +func (w WorkspaceUpdate) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "properties", w.Properties) + populate(objectMap, "tags", w.Tags) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkspaceUpdate. +func (w *WorkspaceUpdate) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "properties": + err = unpopulate(val, "Properties", &w.Properties) + delete(rawMsg, key) + case "tags": + err = unpopulate(val, "Tags", &w.Tags) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +// MarshalJSON implements the json.Marshaller interface for type WorkspaceUpdateProperties. +func (w WorkspaceUpdateProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]any) + populate(objectMap, "localAuth", w.LocalAuth) + populate(objectMap, "regionalAffinity", w.RegionalAffinity) + return json.Marshal(objectMap) +} + +// UnmarshalJSON implements the json.Unmarshaller interface for type WorkspaceUpdateProperties. +func (w *WorkspaceUpdateProperties) UnmarshalJSON(data []byte) error { + var rawMsg map[string]json.RawMessage + if err := json.Unmarshal(data, &rawMsg); err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + for key, val := range rawMsg { + var err error + switch key { + case "localAuth": + err = unpopulate(val, "LocalAuth", &w.LocalAuth) + delete(rawMsg, key) + case "regionalAffinity": + err = unpopulate(val, "RegionalAffinity", &w.RegionalAffinity) + delete(rawMsg, key) + } + if err != nil { + return fmt.Errorf("unmarshalling type %T: %v", w, err) + } + } + return nil +} + +func populate(m map[string]any, k string, v any) { + 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, fn string, v any) error { + if data == nil || string(data) == "null" { + return nil + } + if err := json.Unmarshal(data, v); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + return nil +} diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/operations_client.go b/sdk/resourcemanager/playwright/armplaywright/operations_client.go similarity index 87% rename from sdk/resourcemanager/loadtesting/armloadtesting/operations_client.go rename to sdk/resourcemanager/playwright/armplaywright/operations_client.go index 90221faf5b81..bf46fe9787b5 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/operations_client.go +++ b/sdk/resourcemanager/playwright/armplaywright/operations_client.go @@ -1,12 +1,8 @@ -//go:build go1.18 -// +build go1.18 - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. +// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT. -package armloadtesting +package armplaywright import ( "context" @@ -37,9 +33,9 @@ func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientO return client, nil } -// NewListPager - Lists all the available API operations for Load Test Resource. +// NewListPager - List the operations for the provider // -// Generated from API version 2022-12-01 +// Generated from API version 2025-07-01-preview // - options - OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. func (client *OperationsClient) NewListPager(options *OperationsClientListOptions) *runtime.Pager[OperationsClientListResponse] { return runtime.NewPager(runtime.PagingHandler[OperationsClientListResponse]{ @@ -65,14 +61,14 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption } // listCreateRequest creates the List request. -func (client *OperationsClient) listCreateRequest(ctx context.Context, options *OperationsClientListOptions) (*policy.Request, error) { +func (client *OperationsClient) listCreateRequest(ctx context.Context, _ *OperationsClientListOptions) (*policy.Request, error) { urlPath := "/providers/Microsoft.LoadTestService/operations" req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) if err != nil { return nil, err } reqQP := req.Raw().URL.Query() - reqQP.Set("api-version", "2022-12-01") + reqQP.Set("api-version", "2025-07-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} return req, nil diff --git a/sdk/resourcemanager/playwright/armplaywright/operations_client_example_test.go b/sdk/resourcemanager/playwright/armplaywright/operations_client_example_test.go new file mode 100644 index 000000000000..43042095963b --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/operations_client_example_test.go @@ -0,0 +1,94 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armplaywright_test + +import ( + "context" + "github.com/Azure/azure-sdk-for-go/sdk/azidentity" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/playwright/armplaywright" + "log" +) + +// Generated from example definition: 2025-07-01-preview/Operations_List.json +func ExampleOperationsClient_NewListPager() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armplaywright.NewClientFactory("", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + pager := clientFactory.NewOperationsClient().NewListPager(nil) + for pager.More() { + page, err := pager.NextPage(ctx) + if err != nil { + log.Fatalf("failed to advance page: %v", err) + } + for _, v := range page.Value { + // You could use page here. We use blank identifier for just demo purposes. + _ = v + } + // If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // page = armplaywright.OperationsClientListResponse{ + // OperationListResult: armplaywright.OperationListResult{ + // Value: []*armplaywright.Operation{ + // { + // Name: to.Ptr("Microsoft.LoadTestService/loadTests/Write"), + // IsDataAction: to.Ptr(false), + // Display: &armplaywright.OperationDisplay{ + // Provider: to.Ptr("Microsoft.LoadTestService"), + // Resource: to.Ptr("loadTests"), + // Operation: to.Ptr("Creates or updates the LoadTests"), + // Description: to.Ptr("Set LoadTests"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.LoadTestService/loadTests/Delete"), + // IsDataAction: to.Ptr(false), + // Display: &armplaywright.OperationDisplay{ + // Provider: to.Ptr("Microsoft.LoadTestService"), + // Resource: to.Ptr("loadTests"), + // Operation: to.Ptr("Deletes the LoadTests"), + // Description: to.Ptr("Delete LoadTests"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.LoadTestService/loadTests/Read"), + // IsDataAction: to.Ptr(false), + // Display: &armplaywright.OperationDisplay{ + // Provider: to.Ptr("Microsoft.LoadTestService"), + // Resource: to.Ptr("loadTests"), + // Operation: to.Ptr("Reads the LoadTests"), + // Description: to.Ptr("Read LoadTests"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.LoadTestService/PlaywrightWorkspaces/Write"), + // IsDataAction: to.Ptr(false), + // Display: &armplaywright.OperationDisplay{ + // Provider: to.Ptr("Microsoft.LoadTestService"), + // Resource: to.Ptr("PlaywrightWorkspaces"), + // Operation: to.Ptr("Creates, updates or deletes Playwright workspace resource"), + // Description: to.Ptr("Creates, updates or deletes Playwright workspace resource"), + // }, + // }, + // { + // Name: to.Ptr("Microsoft.LoadTestService/PlaywrightWorkspaces/Read"), + // IsDataAction: to.Ptr(false), + // Display: &armplaywright.OperationDisplay{ + // Provider: to.Ptr("Microsoft.LoadTestService"), + // Resource: to.Ptr("PlaywrightWorkspaces"), + // Operation: to.Ptr("Reads Playwright workspace resource"), + // Description: to.Ptr("Reads Playwright workspace resource"), + // }, + // }, + // }, + // NextLink: to.Ptr("http://nextlink.contoso.com"), + // }, + // } + } +} diff --git a/sdk/resourcemanager/playwright/armplaywright/options.go b/sdk/resourcemanager/playwright/armplaywright/options.go new file mode 100644 index 000000000000..8b23fa343342 --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/options.go @@ -0,0 +1,51 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armplaywright + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesClientBeginCreateOrUpdateOptions contains the optional parameters for the WorkspacesClient.BeginCreateOrUpdate +// method. +type WorkspacesClientBeginCreateOrUpdateOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// WorkspacesClientBeginDeleteOptions contains the optional parameters for the WorkspacesClient.BeginDelete method. +type WorkspacesClientBeginDeleteOptions struct { + // Resumes the long-running operation from the provided token. + ResumeToken string +} + +// WorkspacesClientCheckNameAvailabilityOptions contains the optional parameters for the WorkspacesClient.CheckNameAvailability +// method. +type WorkspacesClientCheckNameAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesClientGetOptions contains the optional parameters for the WorkspacesClient.Get method. +type WorkspacesClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesClientListByResourceGroupOptions contains the optional parameters for the WorkspacesClient.NewListByResourceGroupPager +// method. +type WorkspacesClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesClientListBySubscriptionOptions contains the optional parameters for the WorkspacesClient.NewListBySubscriptionPager +// method. +type WorkspacesClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// WorkspacesClientUpdateOptions contains the optional parameters for the WorkspacesClient.Update method. +type WorkspacesClientUpdateOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/playwright/armplaywright/responses.go b/sdk/resourcemanager/playwright/armplaywright/responses.go new file mode 100644 index 000000000000..38df78a87f56 --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/responses.go @@ -0,0 +1,52 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armplaywright + +// OperationsClientListResponse contains the response from method OperationsClient.NewListPager. +type OperationsClientListResponse struct { + // A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. + OperationListResult +} + +// WorkspacesClientCheckNameAvailabilityResponse contains the response from method WorkspacesClient.CheckNameAvailability. +type WorkspacesClientCheckNameAvailabilityResponse struct { + // The check availability result. + CheckNameAvailabilityResponse +} + +// WorkspacesClientCreateOrUpdateResponse contains the response from method WorkspacesClient.BeginCreateOrUpdate. +type WorkspacesClientCreateOrUpdateResponse struct { + // Playwright workspace resource. + Workspace +} + +// WorkspacesClientDeleteResponse contains the response from method WorkspacesClient.BeginDelete. +type WorkspacesClientDeleteResponse struct { + // placeholder for future response values +} + +// WorkspacesClientGetResponse contains the response from method WorkspacesClient.Get. +type WorkspacesClientGetResponse struct { + // Playwright workspace resource. + Workspace +} + +// WorkspacesClientListByResourceGroupResponse contains the response from method WorkspacesClient.NewListByResourceGroupPager. +type WorkspacesClientListByResourceGroupResponse struct { + // The response of a PlaywrightWorkspace list operation. + WorkspaceListResult +} + +// WorkspacesClientListBySubscriptionResponse contains the response from method WorkspacesClient.NewListBySubscriptionPager. +type WorkspacesClientListBySubscriptionResponse struct { + // The response of a PlaywrightWorkspace list operation. + WorkspaceListResult +} + +// WorkspacesClientUpdateResponse contains the response from method WorkspacesClient.Update. +type WorkspacesClientUpdateResponse struct { + // Playwright workspace resource. + Workspace +} diff --git a/sdk/resourcemanager/playwright/armplaywright/time_rfc3339.go b/sdk/resourcemanager/playwright/armplaywright/time_rfc3339.go new file mode 100644 index 000000000000..864fe3cc6f93 --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/time_rfc3339.go @@ -0,0 +1,109 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armplaywright + +import ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "regexp" + "strings" + "time" +) + +// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. +var tzOffsetRegex = regexp.MustCompile(`(?:Z|z|\+|-)(?:\d+:\d+)*"*$`) + +const ( + utcDateTime = "2006-01-02T15:04:05.999999999" + utcDateTimeJSON = `"` + utcDateTime + `"` + utcDateTimeNoT = "2006-01-02 15:04:05.999999999" + utcDateTimeJSONNoT = `"` + utcDateTimeNoT + `"` + dateTimeNoT = `2006-01-02 15:04:05.999999999Z07:00` + dateTimeJSON = `"` + time.RFC3339Nano + `"` + dateTimeJSONNoT = `"` + dateTimeNoT + `"` +) + +type dateTimeRFC3339 time.Time + +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalJSON() +} + +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { + tt := time.Time(t) + return tt.MarshalText() +} + +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = dateTimeJSON + } else if tzOffset { + layout = dateTimeJSONNoT + } else if hasT { + layout = utcDateTimeJSON + } else { + layout = utcDateTimeJSONNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + if len(data) == 0 { + return nil + } + tzOffset := tzOffsetRegex.Match(data) + hasT := strings.Contains(string(data), "T") || strings.Contains(string(data), "t") + var layout string + if tzOffset && hasT { + layout = time.RFC3339Nano + } else if tzOffset { + layout = dateTimeNoT + } else if hasT { + layout = utcDateTime + } else { + layout = utcDateTimeNoT + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) Parse(layout, value string) error { + p, err := time.Parse(layout, strings.ToUpper(value)) + *t = dateTimeRFC3339(p) + return err +} + +func (t dateTimeRFC3339) String() string { + return time.Time(t).Format(time.RFC3339Nano) +} + +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { + if t == nil { + return + } else if azcore.IsNullValue(t) { + m[k] = nil + return + } else if reflect.ValueOf(t).IsNil() { + return + } + m[k] = (*dateTimeRFC3339)(t) +} + +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || string(data) == "null" { + return nil + } + var aux dateTimeRFC3339 + if err := json.Unmarshal(data, &aux); err != nil { + return fmt.Errorf("struct field %s: %v", fn, err) + } + *t = (*time.Time)(&aux) + return nil +} diff --git a/sdk/resourcemanager/playwright/armplaywright/tsp-location.yaml b/sdk/resourcemanager/playwright/armplaywright/tsp-location.yaml new file mode 100644 index 000000000000..af70e3b97cae --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/loadtestservice/Playwright.Management +commit: 02d891edd0a78d71fdaa969f028261a831432c54 +repo: Azure/azure-rest-api-specs +additionalDirectories: diff --git a/sdk/resourcemanager/playwright/armplaywright/workspaces_client.go b/sdk/resourcemanager/playwright/armplaywright/workspaces_client.go new file mode 100644 index 000000000000..d60adde8f188 --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/workspaces_client.go @@ -0,0 +1,504 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armplaywright + +import ( + "context" + "errors" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/policy" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" + "net/http" + "net/url" + "strings" +) + +// WorkspacesClient contains the methods for the Workspaces group. +// Don't use this type directly, use NewWorkspacesClient() instead. +type WorkspacesClient struct { + internal *arm.Client + subscriptionID string +} + +// NewWorkspacesClient creates a new instance of WorkspacesClient with the specified values. +// - subscriptionID - The ID of the target subscription. The value must be an UUID. +// - credential - used to authorize requests. Usually a credential from azidentity. +// - options - pass nil to accept the default values. +func NewWorkspacesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkspacesClient, error) { + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) + if err != nil { + return nil, err + } + client := &WorkspacesClient{ + subscriptionID: subscriptionID, + internal: cl, + } + return client, nil +} + +// CheckNameAvailability - Implements global CheckNameAvailability operations +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-07-01-preview +// - body - The CheckAvailability request +// - options - WorkspacesClientCheckNameAvailabilityOptions contains the optional parameters for the WorkspacesClient.CheckNameAvailability +// method. +func (client *WorkspacesClient) CheckNameAvailability(ctx context.Context, body CheckNameAvailabilityRequest, options *WorkspacesClientCheckNameAvailabilityOptions) (WorkspacesClientCheckNameAvailabilityResponse, error) { + var err error + const operationName = "WorkspacesClient.CheckNameAvailability" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.checkNameAvailabilityCreateRequest(ctx, body, options) + if err != nil { + return WorkspacesClientCheckNameAvailabilityResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacesClientCheckNameAvailabilityResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspacesClientCheckNameAvailabilityResponse{}, err + } + resp, err := client.checkNameAvailabilityHandleResponse(httpResp) + return resp, err +} + +// checkNameAvailabilityCreateRequest creates the CheckNameAvailability request. +func (client *WorkspacesClient) checkNameAvailabilityCreateRequest(ctx context.Context, body CheckNameAvailabilityRequest, _ *WorkspacesClientCheckNameAvailabilityOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/checkNameAvailability" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodPost, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil +} + +// checkNameAvailabilityHandleResponse handles the CheckNameAvailability response. +func (client *WorkspacesClient) checkNameAvailabilityHandleResponse(resp *http.Response) (WorkspacesClientCheckNameAvailabilityResponse, error) { + result := WorkspacesClientCheckNameAvailabilityResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.CheckNameAvailabilityResponse); err != nil { + return WorkspacesClientCheckNameAvailabilityResponse{}, err + } + return result, nil +} + +// BeginCreateOrUpdate - Create a PlaywrightWorkspace +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - playwrightWorkspaceName - The name of the PlaywrightWorkspace +// - resource - Resource create parameters. +// - options - WorkspacesClientBeginCreateOrUpdateOptions contains the optional parameters for the WorkspacesClient.BeginCreateOrUpdate +// method. +func (client *WorkspacesClient) BeginCreateOrUpdate(ctx context.Context, resourceGroupName string, playwrightWorkspaceName string, resource Workspace, options *WorkspacesClientBeginCreateOrUpdateOptions) (*runtime.Poller[WorkspacesClientCreateOrUpdateResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.createOrUpdate(ctx, resourceGroupName, playwrightWorkspaceName, resource, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkspacesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WorkspacesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// CreateOrUpdate - Create a PlaywrightWorkspace +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-07-01-preview +func (client *WorkspacesClient) createOrUpdate(ctx context.Context, resourceGroupName string, playwrightWorkspaceName string, resource Workspace, options *WorkspacesClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "WorkspacesClient.BeginCreateOrUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.createOrUpdateCreateRequest(ctx, resourceGroupName, playwrightWorkspaceName, resource, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// createOrUpdateCreateRequest creates the CreateOrUpdate request. +func (client *WorkspacesClient) createOrUpdateCreateRequest(ctx context.Context, resourceGroupName string, playwrightWorkspaceName string, resource Workspace, _ *WorkspacesClientBeginCreateOrUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/playwrightWorkspaces/{playwrightWorkspaceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if playwrightWorkspaceName == "" { + return nil, errors.New("parameter playwrightWorkspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{playwrightWorkspaceName}", url.PathEscape(playwrightWorkspaceName)) + req, err := runtime.NewRequest(ctx, http.MethodPut, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil +} + +// BeginDelete - Delete a PlaywrightWorkspace +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - playwrightWorkspaceName - The name of the PlaywrightWorkspace +// - options - WorkspacesClientBeginDeleteOptions contains the optional parameters for the WorkspacesClient.BeginDelete method. +func (client *WorkspacesClient) BeginDelete(ctx context.Context, resourceGroupName string, playwrightWorkspaceName string, options *WorkspacesClientBeginDeleteOptions) (*runtime.Poller[WorkspacesClientDeleteResponse], error) { + if options == nil || options.ResumeToken == "" { + resp, err := client.deleteOperation(ctx, resourceGroupName, playwrightWorkspaceName, options) + if err != nil { + return nil, err + } + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkspacesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err + } else { + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WorkspacesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + } +} + +// Delete - Delete a PlaywrightWorkspace +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-07-01-preview +func (client *WorkspacesClient) deleteOperation(ctx context.Context, resourceGroupName string, playwrightWorkspaceName string, options *WorkspacesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "WorkspacesClient.BeginDelete" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.deleteCreateRequest(ctx, resourceGroupName, playwrightWorkspaceName, options) + if err != nil { + return nil, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return nil, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err + } + return httpResp, nil +} + +// deleteCreateRequest creates the Delete request. +func (client *WorkspacesClient) deleteCreateRequest(ctx context.Context, resourceGroupName string, playwrightWorkspaceName string, _ *WorkspacesClientBeginDeleteOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/playwrightWorkspaces/{playwrightWorkspaceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if playwrightWorkspaceName == "" { + return nil, errors.New("parameter playwrightWorkspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{playwrightWorkspaceName}", url.PathEscape(playwrightWorkspaceName)) + req, err := runtime.NewRequest(ctx, http.MethodDelete, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// Get - Get a PlaywrightWorkspace +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - playwrightWorkspaceName - The name of the PlaywrightWorkspace +// - options - WorkspacesClientGetOptions contains the optional parameters for the WorkspacesClient.Get method. +func (client *WorkspacesClient) Get(ctx context.Context, resourceGroupName string, playwrightWorkspaceName string, options *WorkspacesClientGetOptions) (WorkspacesClientGetResponse, error) { + var err error + const operationName = "WorkspacesClient.Get" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.getCreateRequest(ctx, resourceGroupName, playwrightWorkspaceName, options) + if err != nil { + return WorkspacesClientGetResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacesClientGetResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspacesClientGetResponse{}, err + } + resp, err := client.getHandleResponse(httpResp) + return resp, err +} + +// getCreateRequest creates the Get request. +func (client *WorkspacesClient) getCreateRequest(ctx context.Context, resourceGroupName string, playwrightWorkspaceName string, _ *WorkspacesClientGetOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/playwrightWorkspaces/{playwrightWorkspaceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if playwrightWorkspaceName == "" { + return nil, errors.New("parameter playwrightWorkspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{playwrightWorkspaceName}", url.PathEscape(playwrightWorkspaceName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// getHandleResponse handles the Get response. +func (client *WorkspacesClient) getHandleResponse(resp *http.Response) (WorkspacesClientGetResponse, error) { + result := WorkspacesClientGetResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Workspace); err != nil { + return WorkspacesClientGetResponse{}, err + } + return result, nil +} + +// NewListByResourceGroupPager - List PlaywrightWorkspace resources by resource group +// +// Generated from API version 2025-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - options - WorkspacesClientListByResourceGroupOptions contains the optional parameters for the WorkspacesClient.NewListByResourceGroupPager +// method. +func (client *WorkspacesClient) NewListByResourceGroupPager(resourceGroupName string, options *WorkspacesClientListByResourceGroupOptions) *runtime.Pager[WorkspacesClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspacesClientListByResourceGroupResponse]{ + More: func(page WorkspacesClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspacesClientListByResourceGroupResponse) (WorkspacesClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspacesClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return WorkspacesClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listByResourceGroupCreateRequest creates the ListByResourceGroup request. +func (client *WorkspacesClient) listByResourceGroupCreateRequest(ctx context.Context, resourceGroupName string, _ *WorkspacesClientListByResourceGroupOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/playwrightWorkspaces" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listByResourceGroupHandleResponse handles the ListByResourceGroup response. +func (client *WorkspacesClient) listByResourceGroupHandleResponse(resp *http.Response) (WorkspacesClientListByResourceGroupResponse, error) { + result := WorkspacesClientListByResourceGroupResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkspaceListResult); err != nil { + return WorkspacesClientListByResourceGroupResponse{}, err + } + return result, nil +} + +// NewListBySubscriptionPager - List PlaywrightWorkspace resources by subscription ID +// +// Generated from API version 2025-07-01-preview +// - options - WorkspacesClientListBySubscriptionOptions contains the optional parameters for the WorkspacesClient.NewListBySubscriptionPager +// method. +func (client *WorkspacesClient) NewListBySubscriptionPager(options *WorkspacesClientListBySubscriptionOptions) *runtime.Pager[WorkspacesClientListBySubscriptionResponse] { + return runtime.NewPager(runtime.PagingHandler[WorkspacesClientListBySubscriptionResponse]{ + More: func(page WorkspacesClientListBySubscriptionResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *WorkspacesClientListBySubscriptionResponse) (WorkspacesClientListBySubscriptionResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkspacesClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listBySubscriptionCreateRequest(ctx, options) + }, nil) + if err != nil { + return WorkspacesClientListBySubscriptionResponse{}, err + } + return client.listBySubscriptionHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) +} + +// listBySubscriptionCreateRequest creates the ListBySubscription request. +func (client *WorkspacesClient) listBySubscriptionCreateRequest(ctx context.Context, _ *WorkspacesClientListBySubscriptionOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/providers/Microsoft.LoadTestService/playwrightWorkspaces" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + req, err := runtime.NewRequest(ctx, http.MethodGet, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + return req, nil +} + +// listBySubscriptionHandleResponse handles the ListBySubscription response. +func (client *WorkspacesClient) listBySubscriptionHandleResponse(resp *http.Response) (WorkspacesClientListBySubscriptionResponse, error) { + result := WorkspacesClientListBySubscriptionResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.WorkspaceListResult); err != nil { + return WorkspacesClientListBySubscriptionResponse{}, err + } + return result, nil +} + +// Update - Update a PlaywrightWorkspace +// If the operation fails it returns an *azcore.ResponseError type. +// +// Generated from API version 2025-07-01-preview +// - resourceGroupName - The name of the resource group. The name is case insensitive. +// - playwrightWorkspaceName - The name of the PlaywrightWorkspace +// - properties - The resource properties to be updated. +// - options - WorkspacesClientUpdateOptions contains the optional parameters for the WorkspacesClient.Update method. +func (client *WorkspacesClient) Update(ctx context.Context, resourceGroupName string, playwrightWorkspaceName string, properties WorkspaceUpdate, options *WorkspacesClientUpdateOptions) (WorkspacesClientUpdateResponse, error) { + var err error + const operationName = "WorkspacesClient.Update" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() + req, err := client.updateCreateRequest(ctx, resourceGroupName, playwrightWorkspaceName, properties, options) + if err != nil { + return WorkspacesClientUpdateResponse{}, err + } + httpResp, err := client.internal.Pipeline().Do(req) + if err != nil { + return WorkspacesClientUpdateResponse{}, err + } + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkspacesClientUpdateResponse{}, err + } + resp, err := client.updateHandleResponse(httpResp) + return resp, err +} + +// updateCreateRequest creates the Update request. +func (client *WorkspacesClient) updateCreateRequest(ctx context.Context, resourceGroupName string, playwrightWorkspaceName string, properties WorkspaceUpdate, _ *WorkspacesClientUpdateOptions) (*policy.Request, error) { + urlPath := "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.LoadTestService/playwrightWorkspaces/{playwrightWorkspaceName}" + if client.subscriptionID == "" { + return nil, errors.New("parameter client.subscriptionID cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{subscriptionId}", url.PathEscape(client.subscriptionID)) + if resourceGroupName == "" { + return nil, errors.New("parameter resourceGroupName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{resourceGroupName}", url.PathEscape(resourceGroupName)) + if playwrightWorkspaceName == "" { + return nil, errors.New("parameter playwrightWorkspaceName cannot be empty") + } + urlPath = strings.ReplaceAll(urlPath, "{playwrightWorkspaceName}", url.PathEscape(playwrightWorkspaceName)) + req, err := runtime.NewRequest(ctx, http.MethodPatch, runtime.JoinPaths(client.internal.Endpoint(), urlPath)) + if err != nil { + return nil, err + } + reqQP := req.Raw().URL.Query() + reqQP.Set("api-version", "2025-07-01-preview") + req.Raw().URL.RawQuery = reqQP.Encode() + req.Raw().Header["Accept"] = []string{"application/json"} + req.Raw().Header["Content-Type"] = []string{"application/json"} + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil +} + +// updateHandleResponse handles the Update response. +func (client *WorkspacesClient) updateHandleResponse(resp *http.Response) (WorkspacesClientUpdateResponse, error) { + result := WorkspacesClientUpdateResponse{} + if err := runtime.UnmarshalAsJSON(resp, &result.Workspace); err != nil { + return WorkspacesClientUpdateResponse{}, err + } + return result, nil +} diff --git a/sdk/resourcemanager/playwright/armplaywright/workspaces_client_example_test.go b/sdk/resourcemanager/playwright/armplaywright/workspaces_client_example_test.go new file mode 100644 index 000000000000..dd81e49c3f07 --- /dev/null +++ b/sdk/resourcemanager/playwright/armplaywright/workspaces_client_example_test.go @@ -0,0 +1,42 @@ +// 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) Go Code Generator. DO NOT EDIT. + +package armplaywright_test + +import ( + "context" + "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/playwright/armplaywright" + "log" +) + +// Generated from example definition: 2025-07-01-preview/PlaywrightWorkspaces_CheckNameAvailability.json +func ExampleWorkspacesClient_CheckNameAvailability() { + cred, err := azidentity.NewDefaultAzureCredential(nil) + if err != nil { + log.Fatalf("failed to obtain a credential: %v", err) + } + ctx := context.Background() + clientFactory, err := armplaywright.NewClientFactory("00000000-0000-0000-0000-000000000000", cred, nil) + if err != nil { + log.Fatalf("failed to create client: %v", err) + } + res, err := clientFactory.NewWorkspacesClient().CheckNameAvailability(ctx, armplaywright.CheckNameAvailabilityRequest{ + Name: to.Ptr("dummyName"), + Type: to.Ptr("Microsoft.LoadTestService/PlaywrightWorkspaces"), + }, nil) + if err != nil { + log.Fatalf("failed to finish the request: %v", err) + } + // You could use response here. We use blank identifier for just demo purposes. + _ = res + // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. + // res = armplaywright.WorkspacesClientCheckNameAvailabilityResponse{ + // CheckNameAvailabilityResponse: &armplaywright.CheckNameAvailabilityResponse{ + // NameAvailable: to.Ptr(true), + // Message: to.Ptr("Test message."), + // }, + // } +}