diff --git a/sdk/resourcemanager/iothub/armiothub/CHANGELOG.md b/sdk/resourcemanager/iothub/armiothub/CHANGELOG.md index 0dc72b78f25b..6bfb2c9d46c5 100644 --- a/sdk/resourcemanager/iothub/armiothub/CHANGELOG.md +++ b/sdk/resourcemanager/iothub/armiothub/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.3.0 (2023-11-24) +### Features Added + +- Support for test fakes and OpenTelemetry trace spans. + + ## 1.2.0 (2023-09-22) ### Features Added diff --git a/sdk/resourcemanager/iothub/armiothub/README.md b/sdk/resourcemanager/iothub/armiothub/README.md index 1a925af1c1cb..7474f42b2ecc 100644 --- a/sdk/resourcemanager/iothub/armiothub/README.md +++ b/sdk/resourcemanager/iothub/armiothub/README.md @@ -60,6 +60,13 @@ A client groups a set of related APIs, providing access to its functionality. C client := clientFactory.NewResourceClient() ``` +## 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 diff --git a/sdk/resourcemanager/iothub/armiothub/autorest.md b/sdk/resourcemanager/iothub/armiothub/autorest.md index dbbaf3df546e..823f15e407ec 100644 --- a/sdk/resourcemanager/iothub/armiothub/autorest.md +++ b/sdk/resourcemanager/iothub/armiothub/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/32c178f2467f792a322f56174be244135d2c907f/specification/iothub/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/32c178f2467f792a322f56174be244135d2c907f/specification/iothub/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 +module-version: 1.3.0 tag: package-2023-06 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/iothub/armiothub/certificates_client.go b/sdk/resourcemanager/iothub/armiothub/certificates_client.go index c74f54ef2e46..000f0eda1176 100644 --- a/sdk/resourcemanager/iothub/armiothub/certificates_client.go +++ b/sdk/resourcemanager/iothub/armiothub/certificates_client.go @@ -32,7 +32,7 @@ type CertificatesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewCertificatesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*CertificatesClient, error) { - cl, err := arm.NewClient(moduleName+".CertificatesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,6 +55,10 @@ func NewCertificatesClient(subscriptionID string, credential azcore.TokenCredent // method. func (client *CertificatesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, certificateName string, certificateDescription CertificateDescription, options *CertificatesClientCreateOrUpdateOptions) (CertificatesClientCreateOrUpdateResponse, error) { var err error + const operationName = "CertificatesClient.CreateOrUpdate" + 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, resourceName, certificateName, certificateDescription, options) if err != nil { return CertificatesClientCreateOrUpdateResponse{}, err @@ -127,6 +131,10 @@ func (client *CertificatesClient) createOrUpdateHandleResponse(resp *http.Respon // - options - CertificatesClientDeleteOptions contains the optional parameters for the CertificatesClient.Delete method. func (client *CertificatesClient) Delete(ctx context.Context, resourceGroupName string, resourceName string, certificateName string, ifMatch string, options *CertificatesClientDeleteOptions) (CertificatesClientDeleteResponse, error) { var err error + const operationName = "CertificatesClient.Delete" + 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, resourceName, certificateName, ifMatch, options) if err != nil { return CertificatesClientDeleteResponse{}, err @@ -186,6 +194,10 @@ func (client *CertificatesClient) deleteCreateRequest(ctx context.Context, resou // method. func (client *CertificatesClient) GenerateVerificationCode(ctx context.Context, resourceGroupName string, resourceName string, certificateName string, ifMatch string, options *CertificatesClientGenerateVerificationCodeOptions) (CertificatesClientGenerateVerificationCodeResponse, error) { var err error + const operationName = "CertificatesClient.GenerateVerificationCode" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.generateVerificationCodeCreateRequest(ctx, resourceGroupName, resourceName, certificateName, ifMatch, options) if err != nil { return CertificatesClientGenerateVerificationCodeResponse{}, err @@ -252,6 +264,10 @@ func (client *CertificatesClient) generateVerificationCodeHandleResponse(resp *h // - options - CertificatesClientGetOptions contains the optional parameters for the CertificatesClient.Get method. func (client *CertificatesClient) Get(ctx context.Context, resourceGroupName string, resourceName string, certificateName string, options *CertificatesClientGetOptions) (CertificatesClientGetResponse, error) { var err error + const operationName = "CertificatesClient.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, resourceName, certificateName, options) if err != nil { return CertificatesClientGetResponse{}, err @@ -317,6 +333,10 @@ func (client *CertificatesClient) getHandleResponse(resp *http.Response) (Certif // method. func (client *CertificatesClient) ListByIotHub(ctx context.Context, resourceGroupName string, resourceName string, options *CertificatesClientListByIotHubOptions) (CertificatesClientListByIotHubResponse, error) { var err error + const operationName = "CertificatesClient.ListByIotHub" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listByIotHubCreateRequest(ctx, resourceGroupName, resourceName, options) if err != nil { return CertificatesClientListByIotHubResponse{}, err @@ -381,6 +401,10 @@ func (client *CertificatesClient) listByIotHubHandleResponse(resp *http.Response // - options - CertificatesClientVerifyOptions contains the optional parameters for the CertificatesClient.Verify method. func (client *CertificatesClient) Verify(ctx context.Context, resourceGroupName string, resourceName string, certificateName string, ifMatch string, certificateVerificationBody CertificateVerificationDescription, options *CertificatesClientVerifyOptions) (CertificatesClientVerifyResponse, error) { var err error + const operationName = "CertificatesClient.Verify" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.verifyCreateRequest(ctx, resourceGroupName, resourceName, certificateName, ifMatch, certificateVerificationBody, options) if err != nil { return CertificatesClientVerifyResponse{}, err diff --git a/sdk/resourcemanager/iothub/armiothub/certificates_client_example_test.go b/sdk/resourcemanager/iothub/armiothub/certificates_client_example_test.go index 577050d4ae3e..97cff289379f 100644 --- a/sdk/resourcemanager/iothub/armiothub/certificates_client_example_test.go +++ b/sdk/resourcemanager/iothub/armiothub/certificates_client_example_test.go @@ -45,12 +45,12 @@ func ExampleCertificatesClient_ListByIotHub() { // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/IotHubs/andbuc-hub/certificates/cert"), // Properties: &armiothub.CertificateProperties{ // Certificate: to.Ptr("############################################"), - // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 12 Oct 2017 19:23:50 GMT"); return t}()), - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Sat, 31 Dec 2039 23:59:59 GMT"); return t}()), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2017-10-12T19:23:50.000Z"); return t}()), + // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2039-12-31T23:59:59.000Z"); return t}()), // IsVerified: to.Ptr(false), // Subject: to.Ptr("CN=testdevice1"), // Thumbprint: to.Ptr("97388663832D0393C9246CAB4FBA2C8677185A25"), - // Updated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 12 Oct 2017 19:23:50 GMT"); return t}()), + // Updated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2017-10-12T19:23:50.000Z"); return t}()), // }, // }}, // } @@ -81,12 +81,12 @@ func ExampleCertificatesClient_Get() { // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/IotHubs/andbuc-hub/certificates/cert"), // Properties: &armiothub.CertificateProperties{ // Certificate: to.Ptr("############################################"), - // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 12 Oct 2017 19:23:50 GMT"); return t}()), - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Sat, 31 Dec 2039 23:59:59 GMT"); return t}()), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2017-10-12T19:23:50.000Z"); return t}()), + // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2039-12-31T23:59:59.000Z"); return t}()), // IsVerified: to.Ptr(false), // Subject: to.Ptr("CN=testdevice1"), // Thumbprint: to.Ptr("97388663832D0393C9246CAB4FBA2C8677185A25"), - // Updated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 12 Oct 2017 19:23:50 GMT"); return t}()), + // Updated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2017-10-12T19:23:50.000Z"); return t}()), // }, // } } @@ -120,12 +120,12 @@ func ExampleCertificatesClient_CreateOrUpdate() { // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/ProvisioningServives/myFirstProvisioningService/certificates/cert"), // Properties: &armiothub.CertificateProperties{ // Certificate: to.Ptr("############################################"), - // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 12 Oct 2017 19:23:50 GMT"); return t}()), - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Sat, 31 Dec 2039 23:59:59 GMT"); return t}()), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2017-10-12T19:23:50.000Z"); return t}()), + // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2039-12-31T23:59:59.000Z"); return t}()), // IsVerified: to.Ptr(false), // Subject: to.Ptr("CN=testdevice1"), // Thumbprint: to.Ptr("97388663832D0393C9246CAB4FBA2C8677185A25"), - // Updated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 12 Oct 2017 19:23:50 GMT"); return t}()), + // Updated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2017-10-12T19:23:50.000Z"); return t}()), // }, // } } @@ -168,12 +168,12 @@ func ExampleCertificatesClient_GenerateVerificationCode() { // res.CertificateWithNonceDescription = armiothub.CertificateWithNonceDescription{ // Name: to.Ptr("cert"), // Properties: &armiothub.CertificatePropertiesWithNonce{ - // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 12 Oct 2017 19:23:50 GMT"); return t}()), - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Sat, 31 Dec 2039 23:59:59 GMT"); return t}()), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2017-10-12T19:23:50.000Z"); return t}()), + // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2039-12-31T23:59:59.000Z"); return t}()), // IsVerified: to.Ptr(false), // Subject: to.Ptr("CN=andbucdevice1"), // Thumbprint: to.Ptr("##############################"), - // Updated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 12 Oct 2017 19:26:56 GMT"); return t}()), + // Updated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2017-10-12T19:26:56.000Z"); return t}()), // VerificationCode: to.Ptr("##################################"), // }, // } @@ -205,12 +205,12 @@ func ExampleCertificatesClient_Verify() { // Etag: to.Ptr("AAAAAAExpTQ="), // ID: to.Ptr("/subscriptions/91d12660-3dec-467a-be2a-213b5544ddc0/resourceGroups/myResourceGroup/providers/Microsoft.Devices/ProvisioningServices/myFirstProvisioningService/certificates/cert"), // Properties: &armiothub.CertificateProperties{ - // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 12 Oct 2017 19:23:50 GMT"); return t}()), - // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Sat, 31 Dec 2039 23:59:59 GMT"); return t}()), + // Created: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2017-10-12T19:23:50.000Z"); return t}()), + // Expiry: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2039-12-31T23:59:59.000Z"); return t}()), // IsVerified: to.Ptr(true), // Subject: to.Ptr("CN=andbucdevice1"), // Thumbprint: to.Ptr("97388663832D0393C9246CAB4FBA2C8677185A25"), - // Updated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 12 Oct 2017 19:26:56 GMT"); return t}()), + // Updated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2017-10-12T19:26:56.000Z"); return t}()), // }, // } } diff --git a/sdk/resourcemanager/iothub/armiothub/client.go b/sdk/resourcemanager/iothub/armiothub/client.go index 304fdc3ac581..3180ad043936 100644 --- a/sdk/resourcemanager/iothub/armiothub/client.go +++ b/sdk/resourcemanager/iothub/armiothub/client.go @@ -32,7 +32,7 @@ type Client struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*Client, error) { - cl, err := arm.NewClient(moduleName+".Client", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -58,10 +58,14 @@ func (client *Client) BeginManualFailover(ctx context.Context, iotHubName string if err != nil { return nil, err } - poller, err := runtime.NewPoller[ClientManualFailoverResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClientManualFailoverResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ClientManualFailoverResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClientManualFailoverResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -71,6 +75,10 @@ func (client *Client) BeginManualFailover(ctx context.Context, iotHubName string // Generated from API version 2023-06-30 func (client *Client) manualFailover(ctx context.Context, iotHubName string, resourceGroupName string, failoverInput FailoverInput, options *ClientBeginManualFailoverOptions) (*http.Response, error) { var err error + const operationName = "Client.BeginManualFailover" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.manualFailoverCreateRequest(ctx, iotHubName, resourceGroupName, failoverInput, options) if err != nil { return nil, err diff --git a/sdk/resourcemanager/iothub/armiothub/client_factory.go b/sdk/resourcemanager/iothub/armiothub/client_factory.go index 37aba63f64b6..95e13ebc58c4 100644 --- a/sdk/resourcemanager/iothub/armiothub/client_factory.go +++ b/sdk/resourcemanager/iothub/armiothub/client_factory.go @@ -27,7 +27,7 @@ type ClientFactory struct { // - 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+".ClientFactory", moduleVersion, credential, options) + _, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -37,36 +37,43 @@ func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, }, nil } +// NewCertificatesClient creates a new instance of CertificatesClient. func (c *ClientFactory) NewCertificatesClient() *CertificatesClient { subClient, _ := NewCertificatesClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewClient creates a new instance of Client. func (c *ClientFactory) NewClient() *Client { subClient, _ := NewClient(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 } +// NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient. func (c *ClientFactory) NewPrivateEndpointConnectionsClient() *PrivateEndpointConnectionsClient { subClient, _ := NewPrivateEndpointConnectionsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient. func (c *ClientFactory) NewPrivateLinkResourcesClient() *PrivateLinkResourcesClient { subClient, _ := NewPrivateLinkResourcesClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewResourceClient creates a new instance of ResourceClient. func (c *ClientFactory) NewResourceClient() *ResourceClient { subClient, _ := NewResourceClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewResourceProviderCommonClient creates a new instance of ResourceProviderCommonClient. func (c *ClientFactory) NewResourceProviderCommonClient() *ResourceProviderCommonClient { subClient, _ := NewResourceProviderCommonClient(c.subscriptionID, c.credential, c.options) return subClient diff --git a/sdk/resourcemanager/iothub/armiothub/constants.go b/sdk/resourcemanager/iothub/armiothub/constants.go index 63b8655f1735..973afbb851d3 100644 --- a/sdk/resourcemanager/iothub/armiothub/constants.go +++ b/sdk/resourcemanager/iothub/armiothub/constants.go @@ -9,8 +9,8 @@ package armiothub const ( - moduleName = "armiothub" - moduleVersion = "v1.2.0" + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/iothub/armiothub" + moduleVersion = "v1.3.0" ) // AccessRights - The permissions assigned to the shared access policy. diff --git a/sdk/resourcemanager/iothub/armiothub/fake/certificates_server.go b/sdk/resourcemanager/iothub/armiothub/fake/certificates_server.go new file mode 100644 index 000000000000..ec3e4db8c69a --- /dev/null +++ b/sdk/resourcemanager/iothub/armiothub/fake/certificates_server.go @@ -0,0 +1,330 @@ +//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/resourcemanager/iothub/armiothub" + "net/http" + "net/url" + "regexp" +) + +// CertificatesServer is a fake server for instances of the armiothub.CertificatesClient type. +type CertificatesServer struct { + // CreateOrUpdate is the fake for method CertificatesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, resourceName string, certificateName string, certificateDescription armiothub.CertificateDescription, options *armiothub.CertificatesClientCreateOrUpdateOptions) (resp azfake.Responder[armiothub.CertificatesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method CertificatesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, resourceName string, certificateName string, ifMatch string, options *armiothub.CertificatesClientDeleteOptions) (resp azfake.Responder[armiothub.CertificatesClientDeleteResponse], errResp azfake.ErrorResponder) + + // GenerateVerificationCode is the fake for method CertificatesClient.GenerateVerificationCode + // HTTP status codes to indicate success: http.StatusOK + GenerateVerificationCode func(ctx context.Context, resourceGroupName string, resourceName string, certificateName string, ifMatch string, options *armiothub.CertificatesClientGenerateVerificationCodeOptions) (resp azfake.Responder[armiothub.CertificatesClientGenerateVerificationCodeResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method CertificatesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, resourceName string, certificateName string, options *armiothub.CertificatesClientGetOptions) (resp azfake.Responder[armiothub.CertificatesClientGetResponse], errResp azfake.ErrorResponder) + + // ListByIotHub is the fake for method CertificatesClient.ListByIotHub + // HTTP status codes to indicate success: http.StatusOK + ListByIotHub func(ctx context.Context, resourceGroupName string, resourceName string, options *armiothub.CertificatesClientListByIotHubOptions) (resp azfake.Responder[armiothub.CertificatesClientListByIotHubResponse], errResp azfake.ErrorResponder) + + // Verify is the fake for method CertificatesClient.Verify + // HTTP status codes to indicate success: http.StatusOK + Verify func(ctx context.Context, resourceGroupName string, resourceName string, certificateName string, ifMatch string, certificateVerificationBody armiothub.CertificateVerificationDescription, options *armiothub.CertificatesClientVerifyOptions) (resp azfake.Responder[armiothub.CertificatesClientVerifyResponse], errResp azfake.ErrorResponder) +} + +// NewCertificatesServerTransport creates a new instance of CertificatesServerTransport with the provided implementation. +// The returned CertificatesServerTransport instance is connected to an instance of armiothub.CertificatesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewCertificatesServerTransport(srv *CertificatesServer) *CertificatesServerTransport { + return &CertificatesServerTransport{srv: srv} +} + +// CertificatesServerTransport connects instances of armiothub.CertificatesClient to instances of CertificatesServer. +// Don't use this type directly, use NewCertificatesServerTransport instead. +type CertificatesServerTransport struct { + srv *CertificatesServer +} + +// Do implements the policy.Transporter interface for CertificatesServerTransport. +func (c *CertificatesServerTransport) 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 "CertificatesClient.CreateOrUpdate": + resp, err = c.dispatchCreateOrUpdate(req) + case "CertificatesClient.Delete": + resp, err = c.dispatchDelete(req) + case "CertificatesClient.GenerateVerificationCode": + resp, err = c.dispatchGenerateVerificationCode(req) + case "CertificatesClient.Get": + resp, err = c.dispatchGet(req) + case "CertificatesClient.ListByIotHub": + resp, err = c.dispatchListByIotHub(req) + case "CertificatesClient.Verify": + resp, err = c.dispatchVerify(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (c *CertificatesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if c.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armiothub.CertificateDescription](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + certificateNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("certificateName")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armiothub.CertificatesClientCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armiothub.CertificatesClientCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := c.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, resourceNameParam, certificateNameParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).CertificateDescription, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *CertificatesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if c.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + certificateNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("certificateName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Delete(req.Context(), resourceGroupNameParam, resourceNameParam, certificateNameParam, getHeaderValue(req.Header, "If-Match"), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *CertificatesServerTransport) dispatchGenerateVerificationCode(req *http.Request) (*http.Response, error) { + if c.srv.GenerateVerificationCode == nil { + return nil, &nonRetriableError{errors.New("fake for method GenerateVerificationCode not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/generateVerificationCode` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + certificateNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("certificateName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.GenerateVerificationCode(req.Context(), resourceGroupNameParam, resourceNameParam, certificateNameParam, getHeaderValue(req.Header, "If-Match"), 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).CertificateWithNonceDescription, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *CertificatesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if c.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\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + certificateNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("certificateName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameParam, resourceNameParam, certificateNameParam, 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).CertificateDescription, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *CertificatesServerTransport) dispatchListByIotHub(req *http.Request) (*http.Response, error) { + if c.srv.ListByIotHub == nil { + return nil, &nonRetriableError{errors.New("fake for method ListByIotHub not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates` + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.ListByIotHub(req.Context(), resourceGroupNameParam, resourceNameParam, 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).CertificateListDescription, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *CertificatesServerTransport) dispatchVerify(req *http.Request) (*http.Response, error) { + if c.srv.Verify == nil { + return nil, &nonRetriableError{errors.New("fake for method Verify not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/verify` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armiothub.CertificateVerificationDescription](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + certificateNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("certificateName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Verify(req.Context(), resourceGroupNameParam, resourceNameParam, certificateNameParam, getHeaderValue(req.Header, "If-Match"), 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).CertificateDescription, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/iothub/armiothub/fake/internal.go b/sdk/resourcemanager/iothub/armiothub/fake/internal.go new file mode 100644 index 000000000000..45777d4ec6e6 --- /dev/null +++ b/sdk/resourcemanager/iothub/armiothub/fake/internal.go @@ -0,0 +1,80 @@ +//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 ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "reflect" + "sync" +) + +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 getHeaderValue(h http.Header, k string) string { + v := h[k] + if len(v) == 0 { + return "" + } + return v[0] +} + +func getOptional[T any](v T) *T { + if reflect.ValueOf(v).IsZero() { + return nil + } + return &v +} + +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/iothub/armiothub/fake/operations_server.go b/sdk/resourcemanager/iothub/armiothub/fake/operations_server.go new file mode 100644 index 000000000000..1ed8a5ba3569 --- /dev/null +++ b/sdk/resourcemanager/iothub/armiothub/fake/operations_server.go @@ -0,0 +1,96 @@ +//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 ( + "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/iothub/armiothub" + "net/http" +) + +// OperationsServer is a fake server for instances of the armiothub.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armiothub.OperationsClientListOptions) (resp azfake.PagerResponder[armiothub.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armiothub.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[armiothub.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armiothub.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armiothub.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) 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 "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armiothub.OperationsClientListResponse, 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) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/iothub/armiothub/fake/privateendpointconnections_server.go b/sdk/resourcemanager/iothub/armiothub/fake/privateendpointconnections_server.go new file mode 100644 index 000000000000..cc3a446bcf0b --- /dev/null +++ b/sdk/resourcemanager/iothub/armiothub/fake/privateendpointconnections_server.go @@ -0,0 +1,261 @@ +//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/resourcemanager/iothub/armiothub" + "net/http" + "net/url" + "regexp" +) + +// PrivateEndpointConnectionsServer is a fake server for instances of the armiothub.PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsServer struct { + // BeginDelete is the fake for method PrivateEndpointConnectionsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, options *armiothub.PrivateEndpointConnectionsClientBeginDeleteOptions) (resp azfake.PollerResponder[armiothub.PrivateEndpointConnectionsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method PrivateEndpointConnectionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, options *armiothub.PrivateEndpointConnectionsClientGetOptions) (resp azfake.Responder[armiothub.PrivateEndpointConnectionsClientGetResponse], errResp azfake.ErrorResponder) + + // List is the fake for method PrivateEndpointConnectionsClient.List + // HTTP status codes to indicate success: http.StatusOK + List func(ctx context.Context, resourceGroupName string, resourceName string, options *armiothub.PrivateEndpointConnectionsClientListOptions) (resp azfake.Responder[armiothub.PrivateEndpointConnectionsClientListResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method PrivateEndpointConnectionsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginUpdate func(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, privateEndpointConnection armiothub.PrivateEndpointConnection, options *armiothub.PrivateEndpointConnectionsClientBeginUpdateOptions) (resp azfake.PollerResponder[armiothub.PrivateEndpointConnectionsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewPrivateEndpointConnectionsServerTransport creates a new instance of PrivateEndpointConnectionsServerTransport with the provided implementation. +// The returned PrivateEndpointConnectionsServerTransport instance is connected to an instance of armiothub.PrivateEndpointConnectionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPrivateEndpointConnectionsServerTransport(srv *PrivateEndpointConnectionsServer) *PrivateEndpointConnectionsServerTransport { + return &PrivateEndpointConnectionsServerTransport{ + srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armiothub.PrivateEndpointConnectionsClientDeleteResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armiothub.PrivateEndpointConnectionsClientUpdateResponse]](), + } +} + +// PrivateEndpointConnectionsServerTransport connects instances of armiothub.PrivateEndpointConnectionsClient to instances of PrivateEndpointConnectionsServer. +// Don't use this type directly, use NewPrivateEndpointConnectionsServerTransport instead. +type PrivateEndpointConnectionsServerTransport struct { + srv *PrivateEndpointConnectionsServer + beginDelete *tracker[azfake.PollerResponder[armiothub.PrivateEndpointConnectionsClientDeleteResponse]] + beginUpdate *tracker[azfake.PollerResponder[armiothub.PrivateEndpointConnectionsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for PrivateEndpointConnectionsServerTransport. +func (p *PrivateEndpointConnectionsServerTransport) 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 "PrivateEndpointConnectionsClient.BeginDelete": + resp, err = p.dispatchBeginDelete(req) + case "PrivateEndpointConnectionsClient.Get": + resp, err = p.dispatchGet(req) + case "PrivateEndpointConnectionsClient.List": + resp, err = p.dispatchList(req) + case "PrivateEndpointConnectionsClient.BeginUpdate": + resp, err = p.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if p.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := p.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/iotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginDelete(req.Context(), resourceGroupNameParam, resourceNameParam, privateEndpointConnectionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + p.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) { + p.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) { + p.beginDelete.remove(req) + } + + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.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\.Devices/iotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, resourceNameParam, privateEndpointConnectionNameParam, 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).PrivateEndpointConnection, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchList(req *http.Request) (*http.Response, error) { + if p.srv.List == nil { + return nil, &nonRetriableError{errors.New("fake for method List not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/iotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections` + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.List(req.Context(), resourceGroupNameParam, resourceNameParam, 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).PrivateEndpointConnectionArray, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if p.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := p.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/iotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armiothub.PrivateEndpointConnection](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginUpdate(req.Context(), resourceGroupNameParam, resourceNameParam, privateEndpointConnectionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + p.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + p.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + p.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/iothub/armiothub/fake/privatelinkresources_server.go b/sdk/resourcemanager/iothub/armiothub/fake/privatelinkresources_server.go new file mode 100644 index 000000000000..fa4286ff7b02 --- /dev/null +++ b/sdk/resourcemanager/iothub/armiothub/fake/privatelinkresources_server.go @@ -0,0 +1,143 @@ +//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/resourcemanager/iothub/armiothub" + "net/http" + "net/url" + "regexp" +) + +// PrivateLinkResourcesServer is a fake server for instances of the armiothub.PrivateLinkResourcesClient type. +type PrivateLinkResourcesServer struct { + // Get is the fake for method PrivateLinkResourcesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, resourceName string, groupID string, options *armiothub.PrivateLinkResourcesClientGetOptions) (resp azfake.Responder[armiothub.PrivateLinkResourcesClientGetResponse], errResp azfake.ErrorResponder) + + // List is the fake for method PrivateLinkResourcesClient.List + // HTTP status codes to indicate success: http.StatusOK + List func(ctx context.Context, resourceGroupName string, resourceName string, options *armiothub.PrivateLinkResourcesClientListOptions) (resp azfake.Responder[armiothub.PrivateLinkResourcesClientListResponse], errResp azfake.ErrorResponder) +} + +// NewPrivateLinkResourcesServerTransport creates a new instance of PrivateLinkResourcesServerTransport with the provided implementation. +// The returned PrivateLinkResourcesServerTransport instance is connected to an instance of armiothub.PrivateLinkResourcesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPrivateLinkResourcesServerTransport(srv *PrivateLinkResourcesServer) *PrivateLinkResourcesServerTransport { + return &PrivateLinkResourcesServerTransport{srv: srv} +} + +// PrivateLinkResourcesServerTransport connects instances of armiothub.PrivateLinkResourcesClient to instances of PrivateLinkResourcesServer. +// Don't use this type directly, use NewPrivateLinkResourcesServerTransport instead. +type PrivateLinkResourcesServerTransport struct { + srv *PrivateLinkResourcesServer +} + +// Do implements the policy.Transporter interface for PrivateLinkResourcesServerTransport. +func (p *PrivateLinkResourcesServerTransport) 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 "PrivateLinkResourcesClient.Get": + resp, err = p.dispatchGet(req) + case "PrivateLinkResourcesClient.List": + resp, err = p.dispatchList(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (p *PrivateLinkResourcesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.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\.Devices/iotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + groupIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("groupId")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, resourceNameParam, groupIDParam, 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).GroupIDInformation, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PrivateLinkResourcesServerTransport) dispatchList(req *http.Request) (*http.Response, error) { + if p.srv.List == nil { + return nil, &nonRetriableError{errors.New("fake for method List not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/iotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources` + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.List(req.Context(), resourceGroupNameParam, resourceNameParam, 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).PrivateLinkResources, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/iothub/armiothub/fake/resource_server.go b/sdk/resourcemanager/iothub/armiothub/fake/resource_server.go new file mode 100644 index 000000000000..6f8a3aeeb7ae --- /dev/null +++ b/sdk/resourcemanager/iothub/armiothub/fake/resource_server.go @@ -0,0 +1,1135 @@ +//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/iothub/armiothub" + "net/http" + "net/url" + "regexp" +) + +// ResourceServer is a fake server for instances of the armiothub.ResourceClient type. +type ResourceServer struct { + // CheckNameAvailability is the fake for method ResourceClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, operationInputs armiothub.OperationInputs, options *armiothub.ResourceClientCheckNameAvailabilityOptions) (resp azfake.Responder[armiothub.ResourceClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // CreateEventHubConsumerGroup is the fake for method ResourceClient.CreateEventHubConsumerGroup + // HTTP status codes to indicate success: http.StatusOK + CreateEventHubConsumerGroup func(ctx context.Context, resourceGroupName string, resourceName string, eventHubEndpointName string, name string, consumerGroupBody armiothub.EventHubConsumerGroupBodyDescription, options *armiothub.ResourceClientCreateEventHubConsumerGroupOptions) (resp azfake.Responder[armiothub.ResourceClientCreateEventHubConsumerGroupResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method ResourceClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, resourceName string, iotHubDescription armiothub.Description, options *armiothub.ResourceClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armiothub.ResourceClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method ResourceClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent, http.StatusNotFound + BeginDelete func(ctx context.Context, resourceGroupName string, resourceName string, options *armiothub.ResourceClientBeginDeleteOptions) (resp azfake.PollerResponder[armiothub.ResourceClientDeleteResponse], errResp azfake.ErrorResponder) + + // DeleteEventHubConsumerGroup is the fake for method ResourceClient.DeleteEventHubConsumerGroup + // HTTP status codes to indicate success: http.StatusOK + DeleteEventHubConsumerGroup func(ctx context.Context, resourceGroupName string, resourceName string, eventHubEndpointName string, name string, options *armiothub.ResourceClientDeleteEventHubConsumerGroupOptions) (resp azfake.Responder[armiothub.ResourceClientDeleteEventHubConsumerGroupResponse], errResp azfake.ErrorResponder) + + // ExportDevices is the fake for method ResourceClient.ExportDevices + // HTTP status codes to indicate success: http.StatusOK + ExportDevices func(ctx context.Context, resourceGroupName string, resourceName string, exportDevicesParameters armiothub.ExportDevicesRequest, options *armiothub.ResourceClientExportDevicesOptions) (resp azfake.Responder[armiothub.ResourceClientExportDevicesResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ResourceClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, resourceName string, options *armiothub.ResourceClientGetOptions) (resp azfake.Responder[armiothub.ResourceClientGetResponse], errResp azfake.ErrorResponder) + + // NewGetEndpointHealthPager is the fake for method ResourceClient.NewGetEndpointHealthPager + // HTTP status codes to indicate success: http.StatusOK + NewGetEndpointHealthPager func(resourceGroupName string, iotHubName string, options *armiothub.ResourceClientGetEndpointHealthOptions) (resp azfake.PagerResponder[armiothub.ResourceClientGetEndpointHealthResponse]) + + // GetEventHubConsumerGroup is the fake for method ResourceClient.GetEventHubConsumerGroup + // HTTP status codes to indicate success: http.StatusOK + GetEventHubConsumerGroup func(ctx context.Context, resourceGroupName string, resourceName string, eventHubEndpointName string, name string, options *armiothub.ResourceClientGetEventHubConsumerGroupOptions) (resp azfake.Responder[armiothub.ResourceClientGetEventHubConsumerGroupResponse], errResp azfake.ErrorResponder) + + // GetJob is the fake for method ResourceClient.GetJob + // HTTP status codes to indicate success: http.StatusOK + GetJob func(ctx context.Context, resourceGroupName string, resourceName string, jobID string, options *armiothub.ResourceClientGetJobOptions) (resp azfake.Responder[armiothub.ResourceClientGetJobResponse], errResp azfake.ErrorResponder) + + // GetKeysForKeyName is the fake for method ResourceClient.GetKeysForKeyName + // HTTP status codes to indicate success: http.StatusOK + GetKeysForKeyName func(ctx context.Context, resourceGroupName string, resourceName string, keyName string, options *armiothub.ResourceClientGetKeysForKeyNameOptions) (resp azfake.Responder[armiothub.ResourceClientGetKeysForKeyNameResponse], errResp azfake.ErrorResponder) + + // NewGetQuotaMetricsPager is the fake for method ResourceClient.NewGetQuotaMetricsPager + // HTTP status codes to indicate success: http.StatusOK + NewGetQuotaMetricsPager func(resourceGroupName string, resourceName string, options *armiothub.ResourceClientGetQuotaMetricsOptions) (resp azfake.PagerResponder[armiothub.ResourceClientGetQuotaMetricsResponse]) + + // GetStats is the fake for method ResourceClient.GetStats + // HTTP status codes to indicate success: http.StatusOK + GetStats func(ctx context.Context, resourceGroupName string, resourceName string, options *armiothub.ResourceClientGetStatsOptions) (resp azfake.Responder[armiothub.ResourceClientGetStatsResponse], errResp azfake.ErrorResponder) + + // NewGetValidSKUsPager is the fake for method ResourceClient.NewGetValidSKUsPager + // HTTP status codes to indicate success: http.StatusOK + NewGetValidSKUsPager func(resourceGroupName string, resourceName string, options *armiothub.ResourceClientGetValidSKUsOptions) (resp azfake.PagerResponder[armiothub.ResourceClientGetValidSKUsResponse]) + + // ImportDevices is the fake for method ResourceClient.ImportDevices + // HTTP status codes to indicate success: http.StatusOK + ImportDevices func(ctx context.Context, resourceGroupName string, resourceName string, importDevicesParameters armiothub.ImportDevicesRequest, options *armiothub.ResourceClientImportDevicesOptions) (resp azfake.Responder[armiothub.ResourceClientImportDevicesResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method ResourceClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armiothub.ResourceClientListByResourceGroupOptions) (resp azfake.PagerResponder[armiothub.ResourceClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method ResourceClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armiothub.ResourceClientListBySubscriptionOptions) (resp azfake.PagerResponder[armiothub.ResourceClientListBySubscriptionResponse]) + + // NewListEventHubConsumerGroupsPager is the fake for method ResourceClient.NewListEventHubConsumerGroupsPager + // HTTP status codes to indicate success: http.StatusOK + NewListEventHubConsumerGroupsPager func(resourceGroupName string, resourceName string, eventHubEndpointName string, options *armiothub.ResourceClientListEventHubConsumerGroupsOptions) (resp azfake.PagerResponder[armiothub.ResourceClientListEventHubConsumerGroupsResponse]) + + // NewListJobsPager is the fake for method ResourceClient.NewListJobsPager + // HTTP status codes to indicate success: http.StatusOK + NewListJobsPager func(resourceGroupName string, resourceName string, options *armiothub.ResourceClientListJobsOptions) (resp azfake.PagerResponder[armiothub.ResourceClientListJobsResponse]) + + // NewListKeysPager is the fake for method ResourceClient.NewListKeysPager + // HTTP status codes to indicate success: http.StatusOK + NewListKeysPager func(resourceGroupName string, resourceName string, options *armiothub.ResourceClientListKeysOptions) (resp azfake.PagerResponder[armiothub.ResourceClientListKeysResponse]) + + // TestAllRoutes is the fake for method ResourceClient.TestAllRoutes + // HTTP status codes to indicate success: http.StatusOK + TestAllRoutes func(ctx context.Context, iotHubName string, resourceGroupName string, input armiothub.TestAllRoutesInput, options *armiothub.ResourceClientTestAllRoutesOptions) (resp azfake.Responder[armiothub.ResourceClientTestAllRoutesResponse], errResp azfake.ErrorResponder) + + // TestRoute is the fake for method ResourceClient.TestRoute + // HTTP status codes to indicate success: http.StatusOK + TestRoute func(ctx context.Context, iotHubName string, resourceGroupName string, input armiothub.TestRouteInput, options *armiothub.ResourceClientTestRouteOptions) (resp azfake.Responder[armiothub.ResourceClientTestRouteResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method ResourceClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK + BeginUpdate func(ctx context.Context, resourceGroupName string, resourceName string, iotHubTags armiothub.TagsResource, options *armiothub.ResourceClientBeginUpdateOptions) (resp azfake.PollerResponder[armiothub.ResourceClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewResourceServerTransport creates a new instance of ResourceServerTransport with the provided implementation. +// The returned ResourceServerTransport instance is connected to an instance of armiothub.ResourceClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewResourceServerTransport(srv *ResourceServer) *ResourceServerTransport { + return &ResourceServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armiothub.ResourceClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armiothub.ResourceClientDeleteResponse]](), + newGetEndpointHealthPager: newTracker[azfake.PagerResponder[armiothub.ResourceClientGetEndpointHealthResponse]](), + newGetQuotaMetricsPager: newTracker[azfake.PagerResponder[armiothub.ResourceClientGetQuotaMetricsResponse]](), + newGetValidSKUsPager: newTracker[azfake.PagerResponder[armiothub.ResourceClientGetValidSKUsResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armiothub.ResourceClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armiothub.ResourceClientListBySubscriptionResponse]](), + newListEventHubConsumerGroupsPager: newTracker[azfake.PagerResponder[armiothub.ResourceClientListEventHubConsumerGroupsResponse]](), + newListJobsPager: newTracker[azfake.PagerResponder[armiothub.ResourceClientListJobsResponse]](), + newListKeysPager: newTracker[azfake.PagerResponder[armiothub.ResourceClientListKeysResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armiothub.ResourceClientUpdateResponse]](), + } +} + +// ResourceServerTransport connects instances of armiothub.ResourceClient to instances of ResourceServer. +// Don't use this type directly, use NewResourceServerTransport instead. +type ResourceServerTransport struct { + srv *ResourceServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armiothub.ResourceClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armiothub.ResourceClientDeleteResponse]] + newGetEndpointHealthPager *tracker[azfake.PagerResponder[armiothub.ResourceClientGetEndpointHealthResponse]] + newGetQuotaMetricsPager *tracker[azfake.PagerResponder[armiothub.ResourceClientGetQuotaMetricsResponse]] + newGetValidSKUsPager *tracker[azfake.PagerResponder[armiothub.ResourceClientGetValidSKUsResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armiothub.ResourceClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armiothub.ResourceClientListBySubscriptionResponse]] + newListEventHubConsumerGroupsPager *tracker[azfake.PagerResponder[armiothub.ResourceClientListEventHubConsumerGroupsResponse]] + newListJobsPager *tracker[azfake.PagerResponder[armiothub.ResourceClientListJobsResponse]] + newListKeysPager *tracker[azfake.PagerResponder[armiothub.ResourceClientListKeysResponse]] + beginUpdate *tracker[azfake.PollerResponder[armiothub.ResourceClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for ResourceServerTransport. +func (r *ResourceServerTransport) 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 "ResourceClient.CheckNameAvailability": + resp, err = r.dispatchCheckNameAvailability(req) + case "ResourceClient.CreateEventHubConsumerGroup": + resp, err = r.dispatchCreateEventHubConsumerGroup(req) + case "ResourceClient.BeginCreateOrUpdate": + resp, err = r.dispatchBeginCreateOrUpdate(req) + case "ResourceClient.BeginDelete": + resp, err = r.dispatchBeginDelete(req) + case "ResourceClient.DeleteEventHubConsumerGroup": + resp, err = r.dispatchDeleteEventHubConsumerGroup(req) + case "ResourceClient.ExportDevices": + resp, err = r.dispatchExportDevices(req) + case "ResourceClient.Get": + resp, err = r.dispatchGet(req) + case "ResourceClient.NewGetEndpointHealthPager": + resp, err = r.dispatchNewGetEndpointHealthPager(req) + case "ResourceClient.GetEventHubConsumerGroup": + resp, err = r.dispatchGetEventHubConsumerGroup(req) + case "ResourceClient.GetJob": + resp, err = r.dispatchGetJob(req) + case "ResourceClient.GetKeysForKeyName": + resp, err = r.dispatchGetKeysForKeyName(req) + case "ResourceClient.NewGetQuotaMetricsPager": + resp, err = r.dispatchNewGetQuotaMetricsPager(req) + case "ResourceClient.GetStats": + resp, err = r.dispatchGetStats(req) + case "ResourceClient.NewGetValidSKUsPager": + resp, err = r.dispatchNewGetValidSKUsPager(req) + case "ResourceClient.ImportDevices": + resp, err = r.dispatchImportDevices(req) + case "ResourceClient.NewListByResourceGroupPager": + resp, err = r.dispatchNewListByResourceGroupPager(req) + case "ResourceClient.NewListBySubscriptionPager": + resp, err = r.dispatchNewListBySubscriptionPager(req) + case "ResourceClient.NewListEventHubConsumerGroupsPager": + resp, err = r.dispatchNewListEventHubConsumerGroupsPager(req) + case "ResourceClient.NewListJobsPager": + resp, err = r.dispatchNewListJobsPager(req) + case "ResourceClient.NewListKeysPager": + resp, err = r.dispatchNewListKeysPager(req) + case "ResourceClient.TestAllRoutes": + resp, err = r.dispatchTestAllRoutes(req) + case "ResourceClient.TestRoute": + resp, err = r.dispatchTestRoute(req) + case "ResourceClient.BeginUpdate": + resp, err = r.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (r *ResourceServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if r.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/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[armiothub.OperationInputs](req) + if err != nil { + return nil, err + } + respr, errRespr := r.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).NameAvailabilityInfo, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchCreateEventHubConsumerGroup(req *http.Request) (*http.Response, error) { + if r.srv.CreateEventHubConsumerGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateEventHubConsumerGroup not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/eventHubEndpoints/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/ConsumerGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armiothub.EventHubConsumerGroupBodyDescription](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + eventHubEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("eventHubEndpointName")]) + if err != nil { + return nil, err + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.CreateEventHubConsumerGroup(req.Context(), resourceGroupNameParam, resourceNameParam, eventHubEndpointNameParam, nameParam, 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).EventHubConsumerGroupInfo, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if r.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := r.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?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[armiothub.Description](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armiothub.ResourceClientBeginCreateOrUpdateOptions + if ifMatchParam != nil { + options = &armiothub.ResourceClientBeginCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := r.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, resourceNameParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + r.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) { + r.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) { + r.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (r *ResourceServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if r.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := r.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginDelete(req.Context(), resourceGroupNameParam, resourceNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + r.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, http.StatusNotFound}, resp.StatusCode) { + r.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent, http.StatusNotFound", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + r.beginDelete.remove(req) + } + + return resp, nil +} + +func (r *ResourceServerTransport) dispatchDeleteEventHubConsumerGroup(req *http.Request) (*http.Response, error) { + if r.srv.DeleteEventHubConsumerGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method DeleteEventHubConsumerGroup not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/eventHubEndpoints/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/ConsumerGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + eventHubEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("eventHubEndpointName")]) + if err != nil { + return nil, err + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.DeleteEventHubConsumerGroup(req.Context(), resourceGroupNameParam, resourceNameParam, eventHubEndpointNameParam, nameParam, 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.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchExportDevices(req *http.Request) (*http.Response, error) { + if r.srv.ExportDevices == nil { + return nil, &nonRetriableError{errors.New("fake for method ExportDevices not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/exportDevices` + 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[armiothub.ExportDevicesRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.ExportDevices(req.Context(), resourceGroupNameParam, resourceNameParam, 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).JobResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if r.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\.Devices/IotHubs/(?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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.Get(req.Context(), resourceGroupNameParam, resourceNameParam, 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).Description, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchNewGetEndpointHealthPager(req *http.Request) (*http.Response, error) { + if r.srv.NewGetEndpointHealthPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewGetEndpointHealthPager not implemented")} + } + newGetEndpointHealthPager := r.newGetEndpointHealthPager.get(req) + if newGetEndpointHealthPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/routingEndpointsHealth` + 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 + } + iotHubNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("iotHubName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewGetEndpointHealthPager(resourceGroupNameParam, iotHubNameParam, nil) + newGetEndpointHealthPager = &resp + r.newGetEndpointHealthPager.add(req, newGetEndpointHealthPager) + server.PagerResponderInjectNextLinks(newGetEndpointHealthPager, req, func(page *armiothub.ResourceClientGetEndpointHealthResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newGetEndpointHealthPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newGetEndpointHealthPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newGetEndpointHealthPager) { + r.newGetEndpointHealthPager.remove(req) + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchGetEventHubConsumerGroup(req *http.Request) (*http.Response, error) { + if r.srv.GetEventHubConsumerGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method GetEventHubConsumerGroup not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/eventHubEndpoints/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/ConsumerGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + eventHubEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("eventHubEndpointName")]) + if err != nil { + return nil, err + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetEventHubConsumerGroup(req.Context(), resourceGroupNameParam, resourceNameParam, eventHubEndpointNameParam, nameParam, 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).EventHubConsumerGroupInfo, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchGetJob(req *http.Request) (*http.Response, error) { + if r.srv.GetJob == nil { + return nil, &nonRetriableError{errors.New("fake for method GetJob not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/jobs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + jobIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("jobId")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetJob(req.Context(), resourceGroupNameParam, resourceNameParam, jobIDParam, 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).JobResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchGetKeysForKeyName(req *http.Request) (*http.Response, error) { + if r.srv.GetKeysForKeyName == nil { + return nil, &nonRetriableError{errors.New("fake for method GetKeysForKeyName not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/IotHubKeys/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listkeys` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + keyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("keyName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetKeysForKeyName(req.Context(), resourceGroupNameParam, resourceNameParam, keyNameParam, 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).SharedAccessSignatureAuthorizationRule, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchNewGetQuotaMetricsPager(req *http.Request) (*http.Response, error) { + if r.srv.NewGetQuotaMetricsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewGetQuotaMetricsPager not implemented")} + } + newGetQuotaMetricsPager := r.newGetQuotaMetricsPager.get(req) + if newGetQuotaMetricsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/quotaMetrics` + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewGetQuotaMetricsPager(resourceGroupNameParam, resourceNameParam, nil) + newGetQuotaMetricsPager = &resp + r.newGetQuotaMetricsPager.add(req, newGetQuotaMetricsPager) + server.PagerResponderInjectNextLinks(newGetQuotaMetricsPager, req, func(page *armiothub.ResourceClientGetQuotaMetricsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newGetQuotaMetricsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newGetQuotaMetricsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newGetQuotaMetricsPager) { + r.newGetQuotaMetricsPager.remove(req) + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchGetStats(req *http.Request) (*http.Response, error) { + if r.srv.GetStats == nil { + return nil, &nonRetriableError{errors.New("fake for method GetStats not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/IotHubStats` + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.GetStats(req.Context(), resourceGroupNameParam, resourceNameParam, 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).RegistryStatistics, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchNewGetValidSKUsPager(req *http.Request) (*http.Response, error) { + if r.srv.NewGetValidSKUsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewGetValidSKUsPager not implemented")} + } + newGetValidSKUsPager := r.newGetValidSKUsPager.get(req) + if newGetValidSKUsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/skus` + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewGetValidSKUsPager(resourceGroupNameParam, resourceNameParam, nil) + newGetValidSKUsPager = &resp + r.newGetValidSKUsPager.add(req, newGetValidSKUsPager) + server.PagerResponderInjectNextLinks(newGetValidSKUsPager, req, func(page *armiothub.ResourceClientGetValidSKUsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newGetValidSKUsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newGetValidSKUsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newGetValidSKUsPager) { + r.newGetValidSKUsPager.remove(req) + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchImportDevices(req *http.Request) (*http.Response, error) { + if r.srv.ImportDevices == nil { + return nil, &nonRetriableError{errors.New("fake for method ImportDevices not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/importDevices` + 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[armiothub.ImportDevicesRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.ImportDevices(req.Context(), resourceGroupNameParam, resourceNameParam, 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).JobResponse, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := r.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs` + 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 := r.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + r.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armiothub.ResourceClientListByResourceGroupResponse, 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) { + r.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + r.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := r.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs` + 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 := r.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + r.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armiothub.ResourceClientListBySubscriptionResponse, 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) { + r.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + r.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchNewListEventHubConsumerGroupsPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListEventHubConsumerGroupsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListEventHubConsumerGroupsPager not implemented")} + } + newListEventHubConsumerGroupsPager := r.newListEventHubConsumerGroupsPager.get(req) + if newListEventHubConsumerGroupsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/eventHubEndpoints/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/ConsumerGroups` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + eventHubEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("eventHubEndpointName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListEventHubConsumerGroupsPager(resourceGroupNameParam, resourceNameParam, eventHubEndpointNameParam, nil) + newListEventHubConsumerGroupsPager = &resp + r.newListEventHubConsumerGroupsPager.add(req, newListEventHubConsumerGroupsPager) + server.PagerResponderInjectNextLinks(newListEventHubConsumerGroupsPager, req, func(page *armiothub.ResourceClientListEventHubConsumerGroupsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListEventHubConsumerGroupsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListEventHubConsumerGroupsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListEventHubConsumerGroupsPager) { + r.newListEventHubConsumerGroupsPager.remove(req) + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchNewListJobsPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListJobsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListJobsPager not implemented")} + } + newListJobsPager := r.newListJobsPager.get(req) + if newListJobsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/jobs` + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListJobsPager(resourceGroupNameParam, resourceNameParam, nil) + newListJobsPager = &resp + r.newListJobsPager.add(req, newListJobsPager) + server.PagerResponderInjectNextLinks(newListJobsPager, req, func(page *armiothub.ResourceClientListJobsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListJobsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListJobsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListJobsPager) { + r.newListJobsPager.remove(req) + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchNewListKeysPager(req *http.Request) (*http.Response, error) { + if r.srv.NewListKeysPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListKeysPager not implemented")} + } + newListKeysPager := r.newListKeysPager.get(req) + if newListKeysPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listkeys` + 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 + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + resp := r.srv.NewListKeysPager(resourceGroupNameParam, resourceNameParam, nil) + newListKeysPager = &resp + r.newListKeysPager.add(req, newListKeysPager) + server.PagerResponderInjectNextLinks(newListKeysPager, req, func(page *armiothub.ResourceClientListKeysResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListKeysPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.newListKeysPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListKeysPager) { + r.newListKeysPager.remove(req) + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchTestAllRoutes(req *http.Request) (*http.Response, error) { + if r.srv.TestAllRoutes == nil { + return nil, &nonRetriableError{errors.New("fake for method TestAllRoutes not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/routing/routes/\$testall` + 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[armiothub.TestAllRoutesInput](req) + if err != nil { + return nil, err + } + iotHubNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("iotHubName")]) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.TestAllRoutes(req.Context(), iotHubNameParam, resourceGroupNameParam, 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).TestAllRoutesResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchTestRoute(req *http.Request) (*http.Response, error) { + if r.srv.TestRoute == nil { + return nil, &nonRetriableError{errors.New("fake for method TestRoute not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/routing/routes/\$testnew` + 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[armiothub.TestRouteInput](req) + if err != nil { + return nil, err + } + iotHubNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("iotHubName")]) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.TestRoute(req.Context(), iotHubNameParam, resourceGroupNameParam, 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).TestRouteResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (r *ResourceServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if r.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := r.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?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[armiothub.TagsResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := r.srv.BeginUpdate(req.Context(), resourceGroupNameParam, resourceNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + r.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK}, resp.StatusCode) { + r.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + r.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/iothub/armiothub/fake/resourceprovidercommon_server.go b/sdk/resourcemanager/iothub/armiothub/fake/resourceprovidercommon_server.go new file mode 100644 index 000000000000..0da022710494 --- /dev/null +++ b/sdk/resourcemanager/iothub/armiothub/fake/resourceprovidercommon_server.go @@ -0,0 +1,91 @@ +//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/resourcemanager/iothub/armiothub" + "net/http" + "regexp" +) + +// ResourceProviderCommonServer is a fake server for instances of the armiothub.ResourceProviderCommonClient type. +type ResourceProviderCommonServer struct { + // GetSubscriptionQuota is the fake for method ResourceProviderCommonClient.GetSubscriptionQuota + // HTTP status codes to indicate success: http.StatusOK + GetSubscriptionQuota func(ctx context.Context, options *armiothub.ResourceProviderCommonClientGetSubscriptionQuotaOptions) (resp azfake.Responder[armiothub.ResourceProviderCommonClientGetSubscriptionQuotaResponse], errResp azfake.ErrorResponder) +} + +// NewResourceProviderCommonServerTransport creates a new instance of ResourceProviderCommonServerTransport with the provided implementation. +// The returned ResourceProviderCommonServerTransport instance is connected to an instance of armiothub.ResourceProviderCommonClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewResourceProviderCommonServerTransport(srv *ResourceProviderCommonServer) *ResourceProviderCommonServerTransport { + return &ResourceProviderCommonServerTransport{srv: srv} +} + +// ResourceProviderCommonServerTransport connects instances of armiothub.ResourceProviderCommonClient to instances of ResourceProviderCommonServer. +// Don't use this type directly, use NewResourceProviderCommonServerTransport instead. +type ResourceProviderCommonServerTransport struct { + srv *ResourceProviderCommonServer +} + +// Do implements the policy.Transporter interface for ResourceProviderCommonServerTransport. +func (r *ResourceProviderCommonServerTransport) 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 "ResourceProviderCommonClient.GetSubscriptionQuota": + resp, err = r.dispatchGetSubscriptionQuota(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (r *ResourceProviderCommonServerTransport) dispatchGetSubscriptionQuota(req *http.Request) (*http.Response, error) { + if r.srv.GetSubscriptionQuota == nil { + return nil, &nonRetriableError{errors.New("fake for method GetSubscriptionQuota not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/usages` + 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) + } + respr, errRespr := r.srv.GetSubscriptionQuota(req.Context(), 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).UserSubscriptionQuotaListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/iothub/armiothub/fake/server.go b/sdk/resourcemanager/iothub/armiothub/fake/server.go new file mode 100644 index 000000000000..ca779bafd3ba --- /dev/null +++ b/sdk/resourcemanager/iothub/armiothub/fake/server.go @@ -0,0 +1,119 @@ +//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/resourcemanager/iothub/armiothub" + "net/http" + "net/url" + "regexp" +) + +// Server is a fake server for instances of the armiothub.Client type. +type Server struct { + // BeginManualFailover is the fake for method Client.BeginManualFailover + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginManualFailover func(ctx context.Context, iotHubName string, resourceGroupName string, failoverInput armiothub.FailoverInput, options *armiothub.ClientBeginManualFailoverOptions) (resp azfake.PollerResponder[armiothub.ClientManualFailoverResponse], errResp azfake.ErrorResponder) +} + +// NewServerTransport creates a new instance of ServerTransport with the provided implementation. +// The returned ServerTransport instance is connected to an instance of armiothub.Client via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewServerTransport(srv *Server) *ServerTransport { + return &ServerTransport{ + srv: srv, + beginManualFailover: newTracker[azfake.PollerResponder[armiothub.ClientManualFailoverResponse]](), + } +} + +// ServerTransport connects instances of armiothub.Client to instances of Server. +// Don't use this type directly, use NewServerTransport instead. +type ServerTransport struct { + srv *Server + beginManualFailover *tracker[azfake.PollerResponder[armiothub.ClientManualFailoverResponse]] +} + +// Do implements the policy.Transporter interface for ServerTransport. +func (s *ServerTransport) 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 "Client.BeginManualFailover": + resp, err = s.dispatchBeginManualFailover(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *ServerTransport) dispatchBeginManualFailover(req *http.Request) (*http.Response, error) { + if s.srv.BeginManualFailover == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginManualFailover not implemented")} + } + beginManualFailover := s.beginManualFailover.get(req) + if beginManualFailover == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Devices/IotHubs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/failover` + 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[armiothub.FailoverInput](req) + if err != nil { + return nil, err + } + iotHubNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("iotHubName")]) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginManualFailover(req.Context(), iotHubNameParam, resourceGroupNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginManualFailover = &respr + s.beginManualFailover.add(req, beginManualFailover) + } + + resp, err := server.PollerResponderNext(beginManualFailover, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + s.beginManualFailover.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginManualFailover) { + s.beginManualFailover.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/iothub/armiothub/fake/server_factory.go b/sdk/resourcemanager/iothub/armiothub/fake/server_factory.go new file mode 100644 index 000000000000..1001cf48eee7 --- /dev/null +++ b/sdk/resourcemanager/iothub/armiothub/fake/server_factory.go @@ -0,0 +1,111 @@ +//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 ( + "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 armiothub.ClientFactory type. +type ServerFactory struct { + CertificatesServer CertificatesServer + Server Server + OperationsServer OperationsServer + PrivateEndpointConnectionsServer PrivateEndpointConnectionsServer + PrivateLinkResourcesServer PrivateLinkResourcesServer + ResourceServer ResourceServer + ResourceProviderCommonServer ResourceProviderCommonServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armiothub.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 armiothub.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trCertificatesServer *CertificatesServerTransport + trServer *ServerTransport + trOperationsServer *OperationsServerTransport + trPrivateEndpointConnectionsServer *PrivateEndpointConnectionsServerTransport + trPrivateLinkResourcesServer *PrivateLinkResourcesServerTransport + trResourceServer *ResourceServerTransport + trResourceProviderCommonServer *ResourceProviderCommonServerTransport +} + +// 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 "CertificatesClient": + initServer(s, &s.trCertificatesServer, func() *CertificatesServerTransport { return NewCertificatesServerTransport(&s.srv.CertificatesServer) }) + resp, err = s.trCertificatesServer.Do(req) + case "Client": + initServer(s, &s.trServer, func() *ServerTransport { return NewServerTransport(&s.srv.Server) }) + resp, err = s.trServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "PrivateEndpointConnectionsClient": + initServer(s, &s.trPrivateEndpointConnectionsServer, func() *PrivateEndpointConnectionsServerTransport { + return NewPrivateEndpointConnectionsServerTransport(&s.srv.PrivateEndpointConnectionsServer) + }) + resp, err = s.trPrivateEndpointConnectionsServer.Do(req) + case "PrivateLinkResourcesClient": + initServer(s, &s.trPrivateLinkResourcesServer, func() *PrivateLinkResourcesServerTransport { + return NewPrivateLinkResourcesServerTransport(&s.srv.PrivateLinkResourcesServer) + }) + resp, err = s.trPrivateLinkResourcesServer.Do(req) + case "ResourceClient": + initServer(s, &s.trResourceServer, func() *ResourceServerTransport { return NewResourceServerTransport(&s.srv.ResourceServer) }) + resp, err = s.trResourceServer.Do(req) + case "ResourceProviderCommonClient": + initServer(s, &s.trResourceProviderCommonServer, func() *ResourceProviderCommonServerTransport { + return NewResourceProviderCommonServerTransport(&s.srv.ResourceProviderCommonServer) + }) + resp, err = s.trResourceProviderCommonServer.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/iothub/armiothub/fake/time_rfc1123.go b/sdk/resourcemanager/iothub/armiothub/fake/time_rfc1123.go new file mode 100644 index 000000000000..61cb0a0e089f --- /dev/null +++ b/sdk/resourcemanager/iothub/armiothub/fake/time_rfc1123.go @@ -0,0 +1,70 @@ +//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 ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "strings" + "time" +) + +const ( + dateTimeRFC1123JSON = `"` + time.RFC1123 + `"` +) + +type dateTimeRFC1123 time.Time + +func (t dateTimeRFC1123) MarshalJSON() ([]byte, error) { + b := []byte(time.Time(t).Format(dateTimeRFC1123JSON)) + return b, nil +} + +func (t dateTimeRFC1123) MarshalText() ([]byte, error) { + b := []byte(time.Time(t).Format(time.RFC1123)) + return b, nil +} + +func (t *dateTimeRFC1123) UnmarshalJSON(data []byte) error { + p, err := time.Parse(dateTimeRFC1123JSON, strings.ToUpper(string(data))) + *t = dateTimeRFC1123(p) + return err +} + +func (t *dateTimeRFC1123) UnmarshalText(data []byte) error { + p, err := time.Parse(time.RFC1123, string(data)) + *t = dateTimeRFC1123(p) + return err +} + +func populateDateTimeRFC1123(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] = (*dateTimeRFC1123)(t) +} + +func unpopulateDateTimeRFC1123(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux dateTimeRFC1123 + 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/iothub/armiothub/fake/time_rfc3339.go b/sdk/resourcemanager/iothub/armiothub/fake/time_rfc3339.go new file mode 100644 index 000000000000..b0535a7b63e6 --- /dev/null +++ b/sdk/resourcemanager/iothub/armiothub/fake/time_rfc3339.go @@ -0,0 +1,86 @@ +//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 ( + "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 ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +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 { + layout := utcDateTimeJSON + if tzOffsetRegex.Match(data) { + layout = dateTimeJSON + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + 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 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 || strings.EqualFold(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/iothub/armiothub/go.mod b/sdk/resourcemanager/iothub/armiothub/go.mod index 820c6fff8797..1b252e51e26e 100644 --- a/sdk/resourcemanager/iothub/armiothub/go.mod +++ b/sdk/resourcemanager/iothub/armiothub/go.mod @@ -3,27 +3,27 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/iothub/armiothub go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 - github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 - github.com/stretchr/testify v1.7.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 + github.com/stretchr/testify v1.8.4 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dnaeon/go-vcr v1.1.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/dnaeon/go-vcr v1.2.0 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 // indirect + github.com/google/uuid v1.3.1 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/crypto v0.6.0 // indirect - golang.org/x/net v0.8.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/text v0.8.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/sdk/resourcemanager/iothub/armiothub/go.sum b/sdk/resourcemanager/iothub/armiothub/go.sum index 93fdfc2850cd..88bb72abf2ba 100644 --- a/sdk/resourcemanager/iothub/armiothub/go.sum +++ b/sdk/resourcemanager/iothub/armiothub/go.sum @@ -1,24 +1,25 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 h1:mLY+pNLjCUeKhgnAJWAKhEUQM+RJQo2H1fuGSw1Ky1E= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2/go.mod h1:FbdwsQ2EzwvXxOPcMFYO8ogEc9uMMIj3YkmCdXdAFmk= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 h1:ECsQtyERDVz3NP3kvDOTLvbQhqWp/x9EsGKtb4ogUr8= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0/go.mod h1:s1tW/At+xHqjNFvWU4G0c0Qv33KOhvbGNj0RCTQDV8s= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 h1:PTFGRSlMKCQelWwxUyYVEUqseBJVemLyqWJjvMyt0do= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0/go.mod h1:LRr2FzBTQlONPPa5HREE5+RjSCTXl7BwOvYOaWTqCaI= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups v1.0.0 h1:pPvTJ1dY0sA35JOeFq6TsY2xj6Z85Yo23Pj4wCCvu4o= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 h1:7CBQ+Ei8SP2c6ydQTGCCrS35bDxgTMfoP2miAwK++OU= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1/go.mod h1:c/wcGeGx5FUPbM/JltUYHZcKmigwyVLJlDq+4HdtXaw= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= +github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= +github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= +github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= @@ -26,23 +27,21 @@ github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9 github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +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/iothub/armiothub/iothub_live_test.go b/sdk/resourcemanager/iothub/armiothub/iothub_live_test.go index 5776b3847542..493c8ae39979 100644 --- a/sdk/resourcemanager/iothub/armiothub/iothub_live_test.go +++ b/sdk/resourcemanager/iothub/armiothub/iothub_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "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/testutil" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2/testutil" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/iothub/armiothub" "github.com/stretchr/testify/suite" ) @@ -41,9 +41,9 @@ func (testsuite *IothubTestSuite) SetupSuite() { testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T()) testsuite.certificateName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "certific", 14, false) testsuite.resourceName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "resource", 14, false) - testsuite.location = testutil.GetEnv("LOCATION", "westus") - testsuite.resourceGroupName = testutil.GetEnv("RESOURCE_GROUP_NAME", "scenarioTestTempGroup") - testsuite.subscriptionId = testutil.GetEnv("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + testsuite.location = recording.GetEnvVariable("LOCATION", "westus") + testsuite.resourceGroupName = recording.GetEnvVariable("RESOURCE_GROUP_NAME", "scenarioTestTempGroup") + testsuite.subscriptionId = recording.GetEnvVariable("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") resourceGroup, _, err := testutil.CreateResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.location) testsuite.Require().NoError(err) testsuite.resourceGroupName = *resourceGroup.Name diff --git a/sdk/resourcemanager/iothub/armiothub/models_serde.go b/sdk/resourcemanager/iothub/armiothub/models_serde.go index 89f857c46b16..8a86a24ae9a1 100644 --- a/sdk/resourcemanager/iothub/armiothub/models_serde.go +++ b/sdk/resourcemanager/iothub/armiothub/models_serde.go @@ -229,12 +229,12 @@ func (c *CertificateListDescription) UnmarshalJSON(data []byte) error { func (c CertificateProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "certificate", c.Certificate) - populateTimeRFC1123(objectMap, "created", c.Created) - populateTimeRFC1123(objectMap, "expiry", c.Expiry) + populateDateTimeRFC1123(objectMap, "created", c.Created) + populateDateTimeRFC1123(objectMap, "expiry", c.Expiry) populate(objectMap, "isVerified", c.IsVerified) populate(objectMap, "subject", c.Subject) populate(objectMap, "thumbprint", c.Thumbprint) - populateTimeRFC1123(objectMap, "updated", c.Updated) + populateDateTimeRFC1123(objectMap, "updated", c.Updated) return json.Marshal(objectMap) } @@ -251,10 +251,10 @@ func (c *CertificateProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Certificate", &c.Certificate) delete(rawMsg, key) case "created": - err = unpopulateTimeRFC1123(val, "Created", &c.Created) + err = unpopulateDateTimeRFC1123(val, "Created", &c.Created) delete(rawMsg, key) case "expiry": - err = unpopulateTimeRFC1123(val, "Expiry", &c.Expiry) + err = unpopulateDateTimeRFC1123(val, "Expiry", &c.Expiry) delete(rawMsg, key) case "isVerified": err = unpopulate(val, "IsVerified", &c.IsVerified) @@ -266,7 +266,7 @@ func (c *CertificateProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Thumbprint", &c.Thumbprint) delete(rawMsg, key) case "updated": - err = unpopulateTimeRFC1123(val, "Updated", &c.Updated) + err = unpopulateDateTimeRFC1123(val, "Updated", &c.Updated) delete(rawMsg, key) } if err != nil { @@ -280,12 +280,12 @@ func (c *CertificateProperties) UnmarshalJSON(data []byte) error { func (c CertificatePropertiesWithNonce) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "certificate", c.Certificate) - populateTimeRFC1123(objectMap, "created", c.Created) - populateTimeRFC1123(objectMap, "expiry", c.Expiry) + populateDateTimeRFC1123(objectMap, "created", c.Created) + populateDateTimeRFC1123(objectMap, "expiry", c.Expiry) populate(objectMap, "isVerified", c.IsVerified) populate(objectMap, "subject", c.Subject) populate(objectMap, "thumbprint", c.Thumbprint) - populateTimeRFC1123(objectMap, "updated", c.Updated) + populateDateTimeRFC1123(objectMap, "updated", c.Updated) populate(objectMap, "verificationCode", c.VerificationCode) return json.Marshal(objectMap) } @@ -303,10 +303,10 @@ func (c *CertificatePropertiesWithNonce) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Certificate", &c.Certificate) delete(rawMsg, key) case "created": - err = unpopulateTimeRFC1123(val, "Created", &c.Created) + err = unpopulateDateTimeRFC1123(val, "Created", &c.Created) delete(rawMsg, key) case "expiry": - err = unpopulateTimeRFC1123(val, "Expiry", &c.Expiry) + err = unpopulateDateTimeRFC1123(val, "Expiry", &c.Expiry) delete(rawMsg, key) case "isVerified": err = unpopulate(val, "IsVerified", &c.IsVerified) @@ -318,7 +318,7 @@ func (c *CertificatePropertiesWithNonce) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Thumbprint", &c.Thumbprint) delete(rawMsg, key) case "updated": - err = unpopulateTimeRFC1123(val, "Updated", &c.Updated) + err = unpopulateDateTimeRFC1123(val, "Updated", &c.Updated) delete(rawMsg, key) case "verificationCode": err = unpopulate(val, "VerificationCode", &c.VerificationCode) @@ -536,9 +536,9 @@ func (e EndpointHealthData) MarshalJSON() ([]byte, error) { populate(objectMap, "endpointId", e.EndpointID) populate(objectMap, "healthStatus", e.HealthStatus) populate(objectMap, "lastKnownError", e.LastKnownError) - populateTimeRFC1123(objectMap, "lastKnownErrorTime", e.LastKnownErrorTime) - populateTimeRFC1123(objectMap, "lastSendAttemptTime", e.LastSendAttemptTime) - populateTimeRFC1123(objectMap, "lastSuccessfulSendAttemptTime", e.LastSuccessfulSendAttemptTime) + populateDateTimeRFC1123(objectMap, "lastKnownErrorTime", e.LastKnownErrorTime) + populateDateTimeRFC1123(objectMap, "lastSendAttemptTime", e.LastSendAttemptTime) + populateDateTimeRFC1123(objectMap, "lastSuccessfulSendAttemptTime", e.LastSuccessfulSendAttemptTime) return json.Marshal(objectMap) } @@ -561,13 +561,13 @@ func (e *EndpointHealthData) UnmarshalJSON(data []byte) error { err = unpopulate(val, "LastKnownError", &e.LastKnownError) delete(rawMsg, key) case "lastKnownErrorTime": - err = unpopulateTimeRFC1123(val, "LastKnownErrorTime", &e.LastKnownErrorTime) + err = unpopulateDateTimeRFC1123(val, "LastKnownErrorTime", &e.LastKnownErrorTime) delete(rawMsg, key) case "lastSendAttemptTime": - err = unpopulateTimeRFC1123(val, "LastSendAttemptTime", &e.LastSendAttemptTime) + err = unpopulateDateTimeRFC1123(val, "LastSendAttemptTime", &e.LastSendAttemptTime) delete(rawMsg, key) case "lastSuccessfulSendAttemptTime": - err = unpopulateTimeRFC1123(val, "LastSuccessfulSendAttemptTime", &e.LastSuccessfulSendAttemptTime) + err = unpopulateDateTimeRFC1123(val, "LastSuccessfulSendAttemptTime", &e.LastSuccessfulSendAttemptTime) delete(rawMsg, key) } if err != nil { @@ -1176,11 +1176,11 @@ func (i *ImportDevicesRequest) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type JobResponse. func (j JobResponse) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC1123(objectMap, "endTimeUtc", j.EndTimeUTC) + populateDateTimeRFC1123(objectMap, "endTimeUtc", j.EndTimeUTC) populate(objectMap, "failureReason", j.FailureReason) populate(objectMap, "jobId", j.JobID) populate(objectMap, "parentJobId", j.ParentJobID) - populateTimeRFC1123(objectMap, "startTimeUtc", j.StartTimeUTC) + populateDateTimeRFC1123(objectMap, "startTimeUtc", j.StartTimeUTC) populate(objectMap, "status", j.Status) populate(objectMap, "statusMessage", j.StatusMessage) populate(objectMap, "type", j.Type) @@ -1197,7 +1197,7 @@ func (j *JobResponse) UnmarshalJSON(data []byte) error { var err error switch key { case "endTimeUtc": - err = unpopulateTimeRFC1123(val, "EndTimeUTC", &j.EndTimeUTC) + err = unpopulateDateTimeRFC1123(val, "EndTimeUTC", &j.EndTimeUTC) delete(rawMsg, key) case "failureReason": err = unpopulate(val, "FailureReason", &j.FailureReason) @@ -1209,7 +1209,7 @@ func (j *JobResponse) UnmarshalJSON(data []byte) error { err = unpopulate(val, "ParentJobID", &j.ParentJobID) delete(rawMsg, key) case "startTimeUtc": - err = unpopulateTimeRFC1123(val, "StartTimeUTC", &j.StartTimeUTC) + err = unpopulateDateTimeRFC1123(val, "StartTimeUTC", &j.StartTimeUTC) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &j.Status) @@ -2928,10 +2928,10 @@ func (s *StorageEndpointProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) populate(objectMap, "lastModifiedBy", s.LastModifiedBy) populate(objectMap, "lastModifiedByType", s.LastModifiedByType) return json.Marshal(objectMap) @@ -2947,7 +2947,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { var err error switch key { case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) delete(rawMsg, key) case "createdBy": err = unpopulate(val, "CreatedBy", &s.CreatedBy) @@ -2956,7 +2956,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { err = unpopulate(val, "CreatedByType", &s.CreatedByType) delete(rawMsg, key) case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) delete(rawMsg, key) case "lastModifiedBy": err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) diff --git a/sdk/resourcemanager/iothub/armiothub/operations_client.go b/sdk/resourcemanager/iothub/armiothub/operations_client.go index 65b96c3df0c5..2fd004a642a3 100644 --- a/sdk/resourcemanager/iothub/armiothub/operations_client.go +++ b/sdk/resourcemanager/iothub/armiothub/operations_client.go @@ -27,7 +27,7 @@ type OperationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,25 +47,20 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.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, options) + }, nil) if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return OperationsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OperationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/iothub/armiothub/privateendpointconnections_client.go b/sdk/resourcemanager/iothub/armiothub/privateendpointconnections_client.go index 6258f0ca4d61..6521efdbebb2 100644 --- a/sdk/resourcemanager/iothub/armiothub/privateendpointconnections_client.go +++ b/sdk/resourcemanager/iothub/armiothub/privateendpointconnections_client.go @@ -32,7 +32,7 @@ type PrivateEndpointConnectionsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateEndpointConnectionsClient, error) { - cl, err := arm.NewClient(moduleName+".PrivateEndpointConnectionsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -58,10 +58,14 @@ func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, if err != nil { return nil, err } - poller, err := runtime.NewPoller[PrivateEndpointConnectionsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateEndpointConnectionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PrivateEndpointConnectionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -71,6 +75,10 @@ func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, // Generated from API version 2023-06-30 func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "PrivateEndpointConnectionsClient.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, resourceName, privateEndpointConnectionName, options) if err != nil { return nil, err @@ -127,6 +135,10 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. // method. func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientGetOptions) (PrivateEndpointConnectionsClientGetResponse, error) { var err error + const operationName = "PrivateEndpointConnectionsClient.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, resourceName, privateEndpointConnectionName, options) if err != nil { return PrivateEndpointConnectionsClientGetResponse{}, err @@ -192,6 +204,10 @@ func (client *PrivateEndpointConnectionsClient) getHandleResponse(resp *http.Res // method. func (client *PrivateEndpointConnectionsClient) List(ctx context.Context, resourceGroupName string, resourceName string, options *PrivateEndpointConnectionsClientListOptions) (PrivateEndpointConnectionsClientListResponse, error) { var err error + const operationName = "PrivateEndpointConnectionsClient.List" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listCreateRequest(ctx, resourceGroupName, resourceName, options) if err != nil { return PrivateEndpointConnectionsClientListResponse{}, err @@ -259,10 +275,14 @@ func (client *PrivateEndpointConnectionsClient) BeginUpdate(ctx context.Context, if err != nil { return nil, err } - poller, err := runtime.NewPoller[PrivateEndpointConnectionsClientUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateEndpointConnectionsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PrivateEndpointConnectionsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -272,6 +292,10 @@ func (client *PrivateEndpointConnectionsClient) BeginUpdate(ctx context.Context, // Generated from API version 2023-06-30 func (client *PrivateEndpointConnectionsClient) update(ctx context.Context, resourceGroupName string, resourceName string, privateEndpointConnectionName string, privateEndpointConnection PrivateEndpointConnection, options *PrivateEndpointConnectionsClientBeginUpdateOptions) (*http.Response, error) { var err error + const operationName = "PrivateEndpointConnectionsClient.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, resourceName, privateEndpointConnectionName, privateEndpointConnection, options) if err != nil { return nil, err diff --git a/sdk/resourcemanager/iothub/armiothub/privatelinkresources_client.go b/sdk/resourcemanager/iothub/armiothub/privatelinkresources_client.go index d3aebd02b142..499ba35b69ad 100644 --- a/sdk/resourcemanager/iothub/armiothub/privatelinkresources_client.go +++ b/sdk/resourcemanager/iothub/armiothub/privatelinkresources_client.go @@ -32,7 +32,7 @@ type PrivateLinkResourcesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateLinkResourcesClient, error) { - cl, err := arm.NewClient(moduleName+".PrivateLinkResourcesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,6 +54,10 @@ func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.Toke // method. func (client *PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, resourceName string, groupID string, options *PrivateLinkResourcesClientGetOptions) (PrivateLinkResourcesClientGetResponse, error) { var err error + const operationName = "PrivateLinkResourcesClient.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, resourceName, groupID, options) if err != nil { return PrivateLinkResourcesClientGetResponse{}, err @@ -119,6 +123,10 @@ func (client *PrivateLinkResourcesClient) getHandleResponse(resp *http.Response) // method. func (client *PrivateLinkResourcesClient) List(ctx context.Context, resourceGroupName string, resourceName string, options *PrivateLinkResourcesClientListOptions) (PrivateLinkResourcesClientListResponse, error) { var err error + const operationName = "PrivateLinkResourcesClient.List" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listCreateRequest(ctx, resourceGroupName, resourceName, options) if err != nil { return PrivateLinkResourcesClientListResponse{}, err diff --git a/sdk/resourcemanager/iothub/armiothub/resource_client.go b/sdk/resourcemanager/iothub/armiothub/resource_client.go index 6cebfb375263..be7f4062a7c6 100644 --- a/sdk/resourcemanager/iothub/armiothub/resource_client.go +++ b/sdk/resourcemanager/iothub/armiothub/resource_client.go @@ -32,7 +32,7 @@ type ResourceClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewResourceClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ResourceClient, error) { - cl, err := arm.NewClient(moduleName+".ResourceClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -52,6 +52,10 @@ func NewResourceClient(subscriptionID string, credential azcore.TokenCredential, // method. func (client *ResourceClient) CheckNameAvailability(ctx context.Context, operationInputs OperationInputs, options *ResourceClientCheckNameAvailabilityOptions) (ResourceClientCheckNameAvailabilityResponse, error) { var err error + const operationName = "ResourceClient.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, operationInputs, options) if err != nil { return ResourceClientCheckNameAvailabilityResponse{}, err @@ -111,6 +115,10 @@ func (client *ResourceClient) checkNameAvailabilityHandleResponse(resp *http.Res // method. func (client *ResourceClient) CreateEventHubConsumerGroup(ctx context.Context, resourceGroupName string, resourceName string, eventHubEndpointName string, name string, consumerGroupBody EventHubConsumerGroupBodyDescription, options *ResourceClientCreateEventHubConsumerGroupOptions) (ResourceClientCreateEventHubConsumerGroupResponse, error) { var err error + const operationName = "ResourceClient.CreateEventHubConsumerGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createEventHubConsumerGroupCreateRequest(ctx, resourceGroupName, resourceName, eventHubEndpointName, name, consumerGroupBody, options) if err != nil { return ResourceClientCreateEventHubConsumerGroupResponse{}, err @@ -191,10 +199,14 @@ func (client *ResourceClient) BeginCreateOrUpdate(ctx context.Context, resourceG if err != nil { return nil, err } - poller, err := runtime.NewPoller[ResourceClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ResourceClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ResourceClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ResourceClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -207,6 +219,10 @@ func (client *ResourceClient) BeginCreateOrUpdate(ctx context.Context, resourceG // Generated from API version 2023-06-30 func (client *ResourceClient) createOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, iotHubDescription Description, options *ResourceClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error + const operationName = "ResourceClient.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, resourceName, iotHubDescription, options) if err != nil { return nil, err @@ -267,10 +283,14 @@ func (client *ResourceClient) BeginDelete(ctx context.Context, resourceGroupName if err != nil { return nil, err } - poller, err := runtime.NewPoller[ResourceClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ResourceClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ResourceClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ResourceClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -280,6 +300,10 @@ func (client *ResourceClient) BeginDelete(ctx context.Context, resourceGroupName // Generated from API version 2023-06-30 func (client *ResourceClient) deleteOperation(ctx context.Context, resourceGroupName string, resourceName string, options *ResourceClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "ResourceClient.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, resourceName, options) if err != nil { return nil, err @@ -333,6 +357,10 @@ func (client *ResourceClient) deleteCreateRequest(ctx context.Context, resourceG // method. func (client *ResourceClient) DeleteEventHubConsumerGroup(ctx context.Context, resourceGroupName string, resourceName string, eventHubEndpointName string, name string, options *ResourceClientDeleteEventHubConsumerGroupOptions) (ResourceClientDeleteEventHubConsumerGroupResponse, error) { var err error + const operationName = "ResourceClient.DeleteEventHubConsumerGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.deleteEventHubConsumerGroupCreateRequest(ctx, resourceGroupName, resourceName, eventHubEndpointName, name, options) if err != nil { return ResourceClientDeleteEventHubConsumerGroupResponse{}, err @@ -394,6 +422,10 @@ func (client *ResourceClient) deleteEventHubConsumerGroupCreateRequest(ctx conte // - options - ResourceClientExportDevicesOptions contains the optional parameters for the ResourceClient.ExportDevices method. func (client *ResourceClient) ExportDevices(ctx context.Context, resourceGroupName string, resourceName string, exportDevicesParameters ExportDevicesRequest, options *ResourceClientExportDevicesOptions) (ResourceClientExportDevicesResponse, error) { var err error + const operationName = "ResourceClient.ExportDevices" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.exportDevicesCreateRequest(ctx, resourceGroupName, resourceName, exportDevicesParameters, options) if err != nil { return ResourceClientExportDevicesResponse{}, err @@ -457,6 +489,10 @@ func (client *ResourceClient) exportDevicesHandleResponse(resp *http.Response) ( // - options - ResourceClientGetOptions contains the optional parameters for the ResourceClient.Get method. func (client *ResourceClient) Get(ctx context.Context, resourceGroupName string, resourceName string, options *ResourceClientGetOptions) (ResourceClientGetResponse, error) { var err error + const operationName = "ResourceClient.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, resourceName, options) if err != nil { return ResourceClientGetResponse{}, err @@ -519,25 +555,20 @@ func (client *ResourceClient) NewGetEndpointHealthPager(resourceGroupName string return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ResourceClientGetEndpointHealthResponse) (ResourceClientGetEndpointHealthResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.getEndpointHealthCreateRequest(ctx, resourceGroupName, iotHubName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ResourceClient.NewGetEndpointHealthPager") + 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.getEndpointHealthCreateRequest(ctx, resourceGroupName, iotHubName, options) + }, nil) if err != nil { return ResourceClientGetEndpointHealthResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ResourceClientGetEndpointHealthResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceClientGetEndpointHealthResponse{}, runtime.NewResponseError(resp) - } return client.getEndpointHealthHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -588,6 +619,10 @@ func (client *ResourceClient) getEndpointHealthHandleResponse(resp *http.Respons // method. func (client *ResourceClient) GetEventHubConsumerGroup(ctx context.Context, resourceGroupName string, resourceName string, eventHubEndpointName string, name string, options *ResourceClientGetEventHubConsumerGroupOptions) (ResourceClientGetEventHubConsumerGroupResponse, error) { var err error + const operationName = "ResourceClient.GetEventHubConsumerGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getEventHubConsumerGroupCreateRequest(ctx, resourceGroupName, resourceName, eventHubEndpointName, name, options) if err != nil { return ResourceClientGetEventHubConsumerGroupResponse{}, err @@ -657,6 +692,10 @@ func (client *ResourceClient) getEventHubConsumerGroupHandleResponse(resp *http. // - options - ResourceClientGetJobOptions contains the optional parameters for the ResourceClient.GetJob method. func (client *ResourceClient) GetJob(ctx context.Context, resourceGroupName string, resourceName string, jobID string, options *ResourceClientGetJobOptions) (ResourceClientGetJobResponse, error) { var err error + const operationName = "ResourceClient.GetJob" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getJobCreateRequest(ctx, resourceGroupName, resourceName, jobID, options) if err != nil { return ResourceClientGetJobResponse{}, err @@ -723,6 +762,10 @@ func (client *ResourceClient) getJobHandleResponse(resp *http.Response) (Resourc // method. func (client *ResourceClient) GetKeysForKeyName(ctx context.Context, resourceGroupName string, resourceName string, keyName string, options *ResourceClientGetKeysForKeyNameOptions) (ResourceClientGetKeysForKeyNameResponse, error) { var err error + const operationName = "ResourceClient.GetKeysForKeyName" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getKeysForKeyNameCreateRequest(ctx, resourceGroupName, resourceName, keyName, options) if err != nil { return ResourceClientGetKeysForKeyNameResponse{}, err @@ -791,25 +834,20 @@ func (client *ResourceClient) NewGetQuotaMetricsPager(resourceGroupName string, return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ResourceClientGetQuotaMetricsResponse) (ResourceClientGetQuotaMetricsResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.getQuotaMetricsCreateRequest(ctx, resourceGroupName, resourceName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ResourceClient.NewGetQuotaMetricsPager") + 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.getQuotaMetricsCreateRequest(ctx, resourceGroupName, resourceName, options) + }, nil) if err != nil { return ResourceClientGetQuotaMetricsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ResourceClientGetQuotaMetricsResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceClientGetQuotaMetricsResponse{}, runtime.NewResponseError(resp) - } return client.getQuotaMetricsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -857,6 +895,10 @@ func (client *ResourceClient) getQuotaMetricsHandleResponse(resp *http.Response) // - options - ResourceClientGetStatsOptions contains the optional parameters for the ResourceClient.GetStats method. func (client *ResourceClient) GetStats(ctx context.Context, resourceGroupName string, resourceName string, options *ResourceClientGetStatsOptions) (ResourceClientGetStatsResponse, error) { var err error + const operationName = "ResourceClient.GetStats" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getStatsCreateRequest(ctx, resourceGroupName, resourceName, options) if err != nil { return ResourceClientGetStatsResponse{}, err @@ -921,25 +963,20 @@ func (client *ResourceClient) NewGetValidSKUsPager(resourceGroupName string, res return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ResourceClientGetValidSKUsResponse) (ResourceClientGetValidSKUsResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.getValidSKUsCreateRequest(ctx, resourceGroupName, resourceName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ResourceClient.NewGetValidSKUsPager") + 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.getValidSKUsCreateRequest(ctx, resourceGroupName, resourceName, options) + }, nil) if err != nil { return ResourceClientGetValidSKUsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ResourceClientGetValidSKUsResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceClientGetValidSKUsResponse{}, runtime.NewResponseError(resp) - } return client.getValidSKUsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -990,6 +1027,10 @@ func (client *ResourceClient) getValidSKUsHandleResponse(resp *http.Response) (R // - options - ResourceClientImportDevicesOptions contains the optional parameters for the ResourceClient.ImportDevices method. func (client *ResourceClient) ImportDevices(ctx context.Context, resourceGroupName string, resourceName string, importDevicesParameters ImportDevicesRequest, options *ResourceClientImportDevicesOptions) (ResourceClientImportDevicesResponse, error) { var err error + const operationName = "ResourceClient.ImportDevices" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.importDevicesCreateRequest(ctx, resourceGroupName, resourceName, importDevicesParameters, options) if err != nil { return ResourceClientImportDevicesResponse{}, err @@ -1056,25 +1097,20 @@ func (client *ResourceClient) NewListByResourceGroupPager(resourceGroupName stri return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ResourceClientListByResourceGroupResponse) (ResourceClientListByResourceGroupResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ResourceClient.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 ResourceClientListByResourceGroupResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ResourceClientListByResourceGroupResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -1120,25 +1156,20 @@ func (client *ResourceClient) NewListBySubscriptionPager(options *ResourceClient return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ResourceClientListBySubscriptionResponse) (ResourceClientListBySubscriptionResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listBySubscriptionCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ResourceClient.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 ResourceClientListBySubscriptionResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ResourceClientListBySubscriptionResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) - } return client.listBySubscriptionHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -1184,25 +1215,20 @@ func (client *ResourceClient) NewListEventHubConsumerGroupsPager(resourceGroupNa return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ResourceClientListEventHubConsumerGroupsResponse) (ResourceClientListEventHubConsumerGroupsResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listEventHubConsumerGroupsCreateRequest(ctx, resourceGroupName, resourceName, eventHubEndpointName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ResourceClient.NewListEventHubConsumerGroupsPager") + 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.listEventHubConsumerGroupsCreateRequest(ctx, resourceGroupName, resourceName, eventHubEndpointName, options) + }, nil) if err != nil { return ResourceClientListEventHubConsumerGroupsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ResourceClientListEventHubConsumerGroupsResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceClientListEventHubConsumerGroupsResponse{}, runtime.NewResponseError(resp) - } return client.listEventHubConsumerGroupsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -1257,25 +1283,20 @@ func (client *ResourceClient) NewListJobsPager(resourceGroupName string, resourc return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ResourceClientListJobsResponse) (ResourceClientListJobsResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listJobsCreateRequest(ctx, resourceGroupName, resourceName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ResourceClient.NewListJobsPager") + 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.listJobsCreateRequest(ctx, resourceGroupName, resourceName, options) + }, nil) if err != nil { return ResourceClientListJobsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ResourceClientListJobsResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceClientListJobsResponse{}, runtime.NewResponseError(resp) - } return client.listJobsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -1326,25 +1347,20 @@ func (client *ResourceClient) NewListKeysPager(resourceGroupName string, resourc return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ResourceClientListKeysResponse) (ResourceClientListKeysResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listKeysCreateRequest(ctx, resourceGroupName, resourceName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ResourceClient.NewListKeysPager") + 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.listKeysCreateRequest(ctx, resourceGroupName, resourceName, options) + }, nil) if err != nil { return ResourceClientListKeysResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ResourceClientListKeysResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ResourceClientListKeysResponse{}, runtime.NewResponseError(resp) - } return client.listKeysHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -1393,6 +1409,10 @@ func (client *ResourceClient) listKeysHandleResponse(resp *http.Response) (Resou // - options - ResourceClientTestAllRoutesOptions contains the optional parameters for the ResourceClient.TestAllRoutes method. func (client *ResourceClient) TestAllRoutes(ctx context.Context, iotHubName string, resourceGroupName string, input TestAllRoutesInput, options *ResourceClientTestAllRoutesOptions) (ResourceClientTestAllRoutesResponse, error) { var err error + const operationName = "ResourceClient.TestAllRoutes" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.testAllRoutesCreateRequest(ctx, iotHubName, resourceGroupName, input, options) if err != nil { return ResourceClientTestAllRoutesResponse{}, err @@ -1457,6 +1477,10 @@ func (client *ResourceClient) testAllRoutesHandleResponse(resp *http.Response) ( // - options - ResourceClientTestRouteOptions contains the optional parameters for the ResourceClient.TestRoute method. func (client *ResourceClient) TestRoute(ctx context.Context, iotHubName string, resourceGroupName string, input TestRouteInput, options *ResourceClientTestRouteOptions) (ResourceClientTestRouteResponse, error) { var err error + const operationName = "ResourceClient.TestRoute" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.testRouteCreateRequest(ctx, iotHubName, resourceGroupName, input, options) if err != nil { return ResourceClientTestRouteResponse{}, err @@ -1525,10 +1549,14 @@ func (client *ResourceClient) BeginUpdate(ctx context.Context, resourceGroupName if err != nil { return nil, err } - poller, err := runtime.NewPoller[ResourceClientUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ResourceClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ResourceClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ResourceClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -1538,6 +1566,10 @@ func (client *ResourceClient) BeginUpdate(ctx context.Context, resourceGroupName // Generated from API version 2023-06-30 func (client *ResourceClient) update(ctx context.Context, resourceGroupName string, resourceName string, iotHubTags TagsResource, options *ResourceClientBeginUpdateOptions) (*http.Response, error) { var err error + const operationName = "ResourceClient.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, resourceName, iotHubTags, options) if err != nil { return nil, err diff --git a/sdk/resourcemanager/iothub/armiothub/resource_client_example_test.go b/sdk/resourcemanager/iothub/armiothub/resource_client_example_test.go index 36f0ffe44c53..09b93762f608 100644 --- a/sdk/resourcemanager/iothub/armiothub/resource_client_example_test.go +++ b/sdk/resourcemanager/iothub/armiothub/resource_client_example_test.go @@ -1360,9 +1360,9 @@ func ExampleResourceClient_NewListJobsPager() { // Value: []*armiothub.JobResponse{ // { // Type: to.Ptr(armiothub.JobTypeUnknown), - // EndTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 15 Jun 2017 19:20:58 GMT"); return t}()), + // EndTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2017-06-15T19:20:58.000Z"); return t}()), // JobID: to.Ptr("test"), - // StartTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 15 Jun 2017 19:20:58 GMT"); return t}()), + // StartTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2017-06-15T19:20:58.000Z"); return t}()), // Status: to.Ptr(armiothub.JobStatusUnknown), // }}, // } @@ -1389,9 +1389,9 @@ func ExampleResourceClient_GetJob() { // 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.JobResponse = armiothub.JobResponse{ // Type: to.Ptr(armiothub.JobTypeUnknown), - // EndTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 15 Jun 2017 19:20:58 GMT"); return t}()), + // EndTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2017-06-15T19:20:58.000Z"); return t}()), // JobID: to.Ptr("test"), - // StartTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 15 Jun 2017 19:20:58 GMT"); return t}()), + // StartTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2017-06-15T19:20:58.000Z"); return t}()), // Status: to.Ptr(armiothub.JobStatusUnknown), // } } @@ -1461,8 +1461,8 @@ func ExampleResourceClient_NewGetEndpointHealthPager() { // { // EndpointID: to.Ptr("id1"), // HealthStatus: to.Ptr(armiothub.EndpointHealthStatusHealthy), - // LastSendAttemptTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Wed, 13 Sep 2022 18:04:32 GMT"); return t}()), - // LastSuccessfulSendAttemptTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Wed, 13 Sep 2022 18:04:32 GMT"); return t}()), + // LastSendAttemptTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2022-09-13T18:04:32.000Z"); return t}()), + // LastSuccessfulSendAttemptTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2022-09-13T18:04:32.000Z"); return t}()), // }, // { // EndpointID: to.Ptr("id2"), @@ -1472,9 +1472,9 @@ func ExampleResourceClient_NewGetEndpointHealthPager() { // EndpointID: to.Ptr("id3"), // HealthStatus: to.Ptr(armiothub.EndpointHealthStatusUnhealthy), // LastKnownError: to.Ptr("NotFound"), - // LastKnownErrorTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Wed, 13 Sep 2022 18:04:32 GMT"); return t}()), - // LastSendAttemptTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Wed, 13 Sep 2022 18:04:32 GMT"); return t}()), - // LastSuccessfulSendAttemptTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Wed, 13 Sep 2022 18:04:32 GMT"); return t}()), + // LastKnownErrorTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2022-09-13T18:04:32.000Z"); return t}()), + // LastSendAttemptTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2022-09-13T18:04:32.000Z"); return t}()), + // LastSuccessfulSendAttemptTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2022-09-13T18:04:32.000Z"); return t}()), // }}, // } } @@ -1714,9 +1714,9 @@ func ExampleResourceClient_ExportDevices() { // 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.JobResponse = armiothub.JobResponse{ // Type: to.Ptr(armiothub.JobTypeUnknown), - // EndTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 15 Jun 2017 19:20:58 GMT"); return t}()), + // EndTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2017-06-15T19:20:58.000Z"); return t}()), // JobID: to.Ptr("test"), - // StartTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 15 Jun 2017 19:20:58 GMT"); return t}()), + // StartTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2017-06-15T19:20:58.000Z"); return t}()), // Status: to.Ptr(armiothub.JobStatusUnknown), // } } @@ -1744,9 +1744,9 @@ func ExampleResourceClient_ImportDevices() { // 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.JobResponse = armiothub.JobResponse{ // Type: to.Ptr(armiothub.JobTypeUnknown), - // EndTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 15 Jun 2017 19:20:58 GMT"); return t}()), + // EndTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2017-06-15T19:20:58.000Z"); return t}()), // JobID: to.Ptr("test"), - // StartTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "Thu, 15 Jun 2017 19:20:58 GMT"); return t}()), + // StartTimeUTC: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC1123, "2017-06-15T19:20:58.000Z"); return t}()), // Status: to.Ptr(armiothub.JobStatusUnknown), // } } diff --git a/sdk/resourcemanager/iothub/armiothub/resourceprovidercommon_client.go b/sdk/resourcemanager/iothub/armiothub/resourceprovidercommon_client.go index fa3fbacac22b..f17652c226cd 100644 --- a/sdk/resourcemanager/iothub/armiothub/resourceprovidercommon_client.go +++ b/sdk/resourcemanager/iothub/armiothub/resourceprovidercommon_client.go @@ -32,7 +32,7 @@ type ResourceProviderCommonClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewResourceProviderCommonClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ResourceProviderCommonClient, error) { - cl, err := arm.NewClient(moduleName+".ResourceProviderCommonClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -51,6 +51,10 @@ func NewResourceProviderCommonClient(subscriptionID string, credential azcore.To // method. func (client *ResourceProviderCommonClient) GetSubscriptionQuota(ctx context.Context, options *ResourceProviderCommonClientGetSubscriptionQuotaOptions) (ResourceProviderCommonClientGetSubscriptionQuotaResponse, error) { var err error + const operationName = "ResourceProviderCommonClient.GetSubscriptionQuota" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getSubscriptionQuotaCreateRequest(ctx, options) if err != nil { return ResourceProviderCommonClientGetSubscriptionQuotaResponse{}, err diff --git a/sdk/resourcemanager/iothub/armiothub/time_rfc1123.go b/sdk/resourcemanager/iothub/armiothub/time_rfc1123.go index c0a41f5d01e1..a6daa27bab4a 100644 --- a/sdk/resourcemanager/iothub/armiothub/time_rfc1123.go +++ b/sdk/resourcemanager/iothub/armiothub/time_rfc1123.go @@ -18,34 +18,34 @@ import ( ) const ( - rfc1123JSON = `"` + time.RFC1123 + `"` + dateTimeRFC1123JSON = `"` + time.RFC1123 + `"` ) -type timeRFC1123 time.Time +type dateTimeRFC1123 time.Time -func (t timeRFC1123) MarshalJSON() ([]byte, error) { - b := []byte(time.Time(t).Format(rfc1123JSON)) +func (t dateTimeRFC1123) MarshalJSON() ([]byte, error) { + b := []byte(time.Time(t).Format(dateTimeRFC1123JSON)) return b, nil } -func (t timeRFC1123) MarshalText() ([]byte, error) { +func (t dateTimeRFC1123) MarshalText() ([]byte, error) { b := []byte(time.Time(t).Format(time.RFC1123)) return b, nil } -func (t *timeRFC1123) UnmarshalJSON(data []byte) error { - p, err := time.Parse(rfc1123JSON, strings.ToUpper(string(data))) - *t = timeRFC1123(p) +func (t *dateTimeRFC1123) UnmarshalJSON(data []byte) error { + p, err := time.Parse(dateTimeRFC1123JSON, strings.ToUpper(string(data))) + *t = dateTimeRFC1123(p) return err } -func (t *timeRFC1123) UnmarshalText(data []byte) error { +func (t *dateTimeRFC1123) UnmarshalText(data []byte) error { p, err := time.Parse(time.RFC1123, string(data)) - *t = timeRFC1123(p) + *t = dateTimeRFC1123(p) return err } -func populateTimeRFC1123(m map[string]any, k string, t *time.Time) { +func populateDateTimeRFC1123(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { @@ -54,14 +54,14 @@ func populateTimeRFC1123(m map[string]any, k string, t *time.Time) { } else if reflect.ValueOf(t).IsNil() { return } - m[k] = (*timeRFC1123)(t) + m[k] = (*dateTimeRFC1123)(t) } -func unpopulateTimeRFC1123(data json.RawMessage, fn string, t **time.Time) error { +func unpopulateDateTimeRFC1123(data json.RawMessage, fn string, t **time.Time) error { if data == nil || strings.EqualFold(string(data), "null") { return nil } - var aux timeRFC1123 + var aux dateTimeRFC1123 if err := json.Unmarshal(data, &aux); err != nil { return fmt.Errorf("struct field %s: %v", fn, err) } diff --git a/sdk/resourcemanager/iothub/armiothub/time_rfc3339.go b/sdk/resourcemanager/iothub/armiothub/time_rfc3339.go index 1948acce7eb6..a13b5d86449e 100644 --- a/sdk/resourcemanager/iothub/armiothub/time_rfc3339.go +++ b/sdk/resourcemanager/iothub/armiothub/time_rfc3339.go @@ -18,50 +18,50 @@ import ( "time" ) -const ( - utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` - utcLayout = "2006-01-02T15:04:05.999999999" - rfc3339JSON = `"` + time.RFC3339Nano + `"` -) - // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) -type timeRFC3339 time.Time +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time -func (t timeRFC3339) MarshalJSON() (json []byte, err error) { +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { tt := time.Time(t) return tt.MarshalJSON() } -func (t timeRFC3339) MarshalText() (text []byte, err error) { +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { tt := time.Time(t) return tt.MarshalText() } -func (t *timeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcLayoutJSON +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON if tzOffsetRegex.Match(data) { - layout = rfc3339JSON + layout = dateTimeJSON } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { - layout := utcLayout +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime if tzOffsetRegex.Match(data) { layout = time.RFC3339Nano } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) Parse(layout, value string) error { +func (t *dateTimeRFC3339) Parse(layout, value string) error { p, err := time.Parse(layout, strings.ToUpper(value)) - *t = timeRFC3339(p) + *t = dateTimeRFC3339(p) return err } -func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { @@ -70,14 +70,14 @@ func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { } else if reflect.ValueOf(t).IsNil() { return } - m[k] = (*timeRFC3339)(t) + m[k] = (*dateTimeRFC3339)(t) } -func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { if data == nil || strings.EqualFold(string(data), "null") { return nil } - var aux timeRFC3339 + var aux dateTimeRFC3339 if err := json.Unmarshal(data, &aux); err != nil { return fmt.Errorf("struct field %s: %v", fn, err) } diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/CHANGELOG.md b/sdk/resourcemanager/iotsecurity/armiotsecurity/CHANGELOG.md index d98d51fb2730..4507845deb6a 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/CHANGELOG.md +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 0.7.0 (2023-11-24) +### Features Added + +- Support for test fakes and OpenTelemetry trace spans. + + ## 0.6.1 (2023-04-14) ### Bug Fixes diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/README.md b/sdk/resourcemanager/iotsecurity/armiotsecurity/README.md index 8bada2d94800..7a02b0b13ba1 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/README.md +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/README.md @@ -60,6 +60,13 @@ A client groups a set of related APIs, providing access to its functionality. C client := clientFactory.NewDevicesClient() ``` +## 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 diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/autorest.md b/sdk/resourcemanager/iotsecurity/armiotsecurity/autorest.md index bd5a7d48c71d..3d986e17079c 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/autorest.md +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/iotsecurity/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/f790e624d0d080b89d962a3bd19c65bc6a6b2f5e/specification/iotsecurity/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 0.6.1 +module-version: 0.7.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/client_factory.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/client_factory.go index 1160ffb8507e..7844e9145168 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/client_factory.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/client_factory.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armiotsecurity @@ -28,7 +27,7 @@ type ClientFactory struct { // - 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+".ClientFactory", moduleVersion, credential, options) + _, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -38,42 +37,50 @@ func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, }, nil } +// NewDefenderSettingsClient creates a new instance of DefenderSettingsClient. func (c *ClientFactory) NewDefenderSettingsClient() *DefenderSettingsClient { subClient, _ := NewDefenderSettingsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) +// NewDeviceGroupsClient creates a new instance of DeviceGroupsClient. +func (c *ClientFactory) NewDeviceGroupsClient() *DeviceGroupsClient { + subClient, _ := NewDeviceGroupsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewSitesClient() *SitesClient { - subClient, _ := NewSitesClient(c.credential, c.options) +// NewDevicesClient creates a new instance of DevicesClient. +func (c *ClientFactory) NewDevicesClient() *DevicesClient { + subClient, _ := NewDevicesClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewSensorsClient() *SensorsClient { - subClient, _ := NewSensorsClient(c.credential, c.options) +// NewLocationsClient creates a new instance of LocationsClient. +func (c *ClientFactory) NewLocationsClient() *LocationsClient { + subClient, _ := NewLocationsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewOnPremiseSensorsClient creates a new instance of OnPremiseSensorsClient. func (c *ClientFactory) NewOnPremiseSensorsClient() *OnPremiseSensorsClient { subClient, _ := NewOnPremiseSensorsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewLocationsClient() *LocationsClient { - subClient, _ := NewLocationsClient(c.subscriptionID, c.credential, c.options) +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewDeviceGroupsClient() *DeviceGroupsClient { - subClient, _ := NewDeviceGroupsClient(c.subscriptionID, c.credential, c.options) +// NewSensorsClient creates a new instance of SensorsClient. +func (c *ClientFactory) NewSensorsClient() *SensorsClient { + subClient, _ := NewSensorsClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewDevicesClient() *DevicesClient { - subClient, _ := NewDevicesClient(c.subscriptionID, c.credential, c.options) +// NewSitesClient creates a new instance of SitesClient. +func (c *ClientFactory) NewSitesClient() *SitesClient { + subClient, _ := NewSitesClient(c.credential, c.options) return subClient } diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/constants.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/constants.go index 971e408d877e..969a275f85e8 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/constants.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/constants.go @@ -3,15 +3,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armiotsecurity const ( - moduleName = "armiotsecurity" - moduleVersion = "v0.6.1" + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/iotsecurity/armiotsecurity" + moduleVersion = "v0.7.0" ) // AuthorizedState - Authorized state of the device. diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/defendersettings_client.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/defendersettings_client.go index 20e6e315b0dd..86be32bc7d8f 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/defendersettings_client.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/defendersettings_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armiotsecurity @@ -33,7 +32,7 @@ type DefenderSettingsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewDefenderSettingsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DefenderSettingsClient, error) { - cl, err := arm.NewClient(moduleName+".DefenderSettingsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -52,18 +51,25 @@ func NewDefenderSettingsClient(subscriptionID string, credential azcore.TokenCre // - options - DefenderSettingsClientCreateOrUpdateOptions contains the optional parameters for the DefenderSettingsClient.CreateOrUpdate // method. func (client *DefenderSettingsClient) CreateOrUpdate(ctx context.Context, defenderSettingsModel DefenderSettingsModel, options *DefenderSettingsClientCreateOrUpdateOptions) (DefenderSettingsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "DefenderSettingsClient.CreateOrUpdate" + 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, defenderSettingsModel, options) if err != nil { return DefenderSettingsClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DefenderSettingsClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return DefenderSettingsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return DefenderSettingsClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -81,7 +87,10 @@ func (client *DefenderSettingsClient) createOrUpdateCreateRequest(ctx context.Co reqQP.Set("api-version", "2021-02-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, defenderSettingsModel) + if err := runtime.MarshalAsJSON(req, defenderSettingsModel); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -99,16 +108,22 @@ func (client *DefenderSettingsClient) createOrUpdateHandleResponse(resp *http.Re // Generated from API version 2021-02-01-preview // - options - DefenderSettingsClientDeleteOptions contains the optional parameters for the DefenderSettingsClient.Delete method. func (client *DefenderSettingsClient) Delete(ctx context.Context, options *DefenderSettingsClientDeleteOptions) (DefenderSettingsClientDeleteResponse, error) { + var err error + const operationName = "DefenderSettingsClient.Delete" + 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, options) if err != nil { return DefenderSettingsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DefenderSettingsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return DefenderSettingsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return DefenderSettingsClientDeleteResponse{}, err } return DefenderSettingsClientDeleteResponse{}, nil } @@ -138,18 +153,24 @@ func (client *DefenderSettingsClient) deleteCreateRequest(ctx context.Context, o // - options - DefenderSettingsClientDownloadManagerActivationOptions contains the optional parameters for the DefenderSettingsClient.DownloadManagerActivation // method. func (client *DefenderSettingsClient) DownloadManagerActivation(ctx context.Context, options *DefenderSettingsClientDownloadManagerActivationOptions) (DefenderSettingsClientDownloadManagerActivationResponse, error) { + var err error + const operationName = "DefenderSettingsClient.DownloadManagerActivation" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.downloadManagerActivationCreateRequest(ctx, options) if err != nil { return DefenderSettingsClientDownloadManagerActivationResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DefenderSettingsClientDownloadManagerActivationResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DefenderSettingsClientDownloadManagerActivationResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefenderSettingsClientDownloadManagerActivationResponse{}, err } - return DefenderSettingsClientDownloadManagerActivationResponse{Body: resp.Body}, nil + return DefenderSettingsClientDownloadManagerActivationResponse{Body: httpResp.Body}, nil } // downloadManagerActivationCreateRequest creates the DownloadManagerActivation request. @@ -177,18 +198,25 @@ func (client *DefenderSettingsClient) downloadManagerActivationCreateRequest(ctx // Generated from API version 2021-02-01-preview // - options - DefenderSettingsClientGetOptions contains the optional parameters for the DefenderSettingsClient.Get method. func (client *DefenderSettingsClient) Get(ctx context.Context, options *DefenderSettingsClientGetOptions) (DefenderSettingsClientGetResponse, error) { + var err error + const operationName = "DefenderSettingsClient.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, options) if err != nil { return DefenderSettingsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DefenderSettingsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DefenderSettingsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefenderSettingsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -224,18 +252,25 @@ func (client *DefenderSettingsClient) getHandleResponse(resp *http.Response) (De // Generated from API version 2021-02-01-preview // - options - DefenderSettingsClientListOptions contains the optional parameters for the DefenderSettingsClient.List method. func (client *DefenderSettingsClient) List(ctx context.Context, options *DefenderSettingsClientListOptions) (DefenderSettingsClientListResponse, error) { + var err error + const operationName = "DefenderSettingsClient.List" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listCreateRequest(ctx, options) if err != nil { return DefenderSettingsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DefenderSettingsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DefenderSettingsClientListResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefenderSettingsClientListResponse{}, err } - return client.listHandleResponse(resp) + resp, err := client.listHandleResponse(httpResp) + return resp, err } // listCreateRequest creates the List request. @@ -272,18 +307,25 @@ func (client *DefenderSettingsClient) listHandleResponse(resp *http.Response) (D // - options - DefenderSettingsClientPackageDownloadsOptions contains the optional parameters for the DefenderSettingsClient.PackageDownloads // method. func (client *DefenderSettingsClient) PackageDownloads(ctx context.Context, options *DefenderSettingsClientPackageDownloadsOptions) (DefenderSettingsClientPackageDownloadsResponse, error) { + var err error + const operationName = "DefenderSettingsClient.PackageDownloads" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.packageDownloadsCreateRequest(ctx, options) if err != nil { return DefenderSettingsClientPackageDownloadsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DefenderSettingsClientPackageDownloadsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DefenderSettingsClientPackageDownloadsResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DefenderSettingsClientPackageDownloadsResponse{}, err } - return client.packageDownloadsHandleResponse(resp) + resp, err := client.packageDownloadsHandleResponse(httpResp) + return resp, err } // packageDownloadsCreateRequest creates the PackageDownloads request. diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/defendersettings_client_example_test.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/defendersettings_client_example_test.go index 455ed4a9f37f..bf56e9a4b906 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/defendersettings_client_example_test.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/defendersettings_client_example_test.go @@ -79,7 +79,7 @@ func ExampleDefenderSettingsClient_Get() { // ID: to.Ptr("/subscriptions/{subscriptionId}/providers/Microsoft.IoTSecurity/defenderSettings/default"), // Properties: &armiotsecurity.DefenderSettingsProperties{ // DeviceQuota: to.Ptr[int32](2000), - // EvaluationEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T00:00:00.0000000Z"); return t}()), + // EvaluationEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T00:00:00.000Z"); return t}()), // MdeIntegration: &armiotsecurity.DefenderSettingsPropertiesMdeIntegration{ // Status: to.Ptr(armiotsecurity.MdeIntegrationEnabled), // }, diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/devicegroups_client.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/devicegroups_client.go index 63c8b520ed85..363f0a3dd979 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/devicegroups_client.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/devicegroups_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armiotsecurity @@ -33,7 +32,7 @@ type DeviceGroupsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewDeviceGroupsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DeviceGroupsClient, error) { - cl, err := arm.NewClient(moduleName+".DeviceGroupsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,18 +53,25 @@ func NewDeviceGroupsClient(subscriptionID string, credential azcore.TokenCredent // - options - DeviceGroupsClientCreateOrUpdateOptions contains the optional parameters for the DeviceGroupsClient.CreateOrUpdate // method. func (client *DeviceGroupsClient) CreateOrUpdate(ctx context.Context, iotDefenderLocation string, deviceGroupName string, deviceGroupModel DeviceGroupModel, options *DeviceGroupsClientCreateOrUpdateOptions) (DeviceGroupsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "DeviceGroupsClient.CreateOrUpdate" + 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, iotDefenderLocation, deviceGroupName, deviceGroupModel, options) if err != nil { return DeviceGroupsClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DeviceGroupsClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return DeviceGroupsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return DeviceGroupsClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -91,7 +97,10 @@ func (client *DeviceGroupsClient) createOrUpdateCreateRequest(ctx context.Contex reqQP.Set("api-version", "2021-02-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, deviceGroupModel) + if err := runtime.MarshalAsJSON(req, deviceGroupModel); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -111,16 +120,22 @@ func (client *DeviceGroupsClient) createOrUpdateHandleResponse(resp *http.Respon // - deviceGroupName - Device group name // - options - DeviceGroupsClientDeleteOptions contains the optional parameters for the DeviceGroupsClient.Delete method. func (client *DeviceGroupsClient) Delete(ctx context.Context, iotDefenderLocation string, deviceGroupName string, options *DeviceGroupsClientDeleteOptions) (DeviceGroupsClientDeleteResponse, error) { + var err error + const operationName = "DeviceGroupsClient.Delete" + 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, iotDefenderLocation, deviceGroupName, options) if err != nil { return DeviceGroupsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DeviceGroupsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return DeviceGroupsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return DeviceGroupsClientDeleteResponse{}, err } return DeviceGroupsClientDeleteResponse{}, nil } @@ -159,18 +174,25 @@ func (client *DeviceGroupsClient) deleteCreateRequest(ctx context.Context, iotDe // - deviceGroupName - Device group name // - options - DeviceGroupsClientGetOptions contains the optional parameters for the DeviceGroupsClient.Get method. func (client *DeviceGroupsClient) Get(ctx context.Context, iotDefenderLocation string, deviceGroupName string, options *DeviceGroupsClientGetOptions) (DeviceGroupsClientGetResponse, error) { + var err error + const operationName = "DeviceGroupsClient.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, iotDefenderLocation, deviceGroupName, options) if err != nil { return DeviceGroupsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DeviceGroupsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DeviceGroupsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DeviceGroupsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -219,25 +241,20 @@ func (client *DeviceGroupsClient) NewListPager(iotDefenderLocation string, optio return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *DeviceGroupsClientListResponse) (DeviceGroupsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, iotDefenderLocation, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DeviceGroupsClient.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, iotDefenderLocation, options) + }, nil) if err != nil { return DeviceGroupsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return DeviceGroupsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DeviceGroupsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/devicegroups_client_example_test.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/devicegroups_client_example_test.go index a65b22f6067b..dcd3bb58da53 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/devicegroups_client_example_test.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/devicegroups_client_example_test.go @@ -48,10 +48,10 @@ func ExampleDeviceGroupsClient_NewListPager() { // Properties: map[string]any{ // }, // SystemData: &armiotsecurity.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // CreatedBy: to.Ptr("string"), // CreatedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // LastModifiedBy: to.Ptr("string"), // LastModifiedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), // }, @@ -85,10 +85,10 @@ func ExampleDeviceGroupsClient_Get() { // Properties: map[string]any{ // }, // SystemData: &armiotsecurity.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // CreatedBy: to.Ptr("string"), // CreatedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // LastModifiedBy: to.Ptr("string"), // LastModifiedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), // }, @@ -122,10 +122,10 @@ func ExampleDeviceGroupsClient_CreateOrUpdate() { // Properties: map[string]any{ // }, // SystemData: &armiotsecurity.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // CreatedBy: to.Ptr("string"), // CreatedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // LastModifiedBy: to.Ptr("string"), // LastModifiedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), // }, diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/devices_client.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/devices_client.go index f035d4f93d76..5f76d02506d0 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/devices_client.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/devices_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armiotsecurity @@ -33,7 +32,7 @@ type DevicesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewDevicesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DevicesClient, error) { - cl, err := arm.NewClient(moduleName+".DevicesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -53,18 +52,25 @@ func NewDevicesClient(subscriptionID string, credential azcore.TokenCredential, // - deviceID - Device Id // - options - DevicesClientGetOptions contains the optional parameters for the DevicesClient.Get method. func (client *DevicesClient) Get(ctx context.Context, iotDefenderLocation string, deviceGroupName string, deviceID string, options *DevicesClientGetOptions) (DevicesClientGetResponse, error) { + var err error + const operationName = "DevicesClient.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, iotDefenderLocation, deviceGroupName, deviceID, options) if err != nil { return DevicesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return DevicesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DevicesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return DevicesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -118,25 +124,20 @@ func (client *DevicesClient) NewListPager(iotDefenderLocation string, deviceGrou return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *DevicesClientListResponse) (DevicesClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, iotDefenderLocation, deviceGroupName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DevicesClient.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, iotDefenderLocation, deviceGroupName, options) + }, nil) if err != nil { return DevicesClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return DevicesClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DevicesClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/devices_client_example_test.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/devices_client_example_test.go index 1cde3cb56417..4869be6ed4ca 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/devices_client_example_test.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/devices_client_example_test.go @@ -57,13 +57,13 @@ func ExampleDevicesClient_NewListPager() { // DeviceSubTypeID: to.Ptr[int32](2), // DeviceTypeDisplayName: to.Ptr("Industrial"), // DeviceTypeID: to.Ptr[int32](17), - // FirstSeen: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-13T06:32:25Z"); return t}()), - // LastSeen: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-13T06:32:25Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-13T06:32:25Z"); return t}()), + // FirstSeen: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-13T06:32:25.000Z"); return t}()), + // LastSeen: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-13T06:32:25.000Z"); return t}()), + // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-13T06:32:25.000Z"); return t}()), // Nics: []*armiotsecurity.Nic{ // { // IPv4Address: to.Ptr("10.168.140.1"), - // LastSeen: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-13T06:32:25Z"); return t}()), + // LastSeen: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-13T06:32:25.000Z"); return t}()), // MacAddress: to.Ptr("34-E1-2D-77-80-D0"), // MacCertainty: to.Ptr(armiotsecurity.MacCertaintyCertain), // Vlans: []*string{ @@ -87,10 +87,10 @@ func ExampleDevicesClient_NewListPager() { // }, // }, // SystemData: &armiotsecurity.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // CreatedBy: to.Ptr("string"), // CreatedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // LastModifiedBy: to.Ptr("string"), // LastModifiedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), // }, @@ -133,13 +133,13 @@ func ExampleDevicesClient_Get() { // DeviceSubTypeID: to.Ptr[int32](2), // DeviceTypeDisplayName: to.Ptr("Industrial"), // DeviceTypeID: to.Ptr[int32](17), - // FirstSeen: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-13T06:32:25Z"); return t}()), - // LastSeen: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-13T06:32:25Z"); return t}()), - // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-13T06:32:25Z"); return t}()), + // FirstSeen: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-13T06:32:25.000Z"); return t}()), + // LastSeen: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-13T06:32:25.000Z"); return t}()), + // LastUpdated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-13T06:32:25.000Z"); return t}()), // Nics: []*armiotsecurity.Nic{ // { // IPv4Address: to.Ptr("10.168.140.1"), - // LastSeen: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-13T06:32:25Z"); return t}()), + // LastSeen: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-13T06:32:25.000Z"); return t}()), // MacAddress: to.Ptr("34-E1-2D-77-80-D0"), // MacCertainty: to.Ptr(armiotsecurity.MacCertaintyCertain), // Vlans: []*string{ @@ -163,10 +163,10 @@ func ExampleDevicesClient_Get() { // }, // }, // SystemData: &armiotsecurity.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // CreatedBy: to.Ptr("string"), // CreatedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // LastModifiedBy: to.Ptr("string"), // LastModifiedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), // }, diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/defendersettings_server.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/defendersettings_server.go new file mode 100644 index 000000000000..125117207873 --- /dev/null +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/defendersettings_server.go @@ -0,0 +1,253 @@ +//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/resourcemanager/iotsecurity/armiotsecurity" + "net/http" + "regexp" +) + +// DefenderSettingsServer is a fake server for instances of the armiotsecurity.DefenderSettingsClient type. +type DefenderSettingsServer struct { + // CreateOrUpdate is the fake for method DefenderSettingsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, defenderSettingsModel armiotsecurity.DefenderSettingsModel, options *armiotsecurity.DefenderSettingsClientCreateOrUpdateOptions) (resp azfake.Responder[armiotsecurity.DefenderSettingsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method DefenderSettingsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, options *armiotsecurity.DefenderSettingsClientDeleteOptions) (resp azfake.Responder[armiotsecurity.DefenderSettingsClientDeleteResponse], errResp azfake.ErrorResponder) + + // DownloadManagerActivation is the fake for method DefenderSettingsClient.DownloadManagerActivation + // HTTP status codes to indicate success: http.StatusOK + DownloadManagerActivation func(ctx context.Context, options *armiotsecurity.DefenderSettingsClientDownloadManagerActivationOptions) (resp azfake.Responder[armiotsecurity.DefenderSettingsClientDownloadManagerActivationResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method DefenderSettingsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, options *armiotsecurity.DefenderSettingsClientGetOptions) (resp azfake.Responder[armiotsecurity.DefenderSettingsClientGetResponse], errResp azfake.ErrorResponder) + + // List is the fake for method DefenderSettingsClient.List + // HTTP status codes to indicate success: http.StatusOK + List func(ctx context.Context, options *armiotsecurity.DefenderSettingsClientListOptions) (resp azfake.Responder[armiotsecurity.DefenderSettingsClientListResponse], errResp azfake.ErrorResponder) + + // PackageDownloads is the fake for method DefenderSettingsClient.PackageDownloads + // HTTP status codes to indicate success: http.StatusOK + PackageDownloads func(ctx context.Context, options *armiotsecurity.DefenderSettingsClientPackageDownloadsOptions) (resp azfake.Responder[armiotsecurity.DefenderSettingsClientPackageDownloadsResponse], errResp azfake.ErrorResponder) +} + +// NewDefenderSettingsServerTransport creates a new instance of DefenderSettingsServerTransport with the provided implementation. +// The returned DefenderSettingsServerTransport instance is connected to an instance of armiotsecurity.DefenderSettingsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDefenderSettingsServerTransport(srv *DefenderSettingsServer) *DefenderSettingsServerTransport { + return &DefenderSettingsServerTransport{srv: srv} +} + +// DefenderSettingsServerTransport connects instances of armiotsecurity.DefenderSettingsClient to instances of DefenderSettingsServer. +// Don't use this type directly, use NewDefenderSettingsServerTransport instead. +type DefenderSettingsServerTransport struct { + srv *DefenderSettingsServer +} + +// Do implements the policy.Transporter interface for DefenderSettingsServerTransport. +func (d *DefenderSettingsServerTransport) 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 "DefenderSettingsClient.CreateOrUpdate": + resp, err = d.dispatchCreateOrUpdate(req) + case "DefenderSettingsClient.Delete": + resp, err = d.dispatchDelete(req) + case "DefenderSettingsClient.DownloadManagerActivation": + resp, err = d.dispatchDownloadManagerActivation(req) + case "DefenderSettingsClient.Get": + resp, err = d.dispatchGet(req) + case "DefenderSettingsClient.List": + resp, err = d.dispatchList(req) + case "DefenderSettingsClient.PackageDownloads": + resp, err = d.dispatchPackageDownloads(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DefenderSettingsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if d.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/defenderSettings/default` + 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[armiotsecurity.DefenderSettingsModel](req) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.CreateOrUpdate(req.Context(), body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DefenderSettingsModel, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DefenderSettingsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if d.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/defenderSettings/default` + 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) + } + respr, errRespr := d.srv.Delete(req.Context(), nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DefenderSettingsServerTransport) dispatchDownloadManagerActivation(req *http.Request) (*http.Response, error) { + if d.srv.DownloadManagerActivation == nil { + return nil, &nonRetriableError{errors.New("fake for method DownloadManagerActivation not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/defenderSettings/default/downloadManagerActivation` + 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) + } + respr, errRespr := d.srv.DownloadManagerActivation(req.Context(), 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.NewResponse(respContent, req, &server.ResponseOptions{ + Body: server.GetResponse(respr).Body, + ContentType: "application/octet-stream", + }) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DefenderSettingsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/defenderSettings/default` + 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) + } + respr, errRespr := d.srv.Get(req.Context(), 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).DefenderSettingsModel, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DefenderSettingsServerTransport) dispatchList(req *http.Request) (*http.Response, error) { + if d.srv.List == nil { + return nil, &nonRetriableError{errors.New("fake for method List not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/defenderSettings` + 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) + } + respr, errRespr := d.srv.List(req.Context(), 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).DefenderSettingsList, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DefenderSettingsServerTransport) dispatchPackageDownloads(req *http.Request) (*http.Response, error) { + if d.srv.PackageDownloads == nil { + return nil, &nonRetriableError{errors.New("fake for method PackageDownloads not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/defenderSettings/default/packageDownloads` + 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) + } + respr, errRespr := d.srv.PackageDownloads(req.Context(), 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).PackageDownloads, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/devicegroups_server.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/devicegroups_server.go new file mode 100644 index 000000000000..d0aac6853dc1 --- /dev/null +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/devicegroups_server.go @@ -0,0 +1,230 @@ +//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/iotsecurity/armiotsecurity" + "net/http" + "net/url" + "regexp" +) + +// DeviceGroupsServer is a fake server for instances of the armiotsecurity.DeviceGroupsClient type. +type DeviceGroupsServer struct { + // CreateOrUpdate is the fake for method DeviceGroupsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, iotDefenderLocation string, deviceGroupName string, deviceGroupModel armiotsecurity.DeviceGroupModel, options *armiotsecurity.DeviceGroupsClientCreateOrUpdateOptions) (resp azfake.Responder[armiotsecurity.DeviceGroupsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method DeviceGroupsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, iotDefenderLocation string, deviceGroupName string, options *armiotsecurity.DeviceGroupsClientDeleteOptions) (resp azfake.Responder[armiotsecurity.DeviceGroupsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method DeviceGroupsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, iotDefenderLocation string, deviceGroupName string, options *armiotsecurity.DeviceGroupsClientGetOptions) (resp azfake.Responder[armiotsecurity.DeviceGroupsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method DeviceGroupsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(iotDefenderLocation string, options *armiotsecurity.DeviceGroupsClientListOptions) (resp azfake.PagerResponder[armiotsecurity.DeviceGroupsClientListResponse]) +} + +// NewDeviceGroupsServerTransport creates a new instance of DeviceGroupsServerTransport with the provided implementation. +// The returned DeviceGroupsServerTransport instance is connected to an instance of armiotsecurity.DeviceGroupsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDeviceGroupsServerTransport(srv *DeviceGroupsServer) *DeviceGroupsServerTransport { + return &DeviceGroupsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armiotsecurity.DeviceGroupsClientListResponse]](), + } +} + +// DeviceGroupsServerTransport connects instances of armiotsecurity.DeviceGroupsClient to instances of DeviceGroupsServer. +// Don't use this type directly, use NewDeviceGroupsServerTransport instead. +type DeviceGroupsServerTransport struct { + srv *DeviceGroupsServer + newListPager *tracker[azfake.PagerResponder[armiotsecurity.DeviceGroupsClientListResponse]] +} + +// Do implements the policy.Transporter interface for DeviceGroupsServerTransport. +func (d *DeviceGroupsServerTransport) 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 "DeviceGroupsClient.CreateOrUpdate": + resp, err = d.dispatchCreateOrUpdate(req) + case "DeviceGroupsClient.Delete": + resp, err = d.dispatchDelete(req) + case "DeviceGroupsClient.Get": + resp, err = d.dispatchGet(req) + case "DeviceGroupsClient.NewListPager": + resp, err = d.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DeviceGroupsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if d.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deviceGroups/(?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[armiotsecurity.DeviceGroupModel](req) + if err != nil { + return nil, err + } + iotDefenderLocationParam, err := url.PathUnescape(matches[regex.SubexpIndex("iotDefenderLocation")]) + if err != nil { + return nil, err + } + deviceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deviceGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.CreateOrUpdate(req.Context(), iotDefenderLocationParam, deviceGroupNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).DeviceGroupModel, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DeviceGroupsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if d.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deviceGroups/(?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) + } + iotDefenderLocationParam, err := url.PathUnescape(matches[regex.SubexpIndex("iotDefenderLocation")]) + if err != nil { + return nil, err + } + deviceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deviceGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Delete(req.Context(), iotDefenderLocationParam, deviceGroupNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DeviceGroupsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deviceGroups/(?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) + } + iotDefenderLocationParam, err := url.PathUnescape(matches[regex.SubexpIndex("iotDefenderLocation")]) + if err != nil { + return nil, err + } + deviceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deviceGroupName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Get(req.Context(), iotDefenderLocationParam, deviceGroupNameParam, 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).DeviceGroupModel, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DeviceGroupsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := d.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deviceGroups` + 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) + } + iotDefenderLocationParam, err := url.PathUnescape(matches[regex.SubexpIndex("iotDefenderLocation")]) + if err != nil { + return nil, err + } + resp := d.srv.NewListPager(iotDefenderLocationParam, nil) + newListPager = &resp + d.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armiotsecurity.DeviceGroupsClientListResponse, 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) { + d.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + d.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/devices_server.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/devices_server.go new file mode 100644 index 000000000000..333d7a554486 --- /dev/null +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/devices_server.go @@ -0,0 +1,168 @@ +//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/iotsecurity/armiotsecurity" + "net/http" + "net/url" + "regexp" +) + +// DevicesServer is a fake server for instances of the armiotsecurity.DevicesClient type. +type DevicesServer struct { + // Get is the fake for method DevicesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, iotDefenderLocation string, deviceGroupName string, deviceID string, options *armiotsecurity.DevicesClientGetOptions) (resp azfake.Responder[armiotsecurity.DevicesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method DevicesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(iotDefenderLocation string, deviceGroupName string, options *armiotsecurity.DevicesClientListOptions) (resp azfake.PagerResponder[armiotsecurity.DevicesClientListResponse]) +} + +// NewDevicesServerTransport creates a new instance of DevicesServerTransport with the provided implementation. +// The returned DevicesServerTransport instance is connected to an instance of armiotsecurity.DevicesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDevicesServerTransport(srv *DevicesServer) *DevicesServerTransport { + return &DevicesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armiotsecurity.DevicesClientListResponse]](), + } +} + +// DevicesServerTransport connects instances of armiotsecurity.DevicesClient to instances of DevicesServer. +// Don't use this type directly, use NewDevicesServerTransport instead. +type DevicesServerTransport struct { + srv *DevicesServer + newListPager *tracker[azfake.PagerResponder[armiotsecurity.DevicesClientListResponse]] +} + +// Do implements the policy.Transporter interface for DevicesServerTransport. +func (d *DevicesServerTransport) 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 "DevicesClient.Get": + resp, err = d.dispatchGet(req) + case "DevicesClient.NewListPager": + resp, err = d.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DevicesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deviceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/devices/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + iotDefenderLocationParam, err := url.PathUnescape(matches[regex.SubexpIndex("iotDefenderLocation")]) + if err != nil { + return nil, err + } + deviceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deviceGroupName")]) + if err != nil { + return nil, err + } + deviceIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("deviceId")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Get(req.Context(), iotDefenderLocationParam, deviceGroupNameParam, deviceIDParam, 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).DeviceModel, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DevicesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := d.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deviceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/devices` + 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) + } + qp := req.URL.Query() + iotDefenderLocationParam, err := url.PathUnescape(matches[regex.SubexpIndex("iotDefenderLocation")]) + if err != nil { + return nil, err + } + deviceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("deviceGroupName")]) + if err != nil { + return nil, err + } + skipTokenUnescaped, err := url.QueryUnescape(qp.Get("$skipToken")) + if err != nil { + return nil, err + } + skipTokenParam := getOptional(skipTokenUnescaped) + var options *armiotsecurity.DevicesClientListOptions + if skipTokenParam != nil { + options = &armiotsecurity.DevicesClientListOptions{ + SkipToken: skipTokenParam, + } + } + resp := d.srv.NewListPager(iotDefenderLocationParam, deviceGroupNameParam, options) + newListPager = &resp + d.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armiotsecurity.DevicesClientListResponse, 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) { + d.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + d.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/internal.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/internal.go new file mode 100644 index 000000000000..94e060e89dbd --- /dev/null +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/internal.go @@ -0,0 +1,72 @@ +//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 ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "reflect" + "sync" +) + +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 getOptional[T any](v T) *T { + if reflect.ValueOf(v).IsZero() { + return nil + } + return &v +} + +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/iotsecurity/armiotsecurity/fake/locations_server.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/locations_server.go new file mode 100644 index 000000000000..58720b67a5af --- /dev/null +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/locations_server.go @@ -0,0 +1,140 @@ +//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/iotsecurity/armiotsecurity" + "net/http" + "net/url" + "regexp" +) + +// LocationsServer is a fake server for instances of the armiotsecurity.LocationsClient type. +type LocationsServer struct { + // Get is the fake for method LocationsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, iotDefenderLocation string, options *armiotsecurity.LocationsClientGetOptions) (resp azfake.Responder[armiotsecurity.LocationsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method LocationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armiotsecurity.LocationsClientListOptions) (resp azfake.PagerResponder[armiotsecurity.LocationsClientListResponse]) +} + +// NewLocationsServerTransport creates a new instance of LocationsServerTransport with the provided implementation. +// The returned LocationsServerTransport instance is connected to an instance of armiotsecurity.LocationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewLocationsServerTransport(srv *LocationsServer) *LocationsServerTransport { + return &LocationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armiotsecurity.LocationsClientListResponse]](), + } +} + +// LocationsServerTransport connects instances of armiotsecurity.LocationsClient to instances of LocationsServer. +// Don't use this type directly, use NewLocationsServerTransport instead. +type LocationsServerTransport struct { + srv *LocationsServer + newListPager *tracker[azfake.PagerResponder[armiotsecurity.LocationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for LocationsServerTransport. +func (l *LocationsServerTransport) 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 "LocationsClient.Get": + resp, err = l.dispatchGet(req) + case "LocationsClient.NewListPager": + resp, err = l.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (l *LocationsServerTransport) 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~%@]+)/providers/Microsoft\.IoTSecurity/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + iotDefenderLocationParam, err := url.PathUnescape(matches[regex.SubexpIndex("iotDefenderLocation")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.Get(req.Context(), iotDefenderLocationParam, 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).LocationModel, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (l *LocationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if l.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := l.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/locations` + 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.NewListPager(nil) + newListPager = &resp + l.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armiotsecurity.LocationsClientListResponse, 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) { + l.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + l.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/onpremisesensors_server.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/onpremisesensors_server.go new file mode 100644 index 000000000000..51bf06b98495 --- /dev/null +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/onpremisesensors_server.go @@ -0,0 +1,277 @@ +//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/resourcemanager/iotsecurity/armiotsecurity" + "net/http" + "net/url" + "regexp" +) + +// OnPremiseSensorsServer is a fake server for instances of the armiotsecurity.OnPremiseSensorsClient type. +type OnPremiseSensorsServer struct { + // CreateOrUpdate is the fake for method OnPremiseSensorsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, onPremiseSensorName string, options *armiotsecurity.OnPremiseSensorsClientCreateOrUpdateOptions) (resp azfake.Responder[armiotsecurity.OnPremiseSensorsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method OnPremiseSensorsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, onPremiseSensorName string, options *armiotsecurity.OnPremiseSensorsClientDeleteOptions) (resp azfake.Responder[armiotsecurity.OnPremiseSensorsClientDeleteResponse], errResp azfake.ErrorResponder) + + // DownloadActivation is the fake for method OnPremiseSensorsClient.DownloadActivation + // HTTP status codes to indicate success: http.StatusOK + DownloadActivation func(ctx context.Context, onPremiseSensorName string, options *armiotsecurity.OnPremiseSensorsClientDownloadActivationOptions) (resp azfake.Responder[armiotsecurity.OnPremiseSensorsClientDownloadActivationResponse], errResp azfake.ErrorResponder) + + // DownloadResetPassword is the fake for method OnPremiseSensorsClient.DownloadResetPassword + // HTTP status codes to indicate success: http.StatusOK + DownloadResetPassword func(ctx context.Context, onPremiseSensorName string, body armiotsecurity.ResetPasswordInput, options *armiotsecurity.OnPremiseSensorsClientDownloadResetPasswordOptions) (resp azfake.Responder[armiotsecurity.OnPremiseSensorsClientDownloadResetPasswordResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method OnPremiseSensorsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, onPremiseSensorName string, options *armiotsecurity.OnPremiseSensorsClientGetOptions) (resp azfake.Responder[armiotsecurity.OnPremiseSensorsClientGetResponse], errResp azfake.ErrorResponder) + + // List is the fake for method OnPremiseSensorsClient.List + // HTTP status codes to indicate success: http.StatusOK + List func(ctx context.Context, options *armiotsecurity.OnPremiseSensorsClientListOptions) (resp azfake.Responder[armiotsecurity.OnPremiseSensorsClientListResponse], errResp azfake.ErrorResponder) +} + +// NewOnPremiseSensorsServerTransport creates a new instance of OnPremiseSensorsServerTransport with the provided implementation. +// The returned OnPremiseSensorsServerTransport instance is connected to an instance of armiotsecurity.OnPremiseSensorsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOnPremiseSensorsServerTransport(srv *OnPremiseSensorsServer) *OnPremiseSensorsServerTransport { + return &OnPremiseSensorsServerTransport{srv: srv} +} + +// OnPremiseSensorsServerTransport connects instances of armiotsecurity.OnPremiseSensorsClient to instances of OnPremiseSensorsServer. +// Don't use this type directly, use NewOnPremiseSensorsServerTransport instead. +type OnPremiseSensorsServerTransport struct { + srv *OnPremiseSensorsServer +} + +// Do implements the policy.Transporter interface for OnPremiseSensorsServerTransport. +func (o *OnPremiseSensorsServerTransport) 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 "OnPremiseSensorsClient.CreateOrUpdate": + resp, err = o.dispatchCreateOrUpdate(req) + case "OnPremiseSensorsClient.Delete": + resp, err = o.dispatchDelete(req) + case "OnPremiseSensorsClient.DownloadActivation": + resp, err = o.dispatchDownloadActivation(req) + case "OnPremiseSensorsClient.DownloadResetPassword": + resp, err = o.dispatchDownloadResetPassword(req) + case "OnPremiseSensorsClient.Get": + resp, err = o.dispatchGet(req) + case "OnPremiseSensorsClient.List": + resp, err = o.dispatchList(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OnPremiseSensorsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if o.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/onPremiseSensors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + onPremiseSensorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("onPremiseSensorName")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.CreateOrUpdate(req.Context(), onPremiseSensorNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).OnPremiseSensor, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (o *OnPremiseSensorsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if o.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/onPremiseSensors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + onPremiseSensorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("onPremiseSensorName")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.Delete(req.Context(), onPremiseSensorNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (o *OnPremiseSensorsServerTransport) dispatchDownloadActivation(req *http.Request) (*http.Response, error) { + if o.srv.DownloadActivation == nil { + return nil, &nonRetriableError{errors.New("fake for method DownloadActivation not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/onPremiseSensors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/downloadActivation` + 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) + } + onPremiseSensorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("onPremiseSensorName")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.DownloadActivation(req.Context(), onPremiseSensorNameParam, 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.NewResponse(respContent, req, &server.ResponseOptions{ + Body: server.GetResponse(respr).Body, + ContentType: "application/octet-stream", + }) + if err != nil { + return nil, err + } + return resp, nil +} + +func (o *OnPremiseSensorsServerTransport) dispatchDownloadResetPassword(req *http.Request) (*http.Response, error) { + if o.srv.DownloadResetPassword == nil { + return nil, &nonRetriableError{errors.New("fake for method DownloadResetPassword not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/onPremiseSensors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/downloadResetPassword` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armiotsecurity.ResetPasswordInput](req) + if err != nil { + return nil, err + } + onPremiseSensorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("onPremiseSensorName")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.DownloadResetPassword(req.Context(), onPremiseSensorNameParam, 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.NewResponse(respContent, req, &server.ResponseOptions{ + Body: server.GetResponse(respr).Body, + ContentType: "application/octet-stream", + }) + if err != nil { + return nil, err + } + return resp, nil +} + +func (o *OnPremiseSensorsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if o.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/onPremiseSensors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + onPremiseSensorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("onPremiseSensorName")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.Get(req.Context(), onPremiseSensorNameParam, 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).OnPremiseSensor, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (o *OnPremiseSensorsServerTransport) dispatchList(req *http.Request) (*http.Response, error) { + if o.srv.List == nil { + return nil, &nonRetriableError{errors.New("fake for method List not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/onPremiseSensors` + 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) + } + respr, errRespr := o.srv.List(req.Context(), 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).OnPremiseSensorsList, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/operations_server.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/operations_server.go new file mode 100644 index 000000000000..4e1c8e49ab85 --- /dev/null +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/operations_server.go @@ -0,0 +1,96 @@ +//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 ( + "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/iotsecurity/armiotsecurity" + "net/http" +) + +// OperationsServer is a fake server for instances of the armiotsecurity.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armiotsecurity.OperationsClientListOptions) (resp azfake.PagerResponder[armiotsecurity.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armiotsecurity.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[armiotsecurity.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armiotsecurity.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armiotsecurity.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) 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 "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armiotsecurity.OperationsClientListResponse, 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) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/sensors_server.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/sensors_server.go new file mode 100644 index 000000000000..06231528a4d4 --- /dev/null +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/sensors_server.go @@ -0,0 +1,344 @@ +//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/resourcemanager/iotsecurity/armiotsecurity" + "net/http" + "net/url" + "regexp" +) + +// SensorsServer is a fake server for instances of the armiotsecurity.SensorsClient type. +type SensorsServer struct { + // CreateOrUpdate is the fake for method SensorsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, scope string, sensorName string, sensorModel armiotsecurity.SensorModel, options *armiotsecurity.SensorsClientCreateOrUpdateOptions) (resp azfake.Responder[armiotsecurity.SensorsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method SensorsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, scope string, sensorName string, options *armiotsecurity.SensorsClientDeleteOptions) (resp azfake.Responder[armiotsecurity.SensorsClientDeleteResponse], errResp azfake.ErrorResponder) + + // DownloadActivation is the fake for method SensorsClient.DownloadActivation + // HTTP status codes to indicate success: http.StatusOK + DownloadActivation func(ctx context.Context, scope string, sensorName string, options *armiotsecurity.SensorsClientDownloadActivationOptions) (resp azfake.Responder[armiotsecurity.SensorsClientDownloadActivationResponse], errResp azfake.ErrorResponder) + + // DownloadResetPassword is the fake for method SensorsClient.DownloadResetPassword + // HTTP status codes to indicate success: http.StatusOK + DownloadResetPassword func(ctx context.Context, scope string, sensorName string, body armiotsecurity.ResetPasswordInput, options *armiotsecurity.SensorsClientDownloadResetPasswordOptions) (resp azfake.Responder[armiotsecurity.SensorsClientDownloadResetPasswordResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method SensorsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, scope string, sensorName string, options *armiotsecurity.SensorsClientGetOptions) (resp azfake.Responder[armiotsecurity.SensorsClientGetResponse], errResp azfake.ErrorResponder) + + // List is the fake for method SensorsClient.List + // HTTP status codes to indicate success: http.StatusOK + List func(ctx context.Context, scope string, options *armiotsecurity.SensorsClientListOptions) (resp azfake.Responder[armiotsecurity.SensorsClientListResponse], errResp azfake.ErrorResponder) + + // TriggerTiPackageUpdate is the fake for method SensorsClient.TriggerTiPackageUpdate + // HTTP status codes to indicate success: http.StatusOK + TriggerTiPackageUpdate func(ctx context.Context, scope string, sensorName string, options *armiotsecurity.SensorsClientTriggerTiPackageUpdateOptions) (resp azfake.Responder[armiotsecurity.SensorsClientTriggerTiPackageUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewSensorsServerTransport creates a new instance of SensorsServerTransport with the provided implementation. +// The returned SensorsServerTransport instance is connected to an instance of armiotsecurity.SensorsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSensorsServerTransport(srv *SensorsServer) *SensorsServerTransport { + return &SensorsServerTransport{srv: srv} +} + +// SensorsServerTransport connects instances of armiotsecurity.SensorsClient to instances of SensorsServer. +// Don't use this type directly, use NewSensorsServerTransport instead. +type SensorsServerTransport struct { + srv *SensorsServer +} + +// Do implements the policy.Transporter interface for SensorsServerTransport. +func (s *SensorsServerTransport) 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 "SensorsClient.CreateOrUpdate": + resp, err = s.dispatchCreateOrUpdate(req) + case "SensorsClient.Delete": + resp, err = s.dispatchDelete(req) + case "SensorsClient.DownloadActivation": + resp, err = s.dispatchDownloadActivation(req) + case "SensorsClient.DownloadResetPassword": + resp, err = s.dispatchDownloadResetPassword(req) + case "SensorsClient.Get": + resp, err = s.dispatchGet(req) + case "SensorsClient.List": + resp, err = s.dispatchList(req) + case "SensorsClient.TriggerTiPackageUpdate": + resp, err = s.dispatchTriggerTiPackageUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SensorsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/sensors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armiotsecurity.SensorModel](req) + if err != nil { + return nil, err + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + sensorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("sensorName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.CreateOrUpdate(req.Context(), scopeParam, sensorNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SensorModel, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SensorsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if s.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/sensors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + sensorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("sensorName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Delete(req.Context(), scopeParam, sensorNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SensorsServerTransport) dispatchDownloadActivation(req *http.Request) (*http.Response, error) { + if s.srv.DownloadActivation == nil { + return nil, &nonRetriableError{errors.New("fake for method DownloadActivation not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/sensors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/downloadActivation` + 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) + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + sensorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("sensorName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.DownloadActivation(req.Context(), scopeParam, sensorNameParam, 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.NewResponse(respContent, req, &server.ResponseOptions{ + Body: server.GetResponse(respr).Body, + ContentType: "application/octet-stream", + }) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SensorsServerTransport) dispatchDownloadResetPassword(req *http.Request) (*http.Response, error) { + if s.srv.DownloadResetPassword == nil { + return nil, &nonRetriableError{errors.New("fake for method DownloadResetPassword not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/sensors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/downloadResetPassword` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armiotsecurity.ResetPasswordInput](req) + if err != nil { + return nil, err + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + sensorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("sensorName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.DownloadResetPassword(req.Context(), scopeParam, sensorNameParam, 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.NewResponse(respContent, req, &server.ResponseOptions{ + Body: server.GetResponse(respr).Body, + ContentType: "application/octet-stream", + }) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SensorsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/sensors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + sensorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("sensorName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), scopeParam, sensorNameParam, 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).SensorModel, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SensorsServerTransport) dispatchList(req *http.Request) (*http.Response, error) { + if s.srv.List == nil { + return nil, &nonRetriableError{errors.New("fake for method List not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/sensors` + 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) + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.List(req.Context(), scopeParam, 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).SensorsList, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SensorsServerTransport) dispatchTriggerTiPackageUpdate(req *http.Request) (*http.Response, error) { + if s.srv.TriggerTiPackageUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method TriggerTiPackageUpdate not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/sensors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/triggerTiPackageUpdate` + 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) + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + sensorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("sensorName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.TriggerTiPackageUpdate(req.Context(), scopeParam, sensorNameParam, 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.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/server_factory.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/server_factory.go new file mode 100644 index 000000000000..980441c61c2d --- /dev/null +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/server_factory.go @@ -0,0 +1,114 @@ +//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 ( + "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 armiotsecurity.ClientFactory type. +type ServerFactory struct { + DefenderSettingsServer DefenderSettingsServer + DeviceGroupsServer DeviceGroupsServer + DevicesServer DevicesServer + LocationsServer LocationsServer + OnPremiseSensorsServer OnPremiseSensorsServer + OperationsServer OperationsServer + SensorsServer SensorsServer + SitesServer SitesServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armiotsecurity.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 armiotsecurity.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trDefenderSettingsServer *DefenderSettingsServerTransport + trDeviceGroupsServer *DeviceGroupsServerTransport + trDevicesServer *DevicesServerTransport + trLocationsServer *LocationsServerTransport + trOnPremiseSensorsServer *OnPremiseSensorsServerTransport + trOperationsServer *OperationsServerTransport + trSensorsServer *SensorsServerTransport + trSitesServer *SitesServerTransport +} + +// 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 "DefenderSettingsClient": + initServer(s, &s.trDefenderSettingsServer, func() *DefenderSettingsServerTransport { + return NewDefenderSettingsServerTransport(&s.srv.DefenderSettingsServer) + }) + resp, err = s.trDefenderSettingsServer.Do(req) + case "DeviceGroupsClient": + initServer(s, &s.trDeviceGroupsServer, func() *DeviceGroupsServerTransport { return NewDeviceGroupsServerTransport(&s.srv.DeviceGroupsServer) }) + resp, err = s.trDeviceGroupsServer.Do(req) + case "DevicesClient": + initServer(s, &s.trDevicesServer, func() *DevicesServerTransport { return NewDevicesServerTransport(&s.srv.DevicesServer) }) + resp, err = s.trDevicesServer.Do(req) + case "LocationsClient": + initServer(s, &s.trLocationsServer, func() *LocationsServerTransport { return NewLocationsServerTransport(&s.srv.LocationsServer) }) + resp, err = s.trLocationsServer.Do(req) + case "OnPremiseSensorsClient": + initServer(s, &s.trOnPremiseSensorsServer, func() *OnPremiseSensorsServerTransport { + return NewOnPremiseSensorsServerTransport(&s.srv.OnPremiseSensorsServer) + }) + resp, err = s.trOnPremiseSensorsServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "SensorsClient": + initServer(s, &s.trSensorsServer, func() *SensorsServerTransport { return NewSensorsServerTransport(&s.srv.SensorsServer) }) + resp, err = s.trSensorsServer.Do(req) + case "SitesClient": + initServer(s, &s.trSitesServer, func() *SitesServerTransport { return NewSitesServerTransport(&s.srv.SitesServer) }) + resp, err = s.trSitesServer.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/iotsecurity/armiotsecurity/fake/sites_server.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/sites_server.go new file mode 100644 index 000000000000..0f63ff4f34d0 --- /dev/null +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/sites_server.go @@ -0,0 +1,205 @@ +//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/resourcemanager/iotsecurity/armiotsecurity" + "net/http" + "net/url" + "regexp" +) + +// SitesServer is a fake server for instances of the armiotsecurity.SitesClient type. +type SitesServer struct { + // CreateOrUpdate is the fake for method SitesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, scope string, siteModel armiotsecurity.SiteModel, options *armiotsecurity.SitesClientCreateOrUpdateOptions) (resp azfake.Responder[armiotsecurity.SitesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method SitesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, scope string, options *armiotsecurity.SitesClientDeleteOptions) (resp azfake.Responder[armiotsecurity.SitesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method SitesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, scope string, options *armiotsecurity.SitesClientGetOptions) (resp azfake.Responder[armiotsecurity.SitesClientGetResponse], errResp azfake.ErrorResponder) + + // List is the fake for method SitesClient.List + // HTTP status codes to indicate success: http.StatusOK + List func(ctx context.Context, scope string, options *armiotsecurity.SitesClientListOptions) (resp azfake.Responder[armiotsecurity.SitesClientListResponse], errResp azfake.ErrorResponder) +} + +// NewSitesServerTransport creates a new instance of SitesServerTransport with the provided implementation. +// The returned SitesServerTransport instance is connected to an instance of armiotsecurity.SitesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSitesServerTransport(srv *SitesServer) *SitesServerTransport { + return &SitesServerTransport{srv: srv} +} + +// SitesServerTransport connects instances of armiotsecurity.SitesClient to instances of SitesServer. +// Don't use this type directly, use NewSitesServerTransport instead. +type SitesServerTransport struct { + srv *SitesServer +} + +// Do implements the policy.Transporter interface for SitesServerTransport. +func (s *SitesServerTransport) 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 "SitesClient.CreateOrUpdate": + resp, err = s.dispatchCreateOrUpdate(req) + case "SitesClient.Delete": + resp, err = s.dispatchDelete(req) + case "SitesClient.Get": + resp, err = s.dispatchGet(req) + case "SitesClient.List": + resp, err = s.dispatchList(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SitesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/sites/default` + 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[armiotsecurity.SiteModel](req) + if err != nil { + return nil, err + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.CreateOrUpdate(req.Context(), scopeParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SiteModel, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SitesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if s.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/sites/default` + 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) + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Delete(req.Context(), scopeParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SitesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/sites/default` + 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) + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), scopeParam, 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).SiteModel, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SitesServerTransport) dispatchList(req *http.Request) (*http.Response, error) { + if s.srv.List == nil { + return nil, &nonRetriableError{errors.New("fake for method List not implemented")} + } + const regexStr = `/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.IoTSecurity/sites` + 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) + } + scopeParam, err := url.PathUnescape(matches[regex.SubexpIndex("scope")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.List(req.Context(), scopeParam, 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).SitesList, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/time_rfc3339.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/time_rfc3339.go new file mode 100644 index 000000000000..b0535a7b63e6 --- /dev/null +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/fake/time_rfc3339.go @@ -0,0 +1,86 @@ +//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 ( + "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 ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +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 { + layout := utcDateTimeJSON + if tzOffsetRegex.Match(data) { + layout = dateTimeJSON + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + 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 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 || strings.EqualFold(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/iotsecurity/armiotsecurity/go.mod b/sdk/resourcemanager/iotsecurity/armiotsecurity/go.mod index 8ace17f4bfaa..e3fd96f8b533 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/go.mod +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/iotsecurity/armiots go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 // indirect + github.com/google/uuid v1.3.1 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.6.0 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect ) diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/go.sum b/sdk/resourcemanager/iotsecurity/armiotsecurity/go.sum index 8ba445a8c4da..7985f1da436f 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/go.sum +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/go.sum @@ -1,31 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= +github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= +github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/locations_client.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/locations_client.go index 059881151bf4..b0abbcfab06d 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/locations_client.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/locations_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armiotsecurity @@ -33,7 +32,7 @@ type LocationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewLocationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LocationsClient, error) { - cl, err := arm.NewClient(moduleName+".LocationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -51,18 +50,25 @@ func NewLocationsClient(subscriptionID string, credential azcore.TokenCredential // - iotDefenderLocation - Defender for IoT location // - options - LocationsClientGetOptions contains the optional parameters for the LocationsClient.Get method. func (client *LocationsClient) Get(ctx context.Context, iotDefenderLocation string, options *LocationsClientGetOptions) (LocationsClientGetResponse, error) { + var err error + const operationName = "LocationsClient.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, iotDefenderLocation, options) if err != nil { return LocationsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return LocationsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LocationsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return LocationsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -106,25 +112,20 @@ func (client *LocationsClient) NewListPager(options *LocationsClientListOptions) return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *LocationsClientListResponse) (LocationsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "LocationsClient.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, options) + }, nil) if err != nil { return LocationsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return LocationsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LocationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/locations_client_example_test.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/locations_client_example_test.go index 47df3b1c37c0..7db7eb5d6e50 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/locations_client_example_test.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/locations_client_example_test.go @@ -48,10 +48,10 @@ func ExampleLocationsClient_NewListPager() { // Properties: map[string]any{ // }, // SystemData: &armiotsecurity.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // CreatedBy: to.Ptr("string"), // CreatedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // LastModifiedBy: to.Ptr("string"), // LastModifiedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), // }, @@ -85,10 +85,10 @@ func ExampleLocationsClient_Get() { // Properties: map[string]any{ // }, // SystemData: &armiotsecurity.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // CreatedBy: to.Ptr("string"), // CreatedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // LastModifiedBy: to.Ptr("string"), // LastModifiedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), // }, diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/models.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/models.go index 487d64b0f0b5..afbb73cc5471 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/models.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/models.go @@ -3,47 +3,13 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armiotsecurity import "time" -// DefenderSettingsClientCreateOrUpdateOptions contains the optional parameters for the DefenderSettingsClient.CreateOrUpdate -// method. -type DefenderSettingsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// DefenderSettingsClientDeleteOptions contains the optional parameters for the DefenderSettingsClient.Delete method. -type DefenderSettingsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// DefenderSettingsClientDownloadManagerActivationOptions contains the optional parameters for the DefenderSettingsClient.DownloadManagerActivation -// method. -type DefenderSettingsClientDownloadManagerActivationOptions struct { - // placeholder for future optional parameters -} - -// DefenderSettingsClientGetOptions contains the optional parameters for the DefenderSettingsClient.Get method. -type DefenderSettingsClientGetOptions struct { - // placeholder for future optional parameters -} - -// DefenderSettingsClientListOptions contains the optional parameters for the DefenderSettingsClient.List method. -type DefenderSettingsClientListOptions struct { - // placeholder for future optional parameters -} - -// DefenderSettingsClientPackageDownloadsOptions contains the optional parameters for the DefenderSettingsClient.PackageDownloads -// method. -type DefenderSettingsClientPackageDownloadsOptions struct { - // placeholder for future optional parameters -} - // DefenderSettingsList - List of IoT Defender settings type DefenderSettingsList struct { // READ-ONLY; List data @@ -116,26 +82,6 @@ type DeviceGroupModel struct { Type *string } -// DeviceGroupsClientCreateOrUpdateOptions contains the optional parameters for the DeviceGroupsClient.CreateOrUpdate method. -type DeviceGroupsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// DeviceGroupsClientDeleteOptions contains the optional parameters for the DeviceGroupsClient.Delete method. -type DeviceGroupsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// DeviceGroupsClientGetOptions contains the optional parameters for the DeviceGroupsClient.Get method. -type DeviceGroupsClientGetOptions struct { - // placeholder for future optional parameters -} - -// DeviceGroupsClientListOptions contains the optional parameters for the DeviceGroupsClient.NewListPager method. -type DeviceGroupsClientListOptions struct { - // placeholder for future optional parameters -} - // DeviceList - List of devices type DeviceList struct { // READ-ONLY; When there are too many devices for one page, use this URI to fetch the next page. @@ -277,17 +223,6 @@ type DeviceProperties struct { Slots []*Slot } -// DevicesClientGetOptions contains the optional parameters for the DevicesClient.Get method. -type DevicesClientGetOptions struct { - // placeholder for future optional parameters -} - -// DevicesClientListOptions contains the optional parameters for the DevicesClient.NewListPager method. -type DevicesClientListOptions struct { - // Skip token used for pagination - SkipToken *string -} - // DimensionProperties - properties for dimension type DimensionProperties struct { // localized display name of the dimension to customer @@ -430,16 +365,6 @@ type LocationModel struct { Type *string } -// LocationsClientGetOptions contains the optional parameters for the LocationsClient.Get method. -type LocationsClientGetOptions struct { - // placeholder for future optional parameters -} - -// LocationsClientListOptions contains the optional parameters for the LocationsClient.NewListPager method. -type LocationsClientListOptions struct { - // placeholder for future optional parameters -} - // MergedDevice - Merged device data type MergedDevice struct { // READ-ONLY; Device data source @@ -494,39 +419,6 @@ type OnPremiseSensor struct { Type *string } -// OnPremiseSensorsClientCreateOrUpdateOptions contains the optional parameters for the OnPremiseSensorsClient.CreateOrUpdate -// method. -type OnPremiseSensorsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// OnPremiseSensorsClientDeleteOptions contains the optional parameters for the OnPremiseSensorsClient.Delete method. -type OnPremiseSensorsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// OnPremiseSensorsClientDownloadActivationOptions contains the optional parameters for the OnPremiseSensorsClient.DownloadActivation -// method. -type OnPremiseSensorsClientDownloadActivationOptions struct { - // placeholder for future optional parameters -} - -// OnPremiseSensorsClientDownloadResetPasswordOptions contains the optional parameters for the OnPremiseSensorsClient.DownloadResetPassword -// method. -type OnPremiseSensorsClientDownloadResetPasswordOptions struct { - // placeholder for future optional parameters -} - -// OnPremiseSensorsClientGetOptions contains the optional parameters for the OnPremiseSensorsClient.Get method. -type OnPremiseSensorsClientGetOptions struct { - // placeholder for future optional parameters -} - -// OnPremiseSensorsClientListOptions contains the optional parameters for the OnPremiseSensorsClient.List method. -type OnPremiseSensorsClientListOptions struct { - // placeholder for future optional parameters -} - // OnPremiseSensorsList - List of on-premise IoT sensors type OnPremiseSensorsList struct { // READ-ONLY; List data @@ -663,11 +555,6 @@ type OperationProperties struct { ServiceSpecification *OperationMetaServiceSpecification } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. -type OperationsClientListOptions struct { - // placeholder for future optional parameters -} - // Package - Device package data type Package struct { // Package name. @@ -873,43 +760,6 @@ type SensorProperties struct { TiVersion *string } -// SensorsClientCreateOrUpdateOptions contains the optional parameters for the SensorsClient.CreateOrUpdate method. -type SensorsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// SensorsClientDeleteOptions contains the optional parameters for the SensorsClient.Delete method. -type SensorsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// SensorsClientDownloadActivationOptions contains the optional parameters for the SensorsClient.DownloadActivation method. -type SensorsClientDownloadActivationOptions struct { - // placeholder for future optional parameters -} - -// SensorsClientDownloadResetPasswordOptions contains the optional parameters for the SensorsClient.DownloadResetPassword -// method. -type SensorsClientDownloadResetPasswordOptions struct { - // placeholder for future optional parameters -} - -// SensorsClientGetOptions contains the optional parameters for the SensorsClient.Get method. -type SensorsClientGetOptions struct { - // placeholder for future optional parameters -} - -// SensorsClientListOptions contains the optional parameters for the SensorsClient.List method. -type SensorsClientListOptions struct { - // placeholder for future optional parameters -} - -// SensorsClientTriggerTiPackageUpdateOptions contains the optional parameters for the SensorsClient.TriggerTiPackageUpdate -// method. -type SensorsClientTriggerTiPackageUpdateOptions struct { - // placeholder for future optional parameters -} - // SensorsList - List of IoT sensors type SensorsList struct { // READ-ONLY; List data @@ -943,26 +793,6 @@ type SiteProperties struct { Tags map[string]*string } -// SitesClientCreateOrUpdateOptions contains the optional parameters for the SitesClient.CreateOrUpdate method. -type SitesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// SitesClientDeleteOptions contains the optional parameters for the SitesClient.Delete method. -type SitesClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// SitesClientGetOptions contains the optional parameters for the SitesClient.Get method. -type SitesClientGetOptions struct { - // placeholder for future optional parameters -} - -// SitesClientListOptions contains the optional parameters for the SitesClient.List method. -type SitesClientListOptions struct { - // placeholder for future optional parameters -} - // SitesList - List of IoT sites type SitesList struct { // READ-ONLY; List data diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/models_serde.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/models_serde.go index ef8e4122829c..3551ffedd868 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/models_serde.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/models_serde.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armiotsecurity @@ -86,7 +85,7 @@ func (d *DefenderSettingsModel) UnmarshalJSON(data []byte) error { func (d DefenderSettingsProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "deviceQuota", d.DeviceQuota) - populateTimeRFC3339(objectMap, "evaluationEndTime", d.EvaluationEndTime) + populateDateTimeRFC3339(objectMap, "evaluationEndTime", d.EvaluationEndTime) populate(objectMap, "mdeIntegration", d.MdeIntegration) populate(objectMap, "onboardingKind", d.OnboardingKind) populate(objectMap, "sentinelWorkspaceResourceIds", d.SentinelWorkspaceResourceIDs) @@ -106,7 +105,7 @@ func (d *DefenderSettingsProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "DeviceQuota", &d.DeviceQuota) delete(rawMsg, key) case "evaluationEndTime": - err = unpopulateTimeRFC3339(val, "EvaluationEndTime", &d.EvaluationEndTime) + err = unpopulateDateTimeRFC3339(val, "EvaluationEndTime", &d.EvaluationEndTime) delete(rawMsg, key) case "mdeIntegration": err = unpopulate(val, "MdeIntegration", &d.MdeIntegration) @@ -319,11 +318,11 @@ func (d DeviceProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "deviceTypeDisplayName", d.DeviceTypeDisplayName) populate(objectMap, "deviceTypeId", d.DeviceTypeID) populate(objectMap, "firmwares", d.Firmwares) - populateTimeRFC3339(objectMap, "firstSeen", d.FirstSeen) + populateDateTimeRFC3339(objectMap, "firstSeen", d.FirstSeen) populate(objectMap, "hardware", d.Hardware) - populateTimeRFC3339(objectMap, "lastProgrammingTime", d.LastProgrammingTime) - populateTimeRFC3339(objectMap, "lastSeen", d.LastSeen) - populateTimeRFC3339(objectMap, "lastUpdated", d.LastUpdated) + populateDateTimeRFC3339(objectMap, "lastProgrammingTime", d.LastProgrammingTime) + populateDateTimeRFC3339(objectMap, "lastSeen", d.LastSeen) + populateDateTimeRFC3339(objectMap, "lastUpdated", d.LastUpdated) populate(objectMap, "mergedDevices", d.MergedDevices) populate(objectMap, "mergedToDeviceId", d.MergedToDeviceID) populate(objectMap, "nics", d.Nics) @@ -401,19 +400,19 @@ func (d *DeviceProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Firmwares", &d.Firmwares) delete(rawMsg, key) case "firstSeen": - err = unpopulateTimeRFC3339(val, "FirstSeen", &d.FirstSeen) + err = unpopulateDateTimeRFC3339(val, "FirstSeen", &d.FirstSeen) delete(rawMsg, key) case "hardware": err = unpopulate(val, "Hardware", &d.Hardware) delete(rawMsg, key) case "lastProgrammingTime": - err = unpopulateTimeRFC3339(val, "LastProgrammingTime", &d.LastProgrammingTime) + err = unpopulateDateTimeRFC3339(val, "LastProgrammingTime", &d.LastProgrammingTime) delete(rawMsg, key) case "lastSeen": - err = unpopulateTimeRFC3339(val, "LastSeen", &d.LastSeen) + err = unpopulateDateTimeRFC3339(val, "LastSeen", &d.LastSeen) delete(rawMsg, key) case "lastUpdated": - err = unpopulateTimeRFC3339(val, "LastUpdated", &d.LastUpdated) + err = unpopulateDateTimeRFC3339(val, "LastUpdated", &d.LastUpdated) delete(rawMsg, key) case "mergedDevices": err = unpopulate(val, "MergedDevices", &d.MergedDevices) @@ -908,7 +907,7 @@ func (n Nic) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "ipv4Address", n.IPv4Address) populate(objectMap, "ipv6Address", n.IPv6Address) - populateTimeRFC3339(objectMap, "lastSeen", n.LastSeen) + populateDateTimeRFC3339(objectMap, "lastSeen", n.LastSeen) populate(objectMap, "macAddress", n.MacAddress) populate(objectMap, "macCertainty", n.MacCertainty) populate(objectMap, "networkAdapterVendor", n.NetworkAdapterVendor) @@ -932,7 +931,7 @@ func (n *Nic) UnmarshalJSON(data []byte) error { err = unpopulate(val, "IPv6Address", &n.IPv6Address) delete(rawMsg, key) case "lastSeen": - err = unpopulateTimeRFC3339(val, "LastSeen", &n.LastSeen) + err = unpopulateDateTimeRFC3339(val, "LastSeen", &n.LastSeen) delete(rawMsg, key) case "macAddress": err = unpopulate(val, "MacAddress", &n.MacAddress) @@ -2107,10 +2106,10 @@ func (s *Slot) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) populate(objectMap, "lastModifiedBy", s.LastModifiedBy) populate(objectMap, "lastModifiedByType", s.LastModifiedByType) return json.Marshal(objectMap) @@ -2126,7 +2125,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { var err error switch key { case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) delete(rawMsg, key) case "createdBy": err = unpopulate(val, "CreatedBy", &s.CreatedBy) @@ -2135,7 +2134,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { err = unpopulate(val, "CreatedByType", &s.CreatedByType) delete(rawMsg, key) case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) delete(rawMsg, key) case "lastModifiedBy": err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/onpremisesensors_client.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/onpremisesensors_client.go index 021acc5f4bea..88ee4a4a9ea1 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/onpremisesensors_client.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/onpremisesensors_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armiotsecurity @@ -33,7 +32,7 @@ type OnPremiseSensorsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOnPremiseSensorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OnPremiseSensorsClient, error) { - cl, err := arm.NewClient(moduleName+".OnPremiseSensorsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -52,18 +51,25 @@ func NewOnPremiseSensorsClient(subscriptionID string, credential azcore.TokenCre // - options - OnPremiseSensorsClientCreateOrUpdateOptions contains the optional parameters for the OnPremiseSensorsClient.CreateOrUpdate // method. func (client *OnPremiseSensorsClient) CreateOrUpdate(ctx context.Context, onPremiseSensorName string, options *OnPremiseSensorsClientCreateOrUpdateOptions) (OnPremiseSensorsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "OnPremiseSensorsClient.CreateOrUpdate" + 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, onPremiseSensorName, options) if err != nil { return OnPremiseSensorsClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return OnPremiseSensorsClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return OnPremiseSensorsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return OnPremiseSensorsClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -104,16 +110,22 @@ func (client *OnPremiseSensorsClient) createOrUpdateHandleResponse(resp *http.Re // - onPremiseSensorName - Name of the on-premise IoT sensor // - options - OnPremiseSensorsClientDeleteOptions contains the optional parameters for the OnPremiseSensorsClient.Delete method. func (client *OnPremiseSensorsClient) Delete(ctx context.Context, onPremiseSensorName string, options *OnPremiseSensorsClientDeleteOptions) (OnPremiseSensorsClientDeleteResponse, error) { + var err error + const operationName = "OnPremiseSensorsClient.Delete" + 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, onPremiseSensorName, options) if err != nil { return OnPremiseSensorsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return OnPremiseSensorsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return OnPremiseSensorsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return OnPremiseSensorsClientDeleteResponse{}, err } return OnPremiseSensorsClientDeleteResponse{}, nil } @@ -148,18 +160,24 @@ func (client *OnPremiseSensorsClient) deleteCreateRequest(ctx context.Context, o // - options - OnPremiseSensorsClientDownloadActivationOptions contains the optional parameters for the OnPremiseSensorsClient.DownloadActivation // method. func (client *OnPremiseSensorsClient) DownloadActivation(ctx context.Context, onPremiseSensorName string, options *OnPremiseSensorsClientDownloadActivationOptions) (OnPremiseSensorsClientDownloadActivationResponse, error) { + var err error + const operationName = "OnPremiseSensorsClient.DownloadActivation" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.downloadActivationCreateRequest(ctx, onPremiseSensorName, options) if err != nil { return OnPremiseSensorsClientDownloadActivationResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return OnPremiseSensorsClientDownloadActivationResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OnPremiseSensorsClientDownloadActivationResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return OnPremiseSensorsClientDownloadActivationResponse{}, err } - return OnPremiseSensorsClientDownloadActivationResponse{Body: resp.Body}, nil + return OnPremiseSensorsClientDownloadActivationResponse{Body: httpResp.Body}, nil } // downloadActivationCreateRequest creates the DownloadActivation request. @@ -194,18 +212,24 @@ func (client *OnPremiseSensorsClient) downloadActivationCreateRequest(ctx contex // - options - OnPremiseSensorsClientDownloadResetPasswordOptions contains the optional parameters for the OnPremiseSensorsClient.DownloadResetPassword // method. func (client *OnPremiseSensorsClient) DownloadResetPassword(ctx context.Context, onPremiseSensorName string, body ResetPasswordInput, options *OnPremiseSensorsClientDownloadResetPasswordOptions) (OnPremiseSensorsClientDownloadResetPasswordResponse, error) { + var err error + const operationName = "OnPremiseSensorsClient.DownloadResetPassword" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.downloadResetPasswordCreateRequest(ctx, onPremiseSensorName, body, options) if err != nil { return OnPremiseSensorsClientDownloadResetPasswordResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return OnPremiseSensorsClientDownloadResetPasswordResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OnPremiseSensorsClientDownloadResetPasswordResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return OnPremiseSensorsClientDownloadResetPasswordResponse{}, err } - return OnPremiseSensorsClientDownloadResetPasswordResponse{Body: resp.Body}, nil + return OnPremiseSensorsClientDownloadResetPasswordResponse{Body: httpResp.Body}, nil } // downloadResetPasswordCreateRequest creates the DownloadResetPassword request. @@ -228,7 +252,10 @@ func (client *OnPremiseSensorsClient) downloadResetPasswordCreateRequest(ctx con req.Raw().URL.RawQuery = reqQP.Encode() runtime.SkipBodyDownload(req) req.Raw().Header["Accept"] = []string{"application/zip"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // Get - Get on-premise IoT sensor @@ -238,18 +265,25 @@ func (client *OnPremiseSensorsClient) downloadResetPasswordCreateRequest(ctx con // - onPremiseSensorName - Name of the on-premise IoT sensor // - options - OnPremiseSensorsClientGetOptions contains the optional parameters for the OnPremiseSensorsClient.Get method. func (client *OnPremiseSensorsClient) Get(ctx context.Context, onPremiseSensorName string, options *OnPremiseSensorsClientGetOptions) (OnPremiseSensorsClientGetResponse, error) { + var err error + const operationName = "OnPremiseSensorsClient.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, onPremiseSensorName, options) if err != nil { return OnPremiseSensorsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return OnPremiseSensorsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OnPremiseSensorsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return OnPremiseSensorsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -289,18 +323,25 @@ func (client *OnPremiseSensorsClient) getHandleResponse(resp *http.Response) (On // Generated from API version 2021-02-01-preview // - options - OnPremiseSensorsClientListOptions contains the optional parameters for the OnPremiseSensorsClient.List method. func (client *OnPremiseSensorsClient) List(ctx context.Context, options *OnPremiseSensorsClientListOptions) (OnPremiseSensorsClientListResponse, error) { + var err error + const operationName = "OnPremiseSensorsClient.List" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listCreateRequest(ctx, options) if err != nil { return OnPremiseSensorsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return OnPremiseSensorsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OnPremiseSensorsClientListResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return OnPremiseSensorsClientListResponse{}, err } - return client.listHandleResponse(resp) + resp, err := client.listHandleResponse(httpResp) + return resp, err } // listCreateRequest creates the List request. diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/onpremisesensors_client_example_test.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/onpremisesensors_client_example_test.go index 95a63480bd23..b4aa9d3f878c 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/onpremisesensors_client_example_test.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/onpremisesensors_client_example_test.go @@ -45,10 +45,10 @@ func ExampleOnPremiseSensorsClient_List() { // Properties: map[string]any{ // }, // SystemData: &armiotsecurity.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // CreatedBy: to.Ptr("string"), // CreatedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // LastModifiedBy: to.Ptr("string"), // LastModifiedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), // }, @@ -60,10 +60,10 @@ func ExampleOnPremiseSensorsClient_List() { // Properties: map[string]any{ // }, // SystemData: &armiotsecurity.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // CreatedBy: to.Ptr("string"), // CreatedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // LastModifiedBy: to.Ptr("string"), // LastModifiedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), // }, @@ -96,10 +96,10 @@ func ExampleOnPremiseSensorsClient_Get() { // Properties: map[string]any{ // }, // SystemData: &armiotsecurity.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // CreatedBy: to.Ptr("string"), // CreatedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // LastModifiedBy: to.Ptr("string"), // LastModifiedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), // }, @@ -131,10 +131,10 @@ func ExampleOnPremiseSensorsClient_CreateOrUpdate() { // Properties: map[string]any{ // }, // SystemData: &armiotsecurity.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // CreatedBy: to.Ptr("string"), // CreatedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // LastModifiedBy: to.Ptr("string"), // LastModifiedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), // }, diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/operations_client.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/operations_client.go index 4aafa53308a2..7bc26769c76e 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/operations_client.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/operations_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armiotsecurity @@ -28,7 +27,7 @@ type OperationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -48,25 +47,20 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.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, options) + }, nil) if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return OperationsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OperationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/options.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/options.go new file mode 100644 index 000000000000..eb02a1674418 --- /dev/null +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/options.go @@ -0,0 +1,178 @@ +//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 armiotsecurity + +// DefenderSettingsClientCreateOrUpdateOptions contains the optional parameters for the DefenderSettingsClient.CreateOrUpdate +// method. +type DefenderSettingsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// DefenderSettingsClientDeleteOptions contains the optional parameters for the DefenderSettingsClient.Delete method. +type DefenderSettingsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// DefenderSettingsClientDownloadManagerActivationOptions contains the optional parameters for the DefenderSettingsClient.DownloadManagerActivation +// method. +type DefenderSettingsClientDownloadManagerActivationOptions struct { + // placeholder for future optional parameters +} + +// DefenderSettingsClientGetOptions contains the optional parameters for the DefenderSettingsClient.Get method. +type DefenderSettingsClientGetOptions struct { + // placeholder for future optional parameters +} + +// DefenderSettingsClientListOptions contains the optional parameters for the DefenderSettingsClient.List method. +type DefenderSettingsClientListOptions struct { + // placeholder for future optional parameters +} + +// DefenderSettingsClientPackageDownloadsOptions contains the optional parameters for the DefenderSettingsClient.PackageDownloads +// method. +type DefenderSettingsClientPackageDownloadsOptions struct { + // placeholder for future optional parameters +} + +// DeviceGroupsClientCreateOrUpdateOptions contains the optional parameters for the DeviceGroupsClient.CreateOrUpdate method. +type DeviceGroupsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// DeviceGroupsClientDeleteOptions contains the optional parameters for the DeviceGroupsClient.Delete method. +type DeviceGroupsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// DeviceGroupsClientGetOptions contains the optional parameters for the DeviceGroupsClient.Get method. +type DeviceGroupsClientGetOptions struct { + // placeholder for future optional parameters +} + +// DeviceGroupsClientListOptions contains the optional parameters for the DeviceGroupsClient.NewListPager method. +type DeviceGroupsClientListOptions struct { + // placeholder for future optional parameters +} + +// DevicesClientGetOptions contains the optional parameters for the DevicesClient.Get method. +type DevicesClientGetOptions struct { + // placeholder for future optional parameters +} + +// DevicesClientListOptions contains the optional parameters for the DevicesClient.NewListPager method. +type DevicesClientListOptions struct { + // Skip token used for pagination + SkipToken *string +} + +// LocationsClientGetOptions contains the optional parameters for the LocationsClient.Get method. +type LocationsClientGetOptions struct { + // placeholder for future optional parameters +} + +// LocationsClientListOptions contains the optional parameters for the LocationsClient.NewListPager method. +type LocationsClientListOptions struct { + // placeholder for future optional parameters +} + +// OnPremiseSensorsClientCreateOrUpdateOptions contains the optional parameters for the OnPremiseSensorsClient.CreateOrUpdate +// method. +type OnPremiseSensorsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// OnPremiseSensorsClientDeleteOptions contains the optional parameters for the OnPremiseSensorsClient.Delete method. +type OnPremiseSensorsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// OnPremiseSensorsClientDownloadActivationOptions contains the optional parameters for the OnPremiseSensorsClient.DownloadActivation +// method. +type OnPremiseSensorsClientDownloadActivationOptions struct { + // placeholder for future optional parameters +} + +// OnPremiseSensorsClientDownloadResetPasswordOptions contains the optional parameters for the OnPremiseSensorsClient.DownloadResetPassword +// method. +type OnPremiseSensorsClientDownloadResetPasswordOptions struct { + // placeholder for future optional parameters +} + +// OnPremiseSensorsClientGetOptions contains the optional parameters for the OnPremiseSensorsClient.Get method. +type OnPremiseSensorsClientGetOptions struct { + // placeholder for future optional parameters +} + +// OnPremiseSensorsClientListOptions contains the optional parameters for the OnPremiseSensorsClient.List method. +type OnPremiseSensorsClientListOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// SensorsClientCreateOrUpdateOptions contains the optional parameters for the SensorsClient.CreateOrUpdate method. +type SensorsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// SensorsClientDeleteOptions contains the optional parameters for the SensorsClient.Delete method. +type SensorsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// SensorsClientDownloadActivationOptions contains the optional parameters for the SensorsClient.DownloadActivation method. +type SensorsClientDownloadActivationOptions struct { + // placeholder for future optional parameters +} + +// SensorsClientDownloadResetPasswordOptions contains the optional parameters for the SensorsClient.DownloadResetPassword +// method. +type SensorsClientDownloadResetPasswordOptions struct { + // placeholder for future optional parameters +} + +// SensorsClientGetOptions contains the optional parameters for the SensorsClient.Get method. +type SensorsClientGetOptions struct { + // placeholder for future optional parameters +} + +// SensorsClientListOptions contains the optional parameters for the SensorsClient.List method. +type SensorsClientListOptions struct { + // placeholder for future optional parameters +} + +// SensorsClientTriggerTiPackageUpdateOptions contains the optional parameters for the SensorsClient.TriggerTiPackageUpdate +// method. +type SensorsClientTriggerTiPackageUpdateOptions struct { + // placeholder for future optional parameters +} + +// SitesClientCreateOrUpdateOptions contains the optional parameters for the SitesClient.CreateOrUpdate method. +type SitesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// SitesClientDeleteOptions contains the optional parameters for the SitesClient.Delete method. +type SitesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// SitesClientGetOptions contains the optional parameters for the SitesClient.Get method. +type SitesClientGetOptions struct { + // placeholder for future optional parameters +} + +// SitesClientListOptions contains the optional parameters for the SitesClient.List method. +type SitesClientListOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/response_types.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/response_types.go index 8460c1340793..f28b57b98d2f 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/response_types.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/response_types.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armiotsecurity @@ -13,6 +12,7 @@ import "io" // DefenderSettingsClientCreateOrUpdateResponse contains the response from method DefenderSettingsClient.CreateOrUpdate. type DefenderSettingsClientCreateOrUpdateResponse struct { + // IoT Defender settings DefenderSettingsModel } @@ -29,21 +29,25 @@ type DefenderSettingsClientDownloadManagerActivationResponse struct { // DefenderSettingsClientGetResponse contains the response from method DefenderSettingsClient.Get. type DefenderSettingsClientGetResponse struct { + // IoT Defender settings DefenderSettingsModel } // DefenderSettingsClientListResponse contains the response from method DefenderSettingsClient.List. type DefenderSettingsClientListResponse struct { + // List of IoT Defender settings DefenderSettingsList } // DefenderSettingsClientPackageDownloadsResponse contains the response from method DefenderSettingsClient.PackageDownloads. type DefenderSettingsClientPackageDownloadsResponse struct { + // Information about package downloads PackageDownloads } // DeviceGroupsClientCreateOrUpdateResponse contains the response from method DeviceGroupsClient.CreateOrUpdate. type DeviceGroupsClientCreateOrUpdateResponse struct { + // Device group DeviceGroupModel } @@ -54,36 +58,43 @@ type DeviceGroupsClientDeleteResponse struct { // DeviceGroupsClientGetResponse contains the response from method DeviceGroupsClient.Get. type DeviceGroupsClientGetResponse struct { + // Device group DeviceGroupModel } // DeviceGroupsClientListResponse contains the response from method DeviceGroupsClient.NewListPager. type DeviceGroupsClientListResponse struct { + // List of device groups DeviceGroupList } // DevicesClientGetResponse contains the response from method DevicesClient.Get. type DevicesClientGetResponse struct { + // Device DeviceModel } // DevicesClientListResponse contains the response from method DevicesClient.NewListPager. type DevicesClientListResponse struct { + // List of devices DeviceList } // LocationsClientGetResponse contains the response from method LocationsClient.Get. type LocationsClientGetResponse struct { + // IoT Defender location LocationModel } // LocationsClientListResponse contains the response from method LocationsClient.NewListPager. type LocationsClientListResponse struct { + // List of Defender for IoT locations LocationList } // OnPremiseSensorsClientCreateOrUpdateResponse contains the response from method OnPremiseSensorsClient.CreateOrUpdate. type OnPremiseSensorsClientCreateOrUpdateResponse struct { + // On-premise IoT sensor OnPremiseSensor } @@ -106,21 +117,25 @@ type OnPremiseSensorsClientDownloadResetPasswordResponse struct { // OnPremiseSensorsClientGetResponse contains the response from method OnPremiseSensorsClient.Get. type OnPremiseSensorsClientGetResponse struct { + // On-premise IoT sensor OnPremiseSensor } // OnPremiseSensorsClientListResponse contains the response from method OnPremiseSensorsClient.List. type OnPremiseSensorsClientListResponse struct { + // List of on-premise IoT sensors OnPremiseSensorsList } // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { + // Paged list of operation resources OperationList } // SensorsClientCreateOrUpdateResponse contains the response from method SensorsClient.CreateOrUpdate. type SensorsClientCreateOrUpdateResponse struct { + // IoT sensor model SensorModel } @@ -143,11 +158,13 @@ type SensorsClientDownloadResetPasswordResponse struct { // SensorsClientGetResponse contains the response from method SensorsClient.Get. type SensorsClientGetResponse struct { + // IoT sensor model SensorModel } // SensorsClientListResponse contains the response from method SensorsClient.List. type SensorsClientListResponse struct { + // List of IoT sensors SensorsList } @@ -158,6 +175,7 @@ type SensorsClientTriggerTiPackageUpdateResponse struct { // SitesClientCreateOrUpdateResponse contains the response from method SitesClient.CreateOrUpdate. type SitesClientCreateOrUpdateResponse struct { + // IoT site model SiteModel } @@ -168,10 +186,12 @@ type SitesClientDeleteResponse struct { // SitesClientGetResponse contains the response from method SitesClient.Get. type SitesClientGetResponse struct { + // IoT site model SiteModel } // SitesClientListResponse contains the response from method SitesClient.List. type SitesClientListResponse struct { + // List of IoT sites SitesList } diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/sensors_client.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/sensors_client.go index 484236f88b8d..101a4b0019ed 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/sensors_client.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/sensors_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armiotsecurity @@ -31,7 +30,7 @@ type SensorsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSensorsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SensorsClient, error) { - cl, err := arm.NewClient(moduleName+".SensorsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -50,18 +49,25 @@ func NewSensorsClient(credential azcore.TokenCredential, options *arm.ClientOpti // - sensorModel - The IoT sensor model // - options - SensorsClientCreateOrUpdateOptions contains the optional parameters for the SensorsClient.CreateOrUpdate method. func (client *SensorsClient) CreateOrUpdate(ctx context.Context, scope string, sensorName string, sensorModel SensorModel, options *SensorsClientCreateOrUpdateOptions) (SensorsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "SensorsClient.CreateOrUpdate" + 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, scope, sensorName, sensorModel, options) if err != nil { return SensorsClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SensorsClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return SensorsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return SensorsClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -80,7 +86,10 @@ func (client *SensorsClient) createOrUpdateCreateRequest(ctx context.Context, sc reqQP.Set("api-version", "2021-02-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, sensorModel) + if err := runtime.MarshalAsJSON(req, sensorModel); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -100,16 +109,22 @@ func (client *SensorsClient) createOrUpdateHandleResponse(resp *http.Response) ( // - sensorName - Name of the IoT sensor // - options - SensorsClientDeleteOptions contains the optional parameters for the SensorsClient.Delete method. func (client *SensorsClient) Delete(ctx context.Context, scope string, sensorName string, options *SensorsClientDeleteOptions) (SensorsClientDeleteResponse, error) { + var err error + const operationName = "SensorsClient.Delete" + 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, scope, sensorName, options) if err != nil { return SensorsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SensorsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return SensorsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return SensorsClientDeleteResponse{}, err } return SensorsClientDeleteResponse{}, nil } @@ -142,18 +157,24 @@ func (client *SensorsClient) deleteCreateRequest(ctx context.Context, scope stri // - options - SensorsClientDownloadActivationOptions contains the optional parameters for the SensorsClient.DownloadActivation // method. func (client *SensorsClient) DownloadActivation(ctx context.Context, scope string, sensorName string, options *SensorsClientDownloadActivationOptions) (SensorsClientDownloadActivationResponse, error) { + var err error + const operationName = "SensorsClient.DownloadActivation" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.downloadActivationCreateRequest(ctx, scope, sensorName, options) if err != nil { return SensorsClientDownloadActivationResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SensorsClientDownloadActivationResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SensorsClientDownloadActivationResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SensorsClientDownloadActivationResponse{}, err } - return SensorsClientDownloadActivationResponse{Body: resp.Body}, nil + return SensorsClientDownloadActivationResponse{Body: httpResp.Body}, nil } // downloadActivationCreateRequest creates the DownloadActivation request. @@ -186,18 +207,24 @@ func (client *SensorsClient) downloadActivationCreateRequest(ctx context.Context // - options - SensorsClientDownloadResetPasswordOptions contains the optional parameters for the SensorsClient.DownloadResetPassword // method. func (client *SensorsClient) DownloadResetPassword(ctx context.Context, scope string, sensorName string, body ResetPasswordInput, options *SensorsClientDownloadResetPasswordOptions) (SensorsClientDownloadResetPasswordResponse, error) { + var err error + const operationName = "SensorsClient.DownloadResetPassword" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.downloadResetPasswordCreateRequest(ctx, scope, sensorName, body, options) if err != nil { return SensorsClientDownloadResetPasswordResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SensorsClientDownloadResetPasswordResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SensorsClientDownloadResetPasswordResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SensorsClientDownloadResetPasswordResponse{}, err } - return SensorsClientDownloadResetPasswordResponse{Body: resp.Body}, nil + return SensorsClientDownloadResetPasswordResponse{Body: httpResp.Body}, nil } // downloadResetPasswordCreateRequest creates the DownloadResetPassword request. @@ -217,7 +244,10 @@ func (client *SensorsClient) downloadResetPasswordCreateRequest(ctx context.Cont req.Raw().URL.RawQuery = reqQP.Encode() runtime.SkipBodyDownload(req) req.Raw().Header["Accept"] = []string{"application/zip"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // Get - Get IoT sensor @@ -228,18 +258,25 @@ func (client *SensorsClient) downloadResetPasswordCreateRequest(ctx context.Cont // - sensorName - Name of the IoT sensor // - options - SensorsClientGetOptions contains the optional parameters for the SensorsClient.Get method. func (client *SensorsClient) Get(ctx context.Context, scope string, sensorName string, options *SensorsClientGetOptions) (SensorsClientGetResponse, error) { + var err error + const operationName = "SensorsClient.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, scope, sensorName, options) if err != nil { return SensorsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SensorsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SensorsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SensorsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -277,18 +314,25 @@ func (client *SensorsClient) getHandleResponse(resp *http.Response) (SensorsClie // - scope - Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) // - options - SensorsClientListOptions contains the optional parameters for the SensorsClient.List method. func (client *SensorsClient) List(ctx context.Context, scope string, options *SensorsClientListOptions) (SensorsClientListResponse, error) { + var err error + const operationName = "SensorsClient.List" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listCreateRequest(ctx, scope, options) if err != nil { return SensorsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SensorsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SensorsClientListResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SensorsClientListResponse{}, err } - return client.listHandleResponse(resp) + resp, err := client.listHandleResponse(httpResp) + return resp, err } // listCreateRequest creates the List request. @@ -324,16 +368,22 @@ func (client *SensorsClient) listHandleResponse(resp *http.Response) (SensorsCli // - options - SensorsClientTriggerTiPackageUpdateOptions contains the optional parameters for the SensorsClient.TriggerTiPackageUpdate // method. func (client *SensorsClient) TriggerTiPackageUpdate(ctx context.Context, scope string, sensorName string, options *SensorsClientTriggerTiPackageUpdateOptions) (SensorsClientTriggerTiPackageUpdateResponse, error) { + var err error + const operationName = "SensorsClient.TriggerTiPackageUpdate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.triggerTiPackageUpdateCreateRequest(ctx, scope, sensorName, options) if err != nil { return SensorsClientTriggerTiPackageUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SensorsClientTriggerTiPackageUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SensorsClientTriggerTiPackageUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SensorsClientTriggerTiPackageUpdateResponse{}, err } return SensorsClientTriggerTiPackageUpdateResponse{}, nil } diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/sensors_client_example_test.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/sensors_client_example_test.go index 1a909b5f6648..5cee0d80e715 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/sensors_client_example_test.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/sensors_client_example_test.go @@ -55,10 +55,10 @@ func ExampleSensorsClient_List() { // Zone: to.Ptr("Zone Name"), // }, // SystemData: &armiotsecurity.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // CreatedBy: to.Ptr("string"), // CreatedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // LastModifiedBy: to.Ptr("string"), // LastModifiedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), // }, @@ -80,10 +80,10 @@ func ExampleSensorsClient_List() { // Zone: to.Ptr("Zone Name"), // }, // SystemData: &armiotsecurity.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // CreatedBy: to.Ptr("string"), // CreatedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // LastModifiedBy: to.Ptr("string"), // LastModifiedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), // }, @@ -126,10 +126,10 @@ func ExampleSensorsClient_Get() { // Zone: to.Ptr("Zone Name"), // }, // SystemData: &armiotsecurity.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // CreatedBy: to.Ptr("string"), // CreatedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // LastModifiedBy: to.Ptr("string"), // LastModifiedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), // }, diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/sites_client.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/sites_client.go index dda37aa20f88..74693cd7331b 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/sites_client.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/sites_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armiotsecurity @@ -29,7 +28,7 @@ type SitesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSitesClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*SitesClient, error) { - cl, err := arm.NewClient(moduleName+".SitesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,18 +46,25 @@ func NewSitesClient(credential azcore.TokenCredential, options *arm.ClientOption // - siteModel - The IoT sites model // - options - SitesClientCreateOrUpdateOptions contains the optional parameters for the SitesClient.CreateOrUpdate method. func (client *SitesClient) CreateOrUpdate(ctx context.Context, scope string, siteModel SiteModel, options *SitesClientCreateOrUpdateOptions) (SitesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "SitesClient.CreateOrUpdate" + 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, scope, siteModel, options) if err != nil { return SitesClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SitesClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return SitesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return SitesClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -73,7 +79,10 @@ func (client *SitesClient) createOrUpdateCreateRequest(ctx context.Context, scop reqQP.Set("api-version", "2021-02-01-preview") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, siteModel) + if err := runtime.MarshalAsJSON(req, siteModel); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -92,16 +101,22 @@ func (client *SitesClient) createOrUpdateHandleResponse(resp *http.Response) (Si // - scope - Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) // - options - SitesClientDeleteOptions contains the optional parameters for the SitesClient.Delete method. func (client *SitesClient) Delete(ctx context.Context, scope string, options *SitesClientDeleteOptions) (SitesClientDeleteResponse, error) { + var err error + const operationName = "SitesClient.Delete" + 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, scope, options) if err != nil { return SitesClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SitesClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return SitesClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return SitesClientDeleteResponse{}, err } return SitesClientDeleteResponse{}, nil } @@ -128,18 +143,25 @@ func (client *SitesClient) deleteCreateRequest(ctx context.Context, scope string // - scope - Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) // - options - SitesClientGetOptions contains the optional parameters for the SitesClient.Get method. func (client *SitesClient) Get(ctx context.Context, scope string, options *SitesClientGetOptions) (SitesClientGetResponse, error) { + var err error + const operationName = "SitesClient.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, scope, options) if err != nil { return SitesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SitesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SitesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SitesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -173,18 +195,25 @@ func (client *SitesClient) getHandleResponse(resp *http.Response) (SitesClientGe // - scope - Scope of the query (IoT Hub, /providers/Microsoft.Devices/iotHubs/myHub) // - options - SitesClientListOptions contains the optional parameters for the SitesClient.List method. func (client *SitesClient) List(ctx context.Context, scope string, options *SitesClientListOptions) (SitesClientListResponse, error) { + var err error + const operationName = "SitesClient.List" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listCreateRequest(ctx, scope, options) if err != nil { return SitesClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SitesClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SitesClientListResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SitesClientListResponse{}, err } - return client.listHandleResponse(resp) + resp, err := client.listHandleResponse(httpResp) + return resp, err } // listCreateRequest creates the List request. diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/sites_client_example_test.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/sites_client_example_test.go index 753320e63904..c2c7f24e091f 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/sites_client_example_test.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/sites_client_example_test.go @@ -50,10 +50,10 @@ func ExampleSitesClient_List() { // }, // }, // SystemData: &armiotsecurity.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // CreatedBy: to.Ptr("string"), // CreatedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // LastModifiedBy: to.Ptr("string"), // LastModifiedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), // }, @@ -91,10 +91,10 @@ func ExampleSitesClient_Get() { // }, // }, // SystemData: &armiotsecurity.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // CreatedBy: to.Ptr("string"), // CreatedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // LastModifiedBy: to.Ptr("string"), // LastModifiedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), // }, @@ -139,10 +139,10 @@ func ExampleSitesClient_CreateOrUpdate() { // }, // }, // SystemData: &armiotsecurity.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // CreatedBy: to.Ptr("string"), // CreatedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.0928001Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-04-27T21:53:29.092Z"); return t}()), // LastModifiedBy: to.Ptr("string"), // LastModifiedByType: to.Ptr(armiotsecurity.CreatedByTypeUser), // }, diff --git a/sdk/resourcemanager/iotsecurity/armiotsecurity/time_rfc3339.go b/sdk/resourcemanager/iotsecurity/armiotsecurity/time_rfc3339.go index d339dbb43f9b..221241eee620 100644 --- a/sdk/resourcemanager/iotsecurity/armiotsecurity/time_rfc3339.go +++ b/sdk/resourcemanager/iotsecurity/armiotsecurity/time_rfc3339.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armiotsecurity @@ -19,50 +18,50 @@ import ( "time" ) -const ( - utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` - utcLayout = "2006-01-02T15:04:05.999999999" - rfc3339JSON = `"` + time.RFC3339Nano + `"` -) - // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) -type timeRFC3339 time.Time +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time -func (t timeRFC3339) MarshalJSON() (json []byte, err error) { +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { tt := time.Time(t) return tt.MarshalJSON() } -func (t timeRFC3339) MarshalText() (text []byte, err error) { +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { tt := time.Time(t) return tt.MarshalText() } -func (t *timeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcLayoutJSON +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON if tzOffsetRegex.Match(data) { - layout = rfc3339JSON + layout = dateTimeJSON } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { - layout := utcLayout +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime if tzOffsetRegex.Match(data) { layout = time.RFC3339Nano } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) Parse(layout, value string) error { +func (t *dateTimeRFC3339) Parse(layout, value string) error { p, err := time.Parse(layout, strings.ToUpper(value)) - *t = timeRFC3339(p) + *t = dateTimeRFC3339(p) return err } -func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { @@ -71,14 +70,14 @@ func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { } else if reflect.ValueOf(t).IsNil() { return } - m[k] = (*timeRFC3339)(t) + m[k] = (*dateTimeRFC3339)(t) } -func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { if data == nil || strings.EqualFold(string(data), "null") { return nil } - var aux timeRFC3339 + var aux dateTimeRFC3339 if err := json.Unmarshal(data, &aux); err != nil { return fmt.Errorf("struct field %s: %v", fn, err) } diff --git a/sdk/resourcemanager/keyvault/armkeyvault/CHANGELOG.md b/sdk/resourcemanager/keyvault/armkeyvault/CHANGELOG.md index b0776fae40bf..77a737e73c98 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/CHANGELOG.md +++ b/sdk/resourcemanager/keyvault/armkeyvault/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.4.0 (2023-11-24) +### Features Added + +- Support for test fakes and OpenTelemetry trace spans. + + ## 1.3.0 (2023-10-27) ### Features Added diff --git a/sdk/resourcemanager/keyvault/armkeyvault/README.md b/sdk/resourcemanager/keyvault/armkeyvault/README.md index 11dbffa467a4..c394a2d4329e 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/README.md +++ b/sdk/resourcemanager/keyvault/armkeyvault/README.md @@ -60,6 +60,13 @@ A client groups a set of related APIs, providing access to its functionality. C client := clientFactory.NewVaultsClient() ``` +## 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. + ## More sample code - [Key](https://aka.ms/azsdk/go/mgmt/samples?path=sdk/resourcemanager/keyvault/key) diff --git a/sdk/resourcemanager/keyvault/armkeyvault/assets.json b/sdk/resourcemanager/keyvault/armkeyvault/assets.json index 0849394ce6a2..84f2859a2209 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/assets.json +++ b/sdk/resourcemanager/keyvault/armkeyvault/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "go", "TagPrefix": "go/resourcemanager/keyvault/armkeyvault", - "Tag": "go/resourcemanager/keyvault/armkeyvault_5d94ebc7b4" + "Tag": "go/resourcemanager/keyvault/armkeyvault_820248387e" } diff --git a/sdk/resourcemanager/keyvault/armkeyvault/autorest.md b/sdk/resourcemanager/keyvault/armkeyvault/autorest.md index 15e504d5c454..25de347af4e2 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/autorest.md +++ b/sdk/resourcemanager/keyvault/armkeyvault/autorest.md @@ -8,7 +8,7 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/keyvault/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/keyvault/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.3.0 +module-version: 1.4.0 modelerfour: seal-single-value-enum-by-default: true tag: package-2023-07 diff --git a/sdk/resourcemanager/keyvault/armkeyvault/client_factory.go b/sdk/resourcemanager/keyvault/armkeyvault/client_factory.go index d5f33c14a1d8..90daa8e6f23b 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/client_factory.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/client_factory.go @@ -28,7 +28,7 @@ type ClientFactory struct { // - 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+".ClientFactory", moduleVersion, credential, options) + _, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -38,56 +38,67 @@ func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, }, nil } +// NewKeysClient creates a new instance of KeysClient. func (c *ClientFactory) NewKeysClient() *KeysClient { subClient, _ := NewKeysClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewMHSMPrivateEndpointConnectionsClient creates a new instance of MHSMPrivateEndpointConnectionsClient. func (c *ClientFactory) NewMHSMPrivateEndpointConnectionsClient() *MHSMPrivateEndpointConnectionsClient { subClient, _ := NewMHSMPrivateEndpointConnectionsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewMHSMPrivateLinkResourcesClient creates a new instance of MHSMPrivateLinkResourcesClient. func (c *ClientFactory) NewMHSMPrivateLinkResourcesClient() *MHSMPrivateLinkResourcesClient { subClient, _ := NewMHSMPrivateLinkResourcesClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewMHSMRegionsClient creates a new instance of MHSMRegionsClient. func (c *ClientFactory) NewMHSMRegionsClient() *MHSMRegionsClient { subClient, _ := NewMHSMRegionsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewManagedHsmKeysClient creates a new instance of ManagedHsmKeysClient. func (c *ClientFactory) NewManagedHsmKeysClient() *ManagedHsmKeysClient { subClient, _ := NewManagedHsmKeysClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewManagedHsmsClient creates a new instance of ManagedHsmsClient. func (c *ClientFactory) NewManagedHsmsClient() *ManagedHsmsClient { subClient, _ := NewManagedHsmsClient(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 } +// NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient. func (c *ClientFactory) NewPrivateEndpointConnectionsClient() *PrivateEndpointConnectionsClient { subClient, _ := NewPrivateEndpointConnectionsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient. func (c *ClientFactory) NewPrivateLinkResourcesClient() *PrivateLinkResourcesClient { subClient, _ := NewPrivateLinkResourcesClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewSecretsClient creates a new instance of SecretsClient. func (c *ClientFactory) NewSecretsClient() *SecretsClient { subClient, _ := NewSecretsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewVaultsClient creates a new instance of VaultsClient. func (c *ClientFactory) NewVaultsClient() *VaultsClient { subClient, _ := NewVaultsClient(c.subscriptionID, c.credential, c.options) return subClient diff --git a/sdk/resourcemanager/keyvault/armkeyvault/constants.go b/sdk/resourcemanager/keyvault/armkeyvault/constants.go index 92c123908d75..0d763ddfb848 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/constants.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/constants.go @@ -9,8 +9,8 @@ package armkeyvault const ( - moduleName = "armkeyvault" - moduleVersion = "v1.3.0" + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvault" + moduleVersion = "v1.4.0" ) type AccessPolicyUpdateKind string diff --git a/sdk/resourcemanager/keyvault/armkeyvault/fake/internal.go b/sdk/resourcemanager/keyvault/armkeyvault/fake/internal.go new file mode 100644 index 000000000000..ce49c535df47 --- /dev/null +++ b/sdk/resourcemanager/keyvault/armkeyvault/fake/internal.go @@ -0,0 +1,83 @@ +//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 ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "sync" +) + +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 parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) { + if v == "" { + return nil, nil + } + t, err := parse(v) + if err != nil { + return nil, err + } + return &t, err +} + +func parseWithCast[T any](v string, parse func(v string) (T, error)) (T, error) { + t, err := parse(v) + if err != nil { + return *new(T), err + } + return t, err +} + +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/keyvault/armkeyvault/fake/keys_server.go b/sdk/resourcemanager/keyvault/armkeyvault/fake/keys_server.go new file mode 100644 index 000000000000..cee1f883df2c --- /dev/null +++ b/sdk/resourcemanager/keyvault/armkeyvault/fake/keys_server.go @@ -0,0 +1,303 @@ +//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/keyvault/armkeyvault" + "net/http" + "net/url" + "regexp" +) + +// KeysServer is a fake server for instances of the armkeyvault.KeysClient type. +type KeysServer struct { + // CreateIfNotExist is the fake for method KeysClient.CreateIfNotExist + // HTTP status codes to indicate success: http.StatusOK + CreateIfNotExist func(ctx context.Context, resourceGroupName string, vaultName string, keyName string, parameters armkeyvault.KeyCreateParameters, options *armkeyvault.KeysClientCreateIfNotExistOptions) (resp azfake.Responder[armkeyvault.KeysClientCreateIfNotExistResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method KeysClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, vaultName string, keyName string, options *armkeyvault.KeysClientGetOptions) (resp azfake.Responder[armkeyvault.KeysClientGetResponse], errResp azfake.ErrorResponder) + + // GetVersion is the fake for method KeysClient.GetVersion + // HTTP status codes to indicate success: http.StatusOK + GetVersion func(ctx context.Context, resourceGroupName string, vaultName string, keyName string, keyVersion string, options *armkeyvault.KeysClientGetVersionOptions) (resp azfake.Responder[armkeyvault.KeysClientGetVersionResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method KeysClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, vaultName string, options *armkeyvault.KeysClientListOptions) (resp azfake.PagerResponder[armkeyvault.KeysClientListResponse]) + + // NewListVersionsPager is the fake for method KeysClient.NewListVersionsPager + // HTTP status codes to indicate success: http.StatusOK + NewListVersionsPager func(resourceGroupName string, vaultName string, keyName string, options *armkeyvault.KeysClientListVersionsOptions) (resp azfake.PagerResponder[armkeyvault.KeysClientListVersionsResponse]) +} + +// NewKeysServerTransport creates a new instance of KeysServerTransport with the provided implementation. +// The returned KeysServerTransport instance is connected to an instance of armkeyvault.KeysClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewKeysServerTransport(srv *KeysServer) *KeysServerTransport { + return &KeysServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armkeyvault.KeysClientListResponse]](), + newListVersionsPager: newTracker[azfake.PagerResponder[armkeyvault.KeysClientListVersionsResponse]](), + } +} + +// KeysServerTransport connects instances of armkeyvault.KeysClient to instances of KeysServer. +// Don't use this type directly, use NewKeysServerTransport instead. +type KeysServerTransport struct { + srv *KeysServer + newListPager *tracker[azfake.PagerResponder[armkeyvault.KeysClientListResponse]] + newListVersionsPager *tracker[azfake.PagerResponder[armkeyvault.KeysClientListVersionsResponse]] +} + +// Do implements the policy.Transporter interface for KeysServerTransport. +func (k *KeysServerTransport) 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 "KeysClient.CreateIfNotExist": + resp, err = k.dispatchCreateIfNotExist(req) + case "KeysClient.Get": + resp, err = k.dispatchGet(req) + case "KeysClient.GetVersion": + resp, err = k.dispatchGetVersion(req) + case "KeysClient.NewListPager": + resp, err = k.dispatchNewListPager(req) + case "KeysClient.NewListVersionsPager": + resp, err = k.dispatchNewListVersionsPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (k *KeysServerTransport) dispatchCreateIfNotExist(req *http.Request) (*http.Response, error) { + if k.srv.CreateIfNotExist == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateIfNotExist not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/vaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/keys/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkeyvault.KeyCreateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + keyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("keyName")]) + if err != nil { + return nil, err + } + respr, errRespr := k.srv.CreateIfNotExist(req.Context(), resourceGroupNameParam, vaultNameParam, keyNameParam, 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).Key, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (k *KeysServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if k.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\.KeyVault/vaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/keys/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + keyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("keyName")]) + if err != nil { + return nil, err + } + respr, errRespr := k.srv.Get(req.Context(), resourceGroupNameParam, vaultNameParam, keyNameParam, 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).Key, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (k *KeysServerTransport) dispatchGetVersion(req *http.Request) (*http.Response, error) { + if k.srv.GetVersion == nil { + return nil, &nonRetriableError{errors.New("fake for method GetVersion not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/vaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/keys/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + keyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("keyName")]) + if err != nil { + return nil, err + } + keyVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("keyVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := k.srv.GetVersion(req.Context(), resourceGroupNameParam, vaultNameParam, keyNameParam, keyVersionParam, 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).Key, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (k *KeysServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if k.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := k.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/vaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/keys` + 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 + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + resp := k.srv.NewListPager(resourceGroupNameParam, vaultNameParam, nil) + newListPager = &resp + k.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armkeyvault.KeysClientListResponse, 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) { + k.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + k.newListPager.remove(req) + } + return resp, nil +} + +func (k *KeysServerTransport) dispatchNewListVersionsPager(req *http.Request) (*http.Response, error) { + if k.srv.NewListVersionsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListVersionsPager not implemented")} + } + newListVersionsPager := k.newListVersionsPager.get(req) + if newListVersionsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/vaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/keys/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + keyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("keyName")]) + if err != nil { + return nil, err + } + resp := k.srv.NewListVersionsPager(resourceGroupNameParam, vaultNameParam, keyNameParam, nil) + newListVersionsPager = &resp + k.newListVersionsPager.add(req, newListVersionsPager) + server.PagerResponderInjectNextLinks(newListVersionsPager, req, func(page *armkeyvault.KeysClientListVersionsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListVersionsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + k.newListVersionsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListVersionsPager) { + k.newListVersionsPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/keyvault/armkeyvault/fake/managedhsmkeys_server.go b/sdk/resourcemanager/keyvault/armkeyvault/fake/managedhsmkeys_server.go new file mode 100644 index 000000000000..c15f266ab367 --- /dev/null +++ b/sdk/resourcemanager/keyvault/armkeyvault/fake/managedhsmkeys_server.go @@ -0,0 +1,303 @@ +//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/keyvault/armkeyvault" + "net/http" + "net/url" + "regexp" +) + +// ManagedHsmKeysServer is a fake server for instances of the armkeyvault.ManagedHsmKeysClient type. +type ManagedHsmKeysServer struct { + // CreateIfNotExist is the fake for method ManagedHsmKeysClient.CreateIfNotExist + // HTTP status codes to indicate success: http.StatusOK + CreateIfNotExist func(ctx context.Context, resourceGroupName string, name string, keyName string, parameters armkeyvault.ManagedHsmKeyCreateParameters, options *armkeyvault.ManagedHsmKeysClientCreateIfNotExistOptions) (resp azfake.Responder[armkeyvault.ManagedHsmKeysClientCreateIfNotExistResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ManagedHsmKeysClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, name string, keyName string, options *armkeyvault.ManagedHsmKeysClientGetOptions) (resp azfake.Responder[armkeyvault.ManagedHsmKeysClientGetResponse], errResp azfake.ErrorResponder) + + // GetVersion is the fake for method ManagedHsmKeysClient.GetVersion + // HTTP status codes to indicate success: http.StatusOK + GetVersion func(ctx context.Context, resourceGroupName string, name string, keyName string, keyVersion string, options *armkeyvault.ManagedHsmKeysClientGetVersionOptions) (resp azfake.Responder[armkeyvault.ManagedHsmKeysClientGetVersionResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method ManagedHsmKeysClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, name string, options *armkeyvault.ManagedHsmKeysClientListOptions) (resp azfake.PagerResponder[armkeyvault.ManagedHsmKeysClientListResponse]) + + // NewListVersionsPager is the fake for method ManagedHsmKeysClient.NewListVersionsPager + // HTTP status codes to indicate success: http.StatusOK + NewListVersionsPager func(resourceGroupName string, name string, keyName string, options *armkeyvault.ManagedHsmKeysClientListVersionsOptions) (resp azfake.PagerResponder[armkeyvault.ManagedHsmKeysClientListVersionsResponse]) +} + +// NewManagedHsmKeysServerTransport creates a new instance of ManagedHsmKeysServerTransport with the provided implementation. +// The returned ManagedHsmKeysServerTransport instance is connected to an instance of armkeyvault.ManagedHsmKeysClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewManagedHsmKeysServerTransport(srv *ManagedHsmKeysServer) *ManagedHsmKeysServerTransport { + return &ManagedHsmKeysServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armkeyvault.ManagedHsmKeysClientListResponse]](), + newListVersionsPager: newTracker[azfake.PagerResponder[armkeyvault.ManagedHsmKeysClientListVersionsResponse]](), + } +} + +// ManagedHsmKeysServerTransport connects instances of armkeyvault.ManagedHsmKeysClient to instances of ManagedHsmKeysServer. +// Don't use this type directly, use NewManagedHsmKeysServerTransport instead. +type ManagedHsmKeysServerTransport struct { + srv *ManagedHsmKeysServer + newListPager *tracker[azfake.PagerResponder[armkeyvault.ManagedHsmKeysClientListResponse]] + newListVersionsPager *tracker[azfake.PagerResponder[armkeyvault.ManagedHsmKeysClientListVersionsResponse]] +} + +// Do implements the policy.Transporter interface for ManagedHsmKeysServerTransport. +func (m *ManagedHsmKeysServerTransport) 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 "ManagedHsmKeysClient.CreateIfNotExist": + resp, err = m.dispatchCreateIfNotExist(req) + case "ManagedHsmKeysClient.Get": + resp, err = m.dispatchGet(req) + case "ManagedHsmKeysClient.GetVersion": + resp, err = m.dispatchGetVersion(req) + case "ManagedHsmKeysClient.NewListPager": + resp, err = m.dispatchNewListPager(req) + case "ManagedHsmKeysClient.NewListVersionsPager": + resp, err = m.dispatchNewListVersionsPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *ManagedHsmKeysServerTransport) dispatchCreateIfNotExist(req *http.Request) (*http.Response, error) { + if m.srv.CreateIfNotExist == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateIfNotExist not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/managedHSMs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/keys/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkeyvault.ManagedHsmKeyCreateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + keyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("keyName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.CreateIfNotExist(req.Context(), resourceGroupNameParam, nameParam, keyNameParam, 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).ManagedHsmKey, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (m *ManagedHsmKeysServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if m.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\.KeyVault/managedHSMs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/keys/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + keyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("keyName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.Get(req.Context(), resourceGroupNameParam, nameParam, keyNameParam, 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).ManagedHsmKey, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (m *ManagedHsmKeysServerTransport) dispatchGetVersion(req *http.Request) (*http.Response, error) { + if m.srv.GetVersion == nil { + return nil, &nonRetriableError{errors.New("fake for method GetVersion not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/managedHSMs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/keys/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + keyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("keyName")]) + if err != nil { + return nil, err + } + keyVersionParam, err := url.PathUnescape(matches[regex.SubexpIndex("keyVersion")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.GetVersion(req.Context(), resourceGroupNameParam, nameParam, keyNameParam, keyVersionParam, 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).ManagedHsmKey, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (m *ManagedHsmKeysServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if m.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := m.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/managedHSMs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/keys` + 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 + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + resp := m.srv.NewListPager(resourceGroupNameParam, nameParam, nil) + newListPager = &resp + m.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armkeyvault.ManagedHsmKeysClientListResponse, 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) { + m.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + m.newListPager.remove(req) + } + return resp, nil +} + +func (m *ManagedHsmKeysServerTransport) dispatchNewListVersionsPager(req *http.Request) (*http.Response, error) { + if m.srv.NewListVersionsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListVersionsPager not implemented")} + } + newListVersionsPager := m.newListVersionsPager.get(req) + if newListVersionsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/managedHSMs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/keys/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + keyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("keyName")]) + if err != nil { + return nil, err + } + resp := m.srv.NewListVersionsPager(resourceGroupNameParam, nameParam, keyNameParam, nil) + newListVersionsPager = &resp + m.newListVersionsPager.add(req, newListVersionsPager) + server.PagerResponderInjectNextLinks(newListVersionsPager, req, func(page *armkeyvault.ManagedHsmKeysClientListVersionsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListVersionsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + m.newListVersionsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListVersionsPager) { + m.newListVersionsPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/keyvault/armkeyvault/fake/managedhsms_server.go b/sdk/resourcemanager/keyvault/armkeyvault/fake/managedhsms_server.go new file mode 100644 index 000000000000..1662b5ea735c --- /dev/null +++ b/sdk/resourcemanager/keyvault/armkeyvault/fake/managedhsms_server.go @@ -0,0 +1,563 @@ +//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/keyvault/armkeyvault" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// ManagedHsmsServer is a fake server for instances of the armkeyvault.ManagedHsmsClient type. +type ManagedHsmsServer struct { + // CheckMhsmNameAvailability is the fake for method ManagedHsmsClient.CheckMhsmNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckMhsmNameAvailability func(ctx context.Context, mhsmName armkeyvault.CheckMhsmNameAvailabilityParameters, options *armkeyvault.ManagedHsmsClientCheckMhsmNameAvailabilityOptions) (resp azfake.Responder[armkeyvault.ManagedHsmsClientCheckMhsmNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method ManagedHsmsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, name string, parameters armkeyvault.ManagedHsm, options *armkeyvault.ManagedHsmsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armkeyvault.ManagedHsmsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method ManagedHsmsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, name string, options *armkeyvault.ManagedHsmsClientBeginDeleteOptions) (resp azfake.PollerResponder[armkeyvault.ManagedHsmsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ManagedHsmsClient.Get + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Get func(ctx context.Context, resourceGroupName string, name string, options *armkeyvault.ManagedHsmsClientGetOptions) (resp azfake.Responder[armkeyvault.ManagedHsmsClientGetResponse], errResp azfake.ErrorResponder) + + // GetDeleted is the fake for method ManagedHsmsClient.GetDeleted + // HTTP status codes to indicate success: http.StatusOK + GetDeleted func(ctx context.Context, name string, location string, options *armkeyvault.ManagedHsmsClientGetDeletedOptions) (resp azfake.Responder[armkeyvault.ManagedHsmsClientGetDeletedResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method ManagedHsmsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armkeyvault.ManagedHsmsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armkeyvault.ManagedHsmsClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method ManagedHsmsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armkeyvault.ManagedHsmsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armkeyvault.ManagedHsmsClientListBySubscriptionResponse]) + + // NewListDeletedPager is the fake for method ManagedHsmsClient.NewListDeletedPager + // HTTP status codes to indicate success: http.StatusOK + NewListDeletedPager func(options *armkeyvault.ManagedHsmsClientListDeletedOptions) (resp azfake.PagerResponder[armkeyvault.ManagedHsmsClientListDeletedResponse]) + + // BeginPurgeDeleted is the fake for method ManagedHsmsClient.BeginPurgeDeleted + // HTTP status codes to indicate success: http.StatusAccepted + BeginPurgeDeleted func(ctx context.Context, name string, location string, options *armkeyvault.ManagedHsmsClientBeginPurgeDeletedOptions) (resp azfake.PollerResponder[armkeyvault.ManagedHsmsClientPurgeDeletedResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method ManagedHsmsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, name string, parameters armkeyvault.ManagedHsm, options *armkeyvault.ManagedHsmsClientBeginUpdateOptions) (resp azfake.PollerResponder[armkeyvault.ManagedHsmsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewManagedHsmsServerTransport creates a new instance of ManagedHsmsServerTransport with the provided implementation. +// The returned ManagedHsmsServerTransport instance is connected to an instance of armkeyvault.ManagedHsmsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewManagedHsmsServerTransport(srv *ManagedHsmsServer) *ManagedHsmsServerTransport { + return &ManagedHsmsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armkeyvault.ManagedHsmsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armkeyvault.ManagedHsmsClientDeleteResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armkeyvault.ManagedHsmsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armkeyvault.ManagedHsmsClientListBySubscriptionResponse]](), + newListDeletedPager: newTracker[azfake.PagerResponder[armkeyvault.ManagedHsmsClientListDeletedResponse]](), + beginPurgeDeleted: newTracker[azfake.PollerResponder[armkeyvault.ManagedHsmsClientPurgeDeletedResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armkeyvault.ManagedHsmsClientUpdateResponse]](), + } +} + +// ManagedHsmsServerTransport connects instances of armkeyvault.ManagedHsmsClient to instances of ManagedHsmsServer. +// Don't use this type directly, use NewManagedHsmsServerTransport instead. +type ManagedHsmsServerTransport struct { + srv *ManagedHsmsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armkeyvault.ManagedHsmsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armkeyvault.ManagedHsmsClientDeleteResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armkeyvault.ManagedHsmsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armkeyvault.ManagedHsmsClientListBySubscriptionResponse]] + newListDeletedPager *tracker[azfake.PagerResponder[armkeyvault.ManagedHsmsClientListDeletedResponse]] + beginPurgeDeleted *tracker[azfake.PollerResponder[armkeyvault.ManagedHsmsClientPurgeDeletedResponse]] + beginUpdate *tracker[azfake.PollerResponder[armkeyvault.ManagedHsmsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for ManagedHsmsServerTransport. +func (m *ManagedHsmsServerTransport) 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 "ManagedHsmsClient.CheckMhsmNameAvailability": + resp, err = m.dispatchCheckMhsmNameAvailability(req) + case "ManagedHsmsClient.BeginCreateOrUpdate": + resp, err = m.dispatchBeginCreateOrUpdate(req) + case "ManagedHsmsClient.BeginDelete": + resp, err = m.dispatchBeginDelete(req) + case "ManagedHsmsClient.Get": + resp, err = m.dispatchGet(req) + case "ManagedHsmsClient.GetDeleted": + resp, err = m.dispatchGetDeleted(req) + case "ManagedHsmsClient.NewListByResourceGroupPager": + resp, err = m.dispatchNewListByResourceGroupPager(req) + case "ManagedHsmsClient.NewListBySubscriptionPager": + resp, err = m.dispatchNewListBySubscriptionPager(req) + case "ManagedHsmsClient.NewListDeletedPager": + resp, err = m.dispatchNewListDeletedPager(req) + case "ManagedHsmsClient.BeginPurgeDeleted": + resp, err = m.dispatchBeginPurgeDeleted(req) + case "ManagedHsmsClient.BeginUpdate": + resp, err = m.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *ManagedHsmsServerTransport) dispatchCheckMhsmNameAvailability(req *http.Request) (*http.Response, error) { + if m.srv.CheckMhsmNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckMhsmNameAvailability not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/checkMhsmNameAvailability` + 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[armkeyvault.CheckMhsmNameAvailabilityParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.CheckMhsmNameAvailability(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).CheckMhsmNameAvailabilityResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (m *ManagedHsmsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if m.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := m.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/managedHSMs/(?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[armkeyvault.ManagedHsm](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, nameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + m.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + m.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + m.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (m *ManagedHsmsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if m.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := m.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/managedHSMs/(?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 + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.BeginDelete(req.Context(), resourceGroupNameParam, nameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + m.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) { + m.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) { + m.beginDelete.remove(req) + } + + return resp, nil +} + +func (m *ManagedHsmsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if m.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\.KeyVault/managedHSMs/(?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 + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.Get(req.Context(), resourceGroupNameParam, nameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ManagedHsm, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (m *ManagedHsmsServerTransport) dispatchGetDeleted(req *http.Request) (*http.Response, error) { + if m.srv.GetDeleted == nil { + return nil, &nonRetriableError{errors.New("fake for method GetDeleted not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deletedManagedHSMs/(?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) + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.GetDeleted(req.Context(), nameParam, locationParam, 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).DeletedManagedHsm, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (m *ManagedHsmsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if m.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := m.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/managedHSMs` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armkeyvault.ManagedHsmsClientListByResourceGroupOptions + if topParam != nil { + options = &armkeyvault.ManagedHsmsClientListByResourceGroupOptions{ + Top: topParam, + } + } + resp := m.srv.NewListByResourceGroupPager(resourceGroupNameParam, options) + newListByResourceGroupPager = &resp + m.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armkeyvault.ManagedHsmsClientListByResourceGroupResponse, 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) { + m.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + m.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (m *ManagedHsmsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if m.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := m.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/managedHSMs` + 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) + } + qp := req.URL.Query() + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armkeyvault.ManagedHsmsClientListBySubscriptionOptions + if topParam != nil { + options = &armkeyvault.ManagedHsmsClientListBySubscriptionOptions{ + Top: topParam, + } + } + resp := m.srv.NewListBySubscriptionPager(options) + newListBySubscriptionPager = &resp + m.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armkeyvault.ManagedHsmsClientListBySubscriptionResponse, 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) { + m.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + m.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (m *ManagedHsmsServerTransport) dispatchNewListDeletedPager(req *http.Request) (*http.Response, error) { + if m.srv.NewListDeletedPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListDeletedPager not implemented")} + } + newListDeletedPager := m.newListDeletedPager.get(req) + if newListDeletedPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/deletedManagedHSMs` + 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 := m.srv.NewListDeletedPager(nil) + newListDeletedPager = &resp + m.newListDeletedPager.add(req, newListDeletedPager) + server.PagerResponderInjectNextLinks(newListDeletedPager, req, func(page *armkeyvault.ManagedHsmsClientListDeletedResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListDeletedPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + m.newListDeletedPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListDeletedPager) { + m.newListDeletedPager.remove(req) + } + return resp, nil +} + +func (m *ManagedHsmsServerTransport) dispatchBeginPurgeDeleted(req *http.Request) (*http.Response, error) { + if m.srv.BeginPurgeDeleted == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginPurgeDeleted not implemented")} + } + beginPurgeDeleted := m.beginPurgeDeleted.get(req) + if beginPurgeDeleted == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deletedManagedHSMs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/purge` + 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) + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.BeginPurgeDeleted(req.Context(), nameParam, locationParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginPurgeDeleted = &respr + m.beginPurgeDeleted.add(req, beginPurgeDeleted) + } + + resp, err := server.PollerResponderNext(beginPurgeDeleted, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted}, resp.StatusCode) { + m.beginPurgeDeleted.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginPurgeDeleted) { + m.beginPurgeDeleted.remove(req) + } + + return resp, nil +} + +func (m *ManagedHsmsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if m.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := m.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/managedHSMs/(?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[armkeyvault.ManagedHsm](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.BeginUpdate(req.Context(), resourceGroupNameParam, nameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + m.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) { + m.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) { + m.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/keyvault/armkeyvault/fake/mhsmprivateendpointconnections_server.go b/sdk/resourcemanager/keyvault/armkeyvault/fake/mhsmprivateendpointconnections_server.go new file mode 100644 index 000000000000..fa9ad7cec2c9 --- /dev/null +++ b/sdk/resourcemanager/keyvault/armkeyvault/fake/mhsmprivateendpointconnections_server.go @@ -0,0 +1,266 @@ +//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/keyvault/armkeyvault" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// MHSMPrivateEndpointConnectionsServer is a fake server for instances of the armkeyvault.MHSMPrivateEndpointConnectionsClient type. +type MHSMPrivateEndpointConnectionsServer struct { + // BeginDelete is the fake for method MHSMPrivateEndpointConnectionsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, name string, privateEndpointConnectionName string, options *armkeyvault.MHSMPrivateEndpointConnectionsClientBeginDeleteOptions) (resp azfake.PollerResponder[armkeyvault.MHSMPrivateEndpointConnectionsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method MHSMPrivateEndpointConnectionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, name string, privateEndpointConnectionName string, options *armkeyvault.MHSMPrivateEndpointConnectionsClientGetOptions) (resp azfake.Responder[armkeyvault.MHSMPrivateEndpointConnectionsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourcePager is the fake for method MHSMPrivateEndpointConnectionsClient.NewListByResourcePager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourcePager func(resourceGroupName string, name string, options *armkeyvault.MHSMPrivateEndpointConnectionsClientListByResourceOptions) (resp azfake.PagerResponder[armkeyvault.MHSMPrivateEndpointConnectionsClientListByResourceResponse]) + + // Put is the fake for method MHSMPrivateEndpointConnectionsClient.Put + // HTTP status codes to indicate success: http.StatusOK + Put func(ctx context.Context, resourceGroupName string, name string, privateEndpointConnectionName string, properties armkeyvault.MHSMPrivateEndpointConnection, options *armkeyvault.MHSMPrivateEndpointConnectionsClientPutOptions) (resp azfake.Responder[armkeyvault.MHSMPrivateEndpointConnectionsClientPutResponse], errResp azfake.ErrorResponder) +} + +// NewMHSMPrivateEndpointConnectionsServerTransport creates a new instance of MHSMPrivateEndpointConnectionsServerTransport with the provided implementation. +// The returned MHSMPrivateEndpointConnectionsServerTransport instance is connected to an instance of armkeyvault.MHSMPrivateEndpointConnectionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewMHSMPrivateEndpointConnectionsServerTransport(srv *MHSMPrivateEndpointConnectionsServer) *MHSMPrivateEndpointConnectionsServerTransport { + return &MHSMPrivateEndpointConnectionsServerTransport{ + srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armkeyvault.MHSMPrivateEndpointConnectionsClientDeleteResponse]](), + newListByResourcePager: newTracker[azfake.PagerResponder[armkeyvault.MHSMPrivateEndpointConnectionsClientListByResourceResponse]](), + } +} + +// MHSMPrivateEndpointConnectionsServerTransport connects instances of armkeyvault.MHSMPrivateEndpointConnectionsClient to instances of MHSMPrivateEndpointConnectionsServer. +// Don't use this type directly, use NewMHSMPrivateEndpointConnectionsServerTransport instead. +type MHSMPrivateEndpointConnectionsServerTransport struct { + srv *MHSMPrivateEndpointConnectionsServer + beginDelete *tracker[azfake.PollerResponder[armkeyvault.MHSMPrivateEndpointConnectionsClientDeleteResponse]] + newListByResourcePager *tracker[azfake.PagerResponder[armkeyvault.MHSMPrivateEndpointConnectionsClientListByResourceResponse]] +} + +// Do implements the policy.Transporter interface for MHSMPrivateEndpointConnectionsServerTransport. +func (m *MHSMPrivateEndpointConnectionsServerTransport) 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 "MHSMPrivateEndpointConnectionsClient.BeginDelete": + resp, err = m.dispatchBeginDelete(req) + case "MHSMPrivateEndpointConnectionsClient.Get": + resp, err = m.dispatchGet(req) + case "MHSMPrivateEndpointConnectionsClient.NewListByResourcePager": + resp, err = m.dispatchNewListByResourcePager(req) + case "MHSMPrivateEndpointConnectionsClient.Put": + resp, err = m.dispatchPut(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *MHSMPrivateEndpointConnectionsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if m.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := m.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/managedHSMs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.BeginDelete(req.Context(), resourceGroupNameParam, nameParam, privateEndpointConnectionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + m.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) { + m.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) { + m.beginDelete.remove(req) + } + + return resp, nil +} + +func (m *MHSMPrivateEndpointConnectionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if m.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\.KeyVault/managedHSMs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.Get(req.Context(), resourceGroupNameParam, nameParam, privateEndpointConnectionNameParam, 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).MHSMPrivateEndpointConnection, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (m *MHSMPrivateEndpointConnectionsServerTransport) dispatchNewListByResourcePager(req *http.Request) (*http.Response, error) { + if m.srv.NewListByResourcePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourcePager not implemented")} + } + newListByResourcePager := m.newListByResourcePager.get(req) + if newListByResourcePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/managedHSMs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections` + 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 + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + resp := m.srv.NewListByResourcePager(resourceGroupNameParam, nameParam, nil) + newListByResourcePager = &resp + m.newListByResourcePager.add(req, newListByResourcePager) + server.PagerResponderInjectNextLinks(newListByResourcePager, req, func(page *armkeyvault.MHSMPrivateEndpointConnectionsClientListByResourceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourcePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + m.newListByResourcePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourcePager) { + m.newListByResourcePager.remove(req) + } + return resp, nil +} + +func (m *MHSMPrivateEndpointConnectionsServerTransport) dispatchPut(req *http.Request) (*http.Response, error) { + if m.srv.Put == nil { + return nil, &nonRetriableError{errors.New("fake for method Put not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/managedHSMs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkeyvault.MHSMPrivateEndpointConnection](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.Put(req.Context(), resourceGroupNameParam, nameParam, privateEndpointConnectionNameParam, 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).MHSMPrivateEndpointConnection, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).AzureAsyncOperation; val != nil { + resp.Header.Set("Azure-AsyncOperation", *val) + } + if val := server.GetResponse(respr).RetryAfter; val != nil { + resp.Header.Set("Retry-After", strconv.FormatInt(int64(*val), 10)) + } + return resp, nil +} diff --git a/sdk/resourcemanager/keyvault/armkeyvault/fake/mhsmprivatelinkresources_server.go b/sdk/resourcemanager/keyvault/armkeyvault/fake/mhsmprivatelinkresources_server.go new file mode 100644 index 000000000000..512e6b1cd42c --- /dev/null +++ b/sdk/resourcemanager/keyvault/armkeyvault/fake/mhsmprivatelinkresources_server.go @@ -0,0 +1,100 @@ +//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/resourcemanager/keyvault/armkeyvault" + "net/http" + "net/url" + "regexp" +) + +// MHSMPrivateLinkResourcesServer is a fake server for instances of the armkeyvault.MHSMPrivateLinkResourcesClient type. +type MHSMPrivateLinkResourcesServer struct { + // ListByMHSMResource is the fake for method MHSMPrivateLinkResourcesClient.ListByMHSMResource + // HTTP status codes to indicate success: http.StatusOK + ListByMHSMResource func(ctx context.Context, resourceGroupName string, name string, options *armkeyvault.MHSMPrivateLinkResourcesClientListByMHSMResourceOptions) (resp azfake.Responder[armkeyvault.MHSMPrivateLinkResourcesClientListByMHSMResourceResponse], errResp azfake.ErrorResponder) +} + +// NewMHSMPrivateLinkResourcesServerTransport creates a new instance of MHSMPrivateLinkResourcesServerTransport with the provided implementation. +// The returned MHSMPrivateLinkResourcesServerTransport instance is connected to an instance of armkeyvault.MHSMPrivateLinkResourcesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewMHSMPrivateLinkResourcesServerTransport(srv *MHSMPrivateLinkResourcesServer) *MHSMPrivateLinkResourcesServerTransport { + return &MHSMPrivateLinkResourcesServerTransport{srv: srv} +} + +// MHSMPrivateLinkResourcesServerTransport connects instances of armkeyvault.MHSMPrivateLinkResourcesClient to instances of MHSMPrivateLinkResourcesServer. +// Don't use this type directly, use NewMHSMPrivateLinkResourcesServerTransport instead. +type MHSMPrivateLinkResourcesServerTransport struct { + srv *MHSMPrivateLinkResourcesServer +} + +// Do implements the policy.Transporter interface for MHSMPrivateLinkResourcesServerTransport. +func (m *MHSMPrivateLinkResourcesServerTransport) 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 "MHSMPrivateLinkResourcesClient.ListByMHSMResource": + resp, err = m.dispatchListByMHSMResource(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *MHSMPrivateLinkResourcesServerTransport) dispatchListByMHSMResource(req *http.Request) (*http.Response, error) { + if m.srv.ListByMHSMResource == nil { + return nil, &nonRetriableError{errors.New("fake for method ListByMHSMResource not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/managedHSMs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources` + 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 + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.ListByMHSMResource(req.Context(), resourceGroupNameParam, nameParam, 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).MHSMPrivateLinkResourceListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/keyvault/armkeyvault/fake/mhsmregions_server.go b/sdk/resourcemanager/keyvault/armkeyvault/fake/mhsmregions_server.go new file mode 100644 index 000000000000..b8d77f1c2f8a --- /dev/null +++ b/sdk/resourcemanager/keyvault/armkeyvault/fake/mhsmregions_server.go @@ -0,0 +1,112 @@ +//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 ( + "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/keyvault/armkeyvault" + "net/http" + "net/url" + "regexp" +) + +// MHSMRegionsServer is a fake server for instances of the armkeyvault.MHSMRegionsClient type. +type MHSMRegionsServer struct { + // NewListByResourcePager is the fake for method MHSMRegionsClient.NewListByResourcePager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourcePager func(resourceGroupName string, name string, options *armkeyvault.MHSMRegionsClientListByResourceOptions) (resp azfake.PagerResponder[armkeyvault.MHSMRegionsClientListByResourceResponse]) +} + +// NewMHSMRegionsServerTransport creates a new instance of MHSMRegionsServerTransport with the provided implementation. +// The returned MHSMRegionsServerTransport instance is connected to an instance of armkeyvault.MHSMRegionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewMHSMRegionsServerTransport(srv *MHSMRegionsServer) *MHSMRegionsServerTransport { + return &MHSMRegionsServerTransport{ + srv: srv, + newListByResourcePager: newTracker[azfake.PagerResponder[armkeyvault.MHSMRegionsClientListByResourceResponse]](), + } +} + +// MHSMRegionsServerTransport connects instances of armkeyvault.MHSMRegionsClient to instances of MHSMRegionsServer. +// Don't use this type directly, use NewMHSMRegionsServerTransport instead. +type MHSMRegionsServerTransport struct { + srv *MHSMRegionsServer + newListByResourcePager *tracker[azfake.PagerResponder[armkeyvault.MHSMRegionsClientListByResourceResponse]] +} + +// Do implements the policy.Transporter interface for MHSMRegionsServerTransport. +func (m *MHSMRegionsServerTransport) 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 "MHSMRegionsClient.NewListByResourcePager": + resp, err = m.dispatchNewListByResourcePager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *MHSMRegionsServerTransport) dispatchNewListByResourcePager(req *http.Request) (*http.Response, error) { + if m.srv.NewListByResourcePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourcePager not implemented")} + } + newListByResourcePager := m.newListByResourcePager.get(req) + if newListByResourcePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/managedHSMs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/regions` + 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 + } + nameParam, err := url.PathUnescape(matches[regex.SubexpIndex("name")]) + if err != nil { + return nil, err + } + resp := m.srv.NewListByResourcePager(resourceGroupNameParam, nameParam, nil) + newListByResourcePager = &resp + m.newListByResourcePager.add(req, newListByResourcePager) + server.PagerResponderInjectNextLinks(newListByResourcePager, req, func(page *armkeyvault.MHSMRegionsClientListByResourceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourcePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + m.newListByResourcePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourcePager) { + m.newListByResourcePager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/keyvault/armkeyvault/fake/operations_server.go b/sdk/resourcemanager/keyvault/armkeyvault/fake/operations_server.go new file mode 100644 index 000000000000..114904a07caf --- /dev/null +++ b/sdk/resourcemanager/keyvault/armkeyvault/fake/operations_server.go @@ -0,0 +1,96 @@ +//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 ( + "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/keyvault/armkeyvault" + "net/http" +) + +// OperationsServer is a fake server for instances of the armkeyvault.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armkeyvault.OperationsClientListOptions) (resp azfake.PagerResponder[armkeyvault.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armkeyvault.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[armkeyvault.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armkeyvault.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armkeyvault.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) 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 "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armkeyvault.OperationsClientListResponse, 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) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/keyvault/armkeyvault/fake/privateendpointconnections_server.go b/sdk/resourcemanager/keyvault/armkeyvault/fake/privateendpointconnections_server.go new file mode 100644 index 000000000000..4d2ffec1674c --- /dev/null +++ b/sdk/resourcemanager/keyvault/armkeyvault/fake/privateendpointconnections_server.go @@ -0,0 +1,266 @@ +//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/keyvault/armkeyvault" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// PrivateEndpointConnectionsServer is a fake server for instances of the armkeyvault.PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsServer struct { + // BeginDelete is the fake for method PrivateEndpointConnectionsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, vaultName string, privateEndpointConnectionName string, options *armkeyvault.PrivateEndpointConnectionsClientBeginDeleteOptions) (resp azfake.PollerResponder[armkeyvault.PrivateEndpointConnectionsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method PrivateEndpointConnectionsClient.Get + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Get func(ctx context.Context, resourceGroupName string, vaultName string, privateEndpointConnectionName string, options *armkeyvault.PrivateEndpointConnectionsClientGetOptions) (resp azfake.Responder[armkeyvault.PrivateEndpointConnectionsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourcePager is the fake for method PrivateEndpointConnectionsClient.NewListByResourcePager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourcePager func(resourceGroupName string, vaultName string, options *armkeyvault.PrivateEndpointConnectionsClientListByResourceOptions) (resp azfake.PagerResponder[armkeyvault.PrivateEndpointConnectionsClientListByResourceResponse]) + + // Put is the fake for method PrivateEndpointConnectionsClient.Put + // HTTP status codes to indicate success: http.StatusOK + Put func(ctx context.Context, resourceGroupName string, vaultName string, privateEndpointConnectionName string, properties armkeyvault.PrivateEndpointConnection, options *armkeyvault.PrivateEndpointConnectionsClientPutOptions) (resp azfake.Responder[armkeyvault.PrivateEndpointConnectionsClientPutResponse], errResp azfake.ErrorResponder) +} + +// NewPrivateEndpointConnectionsServerTransport creates a new instance of PrivateEndpointConnectionsServerTransport with the provided implementation. +// The returned PrivateEndpointConnectionsServerTransport instance is connected to an instance of armkeyvault.PrivateEndpointConnectionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPrivateEndpointConnectionsServerTransport(srv *PrivateEndpointConnectionsServer) *PrivateEndpointConnectionsServerTransport { + return &PrivateEndpointConnectionsServerTransport{ + srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armkeyvault.PrivateEndpointConnectionsClientDeleteResponse]](), + newListByResourcePager: newTracker[azfake.PagerResponder[armkeyvault.PrivateEndpointConnectionsClientListByResourceResponse]](), + } +} + +// PrivateEndpointConnectionsServerTransport connects instances of armkeyvault.PrivateEndpointConnectionsClient to instances of PrivateEndpointConnectionsServer. +// Don't use this type directly, use NewPrivateEndpointConnectionsServerTransport instead. +type PrivateEndpointConnectionsServerTransport struct { + srv *PrivateEndpointConnectionsServer + beginDelete *tracker[azfake.PollerResponder[armkeyvault.PrivateEndpointConnectionsClientDeleteResponse]] + newListByResourcePager *tracker[azfake.PagerResponder[armkeyvault.PrivateEndpointConnectionsClientListByResourceResponse]] +} + +// Do implements the policy.Transporter interface for PrivateEndpointConnectionsServerTransport. +func (p *PrivateEndpointConnectionsServerTransport) 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 "PrivateEndpointConnectionsClient.BeginDelete": + resp, err = p.dispatchBeginDelete(req) + case "PrivateEndpointConnectionsClient.Get": + resp, err = p.dispatchGet(req) + case "PrivateEndpointConnectionsClient.NewListByResourcePager": + resp, err = p.dispatchNewListByResourcePager(req) + case "PrivateEndpointConnectionsClient.Put": + resp, err = p.dispatchPut(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if p.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := p.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/vaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginDelete(req.Context(), resourceGroupNameParam, vaultNameParam, privateEndpointConnectionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + p.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) { + p.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) { + p.beginDelete.remove(req) + } + + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.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\.KeyVault/vaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, vaultNameParam, privateEndpointConnectionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).PrivateEndpointConnection, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchNewListByResourcePager(req *http.Request) (*http.Response, error) { + if p.srv.NewListByResourcePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourcePager not implemented")} + } + newListByResourcePager := p.newListByResourcePager.get(req) + if newListByResourcePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/vaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections` + 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 + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListByResourcePager(resourceGroupNameParam, vaultNameParam, nil) + newListByResourcePager = &resp + p.newListByResourcePager.add(req, newListByResourcePager) + server.PagerResponderInjectNextLinks(newListByResourcePager, req, func(page *armkeyvault.PrivateEndpointConnectionsClientListByResourceResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourcePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListByResourcePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourcePager) { + p.newListByResourcePager.remove(req) + } + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchPut(req *http.Request) (*http.Response, error) { + if p.srv.Put == nil { + return nil, &nonRetriableError{errors.New("fake for method Put not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/vaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkeyvault.PrivateEndpointConnection](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Put(req.Context(), resourceGroupNameParam, vaultNameParam, privateEndpointConnectionNameParam, 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).PrivateEndpointConnection, req) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).AzureAsyncOperation; val != nil { + resp.Header.Set("Azure-AsyncOperation", *val) + } + if val := server.GetResponse(respr).RetryAfter; val != nil { + resp.Header.Set("Retry-After", strconv.FormatInt(int64(*val), 10)) + } + return resp, nil +} diff --git a/sdk/resourcemanager/keyvault/armkeyvault/fake/privatelinkresources_server.go b/sdk/resourcemanager/keyvault/armkeyvault/fake/privatelinkresources_server.go new file mode 100644 index 000000000000..437fc755279c --- /dev/null +++ b/sdk/resourcemanager/keyvault/armkeyvault/fake/privatelinkresources_server.go @@ -0,0 +1,100 @@ +//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/resourcemanager/keyvault/armkeyvault" + "net/http" + "net/url" + "regexp" +) + +// PrivateLinkResourcesServer is a fake server for instances of the armkeyvault.PrivateLinkResourcesClient type. +type PrivateLinkResourcesServer struct { + // ListByVault is the fake for method PrivateLinkResourcesClient.ListByVault + // HTTP status codes to indicate success: http.StatusOK + ListByVault func(ctx context.Context, resourceGroupName string, vaultName string, options *armkeyvault.PrivateLinkResourcesClientListByVaultOptions) (resp azfake.Responder[armkeyvault.PrivateLinkResourcesClientListByVaultResponse], errResp azfake.ErrorResponder) +} + +// NewPrivateLinkResourcesServerTransport creates a new instance of PrivateLinkResourcesServerTransport with the provided implementation. +// The returned PrivateLinkResourcesServerTransport instance is connected to an instance of armkeyvault.PrivateLinkResourcesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPrivateLinkResourcesServerTransport(srv *PrivateLinkResourcesServer) *PrivateLinkResourcesServerTransport { + return &PrivateLinkResourcesServerTransport{srv: srv} +} + +// PrivateLinkResourcesServerTransport connects instances of armkeyvault.PrivateLinkResourcesClient to instances of PrivateLinkResourcesServer. +// Don't use this type directly, use NewPrivateLinkResourcesServerTransport instead. +type PrivateLinkResourcesServerTransport struct { + srv *PrivateLinkResourcesServer +} + +// Do implements the policy.Transporter interface for PrivateLinkResourcesServerTransport. +func (p *PrivateLinkResourcesServerTransport) 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 "PrivateLinkResourcesClient.ListByVault": + resp, err = p.dispatchListByVault(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (p *PrivateLinkResourcesServerTransport) dispatchListByVault(req *http.Request) (*http.Response, error) { + if p.srv.ListByVault == nil { + return nil, &nonRetriableError{errors.New("fake for method ListByVault not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/vaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources` + 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 + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.ListByVault(req.Context(), resourceGroupNameParam, vaultNameParam, 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).PrivateLinkResourceListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/keyvault/armkeyvault/fake/secrets_server.go b/sdk/resourcemanager/keyvault/armkeyvault/fake/secrets_server.go new file mode 100644 index 000000000000..78c5068fe0fa --- /dev/null +++ b/sdk/resourcemanager/keyvault/armkeyvault/fake/secrets_server.go @@ -0,0 +1,272 @@ +//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/keyvault/armkeyvault" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// SecretsServer is a fake server for instances of the armkeyvault.SecretsClient type. +type SecretsServer struct { + // CreateOrUpdate is the fake for method SecretsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, vaultName string, secretName string, parameters armkeyvault.SecretCreateOrUpdateParameters, options *armkeyvault.SecretsClientCreateOrUpdateOptions) (resp azfake.Responder[armkeyvault.SecretsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method SecretsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, vaultName string, secretName string, options *armkeyvault.SecretsClientGetOptions) (resp azfake.Responder[armkeyvault.SecretsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method SecretsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, vaultName string, options *armkeyvault.SecretsClientListOptions) (resp azfake.PagerResponder[armkeyvault.SecretsClientListResponse]) + + // Update is the fake for method SecretsClient.Update + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + Update func(ctx context.Context, resourceGroupName string, vaultName string, secretName string, parameters armkeyvault.SecretPatchParameters, options *armkeyvault.SecretsClientUpdateOptions) (resp azfake.Responder[armkeyvault.SecretsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewSecretsServerTransport creates a new instance of SecretsServerTransport with the provided implementation. +// The returned SecretsServerTransport instance is connected to an instance of armkeyvault.SecretsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSecretsServerTransport(srv *SecretsServer) *SecretsServerTransport { + return &SecretsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armkeyvault.SecretsClientListResponse]](), + } +} + +// SecretsServerTransport connects instances of armkeyvault.SecretsClient to instances of SecretsServer. +// Don't use this type directly, use NewSecretsServerTransport instead. +type SecretsServerTransport struct { + srv *SecretsServer + newListPager *tracker[azfake.PagerResponder[armkeyvault.SecretsClientListResponse]] +} + +// Do implements the policy.Transporter interface for SecretsServerTransport. +func (s *SecretsServerTransport) 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 "SecretsClient.CreateOrUpdate": + resp, err = s.dispatchCreateOrUpdate(req) + case "SecretsClient.Get": + resp, err = s.dispatchGet(req) + case "SecretsClient.NewListPager": + resp, err = s.dispatchNewListPager(req) + case "SecretsClient.Update": + resp, err = s.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SecretsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/vaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/secrets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkeyvault.SecretCreateOrUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + secretNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("secretName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, vaultNameParam, secretNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Secret, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SecretsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.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\.KeyVault/vaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/secrets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + secretNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("secretName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, vaultNameParam, secretNameParam, 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).Secret, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SecretsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := s.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/vaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/secrets` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armkeyvault.SecretsClientListOptions + if topParam != nil { + options = &armkeyvault.SecretsClientListOptions{ + Top: topParam, + } + } + resp := s.srv.NewListPager(resourceGroupNameParam, vaultNameParam, options) + newListPager = &resp + s.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armkeyvault.SecretsClientListResponse, 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) { + s.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + s.newListPager.remove(req) + } + return resp, nil +} + +func (s *SecretsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if s.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\.KeyVault/vaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/secrets/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkeyvault.SecretPatchParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + secretNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("secretName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Update(req.Context(), resourceGroupNameParam, vaultNameParam, secretNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Secret, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/keyvault/armkeyvault/fake/server_factory.go b/sdk/resourcemanager/keyvault/armkeyvault/fake/server_factory.go new file mode 100644 index 000000000000..9cf711c8b125 --- /dev/null +++ b/sdk/resourcemanager/keyvault/armkeyvault/fake/server_factory.go @@ -0,0 +1,135 @@ +//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 ( + "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 armkeyvault.ClientFactory type. +type ServerFactory struct { + KeysServer KeysServer + MHSMPrivateEndpointConnectionsServer MHSMPrivateEndpointConnectionsServer + MHSMPrivateLinkResourcesServer MHSMPrivateLinkResourcesServer + MHSMRegionsServer MHSMRegionsServer + ManagedHsmKeysServer ManagedHsmKeysServer + ManagedHsmsServer ManagedHsmsServer + OperationsServer OperationsServer + PrivateEndpointConnectionsServer PrivateEndpointConnectionsServer + PrivateLinkResourcesServer PrivateLinkResourcesServer + SecretsServer SecretsServer + VaultsServer VaultsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armkeyvault.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 armkeyvault.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trKeysServer *KeysServerTransport + trMHSMPrivateEndpointConnectionsServer *MHSMPrivateEndpointConnectionsServerTransport + trMHSMPrivateLinkResourcesServer *MHSMPrivateLinkResourcesServerTransport + trMHSMRegionsServer *MHSMRegionsServerTransport + trManagedHsmKeysServer *ManagedHsmKeysServerTransport + trManagedHsmsServer *ManagedHsmsServerTransport + trOperationsServer *OperationsServerTransport + trPrivateEndpointConnectionsServer *PrivateEndpointConnectionsServerTransport + trPrivateLinkResourcesServer *PrivateLinkResourcesServerTransport + trSecretsServer *SecretsServerTransport + trVaultsServer *VaultsServerTransport +} + +// 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 "KeysClient": + initServer(s, &s.trKeysServer, func() *KeysServerTransport { return NewKeysServerTransport(&s.srv.KeysServer) }) + resp, err = s.trKeysServer.Do(req) + case "MHSMPrivateEndpointConnectionsClient": + initServer(s, &s.trMHSMPrivateEndpointConnectionsServer, func() *MHSMPrivateEndpointConnectionsServerTransport { + return NewMHSMPrivateEndpointConnectionsServerTransport(&s.srv.MHSMPrivateEndpointConnectionsServer) + }) + resp, err = s.trMHSMPrivateEndpointConnectionsServer.Do(req) + case "MHSMPrivateLinkResourcesClient": + initServer(s, &s.trMHSMPrivateLinkResourcesServer, func() *MHSMPrivateLinkResourcesServerTransport { + return NewMHSMPrivateLinkResourcesServerTransport(&s.srv.MHSMPrivateLinkResourcesServer) + }) + resp, err = s.trMHSMPrivateLinkResourcesServer.Do(req) + case "MHSMRegionsClient": + initServer(s, &s.trMHSMRegionsServer, func() *MHSMRegionsServerTransport { return NewMHSMRegionsServerTransport(&s.srv.MHSMRegionsServer) }) + resp, err = s.trMHSMRegionsServer.Do(req) + case "ManagedHsmKeysClient": + initServer(s, &s.trManagedHsmKeysServer, func() *ManagedHsmKeysServerTransport { + return NewManagedHsmKeysServerTransport(&s.srv.ManagedHsmKeysServer) + }) + resp, err = s.trManagedHsmKeysServer.Do(req) + case "ManagedHsmsClient": + initServer(s, &s.trManagedHsmsServer, func() *ManagedHsmsServerTransport { return NewManagedHsmsServerTransport(&s.srv.ManagedHsmsServer) }) + resp, err = s.trManagedHsmsServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "PrivateEndpointConnectionsClient": + initServer(s, &s.trPrivateEndpointConnectionsServer, func() *PrivateEndpointConnectionsServerTransport { + return NewPrivateEndpointConnectionsServerTransport(&s.srv.PrivateEndpointConnectionsServer) + }) + resp, err = s.trPrivateEndpointConnectionsServer.Do(req) + case "PrivateLinkResourcesClient": + initServer(s, &s.trPrivateLinkResourcesServer, func() *PrivateLinkResourcesServerTransport { + return NewPrivateLinkResourcesServerTransport(&s.srv.PrivateLinkResourcesServer) + }) + resp, err = s.trPrivateLinkResourcesServer.Do(req) + case "SecretsClient": + initServer(s, &s.trSecretsServer, func() *SecretsServerTransport { return NewSecretsServerTransport(&s.srv.SecretsServer) }) + resp, err = s.trSecretsServer.Do(req) + case "VaultsClient": + initServer(s, &s.trVaultsServer, func() *VaultsServerTransport { return NewVaultsServerTransport(&s.srv.VaultsServer) }) + resp, err = s.trVaultsServer.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/keyvault/armkeyvault/fake/time_rfc3339.go b/sdk/resourcemanager/keyvault/armkeyvault/fake/time_rfc3339.go new file mode 100644 index 000000000000..b0535a7b63e6 --- /dev/null +++ b/sdk/resourcemanager/keyvault/armkeyvault/fake/time_rfc3339.go @@ -0,0 +1,86 @@ +//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 ( + "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 ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +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 { + layout := utcDateTimeJSON + if tzOffsetRegex.Match(data) { + layout = dateTimeJSON + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + 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 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 || strings.EqualFold(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/keyvault/armkeyvault/fake/time_unix.go b/sdk/resourcemanager/keyvault/armkeyvault/fake/time_unix.go new file mode 100644 index 000000000000..cf5c6d7c0a04 --- /dev/null +++ b/sdk/resourcemanager/keyvault/armkeyvault/fake/time_unix.go @@ -0,0 +1,61 @@ +//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 ( + "encoding/json" + "fmt" + "github.com/Azure/azure-sdk-for-go/sdk/azcore" + "reflect" + "strings" + "time" +) + +type timeUnix time.Time + +func (t timeUnix) MarshalJSON() ([]byte, error) { + return json.Marshal(time.Time(t).Unix()) +} + +func (t *timeUnix) UnmarshalJSON(data []byte) error { + var seconds int64 + if err := json.Unmarshal(data, &seconds); err != nil { + return err + } + *t = timeUnix(time.Unix(seconds, 0)) + return nil +} + +func (t timeUnix) String() string { + return fmt.Sprintf("%d", time.Time(t).Unix()) +} + +func populateTimeUnix(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] = (*timeUnix)(t) +} + +func unpopulateTimeUnix(data json.RawMessage, fn string, t **time.Time) error { + if data == nil || strings.EqualFold(string(data), "null") { + return nil + } + var aux timeUnix + 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/keyvault/armkeyvault/fake/vaults_server.go b/sdk/resourcemanager/keyvault/armkeyvault/fake/vaults_server.go new file mode 100644 index 000000000000..b9f3ab077a3d --- /dev/null +++ b/sdk/resourcemanager/keyvault/armkeyvault/fake/vaults_server.go @@ -0,0 +1,652 @@ +//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/keyvault/armkeyvault" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// VaultsServer is a fake server for instances of the armkeyvault.VaultsClient type. +type VaultsServer struct { + // CheckNameAvailability is the fake for method VaultsClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, vaultName armkeyvault.VaultCheckNameAvailabilityParameters, options *armkeyvault.VaultsClientCheckNameAvailabilityOptions) (resp azfake.Responder[armkeyvault.VaultsClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method VaultsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, vaultName string, parameters armkeyvault.VaultCreateOrUpdateParameters, options *armkeyvault.VaultsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armkeyvault.VaultsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method VaultsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, vaultName string, options *armkeyvault.VaultsClientDeleteOptions) (resp azfake.Responder[armkeyvault.VaultsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method VaultsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, vaultName string, options *armkeyvault.VaultsClientGetOptions) (resp azfake.Responder[armkeyvault.VaultsClientGetResponse], errResp azfake.ErrorResponder) + + // GetDeleted is the fake for method VaultsClient.GetDeleted + // HTTP status codes to indicate success: http.StatusOK + GetDeleted func(ctx context.Context, vaultName string, location string, options *armkeyvault.VaultsClientGetDeletedOptions) (resp azfake.Responder[armkeyvault.VaultsClientGetDeletedResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method VaultsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armkeyvault.VaultsClientListOptions) (resp azfake.PagerResponder[armkeyvault.VaultsClientListResponse]) + + // NewListByResourceGroupPager is the fake for method VaultsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armkeyvault.VaultsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armkeyvault.VaultsClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method VaultsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armkeyvault.VaultsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armkeyvault.VaultsClientListBySubscriptionResponse]) + + // NewListDeletedPager is the fake for method VaultsClient.NewListDeletedPager + // HTTP status codes to indicate success: http.StatusOK + NewListDeletedPager func(options *armkeyvault.VaultsClientListDeletedOptions) (resp azfake.PagerResponder[armkeyvault.VaultsClientListDeletedResponse]) + + // BeginPurgeDeleted is the fake for method VaultsClient.BeginPurgeDeleted + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginPurgeDeleted func(ctx context.Context, vaultName string, location string, options *armkeyvault.VaultsClientBeginPurgeDeletedOptions) (resp azfake.PollerResponder[armkeyvault.VaultsClientPurgeDeletedResponse], errResp azfake.ErrorResponder) + + // Update is the fake for method VaultsClient.Update + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + Update func(ctx context.Context, resourceGroupName string, vaultName string, parameters armkeyvault.VaultPatchParameters, options *armkeyvault.VaultsClientUpdateOptions) (resp azfake.Responder[armkeyvault.VaultsClientUpdateResponse], errResp azfake.ErrorResponder) + + // UpdateAccessPolicy is the fake for method VaultsClient.UpdateAccessPolicy + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + UpdateAccessPolicy func(ctx context.Context, resourceGroupName string, vaultName string, operationKind armkeyvault.AccessPolicyUpdateKind, parameters armkeyvault.VaultAccessPolicyParameters, options *armkeyvault.VaultsClientUpdateAccessPolicyOptions) (resp azfake.Responder[armkeyvault.VaultsClientUpdateAccessPolicyResponse], errResp azfake.ErrorResponder) +} + +// NewVaultsServerTransport creates a new instance of VaultsServerTransport with the provided implementation. +// The returned VaultsServerTransport instance is connected to an instance of armkeyvault.VaultsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewVaultsServerTransport(srv *VaultsServer) *VaultsServerTransport { + return &VaultsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armkeyvault.VaultsClientCreateOrUpdateResponse]](), + newListPager: newTracker[azfake.PagerResponder[armkeyvault.VaultsClientListResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armkeyvault.VaultsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armkeyvault.VaultsClientListBySubscriptionResponse]](), + newListDeletedPager: newTracker[azfake.PagerResponder[armkeyvault.VaultsClientListDeletedResponse]](), + beginPurgeDeleted: newTracker[azfake.PollerResponder[armkeyvault.VaultsClientPurgeDeletedResponse]](), + } +} + +// VaultsServerTransport connects instances of armkeyvault.VaultsClient to instances of VaultsServer. +// Don't use this type directly, use NewVaultsServerTransport instead. +type VaultsServerTransport struct { + srv *VaultsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armkeyvault.VaultsClientCreateOrUpdateResponse]] + newListPager *tracker[azfake.PagerResponder[armkeyvault.VaultsClientListResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armkeyvault.VaultsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armkeyvault.VaultsClientListBySubscriptionResponse]] + newListDeletedPager *tracker[azfake.PagerResponder[armkeyvault.VaultsClientListDeletedResponse]] + beginPurgeDeleted *tracker[azfake.PollerResponder[armkeyvault.VaultsClientPurgeDeletedResponse]] +} + +// Do implements the policy.Transporter interface for VaultsServerTransport. +func (v *VaultsServerTransport) 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 "VaultsClient.CheckNameAvailability": + resp, err = v.dispatchCheckNameAvailability(req) + case "VaultsClient.BeginCreateOrUpdate": + resp, err = v.dispatchBeginCreateOrUpdate(req) + case "VaultsClient.Delete": + resp, err = v.dispatchDelete(req) + case "VaultsClient.Get": + resp, err = v.dispatchGet(req) + case "VaultsClient.GetDeleted": + resp, err = v.dispatchGetDeleted(req) + case "VaultsClient.NewListPager": + resp, err = v.dispatchNewListPager(req) + case "VaultsClient.NewListByResourceGroupPager": + resp, err = v.dispatchNewListByResourceGroupPager(req) + case "VaultsClient.NewListBySubscriptionPager": + resp, err = v.dispatchNewListBySubscriptionPager(req) + case "VaultsClient.NewListDeletedPager": + resp, err = v.dispatchNewListDeletedPager(req) + case "VaultsClient.BeginPurgeDeleted": + resp, err = v.dispatchBeginPurgeDeleted(req) + case "VaultsClient.Update": + resp, err = v.dispatchUpdate(req) + case "VaultsClient.UpdateAccessPolicy": + resp, err = v.dispatchUpdateAccessPolicy(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (v *VaultsServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if v.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/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[armkeyvault.VaultCheckNameAvailabilityParameters](req) + if err != nil { + return nil, err + } + respr, errRespr := v.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).CheckNameAvailabilityResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (v *VaultsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if v.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := v.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/vaults/(?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[armkeyvault.VaultCreateOrUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, vaultNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + v.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) { + v.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) { + v.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (v *VaultsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if v.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/vaults/(?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 + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.Delete(req.Context(), resourceGroupNameParam, vaultNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (v *VaultsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if v.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\.KeyVault/vaults/(?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 + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.Get(req.Context(), resourceGroupNameParam, vaultNameParam, 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).Vault, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (v *VaultsServerTransport) dispatchGetDeleted(req *http.Request) (*http.Response, error) { + if v.srv.GetDeleted == nil { + return nil, &nonRetriableError{errors.New("fake for method GetDeleted not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deletedVaults/(?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) + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.GetDeleted(req.Context(), vaultNameParam, locationParam, 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).DeletedVault, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (v *VaultsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if v.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := v.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resources` + 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) + } + qp := req.URL.Query() + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armkeyvault.VaultsClientListOptions + if topParam != nil { + options = &armkeyvault.VaultsClientListOptions{ + Top: topParam, + } + } + resp := v.srv.NewListPager(options) + newListPager = &resp + v.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armkeyvault.VaultsClientListResponse, 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) { + v.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + v.newListPager.remove(req) + } + return resp, nil +} + +func (v *VaultsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if v.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := v.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/vaults` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armkeyvault.VaultsClientListByResourceGroupOptions + if topParam != nil { + options = &armkeyvault.VaultsClientListByResourceGroupOptions{ + Top: topParam, + } + } + resp := v.srv.NewListByResourceGroupPager(resourceGroupNameParam, options) + newListByResourceGroupPager = &resp + v.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armkeyvault.VaultsClientListByResourceGroupResponse, 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) { + v.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + v.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (v *VaultsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if v.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := v.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/vaults` + 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) + } + qp := req.URL.Query() + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armkeyvault.VaultsClientListBySubscriptionOptions + if topParam != nil { + options = &armkeyvault.VaultsClientListBySubscriptionOptions{ + Top: topParam, + } + } + resp := v.srv.NewListBySubscriptionPager(options) + newListBySubscriptionPager = &resp + v.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armkeyvault.VaultsClientListBySubscriptionResponse, 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) { + v.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + v.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (v *VaultsServerTransport) dispatchNewListDeletedPager(req *http.Request) (*http.Response, error) { + if v.srv.NewListDeletedPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListDeletedPager not implemented")} + } + newListDeletedPager := v.newListDeletedPager.get(req) + if newListDeletedPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/deletedVaults` + 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 := v.srv.NewListDeletedPager(nil) + newListDeletedPager = &resp + v.newListDeletedPager.add(req, newListDeletedPager) + server.PagerResponderInjectNextLinks(newListDeletedPager, req, func(page *armkeyvault.VaultsClientListDeletedResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListDeletedPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + v.newListDeletedPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListDeletedPager) { + v.newListDeletedPager.remove(req) + } + return resp, nil +} + +func (v *VaultsServerTransport) dispatchBeginPurgeDeleted(req *http.Request) (*http.Response, error) { + if v.srv.BeginPurgeDeleted == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginPurgeDeleted not implemented")} + } + beginPurgeDeleted := v.beginPurgeDeleted.get(req) + if beginPurgeDeleted == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/deletedVaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/purge` + 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) + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginPurgeDeleted(req.Context(), vaultNameParam, locationParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginPurgeDeleted = &respr + v.beginPurgeDeleted.add(req, beginPurgeDeleted) + } + + resp, err := server.PollerResponderNext(beginPurgeDeleted, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + v.beginPurgeDeleted.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginPurgeDeleted) { + v.beginPurgeDeleted.remove(req) + } + + return resp, nil +} + +func (v *VaultsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if v.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\.KeyVault/vaults/(?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[armkeyvault.VaultPatchParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.Update(req.Context(), resourceGroupNameParam, vaultNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Vault, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (v *VaultsServerTransport) dispatchUpdateAccessPolicy(req *http.Request) (*http.Response, error) { + if v.srv.UpdateAccessPolicy == nil { + return nil, &nonRetriableError{errors.New("fake for method UpdateAccessPolicy not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KeyVault/vaults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/accessPolicies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkeyvault.VaultAccessPolicyParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + vaultNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("vaultName")]) + if err != nil { + return nil, err + } + operationKindParam, err := parseWithCast(matches[regex.SubexpIndex("operationKind")], func(v string) (armkeyvault.AccessPolicyUpdateKind, error) { + p, unescapeErr := url.PathUnescape(v) + if unescapeErr != nil { + return "", unescapeErr + } + return armkeyvault.AccessPolicyUpdateKind(p), nil + }) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.UpdateAccessPolicy(req.Context(), resourceGroupNameParam, vaultNameParam, operationKindParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).VaultAccessPolicyParameters, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/keyvault/armkeyvault/go.mod b/sdk/resourcemanager/keyvault/armkeyvault/go.mod index 8c763414cecb..ed898f61e3ea 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/go.mod +++ b/sdk/resourcemanager/keyvault/armkeyvault/go.mod @@ -3,27 +3,27 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvaul go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 - github.com/stretchr/testify v1.7.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 + github.com/stretchr/testify v1.8.4 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dnaeon/go-vcr v1.1.0 // indirect - github.com/golang-jwt/jwt/v4 v4.4.2 // indirect - github.com/google/uuid v1.1.1 // indirect + github.com/dnaeon/go-vcr v1.2.0 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 // indirect + github.com/google/uuid v1.3.1 // indirect github.com/kylelemons/godebug v1.1.0 // indirect - github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 // indirect + github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 // indirect - golang.org/x/net v0.8.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/text v0.8.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/sdk/resourcemanager/keyvault/armkeyvault/go.sum b/sdk/resourcemanager/keyvault/armkeyvault/go.sum index 592e81cc36bb..88bb72abf2ba 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/go.sum +++ b/sdk/resourcemanager/keyvault/armkeyvault/go.sum @@ -1,47 +1,47 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 h1:t/W5MYAuQy81cvM8VUNfRLzhtKpXhVUAN7Cd7KVbTyc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0/go.mod h1:NBanQUfSWiWn3QEpWDTCU0IjBECKOYvl2R8xdRtMtiM= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 h1:mLY+pNLjCUeKhgnAJWAKhEUQM+RJQo2H1fuGSw1Ky1E= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2/go.mod h1:FbdwsQ2EzwvXxOPcMFYO8ogEc9uMMIj3YkmCdXdAFmk= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 h1:ECsQtyERDVz3NP3kvDOTLvbQhqWp/x9EsGKtb4ogUr8= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0/go.mod h1:s1tW/At+xHqjNFvWU4G0c0Qv33KOhvbGNj0RCTQDV8s= -github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0 h1:VgSJlZH5u0k2qxSpqyghcFQKmvYckj46uymKK5XzkBM= -github.com/AzureAD/microsoft-authentication-library-for-go v0.7.0/go.mod h1:BDJ5qMFKx9DugEg3+uQSDCdbYPr5s9vBTrL9P8TpqOU= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 h1:PTFGRSlMKCQelWwxUyYVEUqseBJVemLyqWJjvMyt0do= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0/go.mod h1:LRr2FzBTQlONPPa5HREE5+RjSCTXl7BwOvYOaWTqCaI= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups v1.0.0 h1:pPvTJ1dY0sA35JOeFq6TsY2xj6Z85Yo23Pj4wCCvu4o= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 h1:7CBQ+Ei8SP2c6ydQTGCCrS35bDxgTMfoP2miAwK++OU= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1/go.mod h1:c/wcGeGx5FUPbM/JltUYHZcKmigwyVLJlDq+4HdtXaw= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= -github.com/golang-jwt/jwt/v4 v4.4.2 h1:rcc4lwaZgFMCZ5jxF9ABolDcIHdBytAFgqFPbSJQAYs= -github.com/golang-jwt/jwt/v4 v4.4.2/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY= -github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= +github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= +github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= +github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4 h1:Qj1ukM4GlMWXNdMBuXcXfz/Kw9s1qm0CLY32QxuSImI= -github.com/pkg/browser v0.0.0-20210115035449-ce105d075bb4/go.mod h1:N6UoU20jOqggOuDwUaBQpluzLNDqif3kq9z2wpdYEfQ= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= +github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw= -golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +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/keyvault/armkeyvault/keys_client.go b/sdk/resourcemanager/keyvault/armkeyvault/keys_client.go index da53437de31b..4942ef7dd3ef 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/keys_client.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/keys_client.go @@ -33,7 +33,7 @@ type KeysClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewKeysClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*KeysClient, error) { - cl, err := arm.NewClient(moduleName+".KeysClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -59,6 +59,10 @@ func NewKeysClient(subscriptionID string, credential azcore.TokenCredential, opt // - options - KeysClientCreateIfNotExistOptions contains the optional parameters for the KeysClient.CreateIfNotExist method. func (client *KeysClient) CreateIfNotExist(ctx context.Context, resourceGroupName string, vaultName string, keyName string, parameters KeyCreateParameters, options *KeysClientCreateIfNotExistOptions) (KeysClientCreateIfNotExistResponse, error) { var err error + const operationName = "KeysClient.CreateIfNotExist" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createIfNotExistCreateRequest(ctx, resourceGroupName, vaultName, keyName, parameters, options) if err != nil { return KeysClientCreateIfNotExistResponse{}, err @@ -127,6 +131,10 @@ func (client *KeysClient) createIfNotExistHandleResponse(resp *http.Response) (K // - options - KeysClientGetOptions contains the optional parameters for the KeysClient.Get method. func (client *KeysClient) Get(ctx context.Context, resourceGroupName string, vaultName string, keyName string, options *KeysClientGetOptions) (KeysClientGetResponse, error) { var err error + const operationName = "KeysClient.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, vaultName, keyName, options) if err != nil { return KeysClientGetResponse{}, err @@ -193,6 +201,10 @@ func (client *KeysClient) getHandleResponse(resp *http.Response) (KeysClientGetR // - options - KeysClientGetVersionOptions contains the optional parameters for the KeysClient.GetVersion method. func (client *KeysClient) GetVersion(ctx context.Context, resourceGroupName string, vaultName string, keyName string, keyVersion string, options *KeysClientGetVersionOptions) (KeysClientGetVersionResponse, error) { var err error + const operationName = "KeysClient.GetVersion" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getVersionCreateRequest(ctx, resourceGroupName, vaultName, keyName, keyVersion, options) if err != nil { return KeysClientGetVersionResponse{}, err @@ -264,25 +276,20 @@ func (client *KeysClient) NewListPager(resourceGroupName string, vaultName strin return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *KeysClientListResponse) (KeysClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, vaultName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "KeysClient.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, resourceGroupName, vaultName, options) + }, nil) if err != nil { return KeysClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return KeysClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeysClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -334,25 +341,20 @@ func (client *KeysClient) NewListVersionsPager(resourceGroupName string, vaultNa return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *KeysClientListVersionsResponse) (KeysClientListVersionsResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listVersionsCreateRequest(ctx, resourceGroupName, vaultName, keyName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "KeysClient.NewListVersionsPager") + 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.listVersionsCreateRequest(ctx, resourceGroupName, vaultName, keyName, options) + }, nil) if err != nil { return KeysClientListVersionsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return KeysClientListVersionsResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return KeysClientListVersionsResponse{}, runtime.NewResponseError(resp) - } return client.listVersionsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/keyvault/armkeyvault/keys_client_live_test.go b/sdk/resourcemanager/keyvault/armkeyvault/keys_client_live_test.go index 48ae8bd32143..d9c4924278f3 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/keys_client_live_test.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/keys_client_live_test.go @@ -14,7 +14,8 @@ import ( "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/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/testutil" + "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2/testutil" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvault" "github.com/stretchr/testify/suite" ) @@ -35,10 +36,10 @@ type KeysClientTestSuite struct { func (testsuite *KeysClientTestSuite) SetupSuite() { testsuite.ctx = context.Background() testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T()) - testsuite.location = testutil.GetEnv("LOCATION", "eastus") - testsuite.subscriptionID = testutil.GetEnv("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") - testsuite.tenantID = testutil.GetEnv("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") - testsuite.objectID = testutil.GetEnv("AZURE_OBJECT_ID", "00000000-0000-0000-0000-000000000000") + testsuite.location = recording.GetEnvVariable("LOCATION", "eastus") + testsuite.subscriptionID = recording.GetEnvVariable("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + testsuite.tenantID = recording.GetEnvVariable("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + testsuite.objectID = recording.GetEnvVariable("AZURE_OBJECT_ID", "00000000-0000-0000-0000-000000000000") testutil.StartRecording(testsuite.T(), "sdk/resourcemanager/keyvault/armkeyvault/testdata") resourceGroup, _, err := testutil.CreateResourceGroup(testsuite.ctx, testsuite.subscriptionID, testsuite.cred, testsuite.options, testsuite.location) testsuite.Require().NoError(err) diff --git a/sdk/resourcemanager/keyvault/armkeyvault/managedhsmkeys_client.go b/sdk/resourcemanager/keyvault/armkeyvault/managedhsmkeys_client.go index 98769a5770b8..eb94d15a95e3 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/managedhsmkeys_client.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/managedhsmkeys_client.go @@ -33,7 +33,7 @@ type ManagedHsmKeysClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewManagedHsmKeysClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ManagedHsmKeysClient, error) { - cl, err := arm.NewClient(moduleName+".ManagedHsmKeysClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -60,6 +60,10 @@ func NewManagedHsmKeysClient(subscriptionID string, credential azcore.TokenCrede // method. func (client *ManagedHsmKeysClient) CreateIfNotExist(ctx context.Context, resourceGroupName string, name string, keyName string, parameters ManagedHsmKeyCreateParameters, options *ManagedHsmKeysClientCreateIfNotExistOptions) (ManagedHsmKeysClientCreateIfNotExistResponse, error) { var err error + const operationName = "ManagedHsmKeysClient.CreateIfNotExist" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createIfNotExistCreateRequest(ctx, resourceGroupName, name, keyName, parameters, options) if err != nil { return ManagedHsmKeysClientCreateIfNotExistResponse{}, err @@ -130,6 +134,10 @@ func (client *ManagedHsmKeysClient) createIfNotExistHandleResponse(resp *http.Re // - options - ManagedHsmKeysClientGetOptions contains the optional parameters for the ManagedHsmKeysClient.Get method. func (client *ManagedHsmKeysClient) Get(ctx context.Context, resourceGroupName string, name string, keyName string, options *ManagedHsmKeysClientGetOptions) (ManagedHsmKeysClientGetResponse, error) { var err error + const operationName = "ManagedHsmKeysClient.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, name, keyName, options) if err != nil { return ManagedHsmKeysClientGetResponse{}, err @@ -199,6 +207,10 @@ func (client *ManagedHsmKeysClient) getHandleResponse(resp *http.Response) (Mana // method. func (client *ManagedHsmKeysClient) GetVersion(ctx context.Context, resourceGroupName string, name string, keyName string, keyVersion string, options *ManagedHsmKeysClientGetVersionOptions) (ManagedHsmKeysClientGetVersionResponse, error) { var err error + const operationName = "ManagedHsmKeysClient.GetVersion" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getVersionCreateRequest(ctx, resourceGroupName, name, keyName, keyVersion, options) if err != nil { return ManagedHsmKeysClientGetVersionResponse{}, err @@ -270,25 +282,20 @@ func (client *ManagedHsmKeysClient) NewListPager(resourceGroupName string, name return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ManagedHsmKeysClientListResponse) (ManagedHsmKeysClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, name, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ManagedHsmKeysClient.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, resourceGroupName, name, options) + }, nil) if err != nil { return ManagedHsmKeysClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ManagedHsmKeysClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ManagedHsmKeysClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -343,25 +350,20 @@ func (client *ManagedHsmKeysClient) NewListVersionsPager(resourceGroupName strin return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ManagedHsmKeysClientListVersionsResponse) (ManagedHsmKeysClientListVersionsResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listVersionsCreateRequest(ctx, resourceGroupName, name, keyName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ManagedHsmKeysClient.NewListVersionsPager") + 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.listVersionsCreateRequest(ctx, resourceGroupName, name, keyName, options) + }, nil) if err != nil { return ManagedHsmKeysClientListVersionsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ManagedHsmKeysClientListVersionsResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ManagedHsmKeysClientListVersionsResponse{}, runtime.NewResponseError(resp) - } return client.listVersionsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/keyvault/armkeyvault/managedhsms_client.go b/sdk/resourcemanager/keyvault/armkeyvault/managedhsms_client.go index e81314253252..169d9b8be4f0 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/managedhsms_client.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/managedhsms_client.go @@ -34,7 +34,7 @@ type ManagedHsmsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewManagedHsmsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ManagedHsmsClient, error) { - cl, err := arm.NewClient(moduleName+".ManagedHsmsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,6 +54,10 @@ func NewManagedHsmsClient(subscriptionID string, credential azcore.TokenCredenti // method. func (client *ManagedHsmsClient) CheckMhsmNameAvailability(ctx context.Context, mhsmName CheckMhsmNameAvailabilityParameters, options *ManagedHsmsClientCheckMhsmNameAvailabilityOptions) (ManagedHsmsClientCheckMhsmNameAvailabilityResponse, error) { var err error + const operationName = "ManagedHsmsClient.CheckMhsmNameAvailability" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.checkMhsmNameAvailabilityCreateRequest(ctx, mhsmName, options) if err != nil { return ManagedHsmsClientCheckMhsmNameAvailabilityResponse{}, err @@ -115,10 +119,14 @@ func (client *ManagedHsmsClient) BeginCreateOrUpdate(ctx context.Context, resour if err != nil { return nil, err } - poller, err := runtime.NewPoller[ManagedHsmsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ManagedHsmsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ManagedHsmsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ManagedHsmsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -128,6 +136,10 @@ func (client *ManagedHsmsClient) BeginCreateOrUpdate(ctx context.Context, resour // Generated from API version 2023-07-01 func (client *ManagedHsmsClient) createOrUpdate(ctx context.Context, resourceGroupName string, name string, parameters ManagedHsm, options *ManagedHsmsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error + const operationName = "ManagedHsmsClient.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, name, parameters, options) if err != nil { return nil, err @@ -185,10 +197,14 @@ func (client *ManagedHsmsClient) BeginDelete(ctx context.Context, resourceGroupN if err != nil { return nil, err } - poller, err := runtime.NewPoller[ManagedHsmsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ManagedHsmsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ManagedHsmsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ManagedHsmsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -198,6 +214,10 @@ func (client *ManagedHsmsClient) BeginDelete(ctx context.Context, resourceGroupN // Generated from API version 2023-07-01 func (client *ManagedHsmsClient) deleteOperation(ctx context.Context, resourceGroupName string, name string, options *ManagedHsmsClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "ManagedHsmsClient.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, name, options) if err != nil { return nil, err @@ -248,6 +268,10 @@ func (client *ManagedHsmsClient) deleteCreateRequest(ctx context.Context, resour // - options - ManagedHsmsClientGetOptions contains the optional parameters for the ManagedHsmsClient.Get method. func (client *ManagedHsmsClient) Get(ctx context.Context, resourceGroupName string, name string, options *ManagedHsmsClientGetOptions) (ManagedHsmsClientGetResponse, error) { var err error + const operationName = "ManagedHsmsClient.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, name, options) if err != nil { return ManagedHsmsClientGetResponse{}, err @@ -308,6 +332,10 @@ func (client *ManagedHsmsClient) getHandleResponse(resp *http.Response) (Managed // - options - ManagedHsmsClientGetDeletedOptions contains the optional parameters for the ManagedHsmsClient.GetDeleted method. func (client *ManagedHsmsClient) GetDeleted(ctx context.Context, name string, location string, options *ManagedHsmsClientGetDeletedOptions) (ManagedHsmsClientGetDeletedResponse, error) { var err error + const operationName = "ManagedHsmsClient.GetDeleted" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getDeletedCreateRequest(ctx, name, location, options) if err != nil { return ManagedHsmsClientGetDeletedResponse{}, err @@ -372,25 +400,20 @@ func (client *ManagedHsmsClient) NewListByResourceGroupPager(resourceGroupName s return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ManagedHsmsClientListByResourceGroupResponse) (ManagedHsmsClientListByResourceGroupResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ManagedHsmsClient.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 ManagedHsmsClientListByResourceGroupResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ManagedHsmsClientListByResourceGroupResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ManagedHsmsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -439,25 +462,20 @@ func (client *ManagedHsmsClient) NewListBySubscriptionPager(options *ManagedHsms return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ManagedHsmsClientListBySubscriptionResponse) (ManagedHsmsClientListBySubscriptionResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listBySubscriptionCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return ManagedHsmsClientListBySubscriptionResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ManagedHsmsClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + 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 ManagedHsmsClientListBySubscriptionResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ManagedHsmsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) - } return client.listBySubscriptionHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -502,25 +520,20 @@ func (client *ManagedHsmsClient) NewListDeletedPager(options *ManagedHsmsClientL return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ManagedHsmsClientListDeletedResponse) (ManagedHsmsClientListDeletedResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listDeletedCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return ManagedHsmsClientListDeletedResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ManagedHsmsClient.NewListDeletedPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listDeletedCreateRequest(ctx, options) + }, nil) if err != nil { return ManagedHsmsClientListDeletedResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ManagedHsmsClientListDeletedResponse{}, runtime.NewResponseError(resp) - } return client.listDeletedHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -565,10 +578,14 @@ func (client *ManagedHsmsClient) BeginPurgeDeleted(ctx context.Context, name str if err != nil { return nil, err } - poller, err := runtime.NewPoller[ManagedHsmsClientPurgeDeletedResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ManagedHsmsClientPurgeDeletedResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ManagedHsmsClientPurgeDeletedResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ManagedHsmsClientPurgeDeletedResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -578,6 +595,10 @@ func (client *ManagedHsmsClient) BeginPurgeDeleted(ctx context.Context, name str // Generated from API version 2023-07-01 func (client *ManagedHsmsClient) purgeDeleted(ctx context.Context, name string, location string, options *ManagedHsmsClientBeginPurgeDeletedOptions) (*http.Response, error) { var err error + const operationName = "ManagedHsmsClient.BeginPurgeDeleted" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.purgeDeletedCreateRequest(ctx, name, location, options) if err != nil { return nil, err @@ -633,10 +654,14 @@ func (client *ManagedHsmsClient) BeginUpdate(ctx context.Context, resourceGroupN if err != nil { return nil, err } - poller, err := runtime.NewPoller[ManagedHsmsClientUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ManagedHsmsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ManagedHsmsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ManagedHsmsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -646,6 +671,10 @@ func (client *ManagedHsmsClient) BeginUpdate(ctx context.Context, resourceGroupN // Generated from API version 2023-07-01 func (client *ManagedHsmsClient) update(ctx context.Context, resourceGroupName string, name string, parameters ManagedHsm, options *ManagedHsmsClientBeginUpdateOptions) (*http.Response, error) { var err error + const operationName = "ManagedHsmsClient.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, name, parameters, options) if err != nil { return nil, err diff --git a/sdk/resourcemanager/keyvault/armkeyvault/managedhsms_client_example_test.go b/sdk/resourcemanager/keyvault/armkeyvault/managedhsms_client_example_test.go index 4724ceb2590a..28713dfbca80 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/managedhsms_client_example_test.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/managedhsms_client_example_test.go @@ -392,11 +392,11 @@ func ExampleManagedHsmsClient_NewListDeletedPager() { // Type: to.Ptr("Microsoft.KeyVault/deletedManagedHSMs"), // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.KeyVault/locations/westus/deletedManagedHSMs/hsm1"), // Properties: &armkeyvault.DeletedManagedHsmProperties{ - // DeletionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T00:00:59Z"); return t}()), + // DeletionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T00:00:59.000Z"); return t}()), // Location: to.Ptr("westus"), // MhsmID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hsm-group/providers/Microsoft.KeyVault/managedHSMs/hsm1"), // PurgeProtectionEnabled: to.Ptr(true), - // ScheduledPurgeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T00:00:59Z"); return t}()), + // ScheduledPurgeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T00:00:59.000Z"); return t}()), // Tags: map[string]*string{ // "Dept": to.Ptr("hsm"), // "Environment": to.Ptr("production"), @@ -408,11 +408,11 @@ func ExampleManagedHsmsClient_NewListDeletedPager() { // Type: to.Ptr("Microsoft.KeyVault/deletedManagedHSMs"), // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.KeyVault/locations/westus/deletedManagedHSMs/hsm2"), // Properties: &armkeyvault.DeletedManagedHsmProperties{ - // DeletionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T00:00:59Z"); return t}()), + // DeletionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T00:00:59.000Z"); return t}()), // Location: to.Ptr("westus"), // MhsmID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hsm-group/providers/Microsoft.KeyVault/managedHSMs/hsm2"), // PurgeProtectionEnabled: to.Ptr(true), - // ScheduledPurgeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T00:00:59Z"); return t}()), + // ScheduledPurgeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T00:00:59.000Z"); return t}()), // Tags: map[string]*string{ // "Dept": to.Ptr("hsm"), // "Environment": to.Ptr("production"), @@ -446,11 +446,11 @@ func ExampleManagedHsmsClient_GetDeleted() { // Type: to.Ptr("Microsoft.KeyVault/deletedManagedHSMs"), // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.KeyVault/locations/westus/deletedManagedHSMs/hsm1"), // Properties: &armkeyvault.DeletedManagedHsmProperties{ - // DeletionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T00:00:59Z"); return t}()), + // DeletionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T00:00:59.000Z"); return t}()), // Location: to.Ptr("westus"), // MhsmID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/hsm-group/providers/Microsoft.KeyVault/managedHSMs/hsm1"), // PurgeProtectionEnabled: to.Ptr(true), - // ScheduledPurgeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T00:00:59Z"); return t}()), + // ScheduledPurgeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-04-01T00:00:59.000Z"); return t}()), // Tags: map[string]*string{ // "Dept": to.Ptr("hsm"), // "Environment": to.Ptr("production"), diff --git a/sdk/resourcemanager/keyvault/armkeyvault/mhsmprivateendpointconnections_client.go b/sdk/resourcemanager/keyvault/armkeyvault/mhsmprivateendpointconnections_client.go index 21550c25f229..41cf70240c0e 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/mhsmprivateendpointconnections_client.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/mhsmprivateendpointconnections_client.go @@ -34,7 +34,7 @@ type MHSMPrivateEndpointConnectionsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewMHSMPrivateEndpointConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MHSMPrivateEndpointConnectionsClient, error) { - cl, err := arm.NewClient(moduleName+".MHSMPrivateEndpointConnectionsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -60,10 +60,14 @@ func (client *MHSMPrivateEndpointConnectionsClient) BeginDelete(ctx context.Cont if err != nil { return nil, err } - poller, err := runtime.NewPoller[MHSMPrivateEndpointConnectionsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MHSMPrivateEndpointConnectionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[MHSMPrivateEndpointConnectionsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[MHSMPrivateEndpointConnectionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -73,6 +77,10 @@ func (client *MHSMPrivateEndpointConnectionsClient) BeginDelete(ctx context.Cont // Generated from API version 2023-07-01 func (client *MHSMPrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, name string, privateEndpointConnectionName string, options *MHSMPrivateEndpointConnectionsClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "MHSMPrivateEndpointConnectionsClient.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, name, privateEndpointConnectionName, options) if err != nil { return nil, err @@ -129,6 +137,10 @@ func (client *MHSMPrivateEndpointConnectionsClient) deleteCreateRequest(ctx cont // method. func (client *MHSMPrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, name string, privateEndpointConnectionName string, options *MHSMPrivateEndpointConnectionsClientGetOptions) (MHSMPrivateEndpointConnectionsClientGetResponse, error) { var err error + const operationName = "MHSMPrivateEndpointConnectionsClient.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, name, privateEndpointConnectionName, options) if err != nil { return MHSMPrivateEndpointConnectionsClientGetResponse{}, err @@ -198,25 +210,20 @@ func (client *MHSMPrivateEndpointConnectionsClient) NewListByResourcePager(resou return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *MHSMPrivateEndpointConnectionsClientListByResourceResponse) (MHSMPrivateEndpointConnectionsClientListByResourceResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByResourceCreateRequest(ctx, resourceGroupName, name, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "MHSMPrivateEndpointConnectionsClient.NewListByResourcePager") + 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.listByResourceCreateRequest(ctx, resourceGroupName, name, options) + }, nil) if err != nil { return MHSMPrivateEndpointConnectionsClientListByResourceResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return MHSMPrivateEndpointConnectionsClientListByResourceResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MHSMPrivateEndpointConnectionsClientListByResourceResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -267,6 +274,10 @@ func (client *MHSMPrivateEndpointConnectionsClient) listByResourceHandleResponse // method. func (client *MHSMPrivateEndpointConnectionsClient) Put(ctx context.Context, resourceGroupName string, name string, privateEndpointConnectionName string, properties MHSMPrivateEndpointConnection, options *MHSMPrivateEndpointConnectionsClientPutOptions) (MHSMPrivateEndpointConnectionsClientPutResponse, error) { var err error + const operationName = "MHSMPrivateEndpointConnectionsClient.Put" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.putCreateRequest(ctx, resourceGroupName, name, privateEndpointConnectionName, properties, options) if err != nil { return MHSMPrivateEndpointConnectionsClientPutResponse{}, err diff --git a/sdk/resourcemanager/keyvault/armkeyvault/mhsmprivatelinkresources_client.go b/sdk/resourcemanager/keyvault/armkeyvault/mhsmprivatelinkresources_client.go index 3370d1b0541e..319d6a7e8fe0 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/mhsmprivatelinkresources_client.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/mhsmprivatelinkresources_client.go @@ -33,7 +33,7 @@ type MHSMPrivateLinkResourcesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewMHSMPrivateLinkResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MHSMPrivateLinkResourcesClient, error) { - cl, err := arm.NewClient(moduleName+".MHSMPrivateLinkResourcesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,6 +54,10 @@ func NewMHSMPrivateLinkResourcesClient(subscriptionID string, credential azcore. // method. func (client *MHSMPrivateLinkResourcesClient) ListByMHSMResource(ctx context.Context, resourceGroupName string, name string, options *MHSMPrivateLinkResourcesClientListByMHSMResourceOptions) (MHSMPrivateLinkResourcesClientListByMHSMResourceResponse, error) { var err error + const operationName = "MHSMPrivateLinkResourcesClient.ListByMHSMResource" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listByMHSMResourceCreateRequest(ctx, resourceGroupName, name, options) if err != nil { return MHSMPrivateLinkResourcesClientListByMHSMResourceResponse{}, err diff --git a/sdk/resourcemanager/keyvault/armkeyvault/mhsmregions_client.go b/sdk/resourcemanager/keyvault/armkeyvault/mhsmregions_client.go index f3f2f125caa9..15acd3c3a462 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/mhsmregions_client.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/mhsmregions_client.go @@ -33,7 +33,7 @@ type MHSMRegionsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewMHSMRegionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MHSMRegionsClient, error) { - cl, err := arm.NewClient(moduleName+".MHSMRegionsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -57,25 +57,20 @@ func (client *MHSMRegionsClient) NewListByResourcePager(resourceGroupName string return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *MHSMRegionsClientListByResourceResponse) (MHSMRegionsClientListByResourceResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByResourceCreateRequest(ctx, resourceGroupName, name, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "MHSMRegionsClient.NewListByResourcePager") + 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.listByResourceCreateRequest(ctx, resourceGroupName, name, options) + }, nil) if err != nil { return MHSMRegionsClientListByResourceResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return MHSMRegionsClientListByResourceResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MHSMRegionsClientListByResourceResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/keyvault/armkeyvault/models_serde.go b/sdk/resourcemanager/keyvault/armkeyvault/models_serde.go index 2efa49ee3a81..fbc4d3172291 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/models_serde.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/models_serde.go @@ -253,11 +253,11 @@ func (d *DeletedManagedHsmListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DeletedManagedHsmProperties. func (d DeletedManagedHsmProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "deletionDate", d.DeletionDate) + populateDateTimeRFC3339(objectMap, "deletionDate", d.DeletionDate) populate(objectMap, "location", d.Location) populate(objectMap, "mhsmId", d.MhsmID) populate(objectMap, "purgeProtectionEnabled", d.PurgeProtectionEnabled) - populateTimeRFC3339(objectMap, "scheduledPurgeDate", d.ScheduledPurgeDate) + populateDateTimeRFC3339(objectMap, "scheduledPurgeDate", d.ScheduledPurgeDate) populate(objectMap, "tags", d.Tags) return json.Marshal(objectMap) } @@ -272,7 +272,7 @@ func (d *DeletedManagedHsmProperties) UnmarshalJSON(data []byte) error { var err error switch key { case "deletionDate": - err = unpopulateTimeRFC3339(val, "DeletionDate", &d.DeletionDate) + err = unpopulateDateTimeRFC3339(val, "DeletionDate", &d.DeletionDate) delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &d.Location) @@ -284,7 +284,7 @@ func (d *DeletedManagedHsmProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "PurgeProtectionEnabled", &d.PurgeProtectionEnabled) delete(rawMsg, key) case "scheduledPurgeDate": - err = unpopulateTimeRFC3339(val, "ScheduledPurgeDate", &d.ScheduledPurgeDate) + err = unpopulateDateTimeRFC3339(val, "ScheduledPurgeDate", &d.ScheduledPurgeDate) delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &d.Tags) @@ -370,10 +370,10 @@ func (d *DeletedVaultListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type DeletedVaultProperties. func (d DeletedVaultProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "deletionDate", d.DeletionDate) + populateDateTimeRFC3339(objectMap, "deletionDate", d.DeletionDate) populate(objectMap, "location", d.Location) populate(objectMap, "purgeProtectionEnabled", d.PurgeProtectionEnabled) - populateTimeRFC3339(objectMap, "scheduledPurgeDate", d.ScheduledPurgeDate) + populateDateTimeRFC3339(objectMap, "scheduledPurgeDate", d.ScheduledPurgeDate) populate(objectMap, "tags", d.Tags) populate(objectMap, "vaultId", d.VaultID) return json.Marshal(objectMap) @@ -389,7 +389,7 @@ func (d *DeletedVaultProperties) UnmarshalJSON(data []byte) error { var err error switch key { case "deletionDate": - err = unpopulateTimeRFC3339(val, "DeletionDate", &d.DeletionDate) + err = unpopulateDateTimeRFC3339(val, "DeletionDate", &d.DeletionDate) delete(rawMsg, key) case "location": err = unpopulate(val, "Location", &d.Location) @@ -398,7 +398,7 @@ func (d *DeletedVaultProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "PurgeProtectionEnabled", &d.PurgeProtectionEnabled) delete(rawMsg, key) case "scheduledPurgeDate": - err = unpopulateTimeRFC3339(val, "ScheduledPurgeDate", &d.ScheduledPurgeDate) + err = unpopulateDateTimeRFC3339(val, "ScheduledPurgeDate", &d.ScheduledPurgeDate) delete(rawMsg, key) case "tags": err = unpopulate(val, "Tags", &d.Tags) @@ -1806,7 +1806,7 @@ func (m ManagedHsmProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "provisioningState", m.ProvisioningState) populate(objectMap, "publicNetworkAccess", m.PublicNetworkAccess) populate(objectMap, "regions", m.Regions) - populateTimeRFC3339(objectMap, "scheduledPurgeDate", m.ScheduledPurgeDate) + populateDateTimeRFC3339(objectMap, "scheduledPurgeDate", m.ScheduledPurgeDate) populate(objectMap, "securityDomainProperties", m.SecurityDomainProperties) populate(objectMap, "softDeleteRetentionInDays", m.SoftDeleteRetentionInDays) populate(objectMap, "statusMessage", m.StatusMessage) @@ -1854,7 +1854,7 @@ func (m *ManagedHsmProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Regions", &m.Regions) delete(rawMsg, key) case "scheduledPurgeDate": - err = unpopulateTimeRFC3339(val, "ScheduledPurgeDate", &m.ScheduledPurgeDate) + err = unpopulateDateTimeRFC3339(val, "ScheduledPurgeDate", &m.ScheduledPurgeDate) delete(rawMsg, key) case "securityDomainProperties": err = unpopulate(val, "SecurityDomainProperties", &m.SecurityDomainProperties) @@ -3053,10 +3053,10 @@ func (s *ServiceSpecification) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) populate(objectMap, "lastModifiedBy", s.LastModifiedBy) populate(objectMap, "lastModifiedByType", s.LastModifiedByType) return json.Marshal(objectMap) @@ -3072,7 +3072,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { var err error switch key { case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) delete(rawMsg, key) case "createdBy": err = unpopulate(val, "CreatedBy", &s.CreatedBy) @@ -3081,7 +3081,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { err = unpopulate(val, "CreatedByType", &s.CreatedByType) delete(rawMsg, key) case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) delete(rawMsg, key) case "lastModifiedBy": err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) diff --git a/sdk/resourcemanager/keyvault/armkeyvault/operations_client.go b/sdk/resourcemanager/keyvault/armkeyvault/operations_client.go index 2f0aa4929296..23c695a640a9 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/operations_client.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/operations_client.go @@ -27,7 +27,7 @@ type OperationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,25 +47,20 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.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, options) + }, nil) if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return OperationsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OperationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/keyvault/armkeyvault/privateendpointconnections_client.go b/sdk/resourcemanager/keyvault/armkeyvault/privateendpointconnections_client.go index 8e519486d1b0..4941b953fccf 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/privateendpointconnections_client.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/privateendpointconnections_client.go @@ -34,7 +34,7 @@ type PrivateEndpointConnectionsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateEndpointConnectionsClient, error) { - cl, err := arm.NewClient(moduleName+".PrivateEndpointConnectionsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -60,10 +60,14 @@ func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, if err != nil { return nil, err } - poller, err := runtime.NewPoller[PrivateEndpointConnectionsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateEndpointConnectionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PrivateEndpointConnectionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -73,6 +77,10 @@ func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, // Generated from API version 2023-07-01 func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, vaultName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "PrivateEndpointConnectionsClient.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, vaultName, privateEndpointConnectionName, options) if err != nil { return nil, err @@ -129,6 +137,10 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. // method. func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, vaultName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientGetOptions) (PrivateEndpointConnectionsClientGetResponse, error) { var err error + const operationName = "PrivateEndpointConnectionsClient.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, vaultName, privateEndpointConnectionName, options) if err != nil { return PrivateEndpointConnectionsClientGetResponse{}, err @@ -198,25 +210,20 @@ func (client *PrivateEndpointConnectionsClient) NewListByResourcePager(resourceG return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *PrivateEndpointConnectionsClientListByResourceResponse) (PrivateEndpointConnectionsClientListByResourceResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByResourceCreateRequest(ctx, resourceGroupName, vaultName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrivateEndpointConnectionsClient.NewListByResourcePager") + 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.listByResourceCreateRequest(ctx, resourceGroupName, vaultName, options) + }, nil) if err != nil { return PrivateEndpointConnectionsClientListByResourceResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return PrivateEndpointConnectionsClientListByResourceResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return PrivateEndpointConnectionsClientListByResourceResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -267,6 +274,10 @@ func (client *PrivateEndpointConnectionsClient) listByResourceHandleResponse(res // method. func (client *PrivateEndpointConnectionsClient) Put(ctx context.Context, resourceGroupName string, vaultName string, privateEndpointConnectionName string, properties PrivateEndpointConnection, options *PrivateEndpointConnectionsClientPutOptions) (PrivateEndpointConnectionsClientPutResponse, error) { var err error + const operationName = "PrivateEndpointConnectionsClient.Put" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.putCreateRequest(ctx, resourceGroupName, vaultName, privateEndpointConnectionName, properties, options) if err != nil { return PrivateEndpointConnectionsClientPutResponse{}, err diff --git a/sdk/resourcemanager/keyvault/armkeyvault/privatelinkresources_client.go b/sdk/resourcemanager/keyvault/armkeyvault/privatelinkresources_client.go index 61f7ada623a2..b329955a76d7 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/privatelinkresources_client.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/privatelinkresources_client.go @@ -33,7 +33,7 @@ type PrivateLinkResourcesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateLinkResourcesClient, error) { - cl, err := arm.NewClient(moduleName+".PrivateLinkResourcesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,6 +54,10 @@ func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.Toke // method. func (client *PrivateLinkResourcesClient) ListByVault(ctx context.Context, resourceGroupName string, vaultName string, options *PrivateLinkResourcesClientListByVaultOptions) (PrivateLinkResourcesClientListByVaultResponse, error) { var err error + const operationName = "PrivateLinkResourcesClient.ListByVault" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listByVaultCreateRequest(ctx, resourceGroupName, vaultName, options) if err != nil { return PrivateLinkResourcesClientListByVaultResponse{}, err diff --git a/sdk/resourcemanager/keyvault/armkeyvault/secrets_client.go b/sdk/resourcemanager/keyvault/armkeyvault/secrets_client.go index 6eb796d08cb3..d57157653999 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/secrets_client.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/secrets_client.go @@ -34,7 +34,7 @@ type SecretsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSecretsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SecretsClient, error) { - cl, err := arm.NewClient(moduleName+".SecretsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -59,6 +59,10 @@ func NewSecretsClient(subscriptionID string, credential azcore.TokenCredential, // - options - SecretsClientCreateOrUpdateOptions contains the optional parameters for the SecretsClient.CreateOrUpdate method. func (client *SecretsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, vaultName string, secretName string, parameters SecretCreateOrUpdateParameters, options *SecretsClientCreateOrUpdateOptions) (SecretsClientCreateOrUpdateResponse, error) { var err error + const operationName = "SecretsClient.CreateOrUpdate" + 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, vaultName, secretName, parameters, options) if err != nil { return SecretsClientCreateOrUpdateResponse{}, err @@ -128,6 +132,10 @@ func (client *SecretsClient) createOrUpdateHandleResponse(resp *http.Response) ( // - options - SecretsClientGetOptions contains the optional parameters for the SecretsClient.Get method. func (client *SecretsClient) Get(ctx context.Context, resourceGroupName string, vaultName string, secretName string, options *SecretsClientGetOptions) (SecretsClientGetResponse, error) { var err error + const operationName = "SecretsClient.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, vaultName, secretName, options) if err != nil { return SecretsClientGetResponse{}, err @@ -197,25 +205,20 @@ func (client *SecretsClient) NewListPager(resourceGroupName string, vaultName st return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *SecretsClientListResponse) (SecretsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, vaultName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SecretsClient.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, resourceGroupName, vaultName, options) + }, nil) if err != nil { return SecretsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return SecretsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SecretsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -269,6 +272,10 @@ func (client *SecretsClient) listHandleResponse(resp *http.Response) (SecretsCli // - options - SecretsClientUpdateOptions contains the optional parameters for the SecretsClient.Update method. func (client *SecretsClient) Update(ctx context.Context, resourceGroupName string, vaultName string, secretName string, parameters SecretPatchParameters, options *SecretsClientUpdateOptions) (SecretsClientUpdateResponse, error) { var err error + const operationName = "SecretsClient.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, vaultName, secretName, parameters, options) if err != nil { return SecretsClientUpdateResponse{}, err diff --git a/sdk/resourcemanager/keyvault/armkeyvault/secrets_client_live_test.go b/sdk/resourcemanager/keyvault/armkeyvault/secrets_client_live_test.go index 76d4bb5941d6..79ce91e1f73f 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/secrets_client_live_test.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/secrets_client_live_test.go @@ -14,7 +14,8 @@ import ( "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/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/testutil" + "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2/testutil" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvault" "github.com/stretchr/testify/suite" ) @@ -35,10 +36,10 @@ type SecretsClientTestSuite struct { func (testsuite *SecretsClientTestSuite) SetupSuite() { testsuite.ctx = context.Background() testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T()) - testsuite.location = testutil.GetEnv("LOCATION", "eastus") - testsuite.subscriptionID = testutil.GetEnv("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") - testsuite.tenantID = testutil.GetEnv("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") - testsuite.objectID = testutil.GetEnv("AZURE_OBJECT_ID", "00000000-0000-0000-0000-000000000000") + testsuite.location = recording.GetEnvVariable("LOCATION", "eastus") + testsuite.subscriptionID = recording.GetEnvVariable("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + testsuite.tenantID = recording.GetEnvVariable("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + testsuite.objectID = recording.GetEnvVariable("AZURE_OBJECT_ID", "00000000-0000-0000-0000-000000000000") testutil.StartRecording(testsuite.T(), "sdk/resourcemanager/keyvault/armkeyvault/testdata") resourceGroup, _, err := testutil.CreateResourceGroup(testsuite.ctx, testsuite.subscriptionID, testsuite.cred, testsuite.options, testsuite.location) testsuite.Require().NoError(err) @@ -60,7 +61,7 @@ func (testsuite *SecretsClientTestSuite) TestSecretsCRUD() { fmt.Println("Call operation: Vaults_CreateOrUpdate") vaultsClient, err := armkeyvault.NewVaultsClient(testsuite.subscriptionID, testsuite.cred, testsuite.options) testsuite.Require().NoError(err) - vaultName := "go-test-vault-2" + vaultName := "go-test-vault-22" vPollerResp, err := vaultsClient.BeginCreateOrUpdate( testsuite.ctx, testsuite.resourceGroupName, diff --git a/sdk/resourcemanager/keyvault/armkeyvault/time_rfc3339.go b/sdk/resourcemanager/keyvault/armkeyvault/time_rfc3339.go index 59d8c8054efe..a7b9a6b4d854 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/time_rfc3339.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/time_rfc3339.go @@ -18,50 +18,50 @@ import ( "time" ) -const ( - utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` - utcLayout = "2006-01-02T15:04:05.999999999" - rfc3339JSON = `"` + time.RFC3339Nano + `"` -) - // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) -type timeRFC3339 time.Time +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time -func (t timeRFC3339) MarshalJSON() (json []byte, err error) { +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { tt := time.Time(t) return tt.MarshalJSON() } -func (t timeRFC3339) MarshalText() (text []byte, err error) { +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { tt := time.Time(t) return tt.MarshalText() } -func (t *timeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcLayoutJSON +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON if tzOffsetRegex.Match(data) { - layout = rfc3339JSON + layout = dateTimeJSON } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { - layout := utcLayout +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime if tzOffsetRegex.Match(data) { layout = time.RFC3339Nano } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) Parse(layout, value string) error { +func (t *dateTimeRFC3339) Parse(layout, value string) error { p, err := time.Parse(layout, strings.ToUpper(value)) - *t = timeRFC3339(p) + *t = dateTimeRFC3339(p) return err } -func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { @@ -70,14 +70,14 @@ func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { } else if reflect.ValueOf(t).IsNil() { return } - m[k] = (*timeRFC3339)(t) + m[k] = (*dateTimeRFC3339)(t) } -func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { if data == nil || strings.EqualFold(string(data), "null") { return nil } - var aux timeRFC3339 + var aux dateTimeRFC3339 if err := json.Unmarshal(data, &aux); err != nil { return fmt.Errorf("struct field %s: %v", fn, err) } diff --git a/sdk/resourcemanager/keyvault/armkeyvault/vaults_client.go b/sdk/resourcemanager/keyvault/armkeyvault/vaults_client.go index d791972ced43..00075aff0924 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/vaults_client.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/vaults_client.go @@ -34,7 +34,7 @@ type VaultsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewVaultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VaultsClient, error) { - cl, err := arm.NewClient(moduleName+".VaultsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,6 +54,10 @@ func NewVaultsClient(subscriptionID string, credential azcore.TokenCredential, o // method. func (client *VaultsClient) CheckNameAvailability(ctx context.Context, vaultName VaultCheckNameAvailabilityParameters, options *VaultsClientCheckNameAvailabilityOptions) (VaultsClientCheckNameAvailabilityResponse, error) { var err error + const operationName = "VaultsClient.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, vaultName, options) if err != nil { return VaultsClientCheckNameAvailabilityResponse{}, err @@ -115,10 +119,14 @@ func (client *VaultsClient) BeginCreateOrUpdate(ctx context.Context, resourceGro if err != nil { return nil, err } - poller, err := runtime.NewPoller[VaultsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VaultsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[VaultsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VaultsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -128,6 +136,10 @@ func (client *VaultsClient) BeginCreateOrUpdate(ctx context.Context, resourceGro // Generated from API version 2023-07-01 func (client *VaultsClient) createOrUpdate(ctx context.Context, resourceGroupName string, vaultName string, parameters VaultCreateOrUpdateParameters, options *VaultsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error + const operationName = "VaultsClient.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, vaultName, parameters, options) if err != nil { return nil, err @@ -181,6 +193,10 @@ func (client *VaultsClient) createOrUpdateCreateRequest(ctx context.Context, res // - options - VaultsClientDeleteOptions contains the optional parameters for the VaultsClient.Delete method. func (client *VaultsClient) Delete(ctx context.Context, resourceGroupName string, vaultName string, options *VaultsClientDeleteOptions) (VaultsClientDeleteResponse, error) { var err error + const operationName = "VaultsClient.Delete" + 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, vaultName, options) if err != nil { return VaultsClientDeleteResponse{}, err @@ -231,6 +247,10 @@ func (client *VaultsClient) deleteCreateRequest(ctx context.Context, resourceGro // - options - VaultsClientGetOptions contains the optional parameters for the VaultsClient.Get method. func (client *VaultsClient) Get(ctx context.Context, resourceGroupName string, vaultName string, options *VaultsClientGetOptions) (VaultsClientGetResponse, error) { var err error + const operationName = "VaultsClient.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, vaultName, options) if err != nil { return VaultsClientGetResponse{}, err @@ -291,6 +311,10 @@ func (client *VaultsClient) getHandleResponse(resp *http.Response) (VaultsClient // - options - VaultsClientGetDeletedOptions contains the optional parameters for the VaultsClient.GetDeleted method. func (client *VaultsClient) GetDeleted(ctx context.Context, vaultName string, location string, options *VaultsClientGetDeletedOptions) (VaultsClientGetDeletedResponse, error) { var err error + const operationName = "VaultsClient.GetDeleted" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getDeletedCreateRequest(ctx, vaultName, location, options) if err != nil { return VaultsClientGetDeletedResponse{}, err @@ -352,25 +376,20 @@ func (client *VaultsClient) NewListPager(options *VaultsClientListOptions) *runt return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *VaultsClientListResponse) (VaultsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VaultsClient.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, options) + }, nil) if err != nil { return VaultsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VaultsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return VaultsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -418,25 +437,20 @@ func (client *VaultsClient) NewListByResourceGroupPager(resourceGroupName string return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *VaultsClientListByResourceGroupResponse) (VaultsClientListByResourceGroupResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VaultsClient.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 VaultsClientListByResourceGroupResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VaultsClientListByResourceGroupResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return VaultsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -485,25 +499,20 @@ func (client *VaultsClient) NewListBySubscriptionPager(options *VaultsClientList return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *VaultsClientListBySubscriptionResponse) (VaultsClientListBySubscriptionResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listBySubscriptionCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VaultsClient.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 VaultsClientListBySubscriptionResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VaultsClientListBySubscriptionResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return VaultsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) - } return client.listBySubscriptionHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -547,25 +556,20 @@ func (client *VaultsClient) NewListDeletedPager(options *VaultsClientListDeleted return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *VaultsClientListDeletedResponse) (VaultsClientListDeletedResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listDeletedCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VaultsClient.NewListDeletedPager") + 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.listDeletedCreateRequest(ctx, options) + }, nil) if err != nil { return VaultsClientListDeletedResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VaultsClientListDeletedResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return VaultsClientListDeletedResponse{}, runtime.NewResponseError(resp) - } return client.listDeletedHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -610,10 +614,14 @@ func (client *VaultsClient) BeginPurgeDeleted(ctx context.Context, vaultName str if err != nil { return nil, err } - poller, err := runtime.NewPoller[VaultsClientPurgeDeletedResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VaultsClientPurgeDeletedResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[VaultsClientPurgeDeletedResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VaultsClientPurgeDeletedResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -623,6 +631,10 @@ func (client *VaultsClient) BeginPurgeDeleted(ctx context.Context, vaultName str // Generated from API version 2023-07-01 func (client *VaultsClient) purgeDeleted(ctx context.Context, vaultName string, location string, options *VaultsClientBeginPurgeDeletedOptions) (*http.Response, error) { var err error + const operationName = "VaultsClient.BeginPurgeDeleted" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.purgeDeletedCreateRequest(ctx, vaultName, location, options) if err != nil { return nil, err @@ -674,6 +686,10 @@ func (client *VaultsClient) purgeDeletedCreateRequest(ctx context.Context, vault // - options - VaultsClientUpdateOptions contains the optional parameters for the VaultsClient.Update method. func (client *VaultsClient) Update(ctx context.Context, resourceGroupName string, vaultName string, parameters VaultPatchParameters, options *VaultsClientUpdateOptions) (VaultsClientUpdateResponse, error) { var err error + const operationName = "VaultsClient.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, vaultName, parameters, options) if err != nil { return VaultsClientUpdateResponse{}, err @@ -740,6 +756,10 @@ func (client *VaultsClient) updateHandleResponse(resp *http.Response) (VaultsCli // method. func (client *VaultsClient) UpdateAccessPolicy(ctx context.Context, resourceGroupName string, vaultName string, operationKind AccessPolicyUpdateKind, parameters VaultAccessPolicyParameters, options *VaultsClientUpdateAccessPolicyOptions) (VaultsClientUpdateAccessPolicyResponse, error) { var err error + const operationName = "VaultsClient.UpdateAccessPolicy" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.updateAccessPolicyCreateRequest(ctx, resourceGroupName, vaultName, operationKind, parameters, options) if err != nil { return VaultsClientUpdateAccessPolicyResponse{}, err diff --git a/sdk/resourcemanager/keyvault/armkeyvault/vaults_client_example_test.go b/sdk/resourcemanager/keyvault/armkeyvault/vaults_client_example_test.go index ab5e455f71c9..8735ef2c2202 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/vaults_client_example_test.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/vaults_client_example_test.go @@ -197,10 +197,10 @@ func ExampleVaultsClient_BeginCreateOrUpdate_createANewVaultOrUpdateAnExistingVa // VaultURI: to.Ptr("https://sample-vault.vault.azure.net"), // }, // SystemData: &armkeyvault.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.0000000Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("keyVaultUser1"), // CreatedByType: to.Ptr(armkeyvault.IdentityTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.0000000Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.000Z"); return t}()), // LastModifiedBy: to.Ptr("keyVaultUser2"), // LastModifiedByType: to.Ptr(armkeyvault.IdentityTypeUser), // }, @@ -291,10 +291,10 @@ func ExampleVaultsClient_BeginCreateOrUpdate_createOrUpdateAVaultWithNetworkAcls // VaultURI: to.Ptr("https://sample-vault.vault.azure.net"), // }, // SystemData: &armkeyvault.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.0000000Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("keyVaultUser1"), // CreatedByType: to.Ptr(armkeyvault.IdentityTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.0000000Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.000Z"); return t}()), // LastModifiedBy: to.Ptr("keyVaultUser2"), // LastModifiedByType: to.Ptr(armkeyvault.IdentityTypeUser), // }, @@ -476,10 +476,10 @@ func ExampleVaultsClient_Update() { // VaultURI: to.Ptr("https://sample-vault.vault.azure.net"), // }, // SystemData: &armkeyvault.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.0000000Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("keyVaultUser1"), // CreatedByType: to.Ptr(armkeyvault.IdentityTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.0000000Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.000Z"); return t}()), // LastModifiedBy: to.Ptr("keyVaultUser2"), // LastModifiedByType: to.Ptr(armkeyvault.IdentityTypeUser), // }, @@ -591,10 +591,10 @@ func ExampleVaultsClient_Get() { // VaultURI: to.Ptr("https://sample-vault.vault.azure.net"), // }, // SystemData: &armkeyvault.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.0000000Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("keyVaultUser1"), // CreatedByType: to.Ptr(armkeyvault.IdentityTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.0000000Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.000Z"); return t}()), // LastModifiedBy: to.Ptr("keyVaultUser2"), // LastModifiedByType: to.Ptr(armkeyvault.IdentityTypeUser), // }, @@ -750,10 +750,10 @@ func ExampleVaultsClient_NewListByResourceGroupPager() { // VaultURI: to.Ptr("https://sample-vault.vault.azure.net/"), // }, // SystemData: &armkeyvault.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.0000000Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("keyVaultUser1"), // CreatedByType: to.Ptr(armkeyvault.IdentityTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.0000000Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.000Z"); return t}()), // LastModifiedBy: to.Ptr("keyVaultUser2"), // LastModifiedByType: to.Ptr(armkeyvault.IdentityTypeUser), // }, @@ -856,10 +856,10 @@ func ExampleVaultsClient_NewListBySubscriptionPager() { // VaultURI: to.Ptr("https://sample-vault.vault.azure.net/"), // }, // SystemData: &armkeyvault.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.0000000Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("keyVaultUser1"), // CreatedByType: to.Ptr(armkeyvault.IdentityTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.0000000Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-01-01T12:00:00.000Z"); return t}()), // LastModifiedBy: to.Ptr("keyVaultUser2"), // LastModifiedByType: to.Ptr(armkeyvault.IdentityTypeUser), // }, @@ -899,10 +899,10 @@ func ExampleVaultsClient_NewListDeletedPager() { // Type: to.Ptr("Microsoft.KeyVault/deletedVaults"), // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.KeyVault/locations/westus/deletedVaults/sample-vault"), // Properties: &armkeyvault.DeletedVaultProperties{ - // DeletionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-01-01T00:00:59Z"); return t}()), + // DeletionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-01-01T00:00:59.000Z"); return t}()), // Location: to.Ptr("westus"), // PurgeProtectionEnabled: to.Ptr(true), - // ScheduledPurgeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-01T00:00:59Z"); return t}()), + // ScheduledPurgeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-01T00:00:59.000Z"); return t}()), // Tags: map[string]*string{ // }, // VaultID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/sample-group/providers/Microsoft.KeyVault/vaults/sample-vault"), @@ -935,10 +935,10 @@ func ExampleVaultsClient_GetDeleted() { // Type: to.Ptr("Microsoft.KeyVault/deletedVaults"), // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.KeyVault/locations/westus/deletedVaults/sample-vault"), // Properties: &armkeyvault.DeletedVaultProperties{ - // DeletionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-01-01T00:00:59Z"); return t}()), + // DeletionDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-01-01T00:00:59.000Z"); return t}()), // Location: to.Ptr("westus"), // PurgeProtectionEnabled: to.Ptr(true), - // ScheduledPurgeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-01T00:00:59Z"); return t}()), + // ScheduledPurgeDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-04-01T00:00:59.000Z"); return t}()), // Tags: map[string]*string{ // }, // VaultID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/sample-group/providers/Microsoft.KeyVault/vaults/sample-vault"), diff --git a/sdk/resourcemanager/keyvault/armkeyvault/vaults_client_live_test.go b/sdk/resourcemanager/keyvault/armkeyvault/vaults_client_live_test.go index dcde62f4e027..0a5f76c3df43 100644 --- a/sdk/resourcemanager/keyvault/armkeyvault/vaults_client_live_test.go +++ b/sdk/resourcemanager/keyvault/armkeyvault/vaults_client_live_test.go @@ -14,7 +14,8 @@ import ( "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/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/testutil" + "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2/testutil" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/keyvault/armkeyvault" "github.com/stretchr/testify/suite" ) @@ -35,10 +36,10 @@ type VaultsClientTestSuite struct { func (testsuite *VaultsClientTestSuite) SetupSuite() { testsuite.ctx = context.Background() testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T()) - testsuite.location = testutil.GetEnv("LOCATION", "eastus") - testsuite.subscriptionID = testutil.GetEnv("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") - testsuite.tenantID = testutil.GetEnv("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") - testsuite.objectID = testutil.GetEnv("AZURE_OBJECT_ID", "00000000-0000-0000-0000-000000000000") + testsuite.location = recording.GetEnvVariable("LOCATION", "eastus") + testsuite.subscriptionID = recording.GetEnvVariable("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + testsuite.tenantID = recording.GetEnvVariable("AZURE_TENANT_ID", "00000000-0000-0000-0000-000000000000") + testsuite.objectID = recording.GetEnvVariable("AZURE_OBJECT_ID", "00000000-0000-0000-0000-000000000000") testutil.StartRecording(testsuite.T(), "sdk/resourcemanager/keyvault/armkeyvault/testdata") resourceGroup, _, err := testutil.CreateResourceGroup(testsuite.ctx, testsuite.subscriptionID, testsuite.cred, testsuite.options, testsuite.location) testsuite.Require().NoError(err) diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/CHANGELOG.md b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/CHANGELOG.md index da643a860106..96bfb859e261 100644 --- a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/CHANGELOG.md +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 2.2.0 (2023-11-24) +### Features Added + +- Support for test fakes and OpenTelemetry trace spans. + + ## 2.1.0 (2023-09-22) ### Features Added diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/README.md b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/README.md index e4b380fa8669..2e4b7795483b 100644 --- a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/README.md +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/README.md @@ -60,6 +60,13 @@ A client groups a set of related APIs, providing access to its functionality. C client := clientFactory.NewSourceControlConfigurationsClient() ``` +## 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 diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/autorest.md b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/autorest.md index 5e7bec525e15..38ea33b46bf0 100644 --- a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/autorest.md +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/80c21c17b4a7aa57f637ee594f7cfd653255a7e0/specification/kubernetesconfiguration/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/80c21c17b4a7aa57f637ee594f7cfd653255a7e0/specification/kubernetesconfiguration/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 2.1.0 +module-version: 2.2.0 tag: package-2023-05 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/client_factory.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/client_factory.go index 8fa4c191d513..d68b4ec4a458 100644 --- a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/client_factory.go +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/client_factory.go @@ -27,7 +27,7 @@ type ClientFactory struct { // - 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+".ClientFactory", moduleVersion, credential, options) + _, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -37,31 +37,37 @@ func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, }, nil } +// NewExtensionsClient creates a new instance of ExtensionsClient. func (c *ClientFactory) NewExtensionsClient() *ExtensionsClient { subClient, _ := NewExtensionsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewFluxConfigOperationStatusClient creates a new instance of FluxConfigOperationStatusClient. func (c *ClientFactory) NewFluxConfigOperationStatusClient() *FluxConfigOperationStatusClient { subClient, _ := NewFluxConfigOperationStatusClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewFluxConfigurationsClient creates a new instance of FluxConfigurationsClient. func (c *ClientFactory) NewFluxConfigurationsClient() *FluxConfigurationsClient { subClient, _ := NewFluxConfigurationsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewOperationStatusClient creates a new instance of OperationStatusClient. func (c *ClientFactory) NewOperationStatusClient() *OperationStatusClient { subClient, _ := NewOperationStatusClient(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 } +// NewSourceControlConfigurationsClient creates a new instance of SourceControlConfigurationsClient. func (c *ClientFactory) NewSourceControlConfigurationsClient() *SourceControlConfigurationsClient { subClient, _ := NewSourceControlConfigurationsClient(c.subscriptionID, c.credential, c.options) return subClient diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/constants.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/constants.go index 86977825462d..84bc137a7f1b 100644 --- a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/constants.go +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/constants.go @@ -9,8 +9,8 @@ package armkubernetesconfiguration const ( - moduleName = "armkubernetesconfiguration" - moduleVersion = "v2.1.0" + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration" + moduleVersion = "v2.2.0" ) // AKSIdentityType - The identity type. diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/extensions_client.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/extensions_client.go index 26264f16c2a1..646ed3bd3c0f 100644 --- a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/extensions_client.go +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/extensions_client.go @@ -33,7 +33,7 @@ type ExtensionsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewExtensionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ExtensionsClient, error) { - cl, err := arm.NewClient(moduleName+".ExtensionsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -63,10 +63,13 @@ func (client *ExtensionsClient) BeginCreate(ctx context.Context, resourceGroupNa } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExtensionsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ExtensionsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ExtensionsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -76,6 +79,10 @@ func (client *ExtensionsClient) BeginCreate(ctx context.Context, resourceGroupNa // Generated from API version 2023-05-01 func (client *ExtensionsClient) create(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, extension Extension, options *ExtensionsClientBeginCreateOptions) (*http.Response, error) { var err error + const operationName = "ExtensionsClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createCreateRequest(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, extensionName, extension, options) if err != nil { return nil, err @@ -150,10 +157,13 @@ func (client *ExtensionsClient) BeginDelete(ctx context.Context, resourceGroupNa } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExtensionsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ExtensionsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ExtensionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -163,6 +173,10 @@ func (client *ExtensionsClient) BeginDelete(ctx context.Context, resourceGroupNa // Generated from API version 2023-05-01 func (client *ExtensionsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, options *ExtensionsClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "ExtensionsClient.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, clusterRp, clusterResourceName, clusterName, extensionName, options) if err != nil { return nil, err @@ -231,6 +245,10 @@ func (client *ExtensionsClient) deleteCreateRequest(ctx context.Context, resourc // - options - ExtensionsClientGetOptions contains the optional parameters for the ExtensionsClient.Get method. func (client *ExtensionsClient) Get(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, options *ExtensionsClientGetOptions) (ExtensionsClientGetResponse, error) { var err error + const operationName = "ExtensionsClient.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, clusterRp, clusterResourceName, clusterName, extensionName, options) if err != nil { return ExtensionsClientGetResponse{}, err @@ -308,25 +326,20 @@ func (client *ExtensionsClient) NewListPager(resourceGroupName string, clusterRp return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ExtensionsClientListResponse) (ExtensionsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ExtensionsClient.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, resourceGroupName, clusterRp, clusterResourceName, clusterName, options) + }, nil) if err != nil { return ExtensionsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ExtensionsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ExtensionsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -392,10 +405,13 @@ func (client *ExtensionsClient) BeginUpdate(ctx context.Context, resourceGroupNa } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ExtensionsClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ExtensionsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ExtensionsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -405,6 +421,10 @@ func (client *ExtensionsClient) BeginUpdate(ctx context.Context, resourceGroupNa // Generated from API version 2023-05-01 func (client *ExtensionsClient) update(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, patchExtension PatchExtension, options *ExtensionsClientBeginUpdateOptions) (*http.Response, error) { var err error + const operationName = "ExtensionsClient.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, clusterRp, clusterResourceName, clusterName, extensionName, patchExtension, options) if err != nil { return nil, err diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/extensions_server.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/extensions_server.go new file mode 100644 index 000000000000..7c031ea9ec88 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/extensions_server.go @@ -0,0 +1,388 @@ +//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/kubernetesconfiguration/armkubernetesconfiguration/v2" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// ExtensionsServer is a fake server for instances of the armkubernetesconfiguration.ExtensionsClient type. +type ExtensionsServer struct { + // BeginCreate is the fake for method ExtensionsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, extension armkubernetesconfiguration.Extension, options *armkubernetesconfiguration.ExtensionsClientBeginCreateOptions) (resp azfake.PollerResponder[armkubernetesconfiguration.ExtensionsClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method ExtensionsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, options *armkubernetesconfiguration.ExtensionsClientBeginDeleteOptions) (resp azfake.PollerResponder[armkubernetesconfiguration.ExtensionsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ExtensionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, options *armkubernetesconfiguration.ExtensionsClientGetOptions) (resp azfake.Responder[armkubernetesconfiguration.ExtensionsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method ExtensionsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, options *armkubernetesconfiguration.ExtensionsClientListOptions) (resp azfake.PagerResponder[armkubernetesconfiguration.ExtensionsClientListResponse]) + + // BeginUpdate is the fake for method ExtensionsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, patchExtension armkubernetesconfiguration.PatchExtension, options *armkubernetesconfiguration.ExtensionsClientBeginUpdateOptions) (resp azfake.PollerResponder[armkubernetesconfiguration.ExtensionsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewExtensionsServerTransport creates a new instance of ExtensionsServerTransport with the provided implementation. +// The returned ExtensionsServerTransport instance is connected to an instance of armkubernetesconfiguration.ExtensionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewExtensionsServerTransport(srv *ExtensionsServer) *ExtensionsServerTransport { + return &ExtensionsServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armkubernetesconfiguration.ExtensionsClientCreateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armkubernetesconfiguration.ExtensionsClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armkubernetesconfiguration.ExtensionsClientListResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armkubernetesconfiguration.ExtensionsClientUpdateResponse]](), + } +} + +// ExtensionsServerTransport connects instances of armkubernetesconfiguration.ExtensionsClient to instances of ExtensionsServer. +// Don't use this type directly, use NewExtensionsServerTransport instead. +type ExtensionsServerTransport struct { + srv *ExtensionsServer + beginCreate *tracker[azfake.PollerResponder[armkubernetesconfiguration.ExtensionsClientCreateResponse]] + beginDelete *tracker[azfake.PollerResponder[armkubernetesconfiguration.ExtensionsClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armkubernetesconfiguration.ExtensionsClientListResponse]] + beginUpdate *tracker[azfake.PollerResponder[armkubernetesconfiguration.ExtensionsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for ExtensionsServerTransport. +func (e *ExtensionsServerTransport) 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 "ExtensionsClient.BeginCreate": + resp, err = e.dispatchBeginCreate(req) + case "ExtensionsClient.BeginDelete": + resp, err = e.dispatchBeginDelete(req) + case "ExtensionsClient.Get": + resp, err = e.dispatchGet(req) + case "ExtensionsClient.NewListPager": + resp, err = e.dispatchNewListPager(req) + case "ExtensionsClient.BeginUpdate": + resp, err = e.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (e *ExtensionsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if e.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := e.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/extensions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkubernetesconfiguration.Extension](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + extensionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginCreate(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, extensionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + e.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + e.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + e.beginCreate.remove(req) + } + + return resp, nil +} + +func (e *ExtensionsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if e.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := e.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/extensions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + extensionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionName")]) + if err != nil { + return nil, err + } + forceDeleteUnescaped, err := url.QueryUnescape(qp.Get("forceDelete")) + if err != nil { + return nil, err + } + forceDeleteParam, err := parseOptional(forceDeleteUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + var options *armkubernetesconfiguration.ExtensionsClientBeginDeleteOptions + if forceDeleteParam != nil { + options = &armkubernetesconfiguration.ExtensionsClientBeginDeleteOptions{ + ForceDelete: forceDeleteParam, + } + } + respr, errRespr := e.srv.BeginDelete(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, extensionNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + e.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) { + e.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) { + e.beginDelete.remove(req) + } + + return resp, nil +} + +func (e *ExtensionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if e.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/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/extensions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + 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 + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + extensionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.Get(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, extensionNameParam, 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).Extension, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (e *ExtensionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if e.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := e.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/extensions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + resp := e.srv.NewListPager(resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, nil) + newListPager = &resp + e.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armkubernetesconfiguration.ExtensionsClientListResponse, 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) { + e.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + e.newListPager.remove(req) + } + return resp, nil +} + +func (e *ExtensionsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if e.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := e.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/extensions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkubernetesconfiguration.PatchExtension](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + extensionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionName")]) + if err != nil { + return nil, err + } + respr, errRespr := e.srv.BeginUpdate(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, extensionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + e.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) { + e.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) { + e.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/fluxconfigoperationstatus_server.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/fluxconfigoperationstatus_server.go new file mode 100644 index 000000000000..d9848430a106 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/fluxconfigoperationstatus_server.go @@ -0,0 +1,116 @@ +//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/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/v2" + "net/http" + "net/url" + "regexp" +) + +// FluxConfigOperationStatusServer is a fake server for instances of the armkubernetesconfiguration.FluxConfigOperationStatusClient type. +type FluxConfigOperationStatusServer struct { + // Get is the fake for method FluxConfigOperationStatusClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, operationID string, options *armkubernetesconfiguration.FluxConfigOperationStatusClientGetOptions) (resp azfake.Responder[armkubernetesconfiguration.FluxConfigOperationStatusClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewFluxConfigOperationStatusServerTransport creates a new instance of FluxConfigOperationStatusServerTransport with the provided implementation. +// The returned FluxConfigOperationStatusServerTransport instance is connected to an instance of armkubernetesconfiguration.FluxConfigOperationStatusClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewFluxConfigOperationStatusServerTransport(srv *FluxConfigOperationStatusServer) *FluxConfigOperationStatusServerTransport { + return &FluxConfigOperationStatusServerTransport{srv: srv} +} + +// FluxConfigOperationStatusServerTransport connects instances of armkubernetesconfiguration.FluxConfigOperationStatusClient to instances of FluxConfigOperationStatusServer. +// Don't use this type directly, use NewFluxConfigOperationStatusServerTransport instead. +type FluxConfigOperationStatusServerTransport struct { + srv *FluxConfigOperationStatusServer +} + +// Do implements the policy.Transporter interface for FluxConfigOperationStatusServerTransport. +func (f *FluxConfigOperationStatusServerTransport) 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 "FluxConfigOperationStatusClient.Get": + resp, err = f.dispatchGet(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (f *FluxConfigOperationStatusServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if f.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/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/fluxConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 7 { + 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 + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + fluxConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fluxConfigurationName")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.Get(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, fluxConfigurationNameParam, operationIDParam, 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).OperationStatusResult, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/fluxconfigurations_server.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/fluxconfigurations_server.go new file mode 100644 index 000000000000..14895f5a07c3 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/fluxconfigurations_server.go @@ -0,0 +1,388 @@ +//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/kubernetesconfiguration/armkubernetesconfiguration/v2" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// FluxConfigurationsServer is a fake server for instances of the armkubernetesconfiguration.FluxConfigurationsClient type. +type FluxConfigurationsServer struct { + // BeginCreateOrUpdate is the fake for method FluxConfigurationsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, fluxConfiguration armkubernetesconfiguration.FluxConfiguration, options *armkubernetesconfiguration.FluxConfigurationsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armkubernetesconfiguration.FluxConfigurationsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method FluxConfigurationsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, options *armkubernetesconfiguration.FluxConfigurationsClientBeginDeleteOptions) (resp azfake.PollerResponder[armkubernetesconfiguration.FluxConfigurationsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method FluxConfigurationsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, options *armkubernetesconfiguration.FluxConfigurationsClientGetOptions) (resp azfake.Responder[armkubernetesconfiguration.FluxConfigurationsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method FluxConfigurationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, options *armkubernetesconfiguration.FluxConfigurationsClientListOptions) (resp azfake.PagerResponder[armkubernetesconfiguration.FluxConfigurationsClientListResponse]) + + // BeginUpdate is the fake for method FluxConfigurationsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, fluxConfigurationPatch armkubernetesconfiguration.FluxConfigurationPatch, options *armkubernetesconfiguration.FluxConfigurationsClientBeginUpdateOptions) (resp azfake.PollerResponder[armkubernetesconfiguration.FluxConfigurationsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewFluxConfigurationsServerTransport creates a new instance of FluxConfigurationsServerTransport with the provided implementation. +// The returned FluxConfigurationsServerTransport instance is connected to an instance of armkubernetesconfiguration.FluxConfigurationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewFluxConfigurationsServerTransport(srv *FluxConfigurationsServer) *FluxConfigurationsServerTransport { + return &FluxConfigurationsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armkubernetesconfiguration.FluxConfigurationsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armkubernetesconfiguration.FluxConfigurationsClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armkubernetesconfiguration.FluxConfigurationsClientListResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armkubernetesconfiguration.FluxConfigurationsClientUpdateResponse]](), + } +} + +// FluxConfigurationsServerTransport connects instances of armkubernetesconfiguration.FluxConfigurationsClient to instances of FluxConfigurationsServer. +// Don't use this type directly, use NewFluxConfigurationsServerTransport instead. +type FluxConfigurationsServerTransport struct { + srv *FluxConfigurationsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armkubernetesconfiguration.FluxConfigurationsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armkubernetesconfiguration.FluxConfigurationsClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armkubernetesconfiguration.FluxConfigurationsClientListResponse]] + beginUpdate *tracker[azfake.PollerResponder[armkubernetesconfiguration.FluxConfigurationsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for FluxConfigurationsServerTransport. +func (f *FluxConfigurationsServerTransport) 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 "FluxConfigurationsClient.BeginCreateOrUpdate": + resp, err = f.dispatchBeginCreateOrUpdate(req) + case "FluxConfigurationsClient.BeginDelete": + resp, err = f.dispatchBeginDelete(req) + case "FluxConfigurationsClient.Get": + resp, err = f.dispatchGet(req) + case "FluxConfigurationsClient.NewListPager": + resp, err = f.dispatchNewListPager(req) + case "FluxConfigurationsClient.BeginUpdate": + resp, err = f.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (f *FluxConfigurationsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if f.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := f.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/fluxConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkubernetesconfiguration.FluxConfiguration](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + fluxConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fluxConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, fluxConfigurationNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + f.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) { + f.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) { + f.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (f *FluxConfigurationsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if f.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := f.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/fluxConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + fluxConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fluxConfigurationName")]) + if err != nil { + return nil, err + } + forceDeleteUnescaped, err := url.QueryUnescape(qp.Get("forceDelete")) + if err != nil { + return nil, err + } + forceDeleteParam, err := parseOptional(forceDeleteUnescaped, strconv.ParseBool) + if err != nil { + return nil, err + } + var options *armkubernetesconfiguration.FluxConfigurationsClientBeginDeleteOptions + if forceDeleteParam != nil { + options = &armkubernetesconfiguration.FluxConfigurationsClientBeginDeleteOptions{ + ForceDelete: forceDeleteParam, + } + } + respr, errRespr := f.srv.BeginDelete(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, fluxConfigurationNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + f.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) { + f.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) { + f.beginDelete.remove(req) + } + + return resp, nil +} + +func (f *FluxConfigurationsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if f.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/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/fluxConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + 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 + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + fluxConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fluxConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.Get(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, fluxConfigurationNameParam, 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).FluxConfiguration, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (f *FluxConfigurationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if f.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := f.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/fluxConfigurations` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + resp := f.srv.NewListPager(resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, nil) + newListPager = &resp + f.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armkubernetesconfiguration.FluxConfigurationsClientListResponse, 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) { + f.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + f.newListPager.remove(req) + } + return resp, nil +} + +func (f *FluxConfigurationsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if f.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := f.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/fluxConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkubernetesconfiguration.FluxConfigurationPatch](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + fluxConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fluxConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginUpdate(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, fluxConfigurationNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + f.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) { + f.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) { + f.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/internal.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/internal.go new file mode 100644 index 000000000000..4d8bd36394ec --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/internal.go @@ -0,0 +1,75 @@ +//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 ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "sync" +) + +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 parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) { + if v == "" { + return nil, nil + } + t, err := parse(v) + if err != nil { + return nil, err + } + return &t, err +} + +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/kubernetesconfiguration/armkubernetesconfiguration/fake/operations_server.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/operations_server.go new file mode 100644 index 000000000000..2c1425a3394a --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/operations_server.go @@ -0,0 +1,96 @@ +//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 ( + "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/kubernetesconfiguration/armkubernetesconfiguration/v2" + "net/http" +) + +// OperationsServer is a fake server for instances of the armkubernetesconfiguration.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armkubernetesconfiguration.OperationsClientListOptions) (resp azfake.PagerResponder[armkubernetesconfiguration.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armkubernetesconfiguration.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[armkubernetesconfiguration.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armkubernetesconfiguration.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armkubernetesconfiguration.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) 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 "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armkubernetesconfiguration.OperationsClientListResponse, 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) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/operationstatus_server.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/operationstatus_server.go new file mode 100644 index 000000000000..cb60bb9cf009 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/operationstatus_server.go @@ -0,0 +1,176 @@ +//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/kubernetesconfiguration/armkubernetesconfiguration/v2" + "net/http" + "net/url" + "regexp" +) + +// OperationStatusServer is a fake server for instances of the armkubernetesconfiguration.OperationStatusClient type. +type OperationStatusServer struct { + // Get is the fake for method OperationStatusClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, operationID string, options *armkubernetesconfiguration.OperationStatusClientGetOptions) (resp azfake.Responder[armkubernetesconfiguration.OperationStatusClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method OperationStatusClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, options *armkubernetesconfiguration.OperationStatusClientListOptions) (resp azfake.PagerResponder[armkubernetesconfiguration.OperationStatusClientListResponse]) +} + +// NewOperationStatusServerTransport creates a new instance of OperationStatusServerTransport with the provided implementation. +// The returned OperationStatusServerTransport instance is connected to an instance of armkubernetesconfiguration.OperationStatusClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationStatusServerTransport(srv *OperationStatusServer) *OperationStatusServerTransport { + return &OperationStatusServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armkubernetesconfiguration.OperationStatusClientListResponse]](), + } +} + +// OperationStatusServerTransport connects instances of armkubernetesconfiguration.OperationStatusClient to instances of OperationStatusServer. +// Don't use this type directly, use NewOperationStatusServerTransport instead. +type OperationStatusServerTransport struct { + srv *OperationStatusServer + newListPager *tracker[azfake.PagerResponder[armkubernetesconfiguration.OperationStatusClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationStatusServerTransport. +func (o *OperationStatusServerTransport) 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 "OperationStatusClient.Get": + resp, err = o.dispatchGet(req) + case "OperationStatusClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationStatusServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if o.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/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/extensions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 7 { + 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 + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + extensionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("extensionName")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.Get(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, extensionNameParam, operationIDParam, 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).OperationStatusResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (o *OperationStatusServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/operations` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + resp := o.srv.NewListPager(resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armkubernetesconfiguration.OperationStatusClientListResponse, 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) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/server_factory.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/server_factory.go new file mode 100644 index 000000000000..b1af50755264 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/server_factory.go @@ -0,0 +1,108 @@ +//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 ( + "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 armkubernetesconfiguration.ClientFactory type. +type ServerFactory struct { + ExtensionsServer ExtensionsServer + FluxConfigOperationStatusServer FluxConfigOperationStatusServer + FluxConfigurationsServer FluxConfigurationsServer + OperationStatusServer OperationStatusServer + OperationsServer OperationsServer + SourceControlConfigurationsServer SourceControlConfigurationsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armkubernetesconfiguration.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 armkubernetesconfiguration.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trExtensionsServer *ExtensionsServerTransport + trFluxConfigOperationStatusServer *FluxConfigOperationStatusServerTransport + trFluxConfigurationsServer *FluxConfigurationsServerTransport + trOperationStatusServer *OperationStatusServerTransport + trOperationsServer *OperationsServerTransport + trSourceControlConfigurationsServer *SourceControlConfigurationsServerTransport +} + +// 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 "ExtensionsClient": + initServer(s, &s.trExtensionsServer, func() *ExtensionsServerTransport { return NewExtensionsServerTransport(&s.srv.ExtensionsServer) }) + resp, err = s.trExtensionsServer.Do(req) + case "FluxConfigOperationStatusClient": + initServer(s, &s.trFluxConfigOperationStatusServer, func() *FluxConfigOperationStatusServerTransport { + return NewFluxConfigOperationStatusServerTransport(&s.srv.FluxConfigOperationStatusServer) + }) + resp, err = s.trFluxConfigOperationStatusServer.Do(req) + case "FluxConfigurationsClient": + initServer(s, &s.trFluxConfigurationsServer, func() *FluxConfigurationsServerTransport { + return NewFluxConfigurationsServerTransport(&s.srv.FluxConfigurationsServer) + }) + resp, err = s.trFluxConfigurationsServer.Do(req) + case "OperationStatusClient": + initServer(s, &s.trOperationStatusServer, func() *OperationStatusServerTransport { + return NewOperationStatusServerTransport(&s.srv.OperationStatusServer) + }) + resp, err = s.trOperationStatusServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "SourceControlConfigurationsClient": + initServer(s, &s.trSourceControlConfigurationsServer, func() *SourceControlConfigurationsServerTransport { + return NewSourceControlConfigurationsServerTransport(&s.srv.SourceControlConfigurationsServer) + }) + resp, err = s.trSourceControlConfigurationsServer.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/kubernetesconfiguration/armkubernetesconfiguration/fake/sourcecontrolconfigurations_server.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/sourcecontrolconfigurations_server.go new file mode 100644 index 000000000000..cd7a466bcb40 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/sourcecontrolconfigurations_server.go @@ -0,0 +1,291 @@ +//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/kubernetesconfiguration/armkubernetesconfiguration/v2" + "net/http" + "net/url" + "regexp" +) + +// SourceControlConfigurationsServer is a fake server for instances of the armkubernetesconfiguration.SourceControlConfigurationsClient type. +type SourceControlConfigurationsServer struct { + // CreateOrUpdate is the fake for method SourceControlConfigurationsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, sourceControlConfigurationName string, sourceControlConfiguration armkubernetesconfiguration.SourceControlConfiguration, options *armkubernetesconfiguration.SourceControlConfigurationsClientCreateOrUpdateOptions) (resp azfake.Responder[armkubernetesconfiguration.SourceControlConfigurationsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method SourceControlConfigurationsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, sourceControlConfigurationName string, options *armkubernetesconfiguration.SourceControlConfigurationsClientBeginDeleteOptions) (resp azfake.PollerResponder[armkubernetesconfiguration.SourceControlConfigurationsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method SourceControlConfigurationsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, sourceControlConfigurationName string, options *armkubernetesconfiguration.SourceControlConfigurationsClientGetOptions) (resp azfake.Responder[armkubernetesconfiguration.SourceControlConfigurationsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method SourceControlConfigurationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, options *armkubernetesconfiguration.SourceControlConfigurationsClientListOptions) (resp azfake.PagerResponder[armkubernetesconfiguration.SourceControlConfigurationsClientListResponse]) +} + +// NewSourceControlConfigurationsServerTransport creates a new instance of SourceControlConfigurationsServerTransport with the provided implementation. +// The returned SourceControlConfigurationsServerTransport instance is connected to an instance of armkubernetesconfiguration.SourceControlConfigurationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSourceControlConfigurationsServerTransport(srv *SourceControlConfigurationsServer) *SourceControlConfigurationsServerTransport { + return &SourceControlConfigurationsServerTransport{ + srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armkubernetesconfiguration.SourceControlConfigurationsClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armkubernetesconfiguration.SourceControlConfigurationsClientListResponse]](), + } +} + +// SourceControlConfigurationsServerTransport connects instances of armkubernetesconfiguration.SourceControlConfigurationsClient to instances of SourceControlConfigurationsServer. +// Don't use this type directly, use NewSourceControlConfigurationsServerTransport instead. +type SourceControlConfigurationsServerTransport struct { + srv *SourceControlConfigurationsServer + beginDelete *tracker[azfake.PollerResponder[armkubernetesconfiguration.SourceControlConfigurationsClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armkubernetesconfiguration.SourceControlConfigurationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for SourceControlConfigurationsServerTransport. +func (s *SourceControlConfigurationsServerTransport) 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 "SourceControlConfigurationsClient.CreateOrUpdate": + resp, err = s.dispatchCreateOrUpdate(req) + case "SourceControlConfigurationsClient.BeginDelete": + resp, err = s.dispatchBeginDelete(req) + case "SourceControlConfigurationsClient.Get": + resp, err = s.dispatchGet(req) + case "SourceControlConfigurationsClient.NewListPager": + resp, err = s.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SourceControlConfigurationsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/sourceControlConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkubernetesconfiguration.SourceControlConfiguration](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + sourceControlConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("sourceControlConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, sourceControlConfigurationNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).SourceControlConfiguration, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SourceControlConfigurationsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if s.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := s.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/sourceControlConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + 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 + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + sourceControlConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("sourceControlConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginDelete(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, sourceControlConfigurationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + s.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusNoContent}, resp.StatusCode) { + s.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + s.beginDelete.remove(req) + } + + return resp, nil +} + +func (s *SourceControlConfigurationsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.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/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/sourceControlConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + 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 + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + sourceControlConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("sourceControlConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, sourceControlConfigurationNameParam, 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).SourceControlConfiguration, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SourceControlConfigurationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := s.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.KubernetesConfiguration/sourceControlConfigurations` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + clusterRpParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterRp")]) + if err != nil { + return nil, err + } + clusterResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterResourceName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListPager(resourceGroupNameParam, clusterRpParam, clusterResourceNameParam, clusterNameParam, nil) + newListPager = &resp + s.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armkubernetesconfiguration.SourceControlConfigurationsClientListResponse, 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) { + s.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + s.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/time_rfc3339.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/time_rfc3339.go new file mode 100644 index 000000000000..b0535a7b63e6 --- /dev/null +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fake/time_rfc3339.go @@ -0,0 +1,86 @@ +//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 ( + "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 ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +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 { + layout := utcDateTimeJSON + if tzOffsetRegex.Match(data) { + layout = dateTimeJSON + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + 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 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 || strings.EqualFold(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/kubernetesconfiguration/armkubernetesconfiguration/fluxconfigoperationstatus_client.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fluxconfigoperationstatus_client.go index 8656b56f46d4..b75bced7a001 100644 --- a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fluxconfigoperationstatus_client.go +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fluxconfigoperationstatus_client.go @@ -32,7 +32,7 @@ type FluxConfigOperationStatusClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewFluxConfigOperationStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FluxConfigOperationStatusClient, error) { - cl, err := arm.NewClient(moduleName+".FluxConfigOperationStatusClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -57,6 +57,10 @@ func NewFluxConfigOperationStatusClient(subscriptionID string, credential azcore // method. func (client *FluxConfigOperationStatusClient) Get(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, operationID string, options *FluxConfigOperationStatusClientGetOptions) (FluxConfigOperationStatusClientGetResponse, error) { var err error + const operationName = "FluxConfigOperationStatusClient.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, clusterRp, clusterResourceName, clusterName, fluxConfigurationName, operationID, options) if err != nil { return FluxConfigOperationStatusClientGetResponse{}, err diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fluxconfigurations_client.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fluxconfigurations_client.go index 297326505616..859edd1d1f8b 100644 --- a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fluxconfigurations_client.go +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fluxconfigurations_client.go @@ -33,7 +33,7 @@ type FluxConfigurationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewFluxConfigurationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FluxConfigurationsClient, error) { - cl, err := arm.NewClient(moduleName+".FluxConfigurationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -64,10 +64,13 @@ func (client *FluxConfigurationsClient) BeginCreateOrUpdate(ctx context.Context, } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FluxConfigurationsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken[FluxConfigurationsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FluxConfigurationsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -77,6 +80,10 @@ func (client *FluxConfigurationsClient) BeginCreateOrUpdate(ctx context.Context, // Generated from API version 2023-05-01 func (client *FluxConfigurationsClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, fluxConfiguration FluxConfiguration, options *FluxConfigurationsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error + const operationName = "FluxConfigurationsClient.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, clusterRp, clusterResourceName, clusterName, fluxConfigurationName, fluxConfiguration, options) if err != nil { return nil, err @@ -153,10 +160,13 @@ func (client *FluxConfigurationsClient) BeginDelete(ctx context.Context, resourc } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FluxConfigurationsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken[FluxConfigurationsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FluxConfigurationsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -167,6 +177,10 @@ func (client *FluxConfigurationsClient) BeginDelete(ctx context.Context, resourc // Generated from API version 2023-05-01 func (client *FluxConfigurationsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, options *FluxConfigurationsClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "FluxConfigurationsClient.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, clusterRp, clusterResourceName, clusterName, fluxConfigurationName, options) if err != nil { return nil, err @@ -235,6 +249,10 @@ func (client *FluxConfigurationsClient) deleteCreateRequest(ctx context.Context, // - options - FluxConfigurationsClientGetOptions contains the optional parameters for the FluxConfigurationsClient.Get method. func (client *FluxConfigurationsClient) Get(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, options *FluxConfigurationsClientGetOptions) (FluxConfigurationsClientGetResponse, error) { var err error + const operationName = "FluxConfigurationsClient.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, clusterRp, clusterResourceName, clusterName, fluxConfigurationName, options) if err != nil { return FluxConfigurationsClientGetResponse{}, err @@ -313,25 +331,20 @@ func (client *FluxConfigurationsClient) NewListPager(resourceGroupName string, c return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *FluxConfigurationsClientListResponse) (FluxConfigurationsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "FluxConfigurationsClient.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, resourceGroupName, clusterRp, clusterResourceName, clusterName, options) + }, nil) if err != nil { return FluxConfigurationsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return FluxConfigurationsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FluxConfigurationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -398,10 +411,13 @@ func (client *FluxConfigurationsClient) BeginUpdate(ctx context.Context, resourc } poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FluxConfigurationsClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), }) return poller, err } else { - return runtime.NewPollerFromResumeToken[FluxConfigurationsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FluxConfigurationsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -411,6 +427,10 @@ func (client *FluxConfigurationsClient) BeginUpdate(ctx context.Context, resourc // Generated from API version 2023-05-01 func (client *FluxConfigurationsClient) update(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, fluxConfigurationName string, fluxConfigurationPatch FluxConfigurationPatch, options *FluxConfigurationsClientBeginUpdateOptions) (*http.Response, error) { var err error + const operationName = "FluxConfigurationsClient.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, clusterRp, clusterResourceName, clusterName, fluxConfigurationName, fluxConfigurationPatch, options) if err != nil { return nil, err diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fluxconfigurations_client_example_test.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fluxconfigurations_client_example_test.go index ba28e4ce7ad9..acdff00dd174 100644 --- a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fluxconfigurations_client_example_test.go +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/fluxconfigurations_client_example_test.go @@ -104,8 +104,8 @@ func ExampleFluxConfigurationsClient_Get() { // Scope: to.Ptr(armkubernetesconfiguration.ScopeTypeCluster), // SourceKind: to.Ptr(armkubernetesconfiguration.SourceKindTypeGitRepository), // SourceSyncedCommitID: to.Ptr("master/0ba6f0d30760d567de0bac86c8c4eec13ce1a590"), - // SourceUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12Z"); return t}()), - // StatusUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12Z"); return t}()), + // SourceUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12.000Z"); return t}()), + // StatusUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12.000Z"); return t}()), // Statuses: []*armkubernetesconfiguration.ObjectStatusDefinition{ // { // Name: to.Ptr("srs-fluxconfig"), @@ -114,7 +114,7 @@ func ExampleFluxConfigurationsClient_Get() { // StatusConditions: []*armkubernetesconfiguration.ObjectStatusConditionDefinition{ // { // Type: to.Ptr("Ready"), - // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40Z"); return t}()), + // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40.000Z"); return t}()), // Message: to.Ptr("'Fetched revision: master/0ba6f0d30760d567de0bac86c8c4eec13ce1a590'"), // Reason: to.Ptr("GitOperationSucceed"), // Status: to.Ptr("True"), @@ -138,7 +138,7 @@ func ExampleFluxConfigurationsClient_Get() { // StatusConditions: []*armkubernetesconfiguration.ObjectStatusConditionDefinition{ // { // Type: to.Ptr("Ready"), - // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40Z"); return t}()), + // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40.000Z"); return t}()), // Message: to.Ptr("'Applied revision: master/0ba6f0d30760d567de0bac86c8c4eec13ce1a590'"), // Reason: to.Ptr("ReconciliationSucceeded"), // Status: to.Ptr("True"), @@ -158,7 +158,7 @@ func ExampleFluxConfigurationsClient_Get() { // StatusConditions: []*armkubernetesconfiguration.ObjectStatusConditionDefinition{ // { // Type: to.Ptr("Ready"), - // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40Z"); return t}()), + // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40.000Z"); return t}()), // Message: to.Ptr("'Applied revision: master/0ba6f0d30760d567de0bac86c8c4eec13ce1a590'"), // Reason: to.Ptr("ReconciliationSucceeded"), // Status: to.Ptr("True"), @@ -330,8 +330,8 @@ func ExampleFluxConfigurationsClient_BeginCreateOrUpdate_createFluxConfiguration // Scope: to.Ptr(armkubernetesconfiguration.ScopeTypeCluster), // SourceKind: to.Ptr(armkubernetesconfiguration.SourceKindTypeGitRepository), // SourceSyncedCommitID: to.Ptr("master/0ba6f0d30760d567de0bac86c8c4eec13ce1a590"), - // SourceUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12Z"); return t}()), - // StatusUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12Z"); return t}()), + // SourceUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12.000Z"); return t}()), + // StatusUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12.000Z"); return t}()), // Statuses: []*armkubernetesconfiguration.ObjectStatusDefinition{ // { // Name: to.Ptr("srs-fluxconfig"), @@ -340,7 +340,7 @@ func ExampleFluxConfigurationsClient_BeginCreateOrUpdate_createFluxConfiguration // StatusConditions: []*armkubernetesconfiguration.ObjectStatusConditionDefinition{ // { // Type: to.Ptr("Ready"), - // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40Z"); return t}()), + // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40.000Z"); return t}()), // Message: to.Ptr("'Fetched revision: master/0ba6f0d30760d567de0bac86c8c4eec13ce1a590'"), // Reason: to.Ptr("GitOperationSucceed"), // Status: to.Ptr("True"), @@ -360,7 +360,7 @@ func ExampleFluxConfigurationsClient_BeginCreateOrUpdate_createFluxConfiguration // StatusConditions: []*armkubernetesconfiguration.ObjectStatusConditionDefinition{ // { // Type: to.Ptr("Ready"), - // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40Z"); return t}()), + // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40.000Z"); return t}()), // Message: to.Ptr("'Applied revision: master/0ba6f0d30760d567de0bac86c8c4eec13ce1a590'"), // Reason: to.Ptr("ReconciliationSucceeded"), // Status: to.Ptr("True"), @@ -380,7 +380,7 @@ func ExampleFluxConfigurationsClient_BeginCreateOrUpdate_createFluxConfiguration // StatusConditions: []*armkubernetesconfiguration.ObjectStatusConditionDefinition{ // { // Type: to.Ptr("Ready"), - // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40Z"); return t}()), + // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40.000Z"); return t}()), // Message: to.Ptr("'Applied revision: master/0ba6f0d30760d567de0bac86c8c4eec13ce1a590'"), // Reason: to.Ptr("ReconciliationSucceeded"), // Status: to.Ptr("True"), @@ -492,8 +492,8 @@ func ExampleFluxConfigurationsClient_BeginCreateOrUpdate_createFluxConfiguration // Scope: to.Ptr(armkubernetesconfiguration.ScopeTypeCluster), // SourceKind: to.Ptr(armkubernetesconfiguration.SourceKindTypeBucket), // SourceSyncedCommitID: to.Ptr("0ba6f0d30760d567de0bac86c8c4eec13ce1a590"), - // SourceUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12Z"); return t}()), - // StatusUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12Z"); return t}()), + // SourceUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12.000Z"); return t}()), + // StatusUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12.000Z"); return t}()), // Statuses: []*armkubernetesconfiguration.ObjectStatusDefinition{ // { // Name: to.Ptr("srs-fluxconfig"), @@ -502,7 +502,7 @@ func ExampleFluxConfigurationsClient_BeginCreateOrUpdate_createFluxConfiguration // StatusConditions: []*armkubernetesconfiguration.ObjectStatusConditionDefinition{ // { // Type: to.Ptr("Ready"), - // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-04T07:17:30+00:00"); return t}()), + // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-05-04T07:17:30.000Z"); return t}()), // Message: to.Ptr("stored artifact for revision '55396be14f18fa2b977c1f22becef26a94d1d9a7ccb1e19d12f9cac52d757a84'"), // Reason: to.Ptr("Succeeded"), // Status: to.Ptr("True"), @@ -522,7 +522,7 @@ func ExampleFluxConfigurationsClient_BeginCreateOrUpdate_createFluxConfiguration // StatusConditions: []*armkubernetesconfiguration.ObjectStatusConditionDefinition{ // { // Type: to.Ptr("Ready"), - // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40Z"); return t}()), + // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40.000Z"); return t}()), // Message: to.Ptr("'Applied revision: 0ba6f0d30760d567de0bac86c8c4eec13ce1a590'"), // Reason: to.Ptr("ReconciliationSucceeded"), // Status: to.Ptr("True"), @@ -542,7 +542,7 @@ func ExampleFluxConfigurationsClient_BeginCreateOrUpdate_createFluxConfiguration // StatusConditions: []*armkubernetesconfiguration.ObjectStatusConditionDefinition{ // { // Type: to.Ptr("Ready"), - // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40Z"); return t}()), + // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40.000Z"); return t}()), // Message: to.Ptr("'Applied revision: 0ba6f0d30760d567de0bac86c8c4eec13ce1a590'"), // Reason: to.Ptr("ReconciliationSucceeded"), // Status: to.Ptr("True"), @@ -634,8 +634,8 @@ func ExampleFluxConfigurationsClient_BeginUpdate() { // Scope: to.Ptr(armkubernetesconfiguration.ScopeTypeCluster), // SourceKind: to.Ptr(armkubernetesconfiguration.SourceKindTypeGitRepository), // SourceSyncedCommitID: to.Ptr("master/0ba6f0d30760d567de0bac86c8c4eec13ce1a590"), - // SourceUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12Z"); return t}()), - // StatusUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12Z"); return t}()), + // SourceUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12.000Z"); return t}()), + // StatusUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12.000Z"); return t}()), // Statuses: []*armkubernetesconfiguration.ObjectStatusDefinition{ // { // Name: to.Ptr("srs-fluxconfig"), @@ -644,7 +644,7 @@ func ExampleFluxConfigurationsClient_BeginUpdate() { // StatusConditions: []*armkubernetesconfiguration.ObjectStatusConditionDefinition{ // { // Type: to.Ptr("Ready"), - // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40Z"); return t}()), + // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40.000Z"); return t}()), // Message: to.Ptr("'Fetched revision: master/0ba6f0d30760d567de0bac86c8c4eec13ce1a590'"), // Reason: to.Ptr("GitOperationSucceed"), // Status: to.Ptr("True"), @@ -664,7 +664,7 @@ func ExampleFluxConfigurationsClient_BeginUpdate() { // StatusConditions: []*armkubernetesconfiguration.ObjectStatusConditionDefinition{ // { // Type: to.Ptr("Ready"), - // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40Z"); return t}()), + // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40.000Z"); return t}()), // Message: to.Ptr("'Applied revision: master/0ba6f0d30760d567de0bac86c8c4eec13ce1a590'"), // Reason: to.Ptr("ReconciliationSucceeded"), // Status: to.Ptr("True"), @@ -684,7 +684,7 @@ func ExampleFluxConfigurationsClient_BeginUpdate() { // StatusConditions: []*armkubernetesconfiguration.ObjectStatusConditionDefinition{ // { // Type: to.Ptr("Ready"), - // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40Z"); return t}()), + // LastTransitionTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:12:40.000Z"); return t}()), // Message: to.Ptr("'Applied revision: master/0ba6f0d30760d567de0bac86c8c4eec13ce1a590'"), // Reason: to.Ptr("ReconciliationSucceeded"), // Status: to.Ptr("True"), @@ -808,8 +808,8 @@ func ExampleFluxConfigurationsClient_NewListPager() { // Scope: to.Ptr(armkubernetesconfiguration.ScopeTypeCluster), // SourceKind: to.Ptr(armkubernetesconfiguration.SourceKindTypeGitRepository), // SourceSyncedCommitID: to.Ptr("master/0ba6f0d30760d567de0bac86c8c4eec13ce1a590"), - // SourceUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12Z"); return t}()), - // StatusUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12Z"); return t}()), + // SourceUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12.000Z"); return t}()), + // StatusUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12.000Z"); return t}()), // Statuses: []*armkubernetesconfiguration.ObjectStatusDefinition{ // { // Name: to.Ptr("srs-fluxconfig"), @@ -878,8 +878,8 @@ func ExampleFluxConfigurationsClient_NewListPager() { // Scope: to.Ptr(armkubernetesconfiguration.ScopeTypeCluster), // SourceKind: to.Ptr(armkubernetesconfiguration.SourceKindTypeGitRepository), // SourceSyncedCommitID: to.Ptr("master/0ba6f0d30760d567de0bac86c8c4eec13ce1a590"), - // SourceUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12Z"); return t}()), - // StatusUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12Z"); return t}()), + // SourceUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12.000Z"); return t}()), + // StatusUpdatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-05-19T18:17:12.000Z"); return t}()), // Statuses: []*armkubernetesconfiguration.ObjectStatusDefinition{ // { // Name: to.Ptr("srs-fluxconfig"), diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/go.mod b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/go.mod index d9a411e8dac2..6b8a41c5c547 100644 --- a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/go.mod +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kubernetesconfigura go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.1 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect github.com/golang-jwt/jwt/v5 v5.0.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/google/uuid v1.3.1 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.12.0 // indirect - golang.org/x/net v0.14.0 // indirect - golang.org/x/sys v0.11.0 // indirect - golang.org/x/text v0.12.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect ) diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/go.sum b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/go.sum index 545850a5189d..7985f1da436f 100644 --- a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/go.sum +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/go.sum @@ -1,31 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1 h1:/iHxaJhsFr0+xVFfbMr5vxz848jyiWuIEDhYq3y5odY= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.7.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.1 h1:LNHhpdK7hzUcx/k1LIcuh5k7k1LGIWLQfCjaneSj7Fc= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.1/go.mod h1:uE9zaUfEQT/nbQjVi2IblCG9iaLtZsuYZ8ne+PuQ02M= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.12.0 h1:tFM/ta59kqch6LlvYnPa0yx5a83cL2nHflFhYKvv9Yk= -golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw= -golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= -golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= -golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= -golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/models_serde.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/models_serde.go index 1a3ed4516db7..747ad142584d 100644 --- a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/models_serde.go +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/models_serde.go @@ -239,7 +239,7 @@ func (b *BucketPatchDefinition) UnmarshalJSON(data []byte) error { func (c ComplianceStatus) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "complianceState", c.ComplianceState) - populateTimeRFC3339(objectMap, "lastConfigApplied", c.LastConfigApplied) + populateDateTimeRFC3339(objectMap, "lastConfigApplied", c.LastConfigApplied) populate(objectMap, "message", c.Message) populate(objectMap, "messageLevel", c.MessageLevel) return json.Marshal(objectMap) @@ -258,7 +258,7 @@ func (c *ComplianceStatus) UnmarshalJSON(data []byte) error { err = unpopulate(val, "ComplianceState", &c.ComplianceState) delete(rawMsg, key) case "lastConfigApplied": - err = unpopulateTimeRFC3339(val, "LastConfigApplied", &c.LastConfigApplied) + err = unpopulateDateTimeRFC3339(val, "LastConfigApplied", &c.LastConfigApplied) delete(rawMsg, key) case "message": err = unpopulate(val, "Message", &c.Message) @@ -756,8 +756,8 @@ func (f FluxConfigurationProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "scope", f.Scope) populate(objectMap, "sourceKind", f.SourceKind) populate(objectMap, "sourceSyncedCommitId", f.SourceSyncedCommitID) - populateTimeRFC3339(objectMap, "sourceUpdatedAt", f.SourceUpdatedAt) - populateTimeRFC3339(objectMap, "statusUpdatedAt", f.StatusUpdatedAt) + populateDateTimeRFC3339(objectMap, "sourceUpdatedAt", f.SourceUpdatedAt) + populateDateTimeRFC3339(objectMap, "statusUpdatedAt", f.StatusUpdatedAt) populate(objectMap, "statuses", f.Statuses) populate(objectMap, "suspend", f.Suspend) populate(objectMap, "waitForReconciliation", f.WaitForReconciliation) @@ -816,10 +816,10 @@ func (f *FluxConfigurationProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "SourceSyncedCommitID", &f.SourceSyncedCommitID) delete(rawMsg, key) case "sourceUpdatedAt": - err = unpopulateTimeRFC3339(val, "SourceUpdatedAt", &f.SourceUpdatedAt) + err = unpopulateDateTimeRFC3339(val, "SourceUpdatedAt", &f.SourceUpdatedAt) delete(rawMsg, key) case "statusUpdatedAt": - err = unpopulateTimeRFC3339(val, "StatusUpdatedAt", &f.StatusUpdatedAt) + err = unpopulateDateTimeRFC3339(val, "StatusUpdatedAt", &f.StatusUpdatedAt) delete(rawMsg, key) case "statuses": err = unpopulate(val, "Statuses", &f.Statuses) @@ -1298,7 +1298,7 @@ func (o *ObjectReferenceDefinition) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ObjectStatusConditionDefinition. func (o ObjectStatusConditionDefinition) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "lastTransitionTime", o.LastTransitionTime) + populateDateTimeRFC3339(objectMap, "lastTransitionTime", o.LastTransitionTime) populate(objectMap, "message", o.Message) populate(objectMap, "reason", o.Reason) populate(objectMap, "status", o.Status) @@ -1316,7 +1316,7 @@ func (o *ObjectStatusConditionDefinition) UnmarshalJSON(data []byte) error { var err error switch key { case "lastTransitionTime": - err = unpopulateTimeRFC3339(val, "LastTransitionTime", &o.LastTransitionTime) + err = unpopulateDateTimeRFC3339(val, "LastTransitionTime", &o.LastTransitionTime) delete(rawMsg, key) case "message": err = unpopulate(val, "Message", &o.Message) @@ -2191,10 +2191,10 @@ func (s *SubstituteFromDefinition) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) populate(objectMap, "lastModifiedBy", s.LastModifiedBy) populate(objectMap, "lastModifiedByType", s.LastModifiedByType) return json.Marshal(objectMap) @@ -2210,7 +2210,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { var err error switch key { case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) delete(rawMsg, key) case "createdBy": err = unpopulate(val, "CreatedBy", &s.CreatedBy) @@ -2219,7 +2219,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { err = unpopulate(val, "CreatedByType", &s.CreatedByType) delete(rawMsg, key) case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) delete(rawMsg, key) case "lastModifiedBy": err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/operations_client.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/operations_client.go index a9c3cfdb7ad6..e53e581052bf 100644 --- a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/operations_client.go +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/operations_client.go @@ -27,7 +27,7 @@ type OperationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,25 +47,20 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.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, options) + }, nil) if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return OperationsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OperationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/operationstatus_client.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/operationstatus_client.go index 630c887fc3aa..36e97073320b 100644 --- a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/operationstatus_client.go +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/operationstatus_client.go @@ -32,7 +32,7 @@ type OperationStatusClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationStatusClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationStatusClient, error) { - cl, err := arm.NewClient(moduleName+".OperationStatusClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -56,6 +56,10 @@ func NewOperationStatusClient(subscriptionID string, credential azcore.TokenCred // - options - OperationStatusClientGetOptions contains the optional parameters for the OperationStatusClient.Get method. func (client *OperationStatusClient) Get(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, extensionName string, operationID string, options *OperationStatusClientGetOptions) (OperationStatusClientGetResponse, error) { var err error + const operationName = "OperationStatusClient.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, clusterRp, clusterResourceName, clusterName, extensionName, operationID, options) if err != nil { return OperationStatusClientGetResponse{}, err @@ -138,25 +142,20 @@ func (client *OperationStatusClient) NewListPager(resourceGroupName string, clus return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *OperationStatusClientListResponse) (OperationStatusClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationStatusClient.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, resourceGroupName, clusterRp, clusterResourceName, clusterName, options) + }, nil) if err != nil { return OperationStatusClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return OperationStatusClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OperationStatusClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/sourcecontrolconfigurations_client.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/sourcecontrolconfigurations_client.go index eacd1dda7d0b..5d8ff1e0f73c 100644 --- a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/sourcecontrolconfigurations_client.go +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/sourcecontrolconfigurations_client.go @@ -32,7 +32,7 @@ type SourceControlConfigurationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSourceControlConfigurationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SourceControlConfigurationsClient, error) { - cl, err := arm.NewClient(moduleName+".SourceControlConfigurationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -57,6 +57,10 @@ func NewSourceControlConfigurationsClient(subscriptionID string, credential azco // method. func (client *SourceControlConfigurationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, sourceControlConfigurationName string, sourceControlConfiguration SourceControlConfiguration, options *SourceControlConfigurationsClientCreateOrUpdateOptions) (SourceControlConfigurationsClientCreateOrUpdateResponse, error) { var err error + const operationName = "SourceControlConfigurationsClient.CreateOrUpdate" + 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, clusterRp, clusterResourceName, clusterName, sourceControlConfigurationName, sourceControlConfiguration, options) if err != nil { return SourceControlConfigurationsClientCreateOrUpdateResponse{}, err @@ -141,10 +145,14 @@ func (client *SourceControlConfigurationsClient) BeginDelete(ctx context.Context if err != nil { return nil, err } - poller, err := runtime.NewPoller[SourceControlConfigurationsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SourceControlConfigurationsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[SourceControlConfigurationsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SourceControlConfigurationsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -155,6 +163,10 @@ func (client *SourceControlConfigurationsClient) BeginDelete(ctx context.Context // Generated from API version 2023-05-01 func (client *SourceControlConfigurationsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, sourceControlConfigurationName string, options *SourceControlConfigurationsClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "SourceControlConfigurationsClient.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, clusterRp, clusterResourceName, clusterName, sourceControlConfigurationName, options) if err != nil { return nil, err @@ -221,6 +233,10 @@ func (client *SourceControlConfigurationsClient) deleteCreateRequest(ctx context // method. func (client *SourceControlConfigurationsClient) Get(ctx context.Context, resourceGroupName string, clusterRp string, clusterResourceName string, clusterName string, sourceControlConfigurationName string, options *SourceControlConfigurationsClientGetOptions) (SourceControlConfigurationsClientGetResponse, error) { var err error + const operationName = "SourceControlConfigurationsClient.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, clusterRp, clusterResourceName, clusterName, sourceControlConfigurationName, options) if err != nil { return SourceControlConfigurationsClientGetResponse{}, err @@ -299,25 +315,20 @@ func (client *SourceControlConfigurationsClient) NewListPager(resourceGroupName return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *SourceControlConfigurationsClientListResponse) (SourceControlConfigurationsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, clusterRp, clusterResourceName, clusterName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SourceControlConfigurationsClient.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, resourceGroupName, clusterRp, clusterResourceName, clusterName, options) + }, nil) if err != nil { return SourceControlConfigurationsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return SourceControlConfigurationsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SourceControlConfigurationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/time_rfc3339.go b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/time_rfc3339.go index 648a81ae1fcb..fee145427b88 100644 --- a/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/time_rfc3339.go +++ b/sdk/resourcemanager/kubernetesconfiguration/armkubernetesconfiguration/time_rfc3339.go @@ -18,50 +18,50 @@ import ( "time" ) -const ( - utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` - utcLayout = "2006-01-02T15:04:05.999999999" - rfc3339JSON = `"` + time.RFC3339Nano + `"` -) - // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) -type timeRFC3339 time.Time +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time -func (t timeRFC3339) MarshalJSON() (json []byte, err error) { +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { tt := time.Time(t) return tt.MarshalJSON() } -func (t timeRFC3339) MarshalText() (text []byte, err error) { +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { tt := time.Time(t) return tt.MarshalText() } -func (t *timeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcLayoutJSON +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON if tzOffsetRegex.Match(data) { - layout = rfc3339JSON + layout = dateTimeJSON } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { - layout := utcLayout +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime if tzOffsetRegex.Match(data) { layout = time.RFC3339Nano } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) Parse(layout, value string) error { +func (t *dateTimeRFC3339) Parse(layout, value string) error { p, err := time.Parse(layout, strings.ToUpper(value)) - *t = timeRFC3339(p) + *t = dateTimeRFC3339(p) return err } -func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { @@ -70,14 +70,14 @@ func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { } else if reflect.ValueOf(t).IsNil() { return } - m[k] = (*timeRFC3339)(t) + m[k] = (*dateTimeRFC3339)(t) } -func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { if data == nil || strings.EqualFold(string(data), "null") { return nil } - var aux timeRFC3339 + var aux dateTimeRFC3339 if err := json.Unmarshal(data, &aux); err != nil { return fmt.Errorf("struct field %s: %v", fn, err) } diff --git a/sdk/resourcemanager/kusto/armkusto/CHANGELOG.md b/sdk/resourcemanager/kusto/armkusto/CHANGELOG.md index 3b12eecb1fad..8c61f8ebaa5f 100644 --- a/sdk/resourcemanager/kusto/armkusto/CHANGELOG.md +++ b/sdk/resourcemanager/kusto/armkusto/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 2.2.0 (2023-11-24) +### Features Added + +- Support for test fakes and OpenTelemetry trace spans. + + ## 2.1.0 (2023-10-27) ### Features Added diff --git a/sdk/resourcemanager/kusto/armkusto/README.md b/sdk/resourcemanager/kusto/armkusto/README.md index 8a043a066690..74f14155d061 100644 --- a/sdk/resourcemanager/kusto/armkusto/README.md +++ b/sdk/resourcemanager/kusto/armkusto/README.md @@ -60,6 +60,13 @@ A client groups a set of related APIs, providing access to its functionality. C client := clientFactory.NewDatabasesClient() ``` +## 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 diff --git a/sdk/resourcemanager/kusto/armkusto/attacheddatabaseconfigurations_client.go b/sdk/resourcemanager/kusto/armkusto/attacheddatabaseconfigurations_client.go index 9863a3411a8c..3b4356e0acca 100644 --- a/sdk/resourcemanager/kusto/armkusto/attacheddatabaseconfigurations_client.go +++ b/sdk/resourcemanager/kusto/armkusto/attacheddatabaseconfigurations_client.go @@ -32,7 +32,7 @@ type AttachedDatabaseConfigurationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewAttachedDatabaseConfigurationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*AttachedDatabaseConfigurationsClient, error) { - cl, err := arm.NewClient(moduleName+".AttachedDatabaseConfigurationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,6 +54,10 @@ func NewAttachedDatabaseConfigurationsClient(subscriptionID string, credential a // method. func (client *AttachedDatabaseConfigurationsClient) CheckNameAvailability(ctx context.Context, resourceGroupName string, clusterName string, resourceName AttachedDatabaseConfigurationsCheckNameRequest, options *AttachedDatabaseConfigurationsClientCheckNameAvailabilityOptions) (AttachedDatabaseConfigurationsClientCheckNameAvailabilityResponse, error) { var err error + const operationName = "AttachedDatabaseConfigurationsClient.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, resourceGroupName, clusterName, resourceName, options) if err != nil { return AttachedDatabaseConfigurationsClientCheckNameAvailabilityResponse{}, err @@ -124,10 +128,14 @@ func (client *AttachedDatabaseConfigurationsClient) BeginCreateOrUpdate(ctx cont if err != nil { return nil, err } - poller, err := runtime.NewPoller[AttachedDatabaseConfigurationsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AttachedDatabaseConfigurationsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[AttachedDatabaseConfigurationsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AttachedDatabaseConfigurationsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -137,6 +145,10 @@ func (client *AttachedDatabaseConfigurationsClient) BeginCreateOrUpdate(ctx cont // Generated from API version 2023-08-15 func (client *AttachedDatabaseConfigurationsClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, attachedDatabaseConfigurationName string, parameters AttachedDatabaseConfiguration, options *AttachedDatabaseConfigurationsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error + const operationName = "AttachedDatabaseConfigurationsClient.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, clusterName, attachedDatabaseConfigurationName, parameters, options) if err != nil { return nil, err @@ -200,10 +212,14 @@ func (client *AttachedDatabaseConfigurationsClient) BeginDelete(ctx context.Cont if err != nil { return nil, err } - poller, err := runtime.NewPoller[AttachedDatabaseConfigurationsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[AttachedDatabaseConfigurationsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[AttachedDatabaseConfigurationsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[AttachedDatabaseConfigurationsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -213,6 +229,10 @@ func (client *AttachedDatabaseConfigurationsClient) BeginDelete(ctx context.Cont // Generated from API version 2023-08-15 func (client *AttachedDatabaseConfigurationsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, attachedDatabaseConfigurationName string, options *AttachedDatabaseConfigurationsClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "AttachedDatabaseConfigurationsClient.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, clusterName, attachedDatabaseConfigurationName, options) if err != nil { return nil, err @@ -269,6 +289,10 @@ func (client *AttachedDatabaseConfigurationsClient) deleteCreateRequest(ctx cont // method. func (client *AttachedDatabaseConfigurationsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, attachedDatabaseConfigurationName string, options *AttachedDatabaseConfigurationsClientGetOptions) (AttachedDatabaseConfigurationsClientGetResponse, error) { var err error + const operationName = "AttachedDatabaseConfigurationsClient.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, clusterName, attachedDatabaseConfigurationName, options) if err != nil { return AttachedDatabaseConfigurationsClientGetResponse{}, err @@ -337,6 +361,7 @@ func (client *AttachedDatabaseConfigurationsClient) NewListByClusterPager(resour return false }, Fetcher: func(ctx context.Context, page *AttachedDatabaseConfigurationsClientListByClusterResponse) (AttachedDatabaseConfigurationsClientListByClusterResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "AttachedDatabaseConfigurationsClient.NewListByClusterPager") req, err := client.listByClusterCreateRequest(ctx, resourceGroupName, clusterName, options) if err != nil { return AttachedDatabaseConfigurationsClientListByClusterResponse{}, err @@ -350,6 +375,7 @@ func (client *AttachedDatabaseConfigurationsClient) NewListByClusterPager(resour } return client.listByClusterHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/kusto/armkusto/autorest.md b/sdk/resourcemanager/kusto/armkusto/autorest.md index ddc95746a0f5..93b3d1f9559c 100644 --- a/sdk/resourcemanager/kusto/armkusto/autorest.md +++ b/sdk/resourcemanager/kusto/armkusto/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/azure-kusto/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/9ec0fcc278aa2128c4fbb2b8a1aa93432d72cce0/specification/azure-kusto/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 2.1.0 +module-version: 2.2.0 tag: package-2023-08 ``` diff --git a/sdk/resourcemanager/kusto/armkusto/client_factory.go b/sdk/resourcemanager/kusto/armkusto/client_factory.go index 737ebee3611b..a4cd393e4b89 100644 --- a/sdk/resourcemanager/kusto/armkusto/client_factory.go +++ b/sdk/resourcemanager/kusto/armkusto/client_factory.go @@ -27,7 +27,7 @@ type ClientFactory struct { // - 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+".ClientFactory", moduleVersion, credential, options) + _, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -37,81 +37,97 @@ func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, }, nil } +// NewAttachedDatabaseConfigurationsClient creates a new instance of AttachedDatabaseConfigurationsClient. func (c *ClientFactory) NewAttachedDatabaseConfigurationsClient() *AttachedDatabaseConfigurationsClient { subClient, _ := NewAttachedDatabaseConfigurationsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewClusterPrincipalAssignmentsClient creates a new instance of ClusterPrincipalAssignmentsClient. func (c *ClientFactory) NewClusterPrincipalAssignmentsClient() *ClusterPrincipalAssignmentsClient { subClient, _ := NewClusterPrincipalAssignmentsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewClustersClient creates a new instance of ClustersClient. func (c *ClientFactory) NewClustersClient() *ClustersClient { subClient, _ := NewClustersClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewDataConnectionsClient creates a new instance of DataConnectionsClient. func (c *ClientFactory) NewDataConnectionsClient() *DataConnectionsClient { subClient, _ := NewDataConnectionsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewDatabaseClient creates a new instance of DatabaseClient. func (c *ClientFactory) NewDatabaseClient() *DatabaseClient { subClient, _ := NewDatabaseClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewDatabasePrincipalAssignmentsClient creates a new instance of DatabasePrincipalAssignmentsClient. func (c *ClientFactory) NewDatabasePrincipalAssignmentsClient() *DatabasePrincipalAssignmentsClient { subClient, _ := NewDatabasePrincipalAssignmentsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewDatabasesClient creates a new instance of DatabasesClient. func (c *ClientFactory) NewDatabasesClient() *DatabasesClient { subClient, _ := NewDatabasesClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewManagedPrivateEndpointsClient creates a new instance of ManagedPrivateEndpointsClient. func (c *ClientFactory) NewManagedPrivateEndpointsClient() *ManagedPrivateEndpointsClient { subClient, _ := NewManagedPrivateEndpointsClient(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 } +// NewOperationsResultsClient creates a new instance of OperationsResultsClient. func (c *ClientFactory) NewOperationsResultsClient() *OperationsResultsClient { subClient, _ := NewOperationsResultsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewOperationsResultsLocationClient creates a new instance of OperationsResultsLocationClient. func (c *ClientFactory) NewOperationsResultsLocationClient() *OperationsResultsLocationClient { subClient, _ := NewOperationsResultsLocationClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewPrivateEndpointConnectionsClient creates a new instance of PrivateEndpointConnectionsClient. func (c *ClientFactory) NewPrivateEndpointConnectionsClient() *PrivateEndpointConnectionsClient { subClient, _ := NewPrivateEndpointConnectionsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewPrivateLinkResourcesClient creates a new instance of PrivateLinkResourcesClient. func (c *ClientFactory) NewPrivateLinkResourcesClient() *PrivateLinkResourcesClient { subClient, _ := NewPrivateLinkResourcesClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewSKUsClient creates a new instance of SKUsClient. func (c *ClientFactory) NewSKUsClient() *SKUsClient { subClient, _ := NewSKUsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewSandboxCustomImagesClient creates a new instance of SandboxCustomImagesClient. func (c *ClientFactory) NewSandboxCustomImagesClient() *SandboxCustomImagesClient { subClient, _ := NewSandboxCustomImagesClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewScriptsClient creates a new instance of ScriptsClient. func (c *ClientFactory) NewScriptsClient() *ScriptsClient { subClient, _ := NewScriptsClient(c.subscriptionID, c.credential, c.options) return subClient diff --git a/sdk/resourcemanager/kusto/armkusto/clusterprincipalassignments_client.go b/sdk/resourcemanager/kusto/armkusto/clusterprincipalassignments_client.go index 0b7132831ea2..3227b19de122 100644 --- a/sdk/resourcemanager/kusto/armkusto/clusterprincipalassignments_client.go +++ b/sdk/resourcemanager/kusto/armkusto/clusterprincipalassignments_client.go @@ -32,7 +32,7 @@ type ClusterPrincipalAssignmentsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClusterPrincipalAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClusterPrincipalAssignmentsClient, error) { - cl, err := arm.NewClient(moduleName+".ClusterPrincipalAssignmentsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,6 +54,10 @@ func NewClusterPrincipalAssignmentsClient(subscriptionID string, credential azco // method. func (client *ClusterPrincipalAssignmentsClient) CheckNameAvailability(ctx context.Context, resourceGroupName string, clusterName string, principalAssignmentName ClusterPrincipalAssignmentCheckNameRequest, options *ClusterPrincipalAssignmentsClientCheckNameAvailabilityOptions) (ClusterPrincipalAssignmentsClientCheckNameAvailabilityResponse, error) { var err error + const operationName = "ClusterPrincipalAssignmentsClient.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, resourceGroupName, clusterName, principalAssignmentName, options) if err != nil { return ClusterPrincipalAssignmentsClientCheckNameAvailabilityResponse{}, err @@ -124,10 +128,14 @@ func (client *ClusterPrincipalAssignmentsClient) BeginCreateOrUpdate(ctx context if err != nil { return nil, err } - poller, err := runtime.NewPoller[ClusterPrincipalAssignmentsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClusterPrincipalAssignmentsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ClusterPrincipalAssignmentsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClusterPrincipalAssignmentsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -137,6 +145,10 @@ func (client *ClusterPrincipalAssignmentsClient) BeginCreateOrUpdate(ctx context // Generated from API version 2023-08-15 func (client *ClusterPrincipalAssignmentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, principalAssignmentName string, parameters ClusterPrincipalAssignment, options *ClusterPrincipalAssignmentsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error + const operationName = "ClusterPrincipalAssignmentsClient.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, clusterName, principalAssignmentName, parameters, options) if err != nil { return nil, err @@ -200,10 +212,14 @@ func (client *ClusterPrincipalAssignmentsClient) BeginDelete(ctx context.Context if err != nil { return nil, err } - poller, err := runtime.NewPoller[ClusterPrincipalAssignmentsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClusterPrincipalAssignmentsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ClusterPrincipalAssignmentsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClusterPrincipalAssignmentsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -213,6 +229,10 @@ func (client *ClusterPrincipalAssignmentsClient) BeginDelete(ctx context.Context // Generated from API version 2023-08-15 func (client *ClusterPrincipalAssignmentsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, principalAssignmentName string, options *ClusterPrincipalAssignmentsClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "ClusterPrincipalAssignmentsClient.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, clusterName, principalAssignmentName, options) if err != nil { return nil, err @@ -269,6 +289,10 @@ func (client *ClusterPrincipalAssignmentsClient) deleteCreateRequest(ctx context // method. func (client *ClusterPrincipalAssignmentsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, principalAssignmentName string, options *ClusterPrincipalAssignmentsClientGetOptions) (ClusterPrincipalAssignmentsClientGetResponse, error) { var err error + const operationName = "ClusterPrincipalAssignmentsClient.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, clusterName, principalAssignmentName, options) if err != nil { return ClusterPrincipalAssignmentsClientGetResponse{}, err @@ -337,6 +361,7 @@ func (client *ClusterPrincipalAssignmentsClient) NewListPager(resourceGroupName return false }, Fetcher: func(ctx context.Context, page *ClusterPrincipalAssignmentsClientListResponse) (ClusterPrincipalAssignmentsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ClusterPrincipalAssignmentsClient.NewListPager") req, err := client.listCreateRequest(ctx, resourceGroupName, clusterName, options) if err != nil { return ClusterPrincipalAssignmentsClientListResponse{}, err @@ -350,6 +375,7 @@ func (client *ClusterPrincipalAssignmentsClient) NewListPager(resourceGroupName } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/kusto/armkusto/clusters_client.go b/sdk/resourcemanager/kusto/armkusto/clusters_client.go index a74bd5534f01..fe916f683a63 100644 --- a/sdk/resourcemanager/kusto/armkusto/clusters_client.go +++ b/sdk/resourcemanager/kusto/armkusto/clusters_client.go @@ -32,7 +32,7 @@ type ClustersClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewClustersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ClustersClient, error) { - cl, err := arm.NewClient(moduleName+".ClustersClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -58,10 +58,14 @@ func (client *ClustersClient) BeginAddLanguageExtensions(ctx context.Context, re if err != nil { return nil, err } - poller, err := runtime.NewPoller[ClustersClientAddLanguageExtensionsResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClustersClientAddLanguageExtensionsResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ClustersClientAddLanguageExtensionsResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClustersClientAddLanguageExtensionsResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -71,6 +75,10 @@ func (client *ClustersClient) BeginAddLanguageExtensions(ctx context.Context, re // Generated from API version 2023-08-15 func (client *ClustersClient) addLanguageExtensions(ctx context.Context, resourceGroupName string, clusterName string, languageExtensionsToAdd LanguageExtensionsList, options *ClustersClientBeginAddLanguageExtensionsOptions) (*http.Response, error) { var err error + const operationName = "ClustersClient.BeginAddLanguageExtensions" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.addLanguageExtensionsCreateRequest(ctx, resourceGroupName, clusterName, languageExtensionsToAdd, options) if err != nil { return nil, err @@ -125,6 +133,10 @@ func (client *ClustersClient) addLanguageExtensionsCreateRequest(ctx context.Con // method. func (client *ClustersClient) CheckNameAvailability(ctx context.Context, location string, clusterName ClusterCheckNameRequest, options *ClustersClientCheckNameAvailabilityOptions) (ClustersClientCheckNameAvailabilityResponse, error) { var err error + const operationName = "ClustersClient.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, location, clusterName, options) if err != nil { return ClustersClientCheckNameAvailabilityResponse{}, err @@ -190,10 +202,14 @@ func (client *ClustersClient) BeginCreateOrUpdate(ctx context.Context, resourceG if err != nil { return nil, err } - poller, err := runtime.NewPoller[ClustersClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClustersClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ClustersClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClustersClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -203,6 +219,10 @@ func (client *ClustersClient) BeginCreateOrUpdate(ctx context.Context, resourceG // Generated from API version 2023-08-15 func (client *ClustersClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, parameters Cluster, options *ClustersClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error + const operationName = "ClustersClient.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, clusterName, parameters, options) if err != nil { return nil, err @@ -266,10 +286,14 @@ func (client *ClustersClient) BeginDelete(ctx context.Context, resourceGroupName if err != nil { return nil, err } - poller, err := runtime.NewPoller[ClustersClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClustersClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ClustersClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClustersClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -279,6 +303,10 @@ func (client *ClustersClient) BeginDelete(ctx context.Context, resourceGroupName // Generated from API version 2023-08-15 func (client *ClustersClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "ClustersClient.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, clusterName, options) if err != nil { return nil, err @@ -335,10 +363,14 @@ func (client *ClustersClient) BeginDetachFollowerDatabases(ctx context.Context, if err != nil { return nil, err } - poller, err := runtime.NewPoller[ClustersClientDetachFollowerDatabasesResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClustersClientDetachFollowerDatabasesResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ClustersClientDetachFollowerDatabasesResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClustersClientDetachFollowerDatabasesResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -348,6 +380,10 @@ func (client *ClustersClient) BeginDetachFollowerDatabases(ctx context.Context, // Generated from API version 2023-08-15 func (client *ClustersClient) detachFollowerDatabases(ctx context.Context, resourceGroupName string, clusterName string, followerDatabaseToRemove FollowerDatabaseDefinition, options *ClustersClientBeginDetachFollowerDatabasesOptions) (*http.Response, error) { var err error + const operationName = "ClustersClient.BeginDetachFollowerDatabases" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.detachFollowerDatabasesCreateRequest(ctx, resourceGroupName, clusterName, followerDatabaseToRemove, options) if err != nil { return nil, err @@ -407,10 +443,14 @@ func (client *ClustersClient) BeginDiagnoseVirtualNetwork(ctx context.Context, r if err != nil { return nil, err } - poller, err := runtime.NewPoller[ClustersClientDiagnoseVirtualNetworkResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClustersClientDiagnoseVirtualNetworkResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ClustersClientDiagnoseVirtualNetworkResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClustersClientDiagnoseVirtualNetworkResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -421,6 +461,10 @@ func (client *ClustersClient) BeginDiagnoseVirtualNetwork(ctx context.Context, r // Generated from API version 2023-08-15 func (client *ClustersClient) diagnoseVirtualNetwork(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersClientBeginDiagnoseVirtualNetworkOptions) (*http.Response, error) { var err error + const operationName = "ClustersClient.BeginDiagnoseVirtualNetwork" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.diagnoseVirtualNetworkCreateRequest(ctx, resourceGroupName, clusterName, options) if err != nil { return nil, err @@ -471,6 +515,10 @@ func (client *ClustersClient) diagnoseVirtualNetworkCreateRequest(ctx context.Co // - options - ClustersClientGetOptions contains the optional parameters for the ClustersClient.Get method. func (client *ClustersClient) Get(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersClientGetOptions) (ClustersClientGetResponse, error) { var err error + const operationName = "ClustersClient.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, clusterName, options) if err != nil { return ClustersClientGetResponse{}, err @@ -532,6 +580,7 @@ func (client *ClustersClient) NewListPager(options *ClustersClientListOptions) * return false }, Fetcher: func(ctx context.Context, page *ClustersClientListResponse) (ClustersClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ClustersClient.NewListPager") req, err := client.listCreateRequest(ctx, options) if err != nil { return ClustersClientListResponse{}, err @@ -545,6 +594,7 @@ func (client *ClustersClient) NewListPager(options *ClustersClientListOptions) * } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -587,6 +637,7 @@ func (client *ClustersClient) NewListByResourceGroupPager(resourceGroupName stri return false }, Fetcher: func(ctx context.Context, page *ClustersClientListByResourceGroupResponse) (ClustersClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ClustersClient.NewListByResourceGroupPager") req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) if err != nil { return ClustersClientListByResourceGroupResponse{}, err @@ -600,6 +651,7 @@ func (client *ClustersClient) NewListByResourceGroupPager(resourceGroupName stri } return client.listByResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -648,6 +700,7 @@ func (client *ClustersClient) NewListFollowerDatabasesPager(resourceGroupName st return false }, Fetcher: func(ctx context.Context, page *ClustersClientListFollowerDatabasesResponse) (ClustersClientListFollowerDatabasesResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ClustersClient.NewListFollowerDatabasesPager") req, err := client.listFollowerDatabasesCreateRequest(ctx, resourceGroupName, clusterName, options) if err != nil { return ClustersClientListFollowerDatabasesResponse{}, err @@ -661,6 +714,7 @@ func (client *ClustersClient) NewListFollowerDatabasesPager(resourceGroupName st } return client.listFollowerDatabasesHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -712,6 +766,7 @@ func (client *ClustersClient) NewListLanguageExtensionsPager(resourceGroupName s return false }, Fetcher: func(ctx context.Context, page *ClustersClientListLanguageExtensionsResponse) (ClustersClientListLanguageExtensionsResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ClustersClient.NewListLanguageExtensionsPager") req, err := client.listLanguageExtensionsCreateRequest(ctx, resourceGroupName, clusterName, options) if err != nil { return ClustersClientListLanguageExtensionsResponse{}, err @@ -725,6 +780,7 @@ func (client *ClustersClient) NewListLanguageExtensionsPager(resourceGroupName s } return client.listLanguageExtensionsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -776,25 +832,20 @@ func (client *ClustersClient) NewListOutboundNetworkDependenciesEndpointsPager(r return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ClustersClientListOutboundNetworkDependenciesEndpointsResponse) (ClustersClientListOutboundNetworkDependenciesEndpointsResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listOutboundNetworkDependenciesEndpointsCreateRequest(ctx, resourceGroupName, clusterName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ClustersClient.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, clusterName, options) + }, nil) if err != nil { return ClustersClientListOutboundNetworkDependenciesEndpointsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ClustersClientListOutboundNetworkDependenciesEndpointsResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ClustersClientListOutboundNetworkDependenciesEndpointsResponse{}, runtime.NewResponseError(resp) - } return client.listOutboundNetworkDependenciesEndpointsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -843,6 +894,7 @@ func (client *ClustersClient) NewListSKUsPager(options *ClustersClientListSKUsOp return false }, Fetcher: func(ctx context.Context, page *ClustersClientListSKUsResponse) (ClustersClientListSKUsResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ClustersClient.NewListSKUsPager") req, err := client.listSKUsCreateRequest(ctx, options) if err != nil { return ClustersClientListSKUsResponse{}, err @@ -856,6 +908,7 @@ func (client *ClustersClient) NewListSKUsPager(options *ClustersClientListSKUsOp } return client.listSKUsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -899,6 +952,7 @@ func (client *ClustersClient) NewListSKUsByResourcePager(resourceGroupName strin return false }, Fetcher: func(ctx context.Context, page *ClustersClientListSKUsByResourceResponse) (ClustersClientListSKUsByResourceResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ClustersClient.NewListSKUsByResourcePager") req, err := client.listSKUsByResourceCreateRequest(ctx, resourceGroupName, clusterName, options) if err != nil { return ClustersClientListSKUsByResourceResponse{}, err @@ -912,6 +966,7 @@ func (client *ClustersClient) NewListSKUsByResourcePager(resourceGroupName strin } return client.listSKUsByResourceHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -964,10 +1019,14 @@ func (client *ClustersClient) BeginMigrate(ctx context.Context, resourceGroupNam if err != nil { return nil, err } - poller, err := runtime.NewPoller[ClustersClientMigrateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClustersClientMigrateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ClustersClientMigrateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClustersClientMigrateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -977,6 +1036,10 @@ func (client *ClustersClient) BeginMigrate(ctx context.Context, resourceGroupNam // Generated from API version 2023-08-15 func (client *ClustersClient) migrate(ctx context.Context, resourceGroupName string, clusterName string, clusterMigrateRequest ClusterMigrateRequest, options *ClustersClientBeginMigrateOptions) (*http.Response, error) { var err error + const operationName = "ClustersClient.BeginMigrate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.migrateCreateRequest(ctx, resourceGroupName, clusterName, clusterMigrateRequest, options) if err != nil { return nil, err @@ -1036,10 +1099,14 @@ func (client *ClustersClient) BeginRemoveLanguageExtensions(ctx context.Context, if err != nil { return nil, err } - poller, err := runtime.NewPoller[ClustersClientRemoveLanguageExtensionsResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClustersClientRemoveLanguageExtensionsResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ClustersClientRemoveLanguageExtensionsResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClustersClientRemoveLanguageExtensionsResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -1049,6 +1116,10 @@ func (client *ClustersClient) BeginRemoveLanguageExtensions(ctx context.Context, // Generated from API version 2023-08-15 func (client *ClustersClient) removeLanguageExtensions(ctx context.Context, resourceGroupName string, clusterName string, languageExtensionsToRemove LanguageExtensionsList, options *ClustersClientBeginRemoveLanguageExtensionsOptions) (*http.Response, error) { var err error + const operationName = "ClustersClient.BeginRemoveLanguageExtensions" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.removeLanguageExtensionsCreateRequest(ctx, resourceGroupName, clusterName, languageExtensionsToRemove, options) if err != nil { return nil, err @@ -1106,10 +1177,14 @@ func (client *ClustersClient) BeginStart(ctx context.Context, resourceGroupName if err != nil { return nil, err } - poller, err := runtime.NewPoller[ClustersClientStartResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClustersClientStartResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ClustersClientStartResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClustersClientStartResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -1119,6 +1194,10 @@ func (client *ClustersClient) BeginStart(ctx context.Context, resourceGroupName // Generated from API version 2023-08-15 func (client *ClustersClient) start(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersClientBeginStartOptions) (*http.Response, error) { var err error + const operationName = "ClustersClient.BeginStart" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.startCreateRequest(ctx, resourceGroupName, clusterName, options) if err != nil { return nil, err @@ -1173,10 +1252,14 @@ func (client *ClustersClient) BeginStop(ctx context.Context, resourceGroupName s if err != nil { return nil, err } - poller, err := runtime.NewPoller[ClustersClientStopResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClustersClientStopResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ClustersClientStopResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClustersClientStopResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -1186,6 +1269,10 @@ func (client *ClustersClient) BeginStop(ctx context.Context, resourceGroupName s // Generated from API version 2023-08-15 func (client *ClustersClient) stop(ctx context.Context, resourceGroupName string, clusterName string, options *ClustersClientBeginStopOptions) (*http.Response, error) { var err error + const operationName = "ClustersClient.BeginStop" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.stopCreateRequest(ctx, resourceGroupName, clusterName, options) if err != nil { return nil, err @@ -1241,10 +1328,14 @@ func (client *ClustersClient) BeginUpdate(ctx context.Context, resourceGroupName if err != nil { return nil, err } - poller, err := runtime.NewPoller[ClustersClientUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ClustersClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ClustersClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ClustersClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -1254,6 +1345,10 @@ func (client *ClustersClient) BeginUpdate(ctx context.Context, resourceGroupName // Generated from API version 2023-08-15 func (client *ClustersClient) update(ctx context.Context, resourceGroupName string, clusterName string, parameters ClusterUpdate, options *ClustersClientBeginUpdateOptions) (*http.Response, error) { var err error + const operationName = "ClustersClient.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, clusterName, parameters, options) if err != nil { return nil, err diff --git a/sdk/resourcemanager/kusto/armkusto/clusters_client_example_test.go b/sdk/resourcemanager/kusto/armkusto/clusters_client_example_test.go index 196c6f5c591c..6e74b206a4ea 100644 --- a/sdk/resourcemanager/kusto/armkusto/clusters_client_example_test.go +++ b/sdk/resourcemanager/kusto/armkusto/clusters_client_example_test.go @@ -99,10 +99,10 @@ func ExampleClustersClient_Get() { // Tier: to.Ptr(armkusto.AzureSKUTierStandard), // }, // SystemData: &armkusto.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T15:06:54.2757906Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T15:06:54.275Z"); return t}()), // CreatedBy: to.Ptr("user@microsoft.com"), // CreatedByType: to.Ptr(armkusto.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T15:06:54.2757906Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T15:06:54.275Z"); return t}()), // LastModifiedBy: to.Ptr("user@microsoft.com"), // LastModifiedByType: to.Ptr(armkusto.CreatedByTypeUser), // }, diff --git a/sdk/resourcemanager/kusto/armkusto/constants.go b/sdk/resourcemanager/kusto/armkusto/constants.go index 8aa3e9060c43..29e63f017d6f 100644 --- a/sdk/resourcemanager/kusto/armkusto/constants.go +++ b/sdk/resourcemanager/kusto/armkusto/constants.go @@ -9,8 +9,8 @@ package armkusto const ( - moduleName = "armkusto" - moduleVersion = "v2.1.0" + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kusto/armkusto" + moduleVersion = "v2.2.0" ) // AzureSKUName - SKU name. diff --git a/sdk/resourcemanager/kusto/armkusto/database_client.go b/sdk/resourcemanager/kusto/armkusto/database_client.go index c3ea44672db5..27abeec12015 100644 --- a/sdk/resourcemanager/kusto/armkusto/database_client.go +++ b/sdk/resourcemanager/kusto/armkusto/database_client.go @@ -32,7 +32,7 @@ type DatabaseClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewDatabaseClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DatabaseClient, error) { - cl, err := arm.NewClient(moduleName+".DatabaseClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,6 +54,10 @@ func NewDatabaseClient(subscriptionID string, credential azcore.TokenCredential, // - options - DatabaseClientInviteFollowerOptions contains the optional parameters for the DatabaseClient.InviteFollower method. func (client *DatabaseClient) InviteFollower(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters DatabaseInviteFollowerRequest, options *DatabaseClientInviteFollowerOptions) (DatabaseClientInviteFollowerResponse, error) { var err error + const operationName = "DatabaseClient.InviteFollower" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.inviteFollowerCreateRequest(ctx, resourceGroupName, clusterName, databaseName, parameters, options) if err != nil { return DatabaseClientInviteFollowerResponse{}, err diff --git a/sdk/resourcemanager/kusto/armkusto/databaseprincipalassignments_client.go b/sdk/resourcemanager/kusto/armkusto/databaseprincipalassignments_client.go index cb1843cdcda7..33889f2cc1ac 100644 --- a/sdk/resourcemanager/kusto/armkusto/databaseprincipalassignments_client.go +++ b/sdk/resourcemanager/kusto/armkusto/databaseprincipalassignments_client.go @@ -32,7 +32,7 @@ type DatabasePrincipalAssignmentsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewDatabasePrincipalAssignmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DatabasePrincipalAssignmentsClient, error) { - cl, err := arm.NewClient(moduleName+".DatabasePrincipalAssignmentsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,6 +55,10 @@ func NewDatabasePrincipalAssignmentsClient(subscriptionID string, credential azc // method. func (client *DatabasePrincipalAssignmentsClient) CheckNameAvailability(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName DatabasePrincipalAssignmentCheckNameRequest, options *DatabasePrincipalAssignmentsClientCheckNameAvailabilityOptions) (DatabasePrincipalAssignmentsClientCheckNameAvailabilityResponse, error) { var err error + const operationName = "DatabasePrincipalAssignmentsClient.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, resourceGroupName, clusterName, databaseName, principalAssignmentName, options) if err != nil { return DatabasePrincipalAssignmentsClientCheckNameAvailabilityResponse{}, err @@ -130,10 +134,14 @@ func (client *DatabasePrincipalAssignmentsClient) BeginCreateOrUpdate(ctx contex if err != nil { return nil, err } - poller, err := runtime.NewPoller[DatabasePrincipalAssignmentsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DatabasePrincipalAssignmentsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[DatabasePrincipalAssignmentsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DatabasePrincipalAssignmentsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -143,6 +151,10 @@ func (client *DatabasePrincipalAssignmentsClient) BeginCreateOrUpdate(ctx contex // Generated from API version 2023-08-15 func (client *DatabasePrincipalAssignmentsClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName string, parameters DatabasePrincipalAssignment, options *DatabasePrincipalAssignmentsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error + const operationName = "DatabasePrincipalAssignmentsClient.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, clusterName, databaseName, principalAssignmentName, parameters, options) if err != nil { return nil, err @@ -211,10 +223,14 @@ func (client *DatabasePrincipalAssignmentsClient) BeginDelete(ctx context.Contex if err != nil { return nil, err } - poller, err := runtime.NewPoller[DatabasePrincipalAssignmentsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DatabasePrincipalAssignmentsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[DatabasePrincipalAssignmentsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DatabasePrincipalAssignmentsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -224,6 +240,10 @@ func (client *DatabasePrincipalAssignmentsClient) BeginDelete(ctx context.Contex // Generated from API version 2023-08-15 func (client *DatabasePrincipalAssignmentsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName string, options *DatabasePrincipalAssignmentsClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "DatabasePrincipalAssignmentsClient.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, clusterName, databaseName, principalAssignmentName, options) if err != nil { return nil, err @@ -285,6 +305,10 @@ func (client *DatabasePrincipalAssignmentsClient) deleteCreateRequest(ctx contex // method. func (client *DatabasePrincipalAssignmentsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName string, options *DatabasePrincipalAssignmentsClientGetOptions) (DatabasePrincipalAssignmentsClientGetResponse, error) { var err error + const operationName = "DatabasePrincipalAssignmentsClient.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, clusterName, databaseName, principalAssignmentName, options) if err != nil { return DatabasePrincipalAssignmentsClientGetResponse{}, err @@ -358,6 +382,7 @@ func (client *DatabasePrincipalAssignmentsClient) NewListPager(resourceGroupName return false }, Fetcher: func(ctx context.Context, page *DatabasePrincipalAssignmentsClientListResponse) (DatabasePrincipalAssignmentsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DatabasePrincipalAssignmentsClient.NewListPager") req, err := client.listCreateRequest(ctx, resourceGroupName, clusterName, databaseName, options) if err != nil { return DatabasePrincipalAssignmentsClientListResponse{}, err @@ -371,6 +396,7 @@ func (client *DatabasePrincipalAssignmentsClient) NewListPager(resourceGroupName } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/kusto/armkusto/databases_client.go b/sdk/resourcemanager/kusto/armkusto/databases_client.go index a1e01fd4e34d..674b2a16d43c 100644 --- a/sdk/resourcemanager/kusto/armkusto/databases_client.go +++ b/sdk/resourcemanager/kusto/armkusto/databases_client.go @@ -33,7 +33,7 @@ type DatabasesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewDatabasesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DatabasesClient, error) { - cl, err := arm.NewClient(moduleName+".DatabasesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,6 +55,10 @@ func NewDatabasesClient(subscriptionID string, credential azcore.TokenCredential // - options - DatabasesClientAddPrincipalsOptions contains the optional parameters for the DatabasesClient.AddPrincipals method. func (client *DatabasesClient) AddPrincipals(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, databasePrincipalsToAdd DatabasePrincipalListRequest, options *DatabasesClientAddPrincipalsOptions) (DatabasesClientAddPrincipalsResponse, error) { var err error + const operationName = "DatabasesClient.AddPrincipals" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.addPrincipalsCreateRequest(ctx, resourceGroupName, clusterName, databaseName, databasePrincipalsToAdd, options) if err != nil { return DatabasesClientAddPrincipalsResponse{}, err @@ -124,6 +128,10 @@ func (client *DatabasesClient) addPrincipalsHandleResponse(resp *http.Response) // method. func (client *DatabasesClient) CheckNameAvailability(ctx context.Context, resourceGroupName string, clusterName string, resourceName CheckNameRequest, options *DatabasesClientCheckNameAvailabilityOptions) (DatabasesClientCheckNameAvailabilityResponse, error) { var err error + const operationName = "DatabasesClient.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, resourceGroupName, clusterName, resourceName, options) if err != nil { return DatabasesClientCheckNameAvailabilityResponse{}, err @@ -194,10 +202,14 @@ func (client *DatabasesClient) BeginCreateOrUpdate(ctx context.Context, resource if err != nil { return nil, err } - poller, err := runtime.NewPoller[DatabasesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DatabasesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[DatabasesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DatabasesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -207,6 +219,10 @@ func (client *DatabasesClient) BeginCreateOrUpdate(ctx context.Context, resource // Generated from API version 2023-08-15 func (client *DatabasesClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters DatabaseClassification, options *DatabasesClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error + const operationName = "DatabasesClient.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, clusterName, databaseName, parameters, options) if err != nil { return nil, err @@ -272,10 +288,14 @@ func (client *DatabasesClient) BeginDelete(ctx context.Context, resourceGroupNam if err != nil { return nil, err } - poller, err := runtime.NewPoller[DatabasesClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DatabasesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[DatabasesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DatabasesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -285,6 +305,10 @@ func (client *DatabasesClient) BeginDelete(ctx context.Context, resourceGroupNam // Generated from API version 2023-08-15 func (client *DatabasesClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, options *DatabasesClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "DatabasesClient.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, clusterName, databaseName, options) if err != nil { return nil, err @@ -340,6 +364,10 @@ func (client *DatabasesClient) deleteCreateRequest(ctx context.Context, resource // - options - DatabasesClientGetOptions contains the optional parameters for the DatabasesClient.Get method. func (client *DatabasesClient) Get(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, options *DatabasesClientGetOptions) (DatabasesClientGetResponse, error) { var err error + const operationName = "DatabasesClient.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, clusterName, databaseName, options) if err != nil { return DatabasesClientGetResponse{}, err @@ -408,25 +436,20 @@ func (client *DatabasesClient) NewListByClusterPager(resourceGroupName string, c return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *DatabasesClientListByClusterResponse) (DatabasesClientListByClusterResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByClusterCreateRequest(ctx, resourceGroupName, clusterName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DatabasesClient.NewListByClusterPager") + 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.listByClusterCreateRequest(ctx, resourceGroupName, clusterName, options) + }, nil) if err != nil { return DatabasesClientListByClusterResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return DatabasesClientListByClusterResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return DatabasesClientListByClusterResponse{}, runtime.NewResponseError(resp) - } return client.listByClusterHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -485,6 +508,7 @@ func (client *DatabasesClient) NewListPrincipalsPager(resourceGroupName string, return false }, Fetcher: func(ctx context.Context, page *DatabasesClientListPrincipalsResponse) (DatabasesClientListPrincipalsResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DatabasesClient.NewListPrincipalsPager") req, err := client.listPrincipalsCreateRequest(ctx, resourceGroupName, clusterName, databaseName, options) if err != nil { return DatabasesClientListPrincipalsResponse{}, err @@ -498,6 +522,7 @@ func (client *DatabasesClient) NewListPrincipalsPager(resourceGroupName string, } return client.listPrincipalsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -552,6 +577,10 @@ func (client *DatabasesClient) listPrincipalsHandleResponse(resp *http.Response) // method. func (client *DatabasesClient) RemovePrincipals(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, databasePrincipalsToRemove DatabasePrincipalListRequest, options *DatabasesClientRemovePrincipalsOptions) (DatabasesClientRemovePrincipalsResponse, error) { var err error + const operationName = "DatabasesClient.RemovePrincipals" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.removePrincipalsCreateRequest(ctx, resourceGroupName, clusterName, databaseName, databasePrincipalsToRemove, options) if err != nil { return DatabasesClientRemovePrincipalsResponse{}, err @@ -625,10 +654,14 @@ func (client *DatabasesClient) BeginUpdate(ctx context.Context, resourceGroupNam if err != nil { return nil, err } - poller, err := runtime.NewPoller[DatabasesClientUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DatabasesClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[DatabasesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DatabasesClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -638,6 +671,10 @@ func (client *DatabasesClient) BeginUpdate(ctx context.Context, resourceGroupNam // Generated from API version 2023-08-15 func (client *DatabasesClient) update(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters DatabaseClassification, options *DatabasesClientBeginUpdateOptions) (*http.Response, error) { var err error + const operationName = "DatabasesClient.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, clusterName, databaseName, parameters, options) if err != nil { return nil, err diff --git a/sdk/resourcemanager/kusto/armkusto/databases_client_example_test.go b/sdk/resourcemanager/kusto/armkusto/databases_client_example_test.go index 2ee4c398186a..fcc2b1431ae6 100644 --- a/sdk/resourcemanager/kusto/armkusto/databases_client_example_test.go +++ b/sdk/resourcemanager/kusto/armkusto/databases_client_example_test.go @@ -129,7 +129,7 @@ func ExampleDatabasesClient_NewListByClusterPager() { // ProvisioningState: to.Ptr(armkusto.ProvisioningStateSucceeded), // SoftDeletePeriod: to.Ptr("P1D"), // SuspensionDetails: &armkusto.SuspensionDetails{ - // SuspensionStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-16T15:06:54.2757906Z"); return t}()), + // SuspensionStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-16T15:06:54.275Z"); return t}()), // }, // }, // }}, @@ -199,7 +199,7 @@ func ExampleDatabasesClient_Get_kustoSuspendedDatabasesGet() { // ProvisioningState: to.Ptr(armkusto.ProvisioningStateSucceeded), // SoftDeletePeriod: to.Ptr("P1D"), // SuspensionDetails: &armkusto.SuspensionDetails{ - // SuspensionStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-16T15:06:54.2757906Z"); return t}()), + // SuspensionStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2023-04-16T15:06:54.275Z"); return t}()), // }, // }, // }, diff --git a/sdk/resourcemanager/kusto/armkusto/dataconnections_client.go b/sdk/resourcemanager/kusto/armkusto/dataconnections_client.go index dc63a8d04fc9..c343ac06d682 100644 --- a/sdk/resourcemanager/kusto/armkusto/dataconnections_client.go +++ b/sdk/resourcemanager/kusto/armkusto/dataconnections_client.go @@ -32,7 +32,7 @@ type DataConnectionsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewDataConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*DataConnectionsClient, error) { - cl, err := arm.NewClient(moduleName+".DataConnectionsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,6 +55,10 @@ func NewDataConnectionsClient(subscriptionID string, credential azcore.TokenCred // method. func (client *DataConnectionsClient) CheckNameAvailability(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName DataConnectionCheckNameRequest, options *DataConnectionsClientCheckNameAvailabilityOptions) (DataConnectionsClientCheckNameAvailabilityResponse, error) { var err error + const operationName = "DataConnectionsClient.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, resourceGroupName, clusterName, databaseName, dataConnectionName, options) if err != nil { return DataConnectionsClientCheckNameAvailabilityResponse{}, err @@ -130,10 +134,14 @@ func (client *DataConnectionsClient) BeginCreateOrUpdate(ctx context.Context, re if err != nil { return nil, err } - poller, err := runtime.NewPoller[DataConnectionsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DataConnectionsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[DataConnectionsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DataConnectionsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -143,6 +151,10 @@ func (client *DataConnectionsClient) BeginCreateOrUpdate(ctx context.Context, re // Generated from API version 2023-08-15 func (client *DataConnectionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, parameters DataConnectionClassification, options *DataConnectionsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error + const operationName = "DataConnectionsClient.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, clusterName, databaseName, dataConnectionName, parameters, options) if err != nil { return nil, err @@ -211,10 +223,14 @@ func (client *DataConnectionsClient) BeginDataConnectionValidation(ctx context.C if err != nil { return nil, err } - poller, err := runtime.NewPoller[DataConnectionsClientDataConnectionValidationResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DataConnectionsClientDataConnectionValidationResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[DataConnectionsClientDataConnectionValidationResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DataConnectionsClientDataConnectionValidationResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -224,6 +240,10 @@ func (client *DataConnectionsClient) BeginDataConnectionValidation(ctx context.C // Generated from API version 2023-08-15 func (client *DataConnectionsClient) dataConnectionValidation(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters DataConnectionValidation, options *DataConnectionsClientBeginDataConnectionValidationOptions) (*http.Response, error) { var err error + const operationName = "DataConnectionsClient.BeginDataConnectionValidation" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.dataConnectionValidationCreateRequest(ctx, resourceGroupName, clusterName, databaseName, parameters, options) if err != nil { return nil, err @@ -288,10 +308,14 @@ func (client *DataConnectionsClient) BeginDelete(ctx context.Context, resourceGr if err != nil { return nil, err } - poller, err := runtime.NewPoller[DataConnectionsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DataConnectionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[DataConnectionsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DataConnectionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -301,6 +325,10 @@ func (client *DataConnectionsClient) BeginDelete(ctx context.Context, resourceGr // Generated from API version 2023-08-15 func (client *DataConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, options *DataConnectionsClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "DataConnectionsClient.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, clusterName, databaseName, dataConnectionName, options) if err != nil { return nil, err @@ -361,6 +389,10 @@ func (client *DataConnectionsClient) deleteCreateRequest(ctx context.Context, re // - options - DataConnectionsClientGetOptions contains the optional parameters for the DataConnectionsClient.Get method. func (client *DataConnectionsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, options *DataConnectionsClientGetOptions) (DataConnectionsClientGetResponse, error) { var err error + const operationName = "DataConnectionsClient.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, clusterName, databaseName, dataConnectionName, options) if err != nil { return DataConnectionsClientGetResponse{}, err @@ -434,6 +466,7 @@ func (client *DataConnectionsClient) NewListByDatabasePager(resourceGroupName st return false }, Fetcher: func(ctx context.Context, page *DataConnectionsClientListByDatabaseResponse) (DataConnectionsClientListByDatabaseResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "DataConnectionsClient.NewListByDatabasePager") req, err := client.listByDatabaseCreateRequest(ctx, resourceGroupName, clusterName, databaseName, options) if err != nil { return DataConnectionsClientListByDatabaseResponse{}, err @@ -447,6 +480,7 @@ func (client *DataConnectionsClient) NewListByDatabasePager(resourceGroupName st } return client.listByDatabaseHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -506,10 +540,14 @@ func (client *DataConnectionsClient) BeginUpdate(ctx context.Context, resourceGr if err != nil { return nil, err } - poller, err := runtime.NewPoller[DataConnectionsClientUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[DataConnectionsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[DataConnectionsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[DataConnectionsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -519,6 +557,10 @@ func (client *DataConnectionsClient) BeginUpdate(ctx context.Context, resourceGr // Generated from API version 2023-08-15 func (client *DataConnectionsClient) update(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, parameters DataConnectionClassification, options *DataConnectionsClientBeginUpdateOptions) (*http.Response, error) { var err error + const operationName = "DataConnectionsClient.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, clusterName, databaseName, dataConnectionName, parameters, options) if err != nil { return nil, err diff --git a/sdk/resourcemanager/kusto/armkusto/dataconnections_client_example_test.go b/sdk/resourcemanager/kusto/armkusto/dataconnections_client_example_test.go index 6e414392edc6..47a10235e9c2 100644 --- a/sdk/resourcemanager/kusto/armkusto/dataconnections_client_example_test.go +++ b/sdk/resourcemanager/kusto/armkusto/dataconnections_client_example_test.go @@ -62,7 +62,7 @@ func ExampleDataConnectionsClient_NewListByDatabasePager() { // ManagedIdentityResourceID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/managedidentityTest1"), // MappingRuleName: to.Ptr("TestMapping"), // ProvisioningState: to.Ptr(armkusto.ProvisioningStateSucceeded), - // RetrievalStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-29T12:00:00.6554616Z"); return t}()), + // RetrievalStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-29T12:00:00.655Z"); return t}()), // TableName: to.Ptr("TestTable"), // }, // }, @@ -102,7 +102,7 @@ func ExampleDataConnectionsClient_NewListByDatabasePager() { // ManagedIdentityResourceID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/managedidentityTest1"), // MappingRuleName: to.Ptr("TestMapping"), // ProvisioningState: to.Ptr(armkusto.ProvisioningStateSucceeded), - // RetrievalStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-29T12:00:00.6554616Z"); return t}()), + // RetrievalStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-29T12:00:00.655Z"); return t}()), // TableName: to.Ptr("TestTable"), // }, // }}, @@ -256,7 +256,7 @@ func ExampleDataConnectionsClient_Get_kustoDataConnectionsCosmosDbGet() { // ManagedIdentityResourceID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/managedidentityTest1"), // MappingRuleName: to.Ptr("TestMapping"), // ProvisioningState: to.Ptr(armkusto.ProvisioningStateSucceeded), - // RetrievalStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-29T12:00:00.6554616Z"); return t}()), + // RetrievalStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-29T12:00:00.655Z"); return t}()), // TableName: to.Ptr("TestTable"), // }, // }, @@ -344,7 +344,7 @@ func ExampleDataConnectionsClient_Get_kustoDataConnectionsGet() { // ManagedIdentityResourceID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/managedidentityTest1"), // MappingRuleName: to.Ptr("TestMapping"), // ProvisioningState: to.Ptr(armkusto.ProvisioningStateSucceeded), - // RetrievalStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-29T12:00:00.6554616Z"); return t}()), + // RetrievalStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-29T12:00:00.655Z"); return t}()), // TableName: to.Ptr("TestTable"), // }, // }, @@ -371,7 +371,7 @@ func ExampleDataConnectionsClient_BeginCreateOrUpdate_kustoDataConnectionsCosmos CosmosDbDatabase: to.Ptr("cosmosDbDatabaseTest"), ManagedIdentityResourceID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/managedidentityTest1"), MappingRuleName: to.Ptr("TestMapping"), - RetrievalStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-29T12:00:00.6554616Z"); return t }()), + RetrievalStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-29T12:00:00.655Z"); return t }()), TableName: to.Ptr("TestTable"), }, }, nil) @@ -399,7 +399,7 @@ func ExampleDataConnectionsClient_BeginCreateOrUpdate_kustoDataConnectionsCosmos // ManagedIdentityObjectID: to.Ptr("87654321-1234-1234-1234-123456789123"), // ManagedIdentityResourceID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/managedidentityTest1"), // MappingRuleName: to.Ptr("TestMapping"), - // RetrievalStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-29T12:00:00.6554616Z"); return t}()), + // RetrievalStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-29T12:00:00.655Z"); return t}()), // TableName: to.Ptr("TestTable"), // }, // }, @@ -536,7 +536,7 @@ func ExampleDataConnectionsClient_BeginUpdate_kustoDataConnectionsCosmosDbUpdate CosmosDbDatabase: to.Ptr("cosmosDbDatabaseTest"), ManagedIdentityResourceID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/managedidentityTest1"), MappingRuleName: to.Ptr("TestMapping"), - RetrievalStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-29T12:00:00.6554616Z"); return t }()), + RetrievalStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-29T12:00:00.655Z"); return t }()), TableName: to.Ptr("TestTable"), }, }, nil) @@ -564,7 +564,7 @@ func ExampleDataConnectionsClient_BeginUpdate_kustoDataConnectionsCosmosDbUpdate // ManagedIdentityObjectID: to.Ptr("87654321-1234-1234-1234-123456789123"), // ManagedIdentityResourceID: to.Ptr("/subscriptions/12345678-1234-1234-1234-123456789098/resourceGroups/kustorptest/providers/Microsoft.ManagedIdentity/userAssignedIdentities/managedidentityTest1"), // MappingRuleName: to.Ptr("TestMapping"), - // RetrievalStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-29T12:00:00.6554616Z"); return t}()), + // RetrievalStartDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-07-29T12:00:00.655Z"); return t}()), // TableName: to.Ptr("TestTable"), // }, // }, diff --git a/sdk/resourcemanager/kusto/armkusto/fake/attacheddatabaseconfigurations_server.go b/sdk/resourcemanager/kusto/armkusto/fake/attacheddatabaseconfigurations_server.go new file mode 100644 index 000000000000..7c967585e5e9 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/attacheddatabaseconfigurations_server.go @@ -0,0 +1,311 @@ +//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/resourcemanager/kusto/armkusto/v2" + "net/http" + "net/url" + "regexp" +) + +// AttachedDatabaseConfigurationsServer is a fake server for instances of the armkusto.AttachedDatabaseConfigurationsClient type. +type AttachedDatabaseConfigurationsServer struct { + // CheckNameAvailability is the fake for method AttachedDatabaseConfigurationsClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, resourceGroupName string, clusterName string, resourceName armkusto.AttachedDatabaseConfigurationsCheckNameRequest, options *armkusto.AttachedDatabaseConfigurationsClientCheckNameAvailabilityOptions) (resp azfake.Responder[armkusto.AttachedDatabaseConfigurationsClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method AttachedDatabaseConfigurationsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, clusterName string, attachedDatabaseConfigurationName string, parameters armkusto.AttachedDatabaseConfiguration, options *armkusto.AttachedDatabaseConfigurationsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armkusto.AttachedDatabaseConfigurationsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method AttachedDatabaseConfigurationsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, clusterName string, attachedDatabaseConfigurationName string, options *armkusto.AttachedDatabaseConfigurationsClientBeginDeleteOptions) (resp azfake.PollerResponder[armkusto.AttachedDatabaseConfigurationsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method AttachedDatabaseConfigurationsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterName string, attachedDatabaseConfigurationName string, options *armkusto.AttachedDatabaseConfigurationsClientGetOptions) (resp azfake.Responder[armkusto.AttachedDatabaseConfigurationsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByClusterPager is the fake for method AttachedDatabaseConfigurationsClient.NewListByClusterPager + // HTTP status codes to indicate success: http.StatusOK + NewListByClusterPager func(resourceGroupName string, clusterName string, options *armkusto.AttachedDatabaseConfigurationsClientListByClusterOptions) (resp azfake.PagerResponder[armkusto.AttachedDatabaseConfigurationsClientListByClusterResponse]) +} + +// NewAttachedDatabaseConfigurationsServerTransport creates a new instance of AttachedDatabaseConfigurationsServerTransport with the provided implementation. +// The returned AttachedDatabaseConfigurationsServerTransport instance is connected to an instance of armkusto.AttachedDatabaseConfigurationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewAttachedDatabaseConfigurationsServerTransport(srv *AttachedDatabaseConfigurationsServer) *AttachedDatabaseConfigurationsServerTransport { + return &AttachedDatabaseConfigurationsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armkusto.AttachedDatabaseConfigurationsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armkusto.AttachedDatabaseConfigurationsClientDeleteResponse]](), + newListByClusterPager: newTracker[azfake.PagerResponder[armkusto.AttachedDatabaseConfigurationsClientListByClusterResponse]](), + } +} + +// AttachedDatabaseConfigurationsServerTransport connects instances of armkusto.AttachedDatabaseConfigurationsClient to instances of AttachedDatabaseConfigurationsServer. +// Don't use this type directly, use NewAttachedDatabaseConfigurationsServerTransport instead. +type AttachedDatabaseConfigurationsServerTransport struct { + srv *AttachedDatabaseConfigurationsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armkusto.AttachedDatabaseConfigurationsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armkusto.AttachedDatabaseConfigurationsClientDeleteResponse]] + newListByClusterPager *tracker[azfake.PagerResponder[armkusto.AttachedDatabaseConfigurationsClientListByClusterResponse]] +} + +// Do implements the policy.Transporter interface for AttachedDatabaseConfigurationsServerTransport. +func (a *AttachedDatabaseConfigurationsServerTransport) 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 "AttachedDatabaseConfigurationsClient.CheckNameAvailability": + resp, err = a.dispatchCheckNameAvailability(req) + case "AttachedDatabaseConfigurationsClient.BeginCreateOrUpdate": + resp, err = a.dispatchBeginCreateOrUpdate(req) + case "AttachedDatabaseConfigurationsClient.BeginDelete": + resp, err = a.dispatchBeginDelete(req) + case "AttachedDatabaseConfigurationsClient.Get": + resp, err = a.dispatchGet(req) + case "AttachedDatabaseConfigurationsClient.NewListByClusterPager": + resp, err = a.dispatchNewListByClusterPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (a *AttachedDatabaseConfigurationsServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if a.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/attachedDatabaseConfigurationCheckNameAvailability` + 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[armkusto.AttachedDatabaseConfigurationsCheckNameRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.CheckNameAvailability(req.Context(), resourceGroupNameParam, clusterNameParam, 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).CheckNameResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AttachedDatabaseConfigurationsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if a.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := a.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/attachedDatabaseConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkusto.AttachedDatabaseConfiguration](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + attachedDatabaseConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("attachedDatabaseConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, clusterNameParam, attachedDatabaseConfigurationNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + a.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + a.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + a.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (a *AttachedDatabaseConfigurationsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if a.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := a.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/attachedDatabaseConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + attachedDatabaseConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("attachedDatabaseConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.BeginDelete(req.Context(), resourceGroupNameParam, clusterNameParam, attachedDatabaseConfigurationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + a.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) { + a.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) { + a.beginDelete.remove(req) + } + + return resp, nil +} + +func (a *AttachedDatabaseConfigurationsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if a.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\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/attachedDatabaseConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + attachedDatabaseConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("attachedDatabaseConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := a.srv.Get(req.Context(), resourceGroupNameParam, clusterNameParam, attachedDatabaseConfigurationNameParam, 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).AttachedDatabaseConfiguration, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (a *AttachedDatabaseConfigurationsServerTransport) dispatchNewListByClusterPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListByClusterPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByClusterPager not implemented")} + } + newListByClusterPager := a.newListByClusterPager.get(req) + if newListByClusterPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/attachedDatabaseConfigurations` + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListByClusterPager(resourceGroupNameParam, clusterNameParam, nil) + newListByClusterPager = &resp + a.newListByClusterPager.add(req, newListByClusterPager) + } + resp, err := server.PagerResponderNext(newListByClusterPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListByClusterPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByClusterPager) { + a.newListByClusterPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/kusto/armkusto/fake/clusterprincipalassignments_server.go b/sdk/resourcemanager/kusto/armkusto/fake/clusterprincipalassignments_server.go new file mode 100644 index 000000000000..e4a463322799 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/clusterprincipalassignments_server.go @@ -0,0 +1,311 @@ +//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/resourcemanager/kusto/armkusto/v2" + "net/http" + "net/url" + "regexp" +) + +// ClusterPrincipalAssignmentsServer is a fake server for instances of the armkusto.ClusterPrincipalAssignmentsClient type. +type ClusterPrincipalAssignmentsServer struct { + // CheckNameAvailability is the fake for method ClusterPrincipalAssignmentsClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, resourceGroupName string, clusterName string, principalAssignmentName armkusto.ClusterPrincipalAssignmentCheckNameRequest, options *armkusto.ClusterPrincipalAssignmentsClientCheckNameAvailabilityOptions) (resp azfake.Responder[armkusto.ClusterPrincipalAssignmentsClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method ClusterPrincipalAssignmentsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, clusterName string, principalAssignmentName string, parameters armkusto.ClusterPrincipalAssignment, options *armkusto.ClusterPrincipalAssignmentsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armkusto.ClusterPrincipalAssignmentsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method ClusterPrincipalAssignmentsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, clusterName string, principalAssignmentName string, options *armkusto.ClusterPrincipalAssignmentsClientBeginDeleteOptions) (resp azfake.PollerResponder[armkusto.ClusterPrincipalAssignmentsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ClusterPrincipalAssignmentsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterName string, principalAssignmentName string, options *armkusto.ClusterPrincipalAssignmentsClientGetOptions) (resp azfake.Responder[armkusto.ClusterPrincipalAssignmentsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method ClusterPrincipalAssignmentsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, clusterName string, options *armkusto.ClusterPrincipalAssignmentsClientListOptions) (resp azfake.PagerResponder[armkusto.ClusterPrincipalAssignmentsClientListResponse]) +} + +// NewClusterPrincipalAssignmentsServerTransport creates a new instance of ClusterPrincipalAssignmentsServerTransport with the provided implementation. +// The returned ClusterPrincipalAssignmentsServerTransport instance is connected to an instance of armkusto.ClusterPrincipalAssignmentsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewClusterPrincipalAssignmentsServerTransport(srv *ClusterPrincipalAssignmentsServer) *ClusterPrincipalAssignmentsServerTransport { + return &ClusterPrincipalAssignmentsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armkusto.ClusterPrincipalAssignmentsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armkusto.ClusterPrincipalAssignmentsClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armkusto.ClusterPrincipalAssignmentsClientListResponse]](), + } +} + +// ClusterPrincipalAssignmentsServerTransport connects instances of armkusto.ClusterPrincipalAssignmentsClient to instances of ClusterPrincipalAssignmentsServer. +// Don't use this type directly, use NewClusterPrincipalAssignmentsServerTransport instead. +type ClusterPrincipalAssignmentsServerTransport struct { + srv *ClusterPrincipalAssignmentsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armkusto.ClusterPrincipalAssignmentsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armkusto.ClusterPrincipalAssignmentsClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armkusto.ClusterPrincipalAssignmentsClientListResponse]] +} + +// Do implements the policy.Transporter interface for ClusterPrincipalAssignmentsServerTransport. +func (c *ClusterPrincipalAssignmentsServerTransport) 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 "ClusterPrincipalAssignmentsClient.CheckNameAvailability": + resp, err = c.dispatchCheckNameAvailability(req) + case "ClusterPrincipalAssignmentsClient.BeginCreateOrUpdate": + resp, err = c.dispatchBeginCreateOrUpdate(req) + case "ClusterPrincipalAssignmentsClient.BeginDelete": + resp, err = c.dispatchBeginDelete(req) + case "ClusterPrincipalAssignmentsClient.Get": + resp, err = c.dispatchGet(req) + case "ClusterPrincipalAssignmentsClient.NewListPager": + resp, err = c.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (c *ClusterPrincipalAssignmentsServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if c.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkPrincipalAssignmentNameAvailability` + 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[armkusto.ClusterPrincipalAssignmentCheckNameRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.CheckNameAvailability(req.Context(), resourceGroupNameParam, clusterNameParam, 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).CheckNameResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *ClusterPrincipalAssignmentsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if c.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := c.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/principalAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkusto.ClusterPrincipalAssignment](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + principalAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("principalAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, clusterNameParam, principalAssignmentNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + c.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) { + c.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) { + c.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (c *ClusterPrincipalAssignmentsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if c.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := c.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/principalAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + principalAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("principalAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginDelete(req.Context(), resourceGroupNameParam, clusterNameParam, principalAssignmentNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + c.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) { + c.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) { + c.beginDelete.remove(req) + } + + return resp, nil +} + +func (c *ClusterPrincipalAssignmentsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if c.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\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/principalAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + principalAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("principalAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameParam, clusterNameParam, principalAssignmentNameParam, 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).ClusterPrincipalAssignment, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *ClusterPrincipalAssignmentsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := c.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/principalAssignments` + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + resp := c.srv.NewListPager(resourceGroupNameParam, clusterNameParam, nil) + newListPager = &resp + c.newListPager.add(req, newListPager) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + c.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/kusto/armkusto/fake/clusters_server.go b/sdk/resourcemanager/kusto/armkusto/fake/clusters_server.go new file mode 100644 index 000000000000..dcc219ac44cc --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/clusters_server.go @@ -0,0 +1,1007 @@ +//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/kusto/armkusto/v2" + "net/http" + "net/url" + "regexp" +) + +// ClustersServer is a fake server for instances of the armkusto.ClustersClient type. +type ClustersServer struct { + // BeginAddLanguageExtensions is the fake for method ClustersClient.BeginAddLanguageExtensions + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginAddLanguageExtensions func(ctx context.Context, resourceGroupName string, clusterName string, languageExtensionsToAdd armkusto.LanguageExtensionsList, options *armkusto.ClustersClientBeginAddLanguageExtensionsOptions) (resp azfake.PollerResponder[armkusto.ClustersClientAddLanguageExtensionsResponse], errResp azfake.ErrorResponder) + + // CheckNameAvailability is the fake for method ClustersClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, location string, clusterName armkusto.ClusterCheckNameRequest, options *armkusto.ClustersClientCheckNameAvailabilityOptions) (resp azfake.Responder[armkusto.ClustersClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method ClustersClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, clusterName string, parameters armkusto.Cluster, options *armkusto.ClustersClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armkusto.ClustersClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method ClustersClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, clusterName string, options *armkusto.ClustersClientBeginDeleteOptions) (resp azfake.PollerResponder[armkusto.ClustersClientDeleteResponse], errResp azfake.ErrorResponder) + + // BeginDetachFollowerDatabases is the fake for method ClustersClient.BeginDetachFollowerDatabases + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginDetachFollowerDatabases func(ctx context.Context, resourceGroupName string, clusterName string, followerDatabaseToRemove armkusto.FollowerDatabaseDefinition, options *armkusto.ClustersClientBeginDetachFollowerDatabasesOptions) (resp azfake.PollerResponder[armkusto.ClustersClientDetachFollowerDatabasesResponse], errResp azfake.ErrorResponder) + + // BeginDiagnoseVirtualNetwork is the fake for method ClustersClient.BeginDiagnoseVirtualNetwork + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginDiagnoseVirtualNetwork func(ctx context.Context, resourceGroupName string, clusterName string, options *armkusto.ClustersClientBeginDiagnoseVirtualNetworkOptions) (resp azfake.PollerResponder[armkusto.ClustersClientDiagnoseVirtualNetworkResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ClustersClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterName string, options *armkusto.ClustersClientGetOptions) (resp azfake.Responder[armkusto.ClustersClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method ClustersClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armkusto.ClustersClientListOptions) (resp azfake.PagerResponder[armkusto.ClustersClientListResponse]) + + // NewListByResourceGroupPager is the fake for method ClustersClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armkusto.ClustersClientListByResourceGroupOptions) (resp azfake.PagerResponder[armkusto.ClustersClientListByResourceGroupResponse]) + + // NewListFollowerDatabasesPager is the fake for method ClustersClient.NewListFollowerDatabasesPager + // HTTP status codes to indicate success: http.StatusOK + NewListFollowerDatabasesPager func(resourceGroupName string, clusterName string, options *armkusto.ClustersClientListFollowerDatabasesOptions) (resp azfake.PagerResponder[armkusto.ClustersClientListFollowerDatabasesResponse]) + + // NewListLanguageExtensionsPager is the fake for method ClustersClient.NewListLanguageExtensionsPager + // HTTP status codes to indicate success: http.StatusOK + NewListLanguageExtensionsPager func(resourceGroupName string, clusterName string, options *armkusto.ClustersClientListLanguageExtensionsOptions) (resp azfake.PagerResponder[armkusto.ClustersClientListLanguageExtensionsResponse]) + + // NewListOutboundNetworkDependenciesEndpointsPager is the fake for method ClustersClient.NewListOutboundNetworkDependenciesEndpointsPager + // HTTP status codes to indicate success: http.StatusOK + NewListOutboundNetworkDependenciesEndpointsPager func(resourceGroupName string, clusterName string, options *armkusto.ClustersClientListOutboundNetworkDependenciesEndpointsOptions) (resp azfake.PagerResponder[armkusto.ClustersClientListOutboundNetworkDependenciesEndpointsResponse]) + + // NewListSKUsPager is the fake for method ClustersClient.NewListSKUsPager + // HTTP status codes to indicate success: http.StatusOK + NewListSKUsPager func(options *armkusto.ClustersClientListSKUsOptions) (resp azfake.PagerResponder[armkusto.ClustersClientListSKUsResponse]) + + // NewListSKUsByResourcePager is the fake for method ClustersClient.NewListSKUsByResourcePager + // HTTP status codes to indicate success: http.StatusOK + NewListSKUsByResourcePager func(resourceGroupName string, clusterName string, options *armkusto.ClustersClientListSKUsByResourceOptions) (resp azfake.PagerResponder[armkusto.ClustersClientListSKUsByResourceResponse]) + + // BeginMigrate is the fake for method ClustersClient.BeginMigrate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginMigrate func(ctx context.Context, resourceGroupName string, clusterName string, clusterMigrateRequest armkusto.ClusterMigrateRequest, options *armkusto.ClustersClientBeginMigrateOptions) (resp azfake.PollerResponder[armkusto.ClustersClientMigrateResponse], errResp azfake.ErrorResponder) + + // BeginRemoveLanguageExtensions is the fake for method ClustersClient.BeginRemoveLanguageExtensions + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginRemoveLanguageExtensions func(ctx context.Context, resourceGroupName string, clusterName string, languageExtensionsToRemove armkusto.LanguageExtensionsList, options *armkusto.ClustersClientBeginRemoveLanguageExtensionsOptions) (resp azfake.PollerResponder[armkusto.ClustersClientRemoveLanguageExtensionsResponse], errResp azfake.ErrorResponder) + + // BeginStart is the fake for method ClustersClient.BeginStart + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginStart func(ctx context.Context, resourceGroupName string, clusterName string, options *armkusto.ClustersClientBeginStartOptions) (resp azfake.PollerResponder[armkusto.ClustersClientStartResponse], errResp azfake.ErrorResponder) + + // BeginStop is the fake for method ClustersClient.BeginStop + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginStop func(ctx context.Context, resourceGroupName string, clusterName string, options *armkusto.ClustersClientBeginStopOptions) (resp azfake.PollerResponder[armkusto.ClustersClientStopResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method ClustersClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, clusterName string, parameters armkusto.ClusterUpdate, options *armkusto.ClustersClientBeginUpdateOptions) (resp azfake.PollerResponder[armkusto.ClustersClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewClustersServerTransport creates a new instance of ClustersServerTransport with the provided implementation. +// The returned ClustersServerTransport instance is connected to an instance of armkusto.ClustersClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewClustersServerTransport(srv *ClustersServer) *ClustersServerTransport { + return &ClustersServerTransport{ + srv: srv, + beginAddLanguageExtensions: newTracker[azfake.PollerResponder[armkusto.ClustersClientAddLanguageExtensionsResponse]](), + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armkusto.ClustersClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armkusto.ClustersClientDeleteResponse]](), + beginDetachFollowerDatabases: newTracker[azfake.PollerResponder[armkusto.ClustersClientDetachFollowerDatabasesResponse]](), + beginDiagnoseVirtualNetwork: newTracker[azfake.PollerResponder[armkusto.ClustersClientDiagnoseVirtualNetworkResponse]](), + newListPager: newTracker[azfake.PagerResponder[armkusto.ClustersClientListResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armkusto.ClustersClientListByResourceGroupResponse]](), + newListFollowerDatabasesPager: newTracker[azfake.PagerResponder[armkusto.ClustersClientListFollowerDatabasesResponse]](), + newListLanguageExtensionsPager: newTracker[azfake.PagerResponder[armkusto.ClustersClientListLanguageExtensionsResponse]](), + newListOutboundNetworkDependenciesEndpointsPager: newTracker[azfake.PagerResponder[armkusto.ClustersClientListOutboundNetworkDependenciesEndpointsResponse]](), + newListSKUsPager: newTracker[azfake.PagerResponder[armkusto.ClustersClientListSKUsResponse]](), + newListSKUsByResourcePager: newTracker[azfake.PagerResponder[armkusto.ClustersClientListSKUsByResourceResponse]](), + beginMigrate: newTracker[azfake.PollerResponder[armkusto.ClustersClientMigrateResponse]](), + beginRemoveLanguageExtensions: newTracker[azfake.PollerResponder[armkusto.ClustersClientRemoveLanguageExtensionsResponse]](), + beginStart: newTracker[azfake.PollerResponder[armkusto.ClustersClientStartResponse]](), + beginStop: newTracker[azfake.PollerResponder[armkusto.ClustersClientStopResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armkusto.ClustersClientUpdateResponse]](), + } +} + +// ClustersServerTransport connects instances of armkusto.ClustersClient to instances of ClustersServer. +// Don't use this type directly, use NewClustersServerTransport instead. +type ClustersServerTransport struct { + srv *ClustersServer + beginAddLanguageExtensions *tracker[azfake.PollerResponder[armkusto.ClustersClientAddLanguageExtensionsResponse]] + beginCreateOrUpdate *tracker[azfake.PollerResponder[armkusto.ClustersClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armkusto.ClustersClientDeleteResponse]] + beginDetachFollowerDatabases *tracker[azfake.PollerResponder[armkusto.ClustersClientDetachFollowerDatabasesResponse]] + beginDiagnoseVirtualNetwork *tracker[azfake.PollerResponder[armkusto.ClustersClientDiagnoseVirtualNetworkResponse]] + newListPager *tracker[azfake.PagerResponder[armkusto.ClustersClientListResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armkusto.ClustersClientListByResourceGroupResponse]] + newListFollowerDatabasesPager *tracker[azfake.PagerResponder[armkusto.ClustersClientListFollowerDatabasesResponse]] + newListLanguageExtensionsPager *tracker[azfake.PagerResponder[armkusto.ClustersClientListLanguageExtensionsResponse]] + newListOutboundNetworkDependenciesEndpointsPager *tracker[azfake.PagerResponder[armkusto.ClustersClientListOutboundNetworkDependenciesEndpointsResponse]] + newListSKUsPager *tracker[azfake.PagerResponder[armkusto.ClustersClientListSKUsResponse]] + newListSKUsByResourcePager *tracker[azfake.PagerResponder[armkusto.ClustersClientListSKUsByResourceResponse]] + beginMigrate *tracker[azfake.PollerResponder[armkusto.ClustersClientMigrateResponse]] + beginRemoveLanguageExtensions *tracker[azfake.PollerResponder[armkusto.ClustersClientRemoveLanguageExtensionsResponse]] + beginStart *tracker[azfake.PollerResponder[armkusto.ClustersClientStartResponse]] + beginStop *tracker[azfake.PollerResponder[armkusto.ClustersClientStopResponse]] + beginUpdate *tracker[azfake.PollerResponder[armkusto.ClustersClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for ClustersServerTransport. +func (c *ClustersServerTransport) 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 "ClustersClient.BeginAddLanguageExtensions": + resp, err = c.dispatchBeginAddLanguageExtensions(req) + case "ClustersClient.CheckNameAvailability": + resp, err = c.dispatchCheckNameAvailability(req) + case "ClustersClient.BeginCreateOrUpdate": + resp, err = c.dispatchBeginCreateOrUpdate(req) + case "ClustersClient.BeginDelete": + resp, err = c.dispatchBeginDelete(req) + case "ClustersClient.BeginDetachFollowerDatabases": + resp, err = c.dispatchBeginDetachFollowerDatabases(req) + case "ClustersClient.BeginDiagnoseVirtualNetwork": + resp, err = c.dispatchBeginDiagnoseVirtualNetwork(req) + case "ClustersClient.Get": + resp, err = c.dispatchGet(req) + case "ClustersClient.NewListPager": + resp, err = c.dispatchNewListPager(req) + case "ClustersClient.NewListByResourceGroupPager": + resp, err = c.dispatchNewListByResourceGroupPager(req) + case "ClustersClient.NewListFollowerDatabasesPager": + resp, err = c.dispatchNewListFollowerDatabasesPager(req) + case "ClustersClient.NewListLanguageExtensionsPager": + resp, err = c.dispatchNewListLanguageExtensionsPager(req) + case "ClustersClient.NewListOutboundNetworkDependenciesEndpointsPager": + resp, err = c.dispatchNewListOutboundNetworkDependenciesEndpointsPager(req) + case "ClustersClient.NewListSKUsPager": + resp, err = c.dispatchNewListSKUsPager(req) + case "ClustersClient.NewListSKUsByResourcePager": + resp, err = c.dispatchNewListSKUsByResourcePager(req) + case "ClustersClient.BeginMigrate": + resp, err = c.dispatchBeginMigrate(req) + case "ClustersClient.BeginRemoveLanguageExtensions": + resp, err = c.dispatchBeginRemoveLanguageExtensions(req) + case "ClustersClient.BeginStart": + resp, err = c.dispatchBeginStart(req) + case "ClustersClient.BeginStop": + resp, err = c.dispatchBeginStop(req) + case "ClustersClient.BeginUpdate": + resp, err = c.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (c *ClustersServerTransport) dispatchBeginAddLanguageExtensions(req *http.Request) (*http.Response, error) { + if c.srv.BeginAddLanguageExtensions == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginAddLanguageExtensions not implemented")} + } + beginAddLanguageExtensions := c.beginAddLanguageExtensions.get(req) + if beginAddLanguageExtensions == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/addLanguageExtensions` + 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[armkusto.LanguageExtensionsList](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginAddLanguageExtensions(req.Context(), resourceGroupNameParam, clusterNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginAddLanguageExtensions = &respr + c.beginAddLanguageExtensions.add(req, beginAddLanguageExtensions) + } + + resp, err := server.PollerResponderNext(beginAddLanguageExtensions, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + c.beginAddLanguageExtensions.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginAddLanguageExtensions) { + c.beginAddLanguageExtensions.remove(req) + } + + return resp, nil +} + +func (c *ClustersServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if c.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkNameAvailability` + 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) + } + body, err := server.UnmarshalRequestAsJSON[armkusto.ClusterCheckNameRequest](req) + if err != nil { + return nil, err + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.CheckNameAvailability(req.Context(), locationParam, 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).CheckNameResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *ClustersServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if c.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := c.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?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[armkusto.Cluster](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + ifNoneMatchParam := getOptional(getHeaderValue(req.Header, "If-None-Match")) + var options *armkusto.ClustersClientBeginCreateOrUpdateOptions + if ifMatchParam != nil || ifNoneMatchParam != nil { + options = &armkusto.ClustersClientBeginCreateOrUpdateOptions{ + IfMatch: ifMatchParam, + IfNoneMatch: ifNoneMatchParam, + } + } + respr, errRespr := c.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, clusterNameParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + c.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) { + c.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) { + c.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (c *ClustersServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if c.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := c.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginDelete(req.Context(), resourceGroupNameParam, clusterNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + c.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) { + c.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) { + c.beginDelete.remove(req) + } + + return resp, nil +} + +func (c *ClustersServerTransport) dispatchBeginDetachFollowerDatabases(req *http.Request) (*http.Response, error) { + if c.srv.BeginDetachFollowerDatabases == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDetachFollowerDatabases not implemented")} + } + beginDetachFollowerDatabases := c.beginDetachFollowerDatabases.get(req) + if beginDetachFollowerDatabases == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/detachFollowerDatabases` + 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[armkusto.FollowerDatabaseDefinition](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginDetachFollowerDatabases(req.Context(), resourceGroupNameParam, clusterNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDetachFollowerDatabases = &respr + c.beginDetachFollowerDatabases.add(req, beginDetachFollowerDatabases) + } + + resp, err := server.PollerResponderNext(beginDetachFollowerDatabases, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + c.beginDetachFollowerDatabases.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDetachFollowerDatabases) { + c.beginDetachFollowerDatabases.remove(req) + } + + return resp, nil +} + +func (c *ClustersServerTransport) dispatchBeginDiagnoseVirtualNetwork(req *http.Request) (*http.Response, error) { + if c.srv.BeginDiagnoseVirtualNetwork == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDiagnoseVirtualNetwork not implemented")} + } + beginDiagnoseVirtualNetwork := c.beginDiagnoseVirtualNetwork.get(req) + if beginDiagnoseVirtualNetwork == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/diagnoseVirtualNetwork` + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginDiagnoseVirtualNetwork(req.Context(), resourceGroupNameParam, clusterNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDiagnoseVirtualNetwork = &respr + c.beginDiagnoseVirtualNetwork.add(req, beginDiagnoseVirtualNetwork) + } + + resp, err := server.PollerResponderNext(beginDiagnoseVirtualNetwork, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + c.beginDiagnoseVirtualNetwork.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDiagnoseVirtualNetwork) { + c.beginDiagnoseVirtualNetwork.remove(req) + } + + return resp, nil +} + +func (c *ClustersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if c.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\.Kusto/clusters/(?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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.Get(req.Context(), resourceGroupNameParam, clusterNameParam, 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).Cluster, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (c *ClustersServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := c.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters` + 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 := c.srv.NewListPager(nil) + newListPager = &resp + c.newListPager.add(req, newListPager) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + c.newListPager.remove(req) + } + return resp, nil +} + +func (c *ClustersServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := c.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters` + 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 := c.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + c.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + c.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (c *ClustersServerTransport) dispatchNewListFollowerDatabasesPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListFollowerDatabasesPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListFollowerDatabasesPager not implemented")} + } + newListFollowerDatabasesPager := c.newListFollowerDatabasesPager.get(req) + if newListFollowerDatabasesPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listFollowerDatabases` + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + resp := c.srv.NewListFollowerDatabasesPager(resourceGroupNameParam, clusterNameParam, nil) + newListFollowerDatabasesPager = &resp + c.newListFollowerDatabasesPager.add(req, newListFollowerDatabasesPager) + } + resp, err := server.PagerResponderNext(newListFollowerDatabasesPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListFollowerDatabasesPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListFollowerDatabasesPager) { + c.newListFollowerDatabasesPager.remove(req) + } + return resp, nil +} + +func (c *ClustersServerTransport) dispatchNewListLanguageExtensionsPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListLanguageExtensionsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListLanguageExtensionsPager not implemented")} + } + newListLanguageExtensionsPager := c.newListLanguageExtensionsPager.get(req) + if newListLanguageExtensionsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listLanguageExtensions` + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + resp := c.srv.NewListLanguageExtensionsPager(resourceGroupNameParam, clusterNameParam, nil) + newListLanguageExtensionsPager = &resp + c.newListLanguageExtensionsPager.add(req, newListLanguageExtensionsPager) + } + resp, err := server.PagerResponderNext(newListLanguageExtensionsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListLanguageExtensionsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListLanguageExtensionsPager) { + c.newListLanguageExtensionsPager.remove(req) + } + return resp, nil +} + +func (c *ClustersServerTransport) dispatchNewListOutboundNetworkDependenciesEndpointsPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListOutboundNetworkDependenciesEndpointsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListOutboundNetworkDependenciesEndpointsPager not implemented")} + } + newListOutboundNetworkDependenciesEndpointsPager := c.newListOutboundNetworkDependenciesEndpointsPager.get(req) + if newListOutboundNetworkDependenciesEndpointsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + resp := c.srv.NewListOutboundNetworkDependenciesEndpointsPager(resourceGroupNameParam, clusterNameParam, nil) + newListOutboundNetworkDependenciesEndpointsPager = &resp + c.newListOutboundNetworkDependenciesEndpointsPager.add(req, newListOutboundNetworkDependenciesEndpointsPager) + server.PagerResponderInjectNextLinks(newListOutboundNetworkDependenciesEndpointsPager, req, func(page *armkusto.ClustersClientListOutboundNetworkDependenciesEndpointsResponse, 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) { + c.newListOutboundNetworkDependenciesEndpointsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListOutboundNetworkDependenciesEndpointsPager) { + c.newListOutboundNetworkDependenciesEndpointsPager.remove(req) + } + return resp, nil +} + +func (c *ClustersServerTransport) dispatchNewListSKUsPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListSKUsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListSKUsPager not implemented")} + } + newListSKUsPager := c.newListSKUsPager.get(req) + if newListSKUsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/skus` + 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 := c.srv.NewListSKUsPager(nil) + newListSKUsPager = &resp + c.newListSKUsPager.add(req, newListSKUsPager) + } + resp, err := server.PagerResponderNext(newListSKUsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListSKUsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListSKUsPager) { + c.newListSKUsPager.remove(req) + } + return resp, nil +} + +func (c *ClustersServerTransport) dispatchNewListSKUsByResourcePager(req *http.Request) (*http.Response, error) { + if c.srv.NewListSKUsByResourcePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListSKUsByResourcePager not implemented")} + } + newListSKUsByResourcePager := c.newListSKUsByResourcePager.get(req) + if newListSKUsByResourcePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/skus` + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + resp := c.srv.NewListSKUsByResourcePager(resourceGroupNameParam, clusterNameParam, nil) + newListSKUsByResourcePager = &resp + c.newListSKUsByResourcePager.add(req, newListSKUsByResourcePager) + } + resp, err := server.PagerResponderNext(newListSKUsByResourcePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListSKUsByResourcePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListSKUsByResourcePager) { + c.newListSKUsByResourcePager.remove(req) + } + return resp, nil +} + +func (c *ClustersServerTransport) dispatchBeginMigrate(req *http.Request) (*http.Response, error) { + if c.srv.BeginMigrate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginMigrate not implemented")} + } + beginMigrate := c.beginMigrate.get(req) + if beginMigrate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/migrate` + 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[armkusto.ClusterMigrateRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginMigrate(req.Context(), resourceGroupNameParam, clusterNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginMigrate = &respr + c.beginMigrate.add(req, beginMigrate) + } + + resp, err := server.PollerResponderNext(beginMigrate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + c.beginMigrate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginMigrate) { + c.beginMigrate.remove(req) + } + + return resp, nil +} + +func (c *ClustersServerTransport) dispatchBeginRemoveLanguageExtensions(req *http.Request) (*http.Response, error) { + if c.srv.BeginRemoveLanguageExtensions == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginRemoveLanguageExtensions not implemented")} + } + beginRemoveLanguageExtensions := c.beginRemoveLanguageExtensions.get(req) + if beginRemoveLanguageExtensions == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/removeLanguageExtensions` + 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[armkusto.LanguageExtensionsList](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginRemoveLanguageExtensions(req.Context(), resourceGroupNameParam, clusterNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginRemoveLanguageExtensions = &respr + c.beginRemoveLanguageExtensions.add(req, beginRemoveLanguageExtensions) + } + + resp, err := server.PollerResponderNext(beginRemoveLanguageExtensions, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + c.beginRemoveLanguageExtensions.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginRemoveLanguageExtensions) { + c.beginRemoveLanguageExtensions.remove(req) + } + + return resp, nil +} + +func (c *ClustersServerTransport) dispatchBeginStart(req *http.Request) (*http.Response, error) { + if c.srv.BeginStart == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginStart not implemented")} + } + beginStart := c.beginStart.get(req) + if beginStart == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/start` + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginStart(req.Context(), resourceGroupNameParam, clusterNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginStart = &respr + c.beginStart.add(req, beginStart) + } + + resp, err := server.PollerResponderNext(beginStart, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + c.beginStart.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginStart) { + c.beginStart.remove(req) + } + + return resp, nil +} + +func (c *ClustersServerTransport) dispatchBeginStop(req *http.Request) (*http.Response, error) { + if c.srv.BeginStop == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginStop not implemented")} + } + beginStop := c.beginStop.get(req) + if beginStop == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/stop` + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + respr, errRespr := c.srv.BeginStop(req.Context(), resourceGroupNameParam, clusterNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginStop = &respr + c.beginStop.add(req, beginStop) + } + + resp, err := server.PollerResponderNext(beginStop, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + c.beginStop.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginStop) { + c.beginStop.remove(req) + } + + return resp, nil +} + +func (c *ClustersServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if c.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := c.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?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[armkusto.ClusterUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + ifMatchParam := getOptional(getHeaderValue(req.Header, "If-Match")) + var options *armkusto.ClustersClientBeginUpdateOptions + if ifMatchParam != nil { + options = &armkusto.ClustersClientBeginUpdateOptions{ + IfMatch: ifMatchParam, + } + } + respr, errRespr := c.srv.BeginUpdate(req.Context(), resourceGroupNameParam, clusterNameParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + c.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + c.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + c.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/kusto/armkusto/fake/database_server.go b/sdk/resourcemanager/kusto/armkusto/fake/database_server.go new file mode 100644 index 000000000000..2bcb8d6ebb2d --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/database_server.go @@ -0,0 +1,108 @@ +//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/resourcemanager/kusto/armkusto/v2" + "net/http" + "net/url" + "regexp" +) + +// DatabaseServer is a fake server for instances of the armkusto.DatabaseClient type. +type DatabaseServer struct { + // InviteFollower is the fake for method DatabaseClient.InviteFollower + // HTTP status codes to indicate success: http.StatusOK + InviteFollower func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters armkusto.DatabaseInviteFollowerRequest, options *armkusto.DatabaseClientInviteFollowerOptions) (resp azfake.Responder[armkusto.DatabaseClientInviteFollowerResponse], errResp azfake.ErrorResponder) +} + +// NewDatabaseServerTransport creates a new instance of DatabaseServerTransport with the provided implementation. +// The returned DatabaseServerTransport instance is connected to an instance of armkusto.DatabaseClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDatabaseServerTransport(srv *DatabaseServer) *DatabaseServerTransport { + return &DatabaseServerTransport{srv: srv} +} + +// DatabaseServerTransport connects instances of armkusto.DatabaseClient to instances of DatabaseServer. +// Don't use this type directly, use NewDatabaseServerTransport instead. +type DatabaseServerTransport struct { + srv *DatabaseServer +} + +// Do implements the policy.Transporter interface for DatabaseServerTransport. +func (d *DatabaseServerTransport) 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 "DatabaseClient.InviteFollower": + resp, err = d.dispatchInviteFollower(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DatabaseServerTransport) dispatchInviteFollower(req *http.Request) (*http.Response, error) { + if d.srv.InviteFollower == nil { + return nil, &nonRetriableError{errors.New("fake for method InviteFollower not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/inviteFollower` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkusto.DatabaseInviteFollowerRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.InviteFollower(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, 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).DatabaseInviteFollowerResult, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/kusto/armkusto/fake/databaseprincipalassignments_server.go b/sdk/resourcemanager/kusto/armkusto/fake/databaseprincipalassignments_server.go new file mode 100644 index 000000000000..ba35a67df102 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/databaseprincipalassignments_server.go @@ -0,0 +1,331 @@ +//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/resourcemanager/kusto/armkusto/v2" + "net/http" + "net/url" + "regexp" +) + +// DatabasePrincipalAssignmentsServer is a fake server for instances of the armkusto.DatabasePrincipalAssignmentsClient type. +type DatabasePrincipalAssignmentsServer struct { + // CheckNameAvailability is the fake for method DatabasePrincipalAssignmentsClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName armkusto.DatabasePrincipalAssignmentCheckNameRequest, options *armkusto.DatabasePrincipalAssignmentsClientCheckNameAvailabilityOptions) (resp azfake.Responder[armkusto.DatabasePrincipalAssignmentsClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method DatabasePrincipalAssignmentsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName string, parameters armkusto.DatabasePrincipalAssignment, options *armkusto.DatabasePrincipalAssignmentsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armkusto.DatabasePrincipalAssignmentsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method DatabasePrincipalAssignmentsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName string, options *armkusto.DatabasePrincipalAssignmentsClientBeginDeleteOptions) (resp azfake.PollerResponder[armkusto.DatabasePrincipalAssignmentsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method DatabasePrincipalAssignmentsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, principalAssignmentName string, options *armkusto.DatabasePrincipalAssignmentsClientGetOptions) (resp azfake.Responder[armkusto.DatabasePrincipalAssignmentsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method DatabasePrincipalAssignmentsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, clusterName string, databaseName string, options *armkusto.DatabasePrincipalAssignmentsClientListOptions) (resp azfake.PagerResponder[armkusto.DatabasePrincipalAssignmentsClientListResponse]) +} + +// NewDatabasePrincipalAssignmentsServerTransport creates a new instance of DatabasePrincipalAssignmentsServerTransport with the provided implementation. +// The returned DatabasePrincipalAssignmentsServerTransport instance is connected to an instance of armkusto.DatabasePrincipalAssignmentsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDatabasePrincipalAssignmentsServerTransport(srv *DatabasePrincipalAssignmentsServer) *DatabasePrincipalAssignmentsServerTransport { + return &DatabasePrincipalAssignmentsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armkusto.DatabasePrincipalAssignmentsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armkusto.DatabasePrincipalAssignmentsClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armkusto.DatabasePrincipalAssignmentsClientListResponse]](), + } +} + +// DatabasePrincipalAssignmentsServerTransport connects instances of armkusto.DatabasePrincipalAssignmentsClient to instances of DatabasePrincipalAssignmentsServer. +// Don't use this type directly, use NewDatabasePrincipalAssignmentsServerTransport instead. +type DatabasePrincipalAssignmentsServerTransport struct { + srv *DatabasePrincipalAssignmentsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armkusto.DatabasePrincipalAssignmentsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armkusto.DatabasePrincipalAssignmentsClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armkusto.DatabasePrincipalAssignmentsClientListResponse]] +} + +// Do implements the policy.Transporter interface for DatabasePrincipalAssignmentsServerTransport. +func (d *DatabasePrincipalAssignmentsServerTransport) 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 "DatabasePrincipalAssignmentsClient.CheckNameAvailability": + resp, err = d.dispatchCheckNameAvailability(req) + case "DatabasePrincipalAssignmentsClient.BeginCreateOrUpdate": + resp, err = d.dispatchBeginCreateOrUpdate(req) + case "DatabasePrincipalAssignmentsClient.BeginDelete": + resp, err = d.dispatchBeginDelete(req) + case "DatabasePrincipalAssignmentsClient.Get": + resp, err = d.dispatchGet(req) + case "DatabasePrincipalAssignmentsClient.NewListPager": + resp, err = d.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DatabasePrincipalAssignmentsServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if d.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkPrincipalAssignmentNameAvailability` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkusto.DatabasePrincipalAssignmentCheckNameRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.CheckNameAvailability(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, 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).CheckNameResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DatabasePrincipalAssignmentsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if d.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := d.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/principalAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkusto.DatabasePrincipalAssignment](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + principalAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("principalAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, principalAssignmentNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + d.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) { + d.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) { + d.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (d *DatabasePrincipalAssignmentsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if d.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := d.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/principalAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + principalAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("principalAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginDelete(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, principalAssignmentNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + d.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) { + d.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) { + d.beginDelete.remove(req) + } + + return resp, nil +} + +func (d *DatabasePrincipalAssignmentsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.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\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/principalAssignments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + principalAssignmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("principalAssignmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Get(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, principalAssignmentNameParam, 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).DatabasePrincipalAssignment, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DatabasePrincipalAssignmentsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := d.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/principalAssignments` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + resp := d.srv.NewListPager(resourceGroupNameParam, clusterNameParam, databaseNameParam, nil) + newListPager = &resp + d.newListPager.add(req, newListPager) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + d.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/kusto/armkusto/fake/databases_server.go b/sdk/resourcemanager/kusto/armkusto/fake/databases_server.go new file mode 100644 index 000000000000..5b01bc6e3b61 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/databases_server.go @@ -0,0 +1,579 @@ +//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/kusto/armkusto/v2" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// DatabasesServer is a fake server for instances of the armkusto.DatabasesClient type. +type DatabasesServer struct { + // AddPrincipals is the fake for method DatabasesClient.AddPrincipals + // HTTP status codes to indicate success: http.StatusOK + AddPrincipals func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, databasePrincipalsToAdd armkusto.DatabasePrincipalListRequest, options *armkusto.DatabasesClientAddPrincipalsOptions) (resp azfake.Responder[armkusto.DatabasesClientAddPrincipalsResponse], errResp azfake.ErrorResponder) + + // CheckNameAvailability is the fake for method DatabasesClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, resourceGroupName string, clusterName string, resourceName armkusto.CheckNameRequest, options *armkusto.DatabasesClientCheckNameAvailabilityOptions) (resp azfake.Responder[armkusto.DatabasesClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method DatabasesClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters armkusto.DatabaseClassification, options *armkusto.DatabasesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armkusto.DatabasesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method DatabasesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, options *armkusto.DatabasesClientBeginDeleteOptions) (resp azfake.PollerResponder[armkusto.DatabasesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method DatabasesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, options *armkusto.DatabasesClientGetOptions) (resp azfake.Responder[armkusto.DatabasesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByClusterPager is the fake for method DatabasesClient.NewListByClusterPager + // HTTP status codes to indicate success: http.StatusOK + NewListByClusterPager func(resourceGroupName string, clusterName string, options *armkusto.DatabasesClientListByClusterOptions) (resp azfake.PagerResponder[armkusto.DatabasesClientListByClusterResponse]) + + // NewListPrincipalsPager is the fake for method DatabasesClient.NewListPrincipalsPager + // HTTP status codes to indicate success: http.StatusOK + NewListPrincipalsPager func(resourceGroupName string, clusterName string, databaseName string, options *armkusto.DatabasesClientListPrincipalsOptions) (resp azfake.PagerResponder[armkusto.DatabasesClientListPrincipalsResponse]) + + // RemovePrincipals is the fake for method DatabasesClient.RemovePrincipals + // HTTP status codes to indicate success: http.StatusOK + RemovePrincipals func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, databasePrincipalsToRemove armkusto.DatabasePrincipalListRequest, options *armkusto.DatabasesClientRemovePrincipalsOptions) (resp azfake.Responder[armkusto.DatabasesClientRemovePrincipalsResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method DatabasesClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters armkusto.DatabaseClassification, options *armkusto.DatabasesClientBeginUpdateOptions) (resp azfake.PollerResponder[armkusto.DatabasesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewDatabasesServerTransport creates a new instance of DatabasesServerTransport with the provided implementation. +// The returned DatabasesServerTransport instance is connected to an instance of armkusto.DatabasesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDatabasesServerTransport(srv *DatabasesServer) *DatabasesServerTransport { + return &DatabasesServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armkusto.DatabasesClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armkusto.DatabasesClientDeleteResponse]](), + newListByClusterPager: newTracker[azfake.PagerResponder[armkusto.DatabasesClientListByClusterResponse]](), + newListPrincipalsPager: newTracker[azfake.PagerResponder[armkusto.DatabasesClientListPrincipalsResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armkusto.DatabasesClientUpdateResponse]](), + } +} + +// DatabasesServerTransport connects instances of armkusto.DatabasesClient to instances of DatabasesServer. +// Don't use this type directly, use NewDatabasesServerTransport instead. +type DatabasesServerTransport struct { + srv *DatabasesServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armkusto.DatabasesClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armkusto.DatabasesClientDeleteResponse]] + newListByClusterPager *tracker[azfake.PagerResponder[armkusto.DatabasesClientListByClusterResponse]] + newListPrincipalsPager *tracker[azfake.PagerResponder[armkusto.DatabasesClientListPrincipalsResponse]] + beginUpdate *tracker[azfake.PollerResponder[armkusto.DatabasesClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for DatabasesServerTransport. +func (d *DatabasesServerTransport) 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 "DatabasesClient.AddPrincipals": + resp, err = d.dispatchAddPrincipals(req) + case "DatabasesClient.CheckNameAvailability": + resp, err = d.dispatchCheckNameAvailability(req) + case "DatabasesClient.BeginCreateOrUpdate": + resp, err = d.dispatchBeginCreateOrUpdate(req) + case "DatabasesClient.BeginDelete": + resp, err = d.dispatchBeginDelete(req) + case "DatabasesClient.Get": + resp, err = d.dispatchGet(req) + case "DatabasesClient.NewListByClusterPager": + resp, err = d.dispatchNewListByClusterPager(req) + case "DatabasesClient.NewListPrincipalsPager": + resp, err = d.dispatchNewListPrincipalsPager(req) + case "DatabasesClient.RemovePrincipals": + resp, err = d.dispatchRemovePrincipals(req) + case "DatabasesClient.BeginUpdate": + resp, err = d.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DatabasesServerTransport) dispatchAddPrincipals(req *http.Request) (*http.Response, error) { + if d.srv.AddPrincipals == nil { + return nil, &nonRetriableError{errors.New("fake for method AddPrincipals not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/addPrincipals` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkusto.DatabasePrincipalListRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.AddPrincipals(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, 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).DatabasePrincipalListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DatabasesServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if d.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkNameAvailability` + 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[armkusto.CheckNameRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.CheckNameAvailability(req.Context(), resourceGroupNameParam, clusterNameParam, 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).CheckNameResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DatabasesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if d.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := d.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + raw, err := readRequestBody(req) + if err != nil { + return nil, err + } + body, err := unmarshalDatabaseClassification(raw) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + callerRoleUnescaped, err := url.QueryUnescape(qp.Get("callerRole")) + if err != nil { + return nil, err + } + callerRoleParam := getOptional(armkusto.CallerRole(callerRoleUnescaped)) + var options *armkusto.DatabasesClientBeginCreateOrUpdateOptions + if callerRoleParam != nil { + options = &armkusto.DatabasesClientBeginCreateOrUpdateOptions{ + CallerRole: callerRoleParam, + } + } + respr, errRespr := d.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + d.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + d.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + d.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (d *DatabasesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if d.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := d.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginDelete(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + d.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) { + d.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) { + d.beginDelete.remove(req) + } + + return resp, nil +} + +func (d *DatabasesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.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\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Get(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, 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).DatabaseClassification, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DatabasesServerTransport) dispatchNewListByClusterPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListByClusterPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByClusterPager not implemented")} + } + newListByClusterPager := d.newListByClusterPager.get(req) + if newListByClusterPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + skiptokenUnescaped, err := url.QueryUnescape(qp.Get("$skiptoken")) + if err != nil { + return nil, err + } + skiptokenParam := getOptional(skiptokenUnescaped) + var options *armkusto.DatabasesClientListByClusterOptions + if topParam != nil || skiptokenParam != nil { + options = &armkusto.DatabasesClientListByClusterOptions{ + Top: topParam, + Skiptoken: skiptokenParam, + } + } + resp := d.srv.NewListByClusterPager(resourceGroupNameParam, clusterNameParam, options) + newListByClusterPager = &resp + d.newListByClusterPager.add(req, newListByClusterPager) + server.PagerResponderInjectNextLinks(newListByClusterPager, req, func(page *armkusto.DatabasesClientListByClusterResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByClusterPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListByClusterPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByClusterPager) { + d.newListByClusterPager.remove(req) + } + return resp, nil +} + +func (d *DatabasesServerTransport) dispatchNewListPrincipalsPager(req *http.Request) (*http.Response, error) { + if d.srv.NewListPrincipalsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPrincipalsPager not implemented")} + } + newListPrincipalsPager := d.newListPrincipalsPager.get(req) + if newListPrincipalsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listPrincipals` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + resp := d.srv.NewListPrincipalsPager(resourceGroupNameParam, clusterNameParam, databaseNameParam, nil) + newListPrincipalsPager = &resp + d.newListPrincipalsPager.add(req, newListPrincipalsPager) + } + resp, err := server.PagerResponderNext(newListPrincipalsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListPrincipalsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPrincipalsPager) { + d.newListPrincipalsPager.remove(req) + } + return resp, nil +} + +func (d *DatabasesServerTransport) dispatchRemovePrincipals(req *http.Request) (*http.Response, error) { + if d.srv.RemovePrincipals == nil { + return nil, &nonRetriableError{errors.New("fake for method RemovePrincipals not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/removePrincipals` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkusto.DatabasePrincipalListRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.RemovePrincipals(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, 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).DatabasePrincipalListResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DatabasesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if d.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := d.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + raw, err := readRequestBody(req) + if err != nil { + return nil, err + } + body, err := unmarshalDatabaseClassification(raw) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + callerRoleUnescaped, err := url.QueryUnescape(qp.Get("callerRole")) + if err != nil { + return nil, err + } + callerRoleParam := getOptional(armkusto.CallerRole(callerRoleUnescaped)) + var options *armkusto.DatabasesClientBeginUpdateOptions + if callerRoleParam != nil { + options = &armkusto.DatabasesClientBeginUpdateOptions{ + CallerRole: callerRoleParam, + } + } + respr, errRespr := d.srv.BeginUpdate(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, body, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + d.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + d.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + d.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/kusto/armkusto/fake/dataconnections_server.go b/sdk/resourcemanager/kusto/armkusto/fake/dataconnections_server.go new file mode 100644 index 000000000000..00075e2f6afc --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/dataconnections_server.go @@ -0,0 +1,463 @@ +//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/resourcemanager/kusto/armkusto/v2" + "net/http" + "net/url" + "regexp" +) + +// DataConnectionsServer is a fake server for instances of the armkusto.DataConnectionsClient type. +type DataConnectionsServer struct { + // CheckNameAvailability is the fake for method DataConnectionsClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName armkusto.DataConnectionCheckNameRequest, options *armkusto.DataConnectionsClientCheckNameAvailabilityOptions) (resp azfake.Responder[armkusto.DataConnectionsClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method DataConnectionsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, parameters armkusto.DataConnectionClassification, options *armkusto.DataConnectionsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armkusto.DataConnectionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDataConnectionValidation is the fake for method DataConnectionsClient.BeginDataConnectionValidation + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginDataConnectionValidation func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, parameters armkusto.DataConnectionValidation, options *armkusto.DataConnectionsClientBeginDataConnectionValidationOptions) (resp azfake.PollerResponder[armkusto.DataConnectionsClientDataConnectionValidationResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method DataConnectionsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, options *armkusto.DataConnectionsClientBeginDeleteOptions) (resp azfake.PollerResponder[armkusto.DataConnectionsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method DataConnectionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, options *armkusto.DataConnectionsClientGetOptions) (resp azfake.Responder[armkusto.DataConnectionsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByDatabasePager is the fake for method DataConnectionsClient.NewListByDatabasePager + // HTTP status codes to indicate success: http.StatusOK + NewListByDatabasePager func(resourceGroupName string, clusterName string, databaseName string, options *armkusto.DataConnectionsClientListByDatabaseOptions) (resp azfake.PagerResponder[armkusto.DataConnectionsClientListByDatabaseResponse]) + + // BeginUpdate is the fake for method DataConnectionsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, dataConnectionName string, parameters armkusto.DataConnectionClassification, options *armkusto.DataConnectionsClientBeginUpdateOptions) (resp azfake.PollerResponder[armkusto.DataConnectionsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewDataConnectionsServerTransport creates a new instance of DataConnectionsServerTransport with the provided implementation. +// The returned DataConnectionsServerTransport instance is connected to an instance of armkusto.DataConnectionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewDataConnectionsServerTransport(srv *DataConnectionsServer) *DataConnectionsServerTransport { + return &DataConnectionsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armkusto.DataConnectionsClientCreateOrUpdateResponse]](), + beginDataConnectionValidation: newTracker[azfake.PollerResponder[armkusto.DataConnectionsClientDataConnectionValidationResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armkusto.DataConnectionsClientDeleteResponse]](), + newListByDatabasePager: newTracker[azfake.PagerResponder[armkusto.DataConnectionsClientListByDatabaseResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armkusto.DataConnectionsClientUpdateResponse]](), + } +} + +// DataConnectionsServerTransport connects instances of armkusto.DataConnectionsClient to instances of DataConnectionsServer. +// Don't use this type directly, use NewDataConnectionsServerTransport instead. +type DataConnectionsServerTransport struct { + srv *DataConnectionsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armkusto.DataConnectionsClientCreateOrUpdateResponse]] + beginDataConnectionValidation *tracker[azfake.PollerResponder[armkusto.DataConnectionsClientDataConnectionValidationResponse]] + beginDelete *tracker[azfake.PollerResponder[armkusto.DataConnectionsClientDeleteResponse]] + newListByDatabasePager *tracker[azfake.PagerResponder[armkusto.DataConnectionsClientListByDatabaseResponse]] + beginUpdate *tracker[azfake.PollerResponder[armkusto.DataConnectionsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for DataConnectionsServerTransport. +func (d *DataConnectionsServerTransport) 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 "DataConnectionsClient.CheckNameAvailability": + resp, err = d.dispatchCheckNameAvailability(req) + case "DataConnectionsClient.BeginCreateOrUpdate": + resp, err = d.dispatchBeginCreateOrUpdate(req) + case "DataConnectionsClient.BeginDataConnectionValidation": + resp, err = d.dispatchBeginDataConnectionValidation(req) + case "DataConnectionsClient.BeginDelete": + resp, err = d.dispatchBeginDelete(req) + case "DataConnectionsClient.Get": + resp, err = d.dispatchGet(req) + case "DataConnectionsClient.NewListByDatabasePager": + resp, err = d.dispatchNewListByDatabasePager(req) + case "DataConnectionsClient.BeginUpdate": + resp, err = d.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (d *DataConnectionsServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if d.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/checkNameAvailability` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkusto.DataConnectionCheckNameRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.CheckNameAvailability(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, 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).CheckNameResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DataConnectionsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if d.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := d.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/dataConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + raw, err := readRequestBody(req) + if err != nil { + return nil, err + } + body, err := unmarshalDataConnectionClassification(raw) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + dataConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, dataConnectionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + d.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + d.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + d.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (d *DataConnectionsServerTransport) dispatchBeginDataConnectionValidation(req *http.Request) (*http.Response, error) { + if d.srv.BeginDataConnectionValidation == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDataConnectionValidation not implemented")} + } + beginDataConnectionValidation := d.beginDataConnectionValidation.get(req) + if beginDataConnectionValidation == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/dataConnectionValidation` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkusto.DataConnectionValidation](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginDataConnectionValidation(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDataConnectionValidation = &respr + d.beginDataConnectionValidation.add(req, beginDataConnectionValidation) + } + + resp, err := server.PollerResponderNext(beginDataConnectionValidation, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + d.beginDataConnectionValidation.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDataConnectionValidation) { + d.beginDataConnectionValidation.remove(req) + } + + return resp, nil +} + +func (d *DataConnectionsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if d.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := d.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/dataConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + dataConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginDelete(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, dataConnectionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + d.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) { + d.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) { + d.beginDelete.remove(req) + } + + return resp, nil +} + +func (d *DataConnectionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if d.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\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/dataConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + dataConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.Get(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, dataConnectionNameParam, 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).DataConnectionClassification, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (d *DataConnectionsServerTransport) dispatchNewListByDatabasePager(req *http.Request) (*http.Response, error) { + if d.srv.NewListByDatabasePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByDatabasePager not implemented")} + } + newListByDatabasePager := d.newListByDatabasePager.get(req) + if newListByDatabasePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/dataConnections` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + resp := d.srv.NewListByDatabasePager(resourceGroupNameParam, clusterNameParam, databaseNameParam, nil) + newListByDatabasePager = &resp + d.newListByDatabasePager.add(req, newListByDatabasePager) + } + resp, err := server.PagerResponderNext(newListByDatabasePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + d.newListByDatabasePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByDatabasePager) { + d.newListByDatabasePager.remove(req) + } + return resp, nil +} + +func (d *DataConnectionsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if d.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := d.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/dataConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + raw, err := readRequestBody(req) + if err != nil { + return nil, err + } + body, err := unmarshalDataConnectionClassification(raw) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + dataConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("dataConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := d.srv.BeginUpdate(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, dataConnectionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + d.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + d.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + d.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/kusto/armkusto/fake/internal.go b/sdk/resourcemanager/kusto/armkusto/fake/internal.go new file mode 100644 index 000000000000..e0173df3faef --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/internal.go @@ -0,0 +1,104 @@ +//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 ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "io" + "net/http" + "reflect" + "sync" +) + +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 getHeaderValue(h http.Header, k string) string { + v := h[k] + if len(v) == 0 { + return "" + } + return v[0] +} + +func getOptional[T any](v T) *T { + if reflect.ValueOf(v).IsZero() { + return nil + } + return &v +} + +func parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) { + if v == "" { + return nil, nil + } + t, err := parse(v) + if err != nil { + return nil, err + } + return &t, err +} + +func readRequestBody(req *http.Request) ([]byte, error) { + if req.Body == nil { + return nil, nil + } + body, err := io.ReadAll(req.Body) + if err != nil { + return nil, err + } + req.Body.Close() + return body, nil +} + +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/kusto/armkusto/fake/managedprivateendpoints_server.go b/sdk/resourcemanager/kusto/armkusto/fake/managedprivateendpoints_server.go new file mode 100644 index 000000000000..f5cfeb956167 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/managedprivateendpoints_server.go @@ -0,0 +1,371 @@ +//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/resourcemanager/kusto/armkusto/v2" + "net/http" + "net/url" + "regexp" +) + +// ManagedPrivateEndpointsServer is a fake server for instances of the armkusto.ManagedPrivateEndpointsClient type. +type ManagedPrivateEndpointsServer struct { + // CheckNameAvailability is the fake for method ManagedPrivateEndpointsClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, resourceGroupName string, clusterName string, resourceName armkusto.ManagedPrivateEndpointsCheckNameRequest, options *armkusto.ManagedPrivateEndpointsClientCheckNameAvailabilityOptions) (resp azfake.Responder[armkusto.ManagedPrivateEndpointsClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method ManagedPrivateEndpointsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, parameters armkusto.ManagedPrivateEndpoint, options *armkusto.ManagedPrivateEndpointsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armkusto.ManagedPrivateEndpointsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method ManagedPrivateEndpointsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, options *armkusto.ManagedPrivateEndpointsClientBeginDeleteOptions) (resp azfake.PollerResponder[armkusto.ManagedPrivateEndpointsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ManagedPrivateEndpointsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, options *armkusto.ManagedPrivateEndpointsClientGetOptions) (resp azfake.Responder[armkusto.ManagedPrivateEndpointsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method ManagedPrivateEndpointsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, clusterName string, options *armkusto.ManagedPrivateEndpointsClientListOptions) (resp azfake.PagerResponder[armkusto.ManagedPrivateEndpointsClientListResponse]) + + // BeginUpdate is the fake for method ManagedPrivateEndpointsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, parameters armkusto.ManagedPrivateEndpoint, options *armkusto.ManagedPrivateEndpointsClientBeginUpdateOptions) (resp azfake.PollerResponder[armkusto.ManagedPrivateEndpointsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewManagedPrivateEndpointsServerTransport creates a new instance of ManagedPrivateEndpointsServerTransport with the provided implementation. +// The returned ManagedPrivateEndpointsServerTransport instance is connected to an instance of armkusto.ManagedPrivateEndpointsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewManagedPrivateEndpointsServerTransport(srv *ManagedPrivateEndpointsServer) *ManagedPrivateEndpointsServerTransport { + return &ManagedPrivateEndpointsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armkusto.ManagedPrivateEndpointsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armkusto.ManagedPrivateEndpointsClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armkusto.ManagedPrivateEndpointsClientListResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armkusto.ManagedPrivateEndpointsClientUpdateResponse]](), + } +} + +// ManagedPrivateEndpointsServerTransport connects instances of armkusto.ManagedPrivateEndpointsClient to instances of ManagedPrivateEndpointsServer. +// Don't use this type directly, use NewManagedPrivateEndpointsServerTransport instead. +type ManagedPrivateEndpointsServerTransport struct { + srv *ManagedPrivateEndpointsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armkusto.ManagedPrivateEndpointsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armkusto.ManagedPrivateEndpointsClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armkusto.ManagedPrivateEndpointsClientListResponse]] + beginUpdate *tracker[azfake.PollerResponder[armkusto.ManagedPrivateEndpointsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for ManagedPrivateEndpointsServerTransport. +func (m *ManagedPrivateEndpointsServerTransport) 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 "ManagedPrivateEndpointsClient.CheckNameAvailability": + resp, err = m.dispatchCheckNameAvailability(req) + case "ManagedPrivateEndpointsClient.BeginCreateOrUpdate": + resp, err = m.dispatchBeginCreateOrUpdate(req) + case "ManagedPrivateEndpointsClient.BeginDelete": + resp, err = m.dispatchBeginDelete(req) + case "ManagedPrivateEndpointsClient.Get": + resp, err = m.dispatchGet(req) + case "ManagedPrivateEndpointsClient.NewListPager": + resp, err = m.dispatchNewListPager(req) + case "ManagedPrivateEndpointsClient.BeginUpdate": + resp, err = m.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *ManagedPrivateEndpointsServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if m.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/managedPrivateEndpointsCheckNameAvailability` + 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[armkusto.ManagedPrivateEndpointsCheckNameRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.CheckNameAvailability(req.Context(), resourceGroupNameParam, clusterNameParam, 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).CheckNameResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (m *ManagedPrivateEndpointsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if m.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := m.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/managedPrivateEndpoints/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkusto.ManagedPrivateEndpoint](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + managedPrivateEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managedPrivateEndpointName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, clusterNameParam, managedPrivateEndpointNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + m.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + m.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + m.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (m *ManagedPrivateEndpointsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if m.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := m.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/managedPrivateEndpoints/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + managedPrivateEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managedPrivateEndpointName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.BeginDelete(req.Context(), resourceGroupNameParam, clusterNameParam, managedPrivateEndpointNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + m.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) { + m.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) { + m.beginDelete.remove(req) + } + + return resp, nil +} + +func (m *ManagedPrivateEndpointsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if m.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\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/managedPrivateEndpoints/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + managedPrivateEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managedPrivateEndpointName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.Get(req.Context(), resourceGroupNameParam, clusterNameParam, managedPrivateEndpointNameParam, 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).ManagedPrivateEndpoint, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (m *ManagedPrivateEndpointsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if m.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := m.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/managedPrivateEndpoints` + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + resp := m.srv.NewListPager(resourceGroupNameParam, clusterNameParam, nil) + newListPager = &resp + m.newListPager.add(req, newListPager) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + m.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + m.newListPager.remove(req) + } + return resp, nil +} + +func (m *ManagedPrivateEndpointsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if m.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := m.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/managedPrivateEndpoints/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkusto.ManagedPrivateEndpoint](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + managedPrivateEndpointNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("managedPrivateEndpointName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.BeginUpdate(req.Context(), resourceGroupNameParam, clusterNameParam, managedPrivateEndpointNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + m.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) { + m.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) { + m.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/kusto/armkusto/fake/operations_server.go b/sdk/resourcemanager/kusto/armkusto/fake/operations_server.go new file mode 100644 index 000000000000..7284c8f823ec --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/operations_server.go @@ -0,0 +1,96 @@ +//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 ( + "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/kusto/armkusto/v2" + "net/http" +) + +// OperationsServer is a fake server for instances of the armkusto.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armkusto.OperationsClientListOptions) (resp azfake.PagerResponder[armkusto.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armkusto.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[armkusto.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armkusto.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armkusto.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) 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 "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armkusto.OperationsClientListResponse, 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) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/kusto/armkusto/fake/operationsresults_server.go b/sdk/resourcemanager/kusto/armkusto/fake/operationsresults_server.go new file mode 100644 index 000000000000..f299f4919a21 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/operationsresults_server.go @@ -0,0 +1,100 @@ +//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/resourcemanager/kusto/armkusto/v2" + "net/http" + "net/url" + "regexp" +) + +// OperationsResultsServer is a fake server for instances of the armkusto.OperationsResultsClient type. +type OperationsResultsServer struct { + // Get is the fake for method OperationsResultsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, location string, operationID string, options *armkusto.OperationsResultsClientGetOptions) (resp azfake.Responder[armkusto.OperationsResultsClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewOperationsResultsServerTransport creates a new instance of OperationsResultsServerTransport with the provided implementation. +// The returned OperationsResultsServerTransport instance is connected to an instance of armkusto.OperationsResultsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsResultsServerTransport(srv *OperationsResultsServer) *OperationsResultsServerTransport { + return &OperationsResultsServerTransport{srv: srv} +} + +// OperationsResultsServerTransport connects instances of armkusto.OperationsResultsClient to instances of OperationsResultsServer. +// Don't use this type directly, use NewOperationsResultsServerTransport instead. +type OperationsResultsServerTransport struct { + srv *OperationsResultsServer +} + +// Do implements the policy.Transporter interface for OperationsResultsServerTransport. +func (o *OperationsResultsServerTransport) 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 "OperationsResultsClient.Get": + resp, err = o.dispatchGet(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsResultsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if o.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationResults/(?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 + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.Get(req.Context(), locationParam, operationIDParam, 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).OperationResult, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/kusto/armkusto/fake/operationsresultslocation_server.go b/sdk/resourcemanager/kusto/armkusto/fake/operationsresultslocation_server.go new file mode 100644 index 000000000000..dda158af420c --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/operationsresultslocation_server.go @@ -0,0 +1,103 @@ +//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/resourcemanager/kusto/armkusto/v2" + "net/http" + "net/url" + "regexp" +) + +// OperationsResultsLocationServer is a fake server for instances of the armkusto.OperationsResultsLocationClient type. +type OperationsResultsLocationServer struct { + // Get is the fake for method OperationsResultsLocationClient.Get + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + Get func(ctx context.Context, location string, operationID string, options *armkusto.OperationsResultsLocationClientGetOptions) (resp azfake.Responder[armkusto.OperationsResultsLocationClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewOperationsResultsLocationServerTransport creates a new instance of OperationsResultsLocationServerTransport with the provided implementation. +// The returned OperationsResultsLocationServerTransport instance is connected to an instance of armkusto.OperationsResultsLocationClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationsResultsLocationServerTransport(srv *OperationsResultsLocationServer) *OperationsResultsLocationServerTransport { + return &OperationsResultsLocationServerTransport{srv: srv} +} + +// OperationsResultsLocationServerTransport connects instances of armkusto.OperationsResultsLocationClient to instances of OperationsResultsLocationServer. +// Don't use this type directly, use NewOperationsResultsLocationServerTransport instead. +type OperationsResultsLocationServerTransport struct { + srv *OperationsResultsLocationServer +} + +// Do implements the policy.Transporter interface for OperationsResultsLocationServerTransport. +func (o *OperationsResultsLocationServerTransport) 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 "OperationsResultsLocationClient.Get": + resp, err = o.dispatchGet(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsResultsLocationServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if o.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operationResults/(?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 + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.Get(req.Context(), locationParam, operationIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusAccepted}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).AzureAsyncOperation; val != nil { + resp.Header.Set("Azure-AsyncOperation", *val) + } + return resp, nil +} diff --git a/sdk/resourcemanager/kusto/armkusto/fake/polymorphic_helpers.go b/sdk/resourcemanager/kusto/armkusto/fake/polymorphic_helpers.go new file mode 100644 index 000000000000..e53d680991aa --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/polymorphic_helpers.go @@ -0,0 +1,64 @@ +//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 ( + "encoding/json" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kusto/armkusto/v2" +) + +func unmarshalDataConnectionClassification(rawMsg json.RawMessage) (armkusto.DataConnectionClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b armkusto.DataConnectionClassification + switch m["kind"] { + case string(armkusto.DataConnectionKindCosmosDb): + b = &armkusto.CosmosDbDataConnection{} + case string(armkusto.DataConnectionKindEventGrid): + b = &armkusto.EventGridDataConnection{} + case string(armkusto.DataConnectionKindEventHub): + b = &armkusto.EventHubDataConnection{} + case string(armkusto.DataConnectionKindIotHub): + b = &armkusto.IotHubDataConnection{} + default: + b = &armkusto.DataConnection{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} + +func unmarshalDatabaseClassification(rawMsg json.RawMessage) (armkusto.DatabaseClassification, error) { + if rawMsg == nil { + return nil, nil + } + var m map[string]any + if err := json.Unmarshal(rawMsg, &m); err != nil { + return nil, err + } + var b armkusto.DatabaseClassification + switch m["kind"] { + case string(armkusto.KindReadOnlyFollowing): + b = &armkusto.ReadOnlyFollowingDatabase{} + case string(armkusto.KindReadWrite): + b = &armkusto.ReadWriteDatabase{} + default: + b = &armkusto.Database{} + } + if err := json.Unmarshal(rawMsg, b); err != nil { + return nil, err + } + return b, nil +} diff --git a/sdk/resourcemanager/kusto/armkusto/fake/privateendpointconnections_server.go b/sdk/resourcemanager/kusto/armkusto/fake/privateendpointconnections_server.go new file mode 100644 index 000000000000..628533f3f2c2 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/privateendpointconnections_server.go @@ -0,0 +1,268 @@ +//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/resourcemanager/kusto/armkusto/v2" + "net/http" + "net/url" + "regexp" +) + +// PrivateEndpointConnectionsServer is a fake server for instances of the armkusto.PrivateEndpointConnectionsClient type. +type PrivateEndpointConnectionsServer struct { + // BeginCreateOrUpdate is the fake for method PrivateEndpointConnectionsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string, parameters armkusto.PrivateEndpointConnection, options *armkusto.PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armkusto.PrivateEndpointConnectionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method PrivateEndpointConnectionsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string, options *armkusto.PrivateEndpointConnectionsClientBeginDeleteOptions) (resp azfake.PollerResponder[armkusto.PrivateEndpointConnectionsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method PrivateEndpointConnectionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string, options *armkusto.PrivateEndpointConnectionsClientGetOptions) (resp azfake.Responder[armkusto.PrivateEndpointConnectionsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method PrivateEndpointConnectionsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, clusterName string, options *armkusto.PrivateEndpointConnectionsClientListOptions) (resp azfake.PagerResponder[armkusto.PrivateEndpointConnectionsClientListResponse]) +} + +// NewPrivateEndpointConnectionsServerTransport creates a new instance of PrivateEndpointConnectionsServerTransport with the provided implementation. +// The returned PrivateEndpointConnectionsServerTransport instance is connected to an instance of armkusto.PrivateEndpointConnectionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPrivateEndpointConnectionsServerTransport(srv *PrivateEndpointConnectionsServer) *PrivateEndpointConnectionsServerTransport { + return &PrivateEndpointConnectionsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armkusto.PrivateEndpointConnectionsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armkusto.PrivateEndpointConnectionsClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armkusto.PrivateEndpointConnectionsClientListResponse]](), + } +} + +// PrivateEndpointConnectionsServerTransport connects instances of armkusto.PrivateEndpointConnectionsClient to instances of PrivateEndpointConnectionsServer. +// Don't use this type directly, use NewPrivateEndpointConnectionsServerTransport instead. +type PrivateEndpointConnectionsServerTransport struct { + srv *PrivateEndpointConnectionsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armkusto.PrivateEndpointConnectionsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armkusto.PrivateEndpointConnectionsClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armkusto.PrivateEndpointConnectionsClientListResponse]] +} + +// Do implements the policy.Transporter interface for PrivateEndpointConnectionsServerTransport. +func (p *PrivateEndpointConnectionsServerTransport) 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 "PrivateEndpointConnectionsClient.BeginCreateOrUpdate": + resp, err = p.dispatchBeginCreateOrUpdate(req) + case "PrivateEndpointConnectionsClient.BeginDelete": + resp, err = p.dispatchBeginDelete(req) + case "PrivateEndpointConnectionsClient.Get": + resp, err = p.dispatchGet(req) + case "PrivateEndpointConnectionsClient.NewListPager": + resp, err = p.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if p.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := p.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkusto.PrivateEndpointConnection](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, clusterNameParam, privateEndpointConnectionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + p.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) { + p.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) { + p.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if p.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := p.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.BeginDelete(req.Context(), resourceGroupNameParam, clusterNameParam, privateEndpointConnectionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + p.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) { + p.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) { + p.beginDelete.remove(req) + } + + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.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\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + privateEndpointConnectionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateEndpointConnectionName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, clusterNameParam, privateEndpointConnectionNameParam, 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).PrivateEndpointConnection, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PrivateEndpointConnectionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := p.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateEndpointConnections` + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListPager(resourceGroupNameParam, clusterNameParam, nil) + newListPager = &resp + p.newListPager.add(req, newListPager) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + p.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/kusto/armkusto/fake/privatelinkresources_server.go b/sdk/resourcemanager/kusto/armkusto/fake/privatelinkresources_server.go new file mode 100644 index 000000000000..18380c75e9e7 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/privatelinkresources_server.go @@ -0,0 +1,152 @@ +//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/resourcemanager/kusto/armkusto/v2" + "net/http" + "net/url" + "regexp" +) + +// PrivateLinkResourcesServer is a fake server for instances of the armkusto.PrivateLinkResourcesClient type. +type PrivateLinkResourcesServer struct { + // Get is the fake for method PrivateLinkResourcesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterName string, privateLinkResourceName string, options *armkusto.PrivateLinkResourcesClientGetOptions) (resp azfake.Responder[armkusto.PrivateLinkResourcesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method PrivateLinkResourcesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, clusterName string, options *armkusto.PrivateLinkResourcesClientListOptions) (resp azfake.PagerResponder[armkusto.PrivateLinkResourcesClientListResponse]) +} + +// NewPrivateLinkResourcesServerTransport creates a new instance of PrivateLinkResourcesServerTransport with the provided implementation. +// The returned PrivateLinkResourcesServerTransport instance is connected to an instance of armkusto.PrivateLinkResourcesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewPrivateLinkResourcesServerTransport(srv *PrivateLinkResourcesServer) *PrivateLinkResourcesServerTransport { + return &PrivateLinkResourcesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armkusto.PrivateLinkResourcesClientListResponse]](), + } +} + +// PrivateLinkResourcesServerTransport connects instances of armkusto.PrivateLinkResourcesClient to instances of PrivateLinkResourcesServer. +// Don't use this type directly, use NewPrivateLinkResourcesServerTransport instead. +type PrivateLinkResourcesServerTransport struct { + srv *PrivateLinkResourcesServer + newListPager *tracker[azfake.PagerResponder[armkusto.PrivateLinkResourcesClientListResponse]] +} + +// Do implements the policy.Transporter interface for PrivateLinkResourcesServerTransport. +func (p *PrivateLinkResourcesServerTransport) 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 "PrivateLinkResourcesClient.Get": + resp, err = p.dispatchGet(req) + case "PrivateLinkResourcesClient.NewListPager": + resp, err = p.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (p *PrivateLinkResourcesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if p.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\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + privateLinkResourceNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("privateLinkResourceName")]) + if err != nil { + return nil, err + } + respr, errRespr := p.srv.Get(req.Context(), resourceGroupNameParam, clusterNameParam, privateLinkResourceNameParam, 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).PrivateLinkResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (p *PrivateLinkResourcesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if p.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := p.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/privateLinkResources` + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + resp := p.srv.NewListPager(resourceGroupNameParam, clusterNameParam, nil) + newListPager = &resp + p.newListPager.add(req, newListPager) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + p.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + p.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/kusto/armkusto/fake/sandboxcustomimages_server.go b/sdk/resourcemanager/kusto/armkusto/fake/sandboxcustomimages_server.go new file mode 100644 index 000000000000..dd678410c958 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/sandboxcustomimages_server.go @@ -0,0 +1,371 @@ +//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/resourcemanager/kusto/armkusto/v2" + "net/http" + "net/url" + "regexp" +) + +// SandboxCustomImagesServer is a fake server for instances of the armkusto.SandboxCustomImagesClient type. +type SandboxCustomImagesServer struct { + // CheckNameAvailability is the fake for method SandboxCustomImagesClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, resourceGroupName string, clusterName string, resourceName armkusto.SandboxCustomImagesCheckNameRequest, options *armkusto.SandboxCustomImagesClientCheckNameAvailabilityOptions) (resp azfake.Responder[armkusto.SandboxCustomImagesClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method SandboxCustomImagesClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, clusterName string, sandboxCustomImageName string, parameters armkusto.SandboxCustomImage, options *armkusto.SandboxCustomImagesClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armkusto.SandboxCustomImagesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method SandboxCustomImagesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, clusterName string, sandboxCustomImageName string, options *armkusto.SandboxCustomImagesClientBeginDeleteOptions) (resp azfake.PollerResponder[armkusto.SandboxCustomImagesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method SandboxCustomImagesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterName string, sandboxCustomImageName string, options *armkusto.SandboxCustomImagesClientGetOptions) (resp azfake.Responder[armkusto.SandboxCustomImagesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByClusterPager is the fake for method SandboxCustomImagesClient.NewListByClusterPager + // HTTP status codes to indicate success: http.StatusOK + NewListByClusterPager func(resourceGroupName string, clusterName string, options *armkusto.SandboxCustomImagesClientListByClusterOptions) (resp azfake.PagerResponder[armkusto.SandboxCustomImagesClientListByClusterResponse]) + + // BeginUpdate is the fake for method SandboxCustomImagesClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, clusterName string, sandboxCustomImageName string, parameters armkusto.SandboxCustomImage, options *armkusto.SandboxCustomImagesClientBeginUpdateOptions) (resp azfake.PollerResponder[armkusto.SandboxCustomImagesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewSandboxCustomImagesServerTransport creates a new instance of SandboxCustomImagesServerTransport with the provided implementation. +// The returned SandboxCustomImagesServerTransport instance is connected to an instance of armkusto.SandboxCustomImagesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSandboxCustomImagesServerTransport(srv *SandboxCustomImagesServer) *SandboxCustomImagesServerTransport { + return &SandboxCustomImagesServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armkusto.SandboxCustomImagesClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armkusto.SandboxCustomImagesClientDeleteResponse]](), + newListByClusterPager: newTracker[azfake.PagerResponder[armkusto.SandboxCustomImagesClientListByClusterResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armkusto.SandboxCustomImagesClientUpdateResponse]](), + } +} + +// SandboxCustomImagesServerTransport connects instances of armkusto.SandboxCustomImagesClient to instances of SandboxCustomImagesServer. +// Don't use this type directly, use NewSandboxCustomImagesServerTransport instead. +type SandboxCustomImagesServerTransport struct { + srv *SandboxCustomImagesServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armkusto.SandboxCustomImagesClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armkusto.SandboxCustomImagesClientDeleteResponse]] + newListByClusterPager *tracker[azfake.PagerResponder[armkusto.SandboxCustomImagesClientListByClusterResponse]] + beginUpdate *tracker[azfake.PollerResponder[armkusto.SandboxCustomImagesClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for SandboxCustomImagesServerTransport. +func (s *SandboxCustomImagesServerTransport) 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 "SandboxCustomImagesClient.CheckNameAvailability": + resp, err = s.dispatchCheckNameAvailability(req) + case "SandboxCustomImagesClient.BeginCreateOrUpdate": + resp, err = s.dispatchBeginCreateOrUpdate(req) + case "SandboxCustomImagesClient.BeginDelete": + resp, err = s.dispatchBeginDelete(req) + case "SandboxCustomImagesClient.Get": + resp, err = s.dispatchGet(req) + case "SandboxCustomImagesClient.NewListByClusterPager": + resp, err = s.dispatchNewListByClusterPager(req) + case "SandboxCustomImagesClient.BeginUpdate": + resp, err = s.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SandboxCustomImagesServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if s.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/sandboxCustomImagesCheckNameAvailability` + 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[armkusto.SandboxCustomImagesCheckNameRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.CheckNameAvailability(req.Context(), resourceGroupNameParam, clusterNameParam, 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).CheckNameResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SandboxCustomImagesServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := s.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/sandboxCustomImages/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkusto.SandboxCustomImage](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + sandboxCustomImageNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("sandboxCustomImageName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, clusterNameParam, sandboxCustomImageNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + s.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) { + s.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) { + s.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (s *SandboxCustomImagesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if s.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := s.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/sandboxCustomImages/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + sandboxCustomImageNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("sandboxCustomImageName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginDelete(req.Context(), resourceGroupNameParam, clusterNameParam, sandboxCustomImageNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + s.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) { + s.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) { + s.beginDelete.remove(req) + } + + return resp, nil +} + +func (s *SandboxCustomImagesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.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\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/sandboxCustomImages/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + sandboxCustomImageNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("sandboxCustomImageName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, clusterNameParam, sandboxCustomImageNameParam, 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).SandboxCustomImage, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SandboxCustomImagesServerTransport) dispatchNewListByClusterPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByClusterPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByClusterPager not implemented")} + } + newListByClusterPager := s.newListByClusterPager.get(req) + if newListByClusterPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/sandboxCustomImages` + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListByClusterPager(resourceGroupNameParam, clusterNameParam, nil) + newListByClusterPager = &resp + s.newListByClusterPager.add(req, newListByClusterPager) + } + resp, err := server.PagerResponderNext(newListByClusterPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListByClusterPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByClusterPager) { + s.newListByClusterPager.remove(req) + } + return resp, nil +} + +func (s *SandboxCustomImagesServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if s.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := s.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/sandboxCustomImages/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkusto.SandboxCustomImage](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + sandboxCustomImageNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("sandboxCustomImageName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginUpdate(req.Context(), resourceGroupNameParam, clusterNameParam, sandboxCustomImageNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + s.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + s.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + s.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/kusto/armkusto/fake/scripts_server.go b/sdk/resourcemanager/kusto/armkusto/fake/scripts_server.go new file mode 100644 index 000000000000..b1d794783d89 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/scripts_server.go @@ -0,0 +1,395 @@ +//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/resourcemanager/kusto/armkusto/v2" + "net/http" + "net/url" + "regexp" +) + +// ScriptsServer is a fake server for instances of the armkusto.ScriptsClient type. +type ScriptsServer struct { + // CheckNameAvailability is the fake for method ScriptsClient.CheckNameAvailability + // HTTP status codes to indicate success: http.StatusOK + CheckNameAvailability func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName armkusto.ScriptCheckNameRequest, options *armkusto.ScriptsClientCheckNameAvailabilityOptions) (resp azfake.Responder[armkusto.ScriptsClientCheckNameAvailabilityResponse], errResp azfake.ErrorResponder) + + // BeginCreateOrUpdate is the fake for method ScriptsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, parameters armkusto.Script, options *armkusto.ScriptsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armkusto.ScriptsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method ScriptsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, options *armkusto.ScriptsClientBeginDeleteOptions) (resp azfake.PollerResponder[armkusto.ScriptsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ScriptsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, options *armkusto.ScriptsClientGetOptions) (resp azfake.Responder[armkusto.ScriptsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByDatabasePager is the fake for method ScriptsClient.NewListByDatabasePager + // HTTP status codes to indicate success: http.StatusOK + NewListByDatabasePager func(resourceGroupName string, clusterName string, databaseName string, options *armkusto.ScriptsClientListByDatabaseOptions) (resp azfake.PagerResponder[armkusto.ScriptsClientListByDatabaseResponse]) + + // BeginUpdate is the fake for method ScriptsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, parameters armkusto.Script, options *armkusto.ScriptsClientBeginUpdateOptions) (resp azfake.PollerResponder[armkusto.ScriptsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewScriptsServerTransport creates a new instance of ScriptsServerTransport with the provided implementation. +// The returned ScriptsServerTransport instance is connected to an instance of armkusto.ScriptsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewScriptsServerTransport(srv *ScriptsServer) *ScriptsServerTransport { + return &ScriptsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armkusto.ScriptsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armkusto.ScriptsClientDeleteResponse]](), + newListByDatabasePager: newTracker[azfake.PagerResponder[armkusto.ScriptsClientListByDatabaseResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armkusto.ScriptsClientUpdateResponse]](), + } +} + +// ScriptsServerTransport connects instances of armkusto.ScriptsClient to instances of ScriptsServer. +// Don't use this type directly, use NewScriptsServerTransport instead. +type ScriptsServerTransport struct { + srv *ScriptsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armkusto.ScriptsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armkusto.ScriptsClientDeleteResponse]] + newListByDatabasePager *tracker[azfake.PagerResponder[armkusto.ScriptsClientListByDatabaseResponse]] + beginUpdate *tracker[azfake.PollerResponder[armkusto.ScriptsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for ScriptsServerTransport. +func (s *ScriptsServerTransport) 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 "ScriptsClient.CheckNameAvailability": + resp, err = s.dispatchCheckNameAvailability(req) + case "ScriptsClient.BeginCreateOrUpdate": + resp, err = s.dispatchBeginCreateOrUpdate(req) + case "ScriptsClient.BeginDelete": + resp, err = s.dispatchBeginDelete(req) + case "ScriptsClient.Get": + resp, err = s.dispatchGet(req) + case "ScriptsClient.NewListByDatabasePager": + resp, err = s.dispatchNewListByDatabasePager(req) + case "ScriptsClient.BeginUpdate": + resp, err = s.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *ScriptsServerTransport) dispatchCheckNameAvailability(req *http.Request) (*http.Response, error) { + if s.srv.CheckNameAvailability == nil { + return nil, &nonRetriableError{errors.New("fake for method CheckNameAvailability not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scriptsCheckNameAvailability` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkusto.ScriptCheckNameRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.CheckNameAvailability(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, 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).CheckNameResult, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ScriptsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := s.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scripts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkusto.Script](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + scriptNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scriptName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, scriptNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + s.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + s.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + s.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (s *ScriptsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if s.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := s.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scripts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + scriptNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scriptName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginDelete(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, scriptNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + s.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) { + s.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) { + s.beginDelete.remove(req) + } + + return resp, nil +} + +func (s *ScriptsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.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\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scripts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + scriptNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scriptName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, scriptNameParam, 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).Script, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *ScriptsServerTransport) dispatchNewListByDatabasePager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByDatabasePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByDatabasePager not implemented")} + } + newListByDatabasePager := s.newListByDatabasePager.get(req) + if newListByDatabasePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scripts` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListByDatabasePager(resourceGroupNameParam, clusterNameParam, databaseNameParam, nil) + newListByDatabasePager = &resp + s.newListByDatabasePager.add(req, newListByDatabasePager) + } + resp, err := server.PagerResponderNext(newListByDatabasePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListByDatabasePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByDatabasePager) { + s.newListByDatabasePager.remove(req) + } + return resp, nil +} + +func (s *ScriptsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if s.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := s.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/databases/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scripts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armkusto.Script](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + databaseNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("databaseName")]) + if err != nil { + return nil, err + } + scriptNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scriptName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginUpdate(req.Context(), resourceGroupNameParam, clusterNameParam, databaseNameParam, scriptNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + s.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) { + s.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) { + s.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/kusto/armkusto/fake/server_factory.go b/sdk/resourcemanager/kusto/armkusto/fake/server_factory.go new file mode 100644 index 000000000000..029ecf63a84f --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/server_factory.go @@ -0,0 +1,170 @@ +//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 ( + "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 armkusto.ClientFactory type. +type ServerFactory struct { + AttachedDatabaseConfigurationsServer AttachedDatabaseConfigurationsServer + ClusterPrincipalAssignmentsServer ClusterPrincipalAssignmentsServer + ClustersServer ClustersServer + DataConnectionsServer DataConnectionsServer + DatabaseServer DatabaseServer + DatabasePrincipalAssignmentsServer DatabasePrincipalAssignmentsServer + DatabasesServer DatabasesServer + ManagedPrivateEndpointsServer ManagedPrivateEndpointsServer + OperationsServer OperationsServer + OperationsResultsServer OperationsResultsServer + OperationsResultsLocationServer OperationsResultsLocationServer + PrivateEndpointConnectionsServer PrivateEndpointConnectionsServer + PrivateLinkResourcesServer PrivateLinkResourcesServer + SKUsServer SKUsServer + SandboxCustomImagesServer SandboxCustomImagesServer + ScriptsServer ScriptsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armkusto.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 armkusto.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trAttachedDatabaseConfigurationsServer *AttachedDatabaseConfigurationsServerTransport + trClusterPrincipalAssignmentsServer *ClusterPrincipalAssignmentsServerTransport + trClustersServer *ClustersServerTransport + trDataConnectionsServer *DataConnectionsServerTransport + trDatabaseServer *DatabaseServerTransport + trDatabasePrincipalAssignmentsServer *DatabasePrincipalAssignmentsServerTransport + trDatabasesServer *DatabasesServerTransport + trManagedPrivateEndpointsServer *ManagedPrivateEndpointsServerTransport + trOperationsServer *OperationsServerTransport + trOperationsResultsServer *OperationsResultsServerTransport + trOperationsResultsLocationServer *OperationsResultsLocationServerTransport + trPrivateEndpointConnectionsServer *PrivateEndpointConnectionsServerTransport + trPrivateLinkResourcesServer *PrivateLinkResourcesServerTransport + trSKUsServer *SKUsServerTransport + trSandboxCustomImagesServer *SandboxCustomImagesServerTransport + trScriptsServer *ScriptsServerTransport +} + +// 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 "AttachedDatabaseConfigurationsClient": + initServer(s, &s.trAttachedDatabaseConfigurationsServer, func() *AttachedDatabaseConfigurationsServerTransport { + return NewAttachedDatabaseConfigurationsServerTransport(&s.srv.AttachedDatabaseConfigurationsServer) + }) + resp, err = s.trAttachedDatabaseConfigurationsServer.Do(req) + case "ClusterPrincipalAssignmentsClient": + initServer(s, &s.trClusterPrincipalAssignmentsServer, func() *ClusterPrincipalAssignmentsServerTransport { + return NewClusterPrincipalAssignmentsServerTransport(&s.srv.ClusterPrincipalAssignmentsServer) + }) + resp, err = s.trClusterPrincipalAssignmentsServer.Do(req) + case "ClustersClient": + initServer(s, &s.trClustersServer, func() *ClustersServerTransport { return NewClustersServerTransport(&s.srv.ClustersServer) }) + resp, err = s.trClustersServer.Do(req) + case "DataConnectionsClient": + initServer(s, &s.trDataConnectionsServer, func() *DataConnectionsServerTransport { + return NewDataConnectionsServerTransport(&s.srv.DataConnectionsServer) + }) + resp, err = s.trDataConnectionsServer.Do(req) + case "DatabaseClient": + initServer(s, &s.trDatabaseServer, func() *DatabaseServerTransport { return NewDatabaseServerTransport(&s.srv.DatabaseServer) }) + resp, err = s.trDatabaseServer.Do(req) + case "DatabasePrincipalAssignmentsClient": + initServer(s, &s.trDatabasePrincipalAssignmentsServer, func() *DatabasePrincipalAssignmentsServerTransport { + return NewDatabasePrincipalAssignmentsServerTransport(&s.srv.DatabasePrincipalAssignmentsServer) + }) + resp, err = s.trDatabasePrincipalAssignmentsServer.Do(req) + case "DatabasesClient": + initServer(s, &s.trDatabasesServer, func() *DatabasesServerTransport { return NewDatabasesServerTransport(&s.srv.DatabasesServer) }) + resp, err = s.trDatabasesServer.Do(req) + case "ManagedPrivateEndpointsClient": + initServer(s, &s.trManagedPrivateEndpointsServer, func() *ManagedPrivateEndpointsServerTransport { + return NewManagedPrivateEndpointsServerTransport(&s.srv.ManagedPrivateEndpointsServer) + }) + resp, err = s.trManagedPrivateEndpointsServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "OperationsResultsClient": + initServer(s, &s.trOperationsResultsServer, func() *OperationsResultsServerTransport { + return NewOperationsResultsServerTransport(&s.srv.OperationsResultsServer) + }) + resp, err = s.trOperationsResultsServer.Do(req) + case "OperationsResultsLocationClient": + initServer(s, &s.trOperationsResultsLocationServer, func() *OperationsResultsLocationServerTransport { + return NewOperationsResultsLocationServerTransport(&s.srv.OperationsResultsLocationServer) + }) + resp, err = s.trOperationsResultsLocationServer.Do(req) + case "PrivateEndpointConnectionsClient": + initServer(s, &s.trPrivateEndpointConnectionsServer, func() *PrivateEndpointConnectionsServerTransport { + return NewPrivateEndpointConnectionsServerTransport(&s.srv.PrivateEndpointConnectionsServer) + }) + resp, err = s.trPrivateEndpointConnectionsServer.Do(req) + case "PrivateLinkResourcesClient": + initServer(s, &s.trPrivateLinkResourcesServer, func() *PrivateLinkResourcesServerTransport { + return NewPrivateLinkResourcesServerTransport(&s.srv.PrivateLinkResourcesServer) + }) + resp, err = s.trPrivateLinkResourcesServer.Do(req) + case "SKUsClient": + initServer(s, &s.trSKUsServer, func() *SKUsServerTransport { return NewSKUsServerTransport(&s.srv.SKUsServer) }) + resp, err = s.trSKUsServer.Do(req) + case "SandboxCustomImagesClient": + initServer(s, &s.trSandboxCustomImagesServer, func() *SandboxCustomImagesServerTransport { + return NewSandboxCustomImagesServerTransport(&s.srv.SandboxCustomImagesServer) + }) + resp, err = s.trSandboxCustomImagesServer.Do(req) + case "ScriptsClient": + initServer(s, &s.trScriptsServer, func() *ScriptsServerTransport { return NewScriptsServerTransport(&s.srv.ScriptsServer) }) + resp, err = s.trScriptsServer.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/kusto/armkusto/fake/skus_server.go b/sdk/resourcemanager/kusto/armkusto/fake/skus_server.go new file mode 100644 index 000000000000..68ae728de90f --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/skus_server.go @@ -0,0 +1,104 @@ +//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 ( + "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/resourcemanager/kusto/armkusto/v2" + "net/http" + "net/url" + "regexp" +) + +// SKUsServer is a fake server for instances of the armkusto.SKUsClient type. +type SKUsServer struct { + // NewListPager is the fake for method SKUsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(location string, options *armkusto.SKUsClientListOptions) (resp azfake.PagerResponder[armkusto.SKUsClientListResponse]) +} + +// NewSKUsServerTransport creates a new instance of SKUsServerTransport with the provided implementation. +// The returned SKUsServerTransport instance is connected to an instance of armkusto.SKUsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSKUsServerTransport(srv *SKUsServer) *SKUsServerTransport { + return &SKUsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armkusto.SKUsClientListResponse]](), + } +} + +// SKUsServerTransport connects instances of armkusto.SKUsClient to instances of SKUsServer. +// Don't use this type directly, use NewSKUsServerTransport instead. +type SKUsServerTransport struct { + srv *SKUsServer + newListPager *tracker[azfake.PagerResponder[armkusto.SKUsClientListResponse]] +} + +// Do implements the policy.Transporter interface for SKUsServerTransport. +func (s *SKUsServerTransport) 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 "SKUsClient.NewListPager": + resp, err = s.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SKUsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := s.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Kusto/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/skus` + 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 := s.srv.NewListPager(locationParam, nil) + newListPager = &resp + s.newListPager.add(req, newListPager) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + s.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/kusto/armkusto/fake/time_rfc3339.go b/sdk/resourcemanager/kusto/armkusto/fake/time_rfc3339.go new file mode 100644 index 000000000000..b0535a7b63e6 --- /dev/null +++ b/sdk/resourcemanager/kusto/armkusto/fake/time_rfc3339.go @@ -0,0 +1,86 @@ +//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 ( + "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 ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +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 { + layout := utcDateTimeJSON + if tzOffsetRegex.Match(data) { + layout = dateTimeJSON + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + 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 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 || strings.EqualFold(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/kusto/armkusto/go.mod b/sdk/resourcemanager/kusto/armkusto/go.mod index e3725142fa58..e7c3f2bf2226 100644 --- a/sdk/resourcemanager/kusto/armkusto/go.mod +++ b/sdk/resourcemanager/kusto/armkusto/go.mod @@ -3,27 +3,27 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kusto/armkusto/v2 go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 - github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 - github.com/stretchr/testify v1.7.0 + github.com/stretchr/testify v1.8.4 ) require ( - github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/dnaeon/go-vcr v1.2.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 // indirect + github.com/google/uuid v1.3.1 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/crypto v0.7.0 // indirect - golang.org/x/net v0.8.0 // indirect - golang.org/x/sys v0.6.0 // indirect - golang.org/x/text v0.8.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/sdk/resourcemanager/kusto/armkusto/go.sum b/sdk/resourcemanager/kusto/armkusto/go.sum index fe66006d647a..88bb72abf2ba 100644 --- a/sdk/resourcemanager/kusto/armkusto/go.sum +++ b/sdk/resourcemanager/kusto/armkusto/go.sum @@ -1,25 +1,25 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1 h1:SEy2xmstIphdPwNBUi7uhvjyjhVKISfwjfOJmuy7kg4= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.6.1/go.mod h1:bjGvMhVMb+EEm3VRNQawDMUyMMjo+S5ewNjflkep/0Q= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0 h1:vcYCAze6p19qBW7MhZybIsqD8sMV8js0NyQM8JDnVtg= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.3.0/go.mod h1:OQeznEEkTZ9OrhHJoDD8ZDq51FHgXjqtP9z6bEwBq9U= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0 h1:sXr+ck84g/ZlZUOZiNELInmMgOsuGwdjjVkEIde0OtY= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.3.0/go.mod h1:okt5dMMTOFjX/aovMlrjvvXoPMBVSPzk9185BT0+eZM= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 h1:mLY+pNLjCUeKhgnAJWAKhEUQM+RJQo2H1fuGSw1Ky1E= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2/go.mod h1:FbdwsQ2EzwvXxOPcMFYO8ogEc9uMMIj3YkmCdXdAFmk= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 h1:PTFGRSlMKCQelWwxUyYVEUqseBJVemLyqWJjvMyt0do= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0/go.mod h1:LRr2FzBTQlONPPa5HREE5+RjSCTXl7BwOvYOaWTqCaI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups v1.0.0 h1:pPvTJ1dY0sA35JOeFq6TsY2xj6Z85Yo23Pj4wCCvu4o= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 h1:7CBQ+Ei8SP2c6ydQTGCCrS35bDxgTMfoP2miAwK++OU= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1/go.mod h1:c/wcGeGx5FUPbM/JltUYHZcKmigwyVLJlDq+4HdtXaw= -github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0 h1:OBhqkivkhkMqLPymWEppkm7vgPQY2XsHoEkaMQ0AdZY= -github.com/AzureAD/microsoft-authentication-library-for-go v1.0.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= +github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= @@ -27,23 +27,21 @@ github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9 github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= -golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 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/kusto/armkusto/kusto_live_test.go b/sdk/resourcemanager/kusto/armkusto/kusto_live_test.go index 174b6cc568f4..eca68c582347 100644 --- a/sdk/resourcemanager/kusto/armkusto/kusto_live_test.go +++ b/sdk/resourcemanager/kusto/armkusto/kusto_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "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/testutil" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2/testutil" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/kusto/armkusto/v2" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources" "github.com/stretchr/testify/suite" diff --git a/sdk/resourcemanager/kusto/armkusto/managedprivateendpoints_client.go b/sdk/resourcemanager/kusto/armkusto/managedprivateendpoints_client.go index 2b6d5b97f7b2..7d173bf3f447 100644 --- a/sdk/resourcemanager/kusto/armkusto/managedprivateendpoints_client.go +++ b/sdk/resourcemanager/kusto/armkusto/managedprivateendpoints_client.go @@ -32,7 +32,7 @@ type ManagedPrivateEndpointsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewManagedPrivateEndpointsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ManagedPrivateEndpointsClient, error) { - cl, err := arm.NewClient(moduleName+".ManagedPrivateEndpointsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,6 +54,10 @@ func NewManagedPrivateEndpointsClient(subscriptionID string, credential azcore.T // method. func (client *ManagedPrivateEndpointsClient) CheckNameAvailability(ctx context.Context, resourceGroupName string, clusterName string, resourceName ManagedPrivateEndpointsCheckNameRequest, options *ManagedPrivateEndpointsClientCheckNameAvailabilityOptions) (ManagedPrivateEndpointsClientCheckNameAvailabilityResponse, error) { var err error + const operationName = "ManagedPrivateEndpointsClient.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, resourceGroupName, clusterName, resourceName, options) if err != nil { return ManagedPrivateEndpointsClientCheckNameAvailabilityResponse{}, err @@ -124,10 +128,14 @@ func (client *ManagedPrivateEndpointsClient) BeginCreateOrUpdate(ctx context.Con if err != nil { return nil, err } - poller, err := runtime.NewPoller[ManagedPrivateEndpointsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ManagedPrivateEndpointsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ManagedPrivateEndpointsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ManagedPrivateEndpointsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -137,6 +145,10 @@ func (client *ManagedPrivateEndpointsClient) BeginCreateOrUpdate(ctx context.Con // Generated from API version 2023-08-15 func (client *ManagedPrivateEndpointsClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, parameters ManagedPrivateEndpoint, options *ManagedPrivateEndpointsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error + const operationName = "ManagedPrivateEndpointsClient.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, clusterName, managedPrivateEndpointName, parameters, options) if err != nil { return nil, err @@ -200,10 +212,14 @@ func (client *ManagedPrivateEndpointsClient) BeginDelete(ctx context.Context, re if err != nil { return nil, err } - poller, err := runtime.NewPoller[ManagedPrivateEndpointsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ManagedPrivateEndpointsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ManagedPrivateEndpointsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ManagedPrivateEndpointsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -213,6 +229,10 @@ func (client *ManagedPrivateEndpointsClient) BeginDelete(ctx context.Context, re // Generated from API version 2023-08-15 func (client *ManagedPrivateEndpointsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, options *ManagedPrivateEndpointsClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "ManagedPrivateEndpointsClient.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, clusterName, managedPrivateEndpointName, options) if err != nil { return nil, err @@ -269,6 +289,10 @@ func (client *ManagedPrivateEndpointsClient) deleteCreateRequest(ctx context.Con // method. func (client *ManagedPrivateEndpointsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, options *ManagedPrivateEndpointsClientGetOptions) (ManagedPrivateEndpointsClientGetResponse, error) { var err error + const operationName = "ManagedPrivateEndpointsClient.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, clusterName, managedPrivateEndpointName, options) if err != nil { return ManagedPrivateEndpointsClientGetResponse{}, err @@ -337,6 +361,7 @@ func (client *ManagedPrivateEndpointsClient) NewListPager(resourceGroupName stri return false }, Fetcher: func(ctx context.Context, page *ManagedPrivateEndpointsClientListResponse) (ManagedPrivateEndpointsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ManagedPrivateEndpointsClient.NewListPager") req, err := client.listCreateRequest(ctx, resourceGroupName, clusterName, options) if err != nil { return ManagedPrivateEndpointsClientListResponse{}, err @@ -350,6 +375,7 @@ func (client *ManagedPrivateEndpointsClient) NewListPager(resourceGroupName stri } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -404,10 +430,14 @@ func (client *ManagedPrivateEndpointsClient) BeginUpdate(ctx context.Context, re if err != nil { return nil, err } - poller, err := runtime.NewPoller[ManagedPrivateEndpointsClientUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ManagedPrivateEndpointsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ManagedPrivateEndpointsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ManagedPrivateEndpointsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -417,6 +447,10 @@ func (client *ManagedPrivateEndpointsClient) BeginUpdate(ctx context.Context, re // Generated from API version 2023-08-15 func (client *ManagedPrivateEndpointsClient) update(ctx context.Context, resourceGroupName string, clusterName string, managedPrivateEndpointName string, parameters ManagedPrivateEndpoint, options *ManagedPrivateEndpointsClientBeginUpdateOptions) (*http.Response, error) { var err error + const operationName = "ManagedPrivateEndpointsClient.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, clusterName, managedPrivateEndpointName, parameters, options) if err != nil { return nil, err diff --git a/sdk/resourcemanager/kusto/armkusto/models_serde.go b/sdk/resourcemanager/kusto/armkusto/models_serde.go index bc87fcd41a11..8a1f4b63eab9 100644 --- a/sdk/resourcemanager/kusto/armkusto/models_serde.go +++ b/sdk/resourcemanager/kusto/armkusto/models_serde.go @@ -951,7 +951,7 @@ func (c CosmosDbDataConnectionProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "managedIdentityResourceId", c.ManagedIdentityResourceID) populate(objectMap, "mappingRuleName", c.MappingRuleName) populate(objectMap, "provisioningState", c.ProvisioningState) - populateTimeRFC3339(objectMap, "retrievalStartDate", c.RetrievalStartDate) + populateDateTimeRFC3339(objectMap, "retrievalStartDate", c.RetrievalStartDate) populate(objectMap, "tableName", c.TableName) return json.Marshal(objectMap) } @@ -987,7 +987,7 @@ func (c *CosmosDbDataConnectionProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "ProvisioningState", &c.ProvisioningState) delete(rawMsg, key) case "retrievalStartDate": - err = unpopulateTimeRFC3339(val, "RetrievalStartDate", &c.RetrievalStartDate) + err = unpopulateDateTimeRFC3339(val, "RetrievalStartDate", &c.RetrievalStartDate) delete(rawMsg, key) case "tableName": err = unpopulate(val, "TableName", &c.TableName) @@ -1826,7 +1826,7 @@ func (e EventHubConnectionProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "managedIdentityResourceId", e.ManagedIdentityResourceID) populate(objectMap, "mappingRuleName", e.MappingRuleName) populate(objectMap, "provisioningState", e.ProvisioningState) - populateTimeRFC3339(objectMap, "retrievalStartDate", e.RetrievalStartDate) + populateDateTimeRFC3339(objectMap, "retrievalStartDate", e.RetrievalStartDate) populate(objectMap, "tableName", e.TableName) return json.Marshal(objectMap) } @@ -1871,7 +1871,7 @@ func (e *EventHubConnectionProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "ProvisioningState", &e.ProvisioningState) delete(rawMsg, key) case "retrievalStartDate": - err = unpopulateTimeRFC3339(val, "RetrievalStartDate", &e.RetrievalStartDate) + err = unpopulateDateTimeRFC3339(val, "RetrievalStartDate", &e.RetrievalStartDate) delete(rawMsg, key) case "tableName": err = unpopulate(val, "TableName", &e.TableName) @@ -2050,7 +2050,7 @@ func (i IotHubConnectionProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "iotHubResourceId", i.IotHubResourceID) populate(objectMap, "mappingRuleName", i.MappingRuleName) populate(objectMap, "provisioningState", i.ProvisioningState) - populateTimeRFC3339(objectMap, "retrievalStartDate", i.RetrievalStartDate) + populateDateTimeRFC3339(objectMap, "retrievalStartDate", i.RetrievalStartDate) populate(objectMap, "sharedAccessPolicyName", i.SharedAccessPolicyName) populate(objectMap, "tableName", i.TableName) return json.Marshal(objectMap) @@ -2087,7 +2087,7 @@ func (i *IotHubConnectionProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "ProvisioningState", &i.ProvisioningState) delete(rawMsg, key) case "retrievalStartDate": - err = unpopulateTimeRFC3339(val, "RetrievalStartDate", &i.RetrievalStartDate) + err = unpopulateDateTimeRFC3339(val, "RetrievalStartDate", &i.RetrievalStartDate) delete(rawMsg, key) case "sharedAccessPolicyName": err = unpopulate(val, "SharedAccessPolicyName", &i.SharedAccessPolicyName) @@ -2573,13 +2573,13 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationResult. func (o OperationResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "endTime", o.EndTime) + populateDateTimeRFC3339(objectMap, "endTime", o.EndTime) populate(objectMap, "error", o.Error) populate(objectMap, "id", o.ID) populate(objectMap, "name", o.Name) populate(objectMap, "percentComplete", o.PercentComplete) populate(objectMap, "properties", o.Properties) - populateTimeRFC3339(objectMap, "startTime", o.StartTime) + populateDateTimeRFC3339(objectMap, "startTime", o.StartTime) populate(objectMap, "status", o.Status) return json.Marshal(objectMap) } @@ -2594,7 +2594,7 @@ func (o *OperationResult) UnmarshalJSON(data []byte) error { var err error switch key { case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &o.EndTime) + err = unpopulateDateTimeRFC3339(val, "EndTime", &o.EndTime) delete(rawMsg, key) case "error": err = unpopulate(val, "Error", &o.Error) @@ -2612,7 +2612,7 @@ func (o *OperationResult) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Properties", &o.Properties) delete(rawMsg, key) case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &o.StartTime) + err = unpopulateDateTimeRFC3339(val, "StartTime", &o.StartTime) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &o.Status) @@ -3789,7 +3789,7 @@ func (s *ScriptProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SuspensionDetails. func (s SuspensionDetails) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "suspensionStartDate", s.SuspensionStartDate) + populateDateTimeRFC3339(objectMap, "suspensionStartDate", s.SuspensionStartDate) return json.Marshal(objectMap) } @@ -3803,7 +3803,7 @@ func (s *SuspensionDetails) UnmarshalJSON(data []byte) error { var err error switch key { case "suspensionStartDate": - err = unpopulateTimeRFC3339(val, "SuspensionStartDate", &s.SuspensionStartDate) + err = unpopulateDateTimeRFC3339(val, "SuspensionStartDate", &s.SuspensionStartDate) delete(rawMsg, key) } if err != nil { @@ -3816,10 +3816,10 @@ func (s *SuspensionDetails) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) populate(objectMap, "lastModifiedBy", s.LastModifiedBy) populate(objectMap, "lastModifiedByType", s.LastModifiedByType) return json.Marshal(objectMap) @@ -3835,7 +3835,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { var err error switch key { case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) delete(rawMsg, key) case "createdBy": err = unpopulate(val, "CreatedBy", &s.CreatedBy) @@ -3844,7 +3844,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { err = unpopulate(val, "CreatedByType", &s.CreatedByType) delete(rawMsg, key) case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) delete(rawMsg, key) case "lastModifiedBy": err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) diff --git a/sdk/resourcemanager/kusto/armkusto/operations_client.go b/sdk/resourcemanager/kusto/armkusto/operations_client.go index 1d876d6c532c..827e58114f71 100644 --- a/sdk/resourcemanager/kusto/armkusto/operations_client.go +++ b/sdk/resourcemanager/kusto/armkusto/operations_client.go @@ -27,7 +27,7 @@ type OperationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -47,25 +47,20 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.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, options) + }, nil) if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return OperationsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OperationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/kusto/armkusto/operationsresults_client.go b/sdk/resourcemanager/kusto/armkusto/operationsresults_client.go index 05012bbceab3..6c151ca6ed11 100644 --- a/sdk/resourcemanager/kusto/armkusto/operationsresults_client.go +++ b/sdk/resourcemanager/kusto/armkusto/operationsresults_client.go @@ -32,7 +32,7 @@ type OperationsResultsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationsResultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsResultsClient, error) { - cl, err := arm.NewClient(moduleName+".OperationsResultsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -52,6 +52,10 @@ func NewOperationsResultsClient(subscriptionID string, credential azcore.TokenCr // - options - OperationsResultsClientGetOptions contains the optional parameters for the OperationsResultsClient.Get method. func (client *OperationsResultsClient) Get(ctx context.Context, location string, operationID string, options *OperationsResultsClientGetOptions) (OperationsResultsClientGetResponse, error) { var err error + const operationName = "OperationsResultsClient.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, operationID, options) if err != nil { return OperationsResultsClientGetResponse{}, err diff --git a/sdk/resourcemanager/kusto/armkusto/operationsresults_client_example_test.go b/sdk/resourcemanager/kusto/armkusto/operationsresults_client_example_test.go index 270b6c2daada..a0fa0cbf52e7 100644 --- a/sdk/resourcemanager/kusto/armkusto/operationsresults_client_example_test.go +++ b/sdk/resourcemanager/kusto/armkusto/operationsresults_client_example_test.go @@ -37,7 +37,7 @@ func ExampleOperationsResultsClient_Get() { // 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.OperationResult = armkusto.OperationResult{ // Name: to.Ptr("30972f1b-b61d-4fd8-bd34-3dcfa24670f3"), - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-26T13:45:42.7025301Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-26T13:45:42.702Z"); return t}()), // Error: &armkusto.OperationResultErrorProperties{ // Code: to.Ptr("CannotAlterFollowerDatabase"), // Message: to.Ptr("[BadRequest] Cannot alter leader cluster 'test' for resource name 'adc'."), @@ -48,7 +48,7 @@ func ExampleOperationsResultsClient_Get() { // OperationKind: to.Ptr("FollowerDatabaseCreate"), // OperationState: to.Ptr("BadInput"), // }, - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-26T13:45:39.6554616Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-10-26T13:45:39.655Z"); return t}()), // Status: to.Ptr(armkusto.StatusFailed), // } } diff --git a/sdk/resourcemanager/kusto/armkusto/operationsresultslocation_client.go b/sdk/resourcemanager/kusto/armkusto/operationsresultslocation_client.go index 736c7eb9672f..c2b7bb27048e 100644 --- a/sdk/resourcemanager/kusto/armkusto/operationsresultslocation_client.go +++ b/sdk/resourcemanager/kusto/armkusto/operationsresultslocation_client.go @@ -32,7 +32,7 @@ type OperationsResultsLocationClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationsResultsLocationClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsResultsLocationClient, error) { - cl, err := arm.NewClient(moduleName+".OperationsResultsLocationClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -53,6 +53,10 @@ func NewOperationsResultsLocationClient(subscriptionID string, credential azcore // method. func (client *OperationsResultsLocationClient) Get(ctx context.Context, location string, operationID string, options *OperationsResultsLocationClientGetOptions) (OperationsResultsLocationClientGetResponse, error) { var err error + const operationName = "OperationsResultsLocationClient.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, operationID, options) if err != nil { return OperationsResultsLocationClientGetResponse{}, err diff --git a/sdk/resourcemanager/kusto/armkusto/privateendpointconnections_client.go b/sdk/resourcemanager/kusto/armkusto/privateendpointconnections_client.go index 6d68160c7a21..545d7d1e9c73 100644 --- a/sdk/resourcemanager/kusto/armkusto/privateendpointconnections_client.go +++ b/sdk/resourcemanager/kusto/armkusto/privateendpointconnections_client.go @@ -32,7 +32,7 @@ type PrivateEndpointConnectionsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewPrivateEndpointConnectionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateEndpointConnectionsClient, error) { - cl, err := arm.NewClient(moduleName+".PrivateEndpointConnectionsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -58,10 +58,14 @@ func (client *PrivateEndpointConnectionsClient) BeginCreateOrUpdate(ctx context. if err != nil { return nil, err } - poller, err := runtime.NewPoller[PrivateEndpointConnectionsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateEndpointConnectionsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PrivateEndpointConnectionsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -71,6 +75,10 @@ func (client *PrivateEndpointConnectionsClient) BeginCreateOrUpdate(ctx context. // Generated from API version 2023-08-15 func (client *PrivateEndpointConnectionsClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string, parameters PrivateEndpointConnection, options *PrivateEndpointConnectionsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error + const operationName = "PrivateEndpointConnectionsClient.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, clusterName, privateEndpointConnectionName, parameters, options) if err != nil { return nil, err @@ -134,10 +142,14 @@ func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, if err != nil { return nil, err } - poller, err := runtime.NewPoller[PrivateEndpointConnectionsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[PrivateEndpointConnectionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[PrivateEndpointConnectionsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[PrivateEndpointConnectionsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -147,6 +159,10 @@ func (client *PrivateEndpointConnectionsClient) BeginDelete(ctx context.Context, // Generated from API version 2023-08-15 func (client *PrivateEndpointConnectionsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "PrivateEndpointConnectionsClient.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, clusterName, privateEndpointConnectionName, options) if err != nil { return nil, err @@ -203,6 +219,10 @@ func (client *PrivateEndpointConnectionsClient) deleteCreateRequest(ctx context. // method. func (client *PrivateEndpointConnectionsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, privateEndpointConnectionName string, options *PrivateEndpointConnectionsClientGetOptions) (PrivateEndpointConnectionsClientGetResponse, error) { var err error + const operationName = "PrivateEndpointConnectionsClient.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, clusterName, privateEndpointConnectionName, options) if err != nil { return PrivateEndpointConnectionsClientGetResponse{}, err @@ -271,6 +291,7 @@ func (client *PrivateEndpointConnectionsClient) NewListPager(resourceGroupName s return false }, Fetcher: func(ctx context.Context, page *PrivateEndpointConnectionsClientListResponse) (PrivateEndpointConnectionsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrivateEndpointConnectionsClient.NewListPager") req, err := client.listCreateRequest(ctx, resourceGroupName, clusterName, options) if err != nil { return PrivateEndpointConnectionsClientListResponse{}, err @@ -284,6 +305,7 @@ func (client *PrivateEndpointConnectionsClient) NewListPager(resourceGroupName s } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/kusto/armkusto/privatelinkresources_client.go b/sdk/resourcemanager/kusto/armkusto/privatelinkresources_client.go index 1bed78d94b24..7940b3033147 100644 --- a/sdk/resourcemanager/kusto/armkusto/privatelinkresources_client.go +++ b/sdk/resourcemanager/kusto/armkusto/privatelinkresources_client.go @@ -32,7 +32,7 @@ type PrivateLinkResourcesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*PrivateLinkResourcesClient, error) { - cl, err := arm.NewClient(moduleName+".PrivateLinkResourcesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,6 +54,10 @@ func NewPrivateLinkResourcesClient(subscriptionID string, credential azcore.Toke // method. func (client *PrivateLinkResourcesClient) Get(ctx context.Context, resourceGroupName string, clusterName string, privateLinkResourceName string, options *PrivateLinkResourcesClientGetOptions) (PrivateLinkResourcesClientGetResponse, error) { var err error + const operationName = "PrivateLinkResourcesClient.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, clusterName, privateLinkResourceName, options) if err != nil { return PrivateLinkResourcesClientGetResponse{}, err @@ -122,6 +126,7 @@ func (client *PrivateLinkResourcesClient) NewListPager(resourceGroupName string, return false }, Fetcher: func(ctx context.Context, page *PrivateLinkResourcesClientListResponse) (PrivateLinkResourcesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "PrivateLinkResourcesClient.NewListPager") req, err := client.listCreateRequest(ctx, resourceGroupName, clusterName, options) if err != nil { return PrivateLinkResourcesClientListResponse{}, err @@ -135,6 +140,7 @@ func (client *PrivateLinkResourcesClient) NewListPager(resourceGroupName string, } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/kusto/armkusto/response_types.go b/sdk/resourcemanager/kusto/armkusto/response_types.go index c3bd061f8b82..1d4af0cd84f3 100644 --- a/sdk/resourcemanager/kusto/armkusto/response_types.go +++ b/sdk/resourcemanager/kusto/armkusto/response_types.go @@ -8,6 +8,8 @@ package armkusto +import "encoding/json" + // AttachedDatabaseConfigurationsClientCheckNameAvailabilityResponse contains the response from method AttachedDatabaseConfigurationsClient.CheckNameAvailability. type AttachedDatabaseConfigurationsClientCheckNameAvailabilityResponse struct { // The result returned from a check name availability request. @@ -184,6 +186,11 @@ type DataConnectionsClientCreateOrUpdateResponse struct { DataConnectionClassification } +// MarshalJSON implements the json.Marshaller interface for type DataConnectionsClientCreateOrUpdateResponse. +func (d DataConnectionsClientCreateOrUpdateResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(d.DataConnectionClassification) +} + // UnmarshalJSON implements the json.Unmarshaller interface for type DataConnectionsClientCreateOrUpdateResponse. func (d *DataConnectionsClientCreateOrUpdateResponse) UnmarshalJSON(data []byte) error { res, err := unmarshalDataConnectionClassification(data) @@ -233,6 +240,11 @@ type DataConnectionsClientUpdateResponse struct { DataConnectionClassification } +// MarshalJSON implements the json.Marshaller interface for type DataConnectionsClientUpdateResponse. +func (d DataConnectionsClientUpdateResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(d.DataConnectionClassification) +} + // UnmarshalJSON implements the json.Unmarshaller interface for type DataConnectionsClientUpdateResponse. func (d *DataConnectionsClientUpdateResponse) UnmarshalJSON(data []byte) error { res, err := unmarshalDataConnectionClassification(data) @@ -296,6 +308,11 @@ type DatabasesClientCreateOrUpdateResponse struct { DatabaseClassification } +// MarshalJSON implements the json.Marshaller interface for type DatabasesClientCreateOrUpdateResponse. +func (d DatabasesClientCreateOrUpdateResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(d.DatabaseClassification) +} + // UnmarshalJSON implements the json.Unmarshaller interface for type DatabasesClientCreateOrUpdateResponse. func (d *DatabasesClientCreateOrUpdateResponse) UnmarshalJSON(data []byte) error { res, err := unmarshalDatabaseClassification(data) @@ -351,6 +368,11 @@ type DatabasesClientUpdateResponse struct { DatabaseClassification } +// MarshalJSON implements the json.Marshaller interface for type DatabasesClientUpdateResponse. +func (d DatabasesClientUpdateResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(d.DatabaseClassification) +} + // UnmarshalJSON implements the json.Unmarshaller interface for type DatabasesClientUpdateResponse. func (d *DatabasesClientUpdateResponse) UnmarshalJSON(data []byte) error { res, err := unmarshalDatabaseClassification(data) diff --git a/sdk/resourcemanager/kusto/armkusto/sandboxcustomimages_client.go b/sdk/resourcemanager/kusto/armkusto/sandboxcustomimages_client.go index 5b1af54a4650..0ee90316bd33 100644 --- a/sdk/resourcemanager/kusto/armkusto/sandboxcustomimages_client.go +++ b/sdk/resourcemanager/kusto/armkusto/sandboxcustomimages_client.go @@ -32,7 +32,7 @@ type SandboxCustomImagesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSandboxCustomImagesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SandboxCustomImagesClient, error) { - cl, err := arm.NewClient(moduleName+".SandboxCustomImagesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,6 +54,10 @@ func NewSandboxCustomImagesClient(subscriptionID string, credential azcore.Token // method. func (client *SandboxCustomImagesClient) CheckNameAvailability(ctx context.Context, resourceGroupName string, clusterName string, resourceName SandboxCustomImagesCheckNameRequest, options *SandboxCustomImagesClientCheckNameAvailabilityOptions) (SandboxCustomImagesClientCheckNameAvailabilityResponse, error) { var err error + const operationName = "SandboxCustomImagesClient.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, resourceGroupName, clusterName, resourceName, options) if err != nil { return SandboxCustomImagesClientCheckNameAvailabilityResponse{}, err @@ -124,10 +128,14 @@ func (client *SandboxCustomImagesClient) BeginCreateOrUpdate(ctx context.Context if err != nil { return nil, err } - poller, err := runtime.NewPoller[SandboxCustomImagesClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SandboxCustomImagesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[SandboxCustomImagesClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SandboxCustomImagesClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -137,6 +145,10 @@ func (client *SandboxCustomImagesClient) BeginCreateOrUpdate(ctx context.Context // Generated from API version 2023-08-15 func (client *SandboxCustomImagesClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, sandboxCustomImageName string, parameters SandboxCustomImage, options *SandboxCustomImagesClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error + const operationName = "SandboxCustomImagesClient.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, clusterName, sandboxCustomImageName, parameters, options) if err != nil { return nil, err @@ -200,10 +212,14 @@ func (client *SandboxCustomImagesClient) BeginDelete(ctx context.Context, resour if err != nil { return nil, err } - poller, err := runtime.NewPoller[SandboxCustomImagesClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SandboxCustomImagesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[SandboxCustomImagesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SandboxCustomImagesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -213,6 +229,10 @@ func (client *SandboxCustomImagesClient) BeginDelete(ctx context.Context, resour // Generated from API version 2023-08-15 func (client *SandboxCustomImagesClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, sandboxCustomImageName string, options *SandboxCustomImagesClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "SandboxCustomImagesClient.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, clusterName, sandboxCustomImageName, options) if err != nil { return nil, err @@ -268,6 +288,10 @@ func (client *SandboxCustomImagesClient) deleteCreateRequest(ctx context.Context // - options - SandboxCustomImagesClientGetOptions contains the optional parameters for the SandboxCustomImagesClient.Get method. func (client *SandboxCustomImagesClient) Get(ctx context.Context, resourceGroupName string, clusterName string, sandboxCustomImageName string, options *SandboxCustomImagesClientGetOptions) (SandboxCustomImagesClientGetResponse, error) { var err error + const operationName = "SandboxCustomImagesClient.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, clusterName, sandboxCustomImageName, options) if err != nil { return SandboxCustomImagesClientGetResponse{}, err @@ -336,6 +360,7 @@ func (client *SandboxCustomImagesClient) NewListByClusterPager(resourceGroupName return false }, Fetcher: func(ctx context.Context, page *SandboxCustomImagesClientListByClusterResponse) (SandboxCustomImagesClientListByClusterResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SandboxCustomImagesClient.NewListByClusterPager") req, err := client.listByClusterCreateRequest(ctx, resourceGroupName, clusterName, options) if err != nil { return SandboxCustomImagesClientListByClusterResponse{}, err @@ -349,6 +374,7 @@ func (client *SandboxCustomImagesClient) NewListByClusterPager(resourceGroupName } return client.listByClusterHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -403,10 +429,14 @@ func (client *SandboxCustomImagesClient) BeginUpdate(ctx context.Context, resour if err != nil { return nil, err } - poller, err := runtime.NewPoller[SandboxCustomImagesClientUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SandboxCustomImagesClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[SandboxCustomImagesClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SandboxCustomImagesClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -416,6 +446,10 @@ func (client *SandboxCustomImagesClient) BeginUpdate(ctx context.Context, resour // Generated from API version 2023-08-15 func (client *SandboxCustomImagesClient) update(ctx context.Context, resourceGroupName string, clusterName string, sandboxCustomImageName string, parameters SandboxCustomImage, options *SandboxCustomImagesClientBeginUpdateOptions) (*http.Response, error) { var err error + const operationName = "SandboxCustomImagesClient.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, clusterName, sandboxCustomImageName, parameters, options) if err != nil { return nil, err diff --git a/sdk/resourcemanager/kusto/armkusto/scripts_client.go b/sdk/resourcemanager/kusto/armkusto/scripts_client.go index 4ea0095bda44..54062863dbf7 100644 --- a/sdk/resourcemanager/kusto/armkusto/scripts_client.go +++ b/sdk/resourcemanager/kusto/armkusto/scripts_client.go @@ -32,7 +32,7 @@ type ScriptsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewScriptsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ScriptsClient, error) { - cl, err := arm.NewClient(moduleName+".ScriptsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,6 +55,10 @@ func NewScriptsClient(subscriptionID string, credential azcore.TokenCredential, // method. func (client *ScriptsClient) CheckNameAvailability(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName ScriptCheckNameRequest, options *ScriptsClientCheckNameAvailabilityOptions) (ScriptsClientCheckNameAvailabilityResponse, error) { var err error + const operationName = "ScriptsClient.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, resourceGroupName, clusterName, databaseName, scriptName, options) if err != nil { return ScriptsClientCheckNameAvailabilityResponse{}, err @@ -130,10 +134,14 @@ func (client *ScriptsClient) BeginCreateOrUpdate(ctx context.Context, resourceGr if err != nil { return nil, err } - poller, err := runtime.NewPoller[ScriptsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ScriptsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ScriptsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ScriptsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -143,6 +151,10 @@ func (client *ScriptsClient) BeginCreateOrUpdate(ctx context.Context, resourceGr // Generated from API version 2023-08-15 func (client *ScriptsClient) createOrUpdate(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, parameters Script, options *ScriptsClientBeginCreateOrUpdateOptions) (*http.Response, error) { var err error + const operationName = "ScriptsClient.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, clusterName, databaseName, scriptName, parameters, options) if err != nil { return nil, err @@ -210,10 +222,14 @@ func (client *ScriptsClient) BeginDelete(ctx context.Context, resourceGroupName if err != nil { return nil, err } - poller, err := runtime.NewPoller[ScriptsClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ScriptsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ScriptsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ScriptsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -223,6 +239,10 @@ func (client *ScriptsClient) BeginDelete(ctx context.Context, resourceGroupName // Generated from API version 2023-08-15 func (client *ScriptsClient) deleteOperation(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, options *ScriptsClientBeginDeleteOptions) (*http.Response, error) { var err error + const operationName = "ScriptsClient.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, clusterName, databaseName, scriptName, options) if err != nil { return nil, err @@ -283,6 +303,10 @@ func (client *ScriptsClient) deleteCreateRequest(ctx context.Context, resourceGr // - options - ScriptsClientGetOptions contains the optional parameters for the ScriptsClient.Get method. func (client *ScriptsClient) Get(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, options *ScriptsClientGetOptions) (ScriptsClientGetResponse, error) { var err error + const operationName = "ScriptsClient.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, clusterName, databaseName, scriptName, options) if err != nil { return ScriptsClientGetResponse{}, err @@ -356,6 +380,7 @@ func (client *ScriptsClient) NewListByDatabasePager(resourceGroupName string, cl return false }, Fetcher: func(ctx context.Context, page *ScriptsClientListByDatabaseResponse) (ScriptsClientListByDatabaseResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ScriptsClient.NewListByDatabasePager") req, err := client.listByDatabaseCreateRequest(ctx, resourceGroupName, clusterName, databaseName, options) if err != nil { return ScriptsClientListByDatabaseResponse{}, err @@ -369,6 +394,7 @@ func (client *ScriptsClient) NewListByDatabasePager(resourceGroupName string, cl } return client.listByDatabaseHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -427,10 +453,14 @@ func (client *ScriptsClient) BeginUpdate(ctx context.Context, resourceGroupName if err != nil { return nil, err } - poller, err := runtime.NewPoller[ScriptsClientUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[ScriptsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) return poller, err } else { - return runtime.NewPollerFromResumeToken[ScriptsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[ScriptsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -440,6 +470,10 @@ func (client *ScriptsClient) BeginUpdate(ctx context.Context, resourceGroupName // Generated from API version 2023-08-15 func (client *ScriptsClient) update(ctx context.Context, resourceGroupName string, clusterName string, databaseName string, scriptName string, parameters Script, options *ScriptsClientBeginUpdateOptions) (*http.Response, error) { var err error + const operationName = "ScriptsClient.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, clusterName, databaseName, scriptName, parameters, options) if err != nil { return nil, err diff --git a/sdk/resourcemanager/kusto/armkusto/scripts_client_example_test.go b/sdk/resourcemanager/kusto/armkusto/scripts_client_example_test.go index 463bb4ffa3e1..c75072c4e861 100644 --- a/sdk/resourcemanager/kusto/armkusto/scripts_client_example_test.go +++ b/sdk/resourcemanager/kusto/armkusto/scripts_client_example_test.go @@ -52,10 +52,10 @@ func ExampleScriptsClient_NewListByDatabasePager() { // ScriptURL: to.Ptr("https://mysa.blob.core.windows.net/container/script.txt"), // }, // SystemData: &armkusto.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T15:06:54.2757906Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T15:06:54.275Z"); return t}()), // CreatedBy: to.Ptr("user@microsoft.com"), // CreatedByType: to.Ptr(armkusto.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T15:06:54.2757906Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T15:06:54.275Z"); return t}()), // LastModifiedBy: to.Ptr("user@microsoft.com"), // LastModifiedByType: to.Ptr(armkusto.CreatedByTypeUser), // }, @@ -70,10 +70,10 @@ func ExampleScriptsClient_NewListByDatabasePager() { // ScriptURL: to.Ptr("https://mysa.blob.core.windows.net/container/script2.txt"), // }, // SystemData: &armkusto.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T15:06:54.2757906Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T15:06:54.275Z"); return t}()), // CreatedBy: to.Ptr("user@microsoft.com"), // CreatedByType: to.Ptr(armkusto.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-30T16:07:55.2831451Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-30T16:07:55.283Z"); return t}()), // LastModifiedBy: to.Ptr("user2@microsoft.com"), // LastModifiedByType: to.Ptr(armkusto.CreatedByTypeUser), // }, @@ -110,10 +110,10 @@ func ExampleScriptsClient_Get() { // ScriptURL: to.Ptr("https://mysa.blob.core.windows.net/container/script.txt"), // }, // SystemData: &armkusto.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T15:06:54.2757906Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T15:06:54.275Z"); return t}()), // CreatedBy: to.Ptr("user@microsoft.com"), // CreatedByType: to.Ptr(armkusto.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T15:06:54.2757906Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T15:06:54.275Z"); return t}()), // LastModifiedBy: to.Ptr("user@microsoft.com"), // LastModifiedByType: to.Ptr(armkusto.CreatedByTypeUser), // }, @@ -159,10 +159,10 @@ func ExampleScriptsClient_BeginCreateOrUpdate() { // ScriptURL: to.Ptr("https://mysa.blob.core.windows.net/container/script.txt"), // }, // SystemData: &armkusto.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T15:06:54.2757906Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T15:06:54.275Z"); return t}()), // CreatedBy: to.Ptr("user@microsoft.com"), // CreatedByType: to.Ptr(armkusto.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T17:16:24.3644126Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T17:16:24.364Z"); return t}()), // LastModifiedBy: to.Ptr("user2@microsoft.com"), // LastModifiedByType: to.Ptr(armkusto.CreatedByTypeUser), // }, @@ -208,10 +208,10 @@ func ExampleScriptsClient_BeginUpdate() { // ScriptURL: to.Ptr("https://mysa.blob.core.windows.net/container/script.txt"), // }, // SystemData: &armkusto.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T15:06:54.2757906Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-29T15:06:54.275Z"); return t}()), // CreatedBy: to.Ptr("user@microsoft.com"), // CreatedByType: to.Ptr(armkusto.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T17:16:24.3644126Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-07-01T17:16:24.364Z"); return t}()), // LastModifiedBy: to.Ptr("user2@microsoft.com"), // LastModifiedByType: to.Ptr(armkusto.CreatedByTypeUser), // }, diff --git a/sdk/resourcemanager/kusto/armkusto/skus_client.go b/sdk/resourcemanager/kusto/armkusto/skus_client.go index 72fd6c9b817c..61e3045d5e47 100644 --- a/sdk/resourcemanager/kusto/armkusto/skus_client.go +++ b/sdk/resourcemanager/kusto/armkusto/skus_client.go @@ -32,7 +32,7 @@ type SKUsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSKUsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SKUsClient, error) { - cl, err := arm.NewClient(moduleName+".SKUsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,6 +54,7 @@ func (client *SKUsClient) NewListPager(location string, options *SKUsClientListO return false }, Fetcher: func(ctx context.Context, page *SKUsClientListResponse) (SKUsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SKUsClient.NewListPager") req, err := client.listCreateRequest(ctx, location, options) if err != nil { return SKUsClientListResponse{}, err @@ -67,6 +68,7 @@ func (client *SKUsClient) NewListPager(location string, options *SKUsClientListO } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/kusto/armkusto/time_rfc3339.go b/sdk/resourcemanager/kusto/armkusto/time_rfc3339.go index 4f68b299feae..4dc5d1d956eb 100644 --- a/sdk/resourcemanager/kusto/armkusto/time_rfc3339.go +++ b/sdk/resourcemanager/kusto/armkusto/time_rfc3339.go @@ -18,50 +18,50 @@ import ( "time" ) -const ( - utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` - utcLayout = "2006-01-02T15:04:05.999999999" - rfc3339JSON = `"` + time.RFC3339Nano + `"` -) - // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) -type timeRFC3339 time.Time +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time -func (t timeRFC3339) MarshalJSON() (json []byte, err error) { +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { tt := time.Time(t) return tt.MarshalJSON() } -func (t timeRFC3339) MarshalText() (text []byte, err error) { +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { tt := time.Time(t) return tt.MarshalText() } -func (t *timeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcLayoutJSON +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON if tzOffsetRegex.Match(data) { - layout = rfc3339JSON + layout = dateTimeJSON } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { - layout := utcLayout +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime if tzOffsetRegex.Match(data) { layout = time.RFC3339Nano } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) Parse(layout, value string) error { +func (t *dateTimeRFC3339) Parse(layout, value string) error { p, err := time.Parse(layout, strings.ToUpper(value)) - *t = timeRFC3339(p) + *t = dateTimeRFC3339(p) return err } -func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { @@ -70,14 +70,14 @@ func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { } else if reflect.ValueOf(t).IsNil() { return } - m[k] = (*timeRFC3339)(t) + m[k] = (*dateTimeRFC3339)(t) } -func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { if data == nil || strings.EqualFold(string(data), "null") { return nil } - var aux timeRFC3339 + var aux dateTimeRFC3339 if err := json.Unmarshal(data, &aux); err != nil { return fmt.Errorf("struct field %s: %v", fn, err) } diff --git a/sdk/resourcemanager/labservices/armlabservices/CHANGELOG.md b/sdk/resourcemanager/labservices/armlabservices/CHANGELOG.md index b29596b5cdad..4279fe74f95f 100644 --- a/sdk/resourcemanager/labservices/armlabservices/CHANGELOG.md +++ b/sdk/resourcemanager/labservices/armlabservices/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.2.0 (2023-11-24) +### Features Added + +- Support for test fakes and OpenTelemetry trace spans. + + ## 1.1.1 (2023-04-14) ### Bug Fixes diff --git a/sdk/resourcemanager/labservices/armlabservices/README.md b/sdk/resourcemanager/labservices/armlabservices/README.md index e88a8a81d81a..bb0a46d66cb4 100644 --- a/sdk/resourcemanager/labservices/armlabservices/README.md +++ b/sdk/resourcemanager/labservices/armlabservices/README.md @@ -60,6 +60,13 @@ A client groups a set of related APIs, providing access to its functionality. C client := clientFactory.NewLabPlansClient() ``` +## 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 diff --git a/sdk/resourcemanager/labservices/armlabservices/autorest.md b/sdk/resourcemanager/labservices/armlabservices/autorest.md index 4a33bb4f7f7c..e347767a0768 100644 --- a/sdk/resourcemanager/labservices/armlabservices/autorest.md +++ b/sdk/resourcemanager/labservices/armlabservices/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/4c2cdccf6ca3281dd50ed8788ce1de2e0d480973/specification/labservices/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/4c2cdccf6ca3281dd50ed8788ce1de2e0d480973/specification/labservices/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.1.1 +module-version: 1.2.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/labservices/armlabservices/client_factory.go b/sdk/resourcemanager/labservices/armlabservices/client_factory.go index d36b60aa74b3..b427dd72f2e9 100644 --- a/sdk/resourcemanager/labservices/armlabservices/client_factory.go +++ b/sdk/resourcemanager/labservices/armlabservices/client_factory.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlabservices @@ -28,7 +27,7 @@ type ClientFactory struct { // - 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+".ClientFactory", moduleVersion, credential, options) + _, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -38,51 +37,61 @@ func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, }, nil } +// NewImagesClient creates a new instance of ImagesClient. func (c *ClientFactory) NewImagesClient() *ImagesClient { subClient, _ := NewImagesClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewLabPlansClient creates a new instance of LabPlansClient. func (c *ClientFactory) NewLabPlansClient() *LabPlansClient { subClient, _ := NewLabPlansClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) - return subClient -} - +// NewLabsClient creates a new instance of LabsClient. func (c *ClientFactory) NewLabsClient() *LabsClient { subClient, _ := NewLabsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewOperationResultsClient creates a new instance of OperationResultsClient. func (c *ClientFactory) NewOperationResultsClient() *OperationResultsClient { subClient, _ := NewOperationResultsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewSchedulesClient() *SchedulesClient { - subClient, _ := NewSchedulesClient(c.subscriptionID, c.credential, c.options) +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) return subClient } +// NewSKUsClient creates a new instance of SKUsClient. func (c *ClientFactory) NewSKUsClient() *SKUsClient { subClient, _ := NewSKUsClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewSchedulesClient creates a new instance of SchedulesClient. +func (c *ClientFactory) NewSchedulesClient() *SchedulesClient { + subClient, _ := NewSchedulesClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +// NewUsagesClient creates a new instance of UsagesClient. func (c *ClientFactory) NewUsagesClient() *UsagesClient { subClient, _ := NewUsagesClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewUsersClient creates a new instance of UsersClient. func (c *ClientFactory) NewUsersClient() *UsersClient { subClient, _ := NewUsersClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewVirtualMachinesClient creates a new instance of VirtualMachinesClient. func (c *ClientFactory) NewVirtualMachinesClient() *VirtualMachinesClient { subClient, _ := NewVirtualMachinesClient(c.subscriptionID, c.credential, c.options) return subClient diff --git a/sdk/resourcemanager/labservices/armlabservices/constants.go b/sdk/resourcemanager/labservices/armlabservices/constants.go index 362703c16a4e..9fe19086c3bd 100644 --- a/sdk/resourcemanager/labservices/armlabservices/constants.go +++ b/sdk/resourcemanager/labservices/armlabservices/constants.go @@ -3,15 +3,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlabservices const ( - moduleName = "armlabservices" - moduleVersion = "v1.1.1" + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/labservices/armlabservices" + moduleVersion = "v1.2.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. @@ -32,17 +31,17 @@ func PossibleActionTypeValues() []ActionType { type ConnectionType string const ( - ConnectionTypePublic ConnectionType = "Public" - ConnectionTypePrivate ConnectionType = "Private" ConnectionTypeNone ConnectionType = "None" + ConnectionTypePrivate ConnectionType = "Private" + ConnectionTypePublic ConnectionType = "Public" ) // PossibleConnectionTypeValues returns the possible values for the ConnectionType const type. func PossibleConnectionTypeValues() []ConnectionType { return []ConnectionType{ - ConnectionTypePublic, - ConnectionTypePrivate, ConnectionTypeNone, + ConnectionTypePrivate, + ConnectionTypePublic, } } @@ -89,15 +88,15 @@ func PossibleCreatedByTypeValues() []CreatedByType { type EnableState string const ( - EnableStateEnabled EnableState = "Enabled" EnableStateDisabled EnableState = "Disabled" + EnableStateEnabled EnableState = "Enabled" ) // PossibleEnableStateValues returns the possible values for the EnableState const type. func PossibleEnableStateValues() []EnableState { return []EnableState{ - EnableStateEnabled, EnableStateDisabled, + EnableStateEnabled, } } @@ -105,23 +104,23 @@ func PossibleEnableStateValues() []EnableState { type InvitationState string const ( + // InvitationStateFailed - There was an error while sending the invitation. + InvitationStateFailed InvitationState = "Failed" // InvitationStateNotSent - The invitation has not been sent. InvitationStateNotSent InvitationState = "NotSent" // InvitationStateSending - Currently sending the invitation. InvitationStateSending InvitationState = "Sending" // InvitationStateSent - The invitation has been successfully sent. InvitationStateSent InvitationState = "Sent" - // InvitationStateFailed - There was an error while sending the invitation. - InvitationStateFailed InvitationState = "Failed" ) // PossibleInvitationStateValues returns the possible values for the InvitationState const type. func PossibleInvitationStateValues() []InvitationState { return []InvitationState{ + InvitationStateFailed, InvitationStateNotSent, InvitationStateSending, InvitationStateSent, - InvitationStateFailed, } } @@ -147,24 +146,24 @@ type LabState string const ( // LabStateDraft - The lab is currently in draft (has not been published). LabStateDraft LabState = "Draft" + // LabStatePublished - The lab has been published. + LabStatePublished LabState = "Published" // LabStatePublishing - The lab is publishing. LabStatePublishing LabState = "Publishing" // LabStateScaling - The lab is scaling. LabStateScaling LabState = "Scaling" // LabStateSyncing - The lab is syncing users. LabStateSyncing LabState = "Syncing" - // LabStatePublished - The lab has been published. - LabStatePublished LabState = "Published" ) // PossibleLabStateValues returns the possible values for the LabState const type. func PossibleLabStateValues() []LabState { return []LabState{ LabStateDraft, + LabStatePublished, LabStatePublishing, LabStateScaling, LabStateSyncing, - LabStatePublished, } } @@ -172,26 +171,26 @@ func PossibleLabStateValues() []LabState { type OperationStatus string const ( - // OperationStatusNotStarted - The operation has been accepted but hasn't started. - OperationStatusNotStarted OperationStatus = "NotStarted" + // OperationStatusCanceled - Not supported yet + OperationStatusCanceled OperationStatus = "Canceled" + // OperationStatusFailed - The operation failed + OperationStatusFailed OperationStatus = "Failed" // OperationStatusInProgress - The operation is running OperationStatusInProgress OperationStatus = "InProgress" + // OperationStatusNotStarted - The operation has been accepted but hasn't started. + OperationStatusNotStarted OperationStatus = "NotStarted" // OperationStatusSucceeded - The operation Succeeded OperationStatusSucceeded OperationStatus = "Succeeded" - // OperationStatusFailed - The operation failed - OperationStatusFailed OperationStatus = "Failed" - // OperationStatusCanceled - Not supported yet - OperationStatusCanceled OperationStatus = "Canceled" ) // PossibleOperationStatusValues returns the possible values for the OperationStatus const type. func PossibleOperationStatusValues() []OperationStatus { return []OperationStatus{ - OperationStatusNotStarted, + OperationStatusCanceled, + OperationStatusFailed, OperationStatusInProgress, + OperationStatusNotStarted, OperationStatusSucceeded, - OperationStatusFailed, - OperationStatusCanceled, } } @@ -236,15 +235,15 @@ func PossibleOsStateValues() []OsState { type OsType string const ( - OsTypeWindows OsType = "Windows" OsTypeLinux OsType = "Linux" + OsTypeWindows OsType = "Windows" ) // PossibleOsTypeValues returns the possible values for the OsType const type. func PossibleOsTypeValues() []OsType { return []OsType{ - OsTypeWindows, OsTypeLinux, + OsTypeWindows, } } @@ -254,28 +253,28 @@ type ProvisioningState string const ( // ProvisioningStateCreating - Resource is in the process of being created. ProvisioningStateCreating ProvisioningState = "Creating" - // ProvisioningStateUpdating - New property values are being applied to the resource. - ProvisioningStateUpdating ProvisioningState = "Updating" // ProvisioningStateDeleting - Resource is in the process of being deleted. ProvisioningStateDeleting ProvisioningState = "Deleting" - // ProvisioningStateSucceeded - Resource is in healthy state after creation or update operation. - ProvisioningStateSucceeded ProvisioningState = "Succeeded" // ProvisioningStateFailed - Previous operation on the resource has failed leaving resource in unhealthy state. ProvisioningStateFailed ProvisioningState = "Failed" // ProvisioningStateLocked - The resource is locked and changes are currently blocked. This could be due to maintenance or // a scheduled operation. The state will go back to succeeded once the locking operation has finished. ProvisioningStateLocked ProvisioningState = "Locked" + // ProvisioningStateSucceeded - Resource is in healthy state after creation or update operation. + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating - New property values are being applied to the resource. + ProvisioningStateUpdating ProvisioningState = "Updating" ) // PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. func PossibleProvisioningStateValues() []ProvisioningState { return []ProvisioningState{ ProvisioningStateCreating, - ProvisioningStateUpdating, ProvisioningStateDeleting, - ProvisioningStateSucceeded, ProvisioningStateFailed, ProvisioningStateLocked, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, } } @@ -301,17 +300,17 @@ func PossibleRecurrenceFrequencyValues() []RecurrenceFrequency { type RegistrationState string const ( - // RegistrationStateRegistered - User has not yet registered with the lab. - RegistrationStateRegistered RegistrationState = "Registered" // RegistrationStateNotRegistered - User has registered with the lab. RegistrationStateNotRegistered RegistrationState = "NotRegistered" + // RegistrationStateRegistered - User has not yet registered with the lab. + RegistrationStateRegistered RegistrationState = "Registered" ) // PossibleRegistrationStateValues returns the possible values for the RegistrationState const type. func PossibleRegistrationStateValues() []RegistrationState { return []RegistrationState{ - RegistrationStateRegistered, RegistrationStateNotRegistered, + RegistrationStateRegistered, } } @@ -350,19 +349,19 @@ func PossibleRestrictionTypeValues() []RestrictionType { type SKUTier string const ( - SKUTierFree SKUTier = "Free" SKUTierBasic SKUTier = "Basic" - SKUTierStandard SKUTier = "Standard" + SKUTierFree SKUTier = "Free" SKUTierPremium SKUTier = "Premium" + SKUTierStandard SKUTier = "Standard" ) // PossibleSKUTierValues returns the possible values for the SKUTier const type. func PossibleSKUTierValues() []SKUTier { return []SKUTier{ - SKUTierFree, SKUTierBasic, - SKUTierStandard, + SKUTierFree, SKUTierPremium, + SKUTierStandard, } } @@ -391,21 +390,21 @@ func PossibleScaleTypeValues() []ScaleType { type ShutdownOnIdleMode string const ( + // ShutdownOnIdleModeLowUsage - The VM will be considered as idle when user is absent and the resource (CPU and disk) consumption + // is low. + ShutdownOnIdleModeLowUsage ShutdownOnIdleMode = "LowUsage" // ShutdownOnIdleModeNone - The VM won't be shut down when it is idle. ShutdownOnIdleModeNone ShutdownOnIdleMode = "None" // ShutdownOnIdleModeUserAbsence - The VM will be considered as idle when there is no keyboard or mouse input. ShutdownOnIdleModeUserAbsence ShutdownOnIdleMode = "UserAbsence" - // ShutdownOnIdleModeLowUsage - The VM will be considered as idle when user is absent and the resource (CPU and disk) consumption - // is low. - ShutdownOnIdleModeLowUsage ShutdownOnIdleMode = "LowUsage" ) // PossibleShutdownOnIdleModeValues returns the possible values for the ShutdownOnIdleMode const type. func PossibleShutdownOnIdleModeValues() []ShutdownOnIdleMode { return []ShutdownOnIdleMode{ + ShutdownOnIdleModeLowUsage, ShutdownOnIdleModeNone, ShutdownOnIdleModeUserAbsence, - ShutdownOnIdleModeLowUsage, } } @@ -427,32 +426,32 @@ func PossibleUsageUnitValues() []UsageUnit { type VirtualMachineState string const ( - // VirtualMachineStateStopped - The VM is currently stopped. - VirtualMachineStateStopped VirtualMachineState = "Stopped" - // VirtualMachineStateStarting - The VM is starting. - VirtualMachineStateStarting VirtualMachineState = "Starting" + // VirtualMachineStateRedeploying - The VM is being redeployed. + VirtualMachineStateRedeploying VirtualMachineState = "Redeploying" + // VirtualMachineStateReimaging - The VM is being reimaged. + VirtualMachineStateReimaging VirtualMachineState = "Reimaging" + // VirtualMachineStateResettingPassword - The VM password is being reset. + VirtualMachineStateResettingPassword VirtualMachineState = "ResettingPassword" // VirtualMachineStateRunning - The VM is running. VirtualMachineStateRunning VirtualMachineState = "Running" + // VirtualMachineStateStarting - The VM is starting. + VirtualMachineStateStarting VirtualMachineState = "Starting" + // VirtualMachineStateStopped - The VM is currently stopped. + VirtualMachineStateStopped VirtualMachineState = "Stopped" // VirtualMachineStateStopping - The VM is stopping. VirtualMachineStateStopping VirtualMachineState = "Stopping" - // VirtualMachineStateResettingPassword - The VM password is being reset. - VirtualMachineStateResettingPassword VirtualMachineState = "ResettingPassword" - // VirtualMachineStateReimaging - The VM is being reimaged. - VirtualMachineStateReimaging VirtualMachineState = "Reimaging" - // VirtualMachineStateRedeploying - The VM is being redeployed. - VirtualMachineStateRedeploying VirtualMachineState = "Redeploying" ) // PossibleVirtualMachineStateValues returns the possible values for the VirtualMachineState const type. func PossibleVirtualMachineStateValues() []VirtualMachineState { return []VirtualMachineState{ - VirtualMachineStateStopped, - VirtualMachineStateStarting, + VirtualMachineStateRedeploying, + VirtualMachineStateReimaging, + VirtualMachineStateResettingPassword, VirtualMachineStateRunning, + VirtualMachineStateStarting, + VirtualMachineStateStopped, VirtualMachineStateStopping, - VirtualMachineStateResettingPassword, - VirtualMachineStateReimaging, - VirtualMachineStateRedeploying, } } @@ -460,17 +459,17 @@ func PossibleVirtualMachineStateValues() []VirtualMachineState { type VirtualMachineType string const ( - // VirtualMachineTypeUser - A user VM - VirtualMachineTypeUser VirtualMachineType = "User" // VirtualMachineTypeTemplate - A template VM VirtualMachineTypeTemplate VirtualMachineType = "Template" + // VirtualMachineTypeUser - A user VM + VirtualMachineTypeUser VirtualMachineType = "User" ) // PossibleVirtualMachineTypeValues returns the possible values for the VirtualMachineType const type. func PossibleVirtualMachineTypeValues() []VirtualMachineType { return []VirtualMachineType{ - VirtualMachineTypeUser, VirtualMachineTypeTemplate, + VirtualMachineTypeUser, } } @@ -478,31 +477,31 @@ func PossibleVirtualMachineTypeValues() []VirtualMachineType { type WeekDay string const ( - // WeekDaySunday - Schedule will run on Sunday - WeekDaySunday WeekDay = "Sunday" + // WeekDayFriday - Schedule will run on Friday + WeekDayFriday WeekDay = "Friday" // WeekDayMonday - Schedule will run on Monday WeekDayMonday WeekDay = "Monday" + // WeekDaySaturday - Schedule will run on Saturday + WeekDaySaturday WeekDay = "Saturday" + // WeekDaySunday - Schedule will run on Sunday + WeekDaySunday WeekDay = "Sunday" + // WeekDayThursday - Schedule will run on Thursday + WeekDayThursday WeekDay = "Thursday" // WeekDayTuesday - Schedule will run on Tuesday WeekDayTuesday WeekDay = "Tuesday" // WeekDayWednesday - Schedule will run on Wednesday WeekDayWednesday WeekDay = "Wednesday" - // WeekDayThursday - Schedule will run on Thursday - WeekDayThursday WeekDay = "Thursday" - // WeekDayFriday - Schedule will run on Friday - WeekDayFriday WeekDay = "Friday" - // WeekDaySaturday - Schedule will run on Saturday - WeekDaySaturday WeekDay = "Saturday" ) // PossibleWeekDayValues returns the possible values for the WeekDay const type. func PossibleWeekDayValues() []WeekDay { return []WeekDay{ - WeekDaySunday, + WeekDayFriday, WeekDayMonday, + WeekDaySaturday, + WeekDaySunday, + WeekDayThursday, WeekDayTuesday, WeekDayWednesday, - WeekDayThursday, - WeekDayFriday, - WeekDaySaturday, } } diff --git a/sdk/resourcemanager/labservices/armlabservices/fake/images_server.go b/sdk/resourcemanager/labservices/armlabservices/fake/images_server.go new file mode 100644 index 000000000000..da51faee21ae --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/fake/images_server.go @@ -0,0 +1,262 @@ +//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/labservices/armlabservices" + "net/http" + "net/url" + "regexp" +) + +// ImagesServer is a fake server for instances of the armlabservices.ImagesClient type. +type ImagesServer struct { + // CreateOrUpdate is the fake for method ImagesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK + CreateOrUpdate func(ctx context.Context, resourceGroupName string, labPlanName string, imageName string, body armlabservices.Image, options *armlabservices.ImagesClientCreateOrUpdateOptions) (resp azfake.Responder[armlabservices.ImagesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method ImagesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, labPlanName string, imageName string, options *armlabservices.ImagesClientGetOptions) (resp azfake.Responder[armlabservices.ImagesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByLabPlanPager is the fake for method ImagesClient.NewListByLabPlanPager + // HTTP status codes to indicate success: http.StatusOK + NewListByLabPlanPager func(resourceGroupName string, labPlanName string, options *armlabservices.ImagesClientListByLabPlanOptions) (resp azfake.PagerResponder[armlabservices.ImagesClientListByLabPlanResponse]) + + // Update is the fake for method ImagesClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, labPlanName string, imageName string, body armlabservices.ImageUpdate, options *armlabservices.ImagesClientUpdateOptions) (resp azfake.Responder[armlabservices.ImagesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewImagesServerTransport creates a new instance of ImagesServerTransport with the provided implementation. +// The returned ImagesServerTransport instance is connected to an instance of armlabservices.ImagesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewImagesServerTransport(srv *ImagesServer) *ImagesServerTransport { + return &ImagesServerTransport{ + srv: srv, + newListByLabPlanPager: newTracker[azfake.PagerResponder[armlabservices.ImagesClientListByLabPlanResponse]](), + } +} + +// ImagesServerTransport connects instances of armlabservices.ImagesClient to instances of ImagesServer. +// Don't use this type directly, use NewImagesServerTransport instead. +type ImagesServerTransport struct { + srv *ImagesServer + newListByLabPlanPager *tracker[azfake.PagerResponder[armlabservices.ImagesClientListByLabPlanResponse]] +} + +// Do implements the policy.Transporter interface for ImagesServerTransport. +func (i *ImagesServerTransport) 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 "ImagesClient.CreateOrUpdate": + resp, err = i.dispatchCreateOrUpdate(req) + case "ImagesClient.Get": + resp, err = i.dispatchGet(req) + case "ImagesClient.NewListByLabPlanPager": + resp, err = i.dispatchNewListByLabPlanPager(req) + case "ImagesClient.Update": + resp, err = i.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (i *ImagesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if i.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labPlans/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/images/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlabservices.Image](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + labPlanNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labPlanName")]) + if err != nil { + return nil, err + } + imageNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("imageName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, labPlanNameParam, imageNameParam, 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).Image, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *ImagesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if i.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\.LabServices/labPlans/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/images/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + labPlanNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labPlanName")]) + if err != nil { + return nil, err + } + imageNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("imageName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Get(req.Context(), resourceGroupNameParam, labPlanNameParam, imageNameParam, 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).Image, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *ImagesServerTransport) dispatchNewListByLabPlanPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListByLabPlanPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByLabPlanPager not implemented")} + } + newListByLabPlanPager := i.newListByLabPlanPager.get(req) + if newListByLabPlanPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labPlans/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/images` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + labPlanNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labPlanName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlabservices.ImagesClientListByLabPlanOptions + if filterParam != nil { + options = &armlabservices.ImagesClientListByLabPlanOptions{ + Filter: filterParam, + } + } + resp := i.srv.NewListByLabPlanPager(resourceGroupNameParam, labPlanNameParam, options) + newListByLabPlanPager = &resp + i.newListByLabPlanPager.add(req, newListByLabPlanPager) + server.PagerResponderInjectNextLinks(newListByLabPlanPager, req, func(page *armlabservices.ImagesClientListByLabPlanResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByLabPlanPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + i.newListByLabPlanPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByLabPlanPager) { + i.newListByLabPlanPager.remove(req) + } + return resp, nil +} + +func (i *ImagesServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if i.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\.LabServices/labPlans/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/images/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlabservices.ImageUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + labPlanNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labPlanName")]) + if err != nil { + return nil, err + } + imageNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("imageName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Update(req.Context(), resourceGroupNameParam, labPlanNameParam, imageNameParam, 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).Image, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/labservices/armlabservices/fake/internal.go b/sdk/resourcemanager/labservices/armlabservices/fake/internal.go new file mode 100644 index 000000000000..94e060e89dbd --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/fake/internal.go @@ -0,0 +1,72 @@ +//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 ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "reflect" + "sync" +) + +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 getOptional[T any](v T) *T { + if reflect.ValueOf(v).IsZero() { + return nil + } + return &v +} + +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/labservices/armlabservices/fake/labplans_server.go b/sdk/resourcemanager/labservices/armlabservices/fake/labplans_server.go new file mode 100644 index 000000000000..ac8ac2dbfc02 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/fake/labplans_server.go @@ -0,0 +1,421 @@ +//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/labservices/armlabservices" + "net/http" + "net/url" + "regexp" +) + +// LabPlansServer is a fake server for instances of the armlabservices.LabPlansClient type. +type LabPlansServer struct { + // BeginCreateOrUpdate is the fake for method LabPlansClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, labPlanName string, body armlabservices.LabPlan, options *armlabservices.LabPlansClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armlabservices.LabPlansClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method LabPlansClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, labPlanName string, options *armlabservices.LabPlansClientBeginDeleteOptions) (resp azfake.PollerResponder[armlabservices.LabPlansClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method LabPlansClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, labPlanName string, options *armlabservices.LabPlansClientGetOptions) (resp azfake.Responder[armlabservices.LabPlansClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method LabPlansClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armlabservices.LabPlansClientListByResourceGroupOptions) (resp azfake.PagerResponder[armlabservices.LabPlansClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method LabPlansClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armlabservices.LabPlansClientListBySubscriptionOptions) (resp azfake.PagerResponder[armlabservices.LabPlansClientListBySubscriptionResponse]) + + // BeginSaveImage is the fake for method LabPlansClient.BeginSaveImage + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginSaveImage func(ctx context.Context, resourceGroupName string, labPlanName string, body armlabservices.SaveImageBody, options *armlabservices.LabPlansClientBeginSaveImageOptions) (resp azfake.PollerResponder[armlabservices.LabPlansClientSaveImageResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method LabPlansClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, labPlanName string, body armlabservices.LabPlanUpdate, options *armlabservices.LabPlansClientBeginUpdateOptions) (resp azfake.PollerResponder[armlabservices.LabPlansClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewLabPlansServerTransport creates a new instance of LabPlansServerTransport with the provided implementation. +// The returned LabPlansServerTransport instance is connected to an instance of armlabservices.LabPlansClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewLabPlansServerTransport(srv *LabPlansServer) *LabPlansServerTransport { + return &LabPlansServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armlabservices.LabPlansClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armlabservices.LabPlansClientDeleteResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armlabservices.LabPlansClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armlabservices.LabPlansClientListBySubscriptionResponse]](), + beginSaveImage: newTracker[azfake.PollerResponder[armlabservices.LabPlansClientSaveImageResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armlabservices.LabPlansClientUpdateResponse]](), + } +} + +// LabPlansServerTransport connects instances of armlabservices.LabPlansClient to instances of LabPlansServer. +// Don't use this type directly, use NewLabPlansServerTransport instead. +type LabPlansServerTransport struct { + srv *LabPlansServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armlabservices.LabPlansClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armlabservices.LabPlansClientDeleteResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armlabservices.LabPlansClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armlabservices.LabPlansClientListBySubscriptionResponse]] + beginSaveImage *tracker[azfake.PollerResponder[armlabservices.LabPlansClientSaveImageResponse]] + beginUpdate *tracker[azfake.PollerResponder[armlabservices.LabPlansClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for LabPlansServerTransport. +func (l *LabPlansServerTransport) 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 "LabPlansClient.BeginCreateOrUpdate": + resp, err = l.dispatchBeginCreateOrUpdate(req) + case "LabPlansClient.BeginDelete": + resp, err = l.dispatchBeginDelete(req) + case "LabPlansClient.Get": + resp, err = l.dispatchGet(req) + case "LabPlansClient.NewListByResourceGroupPager": + resp, err = l.dispatchNewListByResourceGroupPager(req) + case "LabPlansClient.NewListBySubscriptionPager": + resp, err = l.dispatchNewListBySubscriptionPager(req) + case "LabPlansClient.BeginSaveImage": + resp, err = l.dispatchBeginSaveImage(req) + case "LabPlansClient.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 *LabPlansServerTransport) 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\.LabServices/labPlans/(?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[armlabservices.LabPlan](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + labPlanNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labPlanName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, labPlanNameParam, 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, http.StatusAccepted}, resp.StatusCode) { + l.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + l.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (l *LabPlansServerTransport) 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\.LabServices/labPlans/(?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 + } + labPlanNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labPlanName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.BeginDelete(req.Context(), resourceGroupNameParam, labPlanNameParam, 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 *LabPlansServerTransport) 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\.LabServices/labPlans/(?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 + } + labPlanNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labPlanName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.Get(req.Context(), resourceGroupNameParam, labPlanNameParam, 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).LabPlan, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (l *LabPlansServerTransport) 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\.LabServices/labPlans` + 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 *armlabservices.LabPlansClientListByResourceGroupResponse, 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 *LabPlansServerTransport) 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\.LabServices/labPlans` + 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) + } + qp := req.URL.Query() + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlabservices.LabPlansClientListBySubscriptionOptions + if filterParam != nil { + options = &armlabservices.LabPlansClientListBySubscriptionOptions{ + Filter: filterParam, + } + } + resp := l.srv.NewListBySubscriptionPager(options) + newListBySubscriptionPager = &resp + l.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armlabservices.LabPlansClientListBySubscriptionResponse, 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 *LabPlansServerTransport) dispatchBeginSaveImage(req *http.Request) (*http.Response, error) { + if l.srv.BeginSaveImage == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginSaveImage not implemented")} + } + beginSaveImage := l.beginSaveImage.get(req) + if beginSaveImage == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labPlans/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/saveImage` + 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[armlabservices.SaveImageBody](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + labPlanNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labPlanName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.BeginSaveImage(req.Context(), resourceGroupNameParam, labPlanNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginSaveImage = &respr + l.beginSaveImage.add(req, beginSaveImage) + } + + resp, err := server.PollerResponderNext(beginSaveImage, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + l.beginSaveImage.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginSaveImage) { + l.beginSaveImage.remove(req) + } + + return resp, nil +} + +func (l *LabPlansServerTransport) 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\.LabServices/labPlans/(?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[armlabservices.LabPlanUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + labPlanNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labPlanName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.BeginUpdate(req.Context(), resourceGroupNameParam, labPlanNameParam, 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/labservices/armlabservices/fake/labs_server.go b/sdk/resourcemanager/labservices/armlabservices/fake/labs_server.go new file mode 100644 index 000000000000..9e4fae2567d7 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/fake/labs_server.go @@ -0,0 +1,469 @@ +//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/labservices/armlabservices" + "net/http" + "net/url" + "regexp" +) + +// LabsServer is a fake server for instances of the armlabservices.LabsClient type. +type LabsServer struct { + // BeginCreateOrUpdate is the fake for method LabsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, labName string, body armlabservices.Lab, options *armlabservices.LabsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armlabservices.LabsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method LabsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, labName string, options *armlabservices.LabsClientBeginDeleteOptions) (resp azfake.PollerResponder[armlabservices.LabsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method LabsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, labName string, options *armlabservices.LabsClientGetOptions) (resp azfake.Responder[armlabservices.LabsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method LabsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armlabservices.LabsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armlabservices.LabsClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method LabsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armlabservices.LabsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armlabservices.LabsClientListBySubscriptionResponse]) + + // BeginPublish is the fake for method LabsClient.BeginPublish + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginPublish func(ctx context.Context, resourceGroupName string, labName string, options *armlabservices.LabsClientBeginPublishOptions) (resp azfake.PollerResponder[armlabservices.LabsClientPublishResponse], errResp azfake.ErrorResponder) + + // BeginSyncGroup is the fake for method LabsClient.BeginSyncGroup + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginSyncGroup func(ctx context.Context, resourceGroupName string, labName string, options *armlabservices.LabsClientBeginSyncGroupOptions) (resp azfake.PollerResponder[armlabservices.LabsClientSyncGroupResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method LabsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, labName string, body armlabservices.LabUpdate, options *armlabservices.LabsClientBeginUpdateOptions) (resp azfake.PollerResponder[armlabservices.LabsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewLabsServerTransport creates a new instance of LabsServerTransport with the provided implementation. +// The returned LabsServerTransport instance is connected to an instance of armlabservices.LabsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewLabsServerTransport(srv *LabsServer) *LabsServerTransport { + return &LabsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armlabservices.LabsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armlabservices.LabsClientDeleteResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armlabservices.LabsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armlabservices.LabsClientListBySubscriptionResponse]](), + beginPublish: newTracker[azfake.PollerResponder[armlabservices.LabsClientPublishResponse]](), + beginSyncGroup: newTracker[azfake.PollerResponder[armlabservices.LabsClientSyncGroupResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armlabservices.LabsClientUpdateResponse]](), + } +} + +// LabsServerTransport connects instances of armlabservices.LabsClient to instances of LabsServer. +// Don't use this type directly, use NewLabsServerTransport instead. +type LabsServerTransport struct { + srv *LabsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armlabservices.LabsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armlabservices.LabsClientDeleteResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armlabservices.LabsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armlabservices.LabsClientListBySubscriptionResponse]] + beginPublish *tracker[azfake.PollerResponder[armlabservices.LabsClientPublishResponse]] + beginSyncGroup *tracker[azfake.PollerResponder[armlabservices.LabsClientSyncGroupResponse]] + beginUpdate *tracker[azfake.PollerResponder[armlabservices.LabsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for LabsServerTransport. +func (l *LabsServerTransport) 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 "LabsClient.BeginCreateOrUpdate": + resp, err = l.dispatchBeginCreateOrUpdate(req) + case "LabsClient.BeginDelete": + resp, err = l.dispatchBeginDelete(req) + case "LabsClient.Get": + resp, err = l.dispatchGet(req) + case "LabsClient.NewListByResourceGroupPager": + resp, err = l.dispatchNewListByResourceGroupPager(req) + case "LabsClient.NewListBySubscriptionPager": + resp, err = l.dispatchNewListBySubscriptionPager(req) + case "LabsClient.BeginPublish": + resp, err = l.dispatchBeginPublish(req) + case "LabsClient.BeginSyncGroup": + resp, err = l.dispatchBeginSyncGroup(req) + case "LabsClient.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 *LabsServerTransport) 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\.LabServices/labs/(?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[armlabservices.Lab](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, labNameParam, 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, http.StatusAccepted}, resp.StatusCode) { + l.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + l.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (l *LabsServerTransport) 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\.LabServices/labs/(?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 + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.BeginDelete(req.Context(), resourceGroupNameParam, labNameParam, 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 *LabsServerTransport) 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\.LabServices/labs/(?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 + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.Get(req.Context(), resourceGroupNameParam, labNameParam, 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).Lab, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (l *LabsServerTransport) 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\.LabServices/labs` + 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 *armlabservices.LabsClientListByResourceGroupResponse, 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 *LabsServerTransport) 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\.LabServices/labs` + 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) + } + qp := req.URL.Query() + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlabservices.LabsClientListBySubscriptionOptions + if filterParam != nil { + options = &armlabservices.LabsClientListBySubscriptionOptions{ + Filter: filterParam, + } + } + resp := l.srv.NewListBySubscriptionPager(options) + newListBySubscriptionPager = &resp + l.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armlabservices.LabsClientListBySubscriptionResponse, 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 *LabsServerTransport) dispatchBeginPublish(req *http.Request) (*http.Response, error) { + if l.srv.BeginPublish == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginPublish not implemented")} + } + beginPublish := l.beginPublish.get(req) + if beginPublish == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/publish` + 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 + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.BeginPublish(req.Context(), resourceGroupNameParam, labNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginPublish = &respr + l.beginPublish.add(req, beginPublish) + } + + resp, err := server.PollerResponderNext(beginPublish, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + l.beginPublish.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginPublish) { + l.beginPublish.remove(req) + } + + return resp, nil +} + +func (l *LabsServerTransport) dispatchBeginSyncGroup(req *http.Request) (*http.Response, error) { + if l.srv.BeginSyncGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginSyncGroup not implemented")} + } + beginSyncGroup := l.beginSyncGroup.get(req) + if beginSyncGroup == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/syncGroup` + 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 + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.BeginSyncGroup(req.Context(), resourceGroupNameParam, labNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginSyncGroup = &respr + l.beginSyncGroup.add(req, beginSyncGroup) + } + + resp, err := server.PollerResponderNext(beginSyncGroup, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + l.beginSyncGroup.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginSyncGroup) { + l.beginSyncGroup.remove(req) + } + + return resp, nil +} + +func (l *LabsServerTransport) 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\.LabServices/labs/(?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[armlabservices.LabUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + respr, errRespr := l.srv.BeginUpdate(req.Context(), resourceGroupNameParam, labNameParam, 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/labservices/armlabservices/fake/operationresults_server.go b/sdk/resourcemanager/labservices/armlabservices/fake/operationresults_server.go new file mode 100644 index 000000000000..3741c2f3d8a0 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/fake/operationresults_server.go @@ -0,0 +1,96 @@ +//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/resourcemanager/labservices/armlabservices" + "net/http" + "net/url" + "regexp" +) + +// OperationResultsServer is a fake server for instances of the armlabservices.OperationResultsClient type. +type OperationResultsServer struct { + // Get is the fake for method OperationResultsClient.Get + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Get func(ctx context.Context, operationResultID string, options *armlabservices.OperationResultsClientGetOptions) (resp azfake.Responder[armlabservices.OperationResultsClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewOperationResultsServerTransport creates a new instance of OperationResultsServerTransport with the provided implementation. +// The returned OperationResultsServerTransport instance is connected to an instance of armlabservices.OperationResultsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewOperationResultsServerTransport(srv *OperationResultsServer) *OperationResultsServerTransport { + return &OperationResultsServerTransport{srv: srv} +} + +// OperationResultsServerTransport connects instances of armlabservices.OperationResultsClient to instances of OperationResultsServer. +// Don't use this type directly, use NewOperationResultsServerTransport instead. +type OperationResultsServerTransport struct { + srv *OperationResultsServer +} + +// Do implements the policy.Transporter interface for OperationResultsServerTransport. +func (o *OperationResultsServerTransport) 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 "OperationResultsClient.Get": + resp, err = o.dispatchGet(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationResultsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if o.srv.Get == nil { + return nil, &nonRetriableError{errors.New("fake for method Get not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/operationResults/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + 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) + } + operationResultIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationResultId")]) + if err != nil { + return nil, err + } + respr, errRespr := o.srv.Get(req.Context(), operationResultIDParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).OperationResult, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/labservices/armlabservices/fake/operations_server.go b/sdk/resourcemanager/labservices/armlabservices/fake/operations_server.go new file mode 100644 index 000000000000..e54584b6ac0f --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/fake/operations_server.go @@ -0,0 +1,96 @@ +//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 ( + "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/labservices/armlabservices" + "net/http" +) + +// OperationsServer is a fake server for instances of the armlabservices.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armlabservices.OperationsClientListOptions) (resp azfake.PagerResponder[armlabservices.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armlabservices.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[armlabservices.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armlabservices.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armlabservices.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) 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 "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlabservices.OperationsClientListResponse, 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) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/labservices/armlabservices/fake/schedules_server.go b/sdk/resourcemanager/labservices/armlabservices/fake/schedules_server.go new file mode 100644 index 000000000000..be4a62fef693 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/fake/schedules_server.go @@ -0,0 +1,318 @@ +//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/labservices/armlabservices" + "net/http" + "net/url" + "regexp" +) + +// SchedulesServer is a fake server for instances of the armlabservices.SchedulesClient type. +type SchedulesServer struct { + // CreateOrUpdate is the fake for method SchedulesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, labName string, scheduleName string, body armlabservices.Schedule, options *armlabservices.SchedulesClientCreateOrUpdateOptions) (resp azfake.Responder[armlabservices.SchedulesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method SchedulesClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, labName string, scheduleName string, options *armlabservices.SchedulesClientBeginDeleteOptions) (resp azfake.PollerResponder[armlabservices.SchedulesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method SchedulesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, labName string, scheduleName string, options *armlabservices.SchedulesClientGetOptions) (resp azfake.Responder[armlabservices.SchedulesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByLabPager is the fake for method SchedulesClient.NewListByLabPager + // HTTP status codes to indicate success: http.StatusOK + NewListByLabPager func(resourceGroupName string, labName string, options *armlabservices.SchedulesClientListByLabOptions) (resp azfake.PagerResponder[armlabservices.SchedulesClientListByLabResponse]) + + // Update is the fake for method SchedulesClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, labName string, scheduleName string, body armlabservices.ScheduleUpdate, options *armlabservices.SchedulesClientUpdateOptions) (resp azfake.Responder[armlabservices.SchedulesClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewSchedulesServerTransport creates a new instance of SchedulesServerTransport with the provided implementation. +// The returned SchedulesServerTransport instance is connected to an instance of armlabservices.SchedulesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSchedulesServerTransport(srv *SchedulesServer) *SchedulesServerTransport { + return &SchedulesServerTransport{ + srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armlabservices.SchedulesClientDeleteResponse]](), + newListByLabPager: newTracker[azfake.PagerResponder[armlabservices.SchedulesClientListByLabResponse]](), + } +} + +// SchedulesServerTransport connects instances of armlabservices.SchedulesClient to instances of SchedulesServer. +// Don't use this type directly, use NewSchedulesServerTransport instead. +type SchedulesServerTransport struct { + srv *SchedulesServer + beginDelete *tracker[azfake.PollerResponder[armlabservices.SchedulesClientDeleteResponse]] + newListByLabPager *tracker[azfake.PagerResponder[armlabservices.SchedulesClientListByLabResponse]] +} + +// Do implements the policy.Transporter interface for SchedulesServerTransport. +func (s *SchedulesServerTransport) 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 "SchedulesClient.CreateOrUpdate": + resp, err = s.dispatchCreateOrUpdate(req) + case "SchedulesClient.BeginDelete": + resp, err = s.dispatchBeginDelete(req) + case "SchedulesClient.Get": + resp, err = s.dispatchGet(req) + case "SchedulesClient.NewListByLabPager": + resp, err = s.dispatchNewListByLabPager(req) + case "SchedulesClient.Update": + resp, err = s.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SchedulesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schedules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlabservices.Schedule](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + scheduleNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scheduleName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, labNameParam, scheduleNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Schedule, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SchedulesServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if s.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := s.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schedules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + scheduleNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scheduleName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginDelete(req.Context(), resourceGroupNameParam, labNameParam, scheduleNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + s.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) { + s.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) { + s.beginDelete.remove(req) + } + + return resp, nil +} + +func (s *SchedulesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.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\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schedules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + scheduleNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scheduleName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, labNameParam, scheduleNameParam, 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).Schedule, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SchedulesServerTransport) dispatchNewListByLabPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListByLabPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByLabPager not implemented")} + } + newListByLabPager := s.newListByLabPager.get(req) + if newListByLabPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schedules` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlabservices.SchedulesClientListByLabOptions + if filterParam != nil { + options = &armlabservices.SchedulesClientListByLabOptions{ + Filter: filterParam, + } + } + resp := s.srv.NewListByLabPager(resourceGroupNameParam, labNameParam, options) + newListByLabPager = &resp + s.newListByLabPager.add(req, newListByLabPager) + server.PagerResponderInjectNextLinks(newListByLabPager, req, func(page *armlabservices.SchedulesClientListByLabResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByLabPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListByLabPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByLabPager) { + s.newListByLabPager.remove(req) + } + return resp, nil +} + +func (s *SchedulesServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if s.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\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schedules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlabservices.ScheduleUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + scheduleNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("scheduleName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Update(req.Context(), resourceGroupNameParam, labNameParam, scheduleNameParam, 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).Schedule, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/labservices/armlabservices/fake/server_factory.go b/sdk/resourcemanager/labservices/armlabservices/fake/server_factory.go new file mode 100644 index 000000000000..db4d8438e62b --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/fake/server_factory.go @@ -0,0 +1,124 @@ +//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 ( + "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 armlabservices.ClientFactory type. +type ServerFactory struct { + ImagesServer ImagesServer + LabPlansServer LabPlansServer + LabsServer LabsServer + OperationResultsServer OperationResultsServer + OperationsServer OperationsServer + SKUsServer SKUsServer + SchedulesServer SchedulesServer + UsagesServer UsagesServer + UsersServer UsersServer + VirtualMachinesServer VirtualMachinesServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armlabservices.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 armlabservices.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trImagesServer *ImagesServerTransport + trLabPlansServer *LabPlansServerTransport + trLabsServer *LabsServerTransport + trOperationResultsServer *OperationResultsServerTransport + trOperationsServer *OperationsServerTransport + trSKUsServer *SKUsServerTransport + trSchedulesServer *SchedulesServerTransport + trUsagesServer *UsagesServerTransport + trUsersServer *UsersServerTransport + trVirtualMachinesServer *VirtualMachinesServerTransport +} + +// 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 "ImagesClient": + initServer(s, &s.trImagesServer, func() *ImagesServerTransport { return NewImagesServerTransport(&s.srv.ImagesServer) }) + resp, err = s.trImagesServer.Do(req) + case "LabPlansClient": + initServer(s, &s.trLabPlansServer, func() *LabPlansServerTransport { return NewLabPlansServerTransport(&s.srv.LabPlansServer) }) + resp, err = s.trLabPlansServer.Do(req) + case "LabsClient": + initServer(s, &s.trLabsServer, func() *LabsServerTransport { return NewLabsServerTransport(&s.srv.LabsServer) }) + resp, err = s.trLabsServer.Do(req) + case "OperationResultsClient": + initServer(s, &s.trOperationResultsServer, func() *OperationResultsServerTransport { + return NewOperationResultsServerTransport(&s.srv.OperationResultsServer) + }) + resp, err = s.trOperationResultsServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "SKUsClient": + initServer(s, &s.trSKUsServer, func() *SKUsServerTransport { return NewSKUsServerTransport(&s.srv.SKUsServer) }) + resp, err = s.trSKUsServer.Do(req) + case "SchedulesClient": + initServer(s, &s.trSchedulesServer, func() *SchedulesServerTransport { return NewSchedulesServerTransport(&s.srv.SchedulesServer) }) + resp, err = s.trSchedulesServer.Do(req) + case "UsagesClient": + initServer(s, &s.trUsagesServer, func() *UsagesServerTransport { return NewUsagesServerTransport(&s.srv.UsagesServer) }) + resp, err = s.trUsagesServer.Do(req) + case "UsersClient": + initServer(s, &s.trUsersServer, func() *UsersServerTransport { return NewUsersServerTransport(&s.srv.UsersServer) }) + resp, err = s.trUsersServer.Do(req) + case "VirtualMachinesClient": + initServer(s, &s.trVirtualMachinesServer, func() *VirtualMachinesServerTransport { + return NewVirtualMachinesServerTransport(&s.srv.VirtualMachinesServer) + }) + resp, err = s.trVirtualMachinesServer.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/labservices/armlabservices/fake/skus_server.go b/sdk/resourcemanager/labservices/armlabservices/fake/skus_server.go new file mode 100644 index 000000000000..0429f861bacc --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/fake/skus_server.go @@ -0,0 +1,116 @@ +//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 ( + "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/labservices/armlabservices" + "net/http" + "net/url" + "regexp" +) + +// SKUsServer is a fake server for instances of the armlabservices.SKUsClient type. +type SKUsServer struct { + // NewListPager is the fake for method SKUsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armlabservices.SKUsClientListOptions) (resp azfake.PagerResponder[armlabservices.SKUsClientListResponse]) +} + +// NewSKUsServerTransport creates a new instance of SKUsServerTransport with the provided implementation. +// The returned SKUsServerTransport instance is connected to an instance of armlabservices.SKUsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSKUsServerTransport(srv *SKUsServer) *SKUsServerTransport { + return &SKUsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlabservices.SKUsClientListResponse]](), + } +} + +// SKUsServerTransport connects instances of armlabservices.SKUsClient to instances of SKUsServer. +// Don't use this type directly, use NewSKUsServerTransport instead. +type SKUsServerTransport struct { + srv *SKUsServer + newListPager *tracker[azfake.PagerResponder[armlabservices.SKUsClientListResponse]] +} + +// Do implements the policy.Transporter interface for SKUsServerTransport. +func (s *SKUsServerTransport) 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 "SKUsClient.NewListPager": + resp, err = s.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SKUsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := s.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/skus` + 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) + } + qp := req.URL.Query() + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlabservices.SKUsClientListOptions + if filterParam != nil { + options = &armlabservices.SKUsClientListOptions{ + Filter: filterParam, + } + } + resp := s.srv.NewListPager(options) + newListPager = &resp + s.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlabservices.SKUsClientListResponse, 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) { + s.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + s.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/labservices/armlabservices/fake/time_rfc3339.go b/sdk/resourcemanager/labservices/armlabservices/fake/time_rfc3339.go new file mode 100644 index 000000000000..b0535a7b63e6 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/fake/time_rfc3339.go @@ -0,0 +1,86 @@ +//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 ( + "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 ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +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 { + layout := utcDateTimeJSON + if tzOffsetRegex.Match(data) { + layout = dateTimeJSON + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + 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 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 || strings.EqualFold(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/labservices/armlabservices/fake/usages_server.go b/sdk/resourcemanager/labservices/armlabservices/fake/usages_server.go new file mode 100644 index 000000000000..402f09597f2c --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/fake/usages_server.go @@ -0,0 +1,120 @@ +//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 ( + "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/labservices/armlabservices" + "net/http" + "net/url" + "regexp" +) + +// UsagesServer is a fake server for instances of the armlabservices.UsagesClient type. +type UsagesServer struct { + // NewListByLocationPager is the fake for method UsagesClient.NewListByLocationPager + // HTTP status codes to indicate success: http.StatusOK + NewListByLocationPager func(location string, options *armlabservices.UsagesClientListByLocationOptions) (resp azfake.PagerResponder[armlabservices.UsagesClientListByLocationResponse]) +} + +// NewUsagesServerTransport creates a new instance of UsagesServerTransport with the provided implementation. +// The returned UsagesServerTransport instance is connected to an instance of armlabservices.UsagesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewUsagesServerTransport(srv *UsagesServer) *UsagesServerTransport { + return &UsagesServerTransport{ + srv: srv, + newListByLocationPager: newTracker[azfake.PagerResponder[armlabservices.UsagesClientListByLocationResponse]](), + } +} + +// UsagesServerTransport connects instances of armlabservices.UsagesClient to instances of UsagesServer. +// Don't use this type directly, use NewUsagesServerTransport instead. +type UsagesServerTransport struct { + srv *UsagesServer + newListByLocationPager *tracker[azfake.PagerResponder[armlabservices.UsagesClientListByLocationResponse]] +} + +// Do implements the policy.Transporter interface for UsagesServerTransport. +func (u *UsagesServerTransport) 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 "UsagesClient.NewListByLocationPager": + resp, err = u.dispatchNewListByLocationPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (u *UsagesServerTransport) dispatchNewListByLocationPager(req *http.Request) (*http.Response, error) { + if u.srv.NewListByLocationPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByLocationPager not implemented")} + } + newListByLocationPager := u.newListByLocationPager.get(req) + if newListByLocationPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/usages` + 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) + } + qp := req.URL.Query() + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlabservices.UsagesClientListByLocationOptions + if filterParam != nil { + options = &armlabservices.UsagesClientListByLocationOptions{ + Filter: filterParam, + } + } + resp := u.srv.NewListByLocationPager(locationParam, options) + newListByLocationPager = &resp + u.newListByLocationPager.add(req, newListByLocationPager) + server.PagerResponderInjectNextLinks(newListByLocationPager, req, func(page *armlabservices.UsagesClientListByLocationResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByLocationPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + u.newListByLocationPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByLocationPager) { + u.newListByLocationPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/labservices/armlabservices/fake/users_server.go b/sdk/resourcemanager/labservices/armlabservices/fake/users_server.go new file mode 100644 index 000000000000..35a3ba37367b --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/fake/users_server.go @@ -0,0 +1,404 @@ +//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/labservices/armlabservices" + "net/http" + "net/url" + "regexp" +) + +// UsersServer is a fake server for instances of the armlabservices.UsersClient type. +type UsersServer struct { + // BeginCreateOrUpdate is the fake for method UsersClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated, http.StatusAccepted + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, labName string, userName string, body armlabservices.User, options *armlabservices.UsersClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armlabservices.UsersClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method UsersClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, labName string, userName string, options *armlabservices.UsersClientBeginDeleteOptions) (resp azfake.PollerResponder[armlabservices.UsersClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method UsersClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, labName string, userName string, options *armlabservices.UsersClientGetOptions) (resp azfake.Responder[armlabservices.UsersClientGetResponse], errResp azfake.ErrorResponder) + + // BeginInvite is the fake for method UsersClient.BeginInvite + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginInvite func(ctx context.Context, resourceGroupName string, labName string, userName string, body armlabservices.InviteBody, options *armlabservices.UsersClientBeginInviteOptions) (resp azfake.PollerResponder[armlabservices.UsersClientInviteResponse], errResp azfake.ErrorResponder) + + // NewListByLabPager is the fake for method UsersClient.NewListByLabPager + // HTTP status codes to indicate success: http.StatusOK + NewListByLabPager func(resourceGroupName string, labName string, options *armlabservices.UsersClientListByLabOptions) (resp azfake.PagerResponder[armlabservices.UsersClientListByLabResponse]) + + // BeginUpdate is the fake for method UsersClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginUpdate func(ctx context.Context, resourceGroupName string, labName string, userName string, body armlabservices.UserUpdate, options *armlabservices.UsersClientBeginUpdateOptions) (resp azfake.PollerResponder[armlabservices.UsersClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewUsersServerTransport creates a new instance of UsersServerTransport with the provided implementation. +// The returned UsersServerTransport instance is connected to an instance of armlabservices.UsersClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewUsersServerTransport(srv *UsersServer) *UsersServerTransport { + return &UsersServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armlabservices.UsersClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armlabservices.UsersClientDeleteResponse]](), + beginInvite: newTracker[azfake.PollerResponder[armlabservices.UsersClientInviteResponse]](), + newListByLabPager: newTracker[azfake.PagerResponder[armlabservices.UsersClientListByLabResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armlabservices.UsersClientUpdateResponse]](), + } +} + +// UsersServerTransport connects instances of armlabservices.UsersClient to instances of UsersServer. +// Don't use this type directly, use NewUsersServerTransport instead. +type UsersServerTransport struct { + srv *UsersServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armlabservices.UsersClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armlabservices.UsersClientDeleteResponse]] + beginInvite *tracker[azfake.PollerResponder[armlabservices.UsersClientInviteResponse]] + newListByLabPager *tracker[azfake.PagerResponder[armlabservices.UsersClientListByLabResponse]] + beginUpdate *tracker[azfake.PollerResponder[armlabservices.UsersClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for UsersServerTransport. +func (u *UsersServerTransport) 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 "UsersClient.BeginCreateOrUpdate": + resp, err = u.dispatchBeginCreateOrUpdate(req) + case "UsersClient.BeginDelete": + resp, err = u.dispatchBeginDelete(req) + case "UsersClient.Get": + resp, err = u.dispatchGet(req) + case "UsersClient.BeginInvite": + resp, err = u.dispatchBeginInvite(req) + case "UsersClient.NewListByLabPager": + resp, err = u.dispatchNewListByLabPager(req) + case "UsersClient.BeginUpdate": + resp, err = u.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (u *UsersServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if u.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := u.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/users/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlabservices.User](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + userNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("userName")]) + if err != nil { + return nil, err + } + respr, errRespr := u.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, labNameParam, userNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + u.beginCreateOrUpdate.add(req, beginCreateOrUpdate) + } + + resp, err := server.PollerResponderNext(beginCreateOrUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated, http.StatusAccepted}, resp.StatusCode) { + u.beginCreateOrUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreateOrUpdate) { + u.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (u *UsersServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if u.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := u.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/users/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + userNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("userName")]) + if err != nil { + return nil, err + } + respr, errRespr := u.srv.BeginDelete(req.Context(), resourceGroupNameParam, labNameParam, userNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + u.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) { + u.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) { + u.beginDelete.remove(req) + } + + return resp, nil +} + +func (u *UsersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if u.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\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/users/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + userNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("userName")]) + if err != nil { + return nil, err + } + respr, errRespr := u.srv.Get(req.Context(), resourceGroupNameParam, labNameParam, userNameParam, 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).User, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (u *UsersServerTransport) dispatchBeginInvite(req *http.Request) (*http.Response, error) { + if u.srv.BeginInvite == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginInvite not implemented")} + } + beginInvite := u.beginInvite.get(req) + if beginInvite == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/users/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/invite` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlabservices.InviteBody](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + userNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("userName")]) + if err != nil { + return nil, err + } + respr, errRespr := u.srv.BeginInvite(req.Context(), resourceGroupNameParam, labNameParam, userNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginInvite = &respr + u.beginInvite.add(req, beginInvite) + } + + resp, err := server.PollerResponderNext(beginInvite, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + u.beginInvite.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginInvite) { + u.beginInvite.remove(req) + } + + return resp, nil +} + +func (u *UsersServerTransport) dispatchNewListByLabPager(req *http.Request) (*http.Response, error) { + if u.srv.NewListByLabPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByLabPager not implemented")} + } + newListByLabPager := u.newListByLabPager.get(req) + if newListByLabPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/users` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlabservices.UsersClientListByLabOptions + if filterParam != nil { + options = &armlabservices.UsersClientListByLabOptions{ + Filter: filterParam, + } + } + resp := u.srv.NewListByLabPager(resourceGroupNameParam, labNameParam, options) + newListByLabPager = &resp + u.newListByLabPager.add(req, newListByLabPager) + server.PagerResponderInjectNextLinks(newListByLabPager, req, func(page *armlabservices.UsersClientListByLabResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByLabPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + u.newListByLabPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByLabPager) { + u.newListByLabPager.remove(req) + } + return resp, nil +} + +func (u *UsersServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if u.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := u.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/users/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlabservices.UserUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + userNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("userName")]) + if err != nil { + return nil, err + } + respr, errRespr := u.srv.BeginUpdate(req.Context(), resourceGroupNameParam, labNameParam, userNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + u.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) { + u.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) { + u.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/labservices/armlabservices/fake/virtualmachines_server.go b/sdk/resourcemanager/labservices/armlabservices/fake/virtualmachines_server.go new file mode 100644 index 000000000000..6accc915d727 --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/fake/virtualmachines_server.go @@ -0,0 +1,452 @@ +//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/labservices/armlabservices" + "net/http" + "net/url" + "regexp" +) + +// VirtualMachinesServer is a fake server for instances of the armlabservices.VirtualMachinesClient type. +type VirtualMachinesServer struct { + // Get is the fake for method VirtualMachinesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *armlabservices.VirtualMachinesClientGetOptions) (resp azfake.Responder[armlabservices.VirtualMachinesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByLabPager is the fake for method VirtualMachinesClient.NewListByLabPager + // HTTP status codes to indicate success: http.StatusOK + NewListByLabPager func(resourceGroupName string, labName string, options *armlabservices.VirtualMachinesClientListByLabOptions) (resp azfake.PagerResponder[armlabservices.VirtualMachinesClientListByLabResponse]) + + // BeginRedeploy is the fake for method VirtualMachinesClient.BeginRedeploy + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginRedeploy func(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *armlabservices.VirtualMachinesClientBeginRedeployOptions) (resp azfake.PollerResponder[armlabservices.VirtualMachinesClientRedeployResponse], errResp azfake.ErrorResponder) + + // BeginReimage is the fake for method VirtualMachinesClient.BeginReimage + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginReimage func(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *armlabservices.VirtualMachinesClientBeginReimageOptions) (resp azfake.PollerResponder[armlabservices.VirtualMachinesClientReimageResponse], errResp azfake.ErrorResponder) + + // BeginResetPassword is the fake for method VirtualMachinesClient.BeginResetPassword + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginResetPassword func(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, body armlabservices.ResetPasswordBody, options *armlabservices.VirtualMachinesClientBeginResetPasswordOptions) (resp azfake.PollerResponder[armlabservices.VirtualMachinesClientResetPasswordResponse], errResp azfake.ErrorResponder) + + // BeginStart is the fake for method VirtualMachinesClient.BeginStart + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginStart func(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *armlabservices.VirtualMachinesClientBeginStartOptions) (resp azfake.PollerResponder[armlabservices.VirtualMachinesClientStartResponse], errResp azfake.ErrorResponder) + + // BeginStop is the fake for method VirtualMachinesClient.BeginStop + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginStop func(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *armlabservices.VirtualMachinesClientBeginStopOptions) (resp azfake.PollerResponder[armlabservices.VirtualMachinesClientStopResponse], errResp azfake.ErrorResponder) +} + +// NewVirtualMachinesServerTransport creates a new instance of VirtualMachinesServerTransport with the provided implementation. +// The returned VirtualMachinesServerTransport instance is connected to an instance of armlabservices.VirtualMachinesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewVirtualMachinesServerTransport(srv *VirtualMachinesServer) *VirtualMachinesServerTransport { + return &VirtualMachinesServerTransport{ + srv: srv, + newListByLabPager: newTracker[azfake.PagerResponder[armlabservices.VirtualMachinesClientListByLabResponse]](), + beginRedeploy: newTracker[azfake.PollerResponder[armlabservices.VirtualMachinesClientRedeployResponse]](), + beginReimage: newTracker[azfake.PollerResponder[armlabservices.VirtualMachinesClientReimageResponse]](), + beginResetPassword: newTracker[azfake.PollerResponder[armlabservices.VirtualMachinesClientResetPasswordResponse]](), + beginStart: newTracker[azfake.PollerResponder[armlabservices.VirtualMachinesClientStartResponse]](), + beginStop: newTracker[azfake.PollerResponder[armlabservices.VirtualMachinesClientStopResponse]](), + } +} + +// VirtualMachinesServerTransport connects instances of armlabservices.VirtualMachinesClient to instances of VirtualMachinesServer. +// Don't use this type directly, use NewVirtualMachinesServerTransport instead. +type VirtualMachinesServerTransport struct { + srv *VirtualMachinesServer + newListByLabPager *tracker[azfake.PagerResponder[armlabservices.VirtualMachinesClientListByLabResponse]] + beginRedeploy *tracker[azfake.PollerResponder[armlabservices.VirtualMachinesClientRedeployResponse]] + beginReimage *tracker[azfake.PollerResponder[armlabservices.VirtualMachinesClientReimageResponse]] + beginResetPassword *tracker[azfake.PollerResponder[armlabservices.VirtualMachinesClientResetPasswordResponse]] + beginStart *tracker[azfake.PollerResponder[armlabservices.VirtualMachinesClientStartResponse]] + beginStop *tracker[azfake.PollerResponder[armlabservices.VirtualMachinesClientStopResponse]] +} + +// Do implements the policy.Transporter interface for VirtualMachinesServerTransport. +func (v *VirtualMachinesServerTransport) 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 "VirtualMachinesClient.Get": + resp, err = v.dispatchGet(req) + case "VirtualMachinesClient.NewListByLabPager": + resp, err = v.dispatchNewListByLabPager(req) + case "VirtualMachinesClient.BeginRedeploy": + resp, err = v.dispatchBeginRedeploy(req) + case "VirtualMachinesClient.BeginReimage": + resp, err = v.dispatchBeginReimage(req) + case "VirtualMachinesClient.BeginResetPassword": + resp, err = v.dispatchBeginResetPassword(req) + case "VirtualMachinesClient.BeginStart": + resp, err = v.dispatchBeginStart(req) + case "VirtualMachinesClient.BeginStop": + resp, err = v.dispatchBeginStop(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (v *VirtualMachinesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if v.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\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/virtualMachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + virtualMachineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualMachineName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.Get(req.Context(), resourceGroupNameParam, labNameParam, virtualMachineNameParam, 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).VirtualMachine, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (v *VirtualMachinesServerTransport) dispatchNewListByLabPager(req *http.Request) (*http.Response, error) { + if v.srv.NewListByLabPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByLabPager not implemented")} + } + newListByLabPager := v.newListByLabPager.get(req) + if newListByLabPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/virtualMachines` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlabservices.VirtualMachinesClientListByLabOptions + if filterParam != nil { + options = &armlabservices.VirtualMachinesClientListByLabOptions{ + Filter: filterParam, + } + } + resp := v.srv.NewListByLabPager(resourceGroupNameParam, labNameParam, options) + newListByLabPager = &resp + v.newListByLabPager.add(req, newListByLabPager) + server.PagerResponderInjectNextLinks(newListByLabPager, req, func(page *armlabservices.VirtualMachinesClientListByLabResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByLabPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + v.newListByLabPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByLabPager) { + v.newListByLabPager.remove(req) + } + return resp, nil +} + +func (v *VirtualMachinesServerTransport) dispatchBeginRedeploy(req *http.Request) (*http.Response, error) { + if v.srv.BeginRedeploy == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginRedeploy not implemented")} + } + beginRedeploy := v.beginRedeploy.get(req) + if beginRedeploy == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/virtualMachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/redeploy` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + virtualMachineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualMachineName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginRedeploy(req.Context(), resourceGroupNameParam, labNameParam, virtualMachineNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginRedeploy = &respr + v.beginRedeploy.add(req, beginRedeploy) + } + + resp, err := server.PollerResponderNext(beginRedeploy, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + v.beginRedeploy.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginRedeploy) { + v.beginRedeploy.remove(req) + } + + return resp, nil +} + +func (v *VirtualMachinesServerTransport) dispatchBeginReimage(req *http.Request) (*http.Response, error) { + if v.srv.BeginReimage == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginReimage not implemented")} + } + beginReimage := v.beginReimage.get(req) + if beginReimage == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/virtualMachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/reimage` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + virtualMachineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualMachineName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginReimage(req.Context(), resourceGroupNameParam, labNameParam, virtualMachineNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginReimage = &respr + v.beginReimage.add(req, beginReimage) + } + + resp, err := server.PollerResponderNext(beginReimage, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + v.beginReimage.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginReimage) { + v.beginReimage.remove(req) + } + + return resp, nil +} + +func (v *VirtualMachinesServerTransport) dispatchBeginResetPassword(req *http.Request) (*http.Response, error) { + if v.srv.BeginResetPassword == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginResetPassword not implemented")} + } + beginResetPassword := v.beginResetPassword.get(req) + if beginResetPassword == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/virtualMachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resetPassword` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlabservices.ResetPasswordBody](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + virtualMachineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualMachineName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginResetPassword(req.Context(), resourceGroupNameParam, labNameParam, virtualMachineNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginResetPassword = &respr + v.beginResetPassword.add(req, beginResetPassword) + } + + resp, err := server.PollerResponderNext(beginResetPassword, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + v.beginResetPassword.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginResetPassword) { + v.beginResetPassword.remove(req) + } + + return resp, nil +} + +func (v *VirtualMachinesServerTransport) dispatchBeginStart(req *http.Request) (*http.Response, error) { + if v.srv.BeginStart == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginStart not implemented")} + } + beginStart := v.beginStart.get(req) + if beginStart == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/virtualMachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/start` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + virtualMachineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualMachineName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginStart(req.Context(), resourceGroupNameParam, labNameParam, virtualMachineNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginStart = &respr + v.beginStart.add(req, beginStart) + } + + resp, err := server.PollerResponderNext(beginStart, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + v.beginStart.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginStart) { + v.beginStart.remove(req) + } + + return resp, nil +} + +func (v *VirtualMachinesServerTransport) dispatchBeginStop(req *http.Request) (*http.Response, error) { + if v.srv.BeginStop == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginStop not implemented")} + } + beginStop := v.beginStop.get(req) + if beginStop == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.LabServices/labs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/virtualMachines/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/stop` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + labNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("labName")]) + if err != nil { + return nil, err + } + virtualMachineNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("virtualMachineName")]) + if err != nil { + return nil, err + } + respr, errRespr := v.srv.BeginStop(req.Context(), resourceGroupNameParam, labNameParam, virtualMachineNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginStop = &respr + v.beginStop.add(req, beginStop) + } + + resp, err := server.PollerResponderNext(beginStop, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + v.beginStop.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginStop) { + v.beginStop.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/labservices/armlabservices/go.mod b/sdk/resourcemanager/labservices/armlabservices/go.mod index de29c121d722..804fbfbfb300 100644 --- a/sdk/resourcemanager/labservices/armlabservices/go.mod +++ b/sdk/resourcemanager/labservices/armlabservices/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/labservices/armlabs go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 // indirect + github.com/google/uuid v1.3.1 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.6.0 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect ) diff --git a/sdk/resourcemanager/labservices/armlabservices/go.sum b/sdk/resourcemanager/labservices/armlabservices/go.sum index 8ba445a8c4da..7985f1da436f 100644 --- a/sdk/resourcemanager/labservices/armlabservices/go.sum +++ b/sdk/resourcemanager/labservices/armlabservices/go.sum @@ -1,31 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= +github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= +github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/labservices/armlabservices/images_client.go b/sdk/resourcemanager/labservices/armlabservices/images_client.go index dab2b0c378ca..bc84c14bc76d 100644 --- a/sdk/resourcemanager/labservices/armlabservices/images_client.go +++ b/sdk/resourcemanager/labservices/armlabservices/images_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlabservices @@ -33,7 +32,7 @@ type ImagesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewImagesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*ImagesClient, error) { - cl, err := arm.NewClient(moduleName+".ImagesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,18 +54,25 @@ func NewImagesClient(subscriptionID string, credential azcore.TokenCredential, o // - body - The request body. // - options - ImagesClientCreateOrUpdateOptions contains the optional parameters for the ImagesClient.CreateOrUpdate method. func (client *ImagesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, labPlanName string, imageName string, body Image, options *ImagesClientCreateOrUpdateOptions) (ImagesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "ImagesClient.CreateOrUpdate" + 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, labPlanName, imageName, body, options) if err != nil { return ImagesClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ImagesClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ImagesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ImagesClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -96,7 +102,10 @@ func (client *ImagesClient) createOrUpdateCreateRequest(ctx context.Context, res reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -118,18 +127,25 @@ func (client *ImagesClient) createOrUpdateHandleResponse(resp *http.Response) (I // - imageName - The image name. // - options - ImagesClientGetOptions contains the optional parameters for the ImagesClient.Get method. func (client *ImagesClient) Get(ctx context.Context, resourceGroupName string, labPlanName string, imageName string, options *ImagesClientGetOptions) (ImagesClientGetResponse, error) { + var err error + const operationName = "ImagesClient.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, labPlanName, imageName, options) if err != nil { return ImagesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ImagesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ImagesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ImagesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -185,25 +201,20 @@ func (client *ImagesClient) NewListByLabPlanPager(resourceGroupName string, labP return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *ImagesClientListByLabPlanResponse) (ImagesClientListByLabPlanResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByLabPlanCreateRequest(ctx, resourceGroupName, labPlanName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ImagesClient.NewListByLabPlanPager") + 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.listByLabPlanCreateRequest(ctx, resourceGroupName, labPlanName, options) + }, nil) if err != nil { return ImagesClientListByLabPlanResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ImagesClientListByLabPlanResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ImagesClientListByLabPlanResponse{}, runtime.NewResponseError(resp) - } return client.listByLabPlanHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -256,18 +267,25 @@ func (client *ImagesClient) listByLabPlanHandleResponse(resp *http.Response) (Im // - body - The request body. // - options - ImagesClientUpdateOptions contains the optional parameters for the ImagesClient.Update method. func (client *ImagesClient) Update(ctx context.Context, resourceGroupName string, labPlanName string, imageName string, body ImageUpdate, options *ImagesClientUpdateOptions) (ImagesClientUpdateResponse, error) { + var err error + const operationName = "ImagesClient.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, labPlanName, imageName, body, options) if err != nil { return ImagesClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return ImagesClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return ImagesClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return ImagesClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -297,7 +315,10 @@ func (client *ImagesClient) updateCreateRequest(ctx context.Context, resourceGro reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // updateHandleResponse handles the Update response. diff --git a/sdk/resourcemanager/labservices/armlabservices/images_client_example_test.go b/sdk/resourcemanager/labservices/armlabservices/images_client_example_test.go index 0babacbf8c31..1049a1f2e105 100644 --- a/sdk/resourcemanager/labservices/armlabservices/images_client_example_test.go +++ b/sdk/resourcemanager/labservices/armlabservices/images_client_example_test.go @@ -58,10 +58,10 @@ func ExampleImagesClient_NewListByLabPlanPager() { // Version: to.Ptr("2019.0.20190410"), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -79,10 +79,10 @@ func ExampleImagesClient_NewListByLabPlanPager() { // SharedGalleryID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.Compute/galleries/sig/images/test-1"), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -126,10 +126,10 @@ func ExampleImagesClient_Get() { // Version: to.Ptr("2019.0.20190410"), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -174,10 +174,10 @@ func ExampleImagesClient_CreateOrUpdate() { // Version: to.Ptr("2019.0.20190410"), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -222,10 +222,10 @@ func ExampleImagesClient_Update() { // Version: to.Ptr("2019.0.20190410"), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, diff --git a/sdk/resourcemanager/labservices/armlabservices/labplans_client.go b/sdk/resourcemanager/labservices/armlabservices/labplans_client.go index e2ca38be5deb..313f58910b08 100644 --- a/sdk/resourcemanager/labservices/armlabservices/labplans_client.go +++ b/sdk/resourcemanager/labservices/armlabservices/labplans_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlabservices @@ -33,7 +32,7 @@ type LabPlansClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewLabPlansClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LabPlansClient, error) { - cl, err := arm.NewClient(moduleName+".LabPlansClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -60,11 +59,15 @@ func (client *LabPlansClient) BeginCreateOrUpdate(ctx context.Context, resourceG if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LabPlansClientCreateOrUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LabPlansClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaOriginalURI, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[LabPlansClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LabPlansClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -73,18 +76,24 @@ func (client *LabPlansClient) BeginCreateOrUpdate(ctx context.Context, resourceG // // Generated from API version 2022-08-01 func (client *LabPlansClient) createOrUpdate(ctx context.Context, resourceGroupName string, labPlanName string, body LabPlan, options *LabPlansClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "LabPlansClient.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, labPlanName, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -110,7 +119,10 @@ func (client *LabPlansClient) createOrUpdateCreateRequest(ctx context.Context, r reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Operation to delete a Lab Plan resource. Deleting a lab plan does not delete labs associated with a lab plan, @@ -128,11 +140,15 @@ func (client *LabPlansClient) BeginDelete(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LabPlansClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LabPlansClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[LabPlansClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LabPlansClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -142,18 +158,24 @@ func (client *LabPlansClient) BeginDelete(ctx context.Context, resourceGroupName // // Generated from API version 2022-08-01 func (client *LabPlansClient) deleteOperation(ctx context.Context, resourceGroupName string, labPlanName string, options *LabPlansClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "LabPlansClient.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, labPlanName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -191,18 +213,25 @@ func (client *LabPlansClient) deleteCreateRequest(ctx context.Context, resourceG // and in UI. // - options - LabPlansClientGetOptions contains the optional parameters for the LabPlansClient.Get method. func (client *LabPlansClient) Get(ctx context.Context, resourceGroupName string, labPlanName string, options *LabPlansClientGetOptions) (LabPlansClientGetResponse, error) { + var err error + const operationName = "LabPlansClient.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, labPlanName, options) if err != nil { return LabPlansClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return LabPlansClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LabPlansClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return LabPlansClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -252,25 +281,20 @@ func (client *LabPlansClient) NewListByResourceGroupPager(resourceGroupName stri return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *LabPlansClientListByResourceGroupResponse) (LabPlansClientListByResourceGroupResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return LabPlansClientListByResourceGroupResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "LabPlansClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + 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 LabPlansClientListByResourceGroupResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LabPlansClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -316,25 +340,20 @@ func (client *LabPlansClient) NewListBySubscriptionPager(options *LabPlansClient return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *LabPlansClientListBySubscriptionResponse) (LabPlansClientListBySubscriptionResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listBySubscriptionCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return LabPlansClientListBySubscriptionResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "LabPlansClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + 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 LabPlansClientListBySubscriptionResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LabPlansClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) - } return client.listBySubscriptionHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -383,11 +402,15 @@ func (client *LabPlansClient) BeginSaveImage(ctx context.Context, resourceGroupN if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LabPlansClientSaveImageResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LabPlansClientSaveImageResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[LabPlansClientSaveImageResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LabPlansClientSaveImageResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -396,18 +419,24 @@ func (client *LabPlansClient) BeginSaveImage(ctx context.Context, resourceGroupN // // Generated from API version 2022-08-01 func (client *LabPlansClient) saveImage(ctx context.Context, resourceGroupName string, labPlanName string, body SaveImageBody, options *LabPlansClientBeginSaveImageOptions) (*http.Response, error) { + var err error + const operationName = "LabPlansClient.BeginSaveImage" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.saveImageCreateRequest(ctx, resourceGroupName, labPlanName, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // saveImageCreateRequest creates the SaveImage request. @@ -433,7 +462,10 @@ func (client *LabPlansClient) saveImageCreateRequest(ctx context.Context, resour reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // BeginUpdate - Operation to update a Lab Plan resource. @@ -451,11 +483,15 @@ func (client *LabPlansClient) BeginUpdate(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LabPlansClientUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LabPlansClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[LabPlansClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LabPlansClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -464,18 +500,24 @@ func (client *LabPlansClient) BeginUpdate(ctx context.Context, resourceGroupName // // Generated from API version 2022-08-01 func (client *LabPlansClient) update(ctx context.Context, resourceGroupName string, labPlanName string, body LabPlanUpdate, options *LabPlansClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "LabPlansClient.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, labPlanName, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // updateCreateRequest creates the Update request. @@ -501,5 +543,8 @@ func (client *LabPlansClient) updateCreateRequest(ctx context.Context, resourceG reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/labservices/armlabservices/labplans_client_example_test.go b/sdk/resourcemanager/labservices/armlabservices/labplans_client_example_test.go index ec76d158e176..7a36328f4691 100644 --- a/sdk/resourcemanager/labservices/armlabservices/labplans_client_example_test.go +++ b/sdk/resourcemanager/labservices/armlabservices/labplans_client_example_test.go @@ -80,10 +80,10 @@ func ExampleLabPlansClient_NewListBySubscriptionPager() { // ProvisioningState: to.Ptr(armlabservices.ProvisioningStateSucceeded), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -149,10 +149,10 @@ func ExampleLabPlansClient_NewListByResourceGroupPager() { // ProvisioningState: to.Ptr(armlabservices.ProvisioningStateSucceeded), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -217,10 +217,10 @@ func ExampleLabPlansClient_Get() { // ProvisioningState: to.Ptr(armlabservices.ProvisioningStateSucceeded), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -310,10 +310,10 @@ func ExampleLabPlansClient_BeginCreateOrUpdate() { // ProvisioningState: to.Ptr(armlabservices.ProvisioningStateSucceeded), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -384,10 +384,10 @@ func ExampleLabPlansClient_BeginUpdate() { // ProvisioningState: to.Ptr(armlabservices.ProvisioningStateSucceeded), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, diff --git a/sdk/resourcemanager/labservices/armlabservices/labs_client.go b/sdk/resourcemanager/labservices/armlabservices/labs_client.go index 25f3496d71aa..c08a836127a9 100644 --- a/sdk/resourcemanager/labservices/armlabservices/labs_client.go +++ b/sdk/resourcemanager/labservices/armlabservices/labs_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlabservices @@ -33,7 +32,7 @@ type LabsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewLabsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*LabsClient, error) { - cl, err := arm.NewClient(moduleName+".LabsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -59,11 +58,15 @@ func (client *LabsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroup if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LabsClientCreateOrUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LabsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaOriginalURI, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[LabsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LabsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -72,18 +75,24 @@ func (client *LabsClient) BeginCreateOrUpdate(ctx context.Context, resourceGroup // // Generated from API version 2022-08-01 func (client *LabsClient) createOrUpdate(ctx context.Context, resourceGroupName string, labName string, body Lab, options *LabsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "LabsClient.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, labName, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -109,7 +118,10 @@ func (client *LabsClient) createOrUpdateCreateRequest(ctx context.Context, resou reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Operation to delete a lab resource. @@ -125,11 +137,15 @@ func (client *LabsClient) BeginDelete(ctx context.Context, resourceGroupName str if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LabsClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LabsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[LabsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LabsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -138,18 +154,24 @@ func (client *LabsClient) BeginDelete(ctx context.Context, resourceGroupName str // // Generated from API version 2022-08-01 func (client *LabsClient) deleteOperation(ctx context.Context, resourceGroupName string, labName string, options *LabsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "LabsClient.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, labName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -186,18 +208,25 @@ func (client *LabsClient) deleteCreateRequest(ctx context.Context, resourceGroup // - labName - The name of the lab that uniquely identifies it within containing lab plan. Used in resource URIs. // - options - LabsClientGetOptions contains the optional parameters for the LabsClient.Get method. func (client *LabsClient) Get(ctx context.Context, resourceGroupName string, labName string, options *LabsClientGetOptions) (LabsClientGetResponse, error) { + var err error + const operationName = "LabsClient.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, labName, options) if err != nil { return LabsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return LabsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LabsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return LabsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -247,25 +276,20 @@ func (client *LabsClient) NewListByResourceGroupPager(resourceGroupName string, return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *LabsClientListByResourceGroupResponse) (LabsClientListByResourceGroupResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return LabsClientListByResourceGroupResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "LabsClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + 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 LabsClientListByResourceGroupResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LabsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -311,25 +335,20 @@ func (client *LabsClient) NewListBySubscriptionPager(options *LabsClientListBySu return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *LabsClientListBySubscriptionResponse) (LabsClientListBySubscriptionResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listBySubscriptionCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "LabsClient.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 LabsClientListBySubscriptionResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return LabsClientListBySubscriptionResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LabsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) - } return client.listBySubscriptionHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -376,11 +395,15 @@ func (client *LabsClient) BeginPublish(ctx context.Context, resourceGroupName st if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LabsClientPublishResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LabsClientPublishResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[LabsClientPublishResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LabsClientPublishResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -389,18 +412,24 @@ func (client *LabsClient) BeginPublish(ctx context.Context, resourceGroupName st // // Generated from API version 2022-08-01 func (client *LabsClient) publish(ctx context.Context, resourceGroupName string, labName string, options *LabsClientBeginPublishOptions) (*http.Response, error) { + var err error + const operationName = "LabsClient.BeginPublish" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.publishCreateRequest(ctx, resourceGroupName, labName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // publishCreateRequest creates the Publish request. @@ -442,11 +471,15 @@ func (client *LabsClient) BeginSyncGroup(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LabsClientSyncGroupResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LabsClientSyncGroupResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[LabsClientSyncGroupResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LabsClientSyncGroupResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -455,18 +488,24 @@ func (client *LabsClient) BeginSyncGroup(ctx context.Context, resourceGroupName // // Generated from API version 2022-08-01 func (client *LabsClient) syncGroup(ctx context.Context, resourceGroupName string, labName string, options *LabsClientBeginSyncGroupOptions) (*http.Response, error) { + var err error + const operationName = "LabsClient.BeginSyncGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.syncGroupCreateRequest(ctx, resourceGroupName, labName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // syncGroupCreateRequest creates the SyncGroup request. @@ -509,11 +548,15 @@ func (client *LabsClient) BeginUpdate(ctx context.Context, resourceGroupName str if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LabsClientUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LabsClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[LabsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LabsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -522,18 +565,24 @@ func (client *LabsClient) BeginUpdate(ctx context.Context, resourceGroupName str // // Generated from API version 2022-08-01 func (client *LabsClient) update(ctx context.Context, resourceGroupName string, labName string, body LabUpdate, options *LabsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "LabsClient.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, labName, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // updateCreateRequest creates the Update request. @@ -559,5 +608,8 @@ func (client *LabsClient) updateCreateRequest(ctx context.Context, resourceGroup reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/labservices/armlabservices/labs_client_example_test.go b/sdk/resourcemanager/labservices/armlabservices/labs_client_example_test.go index 9c9cbc07d300..4e3da9779648 100644 --- a/sdk/resourcemanager/labservices/armlabservices/labs_client_example_test.go +++ b/sdk/resourcemanager/labservices/armlabservices/labs_client_example_test.go @@ -98,10 +98,10 @@ func ExampleLabsClient_NewListBySubscriptionPager() { // State: to.Ptr(armlabservices.LabStateDraft), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -190,10 +190,10 @@ func ExampleLabsClient_NewListByResourceGroupPager() { // State: to.Ptr(armlabservices.LabStateDraft), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -276,10 +276,10 @@ func ExampleLabsClient_Get() { // State: to.Ptr(armlabservices.LabStateDraft), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -412,10 +412,10 @@ func ExampleLabsClient_BeginCreateOrUpdate() { // State: to.Ptr(armlabservices.LabStateDraft), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -505,10 +505,10 @@ func ExampleLabsClient_BeginUpdate() { // State: to.Ptr(armlabservices.LabStateDraft), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, diff --git a/sdk/resourcemanager/labservices/armlabservices/models.go b/sdk/resourcemanager/labservices/armlabservices/models.go index 973b057a1843..cbef2300e3ed 100644 --- a/sdk/resourcemanager/labservices/armlabservices/models.go +++ b/sdk/resourcemanager/labservices/armlabservices/models.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlabservices @@ -204,27 +203,6 @@ type ImageUpdateProperties struct { EnabledState *EnableState } -// ImagesClientCreateOrUpdateOptions contains the optional parameters for the ImagesClient.CreateOrUpdate method. -type ImagesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// ImagesClientGetOptions contains the optional parameters for the ImagesClient.Get method. -type ImagesClientGetOptions struct { - // placeholder for future optional parameters -} - -// ImagesClientListByLabPlanOptions contains the optional parameters for the ImagesClient.NewListByLabPlanPager method. -type ImagesClientListByLabPlanOptions struct { - // The filter to apply to the operation. - Filter *string -} - -// ImagesClientUpdateOptions contains the optional parameters for the ImagesClient.Update method. -type ImagesClientUpdateOptions struct { - // placeholder for future optional parameters -} - // InviteBody - Body for a user invite request type InviteBody struct { // Custom text for the invite email. @@ -373,48 +351,6 @@ type LabPlanUpdateProperties struct { SupportInfo *SupportInfo } -// LabPlansClientBeginCreateOrUpdateOptions contains the optional parameters for the LabPlansClient.BeginCreateOrUpdate method. -type LabPlansClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// LabPlansClientBeginDeleteOptions contains the optional parameters for the LabPlansClient.BeginDelete method. -type LabPlansClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// LabPlansClientBeginSaveImageOptions contains the optional parameters for the LabPlansClient.BeginSaveImage method. -type LabPlansClientBeginSaveImageOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// LabPlansClientBeginUpdateOptions contains the optional parameters for the LabPlansClient.BeginUpdate method. -type LabPlansClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// LabPlansClientGetOptions contains the optional parameters for the LabPlansClient.Get method. -type LabPlansClientGetOptions struct { - // placeholder for future optional parameters -} - -// LabPlansClientListByResourceGroupOptions contains the optional parameters for the LabPlansClient.NewListByResourceGroupPager -// method. -type LabPlansClientListByResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// LabPlansClientListBySubscriptionOptions contains the optional parameters for the LabPlansClient.NewListBySubscriptionPager -// method. -type LabPlansClientListBySubscriptionOptions struct { - // The filter to apply to the operation. - Filter *string -} - // LabProperties - Properties of a lab resource. type LabProperties struct { // The resource auto shutdown configuration for the lab. This controls whether actions are taken on resources that are sitting @@ -496,52 +432,6 @@ type LabUpdateProperties struct { VirtualMachineProfile *VirtualMachineProfile } -// LabsClientBeginCreateOrUpdateOptions contains the optional parameters for the LabsClient.BeginCreateOrUpdate method. -type LabsClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// LabsClientBeginDeleteOptions contains the optional parameters for the LabsClient.BeginDelete method. -type LabsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// LabsClientBeginPublishOptions contains the optional parameters for the LabsClient.BeginPublish method. -type LabsClientBeginPublishOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// LabsClientBeginSyncGroupOptions contains the optional parameters for the LabsClient.BeginSyncGroup method. -type LabsClientBeginSyncGroupOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// LabsClientBeginUpdateOptions contains the optional parameters for the LabsClient.BeginUpdate method. -type LabsClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// LabsClientGetOptions contains the optional parameters for the LabsClient.Get method. -type LabsClientGetOptions struct { - // placeholder for future optional parameters -} - -// LabsClientListByResourceGroupOptions contains the optional parameters for the LabsClient.NewListByResourceGroupPager method. -type LabsClientListByResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// LabsClientListBySubscriptionOptions contains the optional parameters for the LabsClient.NewListBySubscriptionPager method. -type LabsClientListBySubscriptionOptions struct { - // The filter to apply to the operation. - Filter *string -} - // ListUsagesResult - List of Core Usages. type ListUsagesResult struct { // The array page of Usages. @@ -624,16 +514,6 @@ type OperationResult struct { Name *string } -// OperationResultsClientGetOptions contains the optional parameters for the OperationResultsClient.Get method. -type OperationResultsClientGetOptions struct { - // placeholder for future optional parameters -} - -// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. -type OperationsClientListOptions struct { - // placeholder for future optional parameters -} - // PagedImages - Paged list of Lab services virtual machine images. type PagedImages struct { // READ-ONLY; The link to get the next page of image results. @@ -866,12 +746,6 @@ type SKURestrictions struct { Values []*string } -// SKUsClientListOptions contains the optional parameters for the SKUsClient.NewListPager method. -type SKUsClientListOptions struct { - // The filter to apply to the operation. - Filter *string -} - // SaveImageBody - Body for the save image POST type SaveImageBody struct { // The ID of the lab virtual machine you want to save an image from. @@ -944,33 +818,6 @@ type ScheduleUpdateProperties struct { TimeZoneID *string } -// SchedulesClientBeginDeleteOptions contains the optional parameters for the SchedulesClient.BeginDelete method. -type SchedulesClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// SchedulesClientCreateOrUpdateOptions contains the optional parameters for the SchedulesClient.CreateOrUpdate method. -type SchedulesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// SchedulesClientGetOptions contains the optional parameters for the SchedulesClient.Get method. -type SchedulesClientGetOptions struct { - // placeholder for future optional parameters -} - -// SchedulesClientListByLabOptions contains the optional parameters for the SchedulesClient.NewListByLabPager method. -type SchedulesClientListByLabOptions struct { - // The filter to apply to the operation. - Filter *string -} - -// SchedulesClientUpdateOptions contains the optional parameters for the SchedulesClient.Update method. -type SchedulesClientUpdateOptions struct { - // placeholder for future optional parameters -} - // SecurityProfile - The lab security profile. type SecurityProfile struct { // Whether any user or only specified users can register to a lab. @@ -1071,12 +918,6 @@ type UsageName struct { Value *string } -// UsagesClientListByLocationOptions contains the optional parameters for the UsagesClient.NewListByLocationPager method. -type UsagesClientListByLocationOptions struct { - // The filter to apply to the operation. - Filter *string -} - // User of a lab that can register for and use virtual machines within the lab. type User struct { // REQUIRED; User resource properties @@ -1134,41 +975,6 @@ type UserUpdateProperties struct { AdditionalUsageQuota *string } -// UsersClientBeginCreateOrUpdateOptions contains the optional parameters for the UsersClient.BeginCreateOrUpdate method. -type UsersClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// UsersClientBeginDeleteOptions contains the optional parameters for the UsersClient.BeginDelete method. -type UsersClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// UsersClientBeginInviteOptions contains the optional parameters for the UsersClient.BeginInvite method. -type UsersClientBeginInviteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// UsersClientBeginUpdateOptions contains the optional parameters for the UsersClient.BeginUpdate method. -type UsersClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// UsersClientGetOptions contains the optional parameters for the UsersClient.Get method. -type UsersClientGetOptions struct { - // placeholder for future optional parameters -} - -// UsersClientListByLabOptions contains the optional parameters for the UsersClient.NewListByLabPager method. -type UsersClientListByLabOptions struct { - // The filter to apply to the operation. - Filter *string -} - // VirtualMachine - A lab virtual machine resource. type VirtualMachine struct { // REQUIRED; Virtual machine resource properties @@ -1264,47 +1070,3 @@ type VirtualMachineProperties struct { // READ-ONLY; The type of this VM resource VMType *VirtualMachineType } - -// VirtualMachinesClientBeginRedeployOptions contains the optional parameters for the VirtualMachinesClient.BeginRedeploy -// method. -type VirtualMachinesClientBeginRedeployOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// VirtualMachinesClientBeginReimageOptions contains the optional parameters for the VirtualMachinesClient.BeginReimage method. -type VirtualMachinesClientBeginReimageOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// VirtualMachinesClientBeginResetPasswordOptions contains the optional parameters for the VirtualMachinesClient.BeginResetPassword -// method. -type VirtualMachinesClientBeginResetPasswordOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// VirtualMachinesClientBeginStartOptions contains the optional parameters for the VirtualMachinesClient.BeginStart method. -type VirtualMachinesClientBeginStartOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// VirtualMachinesClientBeginStopOptions contains the optional parameters for the VirtualMachinesClient.BeginStop method. -type VirtualMachinesClientBeginStopOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// VirtualMachinesClientGetOptions contains the optional parameters for the VirtualMachinesClient.Get method. -type VirtualMachinesClientGetOptions struct { - // placeholder for future optional parameters -} - -// VirtualMachinesClientListByLabOptions contains the optional parameters for the VirtualMachinesClient.NewListByLabPager -// method. -type VirtualMachinesClientListByLabOptions struct { - // The filter to apply to the operation. - Filter *string -} diff --git a/sdk/resourcemanager/labservices/armlabservices/models_serde.go b/sdk/resourcemanager/labservices/armlabservices/models_serde.go index 567411920122..eae46c829a8b 100644 --- a/sdk/resourcemanager/labservices/armlabservices/models_serde.go +++ b/sdk/resourcemanager/labservices/armlabservices/models_serde.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlabservices @@ -1136,12 +1135,12 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type OperationResult. func (o OperationResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "endTime", o.EndTime) + populateDateTimeRFC3339(objectMap, "endTime", o.EndTime) populate(objectMap, "error", o.Error) populate(objectMap, "id", o.ID) populate(objectMap, "name", o.Name) populate(objectMap, "percentComplete", o.PercentComplete) - populateTimeRFC3339(objectMap, "startTime", o.StartTime) + populateDateTimeRFC3339(objectMap, "startTime", o.StartTime) populate(objectMap, "status", o.Status) return json.Marshal(objectMap) } @@ -1156,7 +1155,7 @@ func (o *OperationResult) UnmarshalJSON(data []byte) error { var err error switch key { case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &o.EndTime) + err = unpopulateDateTimeRFC3339(val, "EndTime", &o.EndTime) delete(rawMsg, key) case "error": err = unpopulate(val, "Error", &o.Error) @@ -1171,7 +1170,7 @@ func (o *OperationResult) UnmarshalJSON(data []byte) error { err = unpopulate(val, "PercentComplete", &o.PercentComplete) delete(rawMsg, key) case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &o.StartTime) + err = unpopulateDateTimeRFC3339(val, "StartTime", &o.StartTime) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &o.Status) @@ -1439,7 +1438,7 @@ func (p *ProxyResource) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RecurrencePattern. func (r RecurrencePattern) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "expirationDate", r.ExpirationDate) + populateDateTimeRFC3339(objectMap, "expirationDate", r.ExpirationDate) populate(objectMap, "frequency", r.Frequency) populate(objectMap, "interval", r.Interval) populate(objectMap, "weekDays", r.WeekDays) @@ -1456,7 +1455,7 @@ func (r *RecurrencePattern) UnmarshalJSON(data []byte) error { var err error switch key { case "expirationDate": - err = unpopulateTimeRFC3339(val, "ExpirationDate", &r.ExpirationDate) + err = unpopulateDateTimeRFC3339(val, "ExpirationDate", &r.ExpirationDate) delete(rawMsg, key) case "frequency": err = unpopulate(val, "Frequency", &r.Frequency) @@ -1910,8 +1909,8 @@ func (s ScheduleProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "notes", s.Notes) populate(objectMap, "provisioningState", s.ProvisioningState) populate(objectMap, "recurrencePattern", s.RecurrencePattern) - populateTimeRFC3339(objectMap, "startAt", s.StartAt) - populateTimeRFC3339(objectMap, "stopAt", s.StopAt) + populateDateTimeRFC3339(objectMap, "startAt", s.StartAt) + populateDateTimeRFC3339(objectMap, "stopAt", s.StopAt) populate(objectMap, "timeZoneId", s.TimeZoneID) return json.Marshal(objectMap) } @@ -1935,10 +1934,10 @@ func (s *ScheduleProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "RecurrencePattern", &s.RecurrencePattern) delete(rawMsg, key) case "startAt": - err = unpopulateTimeRFC3339(val, "StartAt", &s.StartAt) + err = unpopulateDateTimeRFC3339(val, "StartAt", &s.StartAt) delete(rawMsg, key) case "stopAt": - err = unpopulateTimeRFC3339(val, "StopAt", &s.StopAt) + err = unpopulateDateTimeRFC3339(val, "StopAt", &s.StopAt) delete(rawMsg, key) case "timeZoneId": err = unpopulate(val, "TimeZoneID", &s.TimeZoneID) @@ -1983,8 +1982,8 @@ func (s ScheduleUpdateProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "notes", s.Notes) populate(objectMap, "recurrencePattern", s.RecurrencePattern) - populateTimeRFC3339(objectMap, "startAt", s.StartAt) - populateTimeRFC3339(objectMap, "stopAt", s.StopAt) + populateDateTimeRFC3339(objectMap, "startAt", s.StartAt) + populateDateTimeRFC3339(objectMap, "stopAt", s.StopAt) populate(objectMap, "timeZoneId", s.TimeZoneID) return json.Marshal(objectMap) } @@ -2005,10 +2004,10 @@ func (s *ScheduleUpdateProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "RecurrencePattern", &s.RecurrencePattern) delete(rawMsg, key) case "startAt": - err = unpopulateTimeRFC3339(val, "StartAt", &s.StartAt) + err = unpopulateDateTimeRFC3339(val, "StartAt", &s.StartAt) delete(rawMsg, key) case "stopAt": - err = unpopulateTimeRFC3339(val, "StopAt", &s.StopAt) + err = unpopulateDateTimeRFC3339(val, "StopAt", &s.StopAt) delete(rawMsg, key) case "timeZoneId": err = unpopulate(val, "TimeZoneID", &s.TimeZoneID) @@ -2094,10 +2093,10 @@ func (s *SupportInfo) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) populate(objectMap, "lastModifiedBy", s.LastModifiedBy) populate(objectMap, "lastModifiedByType", s.LastModifiedByType) return json.Marshal(objectMap) @@ -2113,7 +2112,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { var err error switch key { case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) delete(rawMsg, key) case "createdBy": err = unpopulate(val, "CreatedBy", &s.CreatedBy) @@ -2122,7 +2121,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { err = unpopulate(val, "CreatedByType", &s.CreatedByType) delete(rawMsg, key) case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) delete(rawMsg, key) case "lastModifiedBy": err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) @@ -2335,7 +2334,7 @@ func (u UserProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "additionalUsageQuota", u.AdditionalUsageQuota) populate(objectMap, "displayName", u.DisplayName) populate(objectMap, "email", u.Email) - populateTimeRFC3339(objectMap, "invitationSent", u.InvitationSent) + populateDateTimeRFC3339(objectMap, "invitationSent", u.InvitationSent) populate(objectMap, "invitationState", u.InvitationState) populate(objectMap, "provisioningState", u.ProvisioningState) populate(objectMap, "registrationState", u.RegistrationState) @@ -2362,7 +2361,7 @@ func (u *UserProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Email", &u.Email) delete(rawMsg, key) case "invitationSent": - err = unpopulateTimeRFC3339(val, "InvitationSent", &u.InvitationSent) + err = unpopulateDateTimeRFC3339(val, "InvitationSent", &u.InvitationSent) delete(rawMsg, key) case "invitationState": err = unpopulate(val, "InvitationState", &u.InvitationState) diff --git a/sdk/resourcemanager/labservices/armlabservices/operationresults_client.go b/sdk/resourcemanager/labservices/armlabservices/operationresults_client.go index b784b8117c4d..587d0f64f170 100644 --- a/sdk/resourcemanager/labservices/armlabservices/operationresults_client.go +++ b/sdk/resourcemanager/labservices/armlabservices/operationresults_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlabservices @@ -33,7 +32,7 @@ type OperationResultsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationResultsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationResultsClient, error) { - cl, err := arm.NewClient(moduleName+".OperationResultsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -51,18 +50,25 @@ func NewOperationResultsClient(subscriptionID string, credential azcore.TokenCre // - operationResultID - The operation result ID / name. // - options - OperationResultsClientGetOptions contains the optional parameters for the OperationResultsClient.Get method. func (client *OperationResultsClient) Get(ctx context.Context, operationResultID string, options *OperationResultsClientGetOptions) (OperationResultsClientGetResponse, error) { + var err error + const operationName = "OperationResultsClient.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, operationResultID, options) if err != nil { return OperationResultsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return OperationResultsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return OperationResultsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return OperationResultsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. diff --git a/sdk/resourcemanager/labservices/armlabservices/operationresults_client_example_test.go b/sdk/resourcemanager/labservices/armlabservices/operationresults_client_example_test.go index fd979eba1466..4235d3fbad36 100644 --- a/sdk/resourcemanager/labservices/armlabservices/operationresults_client_example_test.go +++ b/sdk/resourcemanager/labservices/armlabservices/operationresults_client_example_test.go @@ -38,7 +38,7 @@ func ExampleOperationResultsClient_Get() { // res.OperationResult = armlabservices.OperationResult{ // Name: to.Ptr("a64149d8-84cb-4566-ab8e-b4ee1a074174"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/providers/Microsoft.LabServices/operationresults/a64149d8-84cb-4566-ab8e-b4ee1a074174"), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // Status: to.Ptr(armlabservices.OperationStatusInProgress), // } } diff --git a/sdk/resourcemanager/labservices/armlabservices/operations_client.go b/sdk/resourcemanager/labservices/armlabservices/operations_client.go index 2053af24b453..2c386092db2e 100644 --- a/sdk/resourcemanager/labservices/armlabservices/operations_client.go +++ b/sdk/resourcemanager/labservices/armlabservices/operations_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlabservices @@ -28,7 +27,7 @@ type OperationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -48,25 +47,20 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.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, options) + }, nil) if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return OperationsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OperationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/labservices/armlabservices/options.go b/sdk/resourcemanager/labservices/armlabservices/options.go new file mode 100644 index 000000000000..74298d6bc6bf --- /dev/null +++ b/sdk/resourcemanager/labservices/armlabservices/options.go @@ -0,0 +1,246 @@ +//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 armlabservices + +// ImagesClientCreateOrUpdateOptions contains the optional parameters for the ImagesClient.CreateOrUpdate method. +type ImagesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// ImagesClientGetOptions contains the optional parameters for the ImagesClient.Get method. +type ImagesClientGetOptions struct { + // placeholder for future optional parameters +} + +// ImagesClientListByLabPlanOptions contains the optional parameters for the ImagesClient.NewListByLabPlanPager method. +type ImagesClientListByLabPlanOptions struct { + // The filter to apply to the operation. + Filter *string +} + +// ImagesClientUpdateOptions contains the optional parameters for the ImagesClient.Update method. +type ImagesClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// LabPlansClientBeginCreateOrUpdateOptions contains the optional parameters for the LabPlansClient.BeginCreateOrUpdate method. +type LabPlansClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// LabPlansClientBeginDeleteOptions contains the optional parameters for the LabPlansClient.BeginDelete method. +type LabPlansClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// LabPlansClientBeginSaveImageOptions contains the optional parameters for the LabPlansClient.BeginSaveImage method. +type LabPlansClientBeginSaveImageOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// LabPlansClientBeginUpdateOptions contains the optional parameters for the LabPlansClient.BeginUpdate method. +type LabPlansClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// LabPlansClientGetOptions contains the optional parameters for the LabPlansClient.Get method. +type LabPlansClientGetOptions struct { + // placeholder for future optional parameters +} + +// LabPlansClientListByResourceGroupOptions contains the optional parameters for the LabPlansClient.NewListByResourceGroupPager +// method. +type LabPlansClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// LabPlansClientListBySubscriptionOptions contains the optional parameters for the LabPlansClient.NewListBySubscriptionPager +// method. +type LabPlansClientListBySubscriptionOptions struct { + // The filter to apply to the operation. + Filter *string +} + +// LabsClientBeginCreateOrUpdateOptions contains the optional parameters for the LabsClient.BeginCreateOrUpdate method. +type LabsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// LabsClientBeginDeleteOptions contains the optional parameters for the LabsClient.BeginDelete method. +type LabsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// LabsClientBeginPublishOptions contains the optional parameters for the LabsClient.BeginPublish method. +type LabsClientBeginPublishOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// LabsClientBeginSyncGroupOptions contains the optional parameters for the LabsClient.BeginSyncGroup method. +type LabsClientBeginSyncGroupOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// LabsClientBeginUpdateOptions contains the optional parameters for the LabsClient.BeginUpdate method. +type LabsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// LabsClientGetOptions contains the optional parameters for the LabsClient.Get method. +type LabsClientGetOptions struct { + // placeholder for future optional parameters +} + +// LabsClientListByResourceGroupOptions contains the optional parameters for the LabsClient.NewListByResourceGroupPager method. +type LabsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// LabsClientListBySubscriptionOptions contains the optional parameters for the LabsClient.NewListBySubscriptionPager method. +type LabsClientListBySubscriptionOptions struct { + // The filter to apply to the operation. + Filter *string +} + +// OperationResultsClientGetOptions contains the optional parameters for the OperationResultsClient.Get method. +type OperationResultsClientGetOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// SKUsClientListOptions contains the optional parameters for the SKUsClient.NewListPager method. +type SKUsClientListOptions struct { + // The filter to apply to the operation. + Filter *string +} + +// SchedulesClientBeginDeleteOptions contains the optional parameters for the SchedulesClient.BeginDelete method. +type SchedulesClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SchedulesClientCreateOrUpdateOptions contains the optional parameters for the SchedulesClient.CreateOrUpdate method. +type SchedulesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// SchedulesClientGetOptions contains the optional parameters for the SchedulesClient.Get method. +type SchedulesClientGetOptions struct { + // placeholder for future optional parameters +} + +// SchedulesClientListByLabOptions contains the optional parameters for the SchedulesClient.NewListByLabPager method. +type SchedulesClientListByLabOptions struct { + // The filter to apply to the operation. + Filter *string +} + +// SchedulesClientUpdateOptions contains the optional parameters for the SchedulesClient.Update method. +type SchedulesClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// UsagesClientListByLocationOptions contains the optional parameters for the UsagesClient.NewListByLocationPager method. +type UsagesClientListByLocationOptions struct { + // The filter to apply to the operation. + Filter *string +} + +// UsersClientBeginCreateOrUpdateOptions contains the optional parameters for the UsersClient.BeginCreateOrUpdate method. +type UsersClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// UsersClientBeginDeleteOptions contains the optional parameters for the UsersClient.BeginDelete method. +type UsersClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// UsersClientBeginInviteOptions contains the optional parameters for the UsersClient.BeginInvite method. +type UsersClientBeginInviteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// UsersClientBeginUpdateOptions contains the optional parameters for the UsersClient.BeginUpdate method. +type UsersClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// UsersClientGetOptions contains the optional parameters for the UsersClient.Get method. +type UsersClientGetOptions struct { + // placeholder for future optional parameters +} + +// UsersClientListByLabOptions contains the optional parameters for the UsersClient.NewListByLabPager method. +type UsersClientListByLabOptions struct { + // The filter to apply to the operation. + Filter *string +} + +// VirtualMachinesClientBeginRedeployOptions contains the optional parameters for the VirtualMachinesClient.BeginRedeploy +// method. +type VirtualMachinesClientBeginRedeployOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientBeginReimageOptions contains the optional parameters for the VirtualMachinesClient.BeginReimage method. +type VirtualMachinesClientBeginReimageOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientBeginResetPasswordOptions contains the optional parameters for the VirtualMachinesClient.BeginResetPassword +// method. +type VirtualMachinesClientBeginResetPasswordOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientBeginStartOptions contains the optional parameters for the VirtualMachinesClient.BeginStart method. +type VirtualMachinesClientBeginStartOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientBeginStopOptions contains the optional parameters for the VirtualMachinesClient.BeginStop method. +type VirtualMachinesClientBeginStopOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// VirtualMachinesClientGetOptions contains the optional parameters for the VirtualMachinesClient.Get method. +type VirtualMachinesClientGetOptions struct { + // placeholder for future optional parameters +} + +// VirtualMachinesClientListByLabOptions contains the optional parameters for the VirtualMachinesClient.NewListByLabPager +// method. +type VirtualMachinesClientListByLabOptions struct { + // The filter to apply to the operation. + Filter *string +} diff --git a/sdk/resourcemanager/labservices/armlabservices/response_types.go b/sdk/resourcemanager/labservices/armlabservices/response_types.go index eba3a1683e57..24bcbf200f8d 100644 --- a/sdk/resourcemanager/labservices/armlabservices/response_types.go +++ b/sdk/resourcemanager/labservices/armlabservices/response_types.go @@ -3,34 +3,39 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlabservices // ImagesClientCreateOrUpdateResponse contains the response from method ImagesClient.CreateOrUpdate. type ImagesClientCreateOrUpdateResponse struct { + // Lab services virtual machine image Image } // ImagesClientGetResponse contains the response from method ImagesClient.Get. type ImagesClientGetResponse struct { + // Lab services virtual machine image Image } // ImagesClientListByLabPlanResponse contains the response from method ImagesClient.NewListByLabPlanPager. type ImagesClientListByLabPlanResponse struct { + // Paged list of Lab services virtual machine images. PagedImages } // ImagesClientUpdateResponse contains the response from method ImagesClient.Update. type ImagesClientUpdateResponse struct { + // Lab services virtual machine image Image } // LabPlansClientCreateOrUpdateResponse contains the response from method LabPlansClient.BeginCreateOrUpdate. type LabPlansClientCreateOrUpdateResponse struct { + // Lab Plans act as a permission container for creating labs via labs.azure.com. Additionally, they can provide a set of default + // configurations that will apply at the time of creating a lab, but these defaults can still be overwritten. LabPlan } @@ -41,16 +46,20 @@ type LabPlansClientDeleteResponse struct { // LabPlansClientGetResponse contains the response from method LabPlansClient.Get. type LabPlansClientGetResponse struct { + // Lab Plans act as a permission container for creating labs via labs.azure.com. Additionally, they can provide a set of default + // configurations that will apply at the time of creating a lab, but these defaults can still be overwritten. LabPlan } // LabPlansClientListByResourceGroupResponse contains the response from method LabPlansClient.NewListByResourceGroupPager. type LabPlansClientListByResourceGroupResponse struct { + // Paged list of lab plans. PagedLabPlans } // LabPlansClientListBySubscriptionResponse contains the response from method LabPlansClient.NewListBySubscriptionPager. type LabPlansClientListBySubscriptionResponse struct { + // Paged list of lab plans. PagedLabPlans } @@ -61,11 +70,14 @@ type LabPlansClientSaveImageResponse struct { // LabPlansClientUpdateResponse contains the response from method LabPlansClient.BeginUpdate. type LabPlansClientUpdateResponse struct { + // Lab Plans act as a permission container for creating labs via labs.azure.com. Additionally, they can provide a set of default + // configurations that will apply at the time of creating a lab, but these defaults can still be overwritten. LabPlan } // LabsClientCreateOrUpdateResponse contains the response from method LabsClient.BeginCreateOrUpdate. type LabsClientCreateOrUpdateResponse struct { + // The lab resource. Lab } @@ -76,16 +88,19 @@ type LabsClientDeleteResponse struct { // LabsClientGetResponse contains the response from method LabsClient.Get. type LabsClientGetResponse struct { + // The lab resource. Lab } // LabsClientListByResourceGroupResponse contains the response from method LabsClient.NewListByResourceGroupPager. type LabsClientListByResourceGroupResponse struct { + // Paged list of labs. PagedLabs } // LabsClientListBySubscriptionResponse contains the response from method LabsClient.NewListBySubscriptionPager. type LabsClientListBySubscriptionResponse struct { + // Paged list of labs. PagedLabs } @@ -101,26 +116,31 @@ type LabsClientSyncGroupResponse struct { // LabsClientUpdateResponse contains the response from method LabsClient.BeginUpdate. type LabsClientUpdateResponse struct { + // The lab resource. Lab } // OperationResultsClientGetResponse contains the response from method OperationResultsClient.Get. type OperationResultsClientGetResponse struct { + // A long running operation result OperationResult } // 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 } // SKUsClientListResponse contains the response from method SKUsClient.NewListPager. type SKUsClientListResponse struct { + // Paged list of lab services skus. PagedSKUInfos } // SchedulesClientCreateOrUpdateResponse contains the response from method SchedulesClient.CreateOrUpdate. type SchedulesClientCreateOrUpdateResponse struct { + // Schedule for automatically turning virtual machines in a lab on and off at specified times. Schedule } @@ -131,26 +151,31 @@ type SchedulesClientDeleteResponse struct { // SchedulesClientGetResponse contains the response from method SchedulesClient.Get. type SchedulesClientGetResponse struct { + // Schedule for automatically turning virtual machines in a lab on and off at specified times. Schedule } // SchedulesClientListByLabResponse contains the response from method SchedulesClient.NewListByLabPager. type SchedulesClientListByLabResponse struct { + // Paged list of schedules. PagedSchedules } // SchedulesClientUpdateResponse contains the response from method SchedulesClient.Update. type SchedulesClientUpdateResponse struct { + // Schedule for automatically turning virtual machines in a lab on and off at specified times. Schedule } // UsagesClientListByLocationResponse contains the response from method UsagesClient.NewListByLocationPager. type UsagesClientListByLocationResponse struct { + // List of Core Usages. ListUsagesResult } // UsersClientCreateOrUpdateResponse contains the response from method UsersClient.BeginCreateOrUpdate. type UsersClientCreateOrUpdateResponse struct { + // User of a lab that can register for and use virtual machines within the lab. User } @@ -161,6 +186,7 @@ type UsersClientDeleteResponse struct { // UsersClientGetResponse contains the response from method UsersClient.Get. type UsersClientGetResponse struct { + // User of a lab that can register for and use virtual machines within the lab. User } @@ -171,21 +197,25 @@ type UsersClientInviteResponse struct { // UsersClientListByLabResponse contains the response from method UsersClient.NewListByLabPager. type UsersClientListByLabResponse struct { + // Paged list of users. PagedUsers } // UsersClientUpdateResponse contains the response from method UsersClient.BeginUpdate. type UsersClientUpdateResponse struct { + // User of a lab that can register for and use virtual machines within the lab. User } // VirtualMachinesClientGetResponse contains the response from method VirtualMachinesClient.Get. type VirtualMachinesClientGetResponse struct { + // A lab virtual machine resource. VirtualMachine } // VirtualMachinesClientListByLabResponse contains the response from method VirtualMachinesClient.NewListByLabPager. type VirtualMachinesClientListByLabResponse struct { + // Paged list of lab services virtual machines. PagedVirtualMachines } diff --git a/sdk/resourcemanager/labservices/armlabservices/schedules_client.go b/sdk/resourcemanager/labservices/armlabservices/schedules_client.go index 65f82b68090c..d337dee3aba9 100644 --- a/sdk/resourcemanager/labservices/armlabservices/schedules_client.go +++ b/sdk/resourcemanager/labservices/armlabservices/schedules_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlabservices @@ -33,7 +32,7 @@ type SchedulesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSchedulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SchedulesClient, error) { - cl, err := arm.NewClient(moduleName+".SchedulesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,18 +54,25 @@ func NewSchedulesClient(subscriptionID string, credential azcore.TokenCredential // - options - SchedulesClientCreateOrUpdateOptions contains the optional parameters for the SchedulesClient.CreateOrUpdate // method. func (client *SchedulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, labName string, scheduleName string, body Schedule, options *SchedulesClientCreateOrUpdateOptions) (SchedulesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "SchedulesClient.CreateOrUpdate" + 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, labName, scheduleName, body, options) if err != nil { return SchedulesClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SchedulesClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return SchedulesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return SchedulesClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -96,7 +102,10 @@ func (client *SchedulesClient) createOrUpdateCreateRequest(ctx context.Context, reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -122,11 +131,15 @@ func (client *SchedulesClient) BeginDelete(ctx context.Context, resourceGroupNam if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SchedulesClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SchedulesClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[SchedulesClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SchedulesClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -135,18 +148,24 @@ func (client *SchedulesClient) BeginDelete(ctx context.Context, resourceGroupNam // // Generated from API version 2022-08-01 func (client *SchedulesClient) deleteOperation(ctx context.Context, resourceGroupName string, labName string, scheduleName string, options *SchedulesClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "SchedulesClient.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, labName, scheduleName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -188,18 +207,25 @@ func (client *SchedulesClient) deleteCreateRequest(ctx context.Context, resource // - scheduleName - The name of the schedule that uniquely identifies it within containing lab. Used in resource URIs. // - options - SchedulesClientGetOptions contains the optional parameters for the SchedulesClient.Get method. func (client *SchedulesClient) Get(ctx context.Context, resourceGroupName string, labName string, scheduleName string, options *SchedulesClientGetOptions) (SchedulesClientGetResponse, error) { + var err error + const operationName = "SchedulesClient.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, labName, scheduleName, options) if err != nil { return SchedulesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SchedulesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SchedulesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SchedulesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -253,25 +279,20 @@ func (client *SchedulesClient) NewListByLabPager(resourceGroupName string, labNa return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *SchedulesClientListByLabResponse) (SchedulesClientListByLabResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByLabCreateRequest(ctx, resourceGroupName, labName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SchedulesClient.NewListByLabPager") + 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.listByLabCreateRequest(ctx, resourceGroupName, labName, options) + }, nil) if err != nil { return SchedulesClientListByLabResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return SchedulesClientListByLabResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SchedulesClientListByLabResponse{}, runtime.NewResponseError(resp) - } return client.listByLabHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -323,18 +344,25 @@ func (client *SchedulesClient) listByLabHandleResponse(resp *http.Response) (Sch // - body - The request body. // - options - SchedulesClientUpdateOptions contains the optional parameters for the SchedulesClient.Update method. func (client *SchedulesClient) Update(ctx context.Context, resourceGroupName string, labName string, scheduleName string, body ScheduleUpdate, options *SchedulesClientUpdateOptions) (SchedulesClientUpdateResponse, error) { + var err error + const operationName = "SchedulesClient.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, labName, scheduleName, body, options) if err != nil { return SchedulesClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SchedulesClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SchedulesClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SchedulesClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -364,7 +392,10 @@ func (client *SchedulesClient) updateCreateRequest(ctx context.Context, resource reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // updateHandleResponse handles the Update response. diff --git a/sdk/resourcemanager/labservices/armlabservices/schedules_client_example_test.go b/sdk/resourcemanager/labservices/armlabservices/schedules_client_example_test.go index 95c6d6028ccd..7017859a476b 100644 --- a/sdk/resourcemanager/labservices/armlabservices/schedules_client_example_test.go +++ b/sdk/resourcemanager/labservices/armlabservices/schedules_client_example_test.go @@ -51,20 +51,20 @@ func ExampleSchedulesClient_NewListByLabPager() { // Properties: &armlabservices.ScheduleProperties{ // Notes: to.Ptr("Schedule 1 for students"), // RecurrencePattern: &armlabservices.RecurrencePattern{ - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-14T23:59:59Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-14T23:59:59.000Z"); return t}()), // Frequency: to.Ptr(armlabservices.RecurrenceFrequencyDaily), // Interval: to.Ptr[int32](1), // }, - // StartAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T12:00:00Z"); return t}()), - // StopAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T18:00:00Z"); return t}()), + // StartAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T12:00:00.000Z"); return t}()), + // StopAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T18:00:00.000Z"); return t}()), // TimeZoneID: to.Ptr("America/Los_Angeles"), // ProvisioningState: to.Ptr(armlabservices.ProvisioningStateSucceeded), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -76,7 +76,7 @@ func ExampleSchedulesClient_NewListByLabPager() { // Properties: &armlabservices.ScheduleProperties{ // Notes: to.Ptr("Schedule 2 for students"), // RecurrencePattern: &armlabservices.RecurrencePattern{ - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-14T23:59:59Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-14T23:59:59.000Z"); return t}()), // Frequency: to.Ptr(armlabservices.RecurrenceFrequencyWeekly), // WeekDays: []*armlabservices.WeekDay{ // to.Ptr(armlabservices.WeekDayMonday), @@ -85,16 +85,16 @@ func ExampleSchedulesClient_NewListByLabPager() { // to.Ptr(armlabservices.WeekDayThursday), // to.Ptr(armlabservices.WeekDayFriday)}, // }, - // StartAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T12:00:00Z"); return t}()), - // StopAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T18:00:00Z"); return t}()), + // StartAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T12:00:00.000Z"); return t}()), + // StopAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T18:00:00.000Z"); return t}()), // TimeZoneID: to.Ptr("America/Los_Angeles"), // ProvisioningState: to.Ptr(armlabservices.ProvisioningStateSucceeded), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -128,20 +128,20 @@ func ExampleSchedulesClient_Get() { // Properties: &armlabservices.ScheduleProperties{ // Notes: to.Ptr("Schedule 1 for students"), // RecurrencePattern: &armlabservices.RecurrencePattern{ - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-14T23:59:59Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-14T23:59:59.000Z"); return t}()), // Frequency: to.Ptr(armlabservices.RecurrenceFrequencyDaily), // Interval: to.Ptr[int32](1), // }, - // StartAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T12:00:00Z"); return t}()), - // StopAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T18:00:00Z"); return t}()), + // StartAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T12:00:00.000Z"); return t}()), + // StopAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T18:00:00.000Z"); return t}()), // TimeZoneID: to.Ptr("America/Los_Angeles"), // ProvisioningState: to.Ptr(armlabservices.ProvisioningStateSucceeded), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -163,12 +163,12 @@ func ExampleSchedulesClient_CreateOrUpdate() { Properties: &armlabservices.ScheduleProperties{ Notes: to.Ptr("Schedule 1 for students"), RecurrencePattern: &armlabservices.RecurrencePattern{ - ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-14T23:59:59Z"); return t }()), + ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-14T23:59:59.000Z"); return t }()), Frequency: to.Ptr(armlabservices.RecurrenceFrequencyDaily), Interval: to.Ptr[int32](2), }, - StartAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T12:00:00Z"); return t }()), - StopAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T18:00:00Z"); return t }()), + StartAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T12:00:00.000Z"); return t }()), + StopAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T18:00:00.000Z"); return t }()), TimeZoneID: to.Ptr("America/Los_Angeles"), }, }, nil) @@ -185,20 +185,20 @@ func ExampleSchedulesClient_CreateOrUpdate() { // Properties: &armlabservices.ScheduleProperties{ // Notes: to.Ptr("Schedule 1 for students"), // RecurrencePattern: &armlabservices.RecurrencePattern{ - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-14T23:59:59Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-14T23:59:59.000Z"); return t}()), // Frequency: to.Ptr(armlabservices.RecurrenceFrequencyDaily), // Interval: to.Ptr[int32](2), // }, - // StartAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T12:00:00Z"); return t}()), - // StopAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T18:00:00Z"); return t}()), + // StartAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T12:00:00.000Z"); return t}()), + // StopAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T18:00:00.000Z"); return t}()), // TimeZoneID: to.Ptr("America/Los_Angeles"), // ProvisioningState: to.Ptr(armlabservices.ProvisioningStateSucceeded), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -219,7 +219,7 @@ func ExampleSchedulesClient_Update() { res, err := clientFactory.NewSchedulesClient().Update(ctx, "testrg123", "testlab", "schedule1", armlabservices.ScheduleUpdate{ Properties: &armlabservices.ScheduleUpdateProperties{ RecurrencePattern: &armlabservices.RecurrencePattern{ - ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-14T23:59:59Z"); return t }()), + ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-14T23:59:59.000Z"); return t }()), Frequency: to.Ptr(armlabservices.RecurrenceFrequencyDaily), Interval: to.Ptr[int32](2), }, @@ -238,20 +238,20 @@ func ExampleSchedulesClient_Update() { // Properties: &armlabservices.ScheduleProperties{ // Notes: to.Ptr("Schedule 1 for students"), // RecurrencePattern: &armlabservices.RecurrencePattern{ - // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-14T23:59:59Z"); return t}()), + // ExpirationDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-08-14T23:59:59.000Z"); return t}()), // Frequency: to.Ptr(armlabservices.RecurrenceFrequencyDaily), // Interval: to.Ptr[int32](2), // }, - // StartAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T12:00:00Z"); return t}()), - // StopAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T18:00:00Z"); return t}()), + // StartAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T12:00:00.000Z"); return t}()), + // StopAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-26T18:00:00.000Z"); return t}()), // TimeZoneID: to.Ptr("America/Los_Angeles"), // ProvisioningState: to.Ptr(armlabservices.ProvisioningStateSucceeded), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, diff --git a/sdk/resourcemanager/labservices/armlabservices/skus_client.go b/sdk/resourcemanager/labservices/armlabservices/skus_client.go index b2d7ea9d75de..57c9d4973e12 100644 --- a/sdk/resourcemanager/labservices/armlabservices/skus_client.go +++ b/sdk/resourcemanager/labservices/armlabservices/skus_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlabservices @@ -33,7 +32,7 @@ type SKUsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSKUsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SKUsClient, error) { - cl, err := arm.NewClient(moduleName+".SKUsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,25 +53,20 @@ func (client *SKUsClient) NewListPager(options *SKUsClientListOptions) *runtime. return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *SKUsClientListResponse) (SKUsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SKUsClient.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, options) + }, nil) if err != nil { return SKUsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return SKUsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SKUsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/labservices/armlabservices/time_rfc3339.go b/sdk/resourcemanager/labservices/armlabservices/time_rfc3339.go index 88ecf6a4a80e..7b8981eff92b 100644 --- a/sdk/resourcemanager/labservices/armlabservices/time_rfc3339.go +++ b/sdk/resourcemanager/labservices/armlabservices/time_rfc3339.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlabservices @@ -19,50 +18,50 @@ import ( "time" ) -const ( - utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` - utcLayout = "2006-01-02T15:04:05.999999999" - rfc3339JSON = `"` + time.RFC3339Nano + `"` -) - // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) -type timeRFC3339 time.Time +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time -func (t timeRFC3339) MarshalJSON() (json []byte, err error) { +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { tt := time.Time(t) return tt.MarshalJSON() } -func (t timeRFC3339) MarshalText() (text []byte, err error) { +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { tt := time.Time(t) return tt.MarshalText() } -func (t *timeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcLayoutJSON +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON if tzOffsetRegex.Match(data) { - layout = rfc3339JSON + layout = dateTimeJSON } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { - layout := utcLayout +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime if tzOffsetRegex.Match(data) { layout = time.RFC3339Nano } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) Parse(layout, value string) error { +func (t *dateTimeRFC3339) Parse(layout, value string) error { p, err := time.Parse(layout, strings.ToUpper(value)) - *t = timeRFC3339(p) + *t = dateTimeRFC3339(p) return err } -func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { @@ -71,14 +70,14 @@ func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { } else if reflect.ValueOf(t).IsNil() { return } - m[k] = (*timeRFC3339)(t) + m[k] = (*dateTimeRFC3339)(t) } -func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { if data == nil || strings.EqualFold(string(data), "null") { return nil } - var aux timeRFC3339 + var aux dateTimeRFC3339 if err := json.Unmarshal(data, &aux); err != nil { return fmt.Errorf("struct field %s: %v", fn, err) } diff --git a/sdk/resourcemanager/labservices/armlabservices/usages_client.go b/sdk/resourcemanager/labservices/armlabservices/usages_client.go index 2e2cb9a76826..c74de79ca4ec 100644 --- a/sdk/resourcemanager/labservices/armlabservices/usages_client.go +++ b/sdk/resourcemanager/labservices/armlabservices/usages_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlabservices @@ -33,7 +32,7 @@ type UsagesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewUsagesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*UsagesClient, error) { - cl, err := arm.NewClient(moduleName+".UsagesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -56,25 +55,20 @@ func (client *UsagesClient) NewListByLocationPager(location string, options *Usa return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *UsagesClientListByLocationResponse) (UsagesClientListByLocationResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByLocationCreateRequest(ctx, location, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "UsagesClient.NewListByLocationPager") + 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.listByLocationCreateRequest(ctx, location, options) + }, nil) if err != nil { return UsagesClientListByLocationResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return UsagesClientListByLocationResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return UsagesClientListByLocationResponse{}, runtime.NewResponseError(resp) - } return client.listByLocationHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/labservices/armlabservices/users_client.go b/sdk/resourcemanager/labservices/armlabservices/users_client.go index fa58528dd6c8..262d1708c7fa 100644 --- a/sdk/resourcemanager/labservices/armlabservices/users_client.go +++ b/sdk/resourcemanager/labservices/armlabservices/users_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlabservices @@ -33,7 +32,7 @@ type UsersClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewUsersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*UsersClient, error) { - cl, err := arm.NewClient(moduleName+".UsersClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -60,11 +59,15 @@ func (client *UsersClient) BeginCreateOrUpdate(ctx context.Context, resourceGrou if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[UsersClientCreateOrUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[UsersClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaOriginalURI, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[UsersClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[UsersClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -73,18 +76,24 @@ func (client *UsersClient) BeginCreateOrUpdate(ctx context.Context, resourceGrou // // Generated from API version 2022-08-01 func (client *UsersClient) createOrUpdate(ctx context.Context, resourceGroupName string, labName string, userName string, body User, options *UsersClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "UsersClient.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, labName, userName, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -114,7 +123,10 @@ func (client *UsersClient) createOrUpdateCreateRequest(ctx context.Context, reso reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Operation to delete a user resource. @@ -131,11 +143,15 @@ func (client *UsersClient) BeginDelete(ctx context.Context, resourceGroupName st if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[UsersClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[UsersClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[UsersClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[UsersClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -144,18 +160,24 @@ func (client *UsersClient) BeginDelete(ctx context.Context, resourceGroupName st // // Generated from API version 2022-08-01 func (client *UsersClient) deleteOperation(ctx context.Context, resourceGroupName string, labName string, userName string, options *UsersClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "UsersClient.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, labName, userName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -197,18 +219,25 @@ func (client *UsersClient) deleteCreateRequest(ctx context.Context, resourceGrou // - userName - The name of the user that uniquely identifies it within containing lab. Used in resource URIs. // - options - UsersClientGetOptions contains the optional parameters for the UsersClient.Get method. func (client *UsersClient) Get(ctx context.Context, resourceGroupName string, labName string, userName string, options *UsersClientGetOptions) (UsersClientGetResponse, error) { + var err error + const operationName = "UsersClient.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, labName, userName, options) if err != nil { return UsersClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return UsersClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return UsersClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return UsersClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -265,11 +294,15 @@ func (client *UsersClient) BeginInvite(ctx context.Context, resourceGroupName st if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[UsersClientInviteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[UsersClientInviteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[UsersClientInviteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[UsersClientInviteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -278,18 +311,24 @@ func (client *UsersClient) BeginInvite(ctx context.Context, resourceGroupName st // // Generated from API version 2022-08-01 func (client *UsersClient) invite(ctx context.Context, resourceGroupName string, labName string, userName string, body InviteBody, options *UsersClientBeginInviteOptions) (*http.Response, error) { + var err error + const operationName = "UsersClient.BeginInvite" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.inviteCreateRequest(ctx, resourceGroupName, labName, userName, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // inviteCreateRequest creates the Invite request. @@ -319,7 +358,10 @@ func (client *UsersClient) inviteCreateRequest(ctx context.Context, resourceGrou reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // NewListByLabPager - Returns a list of all users for a lab. @@ -334,25 +376,20 @@ func (client *UsersClient) NewListByLabPager(resourceGroupName string, labName s return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *UsersClientListByLabResponse) (UsersClientListByLabResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByLabCreateRequest(ctx, resourceGroupName, labName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return UsersClientListByLabResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "UsersClient.NewListByLabPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByLabCreateRequest(ctx, resourceGroupName, labName, options) + }, nil) if err != nil { return UsersClientListByLabResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return UsersClientListByLabResponse{}, runtime.NewResponseError(resp) - } return client.listByLabHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -409,11 +446,15 @@ func (client *UsersClient) BeginUpdate(ctx context.Context, resourceGroupName st if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[UsersClientUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[UsersClientUpdateResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[UsersClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[UsersClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -422,18 +463,24 @@ func (client *UsersClient) BeginUpdate(ctx context.Context, resourceGroupName st // // Generated from API version 2022-08-01 func (client *UsersClient) update(ctx context.Context, resourceGroupName string, labName string, userName string, body UserUpdate, options *UsersClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "UsersClient.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, labName, userName, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // updateCreateRequest creates the Update request. @@ -463,5 +510,8 @@ func (client *UsersClient) updateCreateRequest(ctx context.Context, resourceGrou reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/labservices/armlabservices/users_client_example_test.go b/sdk/resourcemanager/labservices/armlabservices/users_client_example_test.go index 3e4c6e2b915e..d10b2e80e8e3 100644 --- a/sdk/resourcemanager/labservices/armlabservices/users_client_example_test.go +++ b/sdk/resourcemanager/labservices/armlabservices/users_client_example_test.go @@ -56,10 +56,10 @@ func ExampleUsersClient_NewListByLabPager() { // TotalUsage: to.Ptr("PT10H"), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -100,10 +100,10 @@ func ExampleUsersClient_Get() { // TotalUsage: to.Ptr("PT10H"), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -151,10 +151,10 @@ func ExampleUsersClient_BeginCreateOrUpdate() { // TotalUsage: to.Ptr("PT10H"), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -201,10 +201,10 @@ func ExampleUsersClient_BeginUpdate() { // TotalUsage: to.Ptr("PT10H"), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, diff --git a/sdk/resourcemanager/labservices/armlabservices/virtualmachines_client.go b/sdk/resourcemanager/labservices/armlabservices/virtualmachines_client.go index d5a07c33a35b..752dcc0004bd 100644 --- a/sdk/resourcemanager/labservices/armlabservices/virtualmachines_client.go +++ b/sdk/resourcemanager/labservices/armlabservices/virtualmachines_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlabservices @@ -33,7 +32,7 @@ type VirtualMachinesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewVirtualMachinesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*VirtualMachinesClient, error) { - cl, err := arm.NewClient(moduleName+".VirtualMachinesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,18 +53,25 @@ func NewVirtualMachinesClient(subscriptionID string, credential azcore.TokenCred // URIs. // - options - VirtualMachinesClientGetOptions contains the optional parameters for the VirtualMachinesClient.Get method. func (client *VirtualMachinesClient) Get(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachinesClientGetOptions) (VirtualMachinesClientGetResponse, error) { + var err error + const operationName = "VirtualMachinesClient.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, labName, virtualMachineName, options) if err != nil { return VirtualMachinesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return VirtualMachinesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return VirtualMachinesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return VirtualMachinesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -120,25 +126,20 @@ func (client *VirtualMachinesClient) NewListByLabPager(resourceGroupName string, return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *VirtualMachinesClientListByLabResponse) (VirtualMachinesClientListByLabResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByLabCreateRequest(ctx, resourceGroupName, labName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "VirtualMachinesClient.NewListByLabPager") + 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.listByLabCreateRequest(ctx, resourceGroupName, labName, options) + }, nil) if err != nil { return VirtualMachinesClientListByLabResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return VirtualMachinesClientListByLabResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return VirtualMachinesClientListByLabResponse{}, runtime.NewResponseError(resp) - } return client.listByLabHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -196,11 +197,15 @@ func (client *VirtualMachinesClient) BeginRedeploy(ctx context.Context, resource if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientRedeployResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientRedeployResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientRedeployResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachinesClientRedeployResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -209,18 +214,24 @@ func (client *VirtualMachinesClient) BeginRedeploy(ctx context.Context, resource // // Generated from API version 2022-08-01 func (client *VirtualMachinesClient) redeploy(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachinesClientBeginRedeployOptions) (*http.Response, error) { + var err error + const operationName = "VirtualMachinesClient.BeginRedeploy" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.redeployCreateRequest(ctx, resourceGroupName, labName, virtualMachineName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // redeployCreateRequest creates the Redeploy request. @@ -270,11 +281,15 @@ func (client *VirtualMachinesClient) BeginReimage(ctx context.Context, resourceG if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientReimageResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientReimageResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientReimageResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachinesClientReimageResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -284,18 +299,24 @@ func (client *VirtualMachinesClient) BeginReimage(ctx context.Context, resourceG // // Generated from API version 2022-08-01 func (client *VirtualMachinesClient) reimage(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachinesClientBeginReimageOptions) (*http.Response, error) { + var err error + const operationName = "VirtualMachinesClient.BeginReimage" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.reimageCreateRequest(ctx, resourceGroupName, labName, virtualMachineName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // reimageCreateRequest creates the Reimage request. @@ -345,11 +366,15 @@ func (client *VirtualMachinesClient) BeginResetPassword(ctx context.Context, res if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientResetPasswordResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientResetPasswordResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientResetPasswordResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachinesClientResetPasswordResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -358,18 +383,24 @@ func (client *VirtualMachinesClient) BeginResetPassword(ctx context.Context, res // // Generated from API version 2022-08-01 func (client *VirtualMachinesClient) resetPassword(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, body ResetPasswordBody, options *VirtualMachinesClientBeginResetPasswordOptions) (*http.Response, error) { + var err error + const operationName = "VirtualMachinesClient.BeginResetPassword" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.resetPasswordCreateRequest(ctx, resourceGroupName, labName, virtualMachineName, body, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // resetPasswordCreateRequest creates the ResetPassword request. @@ -399,7 +430,10 @@ func (client *VirtualMachinesClient) resetPasswordCreateRequest(ctx context.Cont reqQP.Set("api-version", "2022-08-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, body) + if err := runtime.MarshalAsJSON(req, body); err != nil { + return nil, err + } + return req, nil } // BeginStart - Action to start a lab virtual machine. @@ -418,11 +452,15 @@ func (client *VirtualMachinesClient) BeginStart(ctx context.Context, resourceGro if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientStartResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientStartResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientStartResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachinesClientStartResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -431,18 +469,24 @@ func (client *VirtualMachinesClient) BeginStart(ctx context.Context, resourceGro // // Generated from API version 2022-08-01 func (client *VirtualMachinesClient) start(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachinesClientBeginStartOptions) (*http.Response, error) { + var err error + const operationName = "VirtualMachinesClient.BeginStart" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.startCreateRequest(ctx, resourceGroupName, labName, virtualMachineName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // startCreateRequest creates the Start request. @@ -491,11 +535,15 @@ func (client *VirtualMachinesClient) BeginStop(ctx context.Context, resourceGrou if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientStopResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[VirtualMachinesClientStopResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[VirtualMachinesClientStopResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[VirtualMachinesClientStopResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -504,18 +552,24 @@ func (client *VirtualMachinesClient) BeginStop(ctx context.Context, resourceGrou // // Generated from API version 2022-08-01 func (client *VirtualMachinesClient) stop(ctx context.Context, resourceGroupName string, labName string, virtualMachineName string, options *VirtualMachinesClientBeginStopOptions) (*http.Response, error) { + var err error + const operationName = "VirtualMachinesClient.BeginStop" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.stopCreateRequest(ctx, resourceGroupName, labName, virtualMachineName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // stopCreateRequest creates the Stop request. diff --git a/sdk/resourcemanager/labservices/armlabservices/virtualmachines_client_example_test.go b/sdk/resourcemanager/labservices/armlabservices/virtualmachines_client_example_test.go index 6514e60cd684..e78c922a9ae1 100644 --- a/sdk/resourcemanager/labservices/armlabservices/virtualmachines_client_example_test.go +++ b/sdk/resourcemanager/labservices/armlabservices/virtualmachines_client_example_test.go @@ -61,10 +61,10 @@ func ExampleVirtualMachinesClient_NewListByLabPager() { // VMType: to.Ptr(armlabservices.VirtualMachineTypeTemplate), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, @@ -110,10 +110,10 @@ func ExampleVirtualMachinesClient_Get() { // VMType: to.Ptr(armlabservices.VirtualMachineTypeTemplate), // }, // SystemData: &armlabservices.SystemData{ - // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00Z"); return t}()), + // CreatedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-05-01T10:00:00.000Z"); return t}()), // CreatedBy: to.Ptr("identity123"), // CreatedByType: to.Ptr(armlabservices.CreatedByTypeUser), - // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28Z"); return t}()), + // LastModifiedAt: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2020-06-01T09:12:28.000Z"); return t}()), // LastModifiedBy: to.Ptr("identity123"), // LastModifiedByType: to.Ptr(armlabservices.CreatedByTypeUser), // }, diff --git a/sdk/resourcemanager/liftrqumulo/armqumulo/CHANGELOG.md b/sdk/resourcemanager/liftrqumulo/armqumulo/CHANGELOG.md index a0f52d58e873..2496553b659d 100644 --- a/sdk/resourcemanager/liftrqumulo/armqumulo/CHANGELOG.md +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.1.0 (2023-11-24) +### Features Added + +- Support for test fakes and OpenTelemetry trace spans. + + ## 1.0.0 (2023-05-26) ### Other Changes diff --git a/sdk/resourcemanager/liftrqumulo/armqumulo/README.md b/sdk/resourcemanager/liftrqumulo/armqumulo/README.md index 5e1798f29ff3..d2c0be59d4b4 100644 --- a/sdk/resourcemanager/liftrqumulo/armqumulo/README.md +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/README.md @@ -60,6 +60,13 @@ A client groups a set of related APIs, providing access to its functionality. C client := clientFactory.NewFileSystemsClient() ``` +## 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 diff --git a/sdk/resourcemanager/liftrqumulo/armqumulo/autorest.md b/sdk/resourcemanager/liftrqumulo/armqumulo/autorest.md index bf488fcbb846..16aefc2d7b37 100644 --- a/sdk/resourcemanager/liftrqumulo/armqumulo/autorest.md +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/liftrqumulo/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/17aa6a1314de5aafef059d9aa2229901df506e75/specification/liftrqumulo/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.0.0 +module-version: 1.1.0 tag: package-2022-10 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/liftrqumulo/armqumulo/client_factory.go b/sdk/resourcemanager/liftrqumulo/armqumulo/client_factory.go index e4997814031a..2db3c0441df7 100644 --- a/sdk/resourcemanager/liftrqumulo/armqumulo/client_factory.go +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/client_factory.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armqumulo @@ -28,7 +27,7 @@ type ClientFactory struct { // - 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+".ClientFactory", moduleVersion, credential, options) + _, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -38,12 +37,14 @@ func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, }, nil } -func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) +// NewFileSystemsClient creates a new instance of FileSystemsClient. +func (c *ClientFactory) NewFileSystemsClient() *FileSystemsClient { + subClient, _ := NewFileSystemsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewFileSystemsClient() *FileSystemsClient { - subClient, _ := NewFileSystemsClient(c.subscriptionID, c.credential, c.options) +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) return subClient } diff --git a/sdk/resourcemanager/liftrqumulo/armqumulo/constants.go b/sdk/resourcemanager/liftrqumulo/armqumulo/constants.go index dd676ebba21c..a2ff5740cf6f 100644 --- a/sdk/resourcemanager/liftrqumulo/armqumulo/constants.go +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/constants.go @@ -3,15 +3,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armqumulo const ( - moduleName = "armqumulo" - moduleVersion = "v1.0.0" + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/liftrqumulo/armqumulo" + moduleVersion = "v1.1.0" ) // ActionType - Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. @@ -117,36 +116,36 @@ type ProvisioningState string const ( // ProvisioningStateAccepted - File system resource creation request accepted ProvisioningStateAccepted ProvisioningState = "Accepted" + // ProvisioningStateCanceled - File system resource creation canceled + ProvisioningStateCanceled ProvisioningState = "Canceled" // ProvisioningStateCreating - File system resource creation started ProvisioningStateCreating ProvisioningState = "Creating" - // ProvisioningStateUpdating - File system resource is being updated - ProvisioningStateUpdating ProvisioningState = "Updating" + // ProvisioningStateDeleted - File system resource is deleted + ProvisioningStateDeleted ProvisioningState = "Deleted" // ProvisioningStateDeleting - File system resource deletion started ProvisioningStateDeleting ProvisioningState = "Deleting" - // ProvisioningStateSucceeded - File system resource creation successful - ProvisioningStateSucceeded ProvisioningState = "Succeeded" // ProvisioningStateFailed - File system resource creation failed ProvisioningStateFailed ProvisioningState = "Failed" - // ProvisioningStateCanceled - File system resource creation canceled - ProvisioningStateCanceled ProvisioningState = "Canceled" - // ProvisioningStateDeleted - File system resource is deleted - ProvisioningStateDeleted ProvisioningState = "Deleted" // ProvisioningStateNotSpecified - File system resource state is unknown ProvisioningStateNotSpecified ProvisioningState = "NotSpecified" + // ProvisioningStateSucceeded - File system resource creation successful + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + // ProvisioningStateUpdating - File system resource is being updated + ProvisioningStateUpdating ProvisioningState = "Updating" ) // PossibleProvisioningStateValues returns the possible values for the ProvisioningState const type. func PossibleProvisioningStateValues() []ProvisioningState { return []ProvisioningState{ ProvisioningStateAccepted, + ProvisioningStateCanceled, ProvisioningStateCreating, - ProvisioningStateUpdating, + ProvisioningStateDeleted, ProvisioningStateDeleting, - ProvisioningStateSucceeded, ProvisioningStateFailed, - ProvisioningStateCanceled, - ProvisioningStateDeleted, ProvisioningStateNotSpecified, + ProvisioningStateSucceeded, + ProvisioningStateUpdating, } } @@ -154,16 +153,16 @@ func PossibleProvisioningStateValues() []ProvisioningState { type StorageSKU string const ( - // StorageSKUStandard - Standard Storage Sku - StorageSKUStandard StorageSKU = "Standard" // StorageSKUPerformance - Performance Storage Sku StorageSKUPerformance StorageSKU = "Performance" + // StorageSKUStandard - Standard Storage Sku + StorageSKUStandard StorageSKU = "Standard" ) // PossibleStorageSKUValues returns the possible values for the StorageSKU const type. func PossibleStorageSKUValues() []StorageSKU { return []StorageSKU{ - StorageSKUStandard, StorageSKUPerformance, + StorageSKUStandard, } } diff --git a/sdk/resourcemanager/liftrqumulo/armqumulo/fake/filesystems_server.go b/sdk/resourcemanager/liftrqumulo/armqumulo/fake/filesystems_server.go new file mode 100644 index 000000000000..d32a96dfbc4f --- /dev/null +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/fake/filesystems_server.go @@ -0,0 +1,340 @@ +//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/liftrqumulo/armqumulo" + "net/http" + "net/url" + "regexp" +) + +// FileSystemsServer is a fake server for instances of the armqumulo.FileSystemsClient type. +type FileSystemsServer struct { + // BeginCreateOrUpdate is the fake for method FileSystemsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, fileSystemName string, resource armqumulo.FileSystemResource, options *armqumulo.FileSystemsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armqumulo.FileSystemsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method FileSystemsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, fileSystemName string, options *armqumulo.FileSystemsClientBeginDeleteOptions) (resp azfake.PollerResponder[armqumulo.FileSystemsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method FileSystemsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, fileSystemName string, options *armqumulo.FileSystemsClientGetOptions) (resp azfake.Responder[armqumulo.FileSystemsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method FileSystemsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armqumulo.FileSystemsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armqumulo.FileSystemsClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method FileSystemsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armqumulo.FileSystemsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armqumulo.FileSystemsClientListBySubscriptionResponse]) + + // Update is the fake for method FileSystemsClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, fileSystemName string, properties armqumulo.FileSystemResourceUpdate, options *armqumulo.FileSystemsClientUpdateOptions) (resp azfake.Responder[armqumulo.FileSystemsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewFileSystemsServerTransport creates a new instance of FileSystemsServerTransport with the provided implementation. +// The returned FileSystemsServerTransport instance is connected to an instance of armqumulo.FileSystemsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewFileSystemsServerTransport(srv *FileSystemsServer) *FileSystemsServerTransport { + return &FileSystemsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armqumulo.FileSystemsClientCreateOrUpdateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armqumulo.FileSystemsClientDeleteResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armqumulo.FileSystemsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armqumulo.FileSystemsClientListBySubscriptionResponse]](), + } +} + +// FileSystemsServerTransport connects instances of armqumulo.FileSystemsClient to instances of FileSystemsServer. +// Don't use this type directly, use NewFileSystemsServerTransport instead. +type FileSystemsServerTransport struct { + srv *FileSystemsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armqumulo.FileSystemsClientCreateOrUpdateResponse]] + beginDelete *tracker[azfake.PollerResponder[armqumulo.FileSystemsClientDeleteResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armqumulo.FileSystemsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armqumulo.FileSystemsClientListBySubscriptionResponse]] +} + +// Do implements the policy.Transporter interface for FileSystemsServerTransport. +func (f *FileSystemsServerTransport) 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 "FileSystemsClient.BeginCreateOrUpdate": + resp, err = f.dispatchBeginCreateOrUpdate(req) + case "FileSystemsClient.BeginDelete": + resp, err = f.dispatchBeginDelete(req) + case "FileSystemsClient.Get": + resp, err = f.dispatchGet(req) + case "FileSystemsClient.NewListByResourceGroupPager": + resp, err = f.dispatchNewListByResourceGroupPager(req) + case "FileSystemsClient.NewListBySubscriptionPager": + resp, err = f.dispatchNewListBySubscriptionPager(req) + case "FileSystemsClient.Update": + resp, err = f.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (f *FileSystemsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if f.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := f.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Qumulo\.Storage/fileSystems/(?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[armqumulo.FileSystemResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + fileSystemNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fileSystemName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, fileSystemNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + f.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) { + f.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) { + f.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (f *FileSystemsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if f.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := f.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Qumulo\.Storage/fileSystems/(?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 + } + fileSystemNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fileSystemName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.BeginDelete(req.Context(), resourceGroupNameParam, fileSystemNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + f.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) { + f.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) { + f.beginDelete.remove(req) + } + + return resp, nil +} + +func (f *FileSystemsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if f.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/Qumulo\.Storage/fileSystems/(?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 + } + fileSystemNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fileSystemName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.Get(req.Context(), resourceGroupNameParam, fileSystemNameParam, 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).FileSystemResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (f *FileSystemsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if f.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := f.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Qumulo\.Storage/fileSystems` + 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 := f.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + f.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armqumulo.FileSystemsClientListByResourceGroupResponse, 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) { + f.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + f.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (f *FileSystemsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if f.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := f.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Qumulo\.Storage/fileSystems` + 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 := f.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + f.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armqumulo.FileSystemsClientListBySubscriptionResponse, 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) { + f.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + f.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (f *FileSystemsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if f.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/Qumulo\.Storage/fileSystems/(?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[armqumulo.FileSystemResourceUpdate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + fileSystemNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("fileSystemName")]) + if err != nil { + return nil, err + } + respr, errRespr := f.srv.Update(req.Context(), resourceGroupNameParam, fileSystemNameParam, 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).FileSystemResource, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/liftrqumulo/armqumulo/fake/internal.go b/sdk/resourcemanager/liftrqumulo/armqumulo/fake/internal.go new file mode 100644 index 000000000000..5f75802a569e --- /dev/null +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/fake/internal.go @@ -0,0 +1,64 @@ +//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 ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "sync" +) + +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/liftrqumulo/armqumulo/fake/operations_server.go b/sdk/resourcemanager/liftrqumulo/armqumulo/fake/operations_server.go new file mode 100644 index 000000000000..ebb88f7d1844 --- /dev/null +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/fake/operations_server.go @@ -0,0 +1,96 @@ +//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 ( + "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/liftrqumulo/armqumulo" + "net/http" +) + +// OperationsServer is a fake server for instances of the armqumulo.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armqumulo.OperationsClientListOptions) (resp azfake.PagerResponder[armqumulo.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armqumulo.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[armqumulo.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armqumulo.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armqumulo.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) 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 "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armqumulo.OperationsClientListResponse, 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) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/liftrqumulo/armqumulo/fake/server_factory.go b/sdk/resourcemanager/liftrqumulo/armqumulo/fake/server_factory.go new file mode 100644 index 000000000000..bfefcaab85d3 --- /dev/null +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/fake/server_factory.go @@ -0,0 +1,80 @@ +//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 ( + "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 armqumulo.ClientFactory type. +type ServerFactory struct { + FileSystemsServer FileSystemsServer + OperationsServer OperationsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armqumulo.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 armqumulo.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trFileSystemsServer *FileSystemsServerTransport + trOperationsServer *OperationsServerTransport +} + +// 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 "FileSystemsClient": + initServer(s, &s.trFileSystemsServer, func() *FileSystemsServerTransport { return NewFileSystemsServerTransport(&s.srv.FileSystemsServer) }) + resp, err = s.trFileSystemsServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.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/liftrqumulo/armqumulo/fake/time_rfc3339.go b/sdk/resourcemanager/liftrqumulo/armqumulo/fake/time_rfc3339.go new file mode 100644 index 000000000000..b0535a7b63e6 --- /dev/null +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/fake/time_rfc3339.go @@ -0,0 +1,86 @@ +//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 ( + "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 ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +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 { + layout := utcDateTimeJSON + if tzOffsetRegex.Match(data) { + layout = dateTimeJSON + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + 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 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 || strings.EqualFold(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/liftrqumulo/armqumulo/filesystems_client.go b/sdk/resourcemanager/liftrqumulo/armqumulo/filesystems_client.go index c5f32e8350c1..9aea0406149c 100644 --- a/sdk/resourcemanager/liftrqumulo/armqumulo/filesystems_client.go +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/filesystems_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armqumulo @@ -33,7 +32,7 @@ type FileSystemsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewFileSystemsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*FileSystemsClient, error) { - cl, err := arm.NewClient(moduleName+".FileSystemsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -59,11 +58,15 @@ func (client *FileSystemsClient) BeginCreateOrUpdate(ctx context.Context, resour if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FileSystemsClientCreateOrUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FileSystemsClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[FileSystemsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FileSystemsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -72,18 +75,24 @@ func (client *FileSystemsClient) BeginCreateOrUpdate(ctx context.Context, resour // // Generated from API version 2022-10-12 func (client *FileSystemsClient) createOrUpdate(ctx context.Context, resourceGroupName string, fileSystemName string, resource FileSystemResource, options *FileSystemsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "FileSystemsClient.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, fileSystemName, resource, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -109,7 +118,10 @@ func (client *FileSystemsClient) createOrUpdateCreateRequest(ctx context.Context reqQP.Set("api-version", "2022-10-12") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, resource) + if err := runtime.MarshalAsJSON(req, resource); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Delete a FileSystemResource @@ -125,11 +137,15 @@ func (client *FileSystemsClient) BeginDelete(ctx context.Context, resourceGroupN if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FileSystemsClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[FileSystemsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[FileSystemsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[FileSystemsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -138,18 +154,24 @@ func (client *FileSystemsClient) BeginDelete(ctx context.Context, resourceGroupN // // Generated from API version 2022-10-12 func (client *FileSystemsClient) deleteOperation(ctx context.Context, resourceGroupName string, fileSystemName string, options *FileSystemsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "FileSystemsClient.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, fileSystemName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -186,18 +208,25 @@ func (client *FileSystemsClient) deleteCreateRequest(ctx context.Context, resour // - fileSystemName - Name of the File System resource // - options - FileSystemsClientGetOptions contains the optional parameters for the FileSystemsClient.Get method. func (client *FileSystemsClient) Get(ctx context.Context, resourceGroupName string, fileSystemName string, options *FileSystemsClientGetOptions) (FileSystemsClientGetResponse, error) { + var err error + const operationName = "FileSystemsClient.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, fileSystemName, options) if err != nil { return FileSystemsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileSystemsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileSystemsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileSystemsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -247,25 +276,20 @@ func (client *FileSystemsClient) NewListByResourceGroupPager(resourceGroupName s return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *FileSystemsClientListByResourceGroupResponse) (FileSystemsClientListByResourceGroupResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return FileSystemsClientListByResourceGroupResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "FileSystemsClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + 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 FileSystemsClientListByResourceGroupResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileSystemsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -311,25 +335,20 @@ func (client *FileSystemsClient) NewListBySubscriptionPager(options *FileSystems return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *FileSystemsClientListBySubscriptionResponse) (FileSystemsClientListBySubscriptionResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listBySubscriptionCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return FileSystemsClientListBySubscriptionResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "FileSystemsClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + 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 FileSystemsClientListBySubscriptionResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileSystemsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) - } return client.listBySubscriptionHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -369,18 +388,25 @@ func (client *FileSystemsClient) listBySubscriptionHandleResponse(resp *http.Res // - properties - The resource properties to be updated. // - options - FileSystemsClientUpdateOptions contains the optional parameters for the FileSystemsClient.Update method. func (client *FileSystemsClient) Update(ctx context.Context, resourceGroupName string, fileSystemName string, properties FileSystemResourceUpdate, options *FileSystemsClientUpdateOptions) (FileSystemsClientUpdateResponse, error) { + var err error + const operationName = "FileSystemsClient.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, fileSystemName, properties, options) if err != nil { return FileSystemsClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return FileSystemsClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return FileSystemsClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return FileSystemsClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -406,7 +432,10 @@ func (client *FileSystemsClient) updateCreateRequest(ctx context.Context, resour reqQP.Set("api-version", "2022-10-12") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, properties) + if err := runtime.MarshalAsJSON(req, properties); err != nil { + return nil, err + } + return req, nil } // updateHandleResponse handles the Update response. diff --git a/sdk/resourcemanager/liftrqumulo/armqumulo/go.mod b/sdk/resourcemanager/liftrqumulo/armqumulo/go.mod index 95b4f8e23fc7..1e58dd26b7ab 100644 --- a/sdk/resourcemanager/liftrqumulo/armqumulo/go.mod +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/liftrqumulo/armqumu go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 // indirect + github.com/google/uuid v1.3.1 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.6.0 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect ) diff --git a/sdk/resourcemanager/liftrqumulo/armqumulo/go.sum b/sdk/resourcemanager/liftrqumulo/armqumulo/go.sum index 8ba445a8c4da..7985f1da436f 100644 --- a/sdk/resourcemanager/liftrqumulo/armqumulo/go.sum +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/go.sum @@ -1,31 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= +github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= +github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/liftrqumulo/armqumulo/models.go b/sdk/resourcemanager/liftrqumulo/armqumulo/models.go index 23908f8b380e..ba9c74bed207 100644 --- a/sdk/resourcemanager/liftrqumulo/armqumulo/models.go +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/models.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armqumulo @@ -110,41 +109,6 @@ type FileSystemResourceUpdateProperties struct { UserDetails *UserDetails } -// FileSystemsClientBeginCreateOrUpdateOptions contains the optional parameters for the FileSystemsClient.BeginCreateOrUpdate -// method. -type FileSystemsClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// FileSystemsClientBeginDeleteOptions contains the optional parameters for the FileSystemsClient.BeginDelete method. -type FileSystemsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// FileSystemsClientGetOptions contains the optional parameters for the FileSystemsClient.Get method. -type FileSystemsClientGetOptions struct { - // placeholder for future optional parameters -} - -// FileSystemsClientListByResourceGroupOptions contains the optional parameters for the FileSystemsClient.NewListByResourceGroupPager -// method. -type FileSystemsClientListByResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// FileSystemsClientListBySubscriptionOptions contains the optional parameters for the FileSystemsClient.NewListBySubscriptionPager -// method. -type FileSystemsClientListBySubscriptionOptions struct { - // placeholder for future optional parameters -} - -// FileSystemsClientUpdateOptions contains the optional parameters for the FileSystemsClient.Update method. -type FileSystemsClientUpdateOptions struct { - // placeholder for future optional parameters -} - // ManagedServiceIdentity - Managed service identity (system assigned and/or user assigned identities) type ManagedServiceIdentity struct { // REQUIRED; Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). @@ -232,11 +196,6 @@ type OperationListResult struct { Value []*Operation } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. -type OperationsClientListOptions struct { - // placeholder for future optional parameters -} - // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). diff --git a/sdk/resourcemanager/liftrqumulo/armqumulo/models_serde.go b/sdk/resourcemanager/liftrqumulo/armqumulo/models_serde.go index 2c4444ff8eee..afe0347b2d36 100644 --- a/sdk/resourcemanager/liftrqumulo/armqumulo/models_serde.go +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/models_serde.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armqumulo @@ -441,10 +440,10 @@ func (o *OperationListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) populate(objectMap, "lastModifiedBy", s.LastModifiedBy) populate(objectMap, "lastModifiedByType", s.LastModifiedByType) return json.Marshal(objectMap) @@ -460,7 +459,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { var err error switch key { case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) delete(rawMsg, key) case "createdBy": err = unpopulate(val, "CreatedBy", &s.CreatedBy) @@ -469,7 +468,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { err = unpopulate(val, "CreatedByType", &s.CreatedByType) delete(rawMsg, key) case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) delete(rawMsg, key) case "lastModifiedBy": err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) diff --git a/sdk/resourcemanager/liftrqumulo/armqumulo/operations_client.go b/sdk/resourcemanager/liftrqumulo/armqumulo/operations_client.go index cda50d8b2b9e..ec8b66c04570 100644 --- a/sdk/resourcemanager/liftrqumulo/armqumulo/operations_client.go +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/operations_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armqumulo @@ -28,7 +27,7 @@ type OperationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -48,25 +47,20 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.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, options) + }, nil) if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return OperationsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OperationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/liftrqumulo/armqumulo/options.go b/sdk/resourcemanager/liftrqumulo/armqumulo/options.go new file mode 100644 index 000000000000..2f8c3864f245 --- /dev/null +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/options.go @@ -0,0 +1,49 @@ +//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 armqumulo + +// FileSystemsClientBeginCreateOrUpdateOptions contains the optional parameters for the FileSystemsClient.BeginCreateOrUpdate +// method. +type FileSystemsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// FileSystemsClientBeginDeleteOptions contains the optional parameters for the FileSystemsClient.BeginDelete method. +type FileSystemsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// FileSystemsClientGetOptions contains the optional parameters for the FileSystemsClient.Get method. +type FileSystemsClientGetOptions struct { + // placeholder for future optional parameters +} + +// FileSystemsClientListByResourceGroupOptions contains the optional parameters for the FileSystemsClient.NewListByResourceGroupPager +// method. +type FileSystemsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// FileSystemsClientListBySubscriptionOptions contains the optional parameters for the FileSystemsClient.NewListBySubscriptionPager +// method. +type FileSystemsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// FileSystemsClientUpdateOptions contains the optional parameters for the FileSystemsClient.Update method. +type FileSystemsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/liftrqumulo/armqumulo/response_types.go b/sdk/resourcemanager/liftrqumulo/armqumulo/response_types.go index 6dacad3ea3e1..eeb3c81b6628 100644 --- a/sdk/resourcemanager/liftrqumulo/armqumulo/response_types.go +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/response_types.go @@ -3,14 +3,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armqumulo // FileSystemsClientCreateOrUpdateResponse contains the response from method FileSystemsClient.BeginCreateOrUpdate. type FileSystemsClientCreateOrUpdateResponse struct { + // A FileSystem Resource by Qumulo FileSystemResource } @@ -21,25 +21,30 @@ type FileSystemsClientDeleteResponse struct { // FileSystemsClientGetResponse contains the response from method FileSystemsClient.Get. type FileSystemsClientGetResponse struct { + // A FileSystem Resource by Qumulo FileSystemResource } // FileSystemsClientListByResourceGroupResponse contains the response from method FileSystemsClient.NewListByResourceGroupPager. type FileSystemsClientListByResourceGroupResponse struct { + // The response of a FileSystemResource list operation. FileSystemResourceListResult } // FileSystemsClientListBySubscriptionResponse contains the response from method FileSystemsClient.NewListBySubscriptionPager. type FileSystemsClientListBySubscriptionResponse struct { + // The response of a FileSystemResource list operation. FileSystemResourceListResult } // FileSystemsClientUpdateResponse contains the response from method FileSystemsClient.Update. type FileSystemsClientUpdateResponse struct { + // A FileSystem Resource by Qumulo FileSystemResource } // 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 } diff --git a/sdk/resourcemanager/liftrqumulo/armqumulo/time_rfc3339.go b/sdk/resourcemanager/liftrqumulo/armqumulo/time_rfc3339.go index 921c9080264d..b1bb2f7b4bb1 100644 --- a/sdk/resourcemanager/liftrqumulo/armqumulo/time_rfc3339.go +++ b/sdk/resourcemanager/liftrqumulo/armqumulo/time_rfc3339.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armqumulo @@ -19,50 +18,50 @@ import ( "time" ) -const ( - utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` - utcLayout = "2006-01-02T15:04:05.999999999" - rfc3339JSON = `"` + time.RFC3339Nano + `"` -) - // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) -type timeRFC3339 time.Time +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time -func (t timeRFC3339) MarshalJSON() (json []byte, err error) { +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { tt := time.Time(t) return tt.MarshalJSON() } -func (t timeRFC3339) MarshalText() (text []byte, err error) { +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { tt := time.Time(t) return tt.MarshalText() } -func (t *timeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcLayoutJSON +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON if tzOffsetRegex.Match(data) { - layout = rfc3339JSON + layout = dateTimeJSON } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { - layout := utcLayout +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime if tzOffsetRegex.Match(data) { layout = time.RFC3339Nano } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) Parse(layout, value string) error { +func (t *dateTimeRFC3339) Parse(layout, value string) error { p, err := time.Parse(layout, strings.ToUpper(value)) - *t = timeRFC3339(p) + *t = dateTimeRFC3339(p) return err } -func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { @@ -71,14 +70,14 @@ func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { } else if reflect.ValueOf(t).IsNil() { return } - m[k] = (*timeRFC3339)(t) + m[k] = (*dateTimeRFC3339)(t) } -func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { if data == nil || strings.EqualFold(string(data), "null") { return nil } - var aux timeRFC3339 + var aux dateTimeRFC3339 if err := json.Unmarshal(data, &aux); err != nil { return fmt.Errorf("struct field %s: %v", fn, err) } diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/CHANGELOG.md b/sdk/resourcemanager/loadtesting/armloadtesting/CHANGELOG.md index 376e3f4d6d99..22bec5129b54 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/CHANGELOG.md +++ b/sdk/resourcemanager/loadtesting/armloadtesting/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.2.0 (2023-11-24) +### Features Added + +- Support for test fakes and OpenTelemetry trace spans. + + ## 1.1.0 (2023-03-31) ### Features Added diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/README.md b/sdk/resourcemanager/loadtesting/armloadtesting/README.md index 8ea17622ad5f..05fe0c2c3046 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/README.md +++ b/sdk/resourcemanager/loadtesting/armloadtesting/README.md @@ -60,6 +60,13 @@ A client groups a set of related APIs, providing access to its functionality. C client := clientFactory.NewLoadTestsClient() ``` +## 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 diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/autorest.md b/sdk/resourcemanager/loadtesting/armloadtesting/autorest.md index 031bcceee64b..2fde958ff520 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/autorest.md +++ b/sdk/resourcemanager/loadtesting/armloadtesting/autorest.md @@ -8,7 +8,7 @@ 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.1.0 +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/client_factory.go b/sdk/resourcemanager/loadtesting/armloadtesting/client_factory.go index fba48fd9b9f7..e2eb7f96a538 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/client_factory.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/client_factory.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armloadtesting @@ -28,7 +27,7 @@ type ClientFactory struct { // - 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+".ClientFactory", moduleVersion, credential, options) + _, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -38,17 +37,20 @@ func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, }, 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 } - -func (c *ClientFactory) NewLoadTestsClient() *LoadTestsClient { - subClient, _ := NewLoadTestsClient(c.subscriptionID, c.credential, c.options) - return subClient -} diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/constants.go b/sdk/resourcemanager/loadtesting/armloadtesting/constants.go index 27915f370b81..5b13e215f4cf 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/constants.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/constants.go @@ -3,15 +3,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armloadtesting const ( - moduleName = "armloadtesting" - moduleVersion = "v1.1.0" + 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. diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/fake/internal.go b/sdk/resourcemanager/loadtesting/armloadtesting/fake/internal.go new file mode 100644 index 000000000000..5f75802a569e --- /dev/null +++ b/sdk/resourcemanager/loadtesting/armloadtesting/fake/internal.go @@ -0,0 +1,64 @@ +//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 ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "sync" +) + +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/loadtests_server.go b/sdk/resourcemanager/loadtesting/armloadtesting/fake/loadtests_server.go new file mode 100644 index 000000000000..262e95a6be41 --- /dev/null +++ b/sdk/resourcemanager/loadtesting/armloadtesting/fake/loadtests_server.go @@ -0,0 +1,402 @@ +//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/operations_server.go b/sdk/resourcemanager/loadtesting/armloadtesting/fake/operations_server.go new file mode 100644 index 000000000000..b697bdd5da9d --- /dev/null +++ b/sdk/resourcemanager/loadtesting/armloadtesting/fake/operations_server.go @@ -0,0 +1,96 @@ +//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 ( + "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" +) + +// OperationsServer is a fake server for instances of the armloadtesting.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]) +} + +// 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 +// 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]](), + } +} + +// OperationsServerTransport connects instances of armloadtesting.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]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) 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 "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armloadtesting.OperationsClientListResponse, 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) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.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 new file mode 100644 index 000000000000..660c2aa50377 --- /dev/null +++ b/sdk/resourcemanager/loadtesting/armloadtesting/fake/quotas_server.go @@ -0,0 +1,191 @@ +//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 new file mode 100644 index 000000000000..d66885eec88a --- /dev/null +++ b/sdk/resourcemanager/loadtesting/armloadtesting/fake/server_factory.go @@ -0,0 +1,85 @@ +//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 ( + "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 armloadtesting.ClientFactory type. +type ServerFactory struct { + LoadTestsServer LoadTestsServer + OperationsServer OperationsServer + QuotasServer QuotasServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armloadtesting.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 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 +} + +// 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 "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) + 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/loadtesting/armloadtesting/fake/time_rfc3339.go b/sdk/resourcemanager/loadtesting/armloadtesting/fake/time_rfc3339.go new file mode 100644 index 000000000000..b0535a7b63e6 --- /dev/null +++ b/sdk/resourcemanager/loadtesting/armloadtesting/fake/time_rfc3339.go @@ -0,0 +1,86 @@ +//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 ( + "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 ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +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 { + layout := utcDateTimeJSON + if tzOffsetRegex.Match(data) { + layout = dateTimeJSON + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + 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 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 || strings.EqualFold(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/loadtesting/armloadtesting/go.mod b/sdk/resourcemanager/loadtesting/armloadtesting/go.mod index 9cb68e1a95db..7cdc482ee9c7 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/go.mod +++ b/sdk/resourcemanager/loadtesting/armloadtesting/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/loadtesting/armload go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 // indirect + github.com/google/uuid v1.3.1 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.6.0 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect ) diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/go.sum b/sdk/resourcemanager/loadtesting/armloadtesting/go.sum index 8ba445a8c4da..7985f1da436f 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/go.sum +++ b/sdk/resourcemanager/loadtesting/armloadtesting/go.sum @@ -1,31 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= +github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= +github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/loadtests_client.go b/sdk/resourcemanager/loadtesting/armloadtesting/loadtests_client.go index d218de12f835..bfd2effb6f4e 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/loadtests_client.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/loadtests_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armloadtesting @@ -33,7 +32,7 @@ type LoadTestsClient struct { // - 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+".LoadTestsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -59,11 +58,15 @@ func (client *LoadTestsClient) BeginCreateOrUpdate(ctx context.Context, resource if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LoadTestsClientCreateOrUpdateResponse]{ + 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[LoadTestsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LoadTestsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -72,18 +75,24 @@ func (client *LoadTestsClient) BeginCreateOrUpdate(ctx context.Context, resource // // 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 } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -109,7 +118,10 @@ func (client *LoadTestsClient) createOrUpdateCreateRequest(ctx context.Context, reqQP.Set("api-version", "2022-12-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, loadTestResource) + if err := runtime.MarshalAsJSON(req, loadTestResource); err != nil { + return nil, err + } + return req, nil } // BeginDelete - Delete a LoadTest resource. @@ -125,11 +137,15 @@ func (client *LoadTestsClient) BeginDelete(ctx context.Context, resourceGroupNam if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LoadTestsClientDeleteResponse]{ + 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[LoadTestsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LoadTestsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -138,18 +154,24 @@ func (client *LoadTestsClient) BeginDelete(ctx context.Context, resourceGroupNam // // 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 } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -186,18 +208,25 @@ func (client *LoadTestsClient) deleteCreateRequest(ctx context.Context, resource // - 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 } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return LoadTestsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LoadTestsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return LoadTestsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -247,25 +276,20 @@ func (client *LoadTestsClient) NewListByResourceGroupPager(resourceGroupName str return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *LoadTestsClientListByResourceGroupResponse) (LoadTestsClientListByResourceGroupResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return LoadTestsClientListByResourceGroupResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "LoadTestsClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + 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 } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LoadTestsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -311,25 +335,20 @@ func (client *LoadTestsClient) NewListBySubscriptionPager(options *LoadTestsClie return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *LoadTestsClientListBySubscriptionResponse) (LoadTestsClientListBySubscriptionResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listBySubscriptionCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + 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 } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return LoadTestsClientListBySubscriptionResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LoadTestsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) - } return client.listBySubscriptionHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -373,25 +392,20 @@ func (client *LoadTestsClient) NewListOutboundNetworkDependenciesEndpointsPager( return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse) (LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listOutboundNetworkDependenciesEndpointsCreateRequest(ctx, resourceGroupName, loadTestName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "LoadTestsClient.NewListOutboundNetworkDependenciesEndpointsPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + 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 } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return LoadTestsClientListOutboundNetworkDependenciesEndpointsResponse{}, runtime.NewResponseError(resp) - } return client.listOutboundNetworkDependenciesEndpointsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -444,11 +458,15 @@ func (client *LoadTestsClient) BeginUpdate(ctx context.Context, resourceGroupNam if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[LoadTestsClientUpdateResponse]{ + 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[LoadTestsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[LoadTestsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -457,18 +475,24 @@ func (client *LoadTestsClient) BeginUpdate(ctx context.Context, resourceGroupNam // // 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 } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // updateCreateRequest creates the Update request. @@ -494,5 +518,8 @@ func (client *LoadTestsClient) updateCreateRequest(ctx context.Context, resource reqQP.Set("api-version", "2022-12-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, loadTestResourcePatchRequestBody) + 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 index 75cfebe93bda..7f3659ec8275 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/loadtests_client_example_test.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/loadtests_client_example_test.go @@ -47,10 +47,10 @@ func ExampleLoadTestsClient_NewListBySubscriptionPager() { // 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:33Z"); return t}()), + // 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:33Z"); return t}()), + // 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), // }, @@ -97,10 +97,10 @@ func ExampleLoadTestsClient_NewListByResourceGroupPager() { // 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:33Z"); return t}()), + // 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:33Z"); return t}()), + // 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), // }, @@ -141,10 +141,10 @@ func ExampleLoadTestsClient_Get() { // 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:33Z"); return t}()), + // 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:33Z"); return t}()), + // 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), // }, @@ -208,10 +208,10 @@ func ExampleLoadTestsClient_BeginCreateOrUpdate() { // 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:33Z"); return t}()), + // 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:33Z"); return t}()), + // 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), // }, @@ -292,10 +292,10 @@ func ExampleLoadTestsClient_BeginUpdate() { // 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:33Z"); return t}()), + // 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:33Z"); return t}()), + // 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), // }, diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/models.go b/sdk/resourcemanager/loadtesting/armloadtesting/models.go index 1ba919933885..1679c6841e69 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/models.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/models.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armloadtesting @@ -14,38 +13,38 @@ import "time" // CheckQuotaAvailabilityResponse - Check quota availability response object. type CheckQuotaAvailabilityResponse struct { // Check quota availability response properties. - Properties *CheckQuotaAvailabilityResponseProperties `json:"properties,omitempty"` + Properties *CheckQuotaAvailabilityResponseProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // CheckQuotaAvailabilityResponseProperties - Check quota availability response properties. type CheckQuotaAvailabilityResponseProperties struct { // Message indicating additional details to add to quota support request. - AvailabilityStatus *string `json:"availabilityStatus,omitempty"` + AvailabilityStatus *string // True/False indicating whether the quota request be granted based on availability. - IsAvailable *bool `json:"isAvailable,omitempty"` + IsAvailable *bool } // EncryptionProperties - Key and identity details for Customer Managed Key encryption of load test resource type EncryptionProperties struct { // All identity configuration for Customer-managed key settings defining which identity should be used to auth to Key Vault. - Identity *EncryptionPropertiesIdentity `json:"identity,omitempty"` + Identity *EncryptionPropertiesIdentity // key encryption key Url, versioned. Ex: https://contosovault.vault.azure.net/keys/contosokek/562a4bb76b524a1493a6afe8e536ee78 // or https://contosovault.vault.azure.net/keys/contosokek. - KeyURL *string `json:"keyUrl,omitempty"` + KeyURL *string } // EncryptionPropertiesIdentity - All identity configuration for Customer-managed key settings defining which identity should @@ -53,359 +52,297 @@ type EncryptionProperties struct { type EncryptionPropertiesIdentity struct { // user assigned identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups/ // /providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId - ResourceID *string `json:"resourceId,omitempty"` + ResourceID *string // Managed identity type to use for accessing encryption key Url - Type *Type `json:"type,omitempty"` + 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 `json:"description,omitempty" azure:"ro"` + Description *string // READ-ONLY; The domain name of the dependency. Domain names may be fully qualified or may contain a * wildcard. - DomainName *string `json:"domainName,omitempty" azure:"ro"` + DomainName *string // READ-ONLY; The list of connection details for this endpoint. - EndpointDetails []*EndpointDetail `json:"endpointDetails,omitempty" azure:"ro"` + EndpointDetails []*EndpointDetail } // EndpointDetail - Details about the connection between the Batch service and the endpoint. type EndpointDetail struct { // READ-ONLY; The port an endpoint is connected to. - Port *int32 `json:"port,omitempty" azure:"ro"` + Port *int32 } // LoadTestProperties - LoadTest resource properties. type LoadTestProperties struct { // Description of the resource. - Description *string `json:"description,omitempty"` + Description *string // CMK Encryption property. - Encryption *EncryptionProperties `json:"encryption,omitempty"` + Encryption *EncryptionProperties // READ-ONLY; Resource data plane URI. - DataPlaneURI *string `json:"dataPlaneURI,omitempty" azure:"ro"` + DataPlaneURI *string // READ-ONLY; Resource provisioning state. - ProvisioningState *ResourceState `json:"provisioningState,omitempty" azure:"ro"` + ProvisioningState *ResourceState } // LoadTestResource - LoadTest details type LoadTestResource struct { // REQUIRED; The geo-location where the resource lives - Location *string `json:"location,omitempty"` + Location *string // The type of identity used for the resource. - Identity *ManagedServiceIdentity `json:"identity,omitempty"` + Identity *ManagedServiceIdentity // Load Test resource properties - Properties *LoadTestProperties `json:"properties,omitempty"` + Properties *LoadTestProperties // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // LoadTestResourcePageList - List of resources page result. type LoadTestResourcePageList struct { // Link to next page of resources. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // List of resources in current page. - Value []*LoadTestResource `json:"value,omitempty"` + Value []*LoadTestResource } // LoadTestResourcePatchRequestBody - LoadTest resource patch request body. type LoadTestResourcePatchRequestBody struct { // The type of identity used for the resource. - Identity *ManagedServiceIdentity `json:"identity,omitempty"` + Identity *ManagedServiceIdentity // Load Test resource properties - Properties *LoadTestResourcePatchRequestBodyProperties `json:"properties,omitempty"` + Properties *LoadTestResourcePatchRequestBodyProperties // Resource tags. - Tags map[string]*string `json:"tags,omitempty"` + Tags map[string]*string } // LoadTestResourcePatchRequestBodyProperties - Load Test resource properties type LoadTestResourcePatchRequestBodyProperties struct { // Description of the resource. - Description *string `json:"description,omitempty"` + Description *string // CMK Encryption property. - Encryption *EncryptionProperties `json:"encryption,omitempty"` -} - -// LoadTestsClientBeginCreateOrUpdateOptions contains the optional parameters for the LoadTestsClient.BeginCreateOrUpdate -// method. -type LoadTestsClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// LoadTestsClientBeginDeleteOptions contains the optional parameters for the LoadTestsClient.BeginDelete method. -type LoadTestsClientBeginDeleteOptions struct { - // Resumes the LRO 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. - 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 -// method. -type LoadTestsClientListByResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// LoadTestsClientListBySubscriptionOptions contains the optional parameters for the LoadTestsClient.NewListBySubscriptionPager -// method. -type LoadTestsClientListBySubscriptionOptions struct { - // placeholder for future optional parameters -} - -// LoadTestsClientListOutboundNetworkDependenciesEndpointsOptions contains the optional parameters for the LoadTestsClient.NewListOutboundNetworkDependenciesEndpointsPager -// method. -type LoadTestsClientListOutboundNetworkDependenciesEndpointsOptions struct { - // placeholder for future optional parameters + Encryption *EncryptionProperties } // ManagedServiceIdentity - Managed service identity (system assigned and/or user assigned identities) type ManagedServiceIdentity struct { // REQUIRED; Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed). - Type *ManagedServiceIdentityType `json:"type,omitempty"` + 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. - UserAssignedIdentities map[string]*UserAssignedIdentity `json:"userAssignedIdentities,omitempty"` + 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 // identity. - PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + PrincipalID *string // READ-ONLY; The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity. - TenantID *string `json:"tenantId,omitempty" azure:"ro"` + 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 `json:"display,omitempty"` + Display *OperationDisplay // READ-ONLY; Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - ActionType *ActionType `json:"actionType,omitempty" azure:"ro"` + 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 `json:"isDataAction,omitempty" azure:"ro"` + 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 `json:"name,omitempty" azure:"ro"` + 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 `json:"origin,omitempty" azure:"ro"` + 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 `json:"description,omitempty" azure:"ro"` + 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 `json:"operation,omitempty" azure:"ro"` + Operation *string // READ-ONLY; The localized friendly form of the resource provider name, e.g. "Microsoft Monitoring Insights" or "Microsoft // Compute". - Provider *string `json:"provider,omitempty" azure:"ro"` + 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 `json:"resource,omitempty" azure:"ro"` + 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 `json:"nextLink,omitempty" azure:"ro"` + NextLink *string // READ-ONLY; List of operations supported by the resource provider - Value []*Operation `json:"value,omitempty" azure:"ro"` -} - -// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. -type OperationsClientListOptions struct { - // placeholder for future optional parameters + Value []*Operation } // OutboundEnvironmentEndpoint - A collection of related endpoints from the same service for which the Batch service requires // outbound access. type OutboundEnvironmentEndpoint struct { // READ-ONLY; The type of service that Azure Load Testing connects to. - Category *string `json:"category,omitempty" azure:"ro"` + Category *string // READ-ONLY; The endpoints for this service to which the Batch service makes outbound calls. - Endpoints []*EndpointDependency `json:"endpoints,omitempty" azure:"ro"` + Endpoints []*EndpointDependency } // OutboundEnvironmentEndpointCollection - Values returned by the List operation. type OutboundEnvironmentEndpointCollection struct { // The continuation token. - NextLink *string `json:"nextLink,omitempty"` + NextLink *string // READ-ONLY; The collection of outbound network dependency endpoints returned by the listing operation. - Value []*OutboundEnvironmentEndpoint `json:"value,omitempty" azure:"ro"` + Value []*OutboundEnvironmentEndpoint } // QuotaBucketRequest - Request object of new quota for a quota bucket. type QuotaBucketRequest struct { // New quota request request properties. - Properties *QuotaBucketRequestProperties `json:"properties,omitempty"` + Properties *QuotaBucketRequestProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + Type *string } // QuotaBucketRequestProperties - New quota request request properties. type QuotaBucketRequestProperties struct { // Current quota limit of the quota bucket. - CurrentQuota *int32 `json:"currentQuota,omitempty"` + CurrentQuota *int32 // Current quota usage of the quota bucket. - CurrentUsage *int32 `json:"currentUsage,omitempty"` + CurrentUsage *int32 // Dimensions for new quota request. - Dimensions *QuotaBucketRequestPropertiesDimensions `json:"dimensions,omitempty"` + Dimensions *QuotaBucketRequestPropertiesDimensions // New quota limit of the quota bucket. - NewQuota *int32 `json:"newQuota,omitempty"` + NewQuota *int32 } // QuotaBucketRequestPropertiesDimensions - Dimensions for new quota request. type QuotaBucketRequestPropertiesDimensions struct { // Location dimension for new quota request of the quota bucket. - Location *string `json:"location,omitempty"` + Location *string // Subscription Id dimension for new quota request of the quota bucket. - SubscriptionID *string `json:"subscriptionId,omitempty"` + SubscriptionID *string } // QuotaResource - Quota bucket details object. type QuotaResource struct { // Quota bucket resource properties. - Properties *QuotaResourceProperties `json:"properties,omitempty"` + Properties *QuotaResourceProperties // READ-ONLY; Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName} - ID *string `json:"id,omitempty" azure:"ro"` + ID *string // READ-ONLY; The name of the resource - Name *string `json:"name,omitempty" azure:"ro"` + Name *string // READ-ONLY; Azure Resource Manager metadata containing createdBy and modifiedBy information. - SystemData *SystemData `json:"systemData,omitempty" azure:"ro"` + SystemData *SystemData // READ-ONLY; The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts" - Type *string `json:"type,omitempty" azure:"ro"` + 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 `json:"nextLink,omitempty" azure:"ro"` + NextLink *string // READ-ONLY; List of quota bucket objects provided by the loadtestservice. - Value []*QuotaResource `json:"value,omitempty" azure:"ro"` + Value []*QuotaResource } // QuotaResourceProperties - Quota bucket resource properties. type QuotaResourceProperties struct { // Current quota limit of the quota bucket. - Limit *int32 `json:"limit,omitempty"` + Limit *int32 // Current quota usage of the quota bucket. - Usage *int32 `json:"usage,omitempty"` + Usage *int32 // READ-ONLY; Resource provisioning state. - ProvisioningState *ResourceState `json:"provisioningState,omitempty" azure:"ro"` -} - -// QuotasClientCheckAvailabilityOptions contains the optional parameters for the QuotasClient.CheckAvailability method. -type QuotasClientCheckAvailabilityOptions struct { - // placeholder for future optional parameters -} - -// QuotasClientGetOptions contains the optional parameters for the QuotasClient.Get method. -type QuotasClientGetOptions struct { - // placeholder for future optional parameters -} - -// QuotasClientListOptions contains the optional parameters for the QuotasClient.NewListPager method. -type QuotasClientListOptions struct { - // placeholder for future optional parameters + ProvisioningState *ResourceState } // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). - CreatedAt *time.Time `json:"createdAt,omitempty"` + CreatedAt *time.Time // The identity that created the resource. - CreatedBy *string `json:"createdBy,omitempty"` + CreatedBy *string // The type of identity that created the resource. - CreatedByType *CreatedByType `json:"createdByType,omitempty"` + CreatedByType *CreatedByType // The timestamp of resource last modification (UTC) - LastModifiedAt *time.Time `json:"lastModifiedAt,omitempty"` + LastModifiedAt *time.Time // The identity that last modified the resource. - LastModifiedBy *string `json:"lastModifiedBy,omitempty"` + LastModifiedBy *string // The type of identity that last modified the resource. - LastModifiedByType *CreatedByType `json:"lastModifiedByType,omitempty"` + LastModifiedByType *CreatedByType } // UserAssignedIdentity - User assigned identity properties type UserAssignedIdentity struct { // READ-ONLY; The client ID of the assigned identity. - ClientID *string `json:"clientId,omitempty" azure:"ro"` + ClientID *string // READ-ONLY; The principal ID of the assigned identity. - PrincipalID *string `json:"principalId,omitempty" azure:"ro"` + PrincipalID *string } diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/models_serde.go b/sdk/resourcemanager/loadtesting/armloadtesting/models_serde.go index 4ec933c53d74..389f360241ae 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/models_serde.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/models_serde.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armloadtesting @@ -844,10 +843,10 @@ func (q *QuotaResourceProperties) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) populate(objectMap, "lastModifiedBy", s.LastModifiedBy) populate(objectMap, "lastModifiedByType", s.LastModifiedByType) return json.Marshal(objectMap) @@ -863,7 +862,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { var err error switch key { case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) delete(rawMsg, key) case "createdBy": err = unpopulate(val, "CreatedBy", &s.CreatedBy) @@ -872,7 +871,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { err = unpopulate(val, "CreatedByType", &s.CreatedByType) delete(rawMsg, key) case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) delete(rawMsg, key) case "lastModifiedBy": err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/operations_client.go b/sdk/resourcemanager/loadtesting/armloadtesting/operations_client.go index b8e7d06736a2..90221faf5b81 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/operations_client.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/operations_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armloadtesting @@ -28,7 +27,7 @@ type OperationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -48,25 +47,20 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.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, options) + }, nil) if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return OperationsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OperationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/options.go b/sdk/resourcemanager/loadtesting/armloadtesting/options.go new file mode 100644 index 000000000000..319a242068ee --- /dev/null +++ b/sdk/resourcemanager/loadtesting/armloadtesting/options.go @@ -0,0 +1,71 @@ +//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 + +// LoadTestsClientBeginCreateOrUpdateOptions contains the optional parameters for the LoadTestsClient.BeginCreateOrUpdate +// method. +type LoadTestsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// LoadTestsClientBeginDeleteOptions contains the optional parameters for the LoadTestsClient.BeginDelete method. +type LoadTestsClientBeginDeleteOptions struct { + // Resumes the LRO 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. + 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 +// method. +type LoadTestsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// LoadTestsClientListBySubscriptionOptions contains the optional parameters for the LoadTestsClient.NewListBySubscriptionPager +// method. +type LoadTestsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// LoadTestsClientListOutboundNetworkDependenciesEndpointsOptions contains the optional parameters for the LoadTestsClient.NewListOutboundNetworkDependenciesEndpointsPager +// method. +type LoadTestsClientListOutboundNetworkDependenciesEndpointsOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// QuotasClientCheckAvailabilityOptions contains the optional parameters for the QuotasClient.CheckAvailability method. +type QuotasClientCheckAvailabilityOptions struct { + // placeholder for future optional parameters +} + +// QuotasClientGetOptions contains the optional parameters for the QuotasClient.Get method. +type QuotasClientGetOptions struct { + // placeholder for future optional parameters +} + +// QuotasClientListOptions contains the optional parameters for the QuotasClient.NewListPager method. +type QuotasClientListOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/quotas_client.go b/sdk/resourcemanager/loadtesting/armloadtesting/quotas_client.go index 59b6158feebf..996cc9dd0dbe 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/quotas_client.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/quotas_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armloadtesting @@ -33,7 +32,7 @@ type QuotasClient struct { // - 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+".QuotasClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,18 +53,25 @@ func NewQuotasClient(subscriptionID string, credential azcore.TokenCredential, o // - 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 } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return QuotasClientCheckAvailabilityResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return QuotasClientCheckAvailabilityResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return QuotasClientCheckAvailabilityResponse{}, err } - return client.checkAvailabilityHandleResponse(resp) + resp, err := client.checkAvailabilityHandleResponse(httpResp) + return resp, err } // checkAvailabilityCreateRequest creates the CheckAvailability request. @@ -91,7 +97,10 @@ func (client *QuotasClient) checkAvailabilityCreateRequest(ctx context.Context, reqQP.Set("api-version", "2022-12-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, quotaBucketRequest) + if err := runtime.MarshalAsJSON(req, quotaBucketRequest); err != nil { + return nil, err + } + return req, nil } // checkAvailabilityHandleResponse handles the CheckAvailability response. @@ -111,18 +120,25 @@ func (client *QuotasClient) checkAvailabilityHandleResponse(resp *http.Response) // - 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 } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return QuotasClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return QuotasClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return QuotasClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -171,25 +187,20 @@ func (client *QuotasClient) NewListPager(location string, options *QuotasClientL return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *QuotasClientListResponse) (QuotasClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, location, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + 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 } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return QuotasClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return QuotasClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/loadtesting/armloadtesting/response_types.go b/sdk/resourcemanager/loadtesting/armloadtesting/response_types.go index 94fd69f26c64..bac914afaefd 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/response_types.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/response_types.go @@ -3,14 +3,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armloadtesting // LoadTestsClientCreateOrUpdateResponse contains the response from method LoadTestsClient.BeginCreateOrUpdate. type LoadTestsClientCreateOrUpdateResponse struct { + // LoadTest details LoadTestResource } @@ -21,45 +21,54 @@ type LoadTestsClientDeleteResponse struct { // 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/time_rfc3339.go b/sdk/resourcemanager/loadtesting/armloadtesting/time_rfc3339.go index e8ca9c280046..da6dcc2e1872 100644 --- a/sdk/resourcemanager/loadtesting/armloadtesting/time_rfc3339.go +++ b/sdk/resourcemanager/loadtesting/armloadtesting/time_rfc3339.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armloadtesting @@ -19,50 +18,50 @@ import ( "time" ) -const ( - utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` - utcLayout = "2006-01-02T15:04:05.999999999" - rfc3339JSON = `"` + time.RFC3339Nano + `"` -) - // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) -type timeRFC3339 time.Time +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time -func (t timeRFC3339) MarshalJSON() (json []byte, err error) { +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { tt := time.Time(t) return tt.MarshalJSON() } -func (t timeRFC3339) MarshalText() (text []byte, err error) { +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { tt := time.Time(t) return tt.MarshalText() } -func (t *timeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcLayoutJSON +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON if tzOffsetRegex.Match(data) { - layout = rfc3339JSON + layout = dateTimeJSON } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { - layout := utcLayout +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime if tzOffsetRegex.Match(data) { layout = time.RFC3339Nano } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) Parse(layout, value string) error { +func (t *dateTimeRFC3339) Parse(layout, value string) error { p, err := time.Parse(layout, strings.ToUpper(value)) - *t = timeRFC3339(p) + *t = dateTimeRFC3339(p) return err } -func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { @@ -71,14 +70,14 @@ func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { } else if reflect.ValueOf(t).IsNil() { return } - m[k] = (*timeRFC3339)(t) + m[k] = (*dateTimeRFC3339)(t) } -func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { if data == nil || strings.EqualFold(string(data), "null") { return nil } - var aux timeRFC3339 + var aux dateTimeRFC3339 if err := json.Unmarshal(data, &aux); err != nil { return fmt.Errorf("struct field %s: %v", fn, err) } diff --git a/sdk/resourcemanager/logic/armlogic/CHANGELOG.md b/sdk/resourcemanager/logic/armlogic/CHANGELOG.md index bc149a64a68c..31eb5df5eceb 100644 --- a/sdk/resourcemanager/logic/armlogic/CHANGELOG.md +++ b/sdk/resourcemanager/logic/armlogic/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.2.0 (2023-11-24) +### Features Added + +- Support for test fakes and OpenTelemetry trace spans. + + ## 1.1.1 (2023-04-14) ### Bug Fixes diff --git a/sdk/resourcemanager/logic/armlogic/README.md b/sdk/resourcemanager/logic/armlogic/README.md index f92af31b001b..e972acef1d73 100644 --- a/sdk/resourcemanager/logic/armlogic/README.md +++ b/sdk/resourcemanager/logic/armlogic/README.md @@ -60,6 +60,13 @@ A client groups a set of related APIs, providing access to its functionality. C client := clientFactory.NewWorkflowsClient() ``` +## 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 diff --git a/sdk/resourcemanager/logic/armlogic/autorest.md b/sdk/resourcemanager/logic/armlogic/autorest.md index 83fd483700f3..9b1a958f3273 100644 --- a/sdk/resourcemanager/logic/armlogic/autorest.md +++ b/sdk/resourcemanager/logic/armlogic/autorest.md @@ -8,5 +8,5 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/logic/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/logic/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.1.1 +module-version: 1.2.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/logic/armlogic/client_factory.go b/sdk/resourcemanager/logic/armlogic/client_factory.go index c3778600e087..58eca001bae5 100644 --- a/sdk/resourcemanager/logic/armlogic/client_factory.go +++ b/sdk/resourcemanager/logic/armlogic/client_factory.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -28,7 +27,7 @@ type ClientFactory struct { // - 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+".ClientFactory", moduleVersion, credential, options) + _, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -38,137 +37,164 @@ func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, }, nil } -func (c *ClientFactory) NewWorkflowsClient() *WorkflowsClient { - subClient, _ := NewWorkflowsClient(c.subscriptionID, c.credential, c.options) +// NewIntegrationAccountAgreementsClient creates a new instance of IntegrationAccountAgreementsClient. +func (c *ClientFactory) NewIntegrationAccountAgreementsClient() *IntegrationAccountAgreementsClient { + subClient, _ := NewIntegrationAccountAgreementsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewWorkflowVersionsClient() *WorkflowVersionsClient { - subClient, _ := NewWorkflowVersionsClient(c.subscriptionID, c.credential, c.options) +// NewIntegrationAccountAssembliesClient creates a new instance of IntegrationAccountAssembliesClient. +func (c *ClientFactory) NewIntegrationAccountAssembliesClient() *IntegrationAccountAssembliesClient { + subClient, _ := NewIntegrationAccountAssembliesClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewWorkflowTriggersClient() *WorkflowTriggersClient { - subClient, _ := NewWorkflowTriggersClient(c.subscriptionID, c.credential, c.options) +// NewIntegrationAccountBatchConfigurationsClient creates a new instance of IntegrationAccountBatchConfigurationsClient. +func (c *ClientFactory) NewIntegrationAccountBatchConfigurationsClient() *IntegrationAccountBatchConfigurationsClient { + subClient, _ := NewIntegrationAccountBatchConfigurationsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewWorkflowVersionTriggersClient() *WorkflowVersionTriggersClient { - subClient, _ := NewWorkflowVersionTriggersClient(c.subscriptionID, c.credential, c.options) +// NewIntegrationAccountCertificatesClient creates a new instance of IntegrationAccountCertificatesClient. +func (c *ClientFactory) NewIntegrationAccountCertificatesClient() *IntegrationAccountCertificatesClient { + subClient, _ := NewIntegrationAccountCertificatesClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewWorkflowTriggerHistoriesClient() *WorkflowTriggerHistoriesClient { - subClient, _ := NewWorkflowTriggerHistoriesClient(c.subscriptionID, c.credential, c.options) +// NewIntegrationAccountMapsClient creates a new instance of IntegrationAccountMapsClient. +func (c *ClientFactory) NewIntegrationAccountMapsClient() *IntegrationAccountMapsClient { + subClient, _ := NewIntegrationAccountMapsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewWorkflowRunsClient() *WorkflowRunsClient { - subClient, _ := NewWorkflowRunsClient(c.subscriptionID, c.credential, c.options) +// NewIntegrationAccountPartnersClient creates a new instance of IntegrationAccountPartnersClient. +func (c *ClientFactory) NewIntegrationAccountPartnersClient() *IntegrationAccountPartnersClient { + subClient, _ := NewIntegrationAccountPartnersClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewWorkflowRunActionsClient() *WorkflowRunActionsClient { - subClient, _ := NewWorkflowRunActionsClient(c.subscriptionID, c.credential, c.options) +// NewIntegrationAccountSchemasClient creates a new instance of IntegrationAccountSchemasClient. +func (c *ClientFactory) NewIntegrationAccountSchemasClient() *IntegrationAccountSchemasClient { + subClient, _ := NewIntegrationAccountSchemasClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewWorkflowRunActionRepetitionsClient() *WorkflowRunActionRepetitionsClient { - subClient, _ := NewWorkflowRunActionRepetitionsClient(c.subscriptionID, c.credential, c.options) +// NewIntegrationAccountSessionsClient creates a new instance of IntegrationAccountSessionsClient. +func (c *ClientFactory) NewIntegrationAccountSessionsClient() *IntegrationAccountSessionsClient { + subClient, _ := NewIntegrationAccountSessionsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewWorkflowRunActionRepetitionsRequestHistoriesClient() *WorkflowRunActionRepetitionsRequestHistoriesClient { - subClient, _ := NewWorkflowRunActionRepetitionsRequestHistoriesClient(c.subscriptionID, c.credential, c.options) +// NewIntegrationAccountsClient creates a new instance of IntegrationAccountsClient. +func (c *ClientFactory) NewIntegrationAccountsClient() *IntegrationAccountsClient { + subClient, _ := NewIntegrationAccountsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewWorkflowRunActionRequestHistoriesClient() *WorkflowRunActionRequestHistoriesClient { - subClient, _ := NewWorkflowRunActionRequestHistoriesClient(c.subscriptionID, c.credential, c.options) +// NewIntegrationServiceEnvironmentManagedAPIOperationsClient creates a new instance of IntegrationServiceEnvironmentManagedAPIOperationsClient. +func (c *ClientFactory) NewIntegrationServiceEnvironmentManagedAPIOperationsClient() *IntegrationServiceEnvironmentManagedAPIOperationsClient { + subClient, _ := NewIntegrationServiceEnvironmentManagedAPIOperationsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewWorkflowRunActionScopeRepetitionsClient() *WorkflowRunActionScopeRepetitionsClient { - subClient, _ := NewWorkflowRunActionScopeRepetitionsClient(c.subscriptionID, c.credential, c.options) +// NewIntegrationServiceEnvironmentManagedApisClient creates a new instance of IntegrationServiceEnvironmentManagedApisClient. +func (c *ClientFactory) NewIntegrationServiceEnvironmentManagedApisClient() *IntegrationServiceEnvironmentManagedApisClient { + subClient, _ := NewIntegrationServiceEnvironmentManagedApisClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewWorkflowRunOperationsClient() *WorkflowRunOperationsClient { - subClient, _ := NewWorkflowRunOperationsClient(c.subscriptionID, c.credential, c.options) +// NewIntegrationServiceEnvironmentNetworkHealthClient creates a new instance of IntegrationServiceEnvironmentNetworkHealthClient. +func (c *ClientFactory) NewIntegrationServiceEnvironmentNetworkHealthClient() *IntegrationServiceEnvironmentNetworkHealthClient { + subClient, _ := NewIntegrationServiceEnvironmentNetworkHealthClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewIntegrationAccountsClient() *IntegrationAccountsClient { - subClient, _ := NewIntegrationAccountsClient(c.subscriptionID, c.credential, c.options) +// NewIntegrationServiceEnvironmentSKUsClient creates a new instance of IntegrationServiceEnvironmentSKUsClient. +func (c *ClientFactory) NewIntegrationServiceEnvironmentSKUsClient() *IntegrationServiceEnvironmentSKUsClient { + subClient, _ := NewIntegrationServiceEnvironmentSKUsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewIntegrationAccountAssembliesClient() *IntegrationAccountAssembliesClient { - subClient, _ := NewIntegrationAccountAssembliesClient(c.subscriptionID, c.credential, c.options) +// NewIntegrationServiceEnvironmentsClient creates a new instance of IntegrationServiceEnvironmentsClient. +func (c *ClientFactory) NewIntegrationServiceEnvironmentsClient() *IntegrationServiceEnvironmentsClient { + subClient, _ := NewIntegrationServiceEnvironmentsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewIntegrationAccountBatchConfigurationsClient() *IntegrationAccountBatchConfigurationsClient { - subClient, _ := NewIntegrationAccountBatchConfigurationsClient(c.subscriptionID, c.credential, c.options) +// NewOperationsClient creates a new instance of OperationsClient. +func (c *ClientFactory) NewOperationsClient() *OperationsClient { + subClient, _ := NewOperationsClient(c.credential, c.options) return subClient } -func (c *ClientFactory) NewIntegrationAccountSchemasClient() *IntegrationAccountSchemasClient { - subClient, _ := NewIntegrationAccountSchemasClient(c.subscriptionID, c.credential, c.options) +// NewWorkflowRunActionRepetitionsClient creates a new instance of WorkflowRunActionRepetitionsClient. +func (c *ClientFactory) NewWorkflowRunActionRepetitionsClient() *WorkflowRunActionRepetitionsClient { + subClient, _ := NewWorkflowRunActionRepetitionsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewIntegrationAccountMapsClient() *IntegrationAccountMapsClient { - subClient, _ := NewIntegrationAccountMapsClient(c.subscriptionID, c.credential, c.options) +// NewWorkflowRunActionRepetitionsRequestHistoriesClient creates a new instance of WorkflowRunActionRepetitionsRequestHistoriesClient. +func (c *ClientFactory) NewWorkflowRunActionRepetitionsRequestHistoriesClient() *WorkflowRunActionRepetitionsRequestHistoriesClient { + subClient, _ := NewWorkflowRunActionRepetitionsRequestHistoriesClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewIntegrationAccountPartnersClient() *IntegrationAccountPartnersClient { - subClient, _ := NewIntegrationAccountPartnersClient(c.subscriptionID, c.credential, c.options) +// NewWorkflowRunActionRequestHistoriesClient creates a new instance of WorkflowRunActionRequestHistoriesClient. +func (c *ClientFactory) NewWorkflowRunActionRequestHistoriesClient() *WorkflowRunActionRequestHistoriesClient { + subClient, _ := NewWorkflowRunActionRequestHistoriesClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewIntegrationAccountAgreementsClient() *IntegrationAccountAgreementsClient { - subClient, _ := NewIntegrationAccountAgreementsClient(c.subscriptionID, c.credential, c.options) +// NewWorkflowRunActionScopeRepetitionsClient creates a new instance of WorkflowRunActionScopeRepetitionsClient. +func (c *ClientFactory) NewWorkflowRunActionScopeRepetitionsClient() *WorkflowRunActionScopeRepetitionsClient { + subClient, _ := NewWorkflowRunActionScopeRepetitionsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewIntegrationAccountCertificatesClient() *IntegrationAccountCertificatesClient { - subClient, _ := NewIntegrationAccountCertificatesClient(c.subscriptionID, c.credential, c.options) +// NewWorkflowRunActionsClient creates a new instance of WorkflowRunActionsClient. +func (c *ClientFactory) NewWorkflowRunActionsClient() *WorkflowRunActionsClient { + subClient, _ := NewWorkflowRunActionsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewIntegrationAccountSessionsClient() *IntegrationAccountSessionsClient { - subClient, _ := NewIntegrationAccountSessionsClient(c.subscriptionID, c.credential, c.options) +// NewWorkflowRunOperationsClient creates a new instance of WorkflowRunOperationsClient. +func (c *ClientFactory) NewWorkflowRunOperationsClient() *WorkflowRunOperationsClient { + subClient, _ := NewWorkflowRunOperationsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewIntegrationServiceEnvironmentsClient() *IntegrationServiceEnvironmentsClient { - subClient, _ := NewIntegrationServiceEnvironmentsClient(c.subscriptionID, c.credential, c.options) +// NewWorkflowRunsClient creates a new instance of WorkflowRunsClient. +func (c *ClientFactory) NewWorkflowRunsClient() *WorkflowRunsClient { + subClient, _ := NewWorkflowRunsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewIntegrationServiceEnvironmentSKUsClient() *IntegrationServiceEnvironmentSKUsClient { - subClient, _ := NewIntegrationServiceEnvironmentSKUsClient(c.subscriptionID, c.credential, c.options) +// NewWorkflowTriggerHistoriesClient creates a new instance of WorkflowTriggerHistoriesClient. +func (c *ClientFactory) NewWorkflowTriggerHistoriesClient() *WorkflowTriggerHistoriesClient { + subClient, _ := NewWorkflowTriggerHistoriesClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewIntegrationServiceEnvironmentNetworkHealthClient() *IntegrationServiceEnvironmentNetworkHealthClient { - subClient, _ := NewIntegrationServiceEnvironmentNetworkHealthClient(c.subscriptionID, c.credential, c.options) +// NewWorkflowTriggersClient creates a new instance of WorkflowTriggersClient. +func (c *ClientFactory) NewWorkflowTriggersClient() *WorkflowTriggersClient { + subClient, _ := NewWorkflowTriggersClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewIntegrationServiceEnvironmentManagedApisClient() *IntegrationServiceEnvironmentManagedApisClient { - subClient, _ := NewIntegrationServiceEnvironmentManagedApisClient(c.subscriptionID, c.credential, c.options) +// NewWorkflowVersionTriggersClient creates a new instance of WorkflowVersionTriggersClient. +func (c *ClientFactory) NewWorkflowVersionTriggersClient() *WorkflowVersionTriggersClient { + subClient, _ := NewWorkflowVersionTriggersClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewIntegrationServiceEnvironmentManagedAPIOperationsClient() *IntegrationServiceEnvironmentManagedAPIOperationsClient { - subClient, _ := NewIntegrationServiceEnvironmentManagedAPIOperationsClient(c.subscriptionID, c.credential, c.options) +// NewWorkflowVersionsClient creates a new instance of WorkflowVersionsClient. +func (c *ClientFactory) NewWorkflowVersionsClient() *WorkflowVersionsClient { + subClient, _ := NewWorkflowVersionsClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewOperationsClient() *OperationsClient { - subClient, _ := NewOperationsClient(c.credential, c.options) +// NewWorkflowsClient creates a new instance of WorkflowsClient. +func (c *ClientFactory) NewWorkflowsClient() *WorkflowsClient { + subClient, _ := NewWorkflowsClient(c.subscriptionID, c.credential, c.options) return subClient } diff --git a/sdk/resourcemanager/logic/armlogic/constants.go b/sdk/resourcemanager/logic/armlogic/constants.go index a4322b22244d..569db13ff0ba 100644 --- a/sdk/resourcemanager/logic/armlogic/constants.go +++ b/sdk/resourcemanager/logic/armlogic/constants.go @@ -3,15 +3,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic const ( - moduleName = "armlogic" - moduleVersion = "v1.1.1" + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/logic/armlogic" + moduleVersion = "v1.2.0" ) // APIDeploymentParameterVisibility - The Api deployment parameter visibility. @@ -73,19 +72,19 @@ func PossibleAPITypeValues() []APIType { type AgreementType string const ( - AgreementTypeNotSpecified AgreementType = "NotSpecified" AgreementTypeAS2 AgreementType = "AS2" - AgreementTypeX12 AgreementType = "X12" AgreementTypeEdifact AgreementType = "Edifact" + AgreementTypeNotSpecified AgreementType = "NotSpecified" + AgreementTypeX12 AgreementType = "X12" ) // PossibleAgreementTypeValues returns the possible values for the AgreementType const type. func PossibleAgreementTypeValues() []AgreementType { return []AgreementType{ - AgreementTypeNotSpecified, AgreementTypeAS2, - AgreementTypeX12, AgreementTypeEdifact, + AgreementTypeNotSpecified, + AgreementTypeX12, } } @@ -113,50 +112,50 @@ func PossibleAzureAsyncOperationStateValues() []AzureAsyncOperationState { type DayOfWeek string const ( - DayOfWeekSunday DayOfWeek = "Sunday" + DayOfWeekFriday DayOfWeek = "Friday" DayOfWeekMonday DayOfWeek = "Monday" + DayOfWeekSaturday DayOfWeek = "Saturday" + DayOfWeekSunday DayOfWeek = "Sunday" + DayOfWeekThursday DayOfWeek = "Thursday" DayOfWeekTuesday DayOfWeek = "Tuesday" DayOfWeekWednesday DayOfWeek = "Wednesday" - DayOfWeekThursday DayOfWeek = "Thursday" - DayOfWeekFriday DayOfWeek = "Friday" - DayOfWeekSaturday DayOfWeek = "Saturday" ) // PossibleDayOfWeekValues returns the possible values for the DayOfWeek const type. func PossibleDayOfWeekValues() []DayOfWeek { return []DayOfWeek{ - DayOfWeekSunday, + DayOfWeekFriday, DayOfWeekMonday, + DayOfWeekSaturday, + DayOfWeekSunday, + DayOfWeekThursday, DayOfWeekTuesday, DayOfWeekWednesday, - DayOfWeekThursday, - DayOfWeekFriday, - DayOfWeekSaturday, } } type DaysOfWeek string const ( - DaysOfWeekSunday DaysOfWeek = "Sunday" + DaysOfWeekFriday DaysOfWeek = "Friday" DaysOfWeekMonday DaysOfWeek = "Monday" + DaysOfWeekSaturday DaysOfWeek = "Saturday" + DaysOfWeekSunday DaysOfWeek = "Sunday" + DaysOfWeekThursday DaysOfWeek = "Thursday" DaysOfWeekTuesday DaysOfWeek = "Tuesday" DaysOfWeekWednesday DaysOfWeek = "Wednesday" - DaysOfWeekThursday DaysOfWeek = "Thursday" - DaysOfWeekFriday DaysOfWeek = "Friday" - DaysOfWeekSaturday DaysOfWeek = "Saturday" ) // PossibleDaysOfWeekValues returns the possible values for the DaysOfWeek const type. func PossibleDaysOfWeekValues() []DaysOfWeek { return []DaysOfWeek{ - DaysOfWeekSunday, + DaysOfWeekFriday, DaysOfWeekMonday, + DaysOfWeekSaturday, + DaysOfWeekSunday, + DaysOfWeekThursday, DaysOfWeekTuesday, DaysOfWeekWednesday, - DaysOfWeekThursday, - DaysOfWeekFriday, - DaysOfWeekSaturday, } } @@ -206,17 +205,17 @@ func PossibleEdifactCharacterSetValues() []EdifactCharacterSet { type EdifactDecimalIndicator string const ( - EdifactDecimalIndicatorNotSpecified EdifactDecimalIndicator = "NotSpecified" EdifactDecimalIndicatorComma EdifactDecimalIndicator = "Comma" EdifactDecimalIndicatorDecimal EdifactDecimalIndicator = "Decimal" + EdifactDecimalIndicatorNotSpecified EdifactDecimalIndicator = "NotSpecified" ) // PossibleEdifactDecimalIndicatorValues returns the possible values for the EdifactDecimalIndicator const type. func PossibleEdifactDecimalIndicatorValues() []EdifactDecimalIndicator { return []EdifactDecimalIndicator{ - EdifactDecimalIndicatorNotSpecified, EdifactDecimalIndicatorComma, EdifactDecimalIndicatorDecimal, + EdifactDecimalIndicatorNotSpecified, } } @@ -270,23 +269,23 @@ func PossibleErrorResponseCodeValues() []ErrorResponseCode { type EventLevel string const ( - EventLevelLogAlways EventLevel = "LogAlways" EventLevelCritical EventLevel = "Critical" EventLevelError EventLevel = "Error" - EventLevelWarning EventLevel = "Warning" EventLevelInformational EventLevel = "Informational" + EventLevelLogAlways EventLevel = "LogAlways" EventLevelVerbose EventLevel = "Verbose" + EventLevelWarning EventLevel = "Warning" ) // PossibleEventLevelValues returns the possible values for the EventLevel const type. func PossibleEventLevelValues() []EventLevel { return []EventLevel{ - EventLevelLogAlways, EventLevelCritical, EventLevelError, - EventLevelWarning, EventLevelInformational, + EventLevelLogAlways, EventLevelVerbose, + EventLevelWarning, } } @@ -678,21 +677,21 @@ func PossibleSchemaTypeValues() []SchemaType { type SegmentTerminatorSuffix string const ( - SegmentTerminatorSuffixNotSpecified SegmentTerminatorSuffix = "NotSpecified" - SegmentTerminatorSuffixNone SegmentTerminatorSuffix = "None" SegmentTerminatorSuffixCR SegmentTerminatorSuffix = "CR" - SegmentTerminatorSuffixLF SegmentTerminatorSuffix = "LF" SegmentTerminatorSuffixCRLF SegmentTerminatorSuffix = "CRLF" + SegmentTerminatorSuffixLF SegmentTerminatorSuffix = "LF" + SegmentTerminatorSuffixNone SegmentTerminatorSuffix = "None" + SegmentTerminatorSuffixNotSpecified SegmentTerminatorSuffix = "NotSpecified" ) // PossibleSegmentTerminatorSuffixValues returns the possible values for the SegmentTerminatorSuffix const type. func PossibleSegmentTerminatorSuffixValues() []SegmentTerminatorSuffix { return []SegmentTerminatorSuffix{ - SegmentTerminatorSuffixNotSpecified, - SegmentTerminatorSuffixNone, SegmentTerminatorSuffixCR, - SegmentTerminatorSuffixLF, SegmentTerminatorSuffixCRLF, + SegmentTerminatorSuffixLF, + SegmentTerminatorSuffixNone, + SegmentTerminatorSuffixNotSpecified, } } diff --git a/sdk/resourcemanager/logic/armlogic/fake/integrationaccountagreements_server.go b/sdk/resourcemanager/logic/armlogic/fake/integrationaccountagreements_server.go new file mode 100644 index 000000000000..9c4da58c7a6c --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/integrationaccountagreements_server.go @@ -0,0 +1,321 @@ +//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/logic/armlogic" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// IntegrationAccountAgreementsServer is a fake server for instances of the armlogic.IntegrationAccountAgreementsClient type. +type IntegrationAccountAgreementsServer struct { + // CreateOrUpdate is the fake for method IntegrationAccountAgreementsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, integrationAccountName string, agreementName string, agreement armlogic.IntegrationAccountAgreement, options *armlogic.IntegrationAccountAgreementsClientCreateOrUpdateOptions) (resp azfake.Responder[armlogic.IntegrationAccountAgreementsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method IntegrationAccountAgreementsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, integrationAccountName string, agreementName string, options *armlogic.IntegrationAccountAgreementsClientDeleteOptions) (resp azfake.Responder[armlogic.IntegrationAccountAgreementsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method IntegrationAccountAgreementsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, integrationAccountName string, agreementName string, options *armlogic.IntegrationAccountAgreementsClientGetOptions) (resp azfake.Responder[armlogic.IntegrationAccountAgreementsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method IntegrationAccountAgreementsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, integrationAccountName string, options *armlogic.IntegrationAccountAgreementsClientListOptions) (resp azfake.PagerResponder[armlogic.IntegrationAccountAgreementsClientListResponse]) + + // ListContentCallbackURL is the fake for method IntegrationAccountAgreementsClient.ListContentCallbackURL + // HTTP status codes to indicate success: http.StatusOK + ListContentCallbackURL func(ctx context.Context, resourceGroupName string, integrationAccountName string, agreementName string, listContentCallbackURL armlogic.GetCallbackURLParameters, options *armlogic.IntegrationAccountAgreementsClientListContentCallbackURLOptions) (resp azfake.Responder[armlogic.IntegrationAccountAgreementsClientListContentCallbackURLResponse], errResp azfake.ErrorResponder) +} + +// NewIntegrationAccountAgreementsServerTransport creates a new instance of IntegrationAccountAgreementsServerTransport with the provided implementation. +// The returned IntegrationAccountAgreementsServerTransport instance is connected to an instance of armlogic.IntegrationAccountAgreementsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewIntegrationAccountAgreementsServerTransport(srv *IntegrationAccountAgreementsServer) *IntegrationAccountAgreementsServerTransport { + return &IntegrationAccountAgreementsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.IntegrationAccountAgreementsClientListResponse]](), + } +} + +// IntegrationAccountAgreementsServerTransport connects instances of armlogic.IntegrationAccountAgreementsClient to instances of IntegrationAccountAgreementsServer. +// Don't use this type directly, use NewIntegrationAccountAgreementsServerTransport instead. +type IntegrationAccountAgreementsServerTransport struct { + srv *IntegrationAccountAgreementsServer + newListPager *tracker[azfake.PagerResponder[armlogic.IntegrationAccountAgreementsClientListResponse]] +} + +// Do implements the policy.Transporter interface for IntegrationAccountAgreementsServerTransport. +func (i *IntegrationAccountAgreementsServerTransport) 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 "IntegrationAccountAgreementsClient.CreateOrUpdate": + resp, err = i.dispatchCreateOrUpdate(req) + case "IntegrationAccountAgreementsClient.Delete": + resp, err = i.dispatchDelete(req) + case "IntegrationAccountAgreementsClient.Get": + resp, err = i.dispatchGet(req) + case "IntegrationAccountAgreementsClient.NewListPager": + resp, err = i.dispatchNewListPager(req) + case "IntegrationAccountAgreementsClient.ListContentCallbackURL": + resp, err = i.dispatchListContentCallbackURL(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (i *IntegrationAccountAgreementsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if i.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/agreements/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogic.IntegrationAccountAgreement](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + agreementNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("agreementName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, integrationAccountNameParam, agreementNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).IntegrationAccountAgreement, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountAgreementsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if i.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/agreements/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + agreementNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("agreementName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Delete(req.Context(), resourceGroupNameParam, integrationAccountNameParam, agreementNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountAgreementsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if i.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\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/agreements/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + agreementNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("agreementName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Get(req.Context(), resourceGroupNameParam, integrationAccountNameParam, agreementNameParam, 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).IntegrationAccountAgreement, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountAgreementsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := i.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/agreements` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlogic.IntegrationAccountAgreementsClientListOptions + if topParam != nil || filterParam != nil { + options = &armlogic.IntegrationAccountAgreementsClientListOptions{ + Top: topParam, + Filter: filterParam, + } + } + resp := i.srv.NewListPager(resourceGroupNameParam, integrationAccountNameParam, options) + newListPager = &resp + i.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogic.IntegrationAccountAgreementsClientListResponse, 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) { + i.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + i.newListPager.remove(req) + } + return resp, nil +} + +func (i *IntegrationAccountAgreementsServerTransport) dispatchListContentCallbackURL(req *http.Request) (*http.Response, error) { + if i.srv.ListContentCallbackURL == nil { + return nil, &nonRetriableError{errors.New("fake for method ListContentCallbackURL not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/agreements/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listContentCallbackUrl` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogic.GetCallbackURLParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + agreementNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("agreementName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.ListContentCallbackURL(req.Context(), resourceGroupNameParam, integrationAccountNameParam, agreementNameParam, 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).WorkflowTriggerCallbackURL, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/integrationaccountassemblies_server.go b/sdk/resourcemanager/logic/armlogic/fake/integrationaccountassemblies_server.go new file mode 100644 index 000000000000..8909091cf19c --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/integrationaccountassemblies_server.go @@ -0,0 +1,285 @@ +//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/resourcemanager/logic/armlogic" + "net/http" + "net/url" + "regexp" +) + +// IntegrationAccountAssembliesServer is a fake server for instances of the armlogic.IntegrationAccountAssembliesClient type. +type IntegrationAccountAssembliesServer struct { + // CreateOrUpdate is the fake for method IntegrationAccountAssembliesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, integrationAccountName string, assemblyArtifactName string, assemblyArtifact armlogic.AssemblyDefinition, options *armlogic.IntegrationAccountAssembliesClientCreateOrUpdateOptions) (resp azfake.Responder[armlogic.IntegrationAccountAssembliesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method IntegrationAccountAssembliesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, integrationAccountName string, assemblyArtifactName string, options *armlogic.IntegrationAccountAssembliesClientDeleteOptions) (resp azfake.Responder[armlogic.IntegrationAccountAssembliesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method IntegrationAccountAssembliesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, integrationAccountName string, assemblyArtifactName string, options *armlogic.IntegrationAccountAssembliesClientGetOptions) (resp azfake.Responder[armlogic.IntegrationAccountAssembliesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method IntegrationAccountAssembliesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, integrationAccountName string, options *armlogic.IntegrationAccountAssembliesClientListOptions) (resp azfake.PagerResponder[armlogic.IntegrationAccountAssembliesClientListResponse]) + + // ListContentCallbackURL is the fake for method IntegrationAccountAssembliesClient.ListContentCallbackURL + // HTTP status codes to indicate success: http.StatusOK + ListContentCallbackURL func(ctx context.Context, resourceGroupName string, integrationAccountName string, assemblyArtifactName string, options *armlogic.IntegrationAccountAssembliesClientListContentCallbackURLOptions) (resp azfake.Responder[armlogic.IntegrationAccountAssembliesClientListContentCallbackURLResponse], errResp azfake.ErrorResponder) +} + +// NewIntegrationAccountAssembliesServerTransport creates a new instance of IntegrationAccountAssembliesServerTransport with the provided implementation. +// The returned IntegrationAccountAssembliesServerTransport instance is connected to an instance of armlogic.IntegrationAccountAssembliesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewIntegrationAccountAssembliesServerTransport(srv *IntegrationAccountAssembliesServer) *IntegrationAccountAssembliesServerTransport { + return &IntegrationAccountAssembliesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.IntegrationAccountAssembliesClientListResponse]](), + } +} + +// IntegrationAccountAssembliesServerTransport connects instances of armlogic.IntegrationAccountAssembliesClient to instances of IntegrationAccountAssembliesServer. +// Don't use this type directly, use NewIntegrationAccountAssembliesServerTransport instead. +type IntegrationAccountAssembliesServerTransport struct { + srv *IntegrationAccountAssembliesServer + newListPager *tracker[azfake.PagerResponder[armlogic.IntegrationAccountAssembliesClientListResponse]] +} + +// Do implements the policy.Transporter interface for IntegrationAccountAssembliesServerTransport. +func (i *IntegrationAccountAssembliesServerTransport) 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 "IntegrationAccountAssembliesClient.CreateOrUpdate": + resp, err = i.dispatchCreateOrUpdate(req) + case "IntegrationAccountAssembliesClient.Delete": + resp, err = i.dispatchDelete(req) + case "IntegrationAccountAssembliesClient.Get": + resp, err = i.dispatchGet(req) + case "IntegrationAccountAssembliesClient.NewListPager": + resp, err = i.dispatchNewListPager(req) + case "IntegrationAccountAssembliesClient.ListContentCallbackURL": + resp, err = i.dispatchListContentCallbackURL(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (i *IntegrationAccountAssembliesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if i.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/assemblies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogic.AssemblyDefinition](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + assemblyArtifactNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("assemblyArtifactName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, integrationAccountNameParam, assemblyArtifactNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).AssemblyDefinition, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountAssembliesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if i.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/assemblies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + assemblyArtifactNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("assemblyArtifactName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Delete(req.Context(), resourceGroupNameParam, integrationAccountNameParam, assemblyArtifactNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountAssembliesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if i.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\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/assemblies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + assemblyArtifactNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("assemblyArtifactName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Get(req.Context(), resourceGroupNameParam, integrationAccountNameParam, assemblyArtifactNameParam, 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).AssemblyDefinition, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountAssembliesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := i.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/assemblies` + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + resp := i.srv.NewListPager(resourceGroupNameParam, integrationAccountNameParam, nil) + newListPager = &resp + i.newListPager.add(req, newListPager) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + i.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + i.newListPager.remove(req) + } + return resp, nil +} + +func (i *IntegrationAccountAssembliesServerTransport) dispatchListContentCallbackURL(req *http.Request) (*http.Response, error) { + if i.srv.ListContentCallbackURL == nil { + return nil, &nonRetriableError{errors.New("fake for method ListContentCallbackURL not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/assemblies/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listContentCallbackUrl` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + assemblyArtifactNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("assemblyArtifactName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.ListContentCallbackURL(req.Context(), resourceGroupNameParam, integrationAccountNameParam, assemblyArtifactNameParam, 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).WorkflowTriggerCallbackURL, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/integrationaccountbatchconfigurations_server.go b/sdk/resourcemanager/logic/armlogic/fake/integrationaccountbatchconfigurations_server.go new file mode 100644 index 000000000000..3490bd5c10ca --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/integrationaccountbatchconfigurations_server.go @@ -0,0 +1,242 @@ +//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/resourcemanager/logic/armlogic" + "net/http" + "net/url" + "regexp" +) + +// IntegrationAccountBatchConfigurationsServer is a fake server for instances of the armlogic.IntegrationAccountBatchConfigurationsClient type. +type IntegrationAccountBatchConfigurationsServer struct { + // CreateOrUpdate is the fake for method IntegrationAccountBatchConfigurationsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, integrationAccountName string, batchConfigurationName string, batchConfiguration armlogic.BatchConfiguration, options *armlogic.IntegrationAccountBatchConfigurationsClientCreateOrUpdateOptions) (resp azfake.Responder[armlogic.IntegrationAccountBatchConfigurationsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method IntegrationAccountBatchConfigurationsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, integrationAccountName string, batchConfigurationName string, options *armlogic.IntegrationAccountBatchConfigurationsClientDeleteOptions) (resp azfake.Responder[armlogic.IntegrationAccountBatchConfigurationsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method IntegrationAccountBatchConfigurationsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, integrationAccountName string, batchConfigurationName string, options *armlogic.IntegrationAccountBatchConfigurationsClientGetOptions) (resp azfake.Responder[armlogic.IntegrationAccountBatchConfigurationsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method IntegrationAccountBatchConfigurationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, integrationAccountName string, options *armlogic.IntegrationAccountBatchConfigurationsClientListOptions) (resp azfake.PagerResponder[armlogic.IntegrationAccountBatchConfigurationsClientListResponse]) +} + +// NewIntegrationAccountBatchConfigurationsServerTransport creates a new instance of IntegrationAccountBatchConfigurationsServerTransport with the provided implementation. +// The returned IntegrationAccountBatchConfigurationsServerTransport instance is connected to an instance of armlogic.IntegrationAccountBatchConfigurationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewIntegrationAccountBatchConfigurationsServerTransport(srv *IntegrationAccountBatchConfigurationsServer) *IntegrationAccountBatchConfigurationsServerTransport { + return &IntegrationAccountBatchConfigurationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.IntegrationAccountBatchConfigurationsClientListResponse]](), + } +} + +// IntegrationAccountBatchConfigurationsServerTransport connects instances of armlogic.IntegrationAccountBatchConfigurationsClient to instances of IntegrationAccountBatchConfigurationsServer. +// Don't use this type directly, use NewIntegrationAccountBatchConfigurationsServerTransport instead. +type IntegrationAccountBatchConfigurationsServerTransport struct { + srv *IntegrationAccountBatchConfigurationsServer + newListPager *tracker[azfake.PagerResponder[armlogic.IntegrationAccountBatchConfigurationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for IntegrationAccountBatchConfigurationsServerTransport. +func (i *IntegrationAccountBatchConfigurationsServerTransport) 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 "IntegrationAccountBatchConfigurationsClient.CreateOrUpdate": + resp, err = i.dispatchCreateOrUpdate(req) + case "IntegrationAccountBatchConfigurationsClient.Delete": + resp, err = i.dispatchDelete(req) + case "IntegrationAccountBatchConfigurationsClient.Get": + resp, err = i.dispatchGet(req) + case "IntegrationAccountBatchConfigurationsClient.NewListPager": + resp, err = i.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (i *IntegrationAccountBatchConfigurationsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if i.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/batchConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogic.BatchConfiguration](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + batchConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("batchConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, integrationAccountNameParam, batchConfigurationNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).BatchConfiguration, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountBatchConfigurationsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if i.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/batchConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + batchConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("batchConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Delete(req.Context(), resourceGroupNameParam, integrationAccountNameParam, batchConfigurationNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountBatchConfigurationsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if i.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\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/batchConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + batchConfigurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("batchConfigurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Get(req.Context(), resourceGroupNameParam, integrationAccountNameParam, batchConfigurationNameParam, 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).BatchConfiguration, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountBatchConfigurationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := i.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/batchConfigurations` + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + resp := i.srv.NewListPager(resourceGroupNameParam, integrationAccountNameParam, nil) + newListPager = &resp + i.newListPager.add(req, newListPager) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + i.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + i.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/integrationaccountcertificates_server.go b/sdk/resourcemanager/logic/armlogic/fake/integrationaccountcertificates_server.go new file mode 100644 index 000000000000..865f0a7a2f05 --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/integrationaccountcertificates_server.go @@ -0,0 +1,268 @@ +//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/logic/armlogic" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// IntegrationAccountCertificatesServer is a fake server for instances of the armlogic.IntegrationAccountCertificatesClient type. +type IntegrationAccountCertificatesServer struct { + // CreateOrUpdate is the fake for method IntegrationAccountCertificatesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, integrationAccountName string, certificateName string, certificate armlogic.IntegrationAccountCertificate, options *armlogic.IntegrationAccountCertificatesClientCreateOrUpdateOptions) (resp azfake.Responder[armlogic.IntegrationAccountCertificatesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method IntegrationAccountCertificatesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, integrationAccountName string, certificateName string, options *armlogic.IntegrationAccountCertificatesClientDeleteOptions) (resp azfake.Responder[armlogic.IntegrationAccountCertificatesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method IntegrationAccountCertificatesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, integrationAccountName string, certificateName string, options *armlogic.IntegrationAccountCertificatesClientGetOptions) (resp azfake.Responder[armlogic.IntegrationAccountCertificatesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method IntegrationAccountCertificatesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, integrationAccountName string, options *armlogic.IntegrationAccountCertificatesClientListOptions) (resp azfake.PagerResponder[armlogic.IntegrationAccountCertificatesClientListResponse]) +} + +// NewIntegrationAccountCertificatesServerTransport creates a new instance of IntegrationAccountCertificatesServerTransport with the provided implementation. +// The returned IntegrationAccountCertificatesServerTransport instance is connected to an instance of armlogic.IntegrationAccountCertificatesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewIntegrationAccountCertificatesServerTransport(srv *IntegrationAccountCertificatesServer) *IntegrationAccountCertificatesServerTransport { + return &IntegrationAccountCertificatesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.IntegrationAccountCertificatesClientListResponse]](), + } +} + +// IntegrationAccountCertificatesServerTransport connects instances of armlogic.IntegrationAccountCertificatesClient to instances of IntegrationAccountCertificatesServer. +// Don't use this type directly, use NewIntegrationAccountCertificatesServerTransport instead. +type IntegrationAccountCertificatesServerTransport struct { + srv *IntegrationAccountCertificatesServer + newListPager *tracker[azfake.PagerResponder[armlogic.IntegrationAccountCertificatesClientListResponse]] +} + +// Do implements the policy.Transporter interface for IntegrationAccountCertificatesServerTransport. +func (i *IntegrationAccountCertificatesServerTransport) 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 "IntegrationAccountCertificatesClient.CreateOrUpdate": + resp, err = i.dispatchCreateOrUpdate(req) + case "IntegrationAccountCertificatesClient.Delete": + resp, err = i.dispatchDelete(req) + case "IntegrationAccountCertificatesClient.Get": + resp, err = i.dispatchGet(req) + case "IntegrationAccountCertificatesClient.NewListPager": + resp, err = i.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (i *IntegrationAccountCertificatesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if i.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogic.IntegrationAccountCertificate](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + certificateNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("certificateName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, integrationAccountNameParam, certificateNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).IntegrationAccountCertificate, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountCertificatesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if i.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + certificateNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("certificateName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Delete(req.Context(), resourceGroupNameParam, integrationAccountNameParam, certificateNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountCertificatesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if i.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\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + certificateNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("certificateName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Get(req.Context(), resourceGroupNameParam, integrationAccountNameParam, certificateNameParam, 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).IntegrationAccountCertificate, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountCertificatesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := i.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/certificates` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armlogic.IntegrationAccountCertificatesClientListOptions + if topParam != nil { + options = &armlogic.IntegrationAccountCertificatesClientListOptions{ + Top: topParam, + } + } + resp := i.srv.NewListPager(resourceGroupNameParam, integrationAccountNameParam, options) + newListPager = &resp + i.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogic.IntegrationAccountCertificatesClientListResponse, 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) { + i.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + i.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/integrationaccountmaps_server.go b/sdk/resourcemanager/logic/armlogic/fake/integrationaccountmaps_server.go new file mode 100644 index 000000000000..a583cee278a1 --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/integrationaccountmaps_server.go @@ -0,0 +1,321 @@ +//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/logic/armlogic" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// IntegrationAccountMapsServer is a fake server for instances of the armlogic.IntegrationAccountMapsClient type. +type IntegrationAccountMapsServer struct { + // CreateOrUpdate is the fake for method IntegrationAccountMapsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, integrationAccountName string, mapName string, mapParam armlogic.IntegrationAccountMap, options *armlogic.IntegrationAccountMapsClientCreateOrUpdateOptions) (resp azfake.Responder[armlogic.IntegrationAccountMapsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method IntegrationAccountMapsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, integrationAccountName string, mapName string, options *armlogic.IntegrationAccountMapsClientDeleteOptions) (resp azfake.Responder[armlogic.IntegrationAccountMapsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method IntegrationAccountMapsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, integrationAccountName string, mapName string, options *armlogic.IntegrationAccountMapsClientGetOptions) (resp azfake.Responder[armlogic.IntegrationAccountMapsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method IntegrationAccountMapsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, integrationAccountName string, options *armlogic.IntegrationAccountMapsClientListOptions) (resp azfake.PagerResponder[armlogic.IntegrationAccountMapsClientListResponse]) + + // ListContentCallbackURL is the fake for method IntegrationAccountMapsClient.ListContentCallbackURL + // HTTP status codes to indicate success: http.StatusOK + ListContentCallbackURL func(ctx context.Context, resourceGroupName string, integrationAccountName string, mapName string, listContentCallbackURL armlogic.GetCallbackURLParameters, options *armlogic.IntegrationAccountMapsClientListContentCallbackURLOptions) (resp azfake.Responder[armlogic.IntegrationAccountMapsClientListContentCallbackURLResponse], errResp azfake.ErrorResponder) +} + +// NewIntegrationAccountMapsServerTransport creates a new instance of IntegrationAccountMapsServerTransport with the provided implementation. +// The returned IntegrationAccountMapsServerTransport instance is connected to an instance of armlogic.IntegrationAccountMapsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewIntegrationAccountMapsServerTransport(srv *IntegrationAccountMapsServer) *IntegrationAccountMapsServerTransport { + return &IntegrationAccountMapsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.IntegrationAccountMapsClientListResponse]](), + } +} + +// IntegrationAccountMapsServerTransport connects instances of armlogic.IntegrationAccountMapsClient to instances of IntegrationAccountMapsServer. +// Don't use this type directly, use NewIntegrationAccountMapsServerTransport instead. +type IntegrationAccountMapsServerTransport struct { + srv *IntegrationAccountMapsServer + newListPager *tracker[azfake.PagerResponder[armlogic.IntegrationAccountMapsClientListResponse]] +} + +// Do implements the policy.Transporter interface for IntegrationAccountMapsServerTransport. +func (i *IntegrationAccountMapsServerTransport) 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 "IntegrationAccountMapsClient.CreateOrUpdate": + resp, err = i.dispatchCreateOrUpdate(req) + case "IntegrationAccountMapsClient.Delete": + resp, err = i.dispatchDelete(req) + case "IntegrationAccountMapsClient.Get": + resp, err = i.dispatchGet(req) + case "IntegrationAccountMapsClient.NewListPager": + resp, err = i.dispatchNewListPager(req) + case "IntegrationAccountMapsClient.ListContentCallbackURL": + resp, err = i.dispatchListContentCallbackURL(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (i *IntegrationAccountMapsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if i.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/maps/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogic.IntegrationAccountMap](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + mapNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("mapName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, integrationAccountNameParam, mapNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).IntegrationAccountMap, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountMapsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if i.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/maps/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + mapNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("mapName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Delete(req.Context(), resourceGroupNameParam, integrationAccountNameParam, mapNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountMapsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if i.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\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/maps/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + mapNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("mapName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Get(req.Context(), resourceGroupNameParam, integrationAccountNameParam, mapNameParam, 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).IntegrationAccountMap, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountMapsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := i.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/maps` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlogic.IntegrationAccountMapsClientListOptions + if topParam != nil || filterParam != nil { + options = &armlogic.IntegrationAccountMapsClientListOptions{ + Top: topParam, + Filter: filterParam, + } + } + resp := i.srv.NewListPager(resourceGroupNameParam, integrationAccountNameParam, options) + newListPager = &resp + i.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogic.IntegrationAccountMapsClientListResponse, 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) { + i.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + i.newListPager.remove(req) + } + return resp, nil +} + +func (i *IntegrationAccountMapsServerTransport) dispatchListContentCallbackURL(req *http.Request) (*http.Response, error) { + if i.srv.ListContentCallbackURL == nil { + return nil, &nonRetriableError{errors.New("fake for method ListContentCallbackURL not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/maps/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listContentCallbackUrl` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogic.GetCallbackURLParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + mapNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("mapName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.ListContentCallbackURL(req.Context(), resourceGroupNameParam, integrationAccountNameParam, mapNameParam, 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).WorkflowTriggerCallbackURL, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/integrationaccountpartners_server.go b/sdk/resourcemanager/logic/armlogic/fake/integrationaccountpartners_server.go new file mode 100644 index 000000000000..6d2e02ed6785 --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/integrationaccountpartners_server.go @@ -0,0 +1,321 @@ +//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/logic/armlogic" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// IntegrationAccountPartnersServer is a fake server for instances of the armlogic.IntegrationAccountPartnersClient type. +type IntegrationAccountPartnersServer struct { + // CreateOrUpdate is the fake for method IntegrationAccountPartnersClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, integrationAccountName string, partnerName string, partner armlogic.IntegrationAccountPartner, options *armlogic.IntegrationAccountPartnersClientCreateOrUpdateOptions) (resp azfake.Responder[armlogic.IntegrationAccountPartnersClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method IntegrationAccountPartnersClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, integrationAccountName string, partnerName string, options *armlogic.IntegrationAccountPartnersClientDeleteOptions) (resp azfake.Responder[armlogic.IntegrationAccountPartnersClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method IntegrationAccountPartnersClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, integrationAccountName string, partnerName string, options *armlogic.IntegrationAccountPartnersClientGetOptions) (resp azfake.Responder[armlogic.IntegrationAccountPartnersClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method IntegrationAccountPartnersClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, integrationAccountName string, options *armlogic.IntegrationAccountPartnersClientListOptions) (resp azfake.PagerResponder[armlogic.IntegrationAccountPartnersClientListResponse]) + + // ListContentCallbackURL is the fake for method IntegrationAccountPartnersClient.ListContentCallbackURL + // HTTP status codes to indicate success: http.StatusOK + ListContentCallbackURL func(ctx context.Context, resourceGroupName string, integrationAccountName string, partnerName string, listContentCallbackURL armlogic.GetCallbackURLParameters, options *armlogic.IntegrationAccountPartnersClientListContentCallbackURLOptions) (resp azfake.Responder[armlogic.IntegrationAccountPartnersClientListContentCallbackURLResponse], errResp azfake.ErrorResponder) +} + +// NewIntegrationAccountPartnersServerTransport creates a new instance of IntegrationAccountPartnersServerTransport with the provided implementation. +// The returned IntegrationAccountPartnersServerTransport instance is connected to an instance of armlogic.IntegrationAccountPartnersClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewIntegrationAccountPartnersServerTransport(srv *IntegrationAccountPartnersServer) *IntegrationAccountPartnersServerTransport { + return &IntegrationAccountPartnersServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.IntegrationAccountPartnersClientListResponse]](), + } +} + +// IntegrationAccountPartnersServerTransport connects instances of armlogic.IntegrationAccountPartnersClient to instances of IntegrationAccountPartnersServer. +// Don't use this type directly, use NewIntegrationAccountPartnersServerTransport instead. +type IntegrationAccountPartnersServerTransport struct { + srv *IntegrationAccountPartnersServer + newListPager *tracker[azfake.PagerResponder[armlogic.IntegrationAccountPartnersClientListResponse]] +} + +// Do implements the policy.Transporter interface for IntegrationAccountPartnersServerTransport. +func (i *IntegrationAccountPartnersServerTransport) 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 "IntegrationAccountPartnersClient.CreateOrUpdate": + resp, err = i.dispatchCreateOrUpdate(req) + case "IntegrationAccountPartnersClient.Delete": + resp, err = i.dispatchDelete(req) + case "IntegrationAccountPartnersClient.Get": + resp, err = i.dispatchGet(req) + case "IntegrationAccountPartnersClient.NewListPager": + resp, err = i.dispatchNewListPager(req) + case "IntegrationAccountPartnersClient.ListContentCallbackURL": + resp, err = i.dispatchListContentCallbackURL(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (i *IntegrationAccountPartnersServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if i.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/partners/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogic.IntegrationAccountPartner](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + partnerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("partnerName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, integrationAccountNameParam, partnerNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).IntegrationAccountPartner, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountPartnersServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if i.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/partners/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + partnerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("partnerName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Delete(req.Context(), resourceGroupNameParam, integrationAccountNameParam, partnerNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountPartnersServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if i.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\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/partners/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + partnerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("partnerName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Get(req.Context(), resourceGroupNameParam, integrationAccountNameParam, partnerNameParam, 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).IntegrationAccountPartner, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountPartnersServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := i.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/partners` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlogic.IntegrationAccountPartnersClientListOptions + if topParam != nil || filterParam != nil { + options = &armlogic.IntegrationAccountPartnersClientListOptions{ + Top: topParam, + Filter: filterParam, + } + } + resp := i.srv.NewListPager(resourceGroupNameParam, integrationAccountNameParam, options) + newListPager = &resp + i.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogic.IntegrationAccountPartnersClientListResponse, 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) { + i.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + i.newListPager.remove(req) + } + return resp, nil +} + +func (i *IntegrationAccountPartnersServerTransport) dispatchListContentCallbackURL(req *http.Request) (*http.Response, error) { + if i.srv.ListContentCallbackURL == nil { + return nil, &nonRetriableError{errors.New("fake for method ListContentCallbackURL not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/partners/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listContentCallbackUrl` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogic.GetCallbackURLParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + partnerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("partnerName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.ListContentCallbackURL(req.Context(), resourceGroupNameParam, integrationAccountNameParam, partnerNameParam, 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).WorkflowTriggerCallbackURL, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/integrationaccounts_server.go b/sdk/resourcemanager/logic/armlogic/fake/integrationaccounts_server.go new file mode 100644 index 000000000000..1e620d49f3fa --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/integrationaccounts_server.go @@ -0,0 +1,536 @@ +//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/logic/armlogic" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// IntegrationAccountsServer is a fake server for instances of the armlogic.IntegrationAccountsClient type. +type IntegrationAccountsServer struct { + // CreateOrUpdate is the fake for method IntegrationAccountsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, integrationAccountName string, integrationAccount armlogic.IntegrationAccount, options *armlogic.IntegrationAccountsClientCreateOrUpdateOptions) (resp azfake.Responder[armlogic.IntegrationAccountsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method IntegrationAccountsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, integrationAccountName string, options *armlogic.IntegrationAccountsClientDeleteOptions) (resp azfake.Responder[armlogic.IntegrationAccountsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method IntegrationAccountsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, integrationAccountName string, options *armlogic.IntegrationAccountsClientGetOptions) (resp azfake.Responder[armlogic.IntegrationAccountsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method IntegrationAccountsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armlogic.IntegrationAccountsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armlogic.IntegrationAccountsClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method IntegrationAccountsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armlogic.IntegrationAccountsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armlogic.IntegrationAccountsClientListBySubscriptionResponse]) + + // ListCallbackURL is the fake for method IntegrationAccountsClient.ListCallbackURL + // HTTP status codes to indicate success: http.StatusOK + ListCallbackURL func(ctx context.Context, resourceGroupName string, integrationAccountName string, parameters armlogic.GetCallbackURLParameters, options *armlogic.IntegrationAccountsClientListCallbackURLOptions) (resp azfake.Responder[armlogic.IntegrationAccountsClientListCallbackURLResponse], errResp azfake.ErrorResponder) + + // NewListKeyVaultKeysPager is the fake for method IntegrationAccountsClient.NewListKeyVaultKeysPager + // HTTP status codes to indicate success: http.StatusOK + NewListKeyVaultKeysPager func(resourceGroupName string, integrationAccountName string, listKeyVaultKeys armlogic.ListKeyVaultKeysDefinition, options *armlogic.IntegrationAccountsClientListKeyVaultKeysOptions) (resp azfake.PagerResponder[armlogic.IntegrationAccountsClientListKeyVaultKeysResponse]) + + // LogTrackingEvents is the fake for method IntegrationAccountsClient.LogTrackingEvents + // HTTP status codes to indicate success: http.StatusOK + LogTrackingEvents func(ctx context.Context, resourceGroupName string, integrationAccountName string, logTrackingEvents armlogic.TrackingEventsDefinition, options *armlogic.IntegrationAccountsClientLogTrackingEventsOptions) (resp azfake.Responder[armlogic.IntegrationAccountsClientLogTrackingEventsResponse], errResp azfake.ErrorResponder) + + // RegenerateAccessKey is the fake for method IntegrationAccountsClient.RegenerateAccessKey + // HTTP status codes to indicate success: http.StatusOK + RegenerateAccessKey func(ctx context.Context, resourceGroupName string, integrationAccountName string, regenerateAccessKey armlogic.RegenerateActionParameter, options *armlogic.IntegrationAccountsClientRegenerateAccessKeyOptions) (resp azfake.Responder[armlogic.IntegrationAccountsClientRegenerateAccessKeyResponse], errResp azfake.ErrorResponder) + + // Update is the fake for method IntegrationAccountsClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, integrationAccountName string, integrationAccount armlogic.IntegrationAccount, options *armlogic.IntegrationAccountsClientUpdateOptions) (resp azfake.Responder[armlogic.IntegrationAccountsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewIntegrationAccountsServerTransport creates a new instance of IntegrationAccountsServerTransport with the provided implementation. +// The returned IntegrationAccountsServerTransport instance is connected to an instance of armlogic.IntegrationAccountsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewIntegrationAccountsServerTransport(srv *IntegrationAccountsServer) *IntegrationAccountsServerTransport { + return &IntegrationAccountsServerTransport{ + srv: srv, + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armlogic.IntegrationAccountsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armlogic.IntegrationAccountsClientListBySubscriptionResponse]](), + newListKeyVaultKeysPager: newTracker[azfake.PagerResponder[armlogic.IntegrationAccountsClientListKeyVaultKeysResponse]](), + } +} + +// IntegrationAccountsServerTransport connects instances of armlogic.IntegrationAccountsClient to instances of IntegrationAccountsServer. +// Don't use this type directly, use NewIntegrationAccountsServerTransport instead. +type IntegrationAccountsServerTransport struct { + srv *IntegrationAccountsServer + newListByResourceGroupPager *tracker[azfake.PagerResponder[armlogic.IntegrationAccountsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armlogic.IntegrationAccountsClientListBySubscriptionResponse]] + newListKeyVaultKeysPager *tracker[azfake.PagerResponder[armlogic.IntegrationAccountsClientListKeyVaultKeysResponse]] +} + +// Do implements the policy.Transporter interface for IntegrationAccountsServerTransport. +func (i *IntegrationAccountsServerTransport) 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 "IntegrationAccountsClient.CreateOrUpdate": + resp, err = i.dispatchCreateOrUpdate(req) + case "IntegrationAccountsClient.Delete": + resp, err = i.dispatchDelete(req) + case "IntegrationAccountsClient.Get": + resp, err = i.dispatchGet(req) + case "IntegrationAccountsClient.NewListByResourceGroupPager": + resp, err = i.dispatchNewListByResourceGroupPager(req) + case "IntegrationAccountsClient.NewListBySubscriptionPager": + resp, err = i.dispatchNewListBySubscriptionPager(req) + case "IntegrationAccountsClient.ListCallbackURL": + resp, err = i.dispatchListCallbackURL(req) + case "IntegrationAccountsClient.NewListKeyVaultKeysPager": + resp, err = i.dispatchNewListKeyVaultKeysPager(req) + case "IntegrationAccountsClient.LogTrackingEvents": + resp, err = i.dispatchLogTrackingEvents(req) + case "IntegrationAccountsClient.RegenerateAccessKey": + resp, err = i.dispatchRegenerateAccessKey(req) + case "IntegrationAccountsClient.Update": + resp, err = i.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (i *IntegrationAccountsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if i.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?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[armlogic.IntegrationAccount](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, integrationAccountNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).IntegrationAccount, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if i.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Delete(req.Context(), resourceGroupNameParam, integrationAccountNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if i.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\.Logic/integrationAccounts/(?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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Get(req.Context(), resourceGroupNameParam, integrationAccountNameParam, 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).IntegrationAccount, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := i.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armlogic.IntegrationAccountsClientListByResourceGroupOptions + if topParam != nil { + options = &armlogic.IntegrationAccountsClientListByResourceGroupOptions{ + Top: topParam, + } + } + resp := i.srv.NewListByResourceGroupPager(resourceGroupNameParam, options) + newListByResourceGroupPager = &resp + i.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armlogic.IntegrationAccountsClientListByResourceGroupResponse, 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) { + i.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + i.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (i *IntegrationAccountsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := i.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts` + 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) + } + qp := req.URL.Query() + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armlogic.IntegrationAccountsClientListBySubscriptionOptions + if topParam != nil { + options = &armlogic.IntegrationAccountsClientListBySubscriptionOptions{ + Top: topParam, + } + } + resp := i.srv.NewListBySubscriptionPager(options) + newListBySubscriptionPager = &resp + i.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armlogic.IntegrationAccountsClientListBySubscriptionResponse, 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) { + i.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + i.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (i *IntegrationAccountsServerTransport) dispatchListCallbackURL(req *http.Request) (*http.Response, error) { + if i.srv.ListCallbackURL == nil { + return nil, &nonRetriableError{errors.New("fake for method ListCallbackURL not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listCallbackUrl` + 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[armlogic.GetCallbackURLParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.ListCallbackURL(req.Context(), resourceGroupNameParam, integrationAccountNameParam, 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).CallbackURL, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountsServerTransport) dispatchNewListKeyVaultKeysPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListKeyVaultKeysPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListKeyVaultKeysPager not implemented")} + } + newListKeyVaultKeysPager := i.newListKeyVaultKeysPager.get(req) + if newListKeyVaultKeysPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listKeyVaultKeys` + 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[armlogic.ListKeyVaultKeysDefinition](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + resp := i.srv.NewListKeyVaultKeysPager(resourceGroupNameParam, integrationAccountNameParam, body, nil) + newListKeyVaultKeysPager = &resp + i.newListKeyVaultKeysPager.add(req, newListKeyVaultKeysPager) + } + resp, err := server.PagerResponderNext(newListKeyVaultKeysPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + i.newListKeyVaultKeysPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListKeyVaultKeysPager) { + i.newListKeyVaultKeysPager.remove(req) + } + return resp, nil +} + +func (i *IntegrationAccountsServerTransport) dispatchLogTrackingEvents(req *http.Request) (*http.Response, error) { + if i.srv.LogTrackingEvents == nil { + return nil, &nonRetriableError{errors.New("fake for method LogTrackingEvents not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/logTrackingEvents` + 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[armlogic.TrackingEventsDefinition](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.LogTrackingEvents(req.Context(), resourceGroupNameParam, integrationAccountNameParam, 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.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountsServerTransport) dispatchRegenerateAccessKey(req *http.Request) (*http.Response, error) { + if i.srv.RegenerateAccessKey == nil { + return nil, &nonRetriableError{errors.New("fake for method RegenerateAccessKey not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/regenerateAccessKey` + 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[armlogic.RegenerateActionParameter](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.RegenerateAccessKey(req.Context(), resourceGroupNameParam, integrationAccountNameParam, 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).IntegrationAccount, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if i.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\.Logic/integrationAccounts/(?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[armlogic.IntegrationAccount](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Update(req.Context(), resourceGroupNameParam, integrationAccountNameParam, 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).IntegrationAccount, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/integrationaccountschemas_server.go b/sdk/resourcemanager/logic/armlogic/fake/integrationaccountschemas_server.go new file mode 100644 index 000000000000..77180e514f4c --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/integrationaccountschemas_server.go @@ -0,0 +1,321 @@ +//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/logic/armlogic" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// IntegrationAccountSchemasServer is a fake server for instances of the armlogic.IntegrationAccountSchemasClient type. +type IntegrationAccountSchemasServer struct { + // CreateOrUpdate is the fake for method IntegrationAccountSchemasClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, integrationAccountName string, schemaName string, schema armlogic.IntegrationAccountSchema, options *armlogic.IntegrationAccountSchemasClientCreateOrUpdateOptions) (resp azfake.Responder[armlogic.IntegrationAccountSchemasClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method IntegrationAccountSchemasClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, integrationAccountName string, schemaName string, options *armlogic.IntegrationAccountSchemasClientDeleteOptions) (resp azfake.Responder[armlogic.IntegrationAccountSchemasClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method IntegrationAccountSchemasClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, integrationAccountName string, schemaName string, options *armlogic.IntegrationAccountSchemasClientGetOptions) (resp azfake.Responder[armlogic.IntegrationAccountSchemasClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method IntegrationAccountSchemasClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, integrationAccountName string, options *armlogic.IntegrationAccountSchemasClientListOptions) (resp azfake.PagerResponder[armlogic.IntegrationAccountSchemasClientListResponse]) + + // ListContentCallbackURL is the fake for method IntegrationAccountSchemasClient.ListContentCallbackURL + // HTTP status codes to indicate success: http.StatusOK + ListContentCallbackURL func(ctx context.Context, resourceGroupName string, integrationAccountName string, schemaName string, listContentCallbackURL armlogic.GetCallbackURLParameters, options *armlogic.IntegrationAccountSchemasClientListContentCallbackURLOptions) (resp azfake.Responder[armlogic.IntegrationAccountSchemasClientListContentCallbackURLResponse], errResp azfake.ErrorResponder) +} + +// NewIntegrationAccountSchemasServerTransport creates a new instance of IntegrationAccountSchemasServerTransport with the provided implementation. +// The returned IntegrationAccountSchemasServerTransport instance is connected to an instance of armlogic.IntegrationAccountSchemasClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewIntegrationAccountSchemasServerTransport(srv *IntegrationAccountSchemasServer) *IntegrationAccountSchemasServerTransport { + return &IntegrationAccountSchemasServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.IntegrationAccountSchemasClientListResponse]](), + } +} + +// IntegrationAccountSchemasServerTransport connects instances of armlogic.IntegrationAccountSchemasClient to instances of IntegrationAccountSchemasServer. +// Don't use this type directly, use NewIntegrationAccountSchemasServerTransport instead. +type IntegrationAccountSchemasServerTransport struct { + srv *IntegrationAccountSchemasServer + newListPager *tracker[azfake.PagerResponder[armlogic.IntegrationAccountSchemasClientListResponse]] +} + +// Do implements the policy.Transporter interface for IntegrationAccountSchemasServerTransport. +func (i *IntegrationAccountSchemasServerTransport) 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 "IntegrationAccountSchemasClient.CreateOrUpdate": + resp, err = i.dispatchCreateOrUpdate(req) + case "IntegrationAccountSchemasClient.Delete": + resp, err = i.dispatchDelete(req) + case "IntegrationAccountSchemasClient.Get": + resp, err = i.dispatchGet(req) + case "IntegrationAccountSchemasClient.NewListPager": + resp, err = i.dispatchNewListPager(req) + case "IntegrationAccountSchemasClient.ListContentCallbackURL": + resp, err = i.dispatchListContentCallbackURL(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (i *IntegrationAccountSchemasServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if i.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schemas/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogic.IntegrationAccountSchema](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + schemaNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("schemaName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, integrationAccountNameParam, schemaNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).IntegrationAccountSchema, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountSchemasServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if i.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schemas/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + schemaNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("schemaName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Delete(req.Context(), resourceGroupNameParam, integrationAccountNameParam, schemaNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountSchemasServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if i.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\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schemas/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + schemaNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("schemaName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Get(req.Context(), resourceGroupNameParam, integrationAccountNameParam, schemaNameParam, 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).IntegrationAccountSchema, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountSchemasServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := i.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schemas` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlogic.IntegrationAccountSchemasClientListOptions + if topParam != nil || filterParam != nil { + options = &armlogic.IntegrationAccountSchemasClientListOptions{ + Top: topParam, + Filter: filterParam, + } + } + resp := i.srv.NewListPager(resourceGroupNameParam, integrationAccountNameParam, options) + newListPager = &resp + i.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogic.IntegrationAccountSchemasClientListResponse, 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) { + i.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + i.newListPager.remove(req) + } + return resp, nil +} + +func (i *IntegrationAccountSchemasServerTransport) dispatchListContentCallbackURL(req *http.Request) (*http.Response, error) { + if i.srv.ListContentCallbackURL == nil { + return nil, &nonRetriableError{errors.New("fake for method ListContentCallbackURL not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schemas/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listContentCallbackUrl` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogic.GetCallbackURLParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + schemaNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("schemaName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.ListContentCallbackURL(req.Context(), resourceGroupNameParam, integrationAccountNameParam, schemaNameParam, 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).WorkflowTriggerCallbackURL, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/integrationaccountsessions_server.go b/sdk/resourcemanager/logic/armlogic/fake/integrationaccountsessions_server.go new file mode 100644 index 000000000000..6395ae776a5e --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/integrationaccountsessions_server.go @@ -0,0 +1,274 @@ +//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/logic/armlogic" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// IntegrationAccountSessionsServer is a fake server for instances of the armlogic.IntegrationAccountSessionsClient type. +type IntegrationAccountSessionsServer struct { + // CreateOrUpdate is the fake for method IntegrationAccountSessionsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, integrationAccountName string, sessionName string, session armlogic.IntegrationAccountSession, options *armlogic.IntegrationAccountSessionsClientCreateOrUpdateOptions) (resp azfake.Responder[armlogic.IntegrationAccountSessionsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method IntegrationAccountSessionsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, integrationAccountName string, sessionName string, options *armlogic.IntegrationAccountSessionsClientDeleteOptions) (resp azfake.Responder[armlogic.IntegrationAccountSessionsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method IntegrationAccountSessionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, integrationAccountName string, sessionName string, options *armlogic.IntegrationAccountSessionsClientGetOptions) (resp azfake.Responder[armlogic.IntegrationAccountSessionsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method IntegrationAccountSessionsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, integrationAccountName string, options *armlogic.IntegrationAccountSessionsClientListOptions) (resp azfake.PagerResponder[armlogic.IntegrationAccountSessionsClientListResponse]) +} + +// NewIntegrationAccountSessionsServerTransport creates a new instance of IntegrationAccountSessionsServerTransport with the provided implementation. +// The returned IntegrationAccountSessionsServerTransport instance is connected to an instance of armlogic.IntegrationAccountSessionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewIntegrationAccountSessionsServerTransport(srv *IntegrationAccountSessionsServer) *IntegrationAccountSessionsServerTransport { + return &IntegrationAccountSessionsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.IntegrationAccountSessionsClientListResponse]](), + } +} + +// IntegrationAccountSessionsServerTransport connects instances of armlogic.IntegrationAccountSessionsClient to instances of IntegrationAccountSessionsServer. +// Don't use this type directly, use NewIntegrationAccountSessionsServerTransport instead. +type IntegrationAccountSessionsServerTransport struct { + srv *IntegrationAccountSessionsServer + newListPager *tracker[azfake.PagerResponder[armlogic.IntegrationAccountSessionsClientListResponse]] +} + +// Do implements the policy.Transporter interface for IntegrationAccountSessionsServerTransport. +func (i *IntegrationAccountSessionsServerTransport) 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 "IntegrationAccountSessionsClient.CreateOrUpdate": + resp, err = i.dispatchCreateOrUpdate(req) + case "IntegrationAccountSessionsClient.Delete": + resp, err = i.dispatchDelete(req) + case "IntegrationAccountSessionsClient.Get": + resp, err = i.dispatchGet(req) + case "IntegrationAccountSessionsClient.NewListPager": + resp, err = i.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (i *IntegrationAccountSessionsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if i.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/sessions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogic.IntegrationAccountSession](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + sessionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("sessionName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, integrationAccountNameParam, sessionNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).IntegrationAccountSession, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountSessionsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if i.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/sessions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + sessionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("sessionName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Delete(req.Context(), resourceGroupNameParam, integrationAccountNameParam, sessionNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountSessionsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if i.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\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/sessions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + sessionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("sessionName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Get(req.Context(), resourceGroupNameParam, integrationAccountNameParam, sessionNameParam, 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).IntegrationAccountSession, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationAccountSessionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := i.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationAccounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/sessions` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + integrationAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationAccountName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlogic.IntegrationAccountSessionsClientListOptions + if topParam != nil || filterParam != nil { + options = &armlogic.IntegrationAccountSessionsClientListOptions{ + Top: topParam, + Filter: filterParam, + } + } + resp := i.srv.NewListPager(resourceGroupNameParam, integrationAccountNameParam, options) + newListPager = &resp + i.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogic.IntegrationAccountSessionsClientListResponse, 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) { + i.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + i.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/integrationserviceenvironmentmanagedapioperations_server.go b/sdk/resourcemanager/logic/armlogic/fake/integrationserviceenvironmentmanagedapioperations_server.go new file mode 100644 index 000000000000..1e224b4b79fb --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/integrationserviceenvironmentmanagedapioperations_server.go @@ -0,0 +1,116 @@ +//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 ( + "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/logic/armlogic" + "net/http" + "net/url" + "regexp" +) + +// IntegrationServiceEnvironmentManagedAPIOperationsServer is a fake server for instances of the armlogic.IntegrationServiceEnvironmentManagedAPIOperationsClient type. +type IntegrationServiceEnvironmentManagedAPIOperationsServer struct { + // NewListPager is the fake for method IntegrationServiceEnvironmentManagedAPIOperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroup string, integrationServiceEnvironmentName string, apiName string, options *armlogic.IntegrationServiceEnvironmentManagedAPIOperationsClientListOptions) (resp azfake.PagerResponder[armlogic.IntegrationServiceEnvironmentManagedAPIOperationsClientListResponse]) +} + +// NewIntegrationServiceEnvironmentManagedAPIOperationsServerTransport creates a new instance of IntegrationServiceEnvironmentManagedAPIOperationsServerTransport with the provided implementation. +// The returned IntegrationServiceEnvironmentManagedAPIOperationsServerTransport instance is connected to an instance of armlogic.IntegrationServiceEnvironmentManagedAPIOperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewIntegrationServiceEnvironmentManagedAPIOperationsServerTransport(srv *IntegrationServiceEnvironmentManagedAPIOperationsServer) *IntegrationServiceEnvironmentManagedAPIOperationsServerTransport { + return &IntegrationServiceEnvironmentManagedAPIOperationsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.IntegrationServiceEnvironmentManagedAPIOperationsClientListResponse]](), + } +} + +// IntegrationServiceEnvironmentManagedAPIOperationsServerTransport connects instances of armlogic.IntegrationServiceEnvironmentManagedAPIOperationsClient to instances of IntegrationServiceEnvironmentManagedAPIOperationsServer. +// Don't use this type directly, use NewIntegrationServiceEnvironmentManagedAPIOperationsServerTransport instead. +type IntegrationServiceEnvironmentManagedAPIOperationsServerTransport struct { + srv *IntegrationServiceEnvironmentManagedAPIOperationsServer + newListPager *tracker[azfake.PagerResponder[armlogic.IntegrationServiceEnvironmentManagedAPIOperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for IntegrationServiceEnvironmentManagedAPIOperationsServerTransport. +func (i *IntegrationServiceEnvironmentManagedAPIOperationsServerTransport) 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 "IntegrationServiceEnvironmentManagedAPIOperationsClient.NewListPager": + resp, err = i.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (i *IntegrationServiceEnvironmentManagedAPIOperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := i.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationServiceEnvironments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/managedApis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/apiOperations` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroup")]) + if err != nil { + return nil, err + } + integrationServiceEnvironmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationServiceEnvironmentName")]) + if err != nil { + return nil, err + } + apiNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiName")]) + if err != nil { + return nil, err + } + resp := i.srv.NewListPager(resourceGroupParam, integrationServiceEnvironmentNameParam, apiNameParam, nil) + newListPager = &resp + i.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogic.IntegrationServiceEnvironmentManagedAPIOperationsClientListResponse, 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) { + i.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + i.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/integrationserviceenvironmentmanagedapis_server.go b/sdk/resourcemanager/logic/armlogic/fake/integrationserviceenvironmentmanagedapis_server.go new file mode 100644 index 000000000000..b48582cade18 --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/integrationserviceenvironmentmanagedapis_server.go @@ -0,0 +1,272 @@ +//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/logic/armlogic" + "net/http" + "net/url" + "regexp" +) + +// IntegrationServiceEnvironmentManagedApisServer is a fake server for instances of the armlogic.IntegrationServiceEnvironmentManagedApisClient type. +type IntegrationServiceEnvironmentManagedApisServer struct { + // BeginDelete is the fake for method IntegrationServiceEnvironmentManagedApisClient.BeginDelete + // HTTP status codes to indicate success: http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroup string, integrationServiceEnvironmentName string, apiName string, options *armlogic.IntegrationServiceEnvironmentManagedApisClientBeginDeleteOptions) (resp azfake.PollerResponder[armlogic.IntegrationServiceEnvironmentManagedApisClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method IntegrationServiceEnvironmentManagedApisClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroup string, integrationServiceEnvironmentName string, apiName string, options *armlogic.IntegrationServiceEnvironmentManagedApisClientGetOptions) (resp azfake.Responder[armlogic.IntegrationServiceEnvironmentManagedApisClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method IntegrationServiceEnvironmentManagedApisClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroup string, integrationServiceEnvironmentName string, options *armlogic.IntegrationServiceEnvironmentManagedApisClientListOptions) (resp azfake.PagerResponder[armlogic.IntegrationServiceEnvironmentManagedApisClientListResponse]) + + // BeginPut is the fake for method IntegrationServiceEnvironmentManagedApisClient.BeginPut + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginPut func(ctx context.Context, resourceGroup string, integrationServiceEnvironmentName string, apiName string, integrationServiceEnvironmentManagedAPI armlogic.IntegrationServiceEnvironmentManagedAPI, options *armlogic.IntegrationServiceEnvironmentManagedApisClientBeginPutOptions) (resp azfake.PollerResponder[armlogic.IntegrationServiceEnvironmentManagedApisClientPutResponse], errResp azfake.ErrorResponder) +} + +// NewIntegrationServiceEnvironmentManagedApisServerTransport creates a new instance of IntegrationServiceEnvironmentManagedApisServerTransport with the provided implementation. +// The returned IntegrationServiceEnvironmentManagedApisServerTransport instance is connected to an instance of armlogic.IntegrationServiceEnvironmentManagedApisClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewIntegrationServiceEnvironmentManagedApisServerTransport(srv *IntegrationServiceEnvironmentManagedApisServer) *IntegrationServiceEnvironmentManagedApisServerTransport { + return &IntegrationServiceEnvironmentManagedApisServerTransport{ + srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armlogic.IntegrationServiceEnvironmentManagedApisClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armlogic.IntegrationServiceEnvironmentManagedApisClientListResponse]](), + beginPut: newTracker[azfake.PollerResponder[armlogic.IntegrationServiceEnvironmentManagedApisClientPutResponse]](), + } +} + +// IntegrationServiceEnvironmentManagedApisServerTransport connects instances of armlogic.IntegrationServiceEnvironmentManagedApisClient to instances of IntegrationServiceEnvironmentManagedApisServer. +// Don't use this type directly, use NewIntegrationServiceEnvironmentManagedApisServerTransport instead. +type IntegrationServiceEnvironmentManagedApisServerTransport struct { + srv *IntegrationServiceEnvironmentManagedApisServer + beginDelete *tracker[azfake.PollerResponder[armlogic.IntegrationServiceEnvironmentManagedApisClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armlogic.IntegrationServiceEnvironmentManagedApisClientListResponse]] + beginPut *tracker[azfake.PollerResponder[armlogic.IntegrationServiceEnvironmentManagedApisClientPutResponse]] +} + +// Do implements the policy.Transporter interface for IntegrationServiceEnvironmentManagedApisServerTransport. +func (i *IntegrationServiceEnvironmentManagedApisServerTransport) 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 "IntegrationServiceEnvironmentManagedApisClient.BeginDelete": + resp, err = i.dispatchBeginDelete(req) + case "IntegrationServiceEnvironmentManagedApisClient.Get": + resp, err = i.dispatchGet(req) + case "IntegrationServiceEnvironmentManagedApisClient.NewListPager": + resp, err = i.dispatchNewListPager(req) + case "IntegrationServiceEnvironmentManagedApisClient.BeginPut": + resp, err = i.dispatchBeginPut(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (i *IntegrationServiceEnvironmentManagedApisServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if i.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := i.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationServiceEnvironments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/managedApis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroup")]) + if err != nil { + return nil, err + } + integrationServiceEnvironmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationServiceEnvironmentName")]) + if err != nil { + return nil, err + } + apiNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.BeginDelete(req.Context(), resourceGroupParam, integrationServiceEnvironmentNameParam, apiNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + i.beginDelete.add(req, beginDelete) + } + + resp, err := server.PollerResponderNext(beginDelete, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusAccepted, http.StatusNoContent}, resp.StatusCode) { + i.beginDelete.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted, http.StatusNoContent", resp.StatusCode)} + } + if !server.PollerResponderMore(beginDelete) { + i.beginDelete.remove(req) + } + + return resp, nil +} + +func (i *IntegrationServiceEnvironmentManagedApisServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if i.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\.Logic/integrationServiceEnvironments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/managedApis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroup")]) + if err != nil { + return nil, err + } + integrationServiceEnvironmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationServiceEnvironmentName")]) + if err != nil { + return nil, err + } + apiNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Get(req.Context(), resourceGroupParam, integrationServiceEnvironmentNameParam, apiNameParam, 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).IntegrationServiceEnvironmentManagedAPI, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationServiceEnvironmentManagedApisServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := i.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationServiceEnvironments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/managedApis` + 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) + } + resourceGroupParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroup")]) + if err != nil { + return nil, err + } + integrationServiceEnvironmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationServiceEnvironmentName")]) + if err != nil { + return nil, err + } + resp := i.srv.NewListPager(resourceGroupParam, integrationServiceEnvironmentNameParam, nil) + newListPager = &resp + i.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogic.IntegrationServiceEnvironmentManagedApisClientListResponse, 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) { + i.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + i.newListPager.remove(req) + } + return resp, nil +} + +func (i *IntegrationServiceEnvironmentManagedApisServerTransport) dispatchBeginPut(req *http.Request) (*http.Response, error) { + if i.srv.BeginPut == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginPut not implemented")} + } + beginPut := i.beginPut.get(req) + if beginPut == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationServiceEnvironments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/managedApis/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogic.IntegrationServiceEnvironmentManagedAPI](req) + if err != nil { + return nil, err + } + resourceGroupParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroup")]) + if err != nil { + return nil, err + } + integrationServiceEnvironmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationServiceEnvironmentName")]) + if err != nil { + return nil, err + } + apiNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("apiName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.BeginPut(req.Context(), resourceGroupParam, integrationServiceEnvironmentNameParam, apiNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginPut = &respr + i.beginPut.add(req, beginPut) + } + + resp, err := server.PollerResponderNext(beginPut, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + i.beginPut.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginPut) { + i.beginPut.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/integrationserviceenvironmentnetworkhealth_server.go b/sdk/resourcemanager/logic/armlogic/fake/integrationserviceenvironmentnetworkhealth_server.go new file mode 100644 index 000000000000..c669411f7b2a --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/integrationserviceenvironmentnetworkhealth_server.go @@ -0,0 +1,100 @@ +//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/resourcemanager/logic/armlogic" + "net/http" + "net/url" + "regexp" +) + +// IntegrationServiceEnvironmentNetworkHealthServer is a fake server for instances of the armlogic.IntegrationServiceEnvironmentNetworkHealthClient type. +type IntegrationServiceEnvironmentNetworkHealthServer struct { + // Get is the fake for method IntegrationServiceEnvironmentNetworkHealthClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroup string, integrationServiceEnvironmentName string, options *armlogic.IntegrationServiceEnvironmentNetworkHealthClientGetOptions) (resp azfake.Responder[armlogic.IntegrationServiceEnvironmentNetworkHealthClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewIntegrationServiceEnvironmentNetworkHealthServerTransport creates a new instance of IntegrationServiceEnvironmentNetworkHealthServerTransport with the provided implementation. +// The returned IntegrationServiceEnvironmentNetworkHealthServerTransport instance is connected to an instance of armlogic.IntegrationServiceEnvironmentNetworkHealthClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewIntegrationServiceEnvironmentNetworkHealthServerTransport(srv *IntegrationServiceEnvironmentNetworkHealthServer) *IntegrationServiceEnvironmentNetworkHealthServerTransport { + return &IntegrationServiceEnvironmentNetworkHealthServerTransport{srv: srv} +} + +// IntegrationServiceEnvironmentNetworkHealthServerTransport connects instances of armlogic.IntegrationServiceEnvironmentNetworkHealthClient to instances of IntegrationServiceEnvironmentNetworkHealthServer. +// Don't use this type directly, use NewIntegrationServiceEnvironmentNetworkHealthServerTransport instead. +type IntegrationServiceEnvironmentNetworkHealthServerTransport struct { + srv *IntegrationServiceEnvironmentNetworkHealthServer +} + +// Do implements the policy.Transporter interface for IntegrationServiceEnvironmentNetworkHealthServerTransport. +func (i *IntegrationServiceEnvironmentNetworkHealthServerTransport) 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 "IntegrationServiceEnvironmentNetworkHealthClient.Get": + resp, err = i.dispatchGet(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (i *IntegrationServiceEnvironmentNetworkHealthServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if i.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\.Logic/integrationServiceEnvironments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/health/network` + 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) + } + resourceGroupParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroup")]) + if err != nil { + return nil, err + } + integrationServiceEnvironmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationServiceEnvironmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Get(req.Context(), resourceGroupParam, integrationServiceEnvironmentNameParam, 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).Value, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/integrationserviceenvironments_server.go b/sdk/resourcemanager/logic/armlogic/fake/integrationserviceenvironments_server.go new file mode 100644 index 000000000000..0a4ac7887aac --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/integrationserviceenvironments_server.go @@ -0,0 +1,422 @@ +//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/logic/armlogic" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// IntegrationServiceEnvironmentsServer is a fake server for instances of the armlogic.IntegrationServiceEnvironmentsClient type. +type IntegrationServiceEnvironmentsServer struct { + // BeginCreateOrUpdate is the fake for method IntegrationServiceEnvironmentsClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroup string, integrationServiceEnvironmentName string, integrationServiceEnvironment armlogic.IntegrationServiceEnvironment, options *armlogic.IntegrationServiceEnvironmentsClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armlogic.IntegrationServiceEnvironmentsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method IntegrationServiceEnvironmentsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroup string, integrationServiceEnvironmentName string, options *armlogic.IntegrationServiceEnvironmentsClientDeleteOptions) (resp azfake.Responder[armlogic.IntegrationServiceEnvironmentsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method IntegrationServiceEnvironmentsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroup string, integrationServiceEnvironmentName string, options *armlogic.IntegrationServiceEnvironmentsClientGetOptions) (resp azfake.Responder[armlogic.IntegrationServiceEnvironmentsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method IntegrationServiceEnvironmentsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroup string, options *armlogic.IntegrationServiceEnvironmentsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armlogic.IntegrationServiceEnvironmentsClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method IntegrationServiceEnvironmentsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armlogic.IntegrationServiceEnvironmentsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armlogic.IntegrationServiceEnvironmentsClientListBySubscriptionResponse]) + + // Restart is the fake for method IntegrationServiceEnvironmentsClient.Restart + // HTTP status codes to indicate success: http.StatusOK + Restart func(ctx context.Context, resourceGroup string, integrationServiceEnvironmentName string, options *armlogic.IntegrationServiceEnvironmentsClientRestartOptions) (resp azfake.Responder[armlogic.IntegrationServiceEnvironmentsClientRestartResponse], errResp azfake.ErrorResponder) + + // BeginUpdate is the fake for method IntegrationServiceEnvironmentsClient.BeginUpdate + // HTTP status codes to indicate success: http.StatusOK + BeginUpdate func(ctx context.Context, resourceGroup string, integrationServiceEnvironmentName string, integrationServiceEnvironment armlogic.IntegrationServiceEnvironment, options *armlogic.IntegrationServiceEnvironmentsClientBeginUpdateOptions) (resp azfake.PollerResponder[armlogic.IntegrationServiceEnvironmentsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewIntegrationServiceEnvironmentsServerTransport creates a new instance of IntegrationServiceEnvironmentsServerTransport with the provided implementation. +// The returned IntegrationServiceEnvironmentsServerTransport instance is connected to an instance of armlogic.IntegrationServiceEnvironmentsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewIntegrationServiceEnvironmentsServerTransport(srv *IntegrationServiceEnvironmentsServer) *IntegrationServiceEnvironmentsServerTransport { + return &IntegrationServiceEnvironmentsServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armlogic.IntegrationServiceEnvironmentsClientCreateOrUpdateResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armlogic.IntegrationServiceEnvironmentsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armlogic.IntegrationServiceEnvironmentsClientListBySubscriptionResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armlogic.IntegrationServiceEnvironmentsClientUpdateResponse]](), + } +} + +// IntegrationServiceEnvironmentsServerTransport connects instances of armlogic.IntegrationServiceEnvironmentsClient to instances of IntegrationServiceEnvironmentsServer. +// Don't use this type directly, use NewIntegrationServiceEnvironmentsServerTransport instead. +type IntegrationServiceEnvironmentsServerTransport struct { + srv *IntegrationServiceEnvironmentsServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armlogic.IntegrationServiceEnvironmentsClientCreateOrUpdateResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armlogic.IntegrationServiceEnvironmentsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armlogic.IntegrationServiceEnvironmentsClientListBySubscriptionResponse]] + beginUpdate *tracker[azfake.PollerResponder[armlogic.IntegrationServiceEnvironmentsClientUpdateResponse]] +} + +// Do implements the policy.Transporter interface for IntegrationServiceEnvironmentsServerTransport. +func (i *IntegrationServiceEnvironmentsServerTransport) 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 "IntegrationServiceEnvironmentsClient.BeginCreateOrUpdate": + resp, err = i.dispatchBeginCreateOrUpdate(req) + case "IntegrationServiceEnvironmentsClient.Delete": + resp, err = i.dispatchDelete(req) + case "IntegrationServiceEnvironmentsClient.Get": + resp, err = i.dispatchGet(req) + case "IntegrationServiceEnvironmentsClient.NewListByResourceGroupPager": + resp, err = i.dispatchNewListByResourceGroupPager(req) + case "IntegrationServiceEnvironmentsClient.NewListBySubscriptionPager": + resp, err = i.dispatchNewListBySubscriptionPager(req) + case "IntegrationServiceEnvironmentsClient.Restart": + resp, err = i.dispatchRestart(req) + case "IntegrationServiceEnvironmentsClient.BeginUpdate": + resp, err = i.dispatchBeginUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (i *IntegrationServiceEnvironmentsServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if i.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := i.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationServiceEnvironments/(?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[armlogic.IntegrationServiceEnvironment](req) + if err != nil { + return nil, err + } + resourceGroupParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroup")]) + if err != nil { + return nil, err + } + integrationServiceEnvironmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationServiceEnvironmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.BeginCreateOrUpdate(req.Context(), resourceGroupParam, integrationServiceEnvironmentNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + i.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) { + i.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) { + i.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (i *IntegrationServiceEnvironmentsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if i.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationServiceEnvironments/(?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) + } + resourceGroupParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroup")]) + if err != nil { + return nil, err + } + integrationServiceEnvironmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationServiceEnvironmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Delete(req.Context(), resourceGroupParam, integrationServiceEnvironmentNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationServiceEnvironmentsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if i.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\.Logic/integrationServiceEnvironments/(?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) + } + resourceGroupParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroup")]) + if err != nil { + return nil, err + } + integrationServiceEnvironmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationServiceEnvironmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Get(req.Context(), resourceGroupParam, integrationServiceEnvironmentNameParam, 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).IntegrationServiceEnvironment, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationServiceEnvironmentsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := i.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationServiceEnvironments` + 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) + } + qp := req.URL.Query() + resourceGroupParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroup")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armlogic.IntegrationServiceEnvironmentsClientListByResourceGroupOptions + if topParam != nil { + options = &armlogic.IntegrationServiceEnvironmentsClientListByResourceGroupOptions{ + Top: topParam, + } + } + resp := i.srv.NewListByResourceGroupPager(resourceGroupParam, options) + newListByResourceGroupPager = &resp + i.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armlogic.IntegrationServiceEnvironmentsClientListByResourceGroupResponse, 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) { + i.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + i.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (i *IntegrationServiceEnvironmentsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := i.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationServiceEnvironments` + 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) + } + qp := req.URL.Query() + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armlogic.IntegrationServiceEnvironmentsClientListBySubscriptionOptions + if topParam != nil { + options = &armlogic.IntegrationServiceEnvironmentsClientListBySubscriptionOptions{ + Top: topParam, + } + } + resp := i.srv.NewListBySubscriptionPager(options) + newListBySubscriptionPager = &resp + i.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armlogic.IntegrationServiceEnvironmentsClientListBySubscriptionResponse, 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) { + i.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + i.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (i *IntegrationServiceEnvironmentsServerTransport) dispatchRestart(req *http.Request) (*http.Response, error) { + if i.srv.Restart == nil { + return nil, &nonRetriableError{errors.New("fake for method Restart not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationServiceEnvironments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/restart` + 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) + } + resourceGroupParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroup")]) + if err != nil { + return nil, err + } + integrationServiceEnvironmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationServiceEnvironmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.Restart(req.Context(), resourceGroupParam, integrationServiceEnvironmentNameParam, 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.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (i *IntegrationServiceEnvironmentsServerTransport) dispatchBeginUpdate(req *http.Request) (*http.Response, error) { + if i.srv.BeginUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginUpdate not implemented")} + } + beginUpdate := i.beginUpdate.get(req) + if beginUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationServiceEnvironments/(?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[armlogic.IntegrationServiceEnvironment](req) + if err != nil { + return nil, err + } + resourceGroupParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroup")]) + if err != nil { + return nil, err + } + integrationServiceEnvironmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationServiceEnvironmentName")]) + if err != nil { + return nil, err + } + respr, errRespr := i.srv.BeginUpdate(req.Context(), resourceGroupParam, integrationServiceEnvironmentNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginUpdate = &respr + i.beginUpdate.add(req, beginUpdate) + } + + resp, err := server.PollerResponderNext(beginUpdate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK}, resp.StatusCode) { + i.beginUpdate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PollerResponderMore(beginUpdate) { + i.beginUpdate.remove(req) + } + + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/integrationserviceenvironmentskus_server.go b/sdk/resourcemanager/logic/armlogic/fake/integrationserviceenvironmentskus_server.go new file mode 100644 index 000000000000..3eb493975933 --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/integrationserviceenvironmentskus_server.go @@ -0,0 +1,112 @@ +//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 ( + "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/logic/armlogic" + "net/http" + "net/url" + "regexp" +) + +// IntegrationServiceEnvironmentSKUsServer is a fake server for instances of the armlogic.IntegrationServiceEnvironmentSKUsClient type. +type IntegrationServiceEnvironmentSKUsServer struct { + // NewListPager is the fake for method IntegrationServiceEnvironmentSKUsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroup string, integrationServiceEnvironmentName string, options *armlogic.IntegrationServiceEnvironmentSKUsClientListOptions) (resp azfake.PagerResponder[armlogic.IntegrationServiceEnvironmentSKUsClientListResponse]) +} + +// NewIntegrationServiceEnvironmentSKUsServerTransport creates a new instance of IntegrationServiceEnvironmentSKUsServerTransport with the provided implementation. +// The returned IntegrationServiceEnvironmentSKUsServerTransport instance is connected to an instance of armlogic.IntegrationServiceEnvironmentSKUsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewIntegrationServiceEnvironmentSKUsServerTransport(srv *IntegrationServiceEnvironmentSKUsServer) *IntegrationServiceEnvironmentSKUsServerTransport { + return &IntegrationServiceEnvironmentSKUsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.IntegrationServiceEnvironmentSKUsClientListResponse]](), + } +} + +// IntegrationServiceEnvironmentSKUsServerTransport connects instances of armlogic.IntegrationServiceEnvironmentSKUsClient to instances of IntegrationServiceEnvironmentSKUsServer. +// Don't use this type directly, use NewIntegrationServiceEnvironmentSKUsServerTransport instead. +type IntegrationServiceEnvironmentSKUsServerTransport struct { + srv *IntegrationServiceEnvironmentSKUsServer + newListPager *tracker[azfake.PagerResponder[armlogic.IntegrationServiceEnvironmentSKUsClientListResponse]] +} + +// Do implements the policy.Transporter interface for IntegrationServiceEnvironmentSKUsServerTransport. +func (i *IntegrationServiceEnvironmentSKUsServerTransport) 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 "IntegrationServiceEnvironmentSKUsClient.NewListPager": + resp, err = i.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (i *IntegrationServiceEnvironmentSKUsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if i.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := i.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/integrationServiceEnvironments/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/skus` + 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) + } + resourceGroupParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroup")]) + if err != nil { + return nil, err + } + integrationServiceEnvironmentNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("integrationServiceEnvironmentName")]) + if err != nil { + return nil, err + } + resp := i.srv.NewListPager(resourceGroupParam, integrationServiceEnvironmentNameParam, nil) + newListPager = &resp + i.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogic.IntegrationServiceEnvironmentSKUsClientListResponse, 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) { + i.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + i.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/internal.go b/sdk/resourcemanager/logic/armlogic/fake/internal.go new file mode 100644 index 000000000000..7d2f89ba4bb2 --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/internal.go @@ -0,0 +1,83 @@ +//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 ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "reflect" + "sync" +) + +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 getOptional[T any](v T) *T { + if reflect.ValueOf(v).IsZero() { + return nil + } + return &v +} + +func parseOptional[T any](v string, parse func(v string) (T, error)) (*T, error) { + if v == "" { + return nil, nil + } + t, err := parse(v) + if err != nil { + return nil, err + } + return &t, err +} + +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/logic/armlogic/fake/operations_server.go b/sdk/resourcemanager/logic/armlogic/fake/operations_server.go new file mode 100644 index 000000000000..04cb2d61f637 --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/operations_server.go @@ -0,0 +1,96 @@ +//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 ( + "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/logic/armlogic" + "net/http" +) + +// OperationsServer is a fake server for instances of the armlogic.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armlogic.OperationsClientListOptions) (resp azfake.PagerResponder[armlogic.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armlogic.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[armlogic.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armlogic.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armlogic.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) 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 "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogic.OperationsClientListResponse, 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) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/server_factory.go b/sdk/resourcemanager/logic/armlogic/fake/server_factory.go new file mode 100644 index 000000000000..3dfcfb68ee7c --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/server_factory.go @@ -0,0 +1,253 @@ +//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 ( + "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 armlogic.ClientFactory type. +type ServerFactory struct { + IntegrationAccountAgreementsServer IntegrationAccountAgreementsServer + IntegrationAccountAssembliesServer IntegrationAccountAssembliesServer + IntegrationAccountBatchConfigurationsServer IntegrationAccountBatchConfigurationsServer + IntegrationAccountCertificatesServer IntegrationAccountCertificatesServer + IntegrationAccountMapsServer IntegrationAccountMapsServer + IntegrationAccountPartnersServer IntegrationAccountPartnersServer + IntegrationAccountSchemasServer IntegrationAccountSchemasServer + IntegrationAccountSessionsServer IntegrationAccountSessionsServer + IntegrationAccountsServer IntegrationAccountsServer + IntegrationServiceEnvironmentManagedAPIOperationsServer IntegrationServiceEnvironmentManagedAPIOperationsServer + IntegrationServiceEnvironmentManagedApisServer IntegrationServiceEnvironmentManagedApisServer + IntegrationServiceEnvironmentNetworkHealthServer IntegrationServiceEnvironmentNetworkHealthServer + IntegrationServiceEnvironmentSKUsServer IntegrationServiceEnvironmentSKUsServer + IntegrationServiceEnvironmentsServer IntegrationServiceEnvironmentsServer + OperationsServer OperationsServer + WorkflowRunActionRepetitionsServer WorkflowRunActionRepetitionsServer + WorkflowRunActionRepetitionsRequestHistoriesServer WorkflowRunActionRepetitionsRequestHistoriesServer + WorkflowRunActionRequestHistoriesServer WorkflowRunActionRequestHistoriesServer + WorkflowRunActionScopeRepetitionsServer WorkflowRunActionScopeRepetitionsServer + WorkflowRunActionsServer WorkflowRunActionsServer + WorkflowRunOperationsServer WorkflowRunOperationsServer + WorkflowRunsServer WorkflowRunsServer + WorkflowTriggerHistoriesServer WorkflowTriggerHistoriesServer + WorkflowTriggersServer WorkflowTriggersServer + WorkflowVersionTriggersServer WorkflowVersionTriggersServer + WorkflowVersionsServer WorkflowVersionsServer + WorkflowsServer WorkflowsServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armlogic.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 armlogic.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trIntegrationAccountAgreementsServer *IntegrationAccountAgreementsServerTransport + trIntegrationAccountAssembliesServer *IntegrationAccountAssembliesServerTransport + trIntegrationAccountBatchConfigurationsServer *IntegrationAccountBatchConfigurationsServerTransport + trIntegrationAccountCertificatesServer *IntegrationAccountCertificatesServerTransport + trIntegrationAccountMapsServer *IntegrationAccountMapsServerTransport + trIntegrationAccountPartnersServer *IntegrationAccountPartnersServerTransport + trIntegrationAccountSchemasServer *IntegrationAccountSchemasServerTransport + trIntegrationAccountSessionsServer *IntegrationAccountSessionsServerTransport + trIntegrationAccountsServer *IntegrationAccountsServerTransport + trIntegrationServiceEnvironmentManagedAPIOperationsServer *IntegrationServiceEnvironmentManagedAPIOperationsServerTransport + trIntegrationServiceEnvironmentManagedApisServer *IntegrationServiceEnvironmentManagedApisServerTransport + trIntegrationServiceEnvironmentNetworkHealthServer *IntegrationServiceEnvironmentNetworkHealthServerTransport + trIntegrationServiceEnvironmentSKUsServer *IntegrationServiceEnvironmentSKUsServerTransport + trIntegrationServiceEnvironmentsServer *IntegrationServiceEnvironmentsServerTransport + trOperationsServer *OperationsServerTransport + trWorkflowRunActionRepetitionsServer *WorkflowRunActionRepetitionsServerTransport + trWorkflowRunActionRepetitionsRequestHistoriesServer *WorkflowRunActionRepetitionsRequestHistoriesServerTransport + trWorkflowRunActionRequestHistoriesServer *WorkflowRunActionRequestHistoriesServerTransport + trWorkflowRunActionScopeRepetitionsServer *WorkflowRunActionScopeRepetitionsServerTransport + trWorkflowRunActionsServer *WorkflowRunActionsServerTransport + trWorkflowRunOperationsServer *WorkflowRunOperationsServerTransport + trWorkflowRunsServer *WorkflowRunsServerTransport + trWorkflowTriggerHistoriesServer *WorkflowTriggerHistoriesServerTransport + trWorkflowTriggersServer *WorkflowTriggersServerTransport + trWorkflowVersionTriggersServer *WorkflowVersionTriggersServerTransport + trWorkflowVersionsServer *WorkflowVersionsServerTransport + trWorkflowsServer *WorkflowsServerTransport +} + +// 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 "IntegrationAccountAgreementsClient": + initServer(s, &s.trIntegrationAccountAgreementsServer, func() *IntegrationAccountAgreementsServerTransport { + return NewIntegrationAccountAgreementsServerTransport(&s.srv.IntegrationAccountAgreementsServer) + }) + resp, err = s.trIntegrationAccountAgreementsServer.Do(req) + case "IntegrationAccountAssembliesClient": + initServer(s, &s.trIntegrationAccountAssembliesServer, func() *IntegrationAccountAssembliesServerTransport { + return NewIntegrationAccountAssembliesServerTransport(&s.srv.IntegrationAccountAssembliesServer) + }) + resp, err = s.trIntegrationAccountAssembliesServer.Do(req) + case "IntegrationAccountBatchConfigurationsClient": + initServer(s, &s.trIntegrationAccountBatchConfigurationsServer, func() *IntegrationAccountBatchConfigurationsServerTransport { + return NewIntegrationAccountBatchConfigurationsServerTransport(&s.srv.IntegrationAccountBatchConfigurationsServer) + }) + resp, err = s.trIntegrationAccountBatchConfigurationsServer.Do(req) + case "IntegrationAccountCertificatesClient": + initServer(s, &s.trIntegrationAccountCertificatesServer, func() *IntegrationAccountCertificatesServerTransport { + return NewIntegrationAccountCertificatesServerTransport(&s.srv.IntegrationAccountCertificatesServer) + }) + resp, err = s.trIntegrationAccountCertificatesServer.Do(req) + case "IntegrationAccountMapsClient": + initServer(s, &s.trIntegrationAccountMapsServer, func() *IntegrationAccountMapsServerTransport { + return NewIntegrationAccountMapsServerTransport(&s.srv.IntegrationAccountMapsServer) + }) + resp, err = s.trIntegrationAccountMapsServer.Do(req) + case "IntegrationAccountPartnersClient": + initServer(s, &s.trIntegrationAccountPartnersServer, func() *IntegrationAccountPartnersServerTransport { + return NewIntegrationAccountPartnersServerTransport(&s.srv.IntegrationAccountPartnersServer) + }) + resp, err = s.trIntegrationAccountPartnersServer.Do(req) + case "IntegrationAccountSchemasClient": + initServer(s, &s.trIntegrationAccountSchemasServer, func() *IntegrationAccountSchemasServerTransport { + return NewIntegrationAccountSchemasServerTransport(&s.srv.IntegrationAccountSchemasServer) + }) + resp, err = s.trIntegrationAccountSchemasServer.Do(req) + case "IntegrationAccountSessionsClient": + initServer(s, &s.trIntegrationAccountSessionsServer, func() *IntegrationAccountSessionsServerTransport { + return NewIntegrationAccountSessionsServerTransport(&s.srv.IntegrationAccountSessionsServer) + }) + resp, err = s.trIntegrationAccountSessionsServer.Do(req) + case "IntegrationAccountsClient": + initServer(s, &s.trIntegrationAccountsServer, func() *IntegrationAccountsServerTransport { + return NewIntegrationAccountsServerTransport(&s.srv.IntegrationAccountsServer) + }) + resp, err = s.trIntegrationAccountsServer.Do(req) + case "IntegrationServiceEnvironmentManagedAPIOperationsClient": + initServer(s, &s.trIntegrationServiceEnvironmentManagedAPIOperationsServer, func() *IntegrationServiceEnvironmentManagedAPIOperationsServerTransport { + return NewIntegrationServiceEnvironmentManagedAPIOperationsServerTransport(&s.srv.IntegrationServiceEnvironmentManagedAPIOperationsServer) + }) + resp, err = s.trIntegrationServiceEnvironmentManagedAPIOperationsServer.Do(req) + case "IntegrationServiceEnvironmentManagedApisClient": + initServer(s, &s.trIntegrationServiceEnvironmentManagedApisServer, func() *IntegrationServiceEnvironmentManagedApisServerTransport { + return NewIntegrationServiceEnvironmentManagedApisServerTransport(&s.srv.IntegrationServiceEnvironmentManagedApisServer) + }) + resp, err = s.trIntegrationServiceEnvironmentManagedApisServer.Do(req) + case "IntegrationServiceEnvironmentNetworkHealthClient": + initServer(s, &s.trIntegrationServiceEnvironmentNetworkHealthServer, func() *IntegrationServiceEnvironmentNetworkHealthServerTransport { + return NewIntegrationServiceEnvironmentNetworkHealthServerTransport(&s.srv.IntegrationServiceEnvironmentNetworkHealthServer) + }) + resp, err = s.trIntegrationServiceEnvironmentNetworkHealthServer.Do(req) + case "IntegrationServiceEnvironmentSKUsClient": + initServer(s, &s.trIntegrationServiceEnvironmentSKUsServer, func() *IntegrationServiceEnvironmentSKUsServerTransport { + return NewIntegrationServiceEnvironmentSKUsServerTransport(&s.srv.IntegrationServiceEnvironmentSKUsServer) + }) + resp, err = s.trIntegrationServiceEnvironmentSKUsServer.Do(req) + case "IntegrationServiceEnvironmentsClient": + initServer(s, &s.trIntegrationServiceEnvironmentsServer, func() *IntegrationServiceEnvironmentsServerTransport { + return NewIntegrationServiceEnvironmentsServerTransport(&s.srv.IntegrationServiceEnvironmentsServer) + }) + resp, err = s.trIntegrationServiceEnvironmentsServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "WorkflowRunActionRepetitionsClient": + initServer(s, &s.trWorkflowRunActionRepetitionsServer, func() *WorkflowRunActionRepetitionsServerTransport { + return NewWorkflowRunActionRepetitionsServerTransport(&s.srv.WorkflowRunActionRepetitionsServer) + }) + resp, err = s.trWorkflowRunActionRepetitionsServer.Do(req) + case "WorkflowRunActionRepetitionsRequestHistoriesClient": + initServer(s, &s.trWorkflowRunActionRepetitionsRequestHistoriesServer, func() *WorkflowRunActionRepetitionsRequestHistoriesServerTransport { + return NewWorkflowRunActionRepetitionsRequestHistoriesServerTransport(&s.srv.WorkflowRunActionRepetitionsRequestHistoriesServer) + }) + resp, err = s.trWorkflowRunActionRepetitionsRequestHistoriesServer.Do(req) + case "WorkflowRunActionRequestHistoriesClient": + initServer(s, &s.trWorkflowRunActionRequestHistoriesServer, func() *WorkflowRunActionRequestHistoriesServerTransport { + return NewWorkflowRunActionRequestHistoriesServerTransport(&s.srv.WorkflowRunActionRequestHistoriesServer) + }) + resp, err = s.trWorkflowRunActionRequestHistoriesServer.Do(req) + case "WorkflowRunActionScopeRepetitionsClient": + initServer(s, &s.trWorkflowRunActionScopeRepetitionsServer, func() *WorkflowRunActionScopeRepetitionsServerTransport { + return NewWorkflowRunActionScopeRepetitionsServerTransport(&s.srv.WorkflowRunActionScopeRepetitionsServer) + }) + resp, err = s.trWorkflowRunActionScopeRepetitionsServer.Do(req) + case "WorkflowRunActionsClient": + initServer(s, &s.trWorkflowRunActionsServer, func() *WorkflowRunActionsServerTransport { + return NewWorkflowRunActionsServerTransport(&s.srv.WorkflowRunActionsServer) + }) + resp, err = s.trWorkflowRunActionsServer.Do(req) + case "WorkflowRunOperationsClient": + initServer(s, &s.trWorkflowRunOperationsServer, func() *WorkflowRunOperationsServerTransport { + return NewWorkflowRunOperationsServerTransport(&s.srv.WorkflowRunOperationsServer) + }) + resp, err = s.trWorkflowRunOperationsServer.Do(req) + case "WorkflowRunsClient": + initServer(s, &s.trWorkflowRunsServer, func() *WorkflowRunsServerTransport { return NewWorkflowRunsServerTransport(&s.srv.WorkflowRunsServer) }) + resp, err = s.trWorkflowRunsServer.Do(req) + case "WorkflowTriggerHistoriesClient": + initServer(s, &s.trWorkflowTriggerHistoriesServer, func() *WorkflowTriggerHistoriesServerTransport { + return NewWorkflowTriggerHistoriesServerTransport(&s.srv.WorkflowTriggerHistoriesServer) + }) + resp, err = s.trWorkflowTriggerHistoriesServer.Do(req) + case "WorkflowTriggersClient": + initServer(s, &s.trWorkflowTriggersServer, func() *WorkflowTriggersServerTransport { + return NewWorkflowTriggersServerTransport(&s.srv.WorkflowTriggersServer) + }) + resp, err = s.trWorkflowTriggersServer.Do(req) + case "WorkflowVersionTriggersClient": + initServer(s, &s.trWorkflowVersionTriggersServer, func() *WorkflowVersionTriggersServerTransport { + return NewWorkflowVersionTriggersServerTransport(&s.srv.WorkflowVersionTriggersServer) + }) + resp, err = s.trWorkflowVersionTriggersServer.Do(req) + case "WorkflowVersionsClient": + initServer(s, &s.trWorkflowVersionsServer, func() *WorkflowVersionsServerTransport { + return NewWorkflowVersionsServerTransport(&s.srv.WorkflowVersionsServer) + }) + resp, err = s.trWorkflowVersionsServer.Do(req) + case "WorkflowsClient": + initServer(s, &s.trWorkflowsServer, func() *WorkflowsServerTransport { return NewWorkflowsServerTransport(&s.srv.WorkflowsServer) }) + resp, err = s.trWorkflowsServer.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/logic/armlogic/fake/time_rfc3339.go b/sdk/resourcemanager/logic/armlogic/fake/time_rfc3339.go new file mode 100644 index 000000000000..b0535a7b63e6 --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/time_rfc3339.go @@ -0,0 +1,86 @@ +//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 ( + "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 ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +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 { + layout := utcDateTimeJSON + if tzOffsetRegex.Match(data) { + layout = dateTimeJSON + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + 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 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 || strings.EqualFold(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/logic/armlogic/fake/workflowrunactionrepetitions_server.go b/sdk/resourcemanager/logic/armlogic/fake/workflowrunactionrepetitions_server.go new file mode 100644 index 000000000000..a08f5c234ac0 --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/workflowrunactionrepetitions_server.go @@ -0,0 +1,226 @@ +//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/resourcemanager/logic/armlogic" + "net/http" + "net/url" + "regexp" +) + +// WorkflowRunActionRepetitionsServer is a fake server for instances of the armlogic.WorkflowRunActionRepetitionsClient type. +type WorkflowRunActionRepetitionsServer struct { + // Get is the fake for method WorkflowRunActionRepetitionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, workflowName string, runName string, actionName string, repetitionName string, options *armlogic.WorkflowRunActionRepetitionsClientGetOptions) (resp azfake.Responder[armlogic.WorkflowRunActionRepetitionsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method WorkflowRunActionRepetitionsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, workflowName string, runName string, actionName string, options *armlogic.WorkflowRunActionRepetitionsClientListOptions) (resp azfake.PagerResponder[armlogic.WorkflowRunActionRepetitionsClientListResponse]) + + // NewListExpressionTracesPager is the fake for method WorkflowRunActionRepetitionsClient.NewListExpressionTracesPager + // HTTP status codes to indicate success: http.StatusOK + NewListExpressionTracesPager func(resourceGroupName string, workflowName string, runName string, actionName string, repetitionName string, options *armlogic.WorkflowRunActionRepetitionsClientListExpressionTracesOptions) (resp azfake.PagerResponder[armlogic.WorkflowRunActionRepetitionsClientListExpressionTracesResponse]) +} + +// NewWorkflowRunActionRepetitionsServerTransport creates a new instance of WorkflowRunActionRepetitionsServerTransport with the provided implementation. +// The returned WorkflowRunActionRepetitionsServerTransport instance is connected to an instance of armlogic.WorkflowRunActionRepetitionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkflowRunActionRepetitionsServerTransport(srv *WorkflowRunActionRepetitionsServer) *WorkflowRunActionRepetitionsServerTransport { + return &WorkflowRunActionRepetitionsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.WorkflowRunActionRepetitionsClientListResponse]](), + newListExpressionTracesPager: newTracker[azfake.PagerResponder[armlogic.WorkflowRunActionRepetitionsClientListExpressionTracesResponse]](), + } +} + +// WorkflowRunActionRepetitionsServerTransport connects instances of armlogic.WorkflowRunActionRepetitionsClient to instances of WorkflowRunActionRepetitionsServer. +// Don't use this type directly, use NewWorkflowRunActionRepetitionsServerTransport instead. +type WorkflowRunActionRepetitionsServerTransport struct { + srv *WorkflowRunActionRepetitionsServer + newListPager *tracker[azfake.PagerResponder[armlogic.WorkflowRunActionRepetitionsClientListResponse]] + newListExpressionTracesPager *tracker[azfake.PagerResponder[armlogic.WorkflowRunActionRepetitionsClientListExpressionTracesResponse]] +} + +// Do implements the policy.Transporter interface for WorkflowRunActionRepetitionsServerTransport. +func (w *WorkflowRunActionRepetitionsServerTransport) 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 "WorkflowRunActionRepetitionsClient.Get": + resp, err = w.dispatchGet(req) + case "WorkflowRunActionRepetitionsClient.NewListPager": + resp, err = w.dispatchNewListPager(req) + case "WorkflowRunActionRepetitionsClient.NewListExpressionTracesPager": + resp, err = w.dispatchNewListExpressionTracesPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (w *WorkflowRunActionRepetitionsServerTransport) 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\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/actions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/repetitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + runNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("runName")]) + if err != nil { + return nil, err + } + actionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("actionName")]) + if err != nil { + return nil, err + } + repetitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("repetitionName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, workflowNameParam, runNameParam, actionNameParam, repetitionNameParam, 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).WorkflowRunActionRepetitionDefinition, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowRunActionRepetitionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := w.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/actions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/repetitions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + runNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("runName")]) + if err != nil { + return nil, err + } + actionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("actionName")]) + if err != nil { + return nil, err + } + resp := w.srv.NewListPager(resourceGroupNameParam, workflowNameParam, runNameParam, actionNameParam, nil) + newListPager = &resp + w.newListPager.add(req, newListPager) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + w.newListPager.remove(req) + } + return resp, nil +} + +func (w *WorkflowRunActionRepetitionsServerTransport) dispatchNewListExpressionTracesPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListExpressionTracesPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListExpressionTracesPager not implemented")} + } + newListExpressionTracesPager := w.newListExpressionTracesPager.get(req) + if newListExpressionTracesPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/actions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/repetitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listExpressionTraces` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + runNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("runName")]) + if err != nil { + return nil, err + } + actionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("actionName")]) + if err != nil { + return nil, err + } + repetitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("repetitionName")]) + if err != nil { + return nil, err + } + resp := w.srv.NewListExpressionTracesPager(resourceGroupNameParam, workflowNameParam, runNameParam, actionNameParam, repetitionNameParam, nil) + newListExpressionTracesPager = &resp + w.newListExpressionTracesPager.add(req, newListExpressionTracesPager) + } + resp, err := server.PagerResponderNext(newListExpressionTracesPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListExpressionTracesPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListExpressionTracesPager) { + w.newListExpressionTracesPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/workflowrunactionrepetitionsrequesthistories_server.go b/sdk/resourcemanager/logic/armlogic/fake/workflowrunactionrepetitionsrequesthistories_server.go new file mode 100644 index 000000000000..3fe4f32ba2fd --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/workflowrunactionrepetitionsrequesthistories_server.go @@ -0,0 +1,180 @@ +//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/logic/armlogic" + "net/http" + "net/url" + "regexp" +) + +// WorkflowRunActionRepetitionsRequestHistoriesServer is a fake server for instances of the armlogic.WorkflowRunActionRepetitionsRequestHistoriesClient type. +type WorkflowRunActionRepetitionsRequestHistoriesServer struct { + // Get is the fake for method WorkflowRunActionRepetitionsRequestHistoriesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, workflowName string, runName string, actionName string, repetitionName string, requestHistoryName string, options *armlogic.WorkflowRunActionRepetitionsRequestHistoriesClientGetOptions) (resp azfake.Responder[armlogic.WorkflowRunActionRepetitionsRequestHistoriesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method WorkflowRunActionRepetitionsRequestHistoriesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, workflowName string, runName string, actionName string, repetitionName string, options *armlogic.WorkflowRunActionRepetitionsRequestHistoriesClientListOptions) (resp azfake.PagerResponder[armlogic.WorkflowRunActionRepetitionsRequestHistoriesClientListResponse]) +} + +// NewWorkflowRunActionRepetitionsRequestHistoriesServerTransport creates a new instance of WorkflowRunActionRepetitionsRequestHistoriesServerTransport with the provided implementation. +// The returned WorkflowRunActionRepetitionsRequestHistoriesServerTransport instance is connected to an instance of armlogic.WorkflowRunActionRepetitionsRequestHistoriesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkflowRunActionRepetitionsRequestHistoriesServerTransport(srv *WorkflowRunActionRepetitionsRequestHistoriesServer) *WorkflowRunActionRepetitionsRequestHistoriesServerTransport { + return &WorkflowRunActionRepetitionsRequestHistoriesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.WorkflowRunActionRepetitionsRequestHistoriesClientListResponse]](), + } +} + +// WorkflowRunActionRepetitionsRequestHistoriesServerTransport connects instances of armlogic.WorkflowRunActionRepetitionsRequestHistoriesClient to instances of WorkflowRunActionRepetitionsRequestHistoriesServer. +// Don't use this type directly, use NewWorkflowRunActionRepetitionsRequestHistoriesServerTransport instead. +type WorkflowRunActionRepetitionsRequestHistoriesServerTransport struct { + srv *WorkflowRunActionRepetitionsRequestHistoriesServer + newListPager *tracker[azfake.PagerResponder[armlogic.WorkflowRunActionRepetitionsRequestHistoriesClientListResponse]] +} + +// Do implements the policy.Transporter interface for WorkflowRunActionRepetitionsRequestHistoriesServerTransport. +func (w *WorkflowRunActionRepetitionsRequestHistoriesServerTransport) 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 "WorkflowRunActionRepetitionsRequestHistoriesClient.Get": + resp, err = w.dispatchGet(req) + case "WorkflowRunActionRepetitionsRequestHistoriesClient.NewListPager": + resp, err = w.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (w *WorkflowRunActionRepetitionsRequestHistoriesServerTransport) 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\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/actions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/repetitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/requestHistories/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 7 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + runNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("runName")]) + if err != nil { + return nil, err + } + actionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("actionName")]) + if err != nil { + return nil, err + } + repetitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("repetitionName")]) + if err != nil { + return nil, err + } + requestHistoryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("requestHistoryName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, workflowNameParam, runNameParam, actionNameParam, repetitionNameParam, requestHistoryNameParam, 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).RequestHistory, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowRunActionRepetitionsRequestHistoriesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := w.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/actions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/repetitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/requestHistories` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + runNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("runName")]) + if err != nil { + return nil, err + } + actionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("actionName")]) + if err != nil { + return nil, err + } + repetitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("repetitionName")]) + if err != nil { + return nil, err + } + resp := w.srv.NewListPager(resourceGroupNameParam, workflowNameParam, runNameParam, actionNameParam, repetitionNameParam, nil) + newListPager = &resp + w.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogic.WorkflowRunActionRepetitionsRequestHistoriesClientListResponse, 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) { + w.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + w.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/workflowrunactionrequesthistories_server.go b/sdk/resourcemanager/logic/armlogic/fake/workflowrunactionrequesthistories_server.go new file mode 100644 index 000000000000..47e521cc616b --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/workflowrunactionrequesthistories_server.go @@ -0,0 +1,172 @@ +//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/logic/armlogic" + "net/http" + "net/url" + "regexp" +) + +// WorkflowRunActionRequestHistoriesServer is a fake server for instances of the armlogic.WorkflowRunActionRequestHistoriesClient type. +type WorkflowRunActionRequestHistoriesServer struct { + // Get is the fake for method WorkflowRunActionRequestHistoriesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, workflowName string, runName string, actionName string, requestHistoryName string, options *armlogic.WorkflowRunActionRequestHistoriesClientGetOptions) (resp azfake.Responder[armlogic.WorkflowRunActionRequestHistoriesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method WorkflowRunActionRequestHistoriesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, workflowName string, runName string, actionName string, options *armlogic.WorkflowRunActionRequestHistoriesClientListOptions) (resp azfake.PagerResponder[armlogic.WorkflowRunActionRequestHistoriesClientListResponse]) +} + +// NewWorkflowRunActionRequestHistoriesServerTransport creates a new instance of WorkflowRunActionRequestHistoriesServerTransport with the provided implementation. +// The returned WorkflowRunActionRequestHistoriesServerTransport instance is connected to an instance of armlogic.WorkflowRunActionRequestHistoriesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkflowRunActionRequestHistoriesServerTransport(srv *WorkflowRunActionRequestHistoriesServer) *WorkflowRunActionRequestHistoriesServerTransport { + return &WorkflowRunActionRequestHistoriesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.WorkflowRunActionRequestHistoriesClientListResponse]](), + } +} + +// WorkflowRunActionRequestHistoriesServerTransport connects instances of armlogic.WorkflowRunActionRequestHistoriesClient to instances of WorkflowRunActionRequestHistoriesServer. +// Don't use this type directly, use NewWorkflowRunActionRequestHistoriesServerTransport instead. +type WorkflowRunActionRequestHistoriesServerTransport struct { + srv *WorkflowRunActionRequestHistoriesServer + newListPager *tracker[azfake.PagerResponder[armlogic.WorkflowRunActionRequestHistoriesClientListResponse]] +} + +// Do implements the policy.Transporter interface for WorkflowRunActionRequestHistoriesServerTransport. +func (w *WorkflowRunActionRequestHistoriesServerTransport) 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 "WorkflowRunActionRequestHistoriesClient.Get": + resp, err = w.dispatchGet(req) + case "WorkflowRunActionRequestHistoriesClient.NewListPager": + resp, err = w.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (w *WorkflowRunActionRequestHistoriesServerTransport) 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\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/actions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/requestHistories/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + runNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("runName")]) + if err != nil { + return nil, err + } + actionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("actionName")]) + if err != nil { + return nil, err + } + requestHistoryNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("requestHistoryName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, workflowNameParam, runNameParam, actionNameParam, requestHistoryNameParam, 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).RequestHistory, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowRunActionRequestHistoriesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := w.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/actions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/requestHistories` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + runNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("runName")]) + if err != nil { + return nil, err + } + actionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("actionName")]) + if err != nil { + return nil, err + } + resp := w.srv.NewListPager(resourceGroupNameParam, workflowNameParam, runNameParam, actionNameParam, nil) + newListPager = &resp + w.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogic.WorkflowRunActionRequestHistoriesClientListResponse, 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) { + w.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + w.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/workflowrunactions_server.go b/sdk/resourcemanager/logic/armlogic/fake/workflowrunactions_server.go new file mode 100644 index 000000000000..f94039e02fe3 --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/workflowrunactions_server.go @@ -0,0 +1,246 @@ +//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/logic/armlogic" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkflowRunActionsServer is a fake server for instances of the armlogic.WorkflowRunActionsClient type. +type WorkflowRunActionsServer struct { + // Get is the fake for method WorkflowRunActionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, workflowName string, runName string, actionName string, options *armlogic.WorkflowRunActionsClientGetOptions) (resp azfake.Responder[armlogic.WorkflowRunActionsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method WorkflowRunActionsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, workflowName string, runName string, options *armlogic.WorkflowRunActionsClientListOptions) (resp azfake.PagerResponder[armlogic.WorkflowRunActionsClientListResponse]) + + // NewListExpressionTracesPager is the fake for method WorkflowRunActionsClient.NewListExpressionTracesPager + // HTTP status codes to indicate success: http.StatusOK + NewListExpressionTracesPager func(resourceGroupName string, workflowName string, runName string, actionName string, options *armlogic.WorkflowRunActionsClientListExpressionTracesOptions) (resp azfake.PagerResponder[armlogic.WorkflowRunActionsClientListExpressionTracesResponse]) +} + +// NewWorkflowRunActionsServerTransport creates a new instance of WorkflowRunActionsServerTransport with the provided implementation. +// The returned WorkflowRunActionsServerTransport instance is connected to an instance of armlogic.WorkflowRunActionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkflowRunActionsServerTransport(srv *WorkflowRunActionsServer) *WorkflowRunActionsServerTransport { + return &WorkflowRunActionsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.WorkflowRunActionsClientListResponse]](), + newListExpressionTracesPager: newTracker[azfake.PagerResponder[armlogic.WorkflowRunActionsClientListExpressionTracesResponse]](), + } +} + +// WorkflowRunActionsServerTransport connects instances of armlogic.WorkflowRunActionsClient to instances of WorkflowRunActionsServer. +// Don't use this type directly, use NewWorkflowRunActionsServerTransport instead. +type WorkflowRunActionsServerTransport struct { + srv *WorkflowRunActionsServer + newListPager *tracker[azfake.PagerResponder[armlogic.WorkflowRunActionsClientListResponse]] + newListExpressionTracesPager *tracker[azfake.PagerResponder[armlogic.WorkflowRunActionsClientListExpressionTracesResponse]] +} + +// Do implements the policy.Transporter interface for WorkflowRunActionsServerTransport. +func (w *WorkflowRunActionsServerTransport) 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 "WorkflowRunActionsClient.Get": + resp, err = w.dispatchGet(req) + case "WorkflowRunActionsClient.NewListPager": + resp, err = w.dispatchNewListPager(req) + case "WorkflowRunActionsClient.NewListExpressionTracesPager": + resp, err = w.dispatchNewListExpressionTracesPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (w *WorkflowRunActionsServerTransport) 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\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/actions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + runNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("runName")]) + if err != nil { + return nil, err + } + actionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("actionName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, workflowNameParam, runNameParam, actionNameParam, 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).WorkflowRunAction, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowRunActionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := w.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/actions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + runNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("runName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlogic.WorkflowRunActionsClientListOptions + if topParam != nil || filterParam != nil { + options = &armlogic.WorkflowRunActionsClientListOptions{ + Top: topParam, + Filter: filterParam, + } + } + resp := w.srv.NewListPager(resourceGroupNameParam, workflowNameParam, runNameParam, options) + newListPager = &resp + w.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogic.WorkflowRunActionsClientListResponse, 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) { + w.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + w.newListPager.remove(req) + } + return resp, nil +} + +func (w *WorkflowRunActionsServerTransport) dispatchNewListExpressionTracesPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListExpressionTracesPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListExpressionTracesPager not implemented")} + } + newListExpressionTracesPager := w.newListExpressionTracesPager.get(req) + if newListExpressionTracesPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/actions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listExpressionTraces` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + runNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("runName")]) + if err != nil { + return nil, err + } + actionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("actionName")]) + if err != nil { + return nil, err + } + resp := w.srv.NewListExpressionTracesPager(resourceGroupNameParam, workflowNameParam, runNameParam, actionNameParam, nil) + newListExpressionTracesPager = &resp + w.newListExpressionTracesPager.add(req, newListExpressionTracesPager) + } + resp, err := server.PagerResponderNext(newListExpressionTracesPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListExpressionTracesPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListExpressionTracesPager) { + w.newListExpressionTracesPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/workflowrunactionscoperepetitions_server.go b/sdk/resourcemanager/logic/armlogic/fake/workflowrunactionscoperepetitions_server.go new file mode 100644 index 000000000000..877b3ce7ce3a --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/workflowrunactionscoperepetitions_server.go @@ -0,0 +1,168 @@ +//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/resourcemanager/logic/armlogic" + "net/http" + "net/url" + "regexp" +) + +// WorkflowRunActionScopeRepetitionsServer is a fake server for instances of the armlogic.WorkflowRunActionScopeRepetitionsClient type. +type WorkflowRunActionScopeRepetitionsServer struct { + // Get is the fake for method WorkflowRunActionScopeRepetitionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, workflowName string, runName string, actionName string, repetitionName string, options *armlogic.WorkflowRunActionScopeRepetitionsClientGetOptions) (resp azfake.Responder[armlogic.WorkflowRunActionScopeRepetitionsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method WorkflowRunActionScopeRepetitionsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, workflowName string, runName string, actionName string, options *armlogic.WorkflowRunActionScopeRepetitionsClientListOptions) (resp azfake.PagerResponder[armlogic.WorkflowRunActionScopeRepetitionsClientListResponse]) +} + +// NewWorkflowRunActionScopeRepetitionsServerTransport creates a new instance of WorkflowRunActionScopeRepetitionsServerTransport with the provided implementation. +// The returned WorkflowRunActionScopeRepetitionsServerTransport instance is connected to an instance of armlogic.WorkflowRunActionScopeRepetitionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkflowRunActionScopeRepetitionsServerTransport(srv *WorkflowRunActionScopeRepetitionsServer) *WorkflowRunActionScopeRepetitionsServerTransport { + return &WorkflowRunActionScopeRepetitionsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.WorkflowRunActionScopeRepetitionsClientListResponse]](), + } +} + +// WorkflowRunActionScopeRepetitionsServerTransport connects instances of armlogic.WorkflowRunActionScopeRepetitionsClient to instances of WorkflowRunActionScopeRepetitionsServer. +// Don't use this type directly, use NewWorkflowRunActionScopeRepetitionsServerTransport instead. +type WorkflowRunActionScopeRepetitionsServerTransport struct { + srv *WorkflowRunActionScopeRepetitionsServer + newListPager *tracker[azfake.PagerResponder[armlogic.WorkflowRunActionScopeRepetitionsClientListResponse]] +} + +// Do implements the policy.Transporter interface for WorkflowRunActionScopeRepetitionsServerTransport. +func (w *WorkflowRunActionScopeRepetitionsServerTransport) 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 "WorkflowRunActionScopeRepetitionsClient.Get": + resp, err = w.dispatchGet(req) + case "WorkflowRunActionScopeRepetitionsClient.NewListPager": + resp, err = w.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (w *WorkflowRunActionScopeRepetitionsServerTransport) 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\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/actions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scopeRepetitions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 6 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + runNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("runName")]) + if err != nil { + return nil, err + } + actionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("actionName")]) + if err != nil { + return nil, err + } + repetitionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("repetitionName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, workflowNameParam, runNameParam, actionNameParam, repetitionNameParam, 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).WorkflowRunActionRepetitionDefinition, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowRunActionScopeRepetitionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := w.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/actions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/scopeRepetitions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + runNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("runName")]) + if err != nil { + return nil, err + } + actionNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("actionName")]) + if err != nil { + return nil, err + } + resp := w.srv.NewListPager(resourceGroupNameParam, workflowNameParam, runNameParam, actionNameParam, nil) + newListPager = &resp + w.newListPager.add(req, newListPager) + } + resp, err := server.PagerResponderNext(newListPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + w.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + w.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/workflowrunoperations_server.go b/sdk/resourcemanager/logic/armlogic/fake/workflowrunoperations_server.go new file mode 100644 index 000000000000..b851c566f0ee --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/workflowrunoperations_server.go @@ -0,0 +1,108 @@ +//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/resourcemanager/logic/armlogic" + "net/http" + "net/url" + "regexp" +) + +// WorkflowRunOperationsServer is a fake server for instances of the armlogic.WorkflowRunOperationsClient type. +type WorkflowRunOperationsServer struct { + // Get is the fake for method WorkflowRunOperationsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, workflowName string, runName string, operationID string, options *armlogic.WorkflowRunOperationsClientGetOptions) (resp azfake.Responder[armlogic.WorkflowRunOperationsClientGetResponse], errResp azfake.ErrorResponder) +} + +// NewWorkflowRunOperationsServerTransport creates a new instance of WorkflowRunOperationsServerTransport with the provided implementation. +// The returned WorkflowRunOperationsServerTransport instance is connected to an instance of armlogic.WorkflowRunOperationsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkflowRunOperationsServerTransport(srv *WorkflowRunOperationsServer) *WorkflowRunOperationsServerTransport { + return &WorkflowRunOperationsServerTransport{srv: srv} +} + +// WorkflowRunOperationsServerTransport connects instances of armlogic.WorkflowRunOperationsClient to instances of WorkflowRunOperationsServer. +// Don't use this type directly, use NewWorkflowRunOperationsServerTransport instead. +type WorkflowRunOperationsServerTransport struct { + srv *WorkflowRunOperationsServer +} + +// Do implements the policy.Transporter interface for WorkflowRunOperationsServerTransport. +func (w *WorkflowRunOperationsServerTransport) 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 "WorkflowRunOperationsClient.Get": + resp, err = w.dispatchGet(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (w *WorkflowRunOperationsServerTransport) 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\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/operations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + runNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("runName")]) + if err != nil { + return nil, err + } + operationIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("operationId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, workflowNameParam, runNameParam, operationIDParam, 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).WorkflowRun, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/workflowruns_server.go b/sdk/resourcemanager/logic/armlogic/fake/workflowruns_server.go new file mode 100644 index 000000000000..b92bf253f6a3 --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/workflowruns_server.go @@ -0,0 +1,227 @@ +//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/logic/armlogic" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkflowRunsServer is a fake server for instances of the armlogic.WorkflowRunsClient type. +type WorkflowRunsServer struct { + // Cancel is the fake for method WorkflowRunsClient.Cancel + // HTTP status codes to indicate success: http.StatusOK + Cancel func(ctx context.Context, resourceGroupName string, workflowName string, runName string, options *armlogic.WorkflowRunsClientCancelOptions) (resp azfake.Responder[armlogic.WorkflowRunsClientCancelResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkflowRunsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, workflowName string, runName string, options *armlogic.WorkflowRunsClientGetOptions) (resp azfake.Responder[armlogic.WorkflowRunsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method WorkflowRunsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, workflowName string, options *armlogic.WorkflowRunsClientListOptions) (resp azfake.PagerResponder[armlogic.WorkflowRunsClientListResponse]) +} + +// NewWorkflowRunsServerTransport creates a new instance of WorkflowRunsServerTransport with the provided implementation. +// The returned WorkflowRunsServerTransport instance is connected to an instance of armlogic.WorkflowRunsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkflowRunsServerTransport(srv *WorkflowRunsServer) *WorkflowRunsServerTransport { + return &WorkflowRunsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.WorkflowRunsClientListResponse]](), + } +} + +// WorkflowRunsServerTransport connects instances of armlogic.WorkflowRunsClient to instances of WorkflowRunsServer. +// Don't use this type directly, use NewWorkflowRunsServerTransport instead. +type WorkflowRunsServerTransport struct { + srv *WorkflowRunsServer + newListPager *tracker[azfake.PagerResponder[armlogic.WorkflowRunsClientListResponse]] +} + +// Do implements the policy.Transporter interface for WorkflowRunsServerTransport. +func (w *WorkflowRunsServerTransport) 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 "WorkflowRunsClient.Cancel": + resp, err = w.dispatchCancel(req) + case "WorkflowRunsClient.Get": + resp, err = w.dispatchGet(req) + case "WorkflowRunsClient.NewListPager": + resp, err = w.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (w *WorkflowRunsServerTransport) dispatchCancel(req *http.Request) (*http.Response, error) { + if w.srv.Cancel == nil { + return nil, &nonRetriableError{errors.New("fake for method Cancel not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/cancel` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + runNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("runName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Cancel(req.Context(), resourceGroupNameParam, workflowNameParam, runNameParam, 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.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowRunsServerTransport) 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\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + runNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("runName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, workflowNameParam, runNameParam, 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).WorkflowRun, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowRunsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := w.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/runs` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlogic.WorkflowRunsClientListOptions + if topParam != nil || filterParam != nil { + options = &armlogic.WorkflowRunsClientListOptions{ + Top: topParam, + Filter: filterParam, + } + } + resp := w.srv.NewListPager(resourceGroupNameParam, workflowNameParam, options) + newListPager = &resp + w.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogic.WorkflowRunsClientListResponse, 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) { + w.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + w.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/workflows_server.go b/sdk/resourcemanager/logic/armlogic/fake/workflows_server.go new file mode 100644 index 000000000000..9ce914496460 --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/workflows_server.go @@ -0,0 +1,757 @@ +//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/logic/armlogic" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkflowsServer is a fake server for instances of the armlogic.WorkflowsClient type. +type WorkflowsServer struct { + // CreateOrUpdate is the fake for method WorkflowsClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + CreateOrUpdate func(ctx context.Context, resourceGroupName string, workflowName string, workflow armlogic.Workflow, options *armlogic.WorkflowsClientCreateOrUpdateOptions) (resp azfake.Responder[armlogic.WorkflowsClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method WorkflowsClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, workflowName string, options *armlogic.WorkflowsClientDeleteOptions) (resp azfake.Responder[armlogic.WorkflowsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Disable is the fake for method WorkflowsClient.Disable + // HTTP status codes to indicate success: http.StatusOK + Disable func(ctx context.Context, resourceGroupName string, workflowName string, options *armlogic.WorkflowsClientDisableOptions) (resp azfake.Responder[armlogic.WorkflowsClientDisableResponse], errResp azfake.ErrorResponder) + + // Enable is the fake for method WorkflowsClient.Enable + // HTTP status codes to indicate success: http.StatusOK + Enable func(ctx context.Context, resourceGroupName string, workflowName string, options *armlogic.WorkflowsClientEnableOptions) (resp azfake.Responder[armlogic.WorkflowsClientEnableResponse], errResp azfake.ErrorResponder) + + // GenerateUpgradedDefinition is the fake for method WorkflowsClient.GenerateUpgradedDefinition + // HTTP status codes to indicate success: http.StatusOK + GenerateUpgradedDefinition func(ctx context.Context, resourceGroupName string, workflowName string, parameters armlogic.GenerateUpgradedDefinitionParameters, options *armlogic.WorkflowsClientGenerateUpgradedDefinitionOptions) (resp azfake.Responder[armlogic.WorkflowsClientGenerateUpgradedDefinitionResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method WorkflowsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, workflowName string, options *armlogic.WorkflowsClientGetOptions) (resp azfake.Responder[armlogic.WorkflowsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method WorkflowsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armlogic.WorkflowsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armlogic.WorkflowsClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method WorkflowsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armlogic.WorkflowsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armlogic.WorkflowsClientListBySubscriptionResponse]) + + // ListCallbackURL is the fake for method WorkflowsClient.ListCallbackURL + // HTTP status codes to indicate success: http.StatusOK + ListCallbackURL func(ctx context.Context, resourceGroupName string, workflowName string, listCallbackURL armlogic.GetCallbackURLParameters, options *armlogic.WorkflowsClientListCallbackURLOptions) (resp azfake.Responder[armlogic.WorkflowsClientListCallbackURLResponse], errResp azfake.ErrorResponder) + + // ListSwagger is the fake for method WorkflowsClient.ListSwagger + // HTTP status codes to indicate success: http.StatusOK + ListSwagger func(ctx context.Context, resourceGroupName string, workflowName string, options *armlogic.WorkflowsClientListSwaggerOptions) (resp azfake.Responder[armlogic.WorkflowsClientListSwaggerResponse], errResp azfake.ErrorResponder) + + // BeginMove is the fake for method WorkflowsClient.BeginMove + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + BeginMove func(ctx context.Context, resourceGroupName string, workflowName string, move armlogic.WorkflowReference, options *armlogic.WorkflowsClientBeginMoveOptions) (resp azfake.PollerResponder[armlogic.WorkflowsClientMoveResponse], errResp azfake.ErrorResponder) + + // RegenerateAccessKey is the fake for method WorkflowsClient.RegenerateAccessKey + // HTTP status codes to indicate success: http.StatusOK + RegenerateAccessKey func(ctx context.Context, resourceGroupName string, workflowName string, keyType armlogic.RegenerateActionParameter, options *armlogic.WorkflowsClientRegenerateAccessKeyOptions) (resp azfake.Responder[armlogic.WorkflowsClientRegenerateAccessKeyResponse], errResp azfake.ErrorResponder) + + // Update is the fake for method WorkflowsClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, workflowName string, options *armlogic.WorkflowsClientUpdateOptions) (resp azfake.Responder[armlogic.WorkflowsClientUpdateResponse], errResp azfake.ErrorResponder) + + // ValidateByLocation is the fake for method WorkflowsClient.ValidateByLocation + // HTTP status codes to indicate success: http.StatusOK + ValidateByLocation func(ctx context.Context, resourceGroupName string, location string, workflowName string, validate armlogic.Workflow, options *armlogic.WorkflowsClientValidateByLocationOptions) (resp azfake.Responder[armlogic.WorkflowsClientValidateByLocationResponse], errResp azfake.ErrorResponder) + + // ValidateByResourceGroup is the fake for method WorkflowsClient.ValidateByResourceGroup + // HTTP status codes to indicate success: http.StatusOK + ValidateByResourceGroup func(ctx context.Context, resourceGroupName string, workflowName string, validate armlogic.Workflow, options *armlogic.WorkflowsClientValidateByResourceGroupOptions) (resp azfake.Responder[armlogic.WorkflowsClientValidateByResourceGroupResponse], errResp azfake.ErrorResponder) +} + +// NewWorkflowsServerTransport creates a new instance of WorkflowsServerTransport with the provided implementation. +// The returned WorkflowsServerTransport instance is connected to an instance of armlogic.WorkflowsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkflowsServerTransport(srv *WorkflowsServer) *WorkflowsServerTransport { + return &WorkflowsServerTransport{ + srv: srv, + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armlogic.WorkflowsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armlogic.WorkflowsClientListBySubscriptionResponse]](), + beginMove: newTracker[azfake.PollerResponder[armlogic.WorkflowsClientMoveResponse]](), + } +} + +// WorkflowsServerTransport connects instances of armlogic.WorkflowsClient to instances of WorkflowsServer. +// Don't use this type directly, use NewWorkflowsServerTransport instead. +type WorkflowsServerTransport struct { + srv *WorkflowsServer + newListByResourceGroupPager *tracker[azfake.PagerResponder[armlogic.WorkflowsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armlogic.WorkflowsClientListBySubscriptionResponse]] + beginMove *tracker[azfake.PollerResponder[armlogic.WorkflowsClientMoveResponse]] +} + +// Do implements the policy.Transporter interface for WorkflowsServerTransport. +func (w *WorkflowsServerTransport) 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 "WorkflowsClient.CreateOrUpdate": + resp, err = w.dispatchCreateOrUpdate(req) + case "WorkflowsClient.Delete": + resp, err = w.dispatchDelete(req) + case "WorkflowsClient.Disable": + resp, err = w.dispatchDisable(req) + case "WorkflowsClient.Enable": + resp, err = w.dispatchEnable(req) + case "WorkflowsClient.GenerateUpgradedDefinition": + resp, err = w.dispatchGenerateUpgradedDefinition(req) + case "WorkflowsClient.Get": + resp, err = w.dispatchGet(req) + case "WorkflowsClient.NewListByResourceGroupPager": + resp, err = w.dispatchNewListByResourceGroupPager(req) + case "WorkflowsClient.NewListBySubscriptionPager": + resp, err = w.dispatchNewListBySubscriptionPager(req) + case "WorkflowsClient.ListCallbackURL": + resp, err = w.dispatchListCallbackURL(req) + case "WorkflowsClient.ListSwagger": + resp, err = w.dispatchListSwagger(req) + case "WorkflowsClient.BeginMove": + resp, err = w.dispatchBeginMove(req) + case "WorkflowsClient.RegenerateAccessKey": + resp, err = w.dispatchRegenerateAccessKey(req) + case "WorkflowsClient.Update": + resp, err = w.dispatchUpdate(req) + case "WorkflowsClient.ValidateByLocation": + resp, err = w.dispatchValidateByLocation(req) + case "WorkflowsClient.ValidateByResourceGroup": + resp, err = w.dispatchValidateByResourceGroup(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (w *WorkflowsServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if w.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?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[armlogic.Workflow](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, workflowNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusCreated}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", respContent.HTTPStatus)} + } + resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).Workflow, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowsServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if w.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Delete(req.Context(), resourceGroupNameParam, workflowNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowsServerTransport) dispatchDisable(req *http.Request) (*http.Response, error) { + if w.srv.Disable == nil { + return nil, &nonRetriableError{errors.New("fake for method Disable not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/disable` + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Disable(req.Context(), resourceGroupNameParam, workflowNameParam, 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.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowsServerTransport) dispatchEnable(req *http.Request) (*http.Response, error) { + if w.srv.Enable == nil { + return nil, &nonRetriableError{errors.New("fake for method Enable not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/enable` + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Enable(req.Context(), resourceGroupNameParam, workflowNameParam, 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.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowsServerTransport) dispatchGenerateUpgradedDefinition(req *http.Request) (*http.Response, error) { + if w.srv.GenerateUpgradedDefinition == nil { + return nil, &nonRetriableError{errors.New("fake for method GenerateUpgradedDefinition not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/generateUpgradedDefinition` + 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[armlogic.GenerateUpgradedDefinitionParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GenerateUpgradedDefinition(req.Context(), resourceGroupNameParam, workflowNameParam, 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).Interface, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowsServerTransport) 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\.Logic/workflows/(?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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, workflowNameParam, 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).Workflow, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowsServerTransport) 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\.Logic/workflows` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlogic.WorkflowsClientListByResourceGroupOptions + if topParam != nil || filterParam != nil { + options = &armlogic.WorkflowsClientListByResourceGroupOptions{ + Top: topParam, + Filter: filterParam, + } + } + resp := w.srv.NewListByResourceGroupPager(resourceGroupNameParam, options) + newListByResourceGroupPager = &resp + w.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armlogic.WorkflowsClientListByResourceGroupResponse, 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 *WorkflowsServerTransport) 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\.Logic/workflows` + 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) + } + qp := req.URL.Query() + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlogic.WorkflowsClientListBySubscriptionOptions + if topParam != nil || filterParam != nil { + options = &armlogic.WorkflowsClientListBySubscriptionOptions{ + Top: topParam, + Filter: filterParam, + } + } + resp := w.srv.NewListBySubscriptionPager(options) + newListBySubscriptionPager = &resp + w.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armlogic.WorkflowsClientListBySubscriptionResponse, 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 *WorkflowsServerTransport) dispatchListCallbackURL(req *http.Request) (*http.Response, error) { + if w.srv.ListCallbackURL == nil { + return nil, &nonRetriableError{errors.New("fake for method ListCallbackURL not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listCallbackUrl` + 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[armlogic.GetCallbackURLParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.ListCallbackURL(req.Context(), resourceGroupNameParam, workflowNameParam, 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).WorkflowTriggerCallbackURL, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowsServerTransport) dispatchListSwagger(req *http.Request) (*http.Response, error) { + if w.srv.ListSwagger == nil { + return nil, &nonRetriableError{errors.New("fake for method ListSwagger not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listSwagger` + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.ListSwagger(req.Context(), resourceGroupNameParam, workflowNameParam, 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).Interface, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowsServerTransport) dispatchBeginMove(req *http.Request) (*http.Response, error) { + if w.srv.BeginMove == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginMove not implemented")} + } + beginMove := w.beginMove.get(req) + if beginMove == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/move` + 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[armlogic.WorkflowReference](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.BeginMove(req.Context(), resourceGroupNameParam, workflowNameParam, body, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginMove = &respr + w.beginMove.add(req, beginMove) + } + + resp, err := server.PollerResponderNext(beginMove, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusAccepted}, resp.StatusCode) { + w.beginMove.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", resp.StatusCode)} + } + if !server.PollerResponderMore(beginMove) { + w.beginMove.remove(req) + } + + return resp, nil +} + +func (w *WorkflowsServerTransport) dispatchRegenerateAccessKey(req *http.Request) (*http.Response, error) { + if w.srv.RegenerateAccessKey == nil { + return nil, &nonRetriableError{errors.New("fake for method RegenerateAccessKey not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/regenerateAccessKey` + 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[armlogic.RegenerateActionParameter](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.RegenerateAccessKey(req.Context(), resourceGroupNameParam, workflowNameParam, 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.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowsServerTransport) 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\.Logic/workflows/(?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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Update(req.Context(), resourceGroupNameParam, workflowNameParam, 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).Workflow, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowsServerTransport) dispatchValidateByLocation(req *http.Request) (*http.Response, error) { + if w.srv.ValidateByLocation == nil { + return nil, &nonRetriableError{errors.New("fake for method ValidateByLocation not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/locations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validate` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogic.Workflow](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + locationParam, err := url.PathUnescape(matches[regex.SubexpIndex("location")]) + if err != nil { + return nil, err + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.ValidateByLocation(req.Context(), resourceGroupNameParam, locationParam, workflowNameParam, 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.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowsServerTransport) dispatchValidateByResourceGroup(req *http.Request) (*http.Response, error) { + if w.srv.ValidateByResourceGroup == nil { + return nil, &nonRetriableError{errors.New("fake for method ValidateByResourceGroup not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/validate` + 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[armlogic.Workflow](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.ValidateByResourceGroup(req.Context(), resourceGroupNameParam, workflowNameParam, 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.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/workflowtriggerhistories_server.go b/sdk/resourcemanager/logic/armlogic/fake/workflowtriggerhistories_server.go new file mode 100644 index 000000000000..2cf33463a267 --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/workflowtriggerhistories_server.go @@ -0,0 +1,239 @@ +//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/logic/armlogic" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkflowTriggerHistoriesServer is a fake server for instances of the armlogic.WorkflowTriggerHistoriesClient type. +type WorkflowTriggerHistoriesServer struct { + // Get is the fake for method WorkflowTriggerHistoriesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, workflowName string, triggerName string, historyName string, options *armlogic.WorkflowTriggerHistoriesClientGetOptions) (resp azfake.Responder[armlogic.WorkflowTriggerHistoriesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method WorkflowTriggerHistoriesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, workflowName string, triggerName string, options *armlogic.WorkflowTriggerHistoriesClientListOptions) (resp azfake.PagerResponder[armlogic.WorkflowTriggerHistoriesClientListResponse]) + + // Resubmit is the fake for method WorkflowTriggerHistoriesClient.Resubmit + // HTTP status codes to indicate success: http.StatusAccepted + Resubmit func(ctx context.Context, resourceGroupName string, workflowName string, triggerName string, historyName string, options *armlogic.WorkflowTriggerHistoriesClientResubmitOptions) (resp azfake.Responder[armlogic.WorkflowTriggerHistoriesClientResubmitResponse], errResp azfake.ErrorResponder) +} + +// NewWorkflowTriggerHistoriesServerTransport creates a new instance of WorkflowTriggerHistoriesServerTransport with the provided implementation. +// The returned WorkflowTriggerHistoriesServerTransport instance is connected to an instance of armlogic.WorkflowTriggerHistoriesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkflowTriggerHistoriesServerTransport(srv *WorkflowTriggerHistoriesServer) *WorkflowTriggerHistoriesServerTransport { + return &WorkflowTriggerHistoriesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.WorkflowTriggerHistoriesClientListResponse]](), + } +} + +// WorkflowTriggerHistoriesServerTransport connects instances of armlogic.WorkflowTriggerHistoriesClient to instances of WorkflowTriggerHistoriesServer. +// Don't use this type directly, use NewWorkflowTriggerHistoriesServerTransport instead. +type WorkflowTriggerHistoriesServerTransport struct { + srv *WorkflowTriggerHistoriesServer + newListPager *tracker[azfake.PagerResponder[armlogic.WorkflowTriggerHistoriesClientListResponse]] +} + +// Do implements the policy.Transporter interface for WorkflowTriggerHistoriesServerTransport. +func (w *WorkflowTriggerHistoriesServerTransport) 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 "WorkflowTriggerHistoriesClient.Get": + resp, err = w.dispatchGet(req) + case "WorkflowTriggerHistoriesClient.NewListPager": + resp, err = w.dispatchNewListPager(req) + case "WorkflowTriggerHistoriesClient.Resubmit": + resp, err = w.dispatchResubmit(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (w *WorkflowTriggerHistoriesServerTransport) 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\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/triggers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/histories/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + triggerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("triggerName")]) + if err != nil { + return nil, err + } + historyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("historyName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, workflowNameParam, triggerNameParam, historyNameParam, 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).WorkflowTriggerHistory, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowTriggerHistoriesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := w.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/triggers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/histories` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + triggerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("triggerName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlogic.WorkflowTriggerHistoriesClientListOptions + if topParam != nil || filterParam != nil { + options = &armlogic.WorkflowTriggerHistoriesClientListOptions{ + Top: topParam, + Filter: filterParam, + } + } + resp := w.srv.NewListPager(resourceGroupNameParam, workflowNameParam, triggerNameParam, options) + newListPager = &resp + w.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogic.WorkflowTriggerHistoriesClientListResponse, 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) { + w.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + w.newListPager.remove(req) + } + return resp, nil +} + +func (w *WorkflowTriggerHistoriesServerTransport) dispatchResubmit(req *http.Request) (*http.Response, error) { + if w.srv.Resubmit == nil { + return nil, &nonRetriableError{errors.New("fake for method Resubmit not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/triggers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/histories/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resubmit` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + triggerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("triggerName")]) + if err != nil { + return nil, err + } + historyNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("historyName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Resubmit(req.Context(), resourceGroupNameParam, workflowNameParam, triggerNameParam, historyNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusAccepted}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusAccepted", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/workflowtriggers_server.go b/sdk/resourcemanager/logic/armlogic/fake/workflowtriggers_server.go new file mode 100644 index 000000000000..a692c95b4a1d --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/workflowtriggers_server.go @@ -0,0 +1,403 @@ +//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/logic/armlogic" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkflowTriggersServer is a fake server for instances of the armlogic.WorkflowTriggersClient type. +type WorkflowTriggersServer struct { + // Get is the fake for method WorkflowTriggersClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, workflowName string, triggerName string, options *armlogic.WorkflowTriggersClientGetOptions) (resp azfake.Responder[armlogic.WorkflowTriggersClientGetResponse], errResp azfake.ErrorResponder) + + // GetSchemaJSON is the fake for method WorkflowTriggersClient.GetSchemaJSON + // HTTP status codes to indicate success: http.StatusOK + GetSchemaJSON func(ctx context.Context, resourceGroupName string, workflowName string, triggerName string, options *armlogic.WorkflowTriggersClientGetSchemaJSONOptions) (resp azfake.Responder[armlogic.WorkflowTriggersClientGetSchemaJSONResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method WorkflowTriggersClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, workflowName string, options *armlogic.WorkflowTriggersClientListOptions) (resp azfake.PagerResponder[armlogic.WorkflowTriggersClientListResponse]) + + // ListCallbackURL is the fake for method WorkflowTriggersClient.ListCallbackURL + // HTTP status codes to indicate success: http.StatusOK + ListCallbackURL func(ctx context.Context, resourceGroupName string, workflowName string, triggerName string, options *armlogic.WorkflowTriggersClientListCallbackURLOptions) (resp azfake.Responder[armlogic.WorkflowTriggersClientListCallbackURLResponse], errResp azfake.ErrorResponder) + + // Reset is the fake for method WorkflowTriggersClient.Reset + // HTTP status codes to indicate success: http.StatusOK + Reset func(ctx context.Context, resourceGroupName string, workflowName string, triggerName string, options *armlogic.WorkflowTriggersClientResetOptions) (resp azfake.Responder[armlogic.WorkflowTriggersClientResetResponse], errResp azfake.ErrorResponder) + + // Run is the fake for method WorkflowTriggersClient.Run + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted + Run func(ctx context.Context, resourceGroupName string, workflowName string, triggerName string, options *armlogic.WorkflowTriggersClientRunOptions) (resp azfake.Responder[armlogic.WorkflowTriggersClientRunResponse], errResp azfake.ErrorResponder) + + // SetState is the fake for method WorkflowTriggersClient.SetState + // HTTP status codes to indicate success: http.StatusOK + SetState func(ctx context.Context, resourceGroupName string, workflowName string, triggerName string, setState armlogic.SetTriggerStateActionDefinition, options *armlogic.WorkflowTriggersClientSetStateOptions) (resp azfake.Responder[armlogic.WorkflowTriggersClientSetStateResponse], errResp azfake.ErrorResponder) +} + +// NewWorkflowTriggersServerTransport creates a new instance of WorkflowTriggersServerTransport with the provided implementation. +// The returned WorkflowTriggersServerTransport instance is connected to an instance of armlogic.WorkflowTriggersClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkflowTriggersServerTransport(srv *WorkflowTriggersServer) *WorkflowTriggersServerTransport { + return &WorkflowTriggersServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.WorkflowTriggersClientListResponse]](), + } +} + +// WorkflowTriggersServerTransport connects instances of armlogic.WorkflowTriggersClient to instances of WorkflowTriggersServer. +// Don't use this type directly, use NewWorkflowTriggersServerTransport instead. +type WorkflowTriggersServerTransport struct { + srv *WorkflowTriggersServer + newListPager *tracker[azfake.PagerResponder[armlogic.WorkflowTriggersClientListResponse]] +} + +// Do implements the policy.Transporter interface for WorkflowTriggersServerTransport. +func (w *WorkflowTriggersServerTransport) 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 "WorkflowTriggersClient.Get": + resp, err = w.dispatchGet(req) + case "WorkflowTriggersClient.GetSchemaJSON": + resp, err = w.dispatchGetSchemaJSON(req) + case "WorkflowTriggersClient.NewListPager": + resp, err = w.dispatchNewListPager(req) + case "WorkflowTriggersClient.ListCallbackURL": + resp, err = w.dispatchListCallbackURL(req) + case "WorkflowTriggersClient.Reset": + resp, err = w.dispatchReset(req) + case "WorkflowTriggersClient.Run": + resp, err = w.dispatchRun(req) + case "WorkflowTriggersClient.SetState": + resp, err = w.dispatchSetState(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (w *WorkflowTriggersServerTransport) 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\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/triggers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + triggerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("triggerName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, workflowNameParam, triggerNameParam, 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).WorkflowTrigger, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowTriggersServerTransport) dispatchGetSchemaJSON(req *http.Request) (*http.Response, error) { + if w.srv.GetSchemaJSON == nil { + return nil, &nonRetriableError{errors.New("fake for method GetSchemaJSON not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/triggers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/schemas/json` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + triggerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("triggerName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.GetSchemaJSON(req.Context(), resourceGroupNameParam, workflowNameParam, triggerNameParam, 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).JSONSchema, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowTriggersServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := w.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/triggers` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + filterUnescaped, err := url.QueryUnescape(qp.Get("$filter")) + if err != nil { + return nil, err + } + filterParam := getOptional(filterUnescaped) + var options *armlogic.WorkflowTriggersClientListOptions + if topParam != nil || filterParam != nil { + options = &armlogic.WorkflowTriggersClientListOptions{ + Top: topParam, + Filter: filterParam, + } + } + resp := w.srv.NewListPager(resourceGroupNameParam, workflowNameParam, options) + newListPager = &resp + w.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogic.WorkflowTriggersClientListResponse, 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) { + w.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + w.newListPager.remove(req) + } + return resp, nil +} + +func (w *WorkflowTriggersServerTransport) dispatchListCallbackURL(req *http.Request) (*http.Response, error) { + if w.srv.ListCallbackURL == nil { + return nil, &nonRetriableError{errors.New("fake for method ListCallbackURL not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/triggers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listCallbackUrl` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + triggerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("triggerName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.ListCallbackURL(req.Context(), resourceGroupNameParam, workflowNameParam, triggerNameParam, 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).WorkflowTriggerCallbackURL, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowTriggersServerTransport) dispatchReset(req *http.Request) (*http.Response, error) { + if w.srv.Reset == nil { + return nil, &nonRetriableError{errors.New("fake for method Reset not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/triggers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/reset` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + triggerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("triggerName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Reset(req.Context(), resourceGroupNameParam, workflowNameParam, triggerNameParam, 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.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowTriggersServerTransport) dispatchRun(req *http.Request) (*http.Response, error) { + if w.srv.Run == nil { + return nil, &nonRetriableError{errors.New("fake for method Run not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/triggers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/run` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + triggerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("triggerName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Run(req.Context(), resourceGroupNameParam, workflowNameParam, triggerNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusAccepted}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowTriggersServerTransport) dispatchSetState(req *http.Request) (*http.Response, error) { + if w.srv.SetState == nil { + return nil, &nonRetriableError{errors.New("fake for method SetState not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/triggers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/setState` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogic.SetTriggerStateActionDefinition](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + triggerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("triggerName")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.SetState(req.Context(), resourceGroupNameParam, workflowNameParam, triggerNameParam, 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.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/workflowversions_server.go b/sdk/resourcemanager/logic/armlogic/fake/workflowversions_server.go new file mode 100644 index 000000000000..78f6495685ec --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/workflowversions_server.go @@ -0,0 +1,178 @@ +//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/logic/armlogic" + "net/http" + "net/url" + "regexp" + "strconv" +) + +// WorkflowVersionsServer is a fake server for instances of the armlogic.WorkflowVersionsClient type. +type WorkflowVersionsServer struct { + // Get is the fake for method WorkflowVersionsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, workflowName string, versionID string, options *armlogic.WorkflowVersionsClientGetOptions) (resp azfake.Responder[armlogic.WorkflowVersionsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method WorkflowVersionsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, workflowName string, options *armlogic.WorkflowVersionsClientListOptions) (resp azfake.PagerResponder[armlogic.WorkflowVersionsClientListResponse]) +} + +// NewWorkflowVersionsServerTransport creates a new instance of WorkflowVersionsServerTransport with the provided implementation. +// The returned WorkflowVersionsServerTransport instance is connected to an instance of armlogic.WorkflowVersionsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkflowVersionsServerTransport(srv *WorkflowVersionsServer) *WorkflowVersionsServerTransport { + return &WorkflowVersionsServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogic.WorkflowVersionsClientListResponse]](), + } +} + +// WorkflowVersionsServerTransport connects instances of armlogic.WorkflowVersionsClient to instances of WorkflowVersionsServer. +// Don't use this type directly, use NewWorkflowVersionsServerTransport instead. +type WorkflowVersionsServerTransport struct { + srv *WorkflowVersionsServer + newListPager *tracker[azfake.PagerResponder[armlogic.WorkflowVersionsClientListResponse]] +} + +// Do implements the policy.Transporter interface for WorkflowVersionsServerTransport. +func (w *WorkflowVersionsServerTransport) 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 "WorkflowVersionsClient.Get": + resp, err = w.dispatchGet(req) + case "WorkflowVersionsClient.NewListPager": + resp, err = w.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (w *WorkflowVersionsServerTransport) 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\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + versionIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("versionId")]) + if err != nil { + return nil, err + } + respr, errRespr := w.srv.Get(req.Context(), resourceGroupNameParam, workflowNameParam, versionIDParam, 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).WorkflowVersion, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (w *WorkflowVersionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if w.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := w.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` + 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) + } + qp := req.URL.Query() + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + topUnescaped, err := url.QueryUnescape(qp.Get("$top")) + if err != nil { + return nil, err + } + topParam, err := parseOptional(topUnescaped, func(v string) (int32, error) { + p, parseErr := strconv.ParseInt(v, 10, 32) + if parseErr != nil { + return 0, parseErr + } + return int32(p), nil + }) + if err != nil { + return nil, err + } + var options *armlogic.WorkflowVersionsClientListOptions + if topParam != nil { + options = &armlogic.WorkflowVersionsClientListOptions{ + Top: topParam, + } + } + resp := w.srv.NewListPager(resourceGroupNameParam, workflowNameParam, options) + newListPager = &resp + w.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogic.WorkflowVersionsClientListResponse, 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) { + w.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + w.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/fake/workflowversiontriggers_server.go b/sdk/resourcemanager/logic/armlogic/fake/workflowversiontriggers_server.go new file mode 100644 index 000000000000..01f8be707988 --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/fake/workflowversiontriggers_server.go @@ -0,0 +1,119 @@ +//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/resourcemanager/logic/armlogic" + "net/http" + "net/url" + "reflect" + "regexp" +) + +// WorkflowVersionTriggersServer is a fake server for instances of the armlogic.WorkflowVersionTriggersClient type. +type WorkflowVersionTriggersServer struct { + // ListCallbackURL is the fake for method WorkflowVersionTriggersClient.ListCallbackURL + // HTTP status codes to indicate success: http.StatusOK + ListCallbackURL func(ctx context.Context, resourceGroupName string, workflowName string, versionID string, triggerName string, options *armlogic.WorkflowVersionTriggersClientListCallbackURLOptions) (resp azfake.Responder[armlogic.WorkflowVersionTriggersClientListCallbackURLResponse], errResp azfake.ErrorResponder) +} + +// NewWorkflowVersionTriggersServerTransport creates a new instance of WorkflowVersionTriggersServerTransport with the provided implementation. +// The returned WorkflowVersionTriggersServerTransport instance is connected to an instance of armlogic.WorkflowVersionTriggersClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewWorkflowVersionTriggersServerTransport(srv *WorkflowVersionTriggersServer) *WorkflowVersionTriggersServerTransport { + return &WorkflowVersionTriggersServerTransport{srv: srv} +} + +// WorkflowVersionTriggersServerTransport connects instances of armlogic.WorkflowVersionTriggersClient to instances of WorkflowVersionTriggersServer. +// Don't use this type directly, use NewWorkflowVersionTriggersServerTransport instead. +type WorkflowVersionTriggersServerTransport struct { + srv *WorkflowVersionTriggersServer +} + +// Do implements the policy.Transporter interface for WorkflowVersionTriggersServerTransport. +func (w *WorkflowVersionTriggersServerTransport) 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 "WorkflowVersionTriggersClient.ListCallbackURL": + resp, err = w.dispatchListCallbackURL(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (w *WorkflowVersionTriggersServerTransport) dispatchListCallbackURL(req *http.Request) (*http.Response, error) { + if w.srv.ListCallbackURL == nil { + return nil, &nonRetriableError{errors.New("fake for method ListCallbackURL not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logic/workflows/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/triggers/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listCallbackUrl` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogic.GetCallbackURLParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + workflowNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("workflowName")]) + if err != nil { + return nil, err + } + versionIDParam, err := url.PathUnescape(matches[regex.SubexpIndex("versionId")]) + if err != nil { + return nil, err + } + triggerNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("triggerName")]) + if err != nil { + return nil, err + } + var options *armlogic.WorkflowVersionTriggersClientListCallbackURLOptions + if !reflect.ValueOf(body).IsZero() { + options = &armlogic.WorkflowVersionTriggersClientListCallbackURLOptions{ + Parameters: &body, + } + } + respr, errRespr := w.srv.ListCallbackURL(req.Context(), resourceGroupNameParam, workflowNameParam, versionIDParam, triggerNameParam, options) + 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).WorkflowTriggerCallbackURL, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/logic/armlogic/go.mod b/sdk/resourcemanager/logic/armlogic/go.mod index 550fa148386a..a0c8dbc5264e 100644 --- a/sdk/resourcemanager/logic/armlogic/go.mod +++ b/sdk/resourcemanager/logic/armlogic/go.mod @@ -3,27 +3,27 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/logic/armlogic go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 - github.com/stretchr/testify v1.7.0 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 + github.com/stretchr/testify v1.8.4 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect - github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dnaeon/go-vcr v1.1.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/dnaeon/go-vcr v1.2.0 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 // indirect + github.com/google/uuid v1.3.1 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - golang.org/x/crypto v0.6.0 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/sdk/resourcemanager/logic/armlogic/go.sum b/sdk/resourcemanager/logic/armlogic/go.sum index 6e2c77825a2c..88bb72abf2ba 100644 --- a/sdk/resourcemanager/logic/armlogic/go.sum +++ b/sdk/resourcemanager/logic/armlogic/go.sum @@ -1,24 +1,25 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2 h1:mLY+pNLjCUeKhgnAJWAKhEUQM+RJQo2H1fuGSw1Ky1E= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal v1.1.2/go.mod h1:FbdwsQ2EzwvXxOPcMFYO8ogEc9uMMIj3YkmCdXdAFmk= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0 h1:ECsQtyERDVz3NP3kvDOTLvbQhqWp/x9EsGKtb4ogUr8= -github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.0.0/go.mod h1:s1tW/At+xHqjNFvWU4G0c0Qv33KOhvbGNj0RCTQDV8s= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0 h1:PTFGRSlMKCQelWwxUyYVEUqseBJVemLyqWJjvMyt0do= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2 v2.0.0/go.mod h1:LRr2FzBTQlONPPa5HREE5+RjSCTXl7BwOvYOaWTqCaI= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/managementgroups/armmanagementgroups v1.0.0 h1:pPvTJ1dY0sA35JOeFq6TsY2xj6Z85Yo23Pj4wCCvu4o= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1 h1:7CBQ+Ei8SP2c6ydQTGCCrS35bDxgTMfoP2miAwK++OU= +github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resources/armresources v1.1.1/go.mod h1:c/wcGeGx5FUPbM/JltUYHZcKmigwyVLJlDq+4HdtXaw= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/dnaeon/go-vcr v1.1.0/go.mod h1:M7tiix8f0r6mKKJ3Yq/kqU1OYf3MnfmBWVbPx/yU9ko= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= +github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= +github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= +github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/modocache/gover v0.0.0-20171022184752-b58185e213c5/go.mod h1:caMODM3PzxT8aQXRPkAt8xlV/e7d7w8GM5g0fa5F0D8= @@ -26,23 +27,21 @@ github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9 github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +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/logic/armlogic/integrationaccountagreements_client.go b/sdk/resourcemanager/logic/armlogic/integrationaccountagreements_client.go index 7b6f3cf22dd5..4300c7864e01 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccountagreements_client.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccountagreements_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -34,7 +33,7 @@ type IntegrationAccountAgreementsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationAccountAgreementsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationAccountAgreementsClient, error) { - cl, err := arm.NewClient(moduleName+".IntegrationAccountAgreementsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -56,18 +55,25 @@ func NewIntegrationAccountAgreementsClient(subscriptionID string, credential azc // - options - IntegrationAccountAgreementsClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountAgreementsClient.CreateOrUpdate // method. func (client *IntegrationAccountAgreementsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, integrationAccountName string, agreementName string, agreement IntegrationAccountAgreement, options *IntegrationAccountAgreementsClientCreateOrUpdateOptions) (IntegrationAccountAgreementsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "IntegrationAccountAgreementsClient.CreateOrUpdate" + 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, integrationAccountName, agreementName, agreement, options) if err != nil { return IntegrationAccountAgreementsClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountAgreementsClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return IntegrationAccountAgreementsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountAgreementsClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -97,7 +103,10 @@ func (client *IntegrationAccountAgreementsClient) createOrUpdateCreateRequest(ct reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, agreement) + if err := runtime.MarshalAsJSON(req, agreement); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -119,16 +128,22 @@ func (client *IntegrationAccountAgreementsClient) createOrUpdateHandleResponse(r // - options - IntegrationAccountAgreementsClientDeleteOptions contains the optional parameters for the IntegrationAccountAgreementsClient.Delete // method. func (client *IntegrationAccountAgreementsClient) Delete(ctx context.Context, resourceGroupName string, integrationAccountName string, agreementName string, options *IntegrationAccountAgreementsClientDeleteOptions) (IntegrationAccountAgreementsClientDeleteResponse, error) { + var err error + const operationName = "IntegrationAccountAgreementsClient.Delete" + 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, integrationAccountName, agreementName, options) if err != nil { return IntegrationAccountAgreementsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountAgreementsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return IntegrationAccountAgreementsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountAgreementsClientDeleteResponse{}, err } return IntegrationAccountAgreementsClientDeleteResponse{}, nil } @@ -173,18 +188,25 @@ func (client *IntegrationAccountAgreementsClient) deleteCreateRequest(ctx contex // - options - IntegrationAccountAgreementsClientGetOptions contains the optional parameters for the IntegrationAccountAgreementsClient.Get // method. func (client *IntegrationAccountAgreementsClient) Get(ctx context.Context, resourceGroupName string, integrationAccountName string, agreementName string, options *IntegrationAccountAgreementsClientGetOptions) (IntegrationAccountAgreementsClientGetResponse, error) { + var err error + const operationName = "IntegrationAccountAgreementsClient.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, integrationAccountName, agreementName, options) if err != nil { return IntegrationAccountAgreementsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountAgreementsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountAgreementsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountAgreementsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -239,25 +261,20 @@ func (client *IntegrationAccountAgreementsClient) NewListPager(resourceGroupName return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *IntegrationAccountAgreementsClientListResponse) (IntegrationAccountAgreementsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, integrationAccountName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return IntegrationAccountAgreementsClientListResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IntegrationAccountAgreementsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, integrationAccountName, options) + }, nil) if err != nil { return IntegrationAccountAgreementsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountAgreementsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -312,18 +329,25 @@ func (client *IntegrationAccountAgreementsClient) listHandleResponse(resp *http. // - options - IntegrationAccountAgreementsClientListContentCallbackURLOptions contains the optional parameters for the IntegrationAccountAgreementsClient.ListContentCallbackURL // method. func (client *IntegrationAccountAgreementsClient) ListContentCallbackURL(ctx context.Context, resourceGroupName string, integrationAccountName string, agreementName string, listContentCallbackURL GetCallbackURLParameters, options *IntegrationAccountAgreementsClientListContentCallbackURLOptions) (IntegrationAccountAgreementsClientListContentCallbackURLResponse, error) { + var err error + const operationName = "IntegrationAccountAgreementsClient.ListContentCallbackURL" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listContentCallbackURLCreateRequest(ctx, resourceGroupName, integrationAccountName, agreementName, listContentCallbackURL, options) if err != nil { return IntegrationAccountAgreementsClientListContentCallbackURLResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountAgreementsClientListContentCallbackURLResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountAgreementsClientListContentCallbackURLResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountAgreementsClientListContentCallbackURLResponse{}, err } - return client.listContentCallbackURLHandleResponse(resp) + resp, err := client.listContentCallbackURLHandleResponse(httpResp) + return resp, err } // listContentCallbackURLCreateRequest creates the ListContentCallbackURL request. @@ -353,7 +377,10 @@ func (client *IntegrationAccountAgreementsClient) listContentCallbackURLCreateRe reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, listContentCallbackURL) + if err := runtime.MarshalAsJSON(req, listContentCallbackURL); err != nil { + return nil, err + } + return req, nil } // listContentCallbackURLHandleResponse handles the ListContentCallbackURL response. diff --git a/sdk/resourcemanager/logic/armlogic/integrationaccountagreements_client_example_test.go b/sdk/resourcemanager/logic/armlogic/integrationaccountagreements_client_example_test.go index 5165c1d92471..83705ba6f29f 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccountagreements_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccountagreements_client_example_test.go @@ -52,7 +52,7 @@ func ExampleIntegrationAccountAgreementsClient_NewListPager() { // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts//agreements/"), // Properties: &armlogic.IntegrationAccountAgreementProperties{ // AgreementType: to.Ptr(armlogic.AgreementTypeX12), - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:00:54.1520445Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:00:54.152Z"); return t}()), // Content: &armlogic.AgreementContent{ // X12: &armlogic.X12AgreementContent{ // ReceiveAgreement: &armlogic.X12OneWayAgreement{ @@ -232,7 +232,7 @@ func ExampleIntegrationAccountAgreementsClient_NewListPager() { // }, // }, // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:00:54.1516558Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:00:54.151Z"); return t}()), // GuestIdentity: &armlogic.BusinessIdentity{ // Qualifier: to.Ptr("AA"), // Value: to.Ptr("AA"), @@ -253,7 +253,7 @@ func ExampleIntegrationAccountAgreementsClient_NewListPager() { // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts//agreements/"), // Properties: &armlogic.IntegrationAccountAgreementProperties{ // AgreementType: to.Ptr(armlogic.AgreementTypeAS2), - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:00:53.4140804Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:00:53.414Z"); return t}()), // Content: &armlogic.AgreementContent{ // AS2: &armlogic.AS2AgreementContent{ // ReceiveAgreement: &armlogic.AS2OneWayAgreement{ @@ -390,7 +390,7 @@ func ExampleIntegrationAccountAgreementsClient_NewListPager() { // }, // }, // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:00:53.4134038Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:00:53.413Z"); return t}()), // GuestIdentity: &armlogic.BusinessIdentity{ // Qualifier: to.Ptr("AA"), // Value: to.Ptr("AA"), @@ -411,7 +411,7 @@ func ExampleIntegrationAccountAgreementsClient_NewListPager() { // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts//agreements/"), // Properties: &armlogic.IntegrationAccountAgreementProperties{ // AgreementType: to.Ptr(armlogic.AgreementTypeEdifact), - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:00:53.8212345Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:00:53.821Z"); return t}()), // Content: &armlogic.AgreementContent{ // Edifact: &armlogic.EdifactAgreementContent{ // ReceiveAgreement: &armlogic.EdifactOneWayAgreement{ @@ -620,7 +620,7 @@ func ExampleIntegrationAccountAgreementsClient_NewListPager() { // }, // }, // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:00:53.8205121Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:00:53.820Z"); return t}()), // GuestIdentity: &armlogic.BusinessIdentity{ // Qualifier: to.Ptr("AA"), // Value: to.Ptr("AA"), @@ -663,7 +663,7 @@ func ExampleIntegrationAccountAgreementsClient_Get() { // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts//agreements/"), // Properties: &armlogic.IntegrationAccountAgreementProperties{ // AgreementType: to.Ptr(armlogic.AgreementTypeAS2), - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:32:54.2945291Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:32:54.294Z"); return t}()), // Content: &armlogic.AgreementContent{ // AS2: &armlogic.AS2AgreementContent{ // ReceiveAgreement: &armlogic.AS2OneWayAgreement{ @@ -800,7 +800,7 @@ func ExampleIntegrationAccountAgreementsClient_Get() { // }, // }, // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:32:54.2938748Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:32:54.293Z"); return t}()), // GuestIdentity: &armlogic.BusinessIdentity{ // Qualifier: to.Ptr("AA"), // Value: to.Ptr("AA"), @@ -996,7 +996,7 @@ func ExampleIntegrationAccountAgreementsClient_CreateOrUpdate() { // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts/IntegrationAccount4533/agreements/"), // Properties: &armlogic.IntegrationAccountAgreementProperties{ // AgreementType: to.Ptr(armlogic.AgreementTypeAS2), - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:32:54.2945291Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:32:54.294Z"); return t}()), // Content: &armlogic.AgreementContent{ // AS2: &armlogic.AS2AgreementContent{ // ReceiveAgreement: &armlogic.AS2OneWayAgreement{ @@ -1133,7 +1133,7 @@ func ExampleIntegrationAccountAgreementsClient_CreateOrUpdate() { // }, // }, // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:32:54.2938748Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T22:32:54.293Z"); return t}()), // GuestIdentity: &armlogic.BusinessIdentity{ // Qualifier: to.Ptr("AA"), // Value: to.Ptr("AA"), @@ -1180,7 +1180,7 @@ func ExampleIntegrationAccountAgreementsClient_ListContentCallbackURL() { } res, err := clientFactory.NewIntegrationAccountAgreementsClient().ListContentCallbackURL(ctx, "testResourceGroup", "testIntegrationAccount", "testAgreement", armlogic.GetCallbackURLParameters{ KeyType: to.Ptr(armlogic.KeyTypePrimary), - NotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-19T16:00:00Z"); return t }()), + NotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-19T16:00:00.000Z"); return t }()), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) diff --git a/sdk/resourcemanager/logic/armlogic/integrationaccountassemblies_client.go b/sdk/resourcemanager/logic/armlogic/integrationaccountassemblies_client.go index ab084301eb24..20a398f4d2cf 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccountassemblies_client.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccountassemblies_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -33,7 +32,7 @@ type IntegrationAccountAssembliesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationAccountAssembliesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationAccountAssembliesClient, error) { - cl, err := arm.NewClient(moduleName+".IntegrationAccountAssembliesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,18 +54,25 @@ func NewIntegrationAccountAssembliesClient(subscriptionID string, credential azc // - options - IntegrationAccountAssembliesClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountAssembliesClient.CreateOrUpdate // method. func (client *IntegrationAccountAssembliesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, integrationAccountName string, assemblyArtifactName string, assemblyArtifact AssemblyDefinition, options *IntegrationAccountAssembliesClientCreateOrUpdateOptions) (IntegrationAccountAssembliesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "IntegrationAccountAssembliesClient.CreateOrUpdate" + 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, integrationAccountName, assemblyArtifactName, assemblyArtifact, options) if err != nil { return IntegrationAccountAssembliesClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountAssembliesClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return IntegrationAccountAssembliesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountAssembliesClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -96,7 +102,10 @@ func (client *IntegrationAccountAssembliesClient) createOrUpdateCreateRequest(ct reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, assemblyArtifact) + if err := runtime.MarshalAsJSON(req, assemblyArtifact); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -118,16 +127,22 @@ func (client *IntegrationAccountAssembliesClient) createOrUpdateHandleResponse(r // - options - IntegrationAccountAssembliesClientDeleteOptions contains the optional parameters for the IntegrationAccountAssembliesClient.Delete // method. func (client *IntegrationAccountAssembliesClient) Delete(ctx context.Context, resourceGroupName string, integrationAccountName string, assemblyArtifactName string, options *IntegrationAccountAssembliesClientDeleteOptions) (IntegrationAccountAssembliesClientDeleteResponse, error) { + var err error + const operationName = "IntegrationAccountAssembliesClient.Delete" + 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, integrationAccountName, assemblyArtifactName, options) if err != nil { return IntegrationAccountAssembliesClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountAssembliesClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return IntegrationAccountAssembliesClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountAssembliesClientDeleteResponse{}, err } return IntegrationAccountAssembliesClientDeleteResponse{}, nil } @@ -172,18 +187,25 @@ func (client *IntegrationAccountAssembliesClient) deleteCreateRequest(ctx contex // - options - IntegrationAccountAssembliesClientGetOptions contains the optional parameters for the IntegrationAccountAssembliesClient.Get // method. func (client *IntegrationAccountAssembliesClient) Get(ctx context.Context, resourceGroupName string, integrationAccountName string, assemblyArtifactName string, options *IntegrationAccountAssembliesClientGetOptions) (IntegrationAccountAssembliesClientGetResponse, error) { + var err error + const operationName = "IntegrationAccountAssembliesClient.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, integrationAccountName, assemblyArtifactName, options) if err != nil { return IntegrationAccountAssembliesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountAssembliesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountAssembliesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountAssembliesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -238,6 +260,7 @@ func (client *IntegrationAccountAssembliesClient) NewListPager(resourceGroupName return false }, Fetcher: func(ctx context.Context, page *IntegrationAccountAssembliesClientListResponse) (IntegrationAccountAssembliesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IntegrationAccountAssembliesClient.NewListPager") req, err := client.listCreateRequest(ctx, resourceGroupName, integrationAccountName, options) if err != nil { return IntegrationAccountAssembliesClientListResponse{}, err @@ -251,6 +274,7 @@ func (client *IntegrationAccountAssembliesClient) NewListPager(resourceGroupName } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -299,18 +323,25 @@ func (client *IntegrationAccountAssembliesClient) listHandleResponse(resp *http. // - options - IntegrationAccountAssembliesClientListContentCallbackURLOptions contains the optional parameters for the IntegrationAccountAssembliesClient.ListContentCallbackURL // method. func (client *IntegrationAccountAssembliesClient) ListContentCallbackURL(ctx context.Context, resourceGroupName string, integrationAccountName string, assemblyArtifactName string, options *IntegrationAccountAssembliesClientListContentCallbackURLOptions) (IntegrationAccountAssembliesClientListContentCallbackURLResponse, error) { + var err error + const operationName = "IntegrationAccountAssembliesClient.ListContentCallbackURL" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listContentCallbackURLCreateRequest(ctx, resourceGroupName, integrationAccountName, assemblyArtifactName, options) if err != nil { return IntegrationAccountAssembliesClientListContentCallbackURLResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountAssembliesClientListContentCallbackURLResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountAssembliesClientListContentCallbackURLResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountAssembliesClientListContentCallbackURLResponse{}, err } - return client.listContentCallbackURLHandleResponse(resp) + resp, err := client.listContentCallbackURLHandleResponse(httpResp) + return resp, err } // listContentCallbackURLCreateRequest creates the ListContentCallbackURL request. diff --git a/sdk/resourcemanager/logic/armlogic/integrationaccountassemblies_client_example_test.go b/sdk/resourcemanager/logic/armlogic/integrationaccountassemblies_client_example_test.go index 22ce085184ed..b01c7c6fef87 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccountassemblies_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccountassemblies_client_example_test.go @@ -47,8 +47,8 @@ func ExampleIntegrationAccountAssembliesClient_NewListPager() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/assemblies"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts/testIntegrationAccount/assemblies/testAssembly"), // Properties: &armlogic.AssemblyProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:45:23.4137139Z"); return t}()), - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:45:23.4129778Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:45:23.413Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:45:23.412Z"); return t}()), // Metadata: map[string]any{ // }, // ContentLink: &armlogic.ContentLink{ @@ -91,8 +91,8 @@ func ExampleIntegrationAccountAssembliesClient_Get() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/assemblies"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts/testIntegrationAccount/assemblies/testAssembly"), // Properties: &armlogic.AssemblyProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:45:23.4137139Z"); return t}()), - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:45:23.4129778Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:45:23.413Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:45:23.412Z"); return t}()), // Metadata: map[string]any{ // }, // ContentLink: &armlogic.ContentLink{ @@ -140,8 +140,8 @@ func ExampleIntegrationAccountAssembliesClient_CreateOrUpdate() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/assemblies"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts/testIntegrationAccount/assemblies/testAssembly"), // Properties: &armlogic.AssemblyProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:45:23.4137139Z"); return t}()), - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:45:23.4129778Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:45:23.413Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:45:23.412Z"); return t}()), // Metadata: map[string]any{ // }, // ContentLink: &armlogic.ContentLink{ diff --git a/sdk/resourcemanager/logic/armlogic/integrationaccountbatchconfigurations_client.go b/sdk/resourcemanager/logic/armlogic/integrationaccountbatchconfigurations_client.go index c3e5af4edb06..2bd97f6c4894 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccountbatchconfigurations_client.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccountbatchconfigurations_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -33,7 +32,7 @@ type IntegrationAccountBatchConfigurationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationAccountBatchConfigurationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationAccountBatchConfigurationsClient, error) { - cl, err := arm.NewClient(moduleName+".IntegrationAccountBatchConfigurationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,18 +54,25 @@ func NewIntegrationAccountBatchConfigurationsClient(subscriptionID string, crede // - options - IntegrationAccountBatchConfigurationsClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountBatchConfigurationsClient.CreateOrUpdate // method. func (client *IntegrationAccountBatchConfigurationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, integrationAccountName string, batchConfigurationName string, batchConfiguration BatchConfiguration, options *IntegrationAccountBatchConfigurationsClientCreateOrUpdateOptions) (IntegrationAccountBatchConfigurationsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "IntegrationAccountBatchConfigurationsClient.CreateOrUpdate" + 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, integrationAccountName, batchConfigurationName, batchConfiguration, options) if err != nil { return IntegrationAccountBatchConfigurationsClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountBatchConfigurationsClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return IntegrationAccountBatchConfigurationsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountBatchConfigurationsClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -96,7 +102,10 @@ func (client *IntegrationAccountBatchConfigurationsClient) createOrUpdateCreateR reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, batchConfiguration) + if err := runtime.MarshalAsJSON(req, batchConfiguration); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -118,16 +127,22 @@ func (client *IntegrationAccountBatchConfigurationsClient) createOrUpdateHandleR // - options - IntegrationAccountBatchConfigurationsClientDeleteOptions contains the optional parameters for the IntegrationAccountBatchConfigurationsClient.Delete // method. func (client *IntegrationAccountBatchConfigurationsClient) Delete(ctx context.Context, resourceGroupName string, integrationAccountName string, batchConfigurationName string, options *IntegrationAccountBatchConfigurationsClientDeleteOptions) (IntegrationAccountBatchConfigurationsClientDeleteResponse, error) { + var err error + const operationName = "IntegrationAccountBatchConfigurationsClient.Delete" + 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, integrationAccountName, batchConfigurationName, options) if err != nil { return IntegrationAccountBatchConfigurationsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountBatchConfigurationsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return IntegrationAccountBatchConfigurationsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountBatchConfigurationsClientDeleteResponse{}, err } return IntegrationAccountBatchConfigurationsClientDeleteResponse{}, nil } @@ -172,18 +187,25 @@ func (client *IntegrationAccountBatchConfigurationsClient) deleteCreateRequest(c // - options - IntegrationAccountBatchConfigurationsClientGetOptions contains the optional parameters for the IntegrationAccountBatchConfigurationsClient.Get // method. func (client *IntegrationAccountBatchConfigurationsClient) Get(ctx context.Context, resourceGroupName string, integrationAccountName string, batchConfigurationName string, options *IntegrationAccountBatchConfigurationsClientGetOptions) (IntegrationAccountBatchConfigurationsClientGetResponse, error) { + var err error + const operationName = "IntegrationAccountBatchConfigurationsClient.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, integrationAccountName, batchConfigurationName, options) if err != nil { return IntegrationAccountBatchConfigurationsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountBatchConfigurationsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountBatchConfigurationsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountBatchConfigurationsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -238,6 +260,7 @@ func (client *IntegrationAccountBatchConfigurationsClient) NewListPager(resource return false }, Fetcher: func(ctx context.Context, page *IntegrationAccountBatchConfigurationsClientListResponse) (IntegrationAccountBatchConfigurationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IntegrationAccountBatchConfigurationsClient.NewListPager") req, err := client.listCreateRequest(ctx, resourceGroupName, integrationAccountName, options) if err != nil { return IntegrationAccountBatchConfigurationsClientListResponse{}, err @@ -251,6 +274,7 @@ func (client *IntegrationAccountBatchConfigurationsClient) NewListPager(resource } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/logic/armlogic/integrationaccountbatchconfigurations_client_example_test.go b/sdk/resourcemanager/logic/armlogic/integrationaccountbatchconfigurations_client_example_test.go index 7e7982ecd23c..a3cb43d08cbc 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccountbatchconfigurations_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccountbatchconfigurations_client_example_test.go @@ -47,8 +47,8 @@ func ExampleIntegrationAccountBatchConfigurationsClient_NewListPager() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/batchConfigurations"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts/testIntegrationAccount/batchConfigurations/testBatchConfiguration"), // Properties: &armlogic.BatchConfigurationProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-26T06:14:16.7042301Z"); return t}()), - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-26T06:14:16.6518552Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-26T06:14:16.704Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-26T06:14:16.651Z"); return t}()), // BatchGroupName: to.Ptr("DEFAULT"), // ReleaseCriteria: &armlogic.BatchReleaseCriteria{ // BatchSize: to.Ptr[int32](234567), @@ -89,8 +89,8 @@ func ExampleIntegrationAccountBatchConfigurationsClient_Get() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/batchConfigurations"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts/testIntegrationAccount/batchConfigurations/testBatchConfiguration"), // Properties: &armlogic.BatchConfigurationProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-26T06:14:16.7042301Z"); return t}()), - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-26T06:14:16.6518552Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-26T06:14:16.704Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-26T06:14:16.651Z"); return t}()), // BatchGroupName: to.Ptr("DEFAULT"), // ReleaseCriteria: &armlogic.BatchReleaseCriteria{ // BatchSize: to.Ptr[int32](234567), @@ -144,8 +144,8 @@ func ExampleIntegrationAccountBatchConfigurationsClient_CreateOrUpdate() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/batchConfigurations"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts/testIntegrationAccount/batchConfigurations/testBatchConfiguration"), // Properties: &armlogic.BatchConfigurationProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-26T06:14:16.7042301Z"); return t}()), - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-26T06:14:16.6518552Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-26T06:14:16.704Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-26T06:14:16.651Z"); return t}()), // BatchGroupName: to.Ptr("DEFAULT"), // ReleaseCriteria: &armlogic.BatchReleaseCriteria{ // BatchSize: to.Ptr[int32](234567), diff --git a/sdk/resourcemanager/logic/armlogic/integrationaccountcertificates_client.go b/sdk/resourcemanager/logic/armlogic/integrationaccountcertificates_client.go index e28f98f4c733..9819ac025cf6 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccountcertificates_client.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccountcertificates_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -34,7 +33,7 @@ type IntegrationAccountCertificatesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationAccountCertificatesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationAccountCertificatesClient, error) { - cl, err := arm.NewClient(moduleName+".IntegrationAccountCertificatesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -56,18 +55,25 @@ func NewIntegrationAccountCertificatesClient(subscriptionID string, credential a // - options - IntegrationAccountCertificatesClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountCertificatesClient.CreateOrUpdate // method. func (client *IntegrationAccountCertificatesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, integrationAccountName string, certificateName string, certificate IntegrationAccountCertificate, options *IntegrationAccountCertificatesClientCreateOrUpdateOptions) (IntegrationAccountCertificatesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "IntegrationAccountCertificatesClient.CreateOrUpdate" + 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, integrationAccountName, certificateName, certificate, options) if err != nil { return IntegrationAccountCertificatesClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountCertificatesClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return IntegrationAccountCertificatesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountCertificatesClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -97,7 +103,10 @@ func (client *IntegrationAccountCertificatesClient) createOrUpdateCreateRequest( reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, certificate) + if err := runtime.MarshalAsJSON(req, certificate); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -119,16 +128,22 @@ func (client *IntegrationAccountCertificatesClient) createOrUpdateHandleResponse // - options - IntegrationAccountCertificatesClientDeleteOptions contains the optional parameters for the IntegrationAccountCertificatesClient.Delete // method. func (client *IntegrationAccountCertificatesClient) Delete(ctx context.Context, resourceGroupName string, integrationAccountName string, certificateName string, options *IntegrationAccountCertificatesClientDeleteOptions) (IntegrationAccountCertificatesClientDeleteResponse, error) { + var err error + const operationName = "IntegrationAccountCertificatesClient.Delete" + 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, integrationAccountName, certificateName, options) if err != nil { return IntegrationAccountCertificatesClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountCertificatesClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return IntegrationAccountCertificatesClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountCertificatesClientDeleteResponse{}, err } return IntegrationAccountCertificatesClientDeleteResponse{}, nil } @@ -173,18 +188,25 @@ func (client *IntegrationAccountCertificatesClient) deleteCreateRequest(ctx cont // - options - IntegrationAccountCertificatesClientGetOptions contains the optional parameters for the IntegrationAccountCertificatesClient.Get // method. func (client *IntegrationAccountCertificatesClient) Get(ctx context.Context, resourceGroupName string, integrationAccountName string, certificateName string, options *IntegrationAccountCertificatesClientGetOptions) (IntegrationAccountCertificatesClientGetResponse, error) { + var err error + const operationName = "IntegrationAccountCertificatesClient.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, integrationAccountName, certificateName, options) if err != nil { return IntegrationAccountCertificatesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountCertificatesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountCertificatesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountCertificatesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -239,25 +261,20 @@ func (client *IntegrationAccountCertificatesClient) NewListPager(resourceGroupNa return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *IntegrationAccountCertificatesClientListResponse) (IntegrationAccountCertificatesClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, integrationAccountName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IntegrationAccountCertificatesClient.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, resourceGroupName, integrationAccountName, options) + }, nil) if err != nil { return IntegrationAccountCertificatesClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return IntegrationAccountCertificatesClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountCertificatesClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/logic/armlogic/integrationaccountcertificates_client_example_test.go b/sdk/resourcemanager/logic/armlogic/integrationaccountcertificates_client_example_test.go index c5c8548dcfa0..a9f3931ad930 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccountcertificates_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccountcertificates_client_example_test.go @@ -47,8 +47,8 @@ func ExampleIntegrationAccountCertificatesClient_NewListPager() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/certificates"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts/testIntegrationAccount/certificates/"), // Properties: &armlogic.IntegrationAccountCertificateProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:33:09.7032076Z"); return t}()), - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:33:09.7022471Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:33:09.703Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:33:09.702Z"); return t}()), // Key: &armlogic.KeyVaultKeyReference{ // KeyName: to.Ptr(""), // KeyVault: &armlogic.KeyVaultKeyReferenceKeyVault{ @@ -88,8 +88,8 @@ func ExampleIntegrationAccountCertificatesClient_Get() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/certificates"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts/IntegrationAccount9472/certificates/testCertificate"), // Properties: &armlogic.IntegrationAccountCertificateProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:42:21.051317Z"); return t}()), - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:42:21.0510202Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:42:21.051Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:42:21.051Z"); return t}()), // Key: &armlogic.KeyVaultKeyReference{ // KeyName: to.Ptr(""), // KeyVault: &armlogic.KeyVaultKeyReferenceKeyVault{ @@ -139,8 +139,8 @@ func ExampleIntegrationAccountCertificatesClient_CreateOrUpdate() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/certificates"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts/testIntegrationAccount/certificates/testCertificate"), // Properties: &armlogic.IntegrationAccountCertificateProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:42:21.051317Z"); return t}()), - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:42:21.0510202Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:42:21.051Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:42:21.051Z"); return t}()), // Key: &armlogic.KeyVaultKeyReference{ // KeyName: to.Ptr(""), // KeyVault: &armlogic.KeyVaultKeyReferenceKeyVault{ diff --git a/sdk/resourcemanager/logic/armlogic/integrationaccountmaps_client.go b/sdk/resourcemanager/logic/armlogic/integrationaccountmaps_client.go index f34de6c03a48..e0bc3461193b 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccountmaps_client.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccountmaps_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -34,7 +33,7 @@ type IntegrationAccountMapsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationAccountMapsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationAccountMapsClient, error) { - cl, err := arm.NewClient(moduleName+".IntegrationAccountMapsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -58,18 +57,25 @@ func NewIntegrationAccountMapsClient(subscriptionID string, credential azcore.To // - options - IntegrationAccountMapsClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountMapsClient.CreateOrUpdate // method. func (client *IntegrationAccountMapsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, integrationAccountName string, mapName string, mapParam IntegrationAccountMap, options *IntegrationAccountMapsClientCreateOrUpdateOptions) (IntegrationAccountMapsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "IntegrationAccountMapsClient.CreateOrUpdate" + 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, integrationAccountName, mapName, mapParam, options) if err != nil { return IntegrationAccountMapsClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountMapsClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return IntegrationAccountMapsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountMapsClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -99,7 +105,10 @@ func (client *IntegrationAccountMapsClient) createOrUpdateCreateRequest(ctx cont reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, mapParam) + if err := runtime.MarshalAsJSON(req, mapParam); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -121,16 +130,22 @@ func (client *IntegrationAccountMapsClient) createOrUpdateHandleResponse(resp *h // - options - IntegrationAccountMapsClientDeleteOptions contains the optional parameters for the IntegrationAccountMapsClient.Delete // method. func (client *IntegrationAccountMapsClient) Delete(ctx context.Context, resourceGroupName string, integrationAccountName string, mapName string, options *IntegrationAccountMapsClientDeleteOptions) (IntegrationAccountMapsClientDeleteResponse, error) { + var err error + const operationName = "IntegrationAccountMapsClient.Delete" + 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, integrationAccountName, mapName, options) if err != nil { return IntegrationAccountMapsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountMapsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return IntegrationAccountMapsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountMapsClientDeleteResponse{}, err } return IntegrationAccountMapsClientDeleteResponse{}, nil } @@ -175,18 +190,25 @@ func (client *IntegrationAccountMapsClient) deleteCreateRequest(ctx context.Cont // - options - IntegrationAccountMapsClientGetOptions contains the optional parameters for the IntegrationAccountMapsClient.Get // method. func (client *IntegrationAccountMapsClient) Get(ctx context.Context, resourceGroupName string, integrationAccountName string, mapName string, options *IntegrationAccountMapsClientGetOptions) (IntegrationAccountMapsClientGetResponse, error) { + var err error + const operationName = "IntegrationAccountMapsClient.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, integrationAccountName, mapName, options) if err != nil { return IntegrationAccountMapsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountMapsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountMapsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountMapsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -241,25 +263,20 @@ func (client *IntegrationAccountMapsClient) NewListPager(resourceGroupName strin return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *IntegrationAccountMapsClientListResponse) (IntegrationAccountMapsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, integrationAccountName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return IntegrationAccountMapsClientListResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IntegrationAccountMapsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, integrationAccountName, options) + }, nil) if err != nil { return IntegrationAccountMapsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountMapsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -314,18 +331,25 @@ func (client *IntegrationAccountMapsClient) listHandleResponse(resp *http.Respon // - options - IntegrationAccountMapsClientListContentCallbackURLOptions contains the optional parameters for the IntegrationAccountMapsClient.ListContentCallbackURL // method. func (client *IntegrationAccountMapsClient) ListContentCallbackURL(ctx context.Context, resourceGroupName string, integrationAccountName string, mapName string, listContentCallbackURL GetCallbackURLParameters, options *IntegrationAccountMapsClientListContentCallbackURLOptions) (IntegrationAccountMapsClientListContentCallbackURLResponse, error) { + var err error + const operationName = "IntegrationAccountMapsClient.ListContentCallbackURL" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listContentCallbackURLCreateRequest(ctx, resourceGroupName, integrationAccountName, mapName, listContentCallbackURL, options) if err != nil { return IntegrationAccountMapsClientListContentCallbackURLResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountMapsClientListContentCallbackURLResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountMapsClientListContentCallbackURLResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountMapsClientListContentCallbackURLResponse{}, err } - return client.listContentCallbackURLHandleResponse(resp) + resp, err := client.listContentCallbackURLHandleResponse(httpResp) + return resp, err } // listContentCallbackURLCreateRequest creates the ListContentCallbackURL request. @@ -355,7 +379,10 @@ func (client *IntegrationAccountMapsClient) listContentCallbackURLCreateRequest( reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, listContentCallbackURL) + if err := runtime.MarshalAsJSON(req, listContentCallbackURL); err != nil { + return nil, err + } + return req, nil } // listContentCallbackURLHandleResponse handles the ListContentCallbackURL response. diff --git a/sdk/resourcemanager/logic/armlogic/integrationaccountmaps_client_example_test.go b/sdk/resourcemanager/logic/armlogic/integrationaccountmaps_client_example_test.go index 65ee801f8ee5..fb7dcb51b477 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccountmaps_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccountmaps_client_example_test.go @@ -51,7 +51,7 @@ func ExampleIntegrationAccountMapsClient_NewListPager() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/maps"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts/testIntegrationAccount/maps/IntegrationAccountMap9943"), // Properties: &armlogic.IntegrationAccountMapProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:34:32.390576Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:34:32.390Z"); return t}()), // ContentLink: &armlogic.ContentLink{ // ContentHash: &armlogic.ContentHash{ // Algorithm: to.Ptr("md5"), @@ -61,7 +61,7 @@ func ExampleIntegrationAccountMapsClient_NewListPager() { // ContentVersion: to.Ptr("\"0x8D45CE3C6D23B4B\""), // URI: to.Ptr(""), // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:34:32.3902373Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:34:32.390Z"); return t}()), // MapType: to.Ptr(armlogic.MapTypeXslt), // Metadata: map[string]any{ // }, @@ -94,7 +94,7 @@ func ExampleIntegrationAccountMapsClient_Get() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/maps"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts/testIntegrationAccount/maps/testMap"), // Properties: &armlogic.IntegrationAccountMapProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:45:23.4137139Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:45:23.413Z"); return t}()), // ContentLink: &armlogic.ContentLink{ // ContentHash: &armlogic.ContentHash{ // Algorithm: to.Ptr("md5"), @@ -104,7 +104,7 @@ func ExampleIntegrationAccountMapsClient_Get() { // ContentVersion: to.Ptr("\"0x8D45CE54B058881\""), // URI: to.Ptr(""), // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:45:23.4129778Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T18:45:23.412Z"); return t}()), // MapType: to.Ptr(armlogic.MapTypeXslt), // Metadata: map[string]any{ // }, @@ -143,7 +143,7 @@ func ExampleIntegrationAccountMapsClient_CreateOrUpdate_createOrUpdateAMap() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/maps"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups//providers/Microsoft.Logic/integrationAccounts//maps/testMap"), // Properties: &armlogic.IntegrationAccountMapProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T18:41:04.4088605Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T18:41:04.408Z"); return t}()), // ContentLink: &armlogic.ContentLink{ // ContentHash: &armlogic.ContentHash{ // Algorithm: to.Ptr("md5"), @@ -153,7 +153,7 @@ func ExampleIntegrationAccountMapsClient_CreateOrUpdate_createOrUpdateAMap() { // ContentVersion: to.Ptr("\"0x8D464C057F22E5F\""), // URI: to.Ptr(""), // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T18:41:03.7366103Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T18:41:03.736Z"); return t}()), // MapType: to.Ptr(armlogic.MapTypeXslt), // Metadata: map[string]any{ // }, @@ -194,7 +194,7 @@ func ExampleIntegrationAccountMapsClient_CreateOrUpdate_createOrUpdateAMapLarger // Type: to.Ptr("Microsoft.Logic/integrationAccounts/maps"), // ID: to.Ptr("/subscriptions//resourceGroups/refresh/providers/Microsoft.Logic/integrationAccounts/testIntegrationAccount/maps/testMap"), // Properties: &armlogic.IntegrationAccountMapProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-02-09T07:40:10.2906473Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-02-09T07:40:10.290Z"); return t}()), // ContentLink: &armlogic.ContentLink{ // ContentHash: &armlogic.ContentHash{ // Algorithm: to.Ptr("md5"), @@ -204,7 +204,7 @@ func ExampleIntegrationAccountMapsClient_CreateOrUpdate_createOrUpdateAMapLarger // ContentVersion: to.Ptr("\"0x8D9EB9F6691E7A2\""), // URI: to.Ptr(""), // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-02-09T07:40:10.2863459Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-02-09T07:40:10.286Z"); return t}()), // MapType: to.Ptr(armlogic.MapTypeXslt), // Metadata: map[string]any{ // }, @@ -242,7 +242,7 @@ func ExampleIntegrationAccountMapsClient_ListContentCallbackURL() { } res, err := clientFactory.NewIntegrationAccountMapsClient().ListContentCallbackURL(ctx, "testResourceGroup", "testIntegrationAccount", "testMap", armlogic.GetCallbackURLParameters{ KeyType: to.Ptr(armlogic.KeyTypePrimary), - NotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-19T16:00:00Z"); return t }()), + NotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-19T16:00:00.000Z"); return t }()), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) diff --git a/sdk/resourcemanager/logic/armlogic/integrationaccountpartners_client.go b/sdk/resourcemanager/logic/armlogic/integrationaccountpartners_client.go index 6e731d6380b7..00f2145dd132 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccountpartners_client.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccountpartners_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -34,7 +33,7 @@ type IntegrationAccountPartnersClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationAccountPartnersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationAccountPartnersClient, error) { - cl, err := arm.NewClient(moduleName+".IntegrationAccountPartnersClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -56,18 +55,25 @@ func NewIntegrationAccountPartnersClient(subscriptionID string, credential azcor // - options - IntegrationAccountPartnersClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountPartnersClient.CreateOrUpdate // method. func (client *IntegrationAccountPartnersClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, integrationAccountName string, partnerName string, partner IntegrationAccountPartner, options *IntegrationAccountPartnersClientCreateOrUpdateOptions) (IntegrationAccountPartnersClientCreateOrUpdateResponse, error) { + var err error + const operationName = "IntegrationAccountPartnersClient.CreateOrUpdate" + 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, integrationAccountName, partnerName, partner, options) if err != nil { return IntegrationAccountPartnersClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountPartnersClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return IntegrationAccountPartnersClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountPartnersClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -97,7 +103,10 @@ func (client *IntegrationAccountPartnersClient) createOrUpdateCreateRequest(ctx reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, partner) + if err := runtime.MarshalAsJSON(req, partner); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -119,16 +128,22 @@ func (client *IntegrationAccountPartnersClient) createOrUpdateHandleResponse(res // - options - IntegrationAccountPartnersClientDeleteOptions contains the optional parameters for the IntegrationAccountPartnersClient.Delete // method. func (client *IntegrationAccountPartnersClient) Delete(ctx context.Context, resourceGroupName string, integrationAccountName string, partnerName string, options *IntegrationAccountPartnersClientDeleteOptions) (IntegrationAccountPartnersClientDeleteResponse, error) { + var err error + const operationName = "IntegrationAccountPartnersClient.Delete" + 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, integrationAccountName, partnerName, options) if err != nil { return IntegrationAccountPartnersClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountPartnersClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return IntegrationAccountPartnersClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountPartnersClientDeleteResponse{}, err } return IntegrationAccountPartnersClientDeleteResponse{}, nil } @@ -173,18 +188,25 @@ func (client *IntegrationAccountPartnersClient) deleteCreateRequest(ctx context. // - options - IntegrationAccountPartnersClientGetOptions contains the optional parameters for the IntegrationAccountPartnersClient.Get // method. func (client *IntegrationAccountPartnersClient) Get(ctx context.Context, resourceGroupName string, integrationAccountName string, partnerName string, options *IntegrationAccountPartnersClientGetOptions) (IntegrationAccountPartnersClientGetResponse, error) { + var err error + const operationName = "IntegrationAccountPartnersClient.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, integrationAccountName, partnerName, options) if err != nil { return IntegrationAccountPartnersClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountPartnersClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountPartnersClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountPartnersClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -239,25 +261,20 @@ func (client *IntegrationAccountPartnersClient) NewListPager(resourceGroupName s return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *IntegrationAccountPartnersClientListResponse) (IntegrationAccountPartnersClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, integrationAccountName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return IntegrationAccountPartnersClientListResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IntegrationAccountPartnersClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, integrationAccountName, options) + }, nil) if err != nil { return IntegrationAccountPartnersClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountPartnersClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -312,18 +329,25 @@ func (client *IntegrationAccountPartnersClient) listHandleResponse(resp *http.Re // - options - IntegrationAccountPartnersClientListContentCallbackURLOptions contains the optional parameters for the IntegrationAccountPartnersClient.ListContentCallbackURL // method. func (client *IntegrationAccountPartnersClient) ListContentCallbackURL(ctx context.Context, resourceGroupName string, integrationAccountName string, partnerName string, listContentCallbackURL GetCallbackURLParameters, options *IntegrationAccountPartnersClientListContentCallbackURLOptions) (IntegrationAccountPartnersClientListContentCallbackURLResponse, error) { + var err error + const operationName = "IntegrationAccountPartnersClient.ListContentCallbackURL" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listContentCallbackURLCreateRequest(ctx, resourceGroupName, integrationAccountName, partnerName, listContentCallbackURL, options) if err != nil { return IntegrationAccountPartnersClientListContentCallbackURLResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountPartnersClientListContentCallbackURLResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountPartnersClientListContentCallbackURLResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountPartnersClientListContentCallbackURLResponse{}, err } - return client.listContentCallbackURLHandleResponse(resp) + resp, err := client.listContentCallbackURLHandleResponse(httpResp) + return resp, err } // listContentCallbackURLCreateRequest creates the ListContentCallbackURL request. @@ -353,7 +377,10 @@ func (client *IntegrationAccountPartnersClient) listContentCallbackURLCreateRequ reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, listContentCallbackURL) + if err := runtime.MarshalAsJSON(req, listContentCallbackURL); err != nil { + return nil, err + } + return req, nil } // listContentCallbackURLHandleResponse handles the ListContentCallbackURL response. diff --git a/sdk/resourcemanager/logic/armlogic/integrationaccountpartners_client_example_test.go b/sdk/resourcemanager/logic/armlogic/integrationaccountpartners_client_example_test.go index 8733123099c8..9793cf6f6bac 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccountpartners_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccountpartners_client_example_test.go @@ -51,7 +51,7 @@ func ExampleIntegrationAccountPartnersClient_NewListPager() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/partners"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts/IntegrationAccount2431/partners/testIntegrationAccount"), // Properties: &armlogic.IntegrationAccountPartnerProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T19:42:59.1987212Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T19:42:59.198Z"); return t}()), // Content: &armlogic.PartnerContent{ // B2B: &armlogic.B2BPartnerContent{ // BusinessIdentities: []*armlogic.BusinessIdentity{ @@ -61,7 +61,7 @@ func ExampleIntegrationAccountPartnersClient_NewListPager() { // }}, // }, // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T19:42:59.197919Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T19:42:59.197Z"); return t}()), // Metadata: map[string]any{ // }, // PartnerType: to.Ptr(armlogic.PartnerTypeB2B), @@ -94,7 +94,7 @@ func ExampleIntegrationAccountPartnersClient_Get() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/partners"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts/testIntegrationAccount/partners/testPartner"), // Properties: &armlogic.IntegrationAccountPartnerProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:01:24.0525141Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:01:24.052Z"); return t}()), // Content: &armlogic.PartnerContent{ // B2B: &armlogic.B2BPartnerContent{ // BusinessIdentities: []*armlogic.BusinessIdentity{ @@ -104,7 +104,7 @@ func ExampleIntegrationAccountPartnersClient_Get() { // }}, // }, // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:01:24.0517156Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:01:24.051Z"); return t}()), // Metadata: map[string]any{ // }, // PartnerType: to.Ptr(armlogic.PartnerTypeB2B), @@ -151,7 +151,7 @@ func ExampleIntegrationAccountPartnersClient_CreateOrUpdate() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/partners"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/flowrg/providers/Microsoft.Logic/integrationAccounts/testIntegrationAccount/partners/testPartner"), // Properties: &armlogic.IntegrationAccountPartnerProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:06:23.5904806Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:06:23.590Z"); return t}()), // Content: &armlogic.PartnerContent{ // B2B: &armlogic.B2BPartnerContent{ // BusinessIdentities: []*armlogic.BusinessIdentity{ @@ -161,7 +161,7 @@ func ExampleIntegrationAccountPartnersClient_CreateOrUpdate() { // }}, // }, // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:06:23.5895246Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-06T20:06:23.589Z"); return t}()), // Metadata: map[string]any{ // }, // PartnerType: to.Ptr(armlogic.PartnerTypeB2B), @@ -199,7 +199,7 @@ func ExampleIntegrationAccountPartnersClient_ListContentCallbackURL() { } res, err := clientFactory.NewIntegrationAccountPartnersClient().ListContentCallbackURL(ctx, "testResourceGroup", "testIntegrationAccount", "testPartner", armlogic.GetCallbackURLParameters{ KeyType: to.Ptr(armlogic.KeyTypePrimary), - NotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-19T16:00:00Z"); return t }()), + NotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-19T16:00:00.000Z"); return t }()), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) diff --git a/sdk/resourcemanager/logic/armlogic/integrationaccounts_client.go b/sdk/resourcemanager/logic/armlogic/integrationaccounts_client.go index 30b0fe127382..9f81ed3ac423 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccounts_client.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccounts_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -34,7 +33,7 @@ type IntegrationAccountsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationAccountsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationAccountsClient, error) { - cl, err := arm.NewClient(moduleName+".IntegrationAccountsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,18 +54,25 @@ func NewIntegrationAccountsClient(subscriptionID string, credential azcore.Token // - options - IntegrationAccountsClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountsClient.CreateOrUpdate // method. func (client *IntegrationAccountsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, integrationAccountName string, integrationAccount IntegrationAccount, options *IntegrationAccountsClientCreateOrUpdateOptions) (IntegrationAccountsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "IntegrationAccountsClient.CreateOrUpdate" + 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, integrationAccountName, integrationAccount, options) if err != nil { return IntegrationAccountsClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountsClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return IntegrationAccountsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountsClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -92,7 +98,10 @@ func (client *IntegrationAccountsClient) createOrUpdateCreateRequest(ctx context reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, integrationAccount) + if err := runtime.MarshalAsJSON(req, integrationAccount); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -113,16 +122,22 @@ func (client *IntegrationAccountsClient) createOrUpdateHandleResponse(resp *http // - options - IntegrationAccountsClientDeleteOptions contains the optional parameters for the IntegrationAccountsClient.Delete // method. func (client *IntegrationAccountsClient) Delete(ctx context.Context, resourceGroupName string, integrationAccountName string, options *IntegrationAccountsClientDeleteOptions) (IntegrationAccountsClientDeleteResponse, error) { + var err error + const operationName = "IntegrationAccountsClient.Delete" + 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, integrationAccountName, options) if err != nil { return IntegrationAccountsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return IntegrationAccountsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountsClientDeleteResponse{}, err } return IntegrationAccountsClientDeleteResponse{}, nil } @@ -161,18 +176,25 @@ func (client *IntegrationAccountsClient) deleteCreateRequest(ctx context.Context // - integrationAccountName - The integration account name. // - options - IntegrationAccountsClientGetOptions contains the optional parameters for the IntegrationAccountsClient.Get method. func (client *IntegrationAccountsClient) Get(ctx context.Context, resourceGroupName string, integrationAccountName string, options *IntegrationAccountsClientGetOptions) (IntegrationAccountsClientGetResponse, error) { + var err error + const operationName = "IntegrationAccountsClient.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, integrationAccountName, options) if err != nil { return IntegrationAccountsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -222,25 +244,20 @@ func (client *IntegrationAccountsClient) NewListByResourceGroupPager(resourceGro return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *IntegrationAccountsClientListByResourceGroupResponse) (IntegrationAccountsClientListByResourceGroupResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IntegrationAccountsClient.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 IntegrationAccountsClientListByResourceGroupResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return IntegrationAccountsClientListByResourceGroupResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -289,25 +306,20 @@ func (client *IntegrationAccountsClient) NewListBySubscriptionPager(options *Int return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *IntegrationAccountsClientListBySubscriptionResponse) (IntegrationAccountsClientListBySubscriptionResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listBySubscriptionCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IntegrationAccountsClient.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 IntegrationAccountsClientListBySubscriptionResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return IntegrationAccountsClientListBySubscriptionResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) - } return client.listBySubscriptionHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -351,18 +363,25 @@ func (client *IntegrationAccountsClient) listBySubscriptionHandleResponse(resp * // - options - IntegrationAccountsClientListCallbackURLOptions contains the optional parameters for the IntegrationAccountsClient.ListCallbackURL // method. func (client *IntegrationAccountsClient) ListCallbackURL(ctx context.Context, resourceGroupName string, integrationAccountName string, parameters GetCallbackURLParameters, options *IntegrationAccountsClientListCallbackURLOptions) (IntegrationAccountsClientListCallbackURLResponse, error) { + var err error + const operationName = "IntegrationAccountsClient.ListCallbackURL" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listCallbackURLCreateRequest(ctx, resourceGroupName, integrationAccountName, parameters, options) if err != nil { return IntegrationAccountsClientListCallbackURLResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountsClientListCallbackURLResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountsClientListCallbackURLResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountsClientListCallbackURLResponse{}, err } - return client.listCallbackURLHandleResponse(resp) + resp, err := client.listCallbackURLHandleResponse(httpResp) + return resp, err } // listCallbackURLCreateRequest creates the ListCallbackURL request. @@ -388,7 +407,10 @@ func (client *IntegrationAccountsClient) listCallbackURLCreateRequest(ctx contex reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // listCallbackURLHandleResponse handles the ListCallbackURL response. @@ -414,6 +436,7 @@ func (client *IntegrationAccountsClient) NewListKeyVaultKeysPager(resourceGroupN return false }, Fetcher: func(ctx context.Context, page *IntegrationAccountsClientListKeyVaultKeysResponse) (IntegrationAccountsClientListKeyVaultKeysResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IntegrationAccountsClient.NewListKeyVaultKeysPager") req, err := client.listKeyVaultKeysCreateRequest(ctx, resourceGroupName, integrationAccountName, listKeyVaultKeys, options) if err != nil { return IntegrationAccountsClientListKeyVaultKeysResponse{}, err @@ -427,6 +450,7 @@ func (client *IntegrationAccountsClient) NewListKeyVaultKeysPager(resourceGroupN } return client.listKeyVaultKeysHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -453,7 +477,10 @@ func (client *IntegrationAccountsClient) listKeyVaultKeysCreateRequest(ctx conte reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, listKeyVaultKeys) + if err := runtime.MarshalAsJSON(req, listKeyVaultKeys); err != nil { + return nil, err + } + return req, nil } // listKeyVaultKeysHandleResponse handles the ListKeyVaultKeys response. @@ -475,16 +502,22 @@ func (client *IntegrationAccountsClient) listKeyVaultKeysHandleResponse(resp *ht // - options - IntegrationAccountsClientLogTrackingEventsOptions contains the optional parameters for the IntegrationAccountsClient.LogTrackingEvents // method. func (client *IntegrationAccountsClient) LogTrackingEvents(ctx context.Context, resourceGroupName string, integrationAccountName string, logTrackingEvents TrackingEventsDefinition, options *IntegrationAccountsClientLogTrackingEventsOptions) (IntegrationAccountsClientLogTrackingEventsResponse, error) { + var err error + const operationName = "IntegrationAccountsClient.LogTrackingEvents" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.logTrackingEventsCreateRequest(ctx, resourceGroupName, integrationAccountName, logTrackingEvents, options) if err != nil { return IntegrationAccountsClientLogTrackingEventsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountsClientLogTrackingEventsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountsClientLogTrackingEventsResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountsClientLogTrackingEventsResponse{}, err } return IntegrationAccountsClientLogTrackingEventsResponse{}, nil } @@ -512,7 +545,10 @@ func (client *IntegrationAccountsClient) logTrackingEventsCreateRequest(ctx cont reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, logTrackingEvents) + if err := runtime.MarshalAsJSON(req, logTrackingEvents); err != nil { + return nil, err + } + return req, nil } // RegenerateAccessKey - Regenerates the integration account access key. @@ -525,18 +561,25 @@ func (client *IntegrationAccountsClient) logTrackingEventsCreateRequest(ctx cont // - options - IntegrationAccountsClientRegenerateAccessKeyOptions contains the optional parameters for the IntegrationAccountsClient.RegenerateAccessKey // method. func (client *IntegrationAccountsClient) RegenerateAccessKey(ctx context.Context, resourceGroupName string, integrationAccountName string, regenerateAccessKey RegenerateActionParameter, options *IntegrationAccountsClientRegenerateAccessKeyOptions) (IntegrationAccountsClientRegenerateAccessKeyResponse, error) { + var err error + const operationName = "IntegrationAccountsClient.RegenerateAccessKey" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.regenerateAccessKeyCreateRequest(ctx, resourceGroupName, integrationAccountName, regenerateAccessKey, options) if err != nil { return IntegrationAccountsClientRegenerateAccessKeyResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountsClientRegenerateAccessKeyResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountsClientRegenerateAccessKeyResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountsClientRegenerateAccessKeyResponse{}, err } - return client.regenerateAccessKeyHandleResponse(resp) + resp, err := client.regenerateAccessKeyHandleResponse(httpResp) + return resp, err } // regenerateAccessKeyCreateRequest creates the RegenerateAccessKey request. @@ -562,7 +605,10 @@ func (client *IntegrationAccountsClient) regenerateAccessKeyCreateRequest(ctx co reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, regenerateAccessKey) + if err := runtime.MarshalAsJSON(req, regenerateAccessKey); err != nil { + return nil, err + } + return req, nil } // regenerateAccessKeyHandleResponse handles the RegenerateAccessKey response. @@ -584,18 +630,25 @@ func (client *IntegrationAccountsClient) regenerateAccessKeyHandleResponse(resp // - options - IntegrationAccountsClientUpdateOptions contains the optional parameters for the IntegrationAccountsClient.Update // method. func (client *IntegrationAccountsClient) Update(ctx context.Context, resourceGroupName string, integrationAccountName string, integrationAccount IntegrationAccount, options *IntegrationAccountsClientUpdateOptions) (IntegrationAccountsClientUpdateResponse, error) { + var err error + const operationName = "IntegrationAccountsClient.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, integrationAccountName, integrationAccount, options) if err != nil { return IntegrationAccountsClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountsClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountsClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountsClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -621,7 +674,10 @@ func (client *IntegrationAccountsClient) updateCreateRequest(ctx context.Context reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, integrationAccount) + if err := runtime.MarshalAsJSON(req, integrationAccount); err != nil { + return nil, err + } + return req, nil } // updateHandleResponse handles the Update response. diff --git a/sdk/resourcemanager/logic/armlogic/integrationaccounts_client_example_test.go b/sdk/resourcemanager/logic/armlogic/integrationaccounts_client_example_test.go index 689568e0f9d9..0219c54dce0c 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccounts_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccounts_client_example_test.go @@ -239,7 +239,7 @@ func ExampleIntegrationAccountsClient_ListCallbackURL() { } res, err := clientFactory.NewIntegrationAccountsClient().ListCallbackURL(ctx, "testResourceGroup", "testIntegrationAccount", armlogic.GetCallbackURLParameters{ KeyType: to.Ptr(armlogic.KeyTypePrimary), - NotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-05T08:00:00Z"); return t }()), + NotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-05T08:00:00.000Z"); return t }()), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) @@ -313,7 +313,7 @@ func ExampleIntegrationAccountsClient_LogTrackingEvents() { Message: to.Ptr("Some error occurred"), }, EventLevel: to.Ptr(armlogic.EventLevelInformational), - EventTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-05T01:54:49.505567Z"); return t }()), + EventTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2016-08-05T01:54:49.505Z"); return t }()), Record: map[string]any{ "agreementProperties": map[string]any{ "agreementName": "testAgreement", diff --git a/sdk/resourcemanager/logic/armlogic/integrationaccounts_live_test.go b/sdk/resourcemanager/logic/armlogic/integrationaccounts_live_test.go index cb0aef050a76..312e921560c7 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccounts_live_test.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccounts_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "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/testutil" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2/testutil" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/logic/armlogic" "github.com/stretchr/testify/suite" ) @@ -58,9 +58,9 @@ func (testsuite *IntegrationAccountsTestSuite) SetupSuite() { testsuite.partnerName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "partnern", 14, false) testsuite.schemaName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "schemana", 14, false) testsuite.sessionName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "sessionn", 14, false) - testsuite.location = testutil.GetEnv("LOCATION", "westus") - testsuite.resourceGroupName = testutil.GetEnv("RESOURCE_GROUP_NAME", "scenarioTestTempGroup") - testsuite.subscriptionId = testutil.GetEnv("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + testsuite.location = recording.GetEnvVariable("LOCATION", "westus") + testsuite.resourceGroupName = recording.GetEnvVariable("RESOURCE_GROUP_NAME", "scenarioTestTempGroup") + testsuite.subscriptionId = recording.GetEnvVariable("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") resourceGroup, _, err := testutil.CreateResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.location) testsuite.Require().NoError(err) testsuite.resourceGroupName = *resourceGroup.Name diff --git a/sdk/resourcemanager/logic/armlogic/integrationaccountschemas_client.go b/sdk/resourcemanager/logic/armlogic/integrationaccountschemas_client.go index ecb8bd269427..49a7d003cc2e 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccountschemas_client.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccountschemas_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -34,7 +33,7 @@ type IntegrationAccountSchemasClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationAccountSchemasClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationAccountSchemasClient, error) { - cl, err := arm.NewClient(moduleName+".IntegrationAccountSchemasClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -56,18 +55,25 @@ func NewIntegrationAccountSchemasClient(subscriptionID string, credential azcore // - options - IntegrationAccountSchemasClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountSchemasClient.CreateOrUpdate // method. func (client *IntegrationAccountSchemasClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, integrationAccountName string, schemaName string, schema IntegrationAccountSchema, options *IntegrationAccountSchemasClientCreateOrUpdateOptions) (IntegrationAccountSchemasClientCreateOrUpdateResponse, error) { + var err error + const operationName = "IntegrationAccountSchemasClient.CreateOrUpdate" + 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, integrationAccountName, schemaName, schema, options) if err != nil { return IntegrationAccountSchemasClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountSchemasClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return IntegrationAccountSchemasClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountSchemasClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -97,7 +103,10 @@ func (client *IntegrationAccountSchemasClient) createOrUpdateCreateRequest(ctx c reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, schema) + if err := runtime.MarshalAsJSON(req, schema); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -119,16 +128,22 @@ func (client *IntegrationAccountSchemasClient) createOrUpdateHandleResponse(resp // - options - IntegrationAccountSchemasClientDeleteOptions contains the optional parameters for the IntegrationAccountSchemasClient.Delete // method. func (client *IntegrationAccountSchemasClient) Delete(ctx context.Context, resourceGroupName string, integrationAccountName string, schemaName string, options *IntegrationAccountSchemasClientDeleteOptions) (IntegrationAccountSchemasClientDeleteResponse, error) { + var err error + const operationName = "IntegrationAccountSchemasClient.Delete" + 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, integrationAccountName, schemaName, options) if err != nil { return IntegrationAccountSchemasClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountSchemasClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return IntegrationAccountSchemasClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountSchemasClientDeleteResponse{}, err } return IntegrationAccountSchemasClientDeleteResponse{}, nil } @@ -173,18 +188,25 @@ func (client *IntegrationAccountSchemasClient) deleteCreateRequest(ctx context.C // - options - IntegrationAccountSchemasClientGetOptions contains the optional parameters for the IntegrationAccountSchemasClient.Get // method. func (client *IntegrationAccountSchemasClient) Get(ctx context.Context, resourceGroupName string, integrationAccountName string, schemaName string, options *IntegrationAccountSchemasClientGetOptions) (IntegrationAccountSchemasClientGetResponse, error) { + var err error + const operationName = "IntegrationAccountSchemasClient.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, integrationAccountName, schemaName, options) if err != nil { return IntegrationAccountSchemasClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountSchemasClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountSchemasClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountSchemasClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -239,25 +261,20 @@ func (client *IntegrationAccountSchemasClient) NewListPager(resourceGroupName st return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *IntegrationAccountSchemasClientListResponse) (IntegrationAccountSchemasClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, integrationAccountName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return IntegrationAccountSchemasClientListResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IntegrationAccountSchemasClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, integrationAccountName, options) + }, nil) if err != nil { return IntegrationAccountSchemasClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountSchemasClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -312,18 +329,25 @@ func (client *IntegrationAccountSchemasClient) listHandleResponse(resp *http.Res // - options - IntegrationAccountSchemasClientListContentCallbackURLOptions contains the optional parameters for the IntegrationAccountSchemasClient.ListContentCallbackURL // method. func (client *IntegrationAccountSchemasClient) ListContentCallbackURL(ctx context.Context, resourceGroupName string, integrationAccountName string, schemaName string, listContentCallbackURL GetCallbackURLParameters, options *IntegrationAccountSchemasClientListContentCallbackURLOptions) (IntegrationAccountSchemasClientListContentCallbackURLResponse, error) { + var err error + const operationName = "IntegrationAccountSchemasClient.ListContentCallbackURL" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listContentCallbackURLCreateRequest(ctx, resourceGroupName, integrationAccountName, schemaName, listContentCallbackURL, options) if err != nil { return IntegrationAccountSchemasClientListContentCallbackURLResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountSchemasClientListContentCallbackURLResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountSchemasClientListContentCallbackURLResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountSchemasClientListContentCallbackURLResponse{}, err } - return client.listContentCallbackURLHandleResponse(resp) + resp, err := client.listContentCallbackURLHandleResponse(httpResp) + return resp, err } // listContentCallbackURLCreateRequest creates the ListContentCallbackURL request. @@ -353,7 +377,10 @@ func (client *IntegrationAccountSchemasClient) listContentCallbackURLCreateReque reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, listContentCallbackURL) + if err := runtime.MarshalAsJSON(req, listContentCallbackURL); err != nil { + return nil, err + } + return req, nil } // listContentCallbackURLHandleResponse handles the ListContentCallbackURL response. diff --git a/sdk/resourcemanager/logic/armlogic/integrationaccountschemas_client_example_test.go b/sdk/resourcemanager/logic/armlogic/integrationaccountschemas_client_example_test.go index af804d409812..db96c0b9ea31 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccountschemas_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccountschemas_client_example_test.go @@ -51,7 +51,7 @@ func ExampleIntegrationAccountSchemasClient_NewListPager() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/schemas"), // ID: to.Ptr("/subscriptions//resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts//schemas/IntegrationAccountSchema3944"), // Properties: &armlogic.IntegrationAccountSchemaProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T01:34:16.7098626Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T01:34:16.709Z"); return t}()), // ContentLink: &armlogic.ContentLink{ // ContentHash: &armlogic.ContentHash{ // Algorithm: to.Ptr("md5"), @@ -61,7 +61,7 @@ func ExampleIntegrationAccountSchemasClient_NewListPager() { // ContentVersion: to.Ptr("\"0x8D45C553EECEB76\""), // URI: to.Ptr(""), // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T01:34:16.7088958Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T01:34:16.708Z"); return t}()), // DocumentName: to.Ptr("OrderFile"), // Metadata: map[string]any{ // }, @@ -96,7 +96,7 @@ func ExampleIntegrationAccountSchemasClient_Get() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/schemas"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts/testIntegrationAccount/schemas/testSchema"), // Properties: &armlogic.IntegrationAccountSchemaProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T01:46:48.0847046Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T01:46:48.084Z"); return t}()), // ContentLink: &armlogic.ContentLink{ // ContentHash: &armlogic.ContentHash{ // Algorithm: to.Ptr("md5"), @@ -106,7 +106,7 @@ func ExampleIntegrationAccountSchemasClient_Get() { // ContentVersion: to.Ptr("\"0x8D45C56FEDFCB45\""), // URI: to.Ptr(""), // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T01:46:48.0837583Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T01:46:48.083Z"); return t}()), // DocumentName: to.Ptr("OrderFile"), // Metadata: map[string]any{ // }, @@ -150,7 +150,7 @@ func ExampleIntegrationAccountSchemasClient_CreateOrUpdate() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/schemas"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/integrationAccounts/testIntegrationAccount/schemas/testSchema"), // Properties: &armlogic.IntegrationAccountSchemaProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T01:46:48.0847046Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T01:46:48.084Z"); return t}()), // ContentLink: &armlogic.ContentLink{ // ContentHash: &armlogic.ContentHash{ // Algorithm: to.Ptr("md5"), @@ -160,7 +160,7 @@ func ExampleIntegrationAccountSchemasClient_CreateOrUpdate() { // ContentVersion: to.Ptr("\"0x8D45C56FEDFCB45\""), // URI: to.Ptr(""), // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T01:46:48.0837583Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-24T01:46:48.083Z"); return t}()), // DocumentName: to.Ptr("OrderFile"), // Metadata: map[string]any{ // }, @@ -200,7 +200,7 @@ func ExampleIntegrationAccountSchemasClient_ListContentCallbackURL() { } res, err := clientFactory.NewIntegrationAccountSchemasClient().ListContentCallbackURL(ctx, "testResourceGroup", "testIntegrationAccount", "testSchema", armlogic.GetCallbackURLParameters{ KeyType: to.Ptr(armlogic.KeyTypePrimary), - NotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-19T16:00:00Z"); return t }()), + NotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-19T16:00:00.000Z"); return t }()), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) diff --git a/sdk/resourcemanager/logic/armlogic/integrationaccountsessions_client.go b/sdk/resourcemanager/logic/armlogic/integrationaccountsessions_client.go index 681a1f13864d..6e848cb861a8 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccountsessions_client.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccountsessions_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -34,7 +33,7 @@ type IntegrationAccountSessionsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationAccountSessionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationAccountSessionsClient, error) { - cl, err := arm.NewClient(moduleName+".IntegrationAccountSessionsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -56,18 +55,25 @@ func NewIntegrationAccountSessionsClient(subscriptionID string, credential azcor // - options - IntegrationAccountSessionsClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountSessionsClient.CreateOrUpdate // method. func (client *IntegrationAccountSessionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, integrationAccountName string, sessionName string, session IntegrationAccountSession, options *IntegrationAccountSessionsClientCreateOrUpdateOptions) (IntegrationAccountSessionsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "IntegrationAccountSessionsClient.CreateOrUpdate" + 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, integrationAccountName, sessionName, session, options) if err != nil { return IntegrationAccountSessionsClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountSessionsClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return IntegrationAccountSessionsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountSessionsClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -97,7 +103,10 @@ func (client *IntegrationAccountSessionsClient) createOrUpdateCreateRequest(ctx reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, session) + if err := runtime.MarshalAsJSON(req, session); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -119,16 +128,22 @@ func (client *IntegrationAccountSessionsClient) createOrUpdateHandleResponse(res // - options - IntegrationAccountSessionsClientDeleteOptions contains the optional parameters for the IntegrationAccountSessionsClient.Delete // method. func (client *IntegrationAccountSessionsClient) Delete(ctx context.Context, resourceGroupName string, integrationAccountName string, sessionName string, options *IntegrationAccountSessionsClientDeleteOptions) (IntegrationAccountSessionsClientDeleteResponse, error) { + var err error + const operationName = "IntegrationAccountSessionsClient.Delete" + 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, integrationAccountName, sessionName, options) if err != nil { return IntegrationAccountSessionsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountSessionsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return IntegrationAccountSessionsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountSessionsClientDeleteResponse{}, err } return IntegrationAccountSessionsClientDeleteResponse{}, nil } @@ -173,18 +188,25 @@ func (client *IntegrationAccountSessionsClient) deleteCreateRequest(ctx context. // - options - IntegrationAccountSessionsClientGetOptions contains the optional parameters for the IntegrationAccountSessionsClient.Get // method. func (client *IntegrationAccountSessionsClient) Get(ctx context.Context, resourceGroupName string, integrationAccountName string, sessionName string, options *IntegrationAccountSessionsClientGetOptions) (IntegrationAccountSessionsClientGetResponse, error) { + var err error + const operationName = "IntegrationAccountSessionsClient.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, integrationAccountName, sessionName, options) if err != nil { return IntegrationAccountSessionsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationAccountSessionsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountSessionsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationAccountSessionsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -239,25 +261,20 @@ func (client *IntegrationAccountSessionsClient) NewListPager(resourceGroupName s return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *IntegrationAccountSessionsClientListResponse) (IntegrationAccountSessionsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, integrationAccountName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IntegrationAccountSessionsClient.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, resourceGroupName, integrationAccountName, options) + }, nil) if err != nil { return IntegrationAccountSessionsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return IntegrationAccountSessionsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationAccountSessionsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/logic/armlogic/integrationaccountsessions_client_example_test.go b/sdk/resourcemanager/logic/armlogic/integrationaccountsessions_client_example_test.go index c7111e30a346..5a4a2b7a35af 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationaccountsessions_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/integrationaccountsessions_client_example_test.go @@ -48,12 +48,12 @@ func ExampleIntegrationAccountSessionsClient_NewListPager() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/sessions"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.Logic/integrationAccounts/testia123/sessions/IntegrationAccountSession1662"), // Properties: &armlogic.IntegrationAccountSessionProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T23:06:24.0158575Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T23:06:24.015Z"); return t}()), // Content: map[string]any{ // "controlNumber": "1234", // "controlNumberChangedTime": "2017-02-21T22:30:11.9923759Z", // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T23:06:24.0152955Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T23:06:24.015Z"); return t}()), // }, // }, // { @@ -61,12 +61,12 @@ func ExampleIntegrationAccountSessionsClient_NewListPager() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/sessions"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.Logic/integrationAccounts/testia123/sessions/IntegrationAccountSession6808"), // Properties: &armlogic.IntegrationAccountSessionProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T23:06:23.7540113Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T23:06:23.754Z"); return t}()), // Content: map[string]any{ // "controlNumber": "1234", // "controlNumberChangedTime": "2017-02-21T22:30:11.9923759Z", // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T23:06:23.7535558Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T23:06:23.753Z"); return t}()), // }, // }, // { @@ -74,12 +74,12 @@ func ExampleIntegrationAccountSessionsClient_NewListPager() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/sessions"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.Logic/integrationAccounts/testia123/sessions/IntegrationAccountSession7315"), // Properties: &armlogic.IntegrationAccountSessionProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T23:06:23.8370161Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T23:06:23.837Z"); return t}()), // Content: map[string]any{ // "controlNumber": "1234", // "controlNumberChangedTime": "2017-02-21T22:30:11.9923759Z", // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T23:06:23.8367926Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T23:06:23.836Z"); return t}()), // }, // }}, // } @@ -109,12 +109,12 @@ func ExampleIntegrationAccountSessionsClient_Get() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/sessions"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.Logic/integrationAccounts/testia123/sessions/testsession123-ICN"), // Properties: &armlogic.IntegrationAccountSessionProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T20:41:35.9796534Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T20:41:35.979Z"); return t}()), // Content: map[string]any{ // "controlNumber": "1234", // "controlNumberChangedTime": "2017-02-21T22:30:11.9923759Z", // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T20:41:35.9789189Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T20:41:35.978Z"); return t}()), // }, // } } @@ -149,12 +149,12 @@ func ExampleIntegrationAccountSessionsClient_CreateOrUpdate() { // Type: to.Ptr("Microsoft.Logic/integrationAccounts/sessions"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testrg123/providers/Microsoft.Logic/integrationAccounts/testia123/sessions/testsession123-ICN"), // Properties: &armlogic.IntegrationAccountSessionProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T20:41:35.9796534Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T20:41:35.979Z"); return t}()), // Content: map[string]any{ // "controlNumber": "1234", // "controlNumberChangedTime": "2017-02-21T22:30:11.9923759Z", // }, - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T20:41:35.9789189Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-02-21T20:41:35.978Z"); return t}()), // }, // } } diff --git a/sdk/resourcemanager/logic/armlogic/integrationserviceenvironmentmanagedapioperations_client.go b/sdk/resourcemanager/logic/armlogic/integrationserviceenvironmentmanagedapioperations_client.go index d9903c707db7..b15972f382ef 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationserviceenvironmentmanagedapioperations_client.go +++ b/sdk/resourcemanager/logic/armlogic/integrationserviceenvironmentmanagedapioperations_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -33,7 +32,7 @@ type IntegrationServiceEnvironmentManagedAPIOperationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationServiceEnvironmentManagedAPIOperationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationServiceEnvironmentManagedAPIOperationsClient, error) { - cl, err := arm.NewClient(moduleName+".IntegrationServiceEnvironmentManagedAPIOperationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -58,25 +57,20 @@ func (client *IntegrationServiceEnvironmentManagedAPIOperationsClient) NewListPa return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *IntegrationServiceEnvironmentManagedAPIOperationsClientListResponse) (IntegrationServiceEnvironmentManagedAPIOperationsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroup, integrationServiceEnvironmentName, apiName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IntegrationServiceEnvironmentManagedAPIOperationsClient.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, resourceGroup, integrationServiceEnvironmentName, apiName, options) + }, nil) if err != nil { return IntegrationServiceEnvironmentManagedAPIOperationsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return IntegrationServiceEnvironmentManagedAPIOperationsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationServiceEnvironmentManagedAPIOperationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/logic/armlogic/integrationserviceenvironmentmanagedapis_client.go b/sdk/resourcemanager/logic/armlogic/integrationserviceenvironmentmanagedapis_client.go index 5f5059afdaff..3e2a02e452c5 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationserviceenvironmentmanagedapis_client.go +++ b/sdk/resourcemanager/logic/armlogic/integrationserviceenvironmentmanagedapis_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -33,7 +32,7 @@ type IntegrationServiceEnvironmentManagedApisClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationServiceEnvironmentManagedApisClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationServiceEnvironmentManagedApisClient, error) { - cl, err := arm.NewClient(moduleName+".IntegrationServiceEnvironmentManagedApisClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -59,9 +58,14 @@ func (client *IntegrationServiceEnvironmentManagedApisClient) BeginDelete(ctx co if err != nil { return nil, err } - return runtime.NewPoller[IntegrationServiceEnvironmentManagedApisClientDeleteResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[IntegrationServiceEnvironmentManagedApisClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[IntegrationServiceEnvironmentManagedApisClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[IntegrationServiceEnvironmentManagedApisClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -70,18 +74,24 @@ func (client *IntegrationServiceEnvironmentManagedApisClient) BeginDelete(ctx co // // Generated from API version 2019-05-01 func (client *IntegrationServiceEnvironmentManagedApisClient) deleteOperation(ctx context.Context, resourceGroup string, integrationServiceEnvironmentName string, apiName string, options *IntegrationServiceEnvironmentManagedApisClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "IntegrationServiceEnvironmentManagedApisClient.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, resourceGroup, integrationServiceEnvironmentName, apiName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -124,18 +134,25 @@ func (client *IntegrationServiceEnvironmentManagedApisClient) deleteCreateReques // - options - IntegrationServiceEnvironmentManagedApisClientGetOptions contains the optional parameters for the IntegrationServiceEnvironmentManagedApisClient.Get // method. func (client *IntegrationServiceEnvironmentManagedApisClient) Get(ctx context.Context, resourceGroup string, integrationServiceEnvironmentName string, apiName string, options *IntegrationServiceEnvironmentManagedApisClientGetOptions) (IntegrationServiceEnvironmentManagedApisClientGetResponse, error) { + var err error + const operationName = "IntegrationServiceEnvironmentManagedApisClient.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, resourceGroup, integrationServiceEnvironmentName, apiName, options) if err != nil { return IntegrationServiceEnvironmentManagedApisClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationServiceEnvironmentManagedApisClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationServiceEnvironmentManagedApisClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationServiceEnvironmentManagedApisClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -190,25 +207,20 @@ func (client *IntegrationServiceEnvironmentManagedApisClient) NewListPager(resou return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *IntegrationServiceEnvironmentManagedApisClientListResponse) (IntegrationServiceEnvironmentManagedApisClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroup, integrationServiceEnvironmentName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return IntegrationServiceEnvironmentManagedApisClientListResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IntegrationServiceEnvironmentManagedApisClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroup, integrationServiceEnvironmentName, options) + }, nil) if err != nil { return IntegrationServiceEnvironmentManagedApisClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationServiceEnvironmentManagedApisClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -263,9 +275,14 @@ func (client *IntegrationServiceEnvironmentManagedApisClient) BeginPut(ctx conte if err != nil { return nil, err } - return runtime.NewPoller[IntegrationServiceEnvironmentManagedApisClientPutResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[IntegrationServiceEnvironmentManagedApisClientPutResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[IntegrationServiceEnvironmentManagedApisClientPutResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[IntegrationServiceEnvironmentManagedApisClientPutResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -274,18 +291,24 @@ func (client *IntegrationServiceEnvironmentManagedApisClient) BeginPut(ctx conte // // Generated from API version 2019-05-01 func (client *IntegrationServiceEnvironmentManagedApisClient) put(ctx context.Context, resourceGroup string, integrationServiceEnvironmentName string, apiName string, integrationServiceEnvironmentManagedAPI IntegrationServiceEnvironmentManagedAPI, options *IntegrationServiceEnvironmentManagedApisClientBeginPutOptions) (*http.Response, error) { + var err error + const operationName = "IntegrationServiceEnvironmentManagedApisClient.BeginPut" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.putCreateRequest(ctx, resourceGroup, integrationServiceEnvironmentName, apiName, integrationServiceEnvironmentManagedAPI, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // putCreateRequest creates the Put request. @@ -315,5 +338,8 @@ func (client *IntegrationServiceEnvironmentManagedApisClient) putCreateRequest(c reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, integrationServiceEnvironmentManagedAPI) + if err := runtime.MarshalAsJSON(req, integrationServiceEnvironmentManagedAPI); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/logic/armlogic/integrationserviceenvironmentnetworkhealth_client.go b/sdk/resourcemanager/logic/armlogic/integrationserviceenvironmentnetworkhealth_client.go index 20908410f9d6..00e6e63380c1 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationserviceenvironmentnetworkhealth_client.go +++ b/sdk/resourcemanager/logic/armlogic/integrationserviceenvironmentnetworkhealth_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -33,7 +32,7 @@ type IntegrationServiceEnvironmentNetworkHealthClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationServiceEnvironmentNetworkHealthClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationServiceEnvironmentNetworkHealthClient, error) { - cl, err := arm.NewClient(moduleName+".IntegrationServiceEnvironmentNetworkHealthClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -53,18 +52,25 @@ func NewIntegrationServiceEnvironmentNetworkHealthClient(subscriptionID string, // - options - IntegrationServiceEnvironmentNetworkHealthClientGetOptions contains the optional parameters for the IntegrationServiceEnvironmentNetworkHealthClient.Get // method. func (client *IntegrationServiceEnvironmentNetworkHealthClient) Get(ctx context.Context, resourceGroup string, integrationServiceEnvironmentName string, options *IntegrationServiceEnvironmentNetworkHealthClientGetOptions) (IntegrationServiceEnvironmentNetworkHealthClientGetResponse, error) { + var err error + const operationName = "IntegrationServiceEnvironmentNetworkHealthClient.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, resourceGroup, integrationServiceEnvironmentName, options) if err != nil { return IntegrationServiceEnvironmentNetworkHealthClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationServiceEnvironmentNetworkHealthClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationServiceEnvironmentNetworkHealthClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationServiceEnvironmentNetworkHealthClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. diff --git a/sdk/resourcemanager/logic/armlogic/integrationserviceenvironments_client.go b/sdk/resourcemanager/logic/armlogic/integrationserviceenvironments_client.go index e97e9bc93be6..ce8d2b22fb98 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationserviceenvironments_client.go +++ b/sdk/resourcemanager/logic/armlogic/integrationserviceenvironments_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -34,7 +33,7 @@ type IntegrationServiceEnvironmentsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationServiceEnvironmentsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationServiceEnvironmentsClient, error) { - cl, err := arm.NewClient(moduleName+".IntegrationServiceEnvironmentsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -60,9 +59,14 @@ func (client *IntegrationServiceEnvironmentsClient) BeginCreateOrUpdate(ctx cont if err != nil { return nil, err } - return runtime.NewPoller[IntegrationServiceEnvironmentsClientCreateOrUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[IntegrationServiceEnvironmentsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[IntegrationServiceEnvironmentsClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[IntegrationServiceEnvironmentsClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -71,18 +75,24 @@ func (client *IntegrationServiceEnvironmentsClient) BeginCreateOrUpdate(ctx cont // // Generated from API version 2019-05-01 func (client *IntegrationServiceEnvironmentsClient) createOrUpdate(ctx context.Context, resourceGroup string, integrationServiceEnvironmentName string, integrationServiceEnvironment IntegrationServiceEnvironment, options *IntegrationServiceEnvironmentsClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "IntegrationServiceEnvironmentsClient.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, resourceGroup, integrationServiceEnvironmentName, integrationServiceEnvironment, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -108,7 +118,10 @@ func (client *IntegrationServiceEnvironmentsClient) createOrUpdateCreateRequest( reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, integrationServiceEnvironment) + if err := runtime.MarshalAsJSON(req, integrationServiceEnvironment); err != nil { + return nil, err + } + return req, nil } // Delete - Deletes an integration service environment. @@ -120,16 +133,22 @@ func (client *IntegrationServiceEnvironmentsClient) createOrUpdateCreateRequest( // - options - IntegrationServiceEnvironmentsClientDeleteOptions contains the optional parameters for the IntegrationServiceEnvironmentsClient.Delete // method. func (client *IntegrationServiceEnvironmentsClient) Delete(ctx context.Context, resourceGroup string, integrationServiceEnvironmentName string, options *IntegrationServiceEnvironmentsClientDeleteOptions) (IntegrationServiceEnvironmentsClientDeleteResponse, error) { + var err error + const operationName = "IntegrationServiceEnvironmentsClient.Delete" + 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, resourceGroup, integrationServiceEnvironmentName, options) if err != nil { return IntegrationServiceEnvironmentsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationServiceEnvironmentsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return IntegrationServiceEnvironmentsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return IntegrationServiceEnvironmentsClientDeleteResponse{}, err } return IntegrationServiceEnvironmentsClientDeleteResponse{}, nil } @@ -169,18 +188,25 @@ func (client *IntegrationServiceEnvironmentsClient) deleteCreateRequest(ctx cont // - options - IntegrationServiceEnvironmentsClientGetOptions contains the optional parameters for the IntegrationServiceEnvironmentsClient.Get // method. func (client *IntegrationServiceEnvironmentsClient) Get(ctx context.Context, resourceGroup string, integrationServiceEnvironmentName string, options *IntegrationServiceEnvironmentsClientGetOptions) (IntegrationServiceEnvironmentsClientGetResponse, error) { + var err error + const operationName = "IntegrationServiceEnvironmentsClient.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, resourceGroup, integrationServiceEnvironmentName, options) if err != nil { return IntegrationServiceEnvironmentsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationServiceEnvironmentsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationServiceEnvironmentsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationServiceEnvironmentsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -230,25 +256,20 @@ func (client *IntegrationServiceEnvironmentsClient) NewListByResourceGroupPager( return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *IntegrationServiceEnvironmentsClientListByResourceGroupResponse) (IntegrationServiceEnvironmentsClientListByResourceGroupResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroup, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IntegrationServiceEnvironmentsClient.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, resourceGroup, options) + }, nil) if err != nil { return IntegrationServiceEnvironmentsClientListByResourceGroupResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return IntegrationServiceEnvironmentsClientListByResourceGroupResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationServiceEnvironmentsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -297,25 +318,20 @@ func (client *IntegrationServiceEnvironmentsClient) NewListBySubscriptionPager(o return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *IntegrationServiceEnvironmentsClientListBySubscriptionResponse) (IntegrationServiceEnvironmentsClientListBySubscriptionResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listBySubscriptionCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IntegrationServiceEnvironmentsClient.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 IntegrationServiceEnvironmentsClientListBySubscriptionResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return IntegrationServiceEnvironmentsClientListBySubscriptionResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationServiceEnvironmentsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) - } return client.listBySubscriptionHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -358,16 +374,22 @@ func (client *IntegrationServiceEnvironmentsClient) listBySubscriptionHandleResp // - options - IntegrationServiceEnvironmentsClientRestartOptions contains the optional parameters for the IntegrationServiceEnvironmentsClient.Restart // method. func (client *IntegrationServiceEnvironmentsClient) Restart(ctx context.Context, resourceGroup string, integrationServiceEnvironmentName string, options *IntegrationServiceEnvironmentsClientRestartOptions) (IntegrationServiceEnvironmentsClientRestartResponse, error) { + var err error + const operationName = "IntegrationServiceEnvironmentsClient.Restart" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.restartCreateRequest(ctx, resourceGroup, integrationServiceEnvironmentName, options) if err != nil { return IntegrationServiceEnvironmentsClientRestartResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return IntegrationServiceEnvironmentsClientRestartResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationServiceEnvironmentsClientRestartResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return IntegrationServiceEnvironmentsClientRestartResponse{}, err } return IntegrationServiceEnvironmentsClientRestartResponse{}, nil } @@ -413,9 +435,14 @@ func (client *IntegrationServiceEnvironmentsClient) BeginUpdate(ctx context.Cont if err != nil { return nil, err } - return runtime.NewPoller[IntegrationServiceEnvironmentsClientUpdateResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[IntegrationServiceEnvironmentsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[IntegrationServiceEnvironmentsClientUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[IntegrationServiceEnvironmentsClientUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -424,18 +451,24 @@ func (client *IntegrationServiceEnvironmentsClient) BeginUpdate(ctx context.Cont // // Generated from API version 2019-05-01 func (client *IntegrationServiceEnvironmentsClient) update(ctx context.Context, resourceGroup string, integrationServiceEnvironmentName string, integrationServiceEnvironment IntegrationServiceEnvironment, options *IntegrationServiceEnvironmentsClientBeginUpdateOptions) (*http.Response, error) { + var err error + const operationName = "IntegrationServiceEnvironmentsClient.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, resourceGroup, integrationServiceEnvironmentName, integrationServiceEnvironment, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // updateCreateRequest creates the Update request. @@ -461,5 +494,8 @@ func (client *IntegrationServiceEnvironmentsClient) updateCreateRequest(ctx cont reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, integrationServiceEnvironment) + if err := runtime.MarshalAsJSON(req, integrationServiceEnvironment); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/logic/armlogic/integrationserviceenvironmentskus_client.go b/sdk/resourcemanager/logic/armlogic/integrationserviceenvironmentskus_client.go index fba23ce641f0..5275cd89841c 100644 --- a/sdk/resourcemanager/logic/armlogic/integrationserviceenvironmentskus_client.go +++ b/sdk/resourcemanager/logic/armlogic/integrationserviceenvironmentskus_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -33,7 +32,7 @@ type IntegrationServiceEnvironmentSKUsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewIntegrationServiceEnvironmentSKUsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*IntegrationServiceEnvironmentSKUsClient, error) { - cl, err := arm.NewClient(moduleName+".IntegrationServiceEnvironmentSKUsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -57,25 +56,20 @@ func (client *IntegrationServiceEnvironmentSKUsClient) NewListPager(resourceGrou return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *IntegrationServiceEnvironmentSKUsClientListResponse) (IntegrationServiceEnvironmentSKUsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroup, integrationServiceEnvironmentName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "IntegrationServiceEnvironmentSKUsClient.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, resourceGroup, integrationServiceEnvironmentName, options) + }, nil) if err != nil { return IntegrationServiceEnvironmentSKUsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return IntegrationServiceEnvironmentSKUsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return IntegrationServiceEnvironmentSKUsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/logic/armlogic/models.go b/sdk/resourcemanager/logic/armlogic/models.go index 08aa85ae1e5a..811e46e54e32 100644 --- a/sdk/resourcemanager/logic/armlogic/models.go +++ b/sdk/resourcemanager/logic/armlogic/models.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -1384,93 +1383,6 @@ type IntegrationAccountAgreementProperties struct { CreatedTime *time.Time } -// IntegrationAccountAgreementsClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountAgreementsClient.CreateOrUpdate -// method. -type IntegrationAccountAgreementsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountAgreementsClientDeleteOptions contains the optional parameters for the IntegrationAccountAgreementsClient.Delete -// method. -type IntegrationAccountAgreementsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountAgreementsClientGetOptions contains the optional parameters for the IntegrationAccountAgreementsClient.Get -// method. -type IntegrationAccountAgreementsClientGetOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountAgreementsClientListContentCallbackURLOptions contains the optional parameters for the IntegrationAccountAgreementsClient.ListContentCallbackURL -// method. -type IntegrationAccountAgreementsClientListContentCallbackURLOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountAgreementsClientListOptions contains the optional parameters for the IntegrationAccountAgreementsClient.NewListPager -// method. -type IntegrationAccountAgreementsClientListOptions struct { - // The filter to apply on the operation. Options for filters include: AgreementType. - Filter *string - // The number of items to be included in the result. - Top *int32 -} - -// IntegrationAccountAssembliesClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountAssembliesClient.CreateOrUpdate -// method. -type IntegrationAccountAssembliesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountAssembliesClientDeleteOptions contains the optional parameters for the IntegrationAccountAssembliesClient.Delete -// method. -type IntegrationAccountAssembliesClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountAssembliesClientGetOptions contains the optional parameters for the IntegrationAccountAssembliesClient.Get -// method. -type IntegrationAccountAssembliesClientGetOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountAssembliesClientListContentCallbackURLOptions contains the optional parameters for the IntegrationAccountAssembliesClient.ListContentCallbackURL -// method. -type IntegrationAccountAssembliesClientListContentCallbackURLOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountAssembliesClientListOptions contains the optional parameters for the IntegrationAccountAssembliesClient.NewListPager -// method. -type IntegrationAccountAssembliesClientListOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountBatchConfigurationsClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountBatchConfigurationsClient.CreateOrUpdate -// method. -type IntegrationAccountBatchConfigurationsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountBatchConfigurationsClientDeleteOptions contains the optional parameters for the IntegrationAccountBatchConfigurationsClient.Delete -// method. -type IntegrationAccountBatchConfigurationsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountBatchConfigurationsClientGetOptions contains the optional parameters for the IntegrationAccountBatchConfigurationsClient.Get -// method. -type IntegrationAccountBatchConfigurationsClientGetOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountBatchConfigurationsClientListOptions contains the optional parameters for the IntegrationAccountBatchConfigurationsClient.NewListPager -// method. -type IntegrationAccountBatchConfigurationsClientListOptions struct { - // placeholder for future optional parameters -} - // IntegrationAccountCertificate - The integration account certificate. type IntegrationAccountCertificate struct { // REQUIRED; The integration account certificate properties. @@ -1519,31 +1431,6 @@ type IntegrationAccountCertificateProperties struct { CreatedTime *time.Time } -// IntegrationAccountCertificatesClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountCertificatesClient.CreateOrUpdate -// method. -type IntegrationAccountCertificatesClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountCertificatesClientDeleteOptions contains the optional parameters for the IntegrationAccountCertificatesClient.Delete -// method. -type IntegrationAccountCertificatesClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountCertificatesClientGetOptions contains the optional parameters for the IntegrationAccountCertificatesClient.Get -// method. -type IntegrationAccountCertificatesClientGetOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountCertificatesClientListOptions contains the optional parameters for the IntegrationAccountCertificatesClient.NewListPager -// method. -type IntegrationAccountCertificatesClientListOptions struct { - // The number of items to be included in the result. - Top *int32 -} - // IntegrationAccountListResult - The list of integration accounts. type IntegrationAccountListResult struct { // The URL to get the next set of results. @@ -1622,38 +1509,6 @@ type IntegrationAccountMapPropertiesParametersSchema struct { Ref *string } -// IntegrationAccountMapsClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountMapsClient.CreateOrUpdate -// method. -type IntegrationAccountMapsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountMapsClientDeleteOptions contains the optional parameters for the IntegrationAccountMapsClient.Delete -// method. -type IntegrationAccountMapsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountMapsClientGetOptions contains the optional parameters for the IntegrationAccountMapsClient.Get method. -type IntegrationAccountMapsClientGetOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountMapsClientListContentCallbackURLOptions contains the optional parameters for the IntegrationAccountMapsClient.ListContentCallbackURL -// method. -type IntegrationAccountMapsClientListContentCallbackURLOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountMapsClientListOptions contains the optional parameters for the IntegrationAccountMapsClient.NewListPager -// method. -type IntegrationAccountMapsClientListOptions struct { - // The filter to apply on the operation. Options for filters include: MapType. - Filter *string - // The number of items to be included in the result. - Top *int32 -} - // IntegrationAccountPartner - The integration account partner. type IntegrationAccountPartner struct { // REQUIRED; The integration account partner properties. @@ -1708,39 +1563,6 @@ type IntegrationAccountPartnerProperties struct { CreatedTime *time.Time } -// IntegrationAccountPartnersClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountPartnersClient.CreateOrUpdate -// method. -type IntegrationAccountPartnersClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountPartnersClientDeleteOptions contains the optional parameters for the IntegrationAccountPartnersClient.Delete -// method. -type IntegrationAccountPartnersClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountPartnersClientGetOptions contains the optional parameters for the IntegrationAccountPartnersClient.Get -// method. -type IntegrationAccountPartnersClientGetOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountPartnersClientListContentCallbackURLOptions contains the optional parameters for the IntegrationAccountPartnersClient.ListContentCallbackURL -// method. -type IntegrationAccountPartnersClientListContentCallbackURLOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountPartnersClientListOptions contains the optional parameters for the IntegrationAccountPartnersClient.NewListPager -// method. -type IntegrationAccountPartnersClientListOptions struct { - // The filter to apply on the operation. Options for filters include: PartnerType. - Filter *string - // The number of items to be included in the result. - Top *int32 -} - // IntegrationAccountProperties - The integration account properties. type IntegrationAccountProperties struct { // The integration service environment. @@ -1825,39 +1647,6 @@ type IntegrationAccountSchemaProperties struct { CreatedTime *time.Time } -// IntegrationAccountSchemasClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountSchemasClient.CreateOrUpdate -// method. -type IntegrationAccountSchemasClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountSchemasClientDeleteOptions contains the optional parameters for the IntegrationAccountSchemasClient.Delete -// method. -type IntegrationAccountSchemasClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountSchemasClientGetOptions contains the optional parameters for the IntegrationAccountSchemasClient.Get -// method. -type IntegrationAccountSchemasClientGetOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountSchemasClientListContentCallbackURLOptions contains the optional parameters for the IntegrationAccountSchemasClient.ListContentCallbackURL -// method. -type IntegrationAccountSchemasClientListContentCallbackURLOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountSchemasClientListOptions contains the optional parameters for the IntegrationAccountSchemasClient.NewListPager -// method. -type IntegrationAccountSchemasClientListOptions struct { - // The filter to apply on the operation. Options for filters include: SchemaType. - Filter *string - // The number of items to be included in the result. - Top *int32 -} - // IntegrationAccountSession - The integration account session. type IntegrationAccountSession struct { // REQUIRED; The integration account session properties. @@ -1906,92 +1695,6 @@ type IntegrationAccountSessionProperties struct { CreatedTime *time.Time } -// IntegrationAccountSessionsClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountSessionsClient.CreateOrUpdate -// method. -type IntegrationAccountSessionsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountSessionsClientDeleteOptions contains the optional parameters for the IntegrationAccountSessionsClient.Delete -// method. -type IntegrationAccountSessionsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountSessionsClientGetOptions contains the optional parameters for the IntegrationAccountSessionsClient.Get -// method. -type IntegrationAccountSessionsClientGetOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountSessionsClientListOptions contains the optional parameters for the IntegrationAccountSessionsClient.NewListPager -// method. -type IntegrationAccountSessionsClientListOptions struct { - // The filter to apply on the operation. Options for filters include: ChangedTime. - Filter *string - // The number of items to be included in the result. - Top *int32 -} - -// IntegrationAccountsClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountsClient.CreateOrUpdate -// method. -type IntegrationAccountsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountsClientDeleteOptions contains the optional parameters for the IntegrationAccountsClient.Delete method. -type IntegrationAccountsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountsClientGetOptions contains the optional parameters for the IntegrationAccountsClient.Get method. -type IntegrationAccountsClientGetOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountsClientListByResourceGroupOptions contains the optional parameters for the IntegrationAccountsClient.NewListByResourceGroupPager -// method. -type IntegrationAccountsClientListByResourceGroupOptions struct { - // The number of items to be included in the result. - Top *int32 -} - -// IntegrationAccountsClientListBySubscriptionOptions contains the optional parameters for the IntegrationAccountsClient.NewListBySubscriptionPager -// method. -type IntegrationAccountsClientListBySubscriptionOptions struct { - // The number of items to be included in the result. - Top *int32 -} - -// IntegrationAccountsClientListCallbackURLOptions contains the optional parameters for the IntegrationAccountsClient.ListCallbackURL -// method. -type IntegrationAccountsClientListCallbackURLOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountsClientListKeyVaultKeysOptions contains the optional parameters for the IntegrationAccountsClient.NewListKeyVaultKeysPager -// method. -type IntegrationAccountsClientListKeyVaultKeysOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountsClientLogTrackingEventsOptions contains the optional parameters for the IntegrationAccountsClient.LogTrackingEvents -// method. -type IntegrationAccountsClientLogTrackingEventsOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountsClientRegenerateAccessKeyOptions contains the optional parameters for the IntegrationAccountsClient.RegenerateAccessKey -// method. -type IntegrationAccountsClientRegenerateAccessKeyOptions struct { - // placeholder for future optional parameters -} - -// IntegrationAccountsClientUpdateOptions contains the optional parameters for the IntegrationAccountsClient.Update method. -type IntegrationAccountsClientUpdateOptions struct { - // placeholder for future optional parameters -} - // IntegrationServiceEnvironmenEncryptionConfiguration - The encryption configuration for the integration service environment. type IntegrationServiceEnvironmenEncryptionConfiguration struct { // The encryption key reference. @@ -2087,12 +1790,6 @@ type IntegrationServiceEnvironmentManagedAPIListResult struct { Value []*IntegrationServiceEnvironmentManagedAPI } -// IntegrationServiceEnvironmentManagedAPIOperationsClientListOptions contains the optional parameters for the IntegrationServiceEnvironmentManagedAPIOperationsClient.NewListPager -// method. -type IntegrationServiceEnvironmentManagedAPIOperationsClientListOptions struct { - // placeholder for future optional parameters -} - // IntegrationServiceEnvironmentManagedAPIProperties - The integration service environment managed api properties. type IntegrationServiceEnvironmentManagedAPIProperties struct { // The integration service environment managed api deployment parameters. @@ -2138,32 +1835,6 @@ type IntegrationServiceEnvironmentManagedAPIProperties struct { RuntimeUrls []*string } -// IntegrationServiceEnvironmentManagedApisClientBeginDeleteOptions contains the optional parameters for the IntegrationServiceEnvironmentManagedApisClient.BeginDelete -// method. -type IntegrationServiceEnvironmentManagedApisClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// IntegrationServiceEnvironmentManagedApisClientBeginPutOptions contains the optional parameters for the IntegrationServiceEnvironmentManagedApisClient.BeginPut -// method. -type IntegrationServiceEnvironmentManagedApisClientBeginPutOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// IntegrationServiceEnvironmentManagedApisClientGetOptions contains the optional parameters for the IntegrationServiceEnvironmentManagedApisClient.Get -// method. -type IntegrationServiceEnvironmentManagedApisClientGetOptions struct { - // placeholder for future optional parameters -} - -// IntegrationServiceEnvironmentManagedApisClientListOptions contains the optional parameters for the IntegrationServiceEnvironmentManagedApisClient.NewListPager -// method. -type IntegrationServiceEnvironmentManagedApisClientListOptions struct { - // placeholder for future optional parameters -} - // IntegrationServiceEnvironmentNetworkDependency - The azure async operation resource. type IntegrationServiceEnvironmentNetworkDependency struct { // The network dependency category type. @@ -2197,12 +1868,6 @@ type IntegrationServiceEnvironmentNetworkEndpoint struct { Ports []*string } -// IntegrationServiceEnvironmentNetworkHealthClientGetOptions contains the optional parameters for the IntegrationServiceEnvironmentNetworkHealthClient.Get -// method. -type IntegrationServiceEnvironmentNetworkHealthClientGetOptions struct { - // placeholder for future optional parameters -} - // IntegrationServiceEnvironmentProperties - The integration service environment properties. type IntegrationServiceEnvironmentProperties struct { // The encryption configuration. @@ -2278,12 +1943,6 @@ type IntegrationServiceEnvironmentSKUList struct { Value []*IntegrationServiceEnvironmentSKUDefinition } -// IntegrationServiceEnvironmentSKUsClientListOptions contains the optional parameters for the IntegrationServiceEnvironmentSKUsClient.NewListPager -// method. -type IntegrationServiceEnvironmentSKUsClientListOptions struct { - // placeholder for future optional parameters -} - // IntegrationServiceEnvironmentSubnetNetworkHealth - The integration service environment subnet network health. type IntegrationServiceEnvironmentSubnetNetworkHealth struct { // REQUIRED; The integration service environment network health state. @@ -2296,52 +1955,6 @@ type IntegrationServiceEnvironmentSubnetNetworkHealth struct { OutboundNetworkHealth *IntegrationServiceEnvironmentNetworkDependencyHealth } -// IntegrationServiceEnvironmentsClientBeginCreateOrUpdateOptions contains the optional parameters for the IntegrationServiceEnvironmentsClient.BeginCreateOrUpdate -// method. -type IntegrationServiceEnvironmentsClientBeginCreateOrUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// IntegrationServiceEnvironmentsClientBeginUpdateOptions contains the optional parameters for the IntegrationServiceEnvironmentsClient.BeginUpdate -// method. -type IntegrationServiceEnvironmentsClientBeginUpdateOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// IntegrationServiceEnvironmentsClientDeleteOptions contains the optional parameters for the IntegrationServiceEnvironmentsClient.Delete -// method. -type IntegrationServiceEnvironmentsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// IntegrationServiceEnvironmentsClientGetOptions contains the optional parameters for the IntegrationServiceEnvironmentsClient.Get -// method. -type IntegrationServiceEnvironmentsClientGetOptions struct { - // placeholder for future optional parameters -} - -// IntegrationServiceEnvironmentsClientListByResourceGroupOptions contains the optional parameters for the IntegrationServiceEnvironmentsClient.NewListByResourceGroupPager -// method. -type IntegrationServiceEnvironmentsClientListByResourceGroupOptions struct { - // The number of items to be included in the result. - Top *int32 -} - -// IntegrationServiceEnvironmentsClientListBySubscriptionOptions contains the optional parameters for the IntegrationServiceEnvironmentsClient.NewListBySubscriptionPager -// method. -type IntegrationServiceEnvironmentsClientListBySubscriptionOptions struct { - // The number of items to be included in the result. - Top *int32 -} - -// IntegrationServiceEnvironmentsClientRestartOptions contains the optional parameters for the IntegrationServiceEnvironmentsClient.Restart -// method. -type IntegrationServiceEnvironmentsClientRestartOptions struct { - // placeholder for future optional parameters -} - // JSONSchema - The JSON schema. type JSONSchema struct { // The JSON content. @@ -2614,11 +2227,6 @@ type OperationResultProperties struct { Status *WorkflowStatus } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. -type OperationsClientListOptions struct { - // placeholder for future optional parameters -} - // PartnerContent - The integration account partner content. type PartnerContent struct { // The B2B partner content. @@ -3363,79 +2971,6 @@ type WorkflowRunActionRepetitionProperties struct { TrackingID *string } -// WorkflowRunActionRepetitionsClientGetOptions contains the optional parameters for the WorkflowRunActionRepetitionsClient.Get -// method. -type WorkflowRunActionRepetitionsClientGetOptions struct { - // placeholder for future optional parameters -} - -// WorkflowRunActionRepetitionsClientListExpressionTracesOptions contains the optional parameters for the WorkflowRunActionRepetitionsClient.NewListExpressionTracesPager -// method. -type WorkflowRunActionRepetitionsClientListExpressionTracesOptions struct { - // placeholder for future optional parameters -} - -// WorkflowRunActionRepetitionsClientListOptions contains the optional parameters for the WorkflowRunActionRepetitionsClient.NewListPager -// method. -type WorkflowRunActionRepetitionsClientListOptions struct { - // placeholder for future optional parameters -} - -// WorkflowRunActionRepetitionsRequestHistoriesClientGetOptions contains the optional parameters for the WorkflowRunActionRepetitionsRequestHistoriesClient.Get -// method. -type WorkflowRunActionRepetitionsRequestHistoriesClientGetOptions struct { - // placeholder for future optional parameters -} - -// WorkflowRunActionRepetitionsRequestHistoriesClientListOptions contains the optional parameters for the WorkflowRunActionRepetitionsRequestHistoriesClient.NewListPager -// method. -type WorkflowRunActionRepetitionsRequestHistoriesClientListOptions struct { - // placeholder for future optional parameters -} - -// WorkflowRunActionRequestHistoriesClientGetOptions contains the optional parameters for the WorkflowRunActionRequestHistoriesClient.Get -// method. -type WorkflowRunActionRequestHistoriesClientGetOptions struct { - // placeholder for future optional parameters -} - -// WorkflowRunActionRequestHistoriesClientListOptions contains the optional parameters for the WorkflowRunActionRequestHistoriesClient.NewListPager -// method. -type WorkflowRunActionRequestHistoriesClientListOptions struct { - // placeholder for future optional parameters -} - -// WorkflowRunActionScopeRepetitionsClientGetOptions contains the optional parameters for the WorkflowRunActionScopeRepetitionsClient.Get -// method. -type WorkflowRunActionScopeRepetitionsClientGetOptions struct { - // placeholder for future optional parameters -} - -// WorkflowRunActionScopeRepetitionsClientListOptions contains the optional parameters for the WorkflowRunActionScopeRepetitionsClient.NewListPager -// method. -type WorkflowRunActionScopeRepetitionsClientListOptions struct { - // placeholder for future optional parameters -} - -// WorkflowRunActionsClientGetOptions contains the optional parameters for the WorkflowRunActionsClient.Get method. -type WorkflowRunActionsClientGetOptions struct { - // placeholder for future optional parameters -} - -// WorkflowRunActionsClientListExpressionTracesOptions contains the optional parameters for the WorkflowRunActionsClient.NewListExpressionTracesPager -// method. -type WorkflowRunActionsClientListExpressionTracesOptions struct { - // placeholder for future optional parameters -} - -// WorkflowRunActionsClientListOptions contains the optional parameters for the WorkflowRunActionsClient.NewListPager method. -type WorkflowRunActionsClientListOptions struct { - // The filter to apply on the operation. Options for filters include: Status. - Filter *string - // The number of items to be included in the result. - Top *int32 -} - // WorkflowRunFilter - The workflow run filter. type WorkflowRunFilter struct { // The status of workflow run. @@ -3451,11 +2986,6 @@ type WorkflowRunListResult struct { Value []*WorkflowRun } -// WorkflowRunOperationsClientGetOptions contains the optional parameters for the WorkflowRunOperationsClient.Get method. -type WorkflowRunOperationsClientGetOptions struct { - // placeholder for future optional parameters -} - // WorkflowRunProperties - The workflow run properties. type WorkflowRunProperties struct { // The run correlation. @@ -3540,24 +3070,6 @@ type WorkflowRunTrigger struct { TrackingID *string } -// WorkflowRunsClientCancelOptions contains the optional parameters for the WorkflowRunsClient.Cancel method. -type WorkflowRunsClientCancelOptions struct { - // placeholder for future optional parameters -} - -// WorkflowRunsClientGetOptions contains the optional parameters for the WorkflowRunsClient.Get method. -type WorkflowRunsClientGetOptions struct { - // placeholder for future optional parameters -} - -// WorkflowRunsClientListOptions contains the optional parameters for the WorkflowRunsClient.NewListPager method. -type WorkflowRunsClientListOptions struct { - // The filter to apply on the operation. Options for filters include: Status, StartTime, and ClientTrackingId. - Filter *string - // The number of items to be included in the result. - Top *int32 -} - // WorkflowTrigger - The workflow trigger. type WorkflowTrigger struct { // The workflow trigger properties. @@ -3600,26 +3112,6 @@ type WorkflowTriggerFilter struct { State *WorkflowState } -// WorkflowTriggerHistoriesClientGetOptions contains the optional parameters for the WorkflowTriggerHistoriesClient.Get method. -type WorkflowTriggerHistoriesClientGetOptions struct { - // placeholder for future optional parameters -} - -// WorkflowTriggerHistoriesClientListOptions contains the optional parameters for the WorkflowTriggerHistoriesClient.NewListPager -// method. -type WorkflowTriggerHistoriesClientListOptions struct { - // The filter to apply on the operation. Options for filters include: Status, StartTime, and ClientTrackingId. - Filter *string - // The number of items to be included in the result. - Top *int32 -} - -// WorkflowTriggerHistoriesClientResubmitOptions contains the optional parameters for the WorkflowTriggerHistoriesClient.Resubmit -// method. -type WorkflowTriggerHistoriesClientResubmitOptions struct { - // placeholder for future optional parameters -} - // WorkflowTriggerHistory - The workflow trigger history. type WorkflowTriggerHistory struct { // Gets the workflow trigger history properties. @@ -3785,46 +3277,6 @@ type WorkflowTriggerReference struct { Type *string } -// WorkflowTriggersClientGetOptions contains the optional parameters for the WorkflowTriggersClient.Get method. -type WorkflowTriggersClientGetOptions struct { - // placeholder for future optional parameters -} - -// WorkflowTriggersClientGetSchemaJSONOptions contains the optional parameters for the WorkflowTriggersClient.GetSchemaJSON -// method. -type WorkflowTriggersClientGetSchemaJSONOptions struct { - // placeholder for future optional parameters -} - -// WorkflowTriggersClientListCallbackURLOptions contains the optional parameters for the WorkflowTriggersClient.ListCallbackURL -// method. -type WorkflowTriggersClientListCallbackURLOptions struct { - // placeholder for future optional parameters -} - -// WorkflowTriggersClientListOptions contains the optional parameters for the WorkflowTriggersClient.NewListPager method. -type WorkflowTriggersClientListOptions struct { - // The filter to apply on the operation. - Filter *string - // The number of items to be included in the result. - Top *int32 -} - -// WorkflowTriggersClientResetOptions contains the optional parameters for the WorkflowTriggersClient.Reset method. -type WorkflowTriggersClientResetOptions struct { - // placeholder for future optional parameters -} - -// WorkflowTriggersClientRunOptions contains the optional parameters for the WorkflowTriggersClient.Run method. -type WorkflowTriggersClientRunOptions struct { - // placeholder for future optional parameters -} - -// WorkflowTriggersClientSetStateOptions contains the optional parameters for the WorkflowTriggersClient.SetState method. -type WorkflowTriggersClientSetStateOptions struct { - // placeholder for future optional parameters -} - // WorkflowVersion - The workflow version. type WorkflowVersion struct { // The resource location. @@ -3894,111 +3346,6 @@ type WorkflowVersionProperties struct { Version *string } -// WorkflowVersionTriggersClientListCallbackURLOptions contains the optional parameters for the WorkflowVersionTriggersClient.ListCallbackURL -// method. -type WorkflowVersionTriggersClientListCallbackURLOptions struct { - // The callback URL parameters. - Parameters *GetCallbackURLParameters -} - -// WorkflowVersionsClientGetOptions contains the optional parameters for the WorkflowVersionsClient.Get method. -type WorkflowVersionsClientGetOptions struct { - // placeholder for future optional parameters -} - -// WorkflowVersionsClientListOptions contains the optional parameters for the WorkflowVersionsClient.NewListPager method. -type WorkflowVersionsClientListOptions struct { - // The number of items to be included in the result. - Top *int32 -} - -// WorkflowsClientBeginMoveOptions contains the optional parameters for the WorkflowsClient.BeginMove method. -type WorkflowsClientBeginMoveOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// WorkflowsClientCreateOrUpdateOptions contains the optional parameters for the WorkflowsClient.CreateOrUpdate method. -type WorkflowsClientCreateOrUpdateOptions struct { - // placeholder for future optional parameters -} - -// WorkflowsClientDeleteOptions contains the optional parameters for the WorkflowsClient.Delete method. -type WorkflowsClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// WorkflowsClientDisableOptions contains the optional parameters for the WorkflowsClient.Disable method. -type WorkflowsClientDisableOptions struct { - // placeholder for future optional parameters -} - -// WorkflowsClientEnableOptions contains the optional parameters for the WorkflowsClient.Enable method. -type WorkflowsClientEnableOptions struct { - // placeholder for future optional parameters -} - -// WorkflowsClientGenerateUpgradedDefinitionOptions contains the optional parameters for the WorkflowsClient.GenerateUpgradedDefinition -// method. -type WorkflowsClientGenerateUpgradedDefinitionOptions struct { - // placeholder for future optional parameters -} - -// WorkflowsClientGetOptions contains the optional parameters for the WorkflowsClient.Get method. -type WorkflowsClientGetOptions struct { - // placeholder for future optional parameters -} - -// WorkflowsClientListByResourceGroupOptions contains the optional parameters for the WorkflowsClient.NewListByResourceGroupPager -// method. -type WorkflowsClientListByResourceGroupOptions struct { - // The filter to apply on the operation. Options for filters include: State, Trigger, and ReferencedResourceId. - Filter *string - // The number of items to be included in the result. - Top *int32 -} - -// WorkflowsClientListBySubscriptionOptions contains the optional parameters for the WorkflowsClient.NewListBySubscriptionPager -// method. -type WorkflowsClientListBySubscriptionOptions struct { - // The filter to apply on the operation. Options for filters include: State, Trigger, and ReferencedResourceId. - Filter *string - // The number of items to be included in the result. - Top *int32 -} - -// WorkflowsClientListCallbackURLOptions contains the optional parameters for the WorkflowsClient.ListCallbackURL method. -type WorkflowsClientListCallbackURLOptions struct { - // placeholder for future optional parameters -} - -// WorkflowsClientListSwaggerOptions contains the optional parameters for the WorkflowsClient.ListSwagger method. -type WorkflowsClientListSwaggerOptions struct { - // placeholder for future optional parameters -} - -// WorkflowsClientRegenerateAccessKeyOptions contains the optional parameters for the WorkflowsClient.RegenerateAccessKey -// method. -type WorkflowsClientRegenerateAccessKeyOptions struct { - // placeholder for future optional parameters -} - -// WorkflowsClientUpdateOptions contains the optional parameters for the WorkflowsClient.Update method. -type WorkflowsClientUpdateOptions struct { - // placeholder for future optional parameters -} - -// WorkflowsClientValidateByLocationOptions contains the optional parameters for the WorkflowsClient.ValidateByLocation method. -type WorkflowsClientValidateByLocationOptions struct { - // placeholder for future optional parameters -} - -// WorkflowsClientValidateByResourceGroupOptions contains the optional parameters for the WorkflowsClient.ValidateByResourceGroup -// method. -type WorkflowsClientValidateByResourceGroupOptions struct { - // placeholder for future optional parameters -} - // WsdlService - The WSDL service. type WsdlService struct { // The list of endpoints' qualified names. diff --git a/sdk/resourcemanager/logic/armlogic/models_serde.go b/sdk/resourcemanager/logic/armlogic/models_serde.go index b459c0380fd7..d048fb6bfea0 100644 --- a/sdk/resourcemanager/logic/armlogic/models_serde.go +++ b/sdk/resourcemanager/logic/armlogic/models_serde.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -1103,11 +1102,11 @@ func (a *AgreementContent) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ArtifactContentPropertiesDefinition. func (a ArtifactContentPropertiesDefinition) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "changedTime", a.ChangedTime) + populateDateTimeRFC3339(objectMap, "changedTime", a.ChangedTime) populateAny(objectMap, "content", a.Content) populate(objectMap, "contentLink", a.ContentLink) populate(objectMap, "contentType", a.ContentType) - populateTimeRFC3339(objectMap, "createdTime", a.CreatedTime) + populateDateTimeRFC3339(objectMap, "createdTime", a.CreatedTime) populateAny(objectMap, "metadata", a.Metadata) return json.Marshal(objectMap) } @@ -1122,7 +1121,7 @@ func (a *ArtifactContentPropertiesDefinition) UnmarshalJSON(data []byte) error { var err error switch key { case "changedTime": - err = unpopulateTimeRFC3339(val, "ChangedTime", &a.ChangedTime) + err = unpopulateDateTimeRFC3339(val, "ChangedTime", &a.ChangedTime) delete(rawMsg, key) case "content": err = unpopulate(val, "Content", &a.Content) @@ -1134,7 +1133,7 @@ func (a *ArtifactContentPropertiesDefinition) UnmarshalJSON(data []byte) error { err = unpopulate(val, "ContentType", &a.ContentType) delete(rawMsg, key) case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedTime", &a.CreatedTime) + err = unpopulateDateTimeRFC3339(val, "CreatedTime", &a.CreatedTime) delete(rawMsg, key) case "metadata": err = unpopulate(val, "Metadata", &a.Metadata) @@ -1150,8 +1149,8 @@ func (a *ArtifactContentPropertiesDefinition) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type ArtifactProperties. func (a ArtifactProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "changedTime", a.ChangedTime) - populateTimeRFC3339(objectMap, "createdTime", a.CreatedTime) + populateDateTimeRFC3339(objectMap, "changedTime", a.ChangedTime) + populateDateTimeRFC3339(objectMap, "createdTime", a.CreatedTime) populateAny(objectMap, "metadata", a.Metadata) return json.Marshal(objectMap) } @@ -1166,10 +1165,10 @@ func (a *ArtifactProperties) UnmarshalJSON(data []byte) error { var err error switch key { case "changedTime": - err = unpopulateTimeRFC3339(val, "ChangedTime", &a.ChangedTime) + err = unpopulateDateTimeRFC3339(val, "ChangedTime", &a.ChangedTime) delete(rawMsg, key) case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedTime", &a.CreatedTime) + err = unpopulateDateTimeRFC3339(val, "CreatedTime", &a.CreatedTime) delete(rawMsg, key) case "metadata": err = unpopulate(val, "Metadata", &a.Metadata) @@ -1263,11 +1262,11 @@ func (a AssemblyProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "assemblyName", a.AssemblyName) populate(objectMap, "assemblyPublicKeyToken", a.AssemblyPublicKeyToken) populate(objectMap, "assemblyVersion", a.AssemblyVersion) - populateTimeRFC3339(objectMap, "changedTime", a.ChangedTime) + populateDateTimeRFC3339(objectMap, "changedTime", a.ChangedTime) populateAny(objectMap, "content", a.Content) populate(objectMap, "contentLink", a.ContentLink) populate(objectMap, "contentType", a.ContentType) - populateTimeRFC3339(objectMap, "createdTime", a.CreatedTime) + populateDateTimeRFC3339(objectMap, "createdTime", a.CreatedTime) populateAny(objectMap, "metadata", a.Metadata) return json.Marshal(objectMap) } @@ -1294,7 +1293,7 @@ func (a *AssemblyProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "AssemblyVersion", &a.AssemblyVersion) delete(rawMsg, key) case "changedTime": - err = unpopulateTimeRFC3339(val, "ChangedTime", &a.ChangedTime) + err = unpopulateDateTimeRFC3339(val, "ChangedTime", &a.ChangedTime) delete(rawMsg, key) case "content": err = unpopulate(val, "Content", &a.Content) @@ -1306,7 +1305,7 @@ func (a *AssemblyProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "ContentType", &a.ContentType) delete(rawMsg, key) case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedTime", &a.CreatedTime) + err = unpopulateDateTimeRFC3339(val, "CreatedTime", &a.CreatedTime) delete(rawMsg, key) case "metadata": err = unpopulate(val, "Metadata", &a.Metadata) @@ -1459,8 +1458,8 @@ func (b *BatchConfigurationCollection) UnmarshalJSON(data []byte) error { func (b BatchConfigurationProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "batchGroupName", b.BatchGroupName) - populateTimeRFC3339(objectMap, "changedTime", b.ChangedTime) - populateTimeRFC3339(objectMap, "createdTime", b.CreatedTime) + populateDateTimeRFC3339(objectMap, "changedTime", b.ChangedTime) + populateDateTimeRFC3339(objectMap, "createdTime", b.CreatedTime) populateAny(objectMap, "metadata", b.Metadata) populate(objectMap, "releaseCriteria", b.ReleaseCriteria) return json.Marshal(objectMap) @@ -1479,10 +1478,10 @@ func (b *BatchConfigurationProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "BatchGroupName", &b.BatchGroupName) delete(rawMsg, key) case "changedTime": - err = unpopulateTimeRFC3339(val, "ChangedTime", &b.ChangedTime) + err = unpopulateDateTimeRFC3339(val, "ChangedTime", &b.ChangedTime) delete(rawMsg, key) case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedTime", &b.CreatedTime) + err = unpopulateDateTimeRFC3339(val, "CreatedTime", &b.CreatedTime) delete(rawMsg, key) case "metadata": err = unpopulate(val, "Metadata", &b.Metadata) @@ -2958,7 +2957,7 @@ func (g *GenerateUpgradedDefinitionParameters) UnmarshalJSON(data []byte) error func (g GetCallbackURLParameters) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "keyType", g.KeyType) - populateTimeRFC3339(objectMap, "notAfter", g.NotAfter) + populateDateTimeRFC3339(objectMap, "notAfter", g.NotAfter) return json.Marshal(objectMap) } @@ -2975,7 +2974,7 @@ func (g *GetCallbackURLParameters) UnmarshalJSON(data []byte) error { err = unpopulate(val, "KeyType", &g.KeyType) delete(rawMsg, key) case "notAfter": - err = unpopulateTimeRFC3339(val, "NotAfter", &g.NotAfter) + err = unpopulateDateTimeRFC3339(val, "NotAfter", &g.NotAfter) delete(rawMsg, key) } if err != nil { @@ -3199,9 +3198,9 @@ func (i *IntegrationAccountAgreementListResult) UnmarshalJSON(data []byte) error func (i IntegrationAccountAgreementProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "agreementType", i.AgreementType) - populateTimeRFC3339(objectMap, "changedTime", i.ChangedTime) + populateDateTimeRFC3339(objectMap, "changedTime", i.ChangedTime) populate(objectMap, "content", i.Content) - populateTimeRFC3339(objectMap, "createdTime", i.CreatedTime) + populateDateTimeRFC3339(objectMap, "createdTime", i.CreatedTime) populate(objectMap, "guestIdentity", i.GuestIdentity) populate(objectMap, "guestPartner", i.GuestPartner) populate(objectMap, "hostIdentity", i.HostIdentity) @@ -3223,13 +3222,13 @@ func (i *IntegrationAccountAgreementProperties) UnmarshalJSON(data []byte) error err = unpopulate(val, "AgreementType", &i.AgreementType) delete(rawMsg, key) case "changedTime": - err = unpopulateTimeRFC3339(val, "ChangedTime", &i.ChangedTime) + err = unpopulateDateTimeRFC3339(val, "ChangedTime", &i.ChangedTime) delete(rawMsg, key) case "content": err = unpopulate(val, "Content", &i.Content) delete(rawMsg, key) case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedTime", &i.CreatedTime) + err = unpopulateDateTimeRFC3339(val, "CreatedTime", &i.CreatedTime) delete(rawMsg, key) case "guestIdentity": err = unpopulate(val, "GuestIdentity", &i.GuestIdentity) @@ -3335,8 +3334,8 @@ func (i *IntegrationAccountCertificateListResult) UnmarshalJSON(data []byte) err // MarshalJSON implements the json.Marshaller interface for type IntegrationAccountCertificateProperties. func (i IntegrationAccountCertificateProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "changedTime", i.ChangedTime) - populateTimeRFC3339(objectMap, "createdTime", i.CreatedTime) + populateDateTimeRFC3339(objectMap, "changedTime", i.ChangedTime) + populateDateTimeRFC3339(objectMap, "createdTime", i.CreatedTime) populate(objectMap, "key", i.Key) populateAny(objectMap, "metadata", i.Metadata) populate(objectMap, "publicCertificate", i.PublicCertificate) @@ -3353,10 +3352,10 @@ func (i *IntegrationAccountCertificateProperties) UnmarshalJSON(data []byte) err var err error switch key { case "changedTime": - err = unpopulateTimeRFC3339(val, "ChangedTime", &i.ChangedTime) + err = unpopulateDateTimeRFC3339(val, "ChangedTime", &i.ChangedTime) delete(rawMsg, key) case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedTime", &i.CreatedTime) + err = unpopulateDateTimeRFC3339(val, "CreatedTime", &i.CreatedTime) delete(rawMsg, key) case "key": err = unpopulate(val, "Key", &i.Key) @@ -3514,11 +3513,11 @@ func (i *IntegrationAccountMapListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IntegrationAccountMapProperties. func (i IntegrationAccountMapProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "changedTime", i.ChangedTime) + populateDateTimeRFC3339(objectMap, "changedTime", i.ChangedTime) populate(objectMap, "content", i.Content) populate(objectMap, "contentLink", i.ContentLink) populate(objectMap, "contentType", i.ContentType) - populateTimeRFC3339(objectMap, "createdTime", i.CreatedTime) + populateDateTimeRFC3339(objectMap, "createdTime", i.CreatedTime) populate(objectMap, "mapType", i.MapType) populateAny(objectMap, "metadata", i.Metadata) populate(objectMap, "parametersSchema", i.ParametersSchema) @@ -3535,7 +3534,7 @@ func (i *IntegrationAccountMapProperties) UnmarshalJSON(data []byte) error { var err error switch key { case "changedTime": - err = unpopulateTimeRFC3339(val, "ChangedTime", &i.ChangedTime) + err = unpopulateDateTimeRFC3339(val, "ChangedTime", &i.ChangedTime) delete(rawMsg, key) case "content": err = unpopulate(val, "Content", &i.Content) @@ -3547,7 +3546,7 @@ func (i *IntegrationAccountMapProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "ContentType", &i.ContentType) delete(rawMsg, key) case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedTime", &i.CreatedTime) + err = unpopulateDateTimeRFC3339(val, "CreatedTime", &i.CreatedTime) delete(rawMsg, key) case "mapType": err = unpopulate(val, "MapType", &i.MapType) @@ -3701,9 +3700,9 @@ func (i *IntegrationAccountPartnerListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IntegrationAccountPartnerProperties. func (i IntegrationAccountPartnerProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "changedTime", i.ChangedTime) + populateDateTimeRFC3339(objectMap, "changedTime", i.ChangedTime) populate(objectMap, "content", i.Content) - populateTimeRFC3339(objectMap, "createdTime", i.CreatedTime) + populateDateTimeRFC3339(objectMap, "createdTime", i.CreatedTime) populateAny(objectMap, "metadata", i.Metadata) populate(objectMap, "partnerType", i.PartnerType) return json.Marshal(objectMap) @@ -3719,13 +3718,13 @@ func (i *IntegrationAccountPartnerProperties) UnmarshalJSON(data []byte) error { var err error switch key { case "changedTime": - err = unpopulateTimeRFC3339(val, "ChangedTime", &i.ChangedTime) + err = unpopulateDateTimeRFC3339(val, "ChangedTime", &i.ChangedTime) delete(rawMsg, key) case "content": err = unpopulate(val, "Content", &i.Content) delete(rawMsg, key) case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedTime", &i.CreatedTime) + err = unpopulateDateTimeRFC3339(val, "CreatedTime", &i.CreatedTime) delete(rawMsg, key) case "metadata": err = unpopulate(val, "Metadata", &i.Metadata) @@ -3907,11 +3906,11 @@ func (i *IntegrationAccountSchemaListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IntegrationAccountSchemaProperties. func (i IntegrationAccountSchemaProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "changedTime", i.ChangedTime) + populateDateTimeRFC3339(objectMap, "changedTime", i.ChangedTime) populate(objectMap, "content", i.Content) populate(objectMap, "contentLink", i.ContentLink) populate(objectMap, "contentType", i.ContentType) - populateTimeRFC3339(objectMap, "createdTime", i.CreatedTime) + populateDateTimeRFC3339(objectMap, "createdTime", i.CreatedTime) populate(objectMap, "documentName", i.DocumentName) populate(objectMap, "fileName", i.FileName) populateAny(objectMap, "metadata", i.Metadata) @@ -3930,7 +3929,7 @@ func (i *IntegrationAccountSchemaProperties) UnmarshalJSON(data []byte) error { var err error switch key { case "changedTime": - err = unpopulateTimeRFC3339(val, "ChangedTime", &i.ChangedTime) + err = unpopulateDateTimeRFC3339(val, "ChangedTime", &i.ChangedTime) delete(rawMsg, key) case "content": err = unpopulate(val, "Content", &i.Content) @@ -3942,7 +3941,7 @@ func (i *IntegrationAccountSchemaProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "ContentType", &i.ContentType) delete(rawMsg, key) case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedTime", &i.CreatedTime) + err = unpopulateDateTimeRFC3339(val, "CreatedTime", &i.CreatedTime) delete(rawMsg, key) case "documentName": err = unpopulate(val, "DocumentName", &i.DocumentName) @@ -4017,7 +4016,7 @@ func (i *IntegrationAccountSession) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IntegrationAccountSessionFilter. func (i IntegrationAccountSessionFilter) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "changedTime", i.ChangedTime) + populateDateTimeRFC3339(objectMap, "changedTime", i.ChangedTime) return json.Marshal(objectMap) } @@ -4031,7 +4030,7 @@ func (i *IntegrationAccountSessionFilter) UnmarshalJSON(data []byte) error { var err error switch key { case "changedTime": - err = unpopulateTimeRFC3339(val, "ChangedTime", &i.ChangedTime) + err = unpopulateDateTimeRFC3339(val, "ChangedTime", &i.ChangedTime) delete(rawMsg, key) } if err != nil { @@ -4075,9 +4074,9 @@ func (i *IntegrationAccountSessionListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type IntegrationAccountSessionProperties. func (i IntegrationAccountSessionProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "changedTime", i.ChangedTime) + populateDateTimeRFC3339(objectMap, "changedTime", i.ChangedTime) populateAny(objectMap, "content", i.Content) - populateTimeRFC3339(objectMap, "createdTime", i.CreatedTime) + populateDateTimeRFC3339(objectMap, "createdTime", i.CreatedTime) return json.Marshal(objectMap) } @@ -4091,13 +4090,13 @@ func (i *IntegrationAccountSessionProperties) UnmarshalJSON(data []byte) error { var err error switch key { case "changedTime": - err = unpopulateTimeRFC3339(val, "ChangedTime", &i.ChangedTime) + err = unpopulateDateTimeRFC3339(val, "ChangedTime", &i.ChangedTime) delete(rawMsg, key) case "content": err = unpopulate(val, "Content", &i.Content) delete(rawMsg, key) case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedTime", &i.CreatedTime) + err = unpopulateDateTimeRFC3339(val, "CreatedTime", &i.CreatedTime) delete(rawMsg, key) } if err != nil { @@ -5435,7 +5434,7 @@ func (o OperationResult) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "code", o.Code) populate(objectMap, "correlation", o.Correlation) - populateTimeRFC3339(objectMap, "endTime", o.EndTime) + populateDateTimeRFC3339(objectMap, "endTime", o.EndTime) populateAny(objectMap, "error", o.Error) populateAny(objectMap, "inputs", o.Inputs) populate(objectMap, "inputsLink", o.InputsLink) @@ -5443,7 +5442,7 @@ func (o OperationResult) MarshalJSON() ([]byte, error) { populateAny(objectMap, "outputs", o.Outputs) populate(objectMap, "outputsLink", o.OutputsLink) populate(objectMap, "retryHistory", o.RetryHistory) - populateTimeRFC3339(objectMap, "startTime", o.StartTime) + populateDateTimeRFC3339(objectMap, "startTime", o.StartTime) populate(objectMap, "status", o.Status) populateAny(objectMap, "trackedProperties", o.TrackedProperties) populate(objectMap, "trackingId", o.TrackingID) @@ -5466,7 +5465,7 @@ func (o *OperationResult) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Correlation", &o.Correlation) delete(rawMsg, key) case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &o.EndTime) + err = unpopulateDateTimeRFC3339(val, "EndTime", &o.EndTime) delete(rawMsg, key) case "error": err = unpopulate(val, "Error", &o.Error) @@ -5490,7 +5489,7 @@ func (o *OperationResult) UnmarshalJSON(data []byte) error { err = unpopulate(val, "RetryHistory", &o.RetryHistory) delete(rawMsg, key) case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &o.StartTime) + err = unpopulateDateTimeRFC3339(val, "StartTime", &o.StartTime) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &o.Status) @@ -5514,9 +5513,9 @@ func (o OperationResultProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "code", o.Code) populate(objectMap, "correlation", o.Correlation) - populateTimeRFC3339(objectMap, "endTime", o.EndTime) + populateDateTimeRFC3339(objectMap, "endTime", o.EndTime) populateAny(objectMap, "error", o.Error) - populateTimeRFC3339(objectMap, "startTime", o.StartTime) + populateDateTimeRFC3339(objectMap, "startTime", o.StartTime) populate(objectMap, "status", o.Status) return json.Marshal(objectMap) } @@ -5537,13 +5536,13 @@ func (o *OperationResultProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Correlation", &o.Correlation) delete(rawMsg, key) case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &o.EndTime) + err = unpopulateDateTimeRFC3339(val, "EndTime", &o.EndTime) delete(rawMsg, key) case "error": err = unpopulate(val, "Error", &o.Error) delete(rawMsg, key) case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &o.StartTime) + err = unpopulateDateTimeRFC3339(val, "StartTime", &o.StartTime) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &o.Status) @@ -5831,10 +5830,10 @@ func (r *RequestHistoryListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type RequestHistoryProperties. func (r RequestHistoryProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "endTime", r.EndTime) + populateDateTimeRFC3339(objectMap, "endTime", r.EndTime) populate(objectMap, "request", r.Request) populate(objectMap, "response", r.Response) - populateTimeRFC3339(objectMap, "startTime", r.StartTime) + populateDateTimeRFC3339(objectMap, "startTime", r.StartTime) return json.Marshal(objectMap) } @@ -5848,7 +5847,7 @@ func (r *RequestHistoryProperties) UnmarshalJSON(data []byte) error { var err error switch key { case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &r.EndTime) + err = unpopulateDateTimeRFC3339(val, "EndTime", &r.EndTime) delete(rawMsg, key) case "request": err = unpopulate(val, "Request", &r.Request) @@ -5857,7 +5856,7 @@ func (r *RequestHistoryProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Response", &r.Response) delete(rawMsg, key) case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &r.StartTime) + err = unpopulateDateTimeRFC3339(val, "StartTime", &r.StartTime) delete(rawMsg, key) } if err != nil { @@ -5985,10 +5984,10 @@ func (r RetryHistory) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "clientRequestId", r.ClientRequestID) populate(objectMap, "code", r.Code) - populateTimeRFC3339(objectMap, "endTime", r.EndTime) + populateDateTimeRFC3339(objectMap, "endTime", r.EndTime) populate(objectMap, "error", r.Error) populate(objectMap, "serviceRequestId", r.ServiceRequestID) - populateTimeRFC3339(objectMap, "startTime", r.StartTime) + populateDateTimeRFC3339(objectMap, "startTime", r.StartTime) return json.Marshal(objectMap) } @@ -6008,7 +6007,7 @@ func (r *RetryHistory) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Code", &r.Code) delete(rawMsg, key) case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &r.EndTime) + err = unpopulateDateTimeRFC3339(val, "EndTime", &r.EndTime) delete(rawMsg, key) case "error": err = unpopulate(val, "Error", &r.Error) @@ -6017,7 +6016,7 @@ func (r *RetryHistory) UnmarshalJSON(data []byte) error { err = unpopulate(val, "ServiceRequestID", &r.ServiceRequestID) delete(rawMsg, key) case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &r.StartTime) + err = unpopulateDateTimeRFC3339(val, "StartTime", &r.StartTime) delete(rawMsg, key) } if err != nil { @@ -6645,7 +6644,7 @@ func (t TrackingEvent) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "error", t.Error) populate(objectMap, "eventLevel", t.EventLevel) - populateTimeRFC3339(objectMap, "eventTime", t.EventTime) + populateDateTimeRFC3339(objectMap, "eventTime", t.EventTime) populateAny(objectMap, "record", t.Record) populate(objectMap, "recordType", t.RecordType) return json.Marshal(objectMap) @@ -6667,7 +6666,7 @@ func (t *TrackingEvent) UnmarshalJSON(data []byte) error { err = unpopulate(val, "EventLevel", &t.EventLevel) delete(rawMsg, key) case "eventTime": - err = unpopulateTimeRFC3339(val, "EventTime", &t.EventTime) + err = unpopulateDateTimeRFC3339(val, "EventTime", &t.EventTime) delete(rawMsg, key) case "record": err = unpopulate(val, "Record", &t.Record) @@ -6976,8 +6975,8 @@ func (w WorkflowProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "accessControl", w.AccessControl) populate(objectMap, "accessEndpoint", w.AccessEndpoint) - populateTimeRFC3339(objectMap, "changedTime", w.ChangedTime) - populateTimeRFC3339(objectMap, "createdTime", w.CreatedTime) + populateDateTimeRFC3339(objectMap, "changedTime", w.ChangedTime) + populateDateTimeRFC3339(objectMap, "createdTime", w.CreatedTime) populateAny(objectMap, "definition", w.Definition) populate(objectMap, "endpointsConfiguration", w.EndpointsConfiguration) populate(objectMap, "integrationAccount", w.IntegrationAccount) @@ -7006,10 +7005,10 @@ func (w *WorkflowProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "AccessEndpoint", &w.AccessEndpoint) delete(rawMsg, key) case "changedTime": - err = unpopulateTimeRFC3339(val, "ChangedTime", &w.ChangedTime) + err = unpopulateDateTimeRFC3339(val, "ChangedTime", &w.ChangedTime) delete(rawMsg, key) case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedTime", &w.CreatedTime) + err = unpopulateDateTimeRFC3339(val, "CreatedTime", &w.CreatedTime) delete(rawMsg, key) case "definition": err = unpopulate(val, "Definition", &w.Definition) @@ -7222,12 +7221,12 @@ func (w WorkflowRunActionProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "code", w.Code) populate(objectMap, "correlation", w.Correlation) - populateTimeRFC3339(objectMap, "endTime", w.EndTime) + populateDateTimeRFC3339(objectMap, "endTime", w.EndTime) populateAny(objectMap, "error", w.Error) populate(objectMap, "inputsLink", w.InputsLink) populate(objectMap, "outputsLink", w.OutputsLink) populate(objectMap, "retryHistory", w.RetryHistory) - populateTimeRFC3339(objectMap, "startTime", w.StartTime) + populateDateTimeRFC3339(objectMap, "startTime", w.StartTime) populate(objectMap, "status", w.Status) populateAny(objectMap, "trackedProperties", w.TrackedProperties) populate(objectMap, "trackingId", w.TrackingID) @@ -7250,7 +7249,7 @@ func (w *WorkflowRunActionProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Correlation", &w.Correlation) delete(rawMsg, key) case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &w.EndTime) + err = unpopulateDateTimeRFC3339(val, "EndTime", &w.EndTime) delete(rawMsg, key) case "error": err = unpopulate(val, "Error", &w.Error) @@ -7265,7 +7264,7 @@ func (w *WorkflowRunActionProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "RetryHistory", &w.RetryHistory) delete(rawMsg, key) case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &w.StartTime) + err = unpopulateDateTimeRFC3339(val, "StartTime", &w.StartTime) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &w.Status) @@ -7367,7 +7366,7 @@ func (w WorkflowRunActionRepetitionProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "code", w.Code) populate(objectMap, "correlation", w.Correlation) - populateTimeRFC3339(objectMap, "endTime", w.EndTime) + populateDateTimeRFC3339(objectMap, "endTime", w.EndTime) populateAny(objectMap, "error", w.Error) populateAny(objectMap, "inputs", w.Inputs) populate(objectMap, "inputsLink", w.InputsLink) @@ -7376,7 +7375,7 @@ func (w WorkflowRunActionRepetitionProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "outputsLink", w.OutputsLink) populate(objectMap, "repetitionIndexes", w.RepetitionIndexes) populate(objectMap, "retryHistory", w.RetryHistory) - populateTimeRFC3339(objectMap, "startTime", w.StartTime) + populateDateTimeRFC3339(objectMap, "startTime", w.StartTime) populate(objectMap, "status", w.Status) populateAny(objectMap, "trackedProperties", w.TrackedProperties) populate(objectMap, "trackingId", w.TrackingID) @@ -7399,7 +7398,7 @@ func (w *WorkflowRunActionRepetitionProperties) UnmarshalJSON(data []byte) error err = unpopulate(val, "Correlation", &w.Correlation) delete(rawMsg, key) case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &w.EndTime) + err = unpopulateDateTimeRFC3339(val, "EndTime", &w.EndTime) delete(rawMsg, key) case "error": err = unpopulate(val, "Error", &w.Error) @@ -7426,7 +7425,7 @@ func (w *WorkflowRunActionRepetitionProperties) UnmarshalJSON(data []byte) error err = unpopulate(val, "RetryHistory", &w.RetryHistory) delete(rawMsg, key) case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &w.StartTime) + err = unpopulateDateTimeRFC3339(val, "StartTime", &w.StartTime) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &w.Status) @@ -7509,14 +7508,14 @@ func (w WorkflowRunProperties) MarshalJSON() ([]byte, error) { populate(objectMap, "code", w.Code) populate(objectMap, "correlation", w.Correlation) populate(objectMap, "correlationId", w.CorrelationID) - populateTimeRFC3339(objectMap, "endTime", w.EndTime) + populateDateTimeRFC3339(objectMap, "endTime", w.EndTime) populateAny(objectMap, "error", w.Error) populate(objectMap, "outputs", w.Outputs) populate(objectMap, "response", w.Response) - populateTimeRFC3339(objectMap, "startTime", w.StartTime) + populateDateTimeRFC3339(objectMap, "startTime", w.StartTime) populate(objectMap, "status", w.Status) populate(objectMap, "trigger", w.Trigger) - populateTimeRFC3339(objectMap, "waitEndTime", w.WaitEndTime) + populateDateTimeRFC3339(objectMap, "waitEndTime", w.WaitEndTime) populate(objectMap, "workflow", w.Workflow) return json.Marshal(objectMap) } @@ -7540,7 +7539,7 @@ func (w *WorkflowRunProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "CorrelationID", &w.CorrelationID) delete(rawMsg, key) case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &w.EndTime) + err = unpopulateDateTimeRFC3339(val, "EndTime", &w.EndTime) delete(rawMsg, key) case "error": err = unpopulate(val, "Error", &w.Error) @@ -7552,7 +7551,7 @@ func (w *WorkflowRunProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Response", &w.Response) delete(rawMsg, key) case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &w.StartTime) + err = unpopulateDateTimeRFC3339(val, "StartTime", &w.StartTime) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &w.Status) @@ -7561,7 +7560,7 @@ func (w *WorkflowRunProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Trigger", &w.Trigger) delete(rawMsg, key) case "waitEndTime": - err = unpopulateTimeRFC3339(val, "WaitEndTime", &w.WaitEndTime) + err = unpopulateDateTimeRFC3339(val, "WaitEndTime", &w.WaitEndTime) delete(rawMsg, key) case "workflow": err = unpopulate(val, "Workflow", &w.Workflow) @@ -7579,15 +7578,15 @@ func (w WorkflowRunTrigger) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "code", w.Code) populate(objectMap, "correlation", w.Correlation) - populateTimeRFC3339(objectMap, "endTime", w.EndTime) + populateDateTimeRFC3339(objectMap, "endTime", w.EndTime) populateAny(objectMap, "error", w.Error) populateAny(objectMap, "inputs", w.Inputs) populate(objectMap, "inputsLink", w.InputsLink) populate(objectMap, "name", w.Name) populateAny(objectMap, "outputs", w.Outputs) populate(objectMap, "outputsLink", w.OutputsLink) - populateTimeRFC3339(objectMap, "scheduledTime", w.ScheduledTime) - populateTimeRFC3339(objectMap, "startTime", w.StartTime) + populateDateTimeRFC3339(objectMap, "scheduledTime", w.ScheduledTime) + populateDateTimeRFC3339(objectMap, "startTime", w.StartTime) populate(objectMap, "status", w.Status) populateAny(objectMap, "trackedProperties", w.TrackedProperties) populate(objectMap, "trackingId", w.TrackingID) @@ -7610,7 +7609,7 @@ func (w *WorkflowRunTrigger) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Correlation", &w.Correlation) delete(rawMsg, key) case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &w.EndTime) + err = unpopulateDateTimeRFC3339(val, "EndTime", &w.EndTime) delete(rawMsg, key) case "error": err = unpopulate(val, "Error", &w.Error) @@ -7631,10 +7630,10 @@ func (w *WorkflowRunTrigger) UnmarshalJSON(data []byte) error { err = unpopulate(val, "OutputsLink", &w.OutputsLink) delete(rawMsg, key) case "scheduledTime": - err = unpopulateTimeRFC3339(val, "ScheduledTime", &w.ScheduledTime) + err = unpopulateDateTimeRFC3339(val, "ScheduledTime", &w.ScheduledTime) delete(rawMsg, key) case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &w.StartTime) + err = unpopulateDateTimeRFC3339(val, "StartTime", &w.StartTime) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &w.Status) @@ -7868,14 +7867,14 @@ func (w WorkflowTriggerHistoryProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "code", w.Code) populate(objectMap, "correlation", w.Correlation) - populateTimeRFC3339(objectMap, "endTime", w.EndTime) + populateDateTimeRFC3339(objectMap, "endTime", w.EndTime) populateAny(objectMap, "error", w.Error) populate(objectMap, "fired", w.Fired) populate(objectMap, "inputsLink", w.InputsLink) populate(objectMap, "outputsLink", w.OutputsLink) populate(objectMap, "run", w.Run) - populateTimeRFC3339(objectMap, "scheduledTime", w.ScheduledTime) - populateTimeRFC3339(objectMap, "startTime", w.StartTime) + populateDateTimeRFC3339(objectMap, "scheduledTime", w.ScheduledTime) + populateDateTimeRFC3339(objectMap, "startTime", w.StartTime) populate(objectMap, "status", w.Status) populate(objectMap, "trackingId", w.TrackingID) return json.Marshal(objectMap) @@ -7897,7 +7896,7 @@ func (w *WorkflowTriggerHistoryProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Correlation", &w.Correlation) delete(rawMsg, key) case "endTime": - err = unpopulateTimeRFC3339(val, "EndTime", &w.EndTime) + err = unpopulateDateTimeRFC3339(val, "EndTime", &w.EndTime) delete(rawMsg, key) case "error": err = unpopulate(val, "Error", &w.Error) @@ -7915,10 +7914,10 @@ func (w *WorkflowTriggerHistoryProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "Run", &w.Run) delete(rawMsg, key) case "scheduledTime": - err = unpopulateTimeRFC3339(val, "ScheduledTime", &w.ScheduledTime) + err = unpopulateDateTimeRFC3339(val, "ScheduledTime", &w.ScheduledTime) delete(rawMsg, key) case "startTime": - err = unpopulateTimeRFC3339(val, "StartTime", &w.StartTime) + err = unpopulateDateTimeRFC3339(val, "StartTime", &w.StartTime) delete(rawMsg, key) case "status": err = unpopulate(val, "Status", &w.Status) @@ -8011,10 +8010,10 @@ func (w *WorkflowTriggerListResult) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type WorkflowTriggerProperties. func (w WorkflowTriggerProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "changedTime", w.ChangedTime) - populateTimeRFC3339(objectMap, "createdTime", w.CreatedTime) - populateTimeRFC3339(objectMap, "lastExecutionTime", w.LastExecutionTime) - populateTimeRFC3339(objectMap, "nextExecutionTime", w.NextExecutionTime) + populateDateTimeRFC3339(objectMap, "changedTime", w.ChangedTime) + populateDateTimeRFC3339(objectMap, "createdTime", w.CreatedTime) + populateDateTimeRFC3339(objectMap, "lastExecutionTime", w.LastExecutionTime) + populateDateTimeRFC3339(objectMap, "nextExecutionTime", w.NextExecutionTime) populate(objectMap, "provisioningState", w.ProvisioningState) populate(objectMap, "recurrence", w.Recurrence) populate(objectMap, "state", w.State) @@ -8033,16 +8032,16 @@ func (w *WorkflowTriggerProperties) UnmarshalJSON(data []byte) error { var err error switch key { case "changedTime": - err = unpopulateTimeRFC3339(val, "ChangedTime", &w.ChangedTime) + err = unpopulateDateTimeRFC3339(val, "ChangedTime", &w.ChangedTime) delete(rawMsg, key) case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedTime", &w.CreatedTime) + err = unpopulateDateTimeRFC3339(val, "CreatedTime", &w.CreatedTime) delete(rawMsg, key) case "lastExecutionTime": - err = unpopulateTimeRFC3339(val, "LastExecutionTime", &w.LastExecutionTime) + err = unpopulateDateTimeRFC3339(val, "LastExecutionTime", &w.LastExecutionTime) delete(rawMsg, key) case "nextExecutionTime": - err = unpopulateTimeRFC3339(val, "NextExecutionTime", &w.NextExecutionTime) + err = unpopulateDateTimeRFC3339(val, "NextExecutionTime", &w.NextExecutionTime) delete(rawMsg, key) case "provisioningState": err = unpopulate(val, "ProvisioningState", &w.ProvisioningState) @@ -8240,8 +8239,8 @@ func (w WorkflowVersionProperties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "accessControl", w.AccessControl) populate(objectMap, "accessEndpoint", w.AccessEndpoint) - populateTimeRFC3339(objectMap, "changedTime", w.ChangedTime) - populateTimeRFC3339(objectMap, "createdTime", w.CreatedTime) + populateDateTimeRFC3339(objectMap, "changedTime", w.ChangedTime) + populateDateTimeRFC3339(objectMap, "createdTime", w.CreatedTime) populateAny(objectMap, "definition", w.Definition) populate(objectMap, "endpointsConfiguration", w.EndpointsConfiguration) populate(objectMap, "integrationAccount", w.IntegrationAccount) @@ -8269,10 +8268,10 @@ func (w *WorkflowVersionProperties) UnmarshalJSON(data []byte) error { err = unpopulate(val, "AccessEndpoint", &w.AccessEndpoint) delete(rawMsg, key) case "changedTime": - err = unpopulateTimeRFC3339(val, "ChangedTime", &w.ChangedTime) + err = unpopulateDateTimeRFC3339(val, "ChangedTime", &w.ChangedTime) delete(rawMsg, key) case "createdTime": - err = unpopulateTimeRFC3339(val, "CreatedTime", &w.CreatedTime) + err = unpopulateDateTimeRFC3339(val, "CreatedTime", &w.CreatedTime) delete(rawMsg, key) case "definition": err = unpopulate(val, "Definition", &w.Definition) diff --git a/sdk/resourcemanager/logic/armlogic/operations_client.go b/sdk/resourcemanager/logic/armlogic/operations_client.go index eb8649adec45..5335e6576293 100644 --- a/sdk/resourcemanager/logic/armlogic/operations_client.go +++ b/sdk/resourcemanager/logic/armlogic/operations_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -28,7 +27,7 @@ type OperationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -48,25 +47,20 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.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, options) + }, nil) if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return OperationsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OperationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/logic/armlogic/operations_live_test.go b/sdk/resourcemanager/logic/armlogic/operations_live_test.go index 8cf51707e113..0131dd00c10f 100644 --- a/sdk/resourcemanager/logic/armlogic/operations_live_test.go +++ b/sdk/resourcemanager/logic/armlogic/operations_live_test.go @@ -13,7 +13,8 @@ import ( "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/resourcemanager/internal/testutil" + "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2/testutil" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/logic/armlogic" "github.com/stretchr/testify/suite" ) @@ -34,9 +35,9 @@ func (testsuite *OperationsTestSuite) SetupSuite() { testsuite.ctx = context.Background() testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T()) - testsuite.location = testutil.GetEnv("LOCATION", "westus") - testsuite.resourceGroupName = testutil.GetEnv("RESOURCE_GROUP_NAME", "scenarioTestTempGroup") - testsuite.subscriptionId = testutil.GetEnv("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + testsuite.location = recording.GetEnvVariable("LOCATION", "westus") + testsuite.resourceGroupName = recording.GetEnvVariable("RESOURCE_GROUP_NAME", "scenarioTestTempGroup") + testsuite.subscriptionId = recording.GetEnvVariable("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") resourceGroup, _, err := testutil.CreateResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.location) testsuite.Require().NoError(err) testsuite.resourceGroupName = *resourceGroup.Name diff --git a/sdk/resourcemanager/logic/armlogic/options.go b/sdk/resourcemanager/logic/armlogic/options.go new file mode 100644 index 000000000000..3a263e2a01d1 --- /dev/null +++ b/sdk/resourcemanager/logic/armlogic/options.go @@ -0,0 +1,672 @@ +//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 armlogic + +// IntegrationAccountAgreementsClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountAgreementsClient.CreateOrUpdate +// method. +type IntegrationAccountAgreementsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountAgreementsClientDeleteOptions contains the optional parameters for the IntegrationAccountAgreementsClient.Delete +// method. +type IntegrationAccountAgreementsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountAgreementsClientGetOptions contains the optional parameters for the IntegrationAccountAgreementsClient.Get +// method. +type IntegrationAccountAgreementsClientGetOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountAgreementsClientListContentCallbackURLOptions contains the optional parameters for the IntegrationAccountAgreementsClient.ListContentCallbackURL +// method. +type IntegrationAccountAgreementsClientListContentCallbackURLOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountAgreementsClientListOptions contains the optional parameters for the IntegrationAccountAgreementsClient.NewListPager +// method. +type IntegrationAccountAgreementsClientListOptions struct { + // The filter to apply on the operation. Options for filters include: AgreementType. + Filter *string + + // The number of items to be included in the result. + Top *int32 +} + +// IntegrationAccountAssembliesClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountAssembliesClient.CreateOrUpdate +// method. +type IntegrationAccountAssembliesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountAssembliesClientDeleteOptions contains the optional parameters for the IntegrationAccountAssembliesClient.Delete +// method. +type IntegrationAccountAssembliesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountAssembliesClientGetOptions contains the optional parameters for the IntegrationAccountAssembliesClient.Get +// method. +type IntegrationAccountAssembliesClientGetOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountAssembliesClientListContentCallbackURLOptions contains the optional parameters for the IntegrationAccountAssembliesClient.ListContentCallbackURL +// method. +type IntegrationAccountAssembliesClientListContentCallbackURLOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountAssembliesClientListOptions contains the optional parameters for the IntegrationAccountAssembliesClient.NewListPager +// method. +type IntegrationAccountAssembliesClientListOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountBatchConfigurationsClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountBatchConfigurationsClient.CreateOrUpdate +// method. +type IntegrationAccountBatchConfigurationsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountBatchConfigurationsClientDeleteOptions contains the optional parameters for the IntegrationAccountBatchConfigurationsClient.Delete +// method. +type IntegrationAccountBatchConfigurationsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountBatchConfigurationsClientGetOptions contains the optional parameters for the IntegrationAccountBatchConfigurationsClient.Get +// method. +type IntegrationAccountBatchConfigurationsClientGetOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountBatchConfigurationsClientListOptions contains the optional parameters for the IntegrationAccountBatchConfigurationsClient.NewListPager +// method. +type IntegrationAccountBatchConfigurationsClientListOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountCertificatesClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountCertificatesClient.CreateOrUpdate +// method. +type IntegrationAccountCertificatesClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountCertificatesClientDeleteOptions contains the optional parameters for the IntegrationAccountCertificatesClient.Delete +// method. +type IntegrationAccountCertificatesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountCertificatesClientGetOptions contains the optional parameters for the IntegrationAccountCertificatesClient.Get +// method. +type IntegrationAccountCertificatesClientGetOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountCertificatesClientListOptions contains the optional parameters for the IntegrationAccountCertificatesClient.NewListPager +// method. +type IntegrationAccountCertificatesClientListOptions struct { + // The number of items to be included in the result. + Top *int32 +} + +// IntegrationAccountMapsClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountMapsClient.CreateOrUpdate +// method. +type IntegrationAccountMapsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountMapsClientDeleteOptions contains the optional parameters for the IntegrationAccountMapsClient.Delete +// method. +type IntegrationAccountMapsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountMapsClientGetOptions contains the optional parameters for the IntegrationAccountMapsClient.Get method. +type IntegrationAccountMapsClientGetOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountMapsClientListContentCallbackURLOptions contains the optional parameters for the IntegrationAccountMapsClient.ListContentCallbackURL +// method. +type IntegrationAccountMapsClientListContentCallbackURLOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountMapsClientListOptions contains the optional parameters for the IntegrationAccountMapsClient.NewListPager +// method. +type IntegrationAccountMapsClientListOptions struct { + // The filter to apply on the operation. Options for filters include: MapType. + Filter *string + + // The number of items to be included in the result. + Top *int32 +} + +// IntegrationAccountPartnersClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountPartnersClient.CreateOrUpdate +// method. +type IntegrationAccountPartnersClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountPartnersClientDeleteOptions contains the optional parameters for the IntegrationAccountPartnersClient.Delete +// method. +type IntegrationAccountPartnersClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountPartnersClientGetOptions contains the optional parameters for the IntegrationAccountPartnersClient.Get +// method. +type IntegrationAccountPartnersClientGetOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountPartnersClientListContentCallbackURLOptions contains the optional parameters for the IntegrationAccountPartnersClient.ListContentCallbackURL +// method. +type IntegrationAccountPartnersClientListContentCallbackURLOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountPartnersClientListOptions contains the optional parameters for the IntegrationAccountPartnersClient.NewListPager +// method. +type IntegrationAccountPartnersClientListOptions struct { + // The filter to apply on the operation. Options for filters include: PartnerType. + Filter *string + + // The number of items to be included in the result. + Top *int32 +} + +// IntegrationAccountSchemasClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountSchemasClient.CreateOrUpdate +// method. +type IntegrationAccountSchemasClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountSchemasClientDeleteOptions contains the optional parameters for the IntegrationAccountSchemasClient.Delete +// method. +type IntegrationAccountSchemasClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountSchemasClientGetOptions contains the optional parameters for the IntegrationAccountSchemasClient.Get +// method. +type IntegrationAccountSchemasClientGetOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountSchemasClientListContentCallbackURLOptions contains the optional parameters for the IntegrationAccountSchemasClient.ListContentCallbackURL +// method. +type IntegrationAccountSchemasClientListContentCallbackURLOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountSchemasClientListOptions contains the optional parameters for the IntegrationAccountSchemasClient.NewListPager +// method. +type IntegrationAccountSchemasClientListOptions struct { + // The filter to apply on the operation. Options for filters include: SchemaType. + Filter *string + + // The number of items to be included in the result. + Top *int32 +} + +// IntegrationAccountSessionsClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountSessionsClient.CreateOrUpdate +// method. +type IntegrationAccountSessionsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountSessionsClientDeleteOptions contains the optional parameters for the IntegrationAccountSessionsClient.Delete +// method. +type IntegrationAccountSessionsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountSessionsClientGetOptions contains the optional parameters for the IntegrationAccountSessionsClient.Get +// method. +type IntegrationAccountSessionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountSessionsClientListOptions contains the optional parameters for the IntegrationAccountSessionsClient.NewListPager +// method. +type IntegrationAccountSessionsClientListOptions struct { + // The filter to apply on the operation. Options for filters include: ChangedTime. + Filter *string + + // The number of items to be included in the result. + Top *int32 +} + +// IntegrationAccountsClientCreateOrUpdateOptions contains the optional parameters for the IntegrationAccountsClient.CreateOrUpdate +// method. +type IntegrationAccountsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountsClientDeleteOptions contains the optional parameters for the IntegrationAccountsClient.Delete method. +type IntegrationAccountsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountsClientGetOptions contains the optional parameters for the IntegrationAccountsClient.Get method. +type IntegrationAccountsClientGetOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountsClientListByResourceGroupOptions contains the optional parameters for the IntegrationAccountsClient.NewListByResourceGroupPager +// method. +type IntegrationAccountsClientListByResourceGroupOptions struct { + // The number of items to be included in the result. + Top *int32 +} + +// IntegrationAccountsClientListBySubscriptionOptions contains the optional parameters for the IntegrationAccountsClient.NewListBySubscriptionPager +// method. +type IntegrationAccountsClientListBySubscriptionOptions struct { + // The number of items to be included in the result. + Top *int32 +} + +// IntegrationAccountsClientListCallbackURLOptions contains the optional parameters for the IntegrationAccountsClient.ListCallbackURL +// method. +type IntegrationAccountsClientListCallbackURLOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountsClientListKeyVaultKeysOptions contains the optional parameters for the IntegrationAccountsClient.NewListKeyVaultKeysPager +// method. +type IntegrationAccountsClientListKeyVaultKeysOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountsClientLogTrackingEventsOptions contains the optional parameters for the IntegrationAccountsClient.LogTrackingEvents +// method. +type IntegrationAccountsClientLogTrackingEventsOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountsClientRegenerateAccessKeyOptions contains the optional parameters for the IntegrationAccountsClient.RegenerateAccessKey +// method. +type IntegrationAccountsClientRegenerateAccessKeyOptions struct { + // placeholder for future optional parameters +} + +// IntegrationAccountsClientUpdateOptions contains the optional parameters for the IntegrationAccountsClient.Update method. +type IntegrationAccountsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// IntegrationServiceEnvironmentManagedAPIOperationsClientListOptions contains the optional parameters for the IntegrationServiceEnvironmentManagedAPIOperationsClient.NewListPager +// method. +type IntegrationServiceEnvironmentManagedAPIOperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// IntegrationServiceEnvironmentManagedApisClientBeginDeleteOptions contains the optional parameters for the IntegrationServiceEnvironmentManagedApisClient.BeginDelete +// method. +type IntegrationServiceEnvironmentManagedApisClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// IntegrationServiceEnvironmentManagedApisClientBeginPutOptions contains the optional parameters for the IntegrationServiceEnvironmentManagedApisClient.BeginPut +// method. +type IntegrationServiceEnvironmentManagedApisClientBeginPutOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// IntegrationServiceEnvironmentManagedApisClientGetOptions contains the optional parameters for the IntegrationServiceEnvironmentManagedApisClient.Get +// method. +type IntegrationServiceEnvironmentManagedApisClientGetOptions struct { + // placeholder for future optional parameters +} + +// IntegrationServiceEnvironmentManagedApisClientListOptions contains the optional parameters for the IntegrationServiceEnvironmentManagedApisClient.NewListPager +// method. +type IntegrationServiceEnvironmentManagedApisClientListOptions struct { + // placeholder for future optional parameters +} + +// IntegrationServiceEnvironmentNetworkHealthClientGetOptions contains the optional parameters for the IntegrationServiceEnvironmentNetworkHealthClient.Get +// method. +type IntegrationServiceEnvironmentNetworkHealthClientGetOptions struct { + // placeholder for future optional parameters +} + +// IntegrationServiceEnvironmentSKUsClientListOptions contains the optional parameters for the IntegrationServiceEnvironmentSKUsClient.NewListPager +// method. +type IntegrationServiceEnvironmentSKUsClientListOptions struct { + // placeholder for future optional parameters +} + +// IntegrationServiceEnvironmentsClientBeginCreateOrUpdateOptions contains the optional parameters for the IntegrationServiceEnvironmentsClient.BeginCreateOrUpdate +// method. +type IntegrationServiceEnvironmentsClientBeginCreateOrUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// IntegrationServiceEnvironmentsClientBeginUpdateOptions contains the optional parameters for the IntegrationServiceEnvironmentsClient.BeginUpdate +// method. +type IntegrationServiceEnvironmentsClientBeginUpdateOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// IntegrationServiceEnvironmentsClientDeleteOptions contains the optional parameters for the IntegrationServiceEnvironmentsClient.Delete +// method. +type IntegrationServiceEnvironmentsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// IntegrationServiceEnvironmentsClientGetOptions contains the optional parameters for the IntegrationServiceEnvironmentsClient.Get +// method. +type IntegrationServiceEnvironmentsClientGetOptions struct { + // placeholder for future optional parameters +} + +// IntegrationServiceEnvironmentsClientListByResourceGroupOptions contains the optional parameters for the IntegrationServiceEnvironmentsClient.NewListByResourceGroupPager +// method. +type IntegrationServiceEnvironmentsClientListByResourceGroupOptions struct { + // The number of items to be included in the result. + Top *int32 +} + +// IntegrationServiceEnvironmentsClientListBySubscriptionOptions contains the optional parameters for the IntegrationServiceEnvironmentsClient.NewListBySubscriptionPager +// method. +type IntegrationServiceEnvironmentsClientListBySubscriptionOptions struct { + // The number of items to be included in the result. + Top *int32 +} + +// IntegrationServiceEnvironmentsClientRestartOptions contains the optional parameters for the IntegrationServiceEnvironmentsClient.Restart +// method. +type IntegrationServiceEnvironmentsClientRestartOptions struct { + // placeholder for future optional parameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// WorkflowRunActionRepetitionsClientGetOptions contains the optional parameters for the WorkflowRunActionRepetitionsClient.Get +// method. +type WorkflowRunActionRepetitionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkflowRunActionRepetitionsClientListExpressionTracesOptions contains the optional parameters for the WorkflowRunActionRepetitionsClient.NewListExpressionTracesPager +// method. +type WorkflowRunActionRepetitionsClientListExpressionTracesOptions struct { + // placeholder for future optional parameters +} + +// WorkflowRunActionRepetitionsClientListOptions contains the optional parameters for the WorkflowRunActionRepetitionsClient.NewListPager +// method. +type WorkflowRunActionRepetitionsClientListOptions struct { + // placeholder for future optional parameters +} + +// WorkflowRunActionRepetitionsRequestHistoriesClientGetOptions contains the optional parameters for the WorkflowRunActionRepetitionsRequestHistoriesClient.Get +// method. +type WorkflowRunActionRepetitionsRequestHistoriesClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkflowRunActionRepetitionsRequestHistoriesClientListOptions contains the optional parameters for the WorkflowRunActionRepetitionsRequestHistoriesClient.NewListPager +// method. +type WorkflowRunActionRepetitionsRequestHistoriesClientListOptions struct { + // placeholder for future optional parameters +} + +// WorkflowRunActionRequestHistoriesClientGetOptions contains the optional parameters for the WorkflowRunActionRequestHistoriesClient.Get +// method. +type WorkflowRunActionRequestHistoriesClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkflowRunActionRequestHistoriesClientListOptions contains the optional parameters for the WorkflowRunActionRequestHistoriesClient.NewListPager +// method. +type WorkflowRunActionRequestHistoriesClientListOptions struct { + // placeholder for future optional parameters +} + +// WorkflowRunActionScopeRepetitionsClientGetOptions contains the optional parameters for the WorkflowRunActionScopeRepetitionsClient.Get +// method. +type WorkflowRunActionScopeRepetitionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkflowRunActionScopeRepetitionsClientListOptions contains the optional parameters for the WorkflowRunActionScopeRepetitionsClient.NewListPager +// method. +type WorkflowRunActionScopeRepetitionsClientListOptions struct { + // placeholder for future optional parameters +} + +// WorkflowRunActionsClientGetOptions contains the optional parameters for the WorkflowRunActionsClient.Get method. +type WorkflowRunActionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkflowRunActionsClientListExpressionTracesOptions contains the optional parameters for the WorkflowRunActionsClient.NewListExpressionTracesPager +// method. +type WorkflowRunActionsClientListExpressionTracesOptions struct { + // placeholder for future optional parameters +} + +// WorkflowRunActionsClientListOptions contains the optional parameters for the WorkflowRunActionsClient.NewListPager method. +type WorkflowRunActionsClientListOptions struct { + // The filter to apply on the operation. Options for filters include: Status. + Filter *string + + // The number of items to be included in the result. + Top *int32 +} + +// WorkflowRunOperationsClientGetOptions contains the optional parameters for the WorkflowRunOperationsClient.Get method. +type WorkflowRunOperationsClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkflowRunsClientCancelOptions contains the optional parameters for the WorkflowRunsClient.Cancel method. +type WorkflowRunsClientCancelOptions struct { + // placeholder for future optional parameters +} + +// WorkflowRunsClientGetOptions contains the optional parameters for the WorkflowRunsClient.Get method. +type WorkflowRunsClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkflowRunsClientListOptions contains the optional parameters for the WorkflowRunsClient.NewListPager method. +type WorkflowRunsClientListOptions struct { + // The filter to apply on the operation. Options for filters include: Status, StartTime, and ClientTrackingId. + Filter *string + + // The number of items to be included in the result. + Top *int32 +} + +// WorkflowTriggerHistoriesClientGetOptions contains the optional parameters for the WorkflowTriggerHistoriesClient.Get method. +type WorkflowTriggerHistoriesClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkflowTriggerHistoriesClientListOptions contains the optional parameters for the WorkflowTriggerHistoriesClient.NewListPager +// method. +type WorkflowTriggerHistoriesClientListOptions struct { + // The filter to apply on the operation. Options for filters include: Status, StartTime, and ClientTrackingId. + Filter *string + + // The number of items to be included in the result. + Top *int32 +} + +// WorkflowTriggerHistoriesClientResubmitOptions contains the optional parameters for the WorkflowTriggerHistoriesClient.Resubmit +// method. +type WorkflowTriggerHistoriesClientResubmitOptions struct { + // placeholder for future optional parameters +} + +// WorkflowTriggersClientGetOptions contains the optional parameters for the WorkflowTriggersClient.Get method. +type WorkflowTriggersClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkflowTriggersClientGetSchemaJSONOptions contains the optional parameters for the WorkflowTriggersClient.GetSchemaJSON +// method. +type WorkflowTriggersClientGetSchemaJSONOptions struct { + // placeholder for future optional parameters +} + +// WorkflowTriggersClientListCallbackURLOptions contains the optional parameters for the WorkflowTriggersClient.ListCallbackURL +// method. +type WorkflowTriggersClientListCallbackURLOptions struct { + // placeholder for future optional parameters +} + +// WorkflowTriggersClientListOptions contains the optional parameters for the WorkflowTriggersClient.NewListPager method. +type WorkflowTriggersClientListOptions struct { + // The filter to apply on the operation. + Filter *string + + // The number of items to be included in the result. + Top *int32 +} + +// WorkflowTriggersClientResetOptions contains the optional parameters for the WorkflowTriggersClient.Reset method. +type WorkflowTriggersClientResetOptions struct { + // placeholder for future optional parameters +} + +// WorkflowTriggersClientRunOptions contains the optional parameters for the WorkflowTriggersClient.Run method. +type WorkflowTriggersClientRunOptions struct { + // placeholder for future optional parameters +} + +// WorkflowTriggersClientSetStateOptions contains the optional parameters for the WorkflowTriggersClient.SetState method. +type WorkflowTriggersClientSetStateOptions struct { + // placeholder for future optional parameters +} + +// WorkflowVersionTriggersClientListCallbackURLOptions contains the optional parameters for the WorkflowVersionTriggersClient.ListCallbackURL +// method. +type WorkflowVersionTriggersClientListCallbackURLOptions struct { + // The callback URL parameters. + Parameters *GetCallbackURLParameters +} + +// WorkflowVersionsClientGetOptions contains the optional parameters for the WorkflowVersionsClient.Get method. +type WorkflowVersionsClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkflowVersionsClientListOptions contains the optional parameters for the WorkflowVersionsClient.NewListPager method. +type WorkflowVersionsClientListOptions struct { + // The number of items to be included in the result. + Top *int32 +} + +// WorkflowsClientBeginMoveOptions contains the optional parameters for the WorkflowsClient.BeginMove method. +type WorkflowsClientBeginMoveOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// WorkflowsClientCreateOrUpdateOptions contains the optional parameters for the WorkflowsClient.CreateOrUpdate method. +type WorkflowsClientCreateOrUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkflowsClientDeleteOptions contains the optional parameters for the WorkflowsClient.Delete method. +type WorkflowsClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// WorkflowsClientDisableOptions contains the optional parameters for the WorkflowsClient.Disable method. +type WorkflowsClientDisableOptions struct { + // placeholder for future optional parameters +} + +// WorkflowsClientEnableOptions contains the optional parameters for the WorkflowsClient.Enable method. +type WorkflowsClientEnableOptions struct { + // placeholder for future optional parameters +} + +// WorkflowsClientGenerateUpgradedDefinitionOptions contains the optional parameters for the WorkflowsClient.GenerateUpgradedDefinition +// method. +type WorkflowsClientGenerateUpgradedDefinitionOptions struct { + // placeholder for future optional parameters +} + +// WorkflowsClientGetOptions contains the optional parameters for the WorkflowsClient.Get method. +type WorkflowsClientGetOptions struct { + // placeholder for future optional parameters +} + +// WorkflowsClientListByResourceGroupOptions contains the optional parameters for the WorkflowsClient.NewListByResourceGroupPager +// method. +type WorkflowsClientListByResourceGroupOptions struct { + // The filter to apply on the operation. Options for filters include: State, Trigger, and ReferencedResourceId. + Filter *string + + // The number of items to be included in the result. + Top *int32 +} + +// WorkflowsClientListBySubscriptionOptions contains the optional parameters for the WorkflowsClient.NewListBySubscriptionPager +// method. +type WorkflowsClientListBySubscriptionOptions struct { + // The filter to apply on the operation. Options for filters include: State, Trigger, and ReferencedResourceId. + Filter *string + + // The number of items to be included in the result. + Top *int32 +} + +// WorkflowsClientListCallbackURLOptions contains the optional parameters for the WorkflowsClient.ListCallbackURL method. +type WorkflowsClientListCallbackURLOptions struct { + // placeholder for future optional parameters +} + +// WorkflowsClientListSwaggerOptions contains the optional parameters for the WorkflowsClient.ListSwagger method. +type WorkflowsClientListSwaggerOptions struct { + // placeholder for future optional parameters +} + +// WorkflowsClientRegenerateAccessKeyOptions contains the optional parameters for the WorkflowsClient.RegenerateAccessKey +// method. +type WorkflowsClientRegenerateAccessKeyOptions struct { + // placeholder for future optional parameters +} + +// WorkflowsClientUpdateOptions contains the optional parameters for the WorkflowsClient.Update method. +type WorkflowsClientUpdateOptions struct { + // placeholder for future optional parameters +} + +// WorkflowsClientValidateByLocationOptions contains the optional parameters for the WorkflowsClient.ValidateByLocation method. +type WorkflowsClientValidateByLocationOptions struct { + // placeholder for future optional parameters +} + +// WorkflowsClientValidateByResourceGroupOptions contains the optional parameters for the WorkflowsClient.ValidateByResourceGroup +// method. +type WorkflowsClientValidateByResourceGroupOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/logic/armlogic/response_types.go b/sdk/resourcemanager/logic/armlogic/response_types.go index 7fe0c60fdf7a..b615dc9c7ad0 100644 --- a/sdk/resourcemanager/logic/armlogic/response_types.go +++ b/sdk/resourcemanager/logic/armlogic/response_types.go @@ -3,14 +3,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic // IntegrationAccountAgreementsClientCreateOrUpdateResponse contains the response from method IntegrationAccountAgreementsClient.CreateOrUpdate. type IntegrationAccountAgreementsClientCreateOrUpdateResponse struct { + // The integration account agreement. IntegrationAccountAgreement } @@ -21,21 +21,25 @@ type IntegrationAccountAgreementsClientDeleteResponse struct { // IntegrationAccountAgreementsClientGetResponse contains the response from method IntegrationAccountAgreementsClient.Get. type IntegrationAccountAgreementsClientGetResponse struct { + // The integration account agreement. IntegrationAccountAgreement } // IntegrationAccountAgreementsClientListContentCallbackURLResponse contains the response from method IntegrationAccountAgreementsClient.ListContentCallbackURL. type IntegrationAccountAgreementsClientListContentCallbackURLResponse struct { + // The workflow trigger callback URL. WorkflowTriggerCallbackURL } // IntegrationAccountAgreementsClientListResponse contains the response from method IntegrationAccountAgreementsClient.NewListPager. type IntegrationAccountAgreementsClientListResponse struct { + // The list of integration account agreements. IntegrationAccountAgreementListResult } // IntegrationAccountAssembliesClientCreateOrUpdateResponse contains the response from method IntegrationAccountAssembliesClient.CreateOrUpdate. type IntegrationAccountAssembliesClientCreateOrUpdateResponse struct { + // The assembly definition. AssemblyDefinition } @@ -46,21 +50,25 @@ type IntegrationAccountAssembliesClientDeleteResponse struct { // IntegrationAccountAssembliesClientGetResponse contains the response from method IntegrationAccountAssembliesClient.Get. type IntegrationAccountAssembliesClientGetResponse struct { + // The assembly definition. AssemblyDefinition } // IntegrationAccountAssembliesClientListContentCallbackURLResponse contains the response from method IntegrationAccountAssembliesClient.ListContentCallbackURL. type IntegrationAccountAssembliesClientListContentCallbackURLResponse struct { + // The workflow trigger callback URL. WorkflowTriggerCallbackURL } // IntegrationAccountAssembliesClientListResponse contains the response from method IntegrationAccountAssembliesClient.NewListPager. type IntegrationAccountAssembliesClientListResponse struct { + // A collection of assembly definitions. AssemblyCollection } // IntegrationAccountBatchConfigurationsClientCreateOrUpdateResponse contains the response from method IntegrationAccountBatchConfigurationsClient.CreateOrUpdate. type IntegrationAccountBatchConfigurationsClientCreateOrUpdateResponse struct { + // The batch configuration resource definition. BatchConfiguration } @@ -71,16 +79,19 @@ type IntegrationAccountBatchConfigurationsClientDeleteResponse struct { // IntegrationAccountBatchConfigurationsClientGetResponse contains the response from method IntegrationAccountBatchConfigurationsClient.Get. type IntegrationAccountBatchConfigurationsClientGetResponse struct { + // The batch configuration resource definition. BatchConfiguration } // IntegrationAccountBatchConfigurationsClientListResponse contains the response from method IntegrationAccountBatchConfigurationsClient.NewListPager. type IntegrationAccountBatchConfigurationsClientListResponse struct { + // A collection of batch configurations. BatchConfigurationCollection } // IntegrationAccountCertificatesClientCreateOrUpdateResponse contains the response from method IntegrationAccountCertificatesClient.CreateOrUpdate. type IntegrationAccountCertificatesClientCreateOrUpdateResponse struct { + // The integration account certificate. IntegrationAccountCertificate } @@ -91,16 +102,19 @@ type IntegrationAccountCertificatesClientDeleteResponse struct { // IntegrationAccountCertificatesClientGetResponse contains the response from method IntegrationAccountCertificatesClient.Get. type IntegrationAccountCertificatesClientGetResponse struct { + // The integration account certificate. IntegrationAccountCertificate } // IntegrationAccountCertificatesClientListResponse contains the response from method IntegrationAccountCertificatesClient.NewListPager. type IntegrationAccountCertificatesClientListResponse struct { + // The list of integration account certificates. IntegrationAccountCertificateListResult } // IntegrationAccountMapsClientCreateOrUpdateResponse contains the response from method IntegrationAccountMapsClient.CreateOrUpdate. type IntegrationAccountMapsClientCreateOrUpdateResponse struct { + // The integration account map. IntegrationAccountMap } @@ -111,21 +125,25 @@ type IntegrationAccountMapsClientDeleteResponse struct { // IntegrationAccountMapsClientGetResponse contains the response from method IntegrationAccountMapsClient.Get. type IntegrationAccountMapsClientGetResponse struct { + // The integration account map. IntegrationAccountMap } // IntegrationAccountMapsClientListContentCallbackURLResponse contains the response from method IntegrationAccountMapsClient.ListContentCallbackURL. type IntegrationAccountMapsClientListContentCallbackURLResponse struct { + // The workflow trigger callback URL. WorkflowTriggerCallbackURL } // IntegrationAccountMapsClientListResponse contains the response from method IntegrationAccountMapsClient.NewListPager. type IntegrationAccountMapsClientListResponse struct { + // The list of integration account maps. IntegrationAccountMapListResult } // IntegrationAccountPartnersClientCreateOrUpdateResponse contains the response from method IntegrationAccountPartnersClient.CreateOrUpdate. type IntegrationAccountPartnersClientCreateOrUpdateResponse struct { + // The integration account partner. IntegrationAccountPartner } @@ -136,21 +154,25 @@ type IntegrationAccountPartnersClientDeleteResponse struct { // IntegrationAccountPartnersClientGetResponse contains the response from method IntegrationAccountPartnersClient.Get. type IntegrationAccountPartnersClientGetResponse struct { + // The integration account partner. IntegrationAccountPartner } // IntegrationAccountPartnersClientListContentCallbackURLResponse contains the response from method IntegrationAccountPartnersClient.ListContentCallbackURL. type IntegrationAccountPartnersClientListContentCallbackURLResponse struct { + // The workflow trigger callback URL. WorkflowTriggerCallbackURL } // IntegrationAccountPartnersClientListResponse contains the response from method IntegrationAccountPartnersClient.NewListPager. type IntegrationAccountPartnersClientListResponse struct { + // The list of integration account partners. IntegrationAccountPartnerListResult } // IntegrationAccountSchemasClientCreateOrUpdateResponse contains the response from method IntegrationAccountSchemasClient.CreateOrUpdate. type IntegrationAccountSchemasClientCreateOrUpdateResponse struct { + // The integration account schema. IntegrationAccountSchema } @@ -161,21 +183,25 @@ type IntegrationAccountSchemasClientDeleteResponse struct { // IntegrationAccountSchemasClientGetResponse contains the response from method IntegrationAccountSchemasClient.Get. type IntegrationAccountSchemasClientGetResponse struct { + // The integration account schema. IntegrationAccountSchema } // IntegrationAccountSchemasClientListContentCallbackURLResponse contains the response from method IntegrationAccountSchemasClient.ListContentCallbackURL. type IntegrationAccountSchemasClientListContentCallbackURLResponse struct { + // The workflow trigger callback URL. WorkflowTriggerCallbackURL } // IntegrationAccountSchemasClientListResponse contains the response from method IntegrationAccountSchemasClient.NewListPager. type IntegrationAccountSchemasClientListResponse struct { + // The list of integration account schemas. IntegrationAccountSchemaListResult } // IntegrationAccountSessionsClientCreateOrUpdateResponse contains the response from method IntegrationAccountSessionsClient.CreateOrUpdate. type IntegrationAccountSessionsClientCreateOrUpdateResponse struct { + // The integration account session. IntegrationAccountSession } @@ -186,16 +212,19 @@ type IntegrationAccountSessionsClientDeleteResponse struct { // IntegrationAccountSessionsClientGetResponse contains the response from method IntegrationAccountSessionsClient.Get. type IntegrationAccountSessionsClientGetResponse struct { + // The integration account session. IntegrationAccountSession } // IntegrationAccountSessionsClientListResponse contains the response from method IntegrationAccountSessionsClient.NewListPager. type IntegrationAccountSessionsClientListResponse struct { + // The list of integration account sessions. IntegrationAccountSessionListResult } // IntegrationAccountsClientCreateOrUpdateResponse contains the response from method IntegrationAccountsClient.CreateOrUpdate. type IntegrationAccountsClientCreateOrUpdateResponse struct { + // The integration account. IntegrationAccount } @@ -206,26 +235,31 @@ type IntegrationAccountsClientDeleteResponse struct { // IntegrationAccountsClientGetResponse contains the response from method IntegrationAccountsClient.Get. type IntegrationAccountsClientGetResponse struct { + // The integration account. IntegrationAccount } // IntegrationAccountsClientListByResourceGroupResponse contains the response from method IntegrationAccountsClient.NewListByResourceGroupPager. type IntegrationAccountsClientListByResourceGroupResponse struct { + // The list of integration accounts. IntegrationAccountListResult } // IntegrationAccountsClientListBySubscriptionResponse contains the response from method IntegrationAccountsClient.NewListBySubscriptionPager. type IntegrationAccountsClientListBySubscriptionResponse struct { + // The list of integration accounts. IntegrationAccountListResult } // IntegrationAccountsClientListCallbackURLResponse contains the response from method IntegrationAccountsClient.ListCallbackURL. type IntegrationAccountsClientListCallbackURLResponse struct { + // The callback url. CallbackURL } // IntegrationAccountsClientListKeyVaultKeysResponse contains the response from method IntegrationAccountsClient.NewListKeyVaultKeysPager. type IntegrationAccountsClientListKeyVaultKeysResponse struct { + // Collection of key vault keys. KeyVaultKeyCollection } @@ -236,16 +270,19 @@ type IntegrationAccountsClientLogTrackingEventsResponse struct { // IntegrationAccountsClientRegenerateAccessKeyResponse contains the response from method IntegrationAccountsClient.RegenerateAccessKey. type IntegrationAccountsClientRegenerateAccessKeyResponse struct { + // The integration account. IntegrationAccount } // IntegrationAccountsClientUpdateResponse contains the response from method IntegrationAccountsClient.Update. type IntegrationAccountsClientUpdateResponse struct { + // The integration account. IntegrationAccount } // IntegrationServiceEnvironmentManagedAPIOperationsClientListResponse contains the response from method IntegrationServiceEnvironmentManagedAPIOperationsClient.NewListPager. type IntegrationServiceEnvironmentManagedAPIOperationsClientListResponse struct { + // The list of managed API operations. APIOperationListResult } @@ -256,16 +293,19 @@ type IntegrationServiceEnvironmentManagedApisClientDeleteResponse struct { // IntegrationServiceEnvironmentManagedApisClientGetResponse contains the response from method IntegrationServiceEnvironmentManagedApisClient.Get. type IntegrationServiceEnvironmentManagedApisClientGetResponse struct { + // The integration service environment managed api. IntegrationServiceEnvironmentManagedAPI } // IntegrationServiceEnvironmentManagedApisClientListResponse contains the response from method IntegrationServiceEnvironmentManagedApisClient.NewListPager. type IntegrationServiceEnvironmentManagedApisClientListResponse struct { + // The list of integration service environment managed APIs. IntegrationServiceEnvironmentManagedAPIListResult } // IntegrationServiceEnvironmentManagedApisClientPutResponse contains the response from method IntegrationServiceEnvironmentManagedApisClient.BeginPut. type IntegrationServiceEnvironmentManagedApisClientPutResponse struct { + // The integration service environment managed api. IntegrationServiceEnvironmentManagedAPI } @@ -277,11 +317,13 @@ type IntegrationServiceEnvironmentNetworkHealthClientGetResponse struct { // IntegrationServiceEnvironmentSKUsClientListResponse contains the response from method IntegrationServiceEnvironmentSKUsClient.NewListPager. type IntegrationServiceEnvironmentSKUsClientListResponse struct { + // The list of integration service environment skus. IntegrationServiceEnvironmentSKUList } // IntegrationServiceEnvironmentsClientCreateOrUpdateResponse contains the response from method IntegrationServiceEnvironmentsClient.BeginCreateOrUpdate. type IntegrationServiceEnvironmentsClientCreateOrUpdateResponse struct { + // The integration service environment. IntegrationServiceEnvironment } @@ -292,16 +334,19 @@ type IntegrationServiceEnvironmentsClientDeleteResponse struct { // IntegrationServiceEnvironmentsClientGetResponse contains the response from method IntegrationServiceEnvironmentsClient.Get. type IntegrationServiceEnvironmentsClientGetResponse struct { + // The integration service environment. IntegrationServiceEnvironment } // IntegrationServiceEnvironmentsClientListByResourceGroupResponse contains the response from method IntegrationServiceEnvironmentsClient.NewListByResourceGroupPager. type IntegrationServiceEnvironmentsClientListByResourceGroupResponse struct { + // The list of integration service environments. IntegrationServiceEnvironmentListResult } // IntegrationServiceEnvironmentsClientListBySubscriptionResponse contains the response from method IntegrationServiceEnvironmentsClient.NewListBySubscriptionPager. type IntegrationServiceEnvironmentsClientListBySubscriptionResponse struct { + // The list of integration service environments. IntegrationServiceEnvironmentListResult } @@ -312,76 +357,92 @@ type IntegrationServiceEnvironmentsClientRestartResponse struct { // IntegrationServiceEnvironmentsClientUpdateResponse contains the response from method IntegrationServiceEnvironmentsClient.BeginUpdate. type IntegrationServiceEnvironmentsClientUpdateResponse struct { + // The integration service environment. IntegrationServiceEnvironment } // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { + // Result of the request to list Logic operations. It contains a list of operations and a URL link to get the next set of + // results. OperationListResult } // WorkflowRunActionRepetitionsClientGetResponse contains the response from method WorkflowRunActionRepetitionsClient.Get. type WorkflowRunActionRepetitionsClientGetResponse struct { + // The workflow run action repetition definition. WorkflowRunActionRepetitionDefinition } // WorkflowRunActionRepetitionsClientListExpressionTracesResponse contains the response from method WorkflowRunActionRepetitionsClient.NewListExpressionTracesPager. type WorkflowRunActionRepetitionsClientListExpressionTracesResponse struct { + // The expression traces. ExpressionTraces } // WorkflowRunActionRepetitionsClientListResponse contains the response from method WorkflowRunActionRepetitionsClient.NewListPager. type WorkflowRunActionRepetitionsClientListResponse struct { + // A collection of workflow run action repetitions. WorkflowRunActionRepetitionDefinitionCollection } // WorkflowRunActionRepetitionsRequestHistoriesClientGetResponse contains the response from method WorkflowRunActionRepetitionsRequestHistoriesClient.Get. type WorkflowRunActionRepetitionsRequestHistoriesClientGetResponse struct { + // The request history. RequestHistory } // WorkflowRunActionRepetitionsRequestHistoriesClientListResponse contains the response from method WorkflowRunActionRepetitionsRequestHistoriesClient.NewListPager. type WorkflowRunActionRepetitionsRequestHistoriesClientListResponse struct { + // The list of workflow request histories. RequestHistoryListResult } // WorkflowRunActionRequestHistoriesClientGetResponse contains the response from method WorkflowRunActionRequestHistoriesClient.Get. type WorkflowRunActionRequestHistoriesClientGetResponse struct { + // The request history. RequestHistory } // WorkflowRunActionRequestHistoriesClientListResponse contains the response from method WorkflowRunActionRequestHistoriesClient.NewListPager. type WorkflowRunActionRequestHistoriesClientListResponse struct { + // The list of workflow request histories. RequestHistoryListResult } // WorkflowRunActionScopeRepetitionsClientGetResponse contains the response from method WorkflowRunActionScopeRepetitionsClient.Get. type WorkflowRunActionScopeRepetitionsClientGetResponse struct { + // The workflow run action repetition definition. WorkflowRunActionRepetitionDefinition } // WorkflowRunActionScopeRepetitionsClientListResponse contains the response from method WorkflowRunActionScopeRepetitionsClient.NewListPager. type WorkflowRunActionScopeRepetitionsClientListResponse struct { + // A collection of workflow run action repetitions. WorkflowRunActionRepetitionDefinitionCollection } // WorkflowRunActionsClientGetResponse contains the response from method WorkflowRunActionsClient.Get. type WorkflowRunActionsClientGetResponse struct { + // The workflow run action. WorkflowRunAction } // WorkflowRunActionsClientListExpressionTracesResponse contains the response from method WorkflowRunActionsClient.NewListExpressionTracesPager. type WorkflowRunActionsClientListExpressionTracesResponse struct { + // The expression traces. ExpressionTraces } // WorkflowRunActionsClientListResponse contains the response from method WorkflowRunActionsClient.NewListPager. type WorkflowRunActionsClientListResponse struct { + // The list of workflow run actions. WorkflowRunActionListResult } // WorkflowRunOperationsClientGetResponse contains the response from method WorkflowRunOperationsClient.Get. type WorkflowRunOperationsClientGetResponse struct { + // The workflow run. WorkflowRun } @@ -392,21 +453,25 @@ type WorkflowRunsClientCancelResponse struct { // WorkflowRunsClientGetResponse contains the response from method WorkflowRunsClient.Get. type WorkflowRunsClientGetResponse struct { + // The workflow run. WorkflowRun } // WorkflowRunsClientListResponse contains the response from method WorkflowRunsClient.NewListPager. type WorkflowRunsClientListResponse struct { + // The list of workflow runs. WorkflowRunListResult } // WorkflowTriggerHistoriesClientGetResponse contains the response from method WorkflowTriggerHistoriesClient.Get. type WorkflowTriggerHistoriesClientGetResponse struct { + // The workflow trigger history. WorkflowTriggerHistory } // WorkflowTriggerHistoriesClientListResponse contains the response from method WorkflowTriggerHistoriesClient.NewListPager. type WorkflowTriggerHistoriesClientListResponse struct { + // The list of workflow trigger histories. WorkflowTriggerHistoryListResult } @@ -417,21 +482,25 @@ type WorkflowTriggerHistoriesClientResubmitResponse struct { // WorkflowTriggersClientGetResponse contains the response from method WorkflowTriggersClient.Get. type WorkflowTriggersClientGetResponse struct { + // The workflow trigger. WorkflowTrigger } // WorkflowTriggersClientGetSchemaJSONResponse contains the response from method WorkflowTriggersClient.GetSchemaJSON. type WorkflowTriggersClientGetSchemaJSONResponse struct { + // The JSON schema. JSONSchema } // WorkflowTriggersClientListCallbackURLResponse contains the response from method WorkflowTriggersClient.ListCallbackURL. type WorkflowTriggersClientListCallbackURLResponse struct { + // The workflow trigger callback URL. WorkflowTriggerCallbackURL } // WorkflowTriggersClientListResponse contains the response from method WorkflowTriggersClient.NewListPager. type WorkflowTriggersClientListResponse struct { + // The list of workflow triggers. WorkflowTriggerListResult } @@ -452,21 +521,25 @@ type WorkflowTriggersClientSetStateResponse struct { // WorkflowVersionTriggersClientListCallbackURLResponse contains the response from method WorkflowVersionTriggersClient.ListCallbackURL. type WorkflowVersionTriggersClientListCallbackURLResponse struct { + // The workflow trigger callback URL. WorkflowTriggerCallbackURL } // WorkflowVersionsClientGetResponse contains the response from method WorkflowVersionsClient.Get. type WorkflowVersionsClientGetResponse struct { + // The workflow version. WorkflowVersion } // WorkflowVersionsClientListResponse contains the response from method WorkflowVersionsClient.NewListPager. type WorkflowVersionsClientListResponse struct { + // The list of workflow versions. WorkflowVersionListResult } // WorkflowsClientCreateOrUpdateResponse contains the response from method WorkflowsClient.CreateOrUpdate. type WorkflowsClientCreateOrUpdateResponse struct { + // The workflow type. Workflow } @@ -493,21 +566,25 @@ type WorkflowsClientGenerateUpgradedDefinitionResponse struct { // WorkflowsClientGetResponse contains the response from method WorkflowsClient.Get. type WorkflowsClientGetResponse struct { + // The workflow type. Workflow } // WorkflowsClientListByResourceGroupResponse contains the response from method WorkflowsClient.NewListByResourceGroupPager. type WorkflowsClientListByResourceGroupResponse struct { + // The list of workflows. WorkflowListResult } // WorkflowsClientListBySubscriptionResponse contains the response from method WorkflowsClient.NewListBySubscriptionPager. type WorkflowsClientListBySubscriptionResponse struct { + // The list of workflows. WorkflowListResult } // WorkflowsClientListCallbackURLResponse contains the response from method WorkflowsClient.ListCallbackURL. type WorkflowsClientListCallbackURLResponse struct { + // The workflow trigger callback URL. WorkflowTriggerCallbackURL } @@ -529,6 +606,7 @@ type WorkflowsClientRegenerateAccessKeyResponse struct { // WorkflowsClientUpdateResponse contains the response from method WorkflowsClient.Update. type WorkflowsClientUpdateResponse struct { + // The workflow type. Workflow } diff --git a/sdk/resourcemanager/logic/armlogic/time_rfc3339.go b/sdk/resourcemanager/logic/armlogic/time_rfc3339.go index 653e808e68e5..37e2346199a0 100644 --- a/sdk/resourcemanager/logic/armlogic/time_rfc3339.go +++ b/sdk/resourcemanager/logic/armlogic/time_rfc3339.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -19,50 +18,50 @@ import ( "time" ) -const ( - utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` - utcLayout = "2006-01-02T15:04:05.999999999" - rfc3339JSON = `"` + time.RFC3339Nano + `"` -) - // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) -type timeRFC3339 time.Time +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time -func (t timeRFC3339) MarshalJSON() (json []byte, err error) { +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { tt := time.Time(t) return tt.MarshalJSON() } -func (t timeRFC3339) MarshalText() (text []byte, err error) { +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { tt := time.Time(t) return tt.MarshalText() } -func (t *timeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcLayoutJSON +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON if tzOffsetRegex.Match(data) { - layout = rfc3339JSON + layout = dateTimeJSON } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { - layout := utcLayout +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime if tzOffsetRegex.Match(data) { layout = time.RFC3339Nano } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) Parse(layout, value string) error { +func (t *dateTimeRFC3339) Parse(layout, value string) error { p, err := time.Parse(layout, strings.ToUpper(value)) - *t = timeRFC3339(p) + *t = dateTimeRFC3339(p) return err } -func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { @@ -71,14 +70,14 @@ func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { } else if reflect.ValueOf(t).IsNil() { return } - m[k] = (*timeRFC3339)(t) + m[k] = (*dateTimeRFC3339)(t) } -func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { if data == nil || strings.EqualFold(string(data), "null") { return nil } - var aux timeRFC3339 + var aux dateTimeRFC3339 if err := json.Unmarshal(data, &aux); err != nil { return fmt.Errorf("struct field %s: %v", fn, err) } diff --git a/sdk/resourcemanager/logic/armlogic/workflowrunactionrepetitions_client.go b/sdk/resourcemanager/logic/armlogic/workflowrunactionrepetitions_client.go index 5abdb3c5a50c..e8087b2c7528 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowrunactionrepetitions_client.go +++ b/sdk/resourcemanager/logic/armlogic/workflowrunactionrepetitions_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -33,7 +32,7 @@ type WorkflowRunActionRepetitionsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkflowRunActionRepetitionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkflowRunActionRepetitionsClient, error) { - cl, err := arm.NewClient(moduleName+".WorkflowRunActionRepetitionsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -56,18 +55,25 @@ func NewWorkflowRunActionRepetitionsClient(subscriptionID string, credential azc // - options - WorkflowRunActionRepetitionsClientGetOptions contains the optional parameters for the WorkflowRunActionRepetitionsClient.Get // method. func (client *WorkflowRunActionRepetitionsClient) Get(ctx context.Context, resourceGroupName string, workflowName string, runName string, actionName string, repetitionName string, options *WorkflowRunActionRepetitionsClientGetOptions) (WorkflowRunActionRepetitionsClientGetResponse, error) { + var err error + const operationName = "WorkflowRunActionRepetitionsClient.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, workflowName, runName, actionName, repetitionName, options) if err != nil { return WorkflowRunActionRepetitionsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowRunActionRepetitionsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowRunActionRepetitionsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowRunActionRepetitionsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -132,6 +138,7 @@ func (client *WorkflowRunActionRepetitionsClient) NewListPager(resourceGroupName return false }, Fetcher: func(ctx context.Context, page *WorkflowRunActionRepetitionsClientListResponse) (WorkflowRunActionRepetitionsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkflowRunActionRepetitionsClient.NewListPager") req, err := client.listCreateRequest(ctx, resourceGroupName, workflowName, runName, actionName, options) if err != nil { return WorkflowRunActionRepetitionsClientListResponse{}, err @@ -145,6 +152,7 @@ func (client *WorkflowRunActionRepetitionsClient) NewListPager(resourceGroupName } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -207,6 +215,7 @@ func (client *WorkflowRunActionRepetitionsClient) NewListExpressionTracesPager(r return false }, Fetcher: func(ctx context.Context, page *WorkflowRunActionRepetitionsClientListExpressionTracesResponse) (WorkflowRunActionRepetitionsClientListExpressionTracesResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkflowRunActionRepetitionsClient.NewListExpressionTracesPager") req, err := client.listExpressionTracesCreateRequest(ctx, resourceGroupName, workflowName, runName, actionName, repetitionName, options) if err != nil { return WorkflowRunActionRepetitionsClientListExpressionTracesResponse{}, err @@ -220,6 +229,7 @@ func (client *WorkflowRunActionRepetitionsClient) NewListExpressionTracesPager(r } return client.listExpressionTracesHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/logic/armlogic/workflowrunactionrepetitions_client_example_test.go b/sdk/resourcemanager/logic/armlogic/workflowrunactionrepetitions_client_example_test.go index 420cd07cf065..374b45285ced 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowrunactionrepetitions_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/workflowrunactionrepetitions_client_example_test.go @@ -51,8 +51,8 @@ func ExampleWorkflowRunActionRepetitionsClient_NewListPager() { // ClientTrackingID: to.Ptr("08586775357427610445444523191"), // ActionTrackingID: to.Ptr("0d8152bb-e198-44a9-bde8-5138eea16dd4"), // }, - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.2264835Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.217991Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.226Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.217Z"); return t}()), // Status: to.Ptr(armlogic.WorkflowStatusSucceeded), // InputsLink: &armlogic.ContentLink{ // ContentHash: &armlogic.ContentHash{ @@ -90,8 +90,8 @@ func ExampleWorkflowRunActionRepetitionsClient_NewListPager() { // ClientTrackingID: to.Ptr("08586775357427610445444523191"), // ActionTrackingID: to.Ptr("f84f23eb-b331-4772-9f39-cc307fa83bc3"), // }, - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.1015421Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.0929911Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.101Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.092Z"); return t}()), // Status: to.Ptr(armlogic.WorkflowStatusSucceeded), // InputsLink: &armlogic.ContentLink{ // ContentHash: &armlogic.ContentHash{ @@ -151,8 +151,8 @@ func ExampleWorkflowRunActionRepetitionsClient_Get() { // ClientTrackingID: to.Ptr("08586775357427610445444523191"), // ActionTrackingID: to.Ptr("f84f23eb-b331-4772-9f39-cc307fa83bc3"), // }, - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.1015421Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.0929911Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.101Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.092Z"); return t}()), // Status: to.Ptr(armlogic.WorkflowStatusSucceeded), // InputsLink: &armlogic.ContentLink{ // ContentHash: &armlogic.ContentHash{ diff --git a/sdk/resourcemanager/logic/armlogic/workflowrunactionrepetitionsrequesthistories_client.go b/sdk/resourcemanager/logic/armlogic/workflowrunactionrepetitionsrequesthistories_client.go index 8f7cdcbf95a1..28baee5537b3 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowrunactionrepetitionsrequesthistories_client.go +++ b/sdk/resourcemanager/logic/armlogic/workflowrunactionrepetitionsrequesthistories_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -33,7 +32,7 @@ type WorkflowRunActionRepetitionsRequestHistoriesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkflowRunActionRepetitionsRequestHistoriesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkflowRunActionRepetitionsRequestHistoriesClient, error) { - cl, err := arm.NewClient(moduleName+".WorkflowRunActionRepetitionsRequestHistoriesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -57,18 +56,25 @@ func NewWorkflowRunActionRepetitionsRequestHistoriesClient(subscriptionID string // - options - WorkflowRunActionRepetitionsRequestHistoriesClientGetOptions contains the optional parameters for the WorkflowRunActionRepetitionsRequestHistoriesClient.Get // method. func (client *WorkflowRunActionRepetitionsRequestHistoriesClient) Get(ctx context.Context, resourceGroupName string, workflowName string, runName string, actionName string, repetitionName string, requestHistoryName string, options *WorkflowRunActionRepetitionsRequestHistoriesClientGetOptions) (WorkflowRunActionRepetitionsRequestHistoriesClientGetResponse, error) { + var err error + const operationName = "WorkflowRunActionRepetitionsRequestHistoriesClient.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, workflowName, runName, actionName, repetitionName, requestHistoryName, options) if err != nil { return WorkflowRunActionRepetitionsRequestHistoriesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowRunActionRepetitionsRequestHistoriesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowRunActionRepetitionsRequestHistoriesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowRunActionRepetitionsRequestHistoriesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -138,25 +144,20 @@ func (client *WorkflowRunActionRepetitionsRequestHistoriesClient) NewListPager(r return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *WorkflowRunActionRepetitionsRequestHistoriesClientListResponse) (WorkflowRunActionRepetitionsRequestHistoriesClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, workflowName, runName, actionName, repetitionName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkflowRunActionRepetitionsRequestHistoriesClient.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, resourceGroupName, workflowName, runName, actionName, repetitionName, options) + }, nil) if err != nil { return WorkflowRunActionRepetitionsRequestHistoriesClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return WorkflowRunActionRepetitionsRequestHistoriesClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowRunActionRepetitionsRequestHistoriesClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/logic/armlogic/workflowrunactionrepetitionsrequesthistories_client_example_test.go b/sdk/resourcemanager/logic/armlogic/workflowrunactionrepetitionsrequesthistories_client_example_test.go index 8830424d0873..ccf5baad3d89 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowrunactionrepetitionsrequesthistories_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/workflowrunactionrepetitionsrequesthistories_client_example_test.go @@ -46,7 +46,7 @@ func ExampleWorkflowRunActionRepetitionsRequestHistoriesClient_NewListPager() { // Type: to.Ptr("Microsoft.Logic/workflows/runs/actions/requestHistories"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/test-resource-group/providers/Microsoft.Logic/workflows/test-workflow/runs/08586611142736787787412824395CU21/actions/HTTP_Webhook/requestHistories/08586611142732800686"), // Properties: &armlogic.RequestHistoryProperties{ - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-25T18:36:52.1863033Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-25T18:36:52.186Z"); return t}()), // Response: &armlogic.Response{ // BodyLink: &armlogic.ContentLink{ // ContentHash: &armlogic.ContentHash{ @@ -67,7 +67,7 @@ func ExampleWorkflowRunActionRepetitionsRequestHistoriesClient_NewListPager() { // }, // StatusCode: to.Ptr[int32](302), // }, - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-25T18:36:51.9206732Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-25T18:36:51.920Z"); return t}()), // Request: &armlogic.Request{ // Method: to.Ptr("GET"), // Headers: map[string]any{ @@ -121,7 +121,7 @@ func ExampleWorkflowRunActionRepetitionsRequestHistoriesClient_Get() { // Type: to.Ptr("Microsoft.Logic/workflows/runs/actions/requestHistories"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/test-resource-group/providers/Microsoft.Logic/workflows/test-workflow/runs/08586611142736787787412824395CU21/actions/HTTP_Webhook/requestHistories/08586611142732800686"), // Properties: &armlogic.RequestHistoryProperties{ - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-25T18:36:52.1863033Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-25T18:36:52.186Z"); return t}()), // Response: &armlogic.Response{ // BodyLink: &armlogic.ContentLink{ // ContentHash: &armlogic.ContentHash{ @@ -142,7 +142,7 @@ func ExampleWorkflowRunActionRepetitionsRequestHistoriesClient_Get() { // }, // StatusCode: to.Ptr[int32](302), // }, - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-25T18:36:51.9206732Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-25T18:36:51.920Z"); return t}()), // Request: &armlogic.Request{ // Method: to.Ptr("GET"), // Headers: map[string]any{ diff --git a/sdk/resourcemanager/logic/armlogic/workflowrunactionrequesthistories_client.go b/sdk/resourcemanager/logic/armlogic/workflowrunactionrequesthistories_client.go index f9e5522422bc..3dc11a96b3c3 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowrunactionrequesthistories_client.go +++ b/sdk/resourcemanager/logic/armlogic/workflowrunactionrequesthistories_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -33,7 +32,7 @@ type WorkflowRunActionRequestHistoriesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkflowRunActionRequestHistoriesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkflowRunActionRequestHistoriesClient, error) { - cl, err := arm.NewClient(moduleName+".WorkflowRunActionRequestHistoriesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -56,18 +55,25 @@ func NewWorkflowRunActionRequestHistoriesClient(subscriptionID string, credentia // - options - WorkflowRunActionRequestHistoriesClientGetOptions contains the optional parameters for the WorkflowRunActionRequestHistoriesClient.Get // method. func (client *WorkflowRunActionRequestHistoriesClient) Get(ctx context.Context, resourceGroupName string, workflowName string, runName string, actionName string, requestHistoryName string, options *WorkflowRunActionRequestHistoriesClientGetOptions) (WorkflowRunActionRequestHistoriesClientGetResponse, error) { + var err error + const operationName = "WorkflowRunActionRequestHistoriesClient.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, workflowName, runName, actionName, requestHistoryName, options) if err != nil { return WorkflowRunActionRequestHistoriesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowRunActionRequestHistoriesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowRunActionRequestHistoriesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowRunActionRequestHistoriesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -132,25 +138,20 @@ func (client *WorkflowRunActionRequestHistoriesClient) NewListPager(resourceGrou return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *WorkflowRunActionRequestHistoriesClientListResponse) (WorkflowRunActionRequestHistoriesClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, workflowName, runName, actionName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkflowRunActionRequestHistoriesClient.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, resourceGroupName, workflowName, runName, actionName, options) + }, nil) if err != nil { return WorkflowRunActionRequestHistoriesClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return WorkflowRunActionRequestHistoriesClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowRunActionRequestHistoriesClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/logic/armlogic/workflowrunactionrequesthistories_client_example_test.go b/sdk/resourcemanager/logic/armlogic/workflowrunactionrequesthistories_client_example_test.go index 2b5c74c4d005..e2061536b46f 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowrunactionrequesthistories_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/workflowrunactionrequesthistories_client_example_test.go @@ -46,7 +46,7 @@ func ExampleWorkflowRunActionRequestHistoriesClient_NewListPager() { // Type: to.Ptr("Microsoft.Logic/workflows/runs/actions/requestHistories"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/test-resource-group/providers/Microsoft.Logic/workflows/test-workflow/runs/08586611142736787787412824395CU21/actions/HTTP_Webhook/requestHistories/08586611142732800686"), // Properties: &armlogic.RequestHistoryProperties{ - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-25T18:36:52.1863033Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-25T18:36:52.186Z"); return t}()), // Response: &armlogic.Response{ // BodyLink: &armlogic.ContentLink{ // ContentHash: &armlogic.ContentHash{ @@ -67,7 +67,7 @@ func ExampleWorkflowRunActionRequestHistoriesClient_NewListPager() { // }, // StatusCode: to.Ptr[int32](302), // }, - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-25T18:36:51.9206732Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-25T18:36:51.920Z"); return t}()), // Request: &armlogic.Request{ // Method: to.Ptr("GET"), // Headers: map[string]any{ @@ -121,7 +121,7 @@ func ExampleWorkflowRunActionRequestHistoriesClient_Get() { // Type: to.Ptr("Microsoft.Logic/workflows/runs/actions/requestHistories"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/test-resource-group/providers/Microsoft.Logic/workflows/test-workflow/runs/08586611142736787787412824395CU21/actions/HTTP_Webhook/requestHistories/08586611142732800686"), // Properties: &armlogic.RequestHistoryProperties{ - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-25T18:36:52.1863033Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-25T18:36:52.186Z"); return t}()), // Response: &armlogic.Response{ // BodyLink: &armlogic.ContentLink{ // ContentHash: &armlogic.ContentHash{ @@ -142,7 +142,7 @@ func ExampleWorkflowRunActionRequestHistoriesClient_Get() { // }, // StatusCode: to.Ptr[int32](302), // }, - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-25T18:36:51.9206732Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-10-25T18:36:51.920Z"); return t}()), // Request: &armlogic.Request{ // Method: to.Ptr("GET"), // Headers: map[string]any{ diff --git a/sdk/resourcemanager/logic/armlogic/workflowrunactions_client.go b/sdk/resourcemanager/logic/armlogic/workflowrunactions_client.go index c312a940983a..b90e43f465f1 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowrunactions_client.go +++ b/sdk/resourcemanager/logic/armlogic/workflowrunactions_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -34,7 +33,7 @@ type WorkflowRunActionsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkflowRunActionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkflowRunActionsClient, error) { - cl, err := arm.NewClient(moduleName+".WorkflowRunActionsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,18 +54,25 @@ func NewWorkflowRunActionsClient(subscriptionID string, credential azcore.TokenC // - actionName - The workflow action name. // - options - WorkflowRunActionsClientGetOptions contains the optional parameters for the WorkflowRunActionsClient.Get method. func (client *WorkflowRunActionsClient) Get(ctx context.Context, resourceGroupName string, workflowName string, runName string, actionName string, options *WorkflowRunActionsClientGetOptions) (WorkflowRunActionsClientGetResponse, error) { + var err error + const operationName = "WorkflowRunActionsClient.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, workflowName, runName, actionName, options) if err != nil { return WorkflowRunActionsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowRunActionsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowRunActionsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowRunActionsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -126,25 +132,20 @@ func (client *WorkflowRunActionsClient) NewListPager(resourceGroupName string, w return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *WorkflowRunActionsClientListResponse) (WorkflowRunActionsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, workflowName, runName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkflowRunActionsClient.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, resourceGroupName, workflowName, runName, options) + }, nil) if err != nil { return WorkflowRunActionsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return WorkflowRunActionsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowRunActionsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -208,6 +209,7 @@ func (client *WorkflowRunActionsClient) NewListExpressionTracesPager(resourceGro return false }, Fetcher: func(ctx context.Context, page *WorkflowRunActionsClientListExpressionTracesResponse) (WorkflowRunActionsClientListExpressionTracesResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkflowRunActionsClient.NewListExpressionTracesPager") req, err := client.listExpressionTracesCreateRequest(ctx, resourceGroupName, workflowName, runName, actionName, options) if err != nil { return WorkflowRunActionsClientListExpressionTracesResponse{}, err @@ -221,6 +223,7 @@ func (client *WorkflowRunActionsClient) NewListExpressionTracesPager(resourceGro } return client.listExpressionTracesHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/logic/armlogic/workflowrunactions_client_example_test.go b/sdk/resourcemanager/logic/armlogic/workflowrunactions_client_example_test.go index 951e32326039..f26734687b71 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowrunactions_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/workflowrunactions_client_example_test.go @@ -53,7 +53,7 @@ func ExampleWorkflowRunActionsClient_NewListPager() { // ClientTrackingID: to.Ptr("08586676746934337772206998657CU22"), // ActionTrackingID: to.Ptr("56063357-45dd-4278-9be5-8220ce0cc9ca"), // }, - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.5450625Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.545Z"); return t}()), // InputsLink: &armlogic.ContentLink{ // ContentHash: &armlogic.ContentHash{ // Algorithm: to.Ptr("md5"), @@ -72,7 +72,7 @@ func ExampleWorkflowRunActionsClient_NewListPager() { // ContentVersion: to.Ptr("6X6KRrevI6AAxEvo9FeBYQ=="), // URI: to.Ptr("https://tempuri.org"), // }, - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.305236Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.305Z"); return t}()), // Status: to.Ptr(armlogic.WorkflowStatusSucceeded), // }, // }}, @@ -108,7 +108,7 @@ func ExampleWorkflowRunActionsClient_Get() { // ClientTrackingID: to.Ptr("08586676746934337772206998657CU22"), // ActionTrackingID: to.Ptr("56063357-45dd-4278-9be5-8220ce0cc9ca"), // }, - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.5450625Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.545Z"); return t}()), // InputsLink: &armlogic.ContentLink{ // ContentHash: &armlogic.ContentHash{ // Algorithm: to.Ptr("md5"), @@ -127,7 +127,7 @@ func ExampleWorkflowRunActionsClient_Get() { // ContentVersion: to.Ptr("6X6KRrevI6AAxEvo9FeBYQ=="), // URI: to.Ptr("https://tempuri.org"), // }, - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.305236Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.305Z"); return t}()), // Status: to.Ptr(armlogic.WorkflowStatusSucceeded), // }, // } diff --git a/sdk/resourcemanager/logic/armlogic/workflowrunactionscoperepetitions_client.go b/sdk/resourcemanager/logic/armlogic/workflowrunactionscoperepetitions_client.go index 6db05f3a18b2..9d1066a7933a 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowrunactionscoperepetitions_client.go +++ b/sdk/resourcemanager/logic/armlogic/workflowrunactionscoperepetitions_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -33,7 +32,7 @@ type WorkflowRunActionScopeRepetitionsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkflowRunActionScopeRepetitionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkflowRunActionScopeRepetitionsClient, error) { - cl, err := arm.NewClient(moduleName+".WorkflowRunActionScopeRepetitionsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -56,18 +55,25 @@ func NewWorkflowRunActionScopeRepetitionsClient(subscriptionID string, credentia // - options - WorkflowRunActionScopeRepetitionsClientGetOptions contains the optional parameters for the WorkflowRunActionScopeRepetitionsClient.Get // method. func (client *WorkflowRunActionScopeRepetitionsClient) Get(ctx context.Context, resourceGroupName string, workflowName string, runName string, actionName string, repetitionName string, options *WorkflowRunActionScopeRepetitionsClientGetOptions) (WorkflowRunActionScopeRepetitionsClientGetResponse, error) { + var err error + const operationName = "WorkflowRunActionScopeRepetitionsClient.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, workflowName, runName, actionName, repetitionName, options) if err != nil { return WorkflowRunActionScopeRepetitionsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowRunActionScopeRepetitionsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowRunActionScopeRepetitionsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowRunActionScopeRepetitionsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -132,6 +138,7 @@ func (client *WorkflowRunActionScopeRepetitionsClient) NewListPager(resourceGrou return false }, Fetcher: func(ctx context.Context, page *WorkflowRunActionScopeRepetitionsClientListResponse) (WorkflowRunActionScopeRepetitionsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkflowRunActionScopeRepetitionsClient.NewListPager") req, err := client.listCreateRequest(ctx, resourceGroupName, workflowName, runName, actionName, options) if err != nil { return WorkflowRunActionScopeRepetitionsClientListResponse{}, err @@ -145,6 +152,7 @@ func (client *WorkflowRunActionScopeRepetitionsClient) NewListPager(resourceGrou } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/logic/armlogic/workflowrunactionscoperepetitions_client_example_test.go b/sdk/resourcemanager/logic/armlogic/workflowrunactionscoperepetitions_client_example_test.go index 1ce58728bec2..028904049721 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowrunactionscoperepetitions_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/workflowrunactionscoperepetitions_client_example_test.go @@ -51,8 +51,8 @@ func ExampleWorkflowRunActionScopeRepetitionsClient_NewListPager() { // ClientTrackingID: to.Ptr("08586775357427610445444523191"), // ActionTrackingID: to.Ptr("5c0e7c24-4891-44e8-b631-8084c5531dd5"), // }, - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.6240967Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.209588Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.624Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.209Z"); return t}()), // Status: to.Ptr(armlogic.WorkflowStatusSucceeded), // RepetitionIndexes: []*armlogic.RepetitionIndex{ // { @@ -71,8 +71,8 @@ func ExampleWorkflowRunActionScopeRepetitionsClient_NewListPager() { // ClientTrackingID: to.Ptr("08586775357427610445444523191"), // ActionTrackingID: to.Ptr("1682d0bd-7189-4478-b333-fe364a80bd69"), // }, - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.2272796Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.0686808Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.227Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.068Z"); return t}()), // Status: to.Ptr(armlogic.WorkflowStatusSucceeded), // RepetitionIndexes: []*armlogic.RepetitionIndex{ // { @@ -113,8 +113,8 @@ func ExampleWorkflowRunActionScopeRepetitionsClient_Get() { // ClientTrackingID: to.Ptr("08586775357427610445444523191"), // ActionTrackingID: to.Ptr("5c0e7c24-4891-44e8-b631-8084c5531dd5"), // }, - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.6240967Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.209588Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.624Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-18T17:05:57.209Z"); return t}()), // Status: to.Ptr(armlogic.WorkflowStatusSucceeded), // RepetitionIndexes: []*armlogic.RepetitionIndex{ // { diff --git a/sdk/resourcemanager/logic/armlogic/workflowrunoperations_client.go b/sdk/resourcemanager/logic/armlogic/workflowrunoperations_client.go index e14540a4ecc9..9a392e1de12d 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowrunoperations_client.go +++ b/sdk/resourcemanager/logic/armlogic/workflowrunoperations_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -33,7 +32,7 @@ type WorkflowRunOperationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkflowRunOperationsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkflowRunOperationsClient, error) { - cl, err := arm.NewClient(moduleName+".WorkflowRunOperationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,18 +54,25 @@ func NewWorkflowRunOperationsClient(subscriptionID string, credential azcore.Tok // - options - WorkflowRunOperationsClientGetOptions contains the optional parameters for the WorkflowRunOperationsClient.Get // method. func (client *WorkflowRunOperationsClient) Get(ctx context.Context, resourceGroupName string, workflowName string, runName string, operationID string, options *WorkflowRunOperationsClientGetOptions) (WorkflowRunOperationsClientGetResponse, error) { + var err error + const operationName = "WorkflowRunOperationsClient.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, workflowName, runName, operationID, options) if err != nil { return WorkflowRunOperationsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowRunOperationsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowRunOperationsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowRunOperationsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. diff --git a/sdk/resourcemanager/logic/armlogic/workflowrunoperations_client_example_test.go b/sdk/resourcemanager/logic/armlogic/workflowrunoperations_client_example_test.go index 3d17949a71f0..772f5dc96684 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowrunoperations_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/workflowrunoperations_client_example_test.go @@ -43,10 +43,10 @@ func ExampleWorkflowRunOperationsClient_Get() { // Correlation: &armlogic.Correlation{ // ClientTrackingID: to.Ptr("08586774142730039209110422528"), // }, - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-20T02:50:13.7177644Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-20T02:50:13.717Z"); return t}()), // Outputs: map[string]*armlogic.WorkflowOutputParameter{ // }, - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-20T02:50:12.4741081Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-20T02:50:12.474Z"); return t}()), // Status: to.Ptr(armlogic.WorkflowStatusSucceeded), // Trigger: &armlogic.WorkflowRunTrigger{ // Name: to.Ptr("Recurrence"), @@ -54,12 +54,12 @@ func ExampleWorkflowRunOperationsClient_Get() { // Correlation: &armlogic.Correlation{ // ClientTrackingID: to.Ptr("08586774142730039209110422528"), // }, - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-20T02:50:12.460076Z"); return t}()), - // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-20T02:50:12.1412543Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-20T02:50:12.460076Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-20T02:50:12.460Z"); return t}()), + // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-20T02:50:12.141Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-20T02:50:12.460Z"); return t}()), // Status: to.Ptr(armlogic.WorkflowStatusSucceeded), // }, - // WaitEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-20T02:50:12.4741081Z"); return t}()), + // WaitEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-20T02:50:12.474Z"); return t}()), // Workflow: &armlogic.ResourceReference{ // Name: to.Ptr("08586993867806980512"), // Type: to.Ptr("Microsoft.Logic/workflows/versions"), diff --git a/sdk/resourcemanager/logic/armlogic/workflowruns_client.go b/sdk/resourcemanager/logic/armlogic/workflowruns_client.go index 323dd5a10d89..c5b394597a44 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowruns_client.go +++ b/sdk/resourcemanager/logic/armlogic/workflowruns_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -34,7 +33,7 @@ type WorkflowRunsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkflowRunsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkflowRunsClient, error) { - cl, err := arm.NewClient(moduleName+".WorkflowRunsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,16 +53,22 @@ func NewWorkflowRunsClient(subscriptionID string, credential azcore.TokenCredent // - runName - The workflow run name. // - options - WorkflowRunsClientCancelOptions contains the optional parameters for the WorkflowRunsClient.Cancel method. func (client *WorkflowRunsClient) Cancel(ctx context.Context, resourceGroupName string, workflowName string, runName string, options *WorkflowRunsClientCancelOptions) (WorkflowRunsClientCancelResponse, error) { + var err error + const operationName = "WorkflowRunsClient.Cancel" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.cancelCreateRequest(ctx, resourceGroupName, workflowName, runName, options) if err != nil { return WorkflowRunsClientCancelResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowRunsClientCancelResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowRunsClientCancelResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowRunsClientCancelResponse{}, err } return WorkflowRunsClientCancelResponse{}, nil } @@ -107,18 +112,25 @@ func (client *WorkflowRunsClient) cancelCreateRequest(ctx context.Context, resou // - runName - The workflow run name. // - options - WorkflowRunsClientGetOptions contains the optional parameters for the WorkflowRunsClient.Get method. func (client *WorkflowRunsClient) Get(ctx context.Context, resourceGroupName string, workflowName string, runName string, options *WorkflowRunsClientGetOptions) (WorkflowRunsClientGetResponse, error) { + var err error + const operationName = "WorkflowRunsClient.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, workflowName, runName, options) if err != nil { return WorkflowRunsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowRunsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowRunsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowRunsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -172,25 +184,20 @@ func (client *WorkflowRunsClient) NewListPager(resourceGroupName string, workflo return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *WorkflowRunsClientListResponse) (WorkflowRunsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, workflowName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return WorkflowRunsClientListResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkflowRunsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, workflowName, options) + }, nil) if err != nil { return WorkflowRunsClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowRunsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/logic/armlogic/workflowruns_client_example_test.go b/sdk/resourcemanager/logic/armlogic/workflowruns_client_example_test.go index cc5c763837b4..34ff5e35c8c9 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowruns_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/workflowruns_client_example_test.go @@ -51,10 +51,10 @@ func ExampleWorkflowRunsClient_NewListPager() { // Correlation: &armlogic.Correlation{ // ClientTrackingID: to.Ptr("08586676746934337772206998657CU22"), // }, - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.5779999Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.577Z"); return t}()), // Outputs: map[string]*armlogic.WorkflowOutputParameter{ // }, - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.044238Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.044Z"); return t}()), // Status: to.Ptr(armlogic.WorkflowStatusSucceeded), // Trigger: &armlogic.WorkflowRunTrigger{ // Name: to.Ptr("Recurrence"), @@ -62,12 +62,12 @@ func ExampleWorkflowRunsClient_NewListPager() { // Correlation: &armlogic.Correlation{ // ClientTrackingID: to.Ptr("08586676746934337772206998657CU22"), // }, - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.0387927Z"); return t}()), - // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:31.6344174Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.0387927Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.038Z"); return t}()), + // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:31.634Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.038Z"); return t}()), // Status: to.Ptr(armlogic.WorkflowStatusSucceeded), // }, - // WaitEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.044238Z"); return t}()), + // WaitEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.044Z"); return t}()), // Workflow: &armlogic.ResourceReference{ // Name: to.Ptr("08586676754160363885"), // Type: to.Ptr("Microsoft.Logic/workflows/versions"), @@ -105,10 +105,10 @@ func ExampleWorkflowRunsClient_Get() { // Correlation: &armlogic.Correlation{ // ClientTrackingID: to.Ptr("08586676746934337772206998657CU22"), // }, - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.5779999Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.577Z"); return t}()), // Outputs: map[string]*armlogic.WorkflowOutputParameter{ // }, - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.044238Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.044Z"); return t}()), // Status: to.Ptr(armlogic.WorkflowStatusSucceeded), // Trigger: &armlogic.WorkflowRunTrigger{ // Name: to.Ptr("Recurrence"), @@ -116,12 +116,12 @@ func ExampleWorkflowRunsClient_Get() { // Correlation: &armlogic.Correlation{ // ClientTrackingID: to.Ptr("08586676746934337772206998657CU22"), // }, - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.0387927Z"); return t}()), - // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:31.6344174Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.0387927Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.038Z"); return t}()), + // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:31.634Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.038Z"); return t}()), // Status: to.Ptr(armlogic.WorkflowStatusSucceeded), // }, - // WaitEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.044238Z"); return t}()), + // WaitEndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.044Z"); return t}()), // Workflow: &armlogic.ResourceReference{ // Name: to.Ptr("08586676754160363885"), // Type: to.Ptr("Microsoft.Logic/workflows/versions"), diff --git a/sdk/resourcemanager/logic/armlogic/workflows_client.go b/sdk/resourcemanager/logic/armlogic/workflows_client.go index 2b35dd2a7b25..8478039ecac2 100644 --- a/sdk/resourcemanager/logic/armlogic/workflows_client.go +++ b/sdk/resourcemanager/logic/armlogic/workflows_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -34,7 +33,7 @@ type WorkflowsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkflowsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkflowsClient, error) { - cl, err := arm.NewClient(moduleName+".WorkflowsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,18 +54,25 @@ func NewWorkflowsClient(subscriptionID string, credential azcore.TokenCredential // - options - WorkflowsClientCreateOrUpdateOptions contains the optional parameters for the WorkflowsClient.CreateOrUpdate // method. func (client *WorkflowsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, workflowName string, workflow Workflow, options *WorkflowsClientCreateOrUpdateOptions) (WorkflowsClientCreateOrUpdateResponse, error) { + var err error + const operationName = "WorkflowsClient.CreateOrUpdate" + 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, workflowName, workflow, options) if err != nil { return WorkflowsClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowsClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return WorkflowsClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return WorkflowsClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -92,7 +98,10 @@ func (client *WorkflowsClient) createOrUpdateCreateRequest(ctx context.Context, reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, workflow) + if err := runtime.MarshalAsJSON(req, workflow); err != nil { + return nil, err + } + return req, nil } // createOrUpdateHandleResponse handles the CreateOrUpdate response. @@ -112,16 +121,22 @@ func (client *WorkflowsClient) createOrUpdateHandleResponse(resp *http.Response) // - workflowName - The workflow name. // - options - WorkflowsClientDeleteOptions contains the optional parameters for the WorkflowsClient.Delete method. func (client *WorkflowsClient) Delete(ctx context.Context, resourceGroupName string, workflowName string, options *WorkflowsClientDeleteOptions) (WorkflowsClientDeleteResponse, error) { + var err error + const operationName = "WorkflowsClient.Delete" + 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, workflowName, options) if err != nil { return WorkflowsClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowsClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusNoContent) { - return WorkflowsClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return WorkflowsClientDeleteResponse{}, err } return WorkflowsClientDeleteResponse{}, nil } @@ -160,16 +175,22 @@ func (client *WorkflowsClient) deleteCreateRequest(ctx context.Context, resource // - workflowName - The workflow name. // - options - WorkflowsClientDisableOptions contains the optional parameters for the WorkflowsClient.Disable method. func (client *WorkflowsClient) Disable(ctx context.Context, resourceGroupName string, workflowName string, options *WorkflowsClientDisableOptions) (WorkflowsClientDisableResponse, error) { + var err error + const operationName = "WorkflowsClient.Disable" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.disableCreateRequest(ctx, resourceGroupName, workflowName, options) if err != nil { return WorkflowsClientDisableResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowsClientDisableResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowsClientDisableResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowsClientDisableResponse{}, err } return WorkflowsClientDisableResponse{}, nil } @@ -208,16 +229,22 @@ func (client *WorkflowsClient) disableCreateRequest(ctx context.Context, resourc // - workflowName - The workflow name. // - options - WorkflowsClientEnableOptions contains the optional parameters for the WorkflowsClient.Enable method. func (client *WorkflowsClient) Enable(ctx context.Context, resourceGroupName string, workflowName string, options *WorkflowsClientEnableOptions) (WorkflowsClientEnableResponse, error) { + var err error + const operationName = "WorkflowsClient.Enable" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.enableCreateRequest(ctx, resourceGroupName, workflowName, options) if err != nil { return WorkflowsClientEnableResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowsClientEnableResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowsClientEnableResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowsClientEnableResponse{}, err } return WorkflowsClientEnableResponse{}, nil } @@ -258,18 +285,25 @@ func (client *WorkflowsClient) enableCreateRequest(ctx context.Context, resource // - options - WorkflowsClientGenerateUpgradedDefinitionOptions contains the optional parameters for the WorkflowsClient.GenerateUpgradedDefinition // method. func (client *WorkflowsClient) GenerateUpgradedDefinition(ctx context.Context, resourceGroupName string, workflowName string, parameters GenerateUpgradedDefinitionParameters, options *WorkflowsClientGenerateUpgradedDefinitionOptions) (WorkflowsClientGenerateUpgradedDefinitionResponse, error) { + var err error + const operationName = "WorkflowsClient.GenerateUpgradedDefinition" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.generateUpgradedDefinitionCreateRequest(ctx, resourceGroupName, workflowName, parameters, options) if err != nil { return WorkflowsClientGenerateUpgradedDefinitionResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowsClientGenerateUpgradedDefinitionResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowsClientGenerateUpgradedDefinitionResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowsClientGenerateUpgradedDefinitionResponse{}, err } - return client.generateUpgradedDefinitionHandleResponse(resp) + resp, err := client.generateUpgradedDefinitionHandleResponse(httpResp) + return resp, err } // generateUpgradedDefinitionCreateRequest creates the GenerateUpgradedDefinition request. @@ -295,7 +329,10 @@ func (client *WorkflowsClient) generateUpgradedDefinitionCreateRequest(ctx conte reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, parameters) + if err := runtime.MarshalAsJSON(req, parameters); err != nil { + return nil, err + } + return req, nil } // generateUpgradedDefinitionHandleResponse handles the GenerateUpgradedDefinition response. @@ -315,18 +352,25 @@ func (client *WorkflowsClient) generateUpgradedDefinitionHandleResponse(resp *ht // - workflowName - The workflow name. // - options - WorkflowsClientGetOptions contains the optional parameters for the WorkflowsClient.Get method. func (client *WorkflowsClient) Get(ctx context.Context, resourceGroupName string, workflowName string, options *WorkflowsClientGetOptions) (WorkflowsClientGetResponse, error) { + var err error + const operationName = "WorkflowsClient.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, workflowName, options) if err != nil { return WorkflowsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -376,25 +420,20 @@ func (client *WorkflowsClient) NewListByResourceGroupPager(resourceGroupName str return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *WorkflowsClientListByResourceGroupResponse) (WorkflowsClientListByResourceGroupResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkflowsClient.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 WorkflowsClientListByResourceGroupResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return WorkflowsClientListByResourceGroupResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -446,25 +485,20 @@ func (client *WorkflowsClient) NewListBySubscriptionPager(options *WorkflowsClie return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *WorkflowsClientListBySubscriptionResponse) (WorkflowsClientListBySubscriptionResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listBySubscriptionCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkflowsClient.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 WorkflowsClientListBySubscriptionResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return WorkflowsClientListBySubscriptionResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) - } return client.listBySubscriptionHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -511,18 +545,25 @@ func (client *WorkflowsClient) listBySubscriptionHandleResponse(resp *http.Respo // - options - WorkflowsClientListCallbackURLOptions contains the optional parameters for the WorkflowsClient.ListCallbackURL // method. func (client *WorkflowsClient) ListCallbackURL(ctx context.Context, resourceGroupName string, workflowName string, listCallbackURL GetCallbackURLParameters, options *WorkflowsClientListCallbackURLOptions) (WorkflowsClientListCallbackURLResponse, error) { + var err error + const operationName = "WorkflowsClient.ListCallbackURL" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listCallbackURLCreateRequest(ctx, resourceGroupName, workflowName, listCallbackURL, options) if err != nil { return WorkflowsClientListCallbackURLResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowsClientListCallbackURLResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowsClientListCallbackURLResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowsClientListCallbackURLResponse{}, err } - return client.listCallbackURLHandleResponse(resp) + resp, err := client.listCallbackURLHandleResponse(httpResp) + return resp, err } // listCallbackURLCreateRequest creates the ListCallbackURL request. @@ -548,7 +589,10 @@ func (client *WorkflowsClient) listCallbackURLCreateRequest(ctx context.Context, reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, listCallbackURL) + if err := runtime.MarshalAsJSON(req, listCallbackURL); err != nil { + return nil, err + } + return req, nil } // listCallbackURLHandleResponse handles the ListCallbackURL response. @@ -568,18 +612,25 @@ func (client *WorkflowsClient) listCallbackURLHandleResponse(resp *http.Response // - workflowName - The workflow name. // - options - WorkflowsClientListSwaggerOptions contains the optional parameters for the WorkflowsClient.ListSwagger method. func (client *WorkflowsClient) ListSwagger(ctx context.Context, resourceGroupName string, workflowName string, options *WorkflowsClientListSwaggerOptions) (WorkflowsClientListSwaggerResponse, error) { + var err error + const operationName = "WorkflowsClient.ListSwagger" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listSwaggerCreateRequest(ctx, resourceGroupName, workflowName, options) if err != nil { return WorkflowsClientListSwaggerResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowsClientListSwaggerResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowsClientListSwaggerResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowsClientListSwaggerResponse{}, err } - return client.listSwaggerHandleResponse(resp) + resp, err := client.listSwaggerHandleResponse(httpResp) + return resp, err } // listSwaggerCreateRequest creates the ListSwagger request. @@ -631,9 +682,14 @@ func (client *WorkflowsClient) BeginMove(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller[WorkflowsClientMoveResponse](resp, client.internal.Pipeline(), nil) + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[WorkflowsClientMoveResponse]{ + Tracer: client.internal.Tracer(), + }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[WorkflowsClientMoveResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[WorkflowsClientMoveResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -642,18 +698,24 @@ func (client *WorkflowsClient) BeginMove(ctx context.Context, resourceGroupName // // Generated from API version 2019-05-01 func (client *WorkflowsClient) move(ctx context.Context, resourceGroupName string, workflowName string, move WorkflowReference, options *WorkflowsClientBeginMoveOptions) (*http.Response, error) { + var err error + const operationName = "WorkflowsClient.BeginMove" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.moveCreateRequest(ctx, resourceGroupName, workflowName, move, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // moveCreateRequest creates the Move request. @@ -679,7 +741,10 @@ func (client *WorkflowsClient) moveCreateRequest(ctx context.Context, resourceGr reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, move) + if err := runtime.MarshalAsJSON(req, move); err != nil { + return nil, err + } + return req, nil } // RegenerateAccessKey - Regenerates the callback URL access key for request triggers. @@ -692,16 +757,22 @@ func (client *WorkflowsClient) moveCreateRequest(ctx context.Context, resourceGr // - options - WorkflowsClientRegenerateAccessKeyOptions contains the optional parameters for the WorkflowsClient.RegenerateAccessKey // method. func (client *WorkflowsClient) RegenerateAccessKey(ctx context.Context, resourceGroupName string, workflowName string, keyType RegenerateActionParameter, options *WorkflowsClientRegenerateAccessKeyOptions) (WorkflowsClientRegenerateAccessKeyResponse, error) { + var err error + const operationName = "WorkflowsClient.RegenerateAccessKey" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.regenerateAccessKeyCreateRequest(ctx, resourceGroupName, workflowName, keyType, options) if err != nil { return WorkflowsClientRegenerateAccessKeyResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowsClientRegenerateAccessKeyResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowsClientRegenerateAccessKeyResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowsClientRegenerateAccessKeyResponse{}, err } return WorkflowsClientRegenerateAccessKeyResponse{}, nil } @@ -729,7 +800,10 @@ func (client *WorkflowsClient) regenerateAccessKeyCreateRequest(ctx context.Cont reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, keyType) + if err := runtime.MarshalAsJSON(req, keyType); err != nil { + return nil, err + } + return req, nil } // Update - Updates a workflow. @@ -740,18 +814,25 @@ func (client *WorkflowsClient) regenerateAccessKeyCreateRequest(ctx context.Cont // - workflowName - The workflow name. // - options - WorkflowsClientUpdateOptions contains the optional parameters for the WorkflowsClient.Update method. func (client *WorkflowsClient) Update(ctx context.Context, resourceGroupName string, workflowName string, options *WorkflowsClientUpdateOptions) (WorkflowsClientUpdateResponse, error) { + var err error + const operationName = "WorkflowsClient.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, workflowName, options) if err != nil { return WorkflowsClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowsClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowsClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowsClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -800,16 +881,22 @@ func (client *WorkflowsClient) updateHandleResponse(resp *http.Response) (Workfl // - options - WorkflowsClientValidateByLocationOptions contains the optional parameters for the WorkflowsClient.ValidateByLocation // method. func (client *WorkflowsClient) ValidateByLocation(ctx context.Context, resourceGroupName string, location string, workflowName string, validate Workflow, options *WorkflowsClientValidateByLocationOptions) (WorkflowsClientValidateByLocationResponse, error) { + var err error + const operationName = "WorkflowsClient.ValidateByLocation" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.validateByLocationCreateRequest(ctx, resourceGroupName, location, workflowName, validate, options) if err != nil { return WorkflowsClientValidateByLocationResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowsClientValidateByLocationResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowsClientValidateByLocationResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowsClientValidateByLocationResponse{}, err } return WorkflowsClientValidateByLocationResponse{}, nil } @@ -841,7 +928,10 @@ func (client *WorkflowsClient) validateByLocationCreateRequest(ctx context.Conte reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, validate) + if err := runtime.MarshalAsJSON(req, validate); err != nil { + return nil, err + } + return req, nil } // ValidateByResourceGroup - Validates the workflow. @@ -854,16 +944,22 @@ func (client *WorkflowsClient) validateByLocationCreateRequest(ctx context.Conte // - options - WorkflowsClientValidateByResourceGroupOptions contains the optional parameters for the WorkflowsClient.ValidateByResourceGroup // method. func (client *WorkflowsClient) ValidateByResourceGroup(ctx context.Context, resourceGroupName string, workflowName string, validate Workflow, options *WorkflowsClientValidateByResourceGroupOptions) (WorkflowsClientValidateByResourceGroupResponse, error) { + var err error + const operationName = "WorkflowsClient.ValidateByResourceGroup" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.validateByResourceGroupCreateRequest(ctx, resourceGroupName, workflowName, validate, options) if err != nil { return WorkflowsClientValidateByResourceGroupResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowsClientValidateByResourceGroupResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowsClientValidateByResourceGroupResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowsClientValidateByResourceGroupResponse{}, err } return WorkflowsClientValidateByResourceGroupResponse{}, nil } @@ -891,5 +987,8 @@ func (client *WorkflowsClient) validateByResourceGroupCreateRequest(ctx context. reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, validate) + if err := runtime.MarshalAsJSON(req, validate); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/logic/armlogic/workflows_client_example_test.go b/sdk/resourcemanager/logic/armlogic/workflows_client_example_test.go index a39e9c485731..d056198591de 100644 --- a/sdk/resourcemanager/logic/armlogic/workflows_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/workflows_client_example_test.go @@ -57,8 +57,8 @@ func ExampleWorkflowsClient_NewListBySubscriptionPager() { // AccessControl: &armlogic.FlowAccessControlConfiguration{ // }, // AccessEndpoint: to.Ptr("http://tempuri.org"), - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T22:54:54.3533634Z"); return t}()), - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-25T01:39:21.4365247Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T22:54:54.353Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-25T01:39:21.436Z"); return t}()), // Definition: map[string]any{ // "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", // "actions":map[string]any{ @@ -154,8 +154,8 @@ func ExampleWorkflowsClient_NewListByResourceGroupPager() { // AccessControl: &armlogic.FlowAccessControlConfiguration{ // }, // AccessEndpoint: to.Ptr("http://tempuri.org"), - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T22:54:54.3533634Z"); return t}()), - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-25T01:39:21.4365247Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T22:54:54.353Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-25T01:39:21.436Z"); return t}()), // Definition: map[string]any{ // "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", // "actions":map[string]any{ @@ -241,8 +241,8 @@ func ExampleWorkflowsClient_Get() { // }, // Properties: &armlogic.WorkflowProperties{ // AccessEndpoint: to.Ptr("http://tempuri.org"), - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T22:54:54.3533634Z"); return t}()), - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-25T01:39:21.4365247Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T22:54:54.353Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-25T01:39:21.436Z"); return t}()), // Definition: map[string]any{ // "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2018-07-01-preview/workflowdefinition.json#", // "actions":map[string]any{ @@ -379,8 +379,8 @@ func ExampleWorkflowsClient_CreateOrUpdate() { // res.Workflow = armlogic.Workflow{ // Properties: &armlogic.WorkflowProperties{ // AccessEndpoint: to.Ptr("http://tempuri.org"), - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T22:54:54.3533634Z"); return t}()), - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-25T01:39:21.4365247Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T22:54:54.353Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-25T01:39:21.436Z"); return t}()), // Definition: map[string]any{ // "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", // "actions":map[string]any{ @@ -463,8 +463,8 @@ func ExampleWorkflowsClient_Update() { // res.Workflow = armlogic.Workflow{ // Properties: &armlogic.WorkflowProperties{ // AccessEndpoint: to.Ptr("http://tempuri.org"), - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T22:54:54.3533634Z"); return t}()), - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-25T01:39:21.4365247Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T22:54:54.353Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-25T01:39:21.436Z"); return t}()), // Definition: map[string]any{ // "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", // "actions":map[string]any{ @@ -624,7 +624,7 @@ func ExampleWorkflowsClient_ListCallbackURL() { } res, err := clientFactory.NewWorkflowsClient().ListCallbackURL(ctx, "testResourceGroup", "testWorkflow", armlogic.GetCallbackURLParameters{ KeyType: to.Ptr(armlogic.KeyTypePrimary), - NotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-19T16:00:00Z"); return t }()), + NotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-19T16:00:00.000Z"); return t }()), }, nil) if err != nil { log.Fatalf("failed to finish the request: %v", err) diff --git a/sdk/resourcemanager/logic/armlogic/workflows_live_test.go b/sdk/resourcemanager/logic/armlogic/workflows_live_test.go index c91ff8f1dff7..ec487d853879 100644 --- a/sdk/resourcemanager/logic/armlogic/workflows_live_test.go +++ b/sdk/resourcemanager/logic/armlogic/workflows_live_test.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/arm" "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/testutil" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2/testutil" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/logic/armlogic" "github.com/stretchr/testify/suite" ) @@ -41,9 +41,9 @@ func (testsuite *WorkflowsTestSuite) SetupSuite() { testsuite.cred, testsuite.options = testutil.GetCredAndClientOptions(testsuite.T()) testsuite.integrationAccountName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "integrat", 14, false) testsuite.workflowName, _ = recording.GenerateAlphaNumericID(testsuite.T(), "workflow", 14, false) - testsuite.location = testutil.GetEnv("LOCATION", "westus") - testsuite.resourceGroupName = testutil.GetEnv("RESOURCE_GROUP_NAME", "scenarioTestTempGroup") - testsuite.subscriptionId = testutil.GetEnv("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") + testsuite.location = recording.GetEnvVariable("LOCATION", "westus") + testsuite.resourceGroupName = recording.GetEnvVariable("RESOURCE_GROUP_NAME", "scenarioTestTempGroup") + testsuite.subscriptionId = recording.GetEnvVariable("AZURE_SUBSCRIPTION_ID", "00000000-0000-0000-0000-000000000000") resourceGroup, _, err := testutil.CreateResourceGroup(testsuite.ctx, testsuite.subscriptionId, testsuite.cred, testsuite.options, testsuite.location) testsuite.Require().NoError(err) testsuite.resourceGroupName = *resourceGroup.Name diff --git a/sdk/resourcemanager/logic/armlogic/workflowtriggerhistories_client.go b/sdk/resourcemanager/logic/armlogic/workflowtriggerhistories_client.go index bf3a7ba3eacf..63a4b21467c9 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowtriggerhistories_client.go +++ b/sdk/resourcemanager/logic/armlogic/workflowtriggerhistories_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -34,7 +33,7 @@ type WorkflowTriggerHistoriesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkflowTriggerHistoriesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkflowTriggerHistoriesClient, error) { - cl, err := arm.NewClient(moduleName+".WorkflowTriggerHistoriesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -56,18 +55,25 @@ func NewWorkflowTriggerHistoriesClient(subscriptionID string, credential azcore. // - options - WorkflowTriggerHistoriesClientGetOptions contains the optional parameters for the WorkflowTriggerHistoriesClient.Get // method. func (client *WorkflowTriggerHistoriesClient) Get(ctx context.Context, resourceGroupName string, workflowName string, triggerName string, historyName string, options *WorkflowTriggerHistoriesClientGetOptions) (WorkflowTriggerHistoriesClientGetResponse, error) { + var err error + const operationName = "WorkflowTriggerHistoriesClient.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, workflowName, triggerName, historyName, options) if err != nil { return WorkflowTriggerHistoriesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowTriggerHistoriesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowTriggerHistoriesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowTriggerHistoriesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -127,25 +133,20 @@ func (client *WorkflowTriggerHistoriesClient) NewListPager(resourceGroupName str return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *WorkflowTriggerHistoriesClientListResponse) (WorkflowTriggerHistoriesClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, workflowName, triggerName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return WorkflowTriggerHistoriesClientListResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkflowTriggerHistoriesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, workflowName, triggerName, options) + }, nil) if err != nil { return WorkflowTriggerHistoriesClientListResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowTriggerHistoriesClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -205,16 +206,22 @@ func (client *WorkflowTriggerHistoriesClient) listHandleResponse(resp *http.Resp // - options - WorkflowTriggerHistoriesClientResubmitOptions contains the optional parameters for the WorkflowTriggerHistoriesClient.Resubmit // method. func (client *WorkflowTriggerHistoriesClient) Resubmit(ctx context.Context, resourceGroupName string, workflowName string, triggerName string, historyName string, options *WorkflowTriggerHistoriesClientResubmitOptions) (WorkflowTriggerHistoriesClientResubmitResponse, error) { + var err error + const operationName = "WorkflowTriggerHistoriesClient.Resubmit" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.resubmitCreateRequest(ctx, resourceGroupName, workflowName, triggerName, historyName, options) if err != nil { return WorkflowTriggerHistoriesClientResubmitResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowTriggerHistoriesClientResubmitResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusAccepted) { - return WorkflowTriggerHistoriesClientResubmitResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return WorkflowTriggerHistoriesClientResubmitResponse{}, err } return WorkflowTriggerHistoriesClientResubmitResponse{}, nil } diff --git a/sdk/resourcemanager/logic/armlogic/workflowtriggerhistories_client_example_test.go b/sdk/resourcemanager/logic/armlogic/workflowtriggerhistories_client_example_test.go index b36b617bb803..d84a43ef09f3 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowtriggerhistories_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/workflowtriggerhistories_client_example_test.go @@ -52,15 +52,15 @@ func ExampleWorkflowTriggerHistoriesClient_NewListPager() { // Correlation: &armlogic.Correlation{ // ClientTrackingID: to.Ptr("08586676746934337772206998657CU22"), // }, - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.2987996Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.298Z"); return t}()), // Fired: to.Ptr(true), // Run: &armlogic.ResourceReference{ // Name: to.Ptr("08586676746934337772206998657CU22"), // Type: to.Ptr("Microsoft.Logic/workflows/runs"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/workflows/testWorkflowName/runs/08586676746934337772206998657CU22"), // }, - // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:31.6344174Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.0387927Z"); return t}()), + // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:31.634Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.038Z"); return t}()), // Status: to.Ptr(armlogic.WorkflowStatusSucceeded), // }, // }}, @@ -95,15 +95,15 @@ func ExampleWorkflowTriggerHistoriesClient_Get() { // Correlation: &armlogic.Correlation{ // ClientTrackingID: to.Ptr("08586676746934337772206998657CU22"), // }, - // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.2987996Z"); return t}()), + // EndTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.298Z"); return t}()), // Fired: to.Ptr(true), // Run: &armlogic.ResourceReference{ // Name: to.Ptr("08586676746934337772206998657CU22"), // Type: to.Ptr("Microsoft.Logic/workflows/runs"), // ID: to.Ptr("/subscriptions/34adfa4f-cedf-4dc0-ba29-b6d1a69ab345/resourceGroups/testResourceGroup/providers/Microsoft.Logic/workflows/testWorkflowName/runs/08586676746934337772206998657CU22"), // }, - // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:31.6344174Z"); return t}()), - // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.0387927Z"); return t}()), + // ScheduledTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:31.634Z"); return t}()), + // StartTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T20:16:32.038Z"); return t}()), // Status: to.Ptr(armlogic.WorkflowStatusSucceeded), // }, // } diff --git a/sdk/resourcemanager/logic/armlogic/workflowtriggers_client.go b/sdk/resourcemanager/logic/armlogic/workflowtriggers_client.go index 2bc6eae788df..5b5ec9a2b862 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowtriggers_client.go +++ b/sdk/resourcemanager/logic/armlogic/workflowtriggers_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -34,7 +33,7 @@ type WorkflowTriggersClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkflowTriggersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkflowTriggersClient, error) { - cl, err := arm.NewClient(moduleName+".WorkflowTriggersClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,18 +53,25 @@ func NewWorkflowTriggersClient(subscriptionID string, credential azcore.TokenCre // - triggerName - The workflow trigger name. // - options - WorkflowTriggersClientGetOptions contains the optional parameters for the WorkflowTriggersClient.Get method. func (client *WorkflowTriggersClient) Get(ctx context.Context, resourceGroupName string, workflowName string, triggerName string, options *WorkflowTriggersClientGetOptions) (WorkflowTriggersClientGetResponse, error) { + var err error + const operationName = "WorkflowTriggersClient.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, workflowName, triggerName, options) if err != nil { return WorkflowTriggersClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowTriggersClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowTriggersClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowTriggersClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -117,18 +123,25 @@ func (client *WorkflowTriggersClient) getHandleResponse(resp *http.Response) (Wo // - options - WorkflowTriggersClientGetSchemaJSONOptions contains the optional parameters for the WorkflowTriggersClient.GetSchemaJSON // method. func (client *WorkflowTriggersClient) GetSchemaJSON(ctx context.Context, resourceGroupName string, workflowName string, triggerName string, options *WorkflowTriggersClientGetSchemaJSONOptions) (WorkflowTriggersClientGetSchemaJSONResponse, error) { + var err error + const operationName = "WorkflowTriggersClient.GetSchemaJSON" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.getSchemaJSONCreateRequest(ctx, resourceGroupName, workflowName, triggerName, options) if err != nil { return WorkflowTriggersClientGetSchemaJSONResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowTriggersClientGetSchemaJSONResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowTriggersClientGetSchemaJSONResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowTriggersClientGetSchemaJSONResponse{}, err } - return client.getSchemaJSONHandleResponse(resp) + resp, err := client.getSchemaJSONHandleResponse(httpResp) + return resp, err } // getSchemaJSONCreateRequest creates the GetSchemaJSON request. @@ -183,25 +196,20 @@ func (client *WorkflowTriggersClient) NewListPager(resourceGroupName string, wor return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *WorkflowTriggersClientListResponse) (WorkflowTriggersClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, workflowName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkflowTriggersClient.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, resourceGroupName, workflowName, options) + }, nil) if err != nil { return WorkflowTriggersClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return WorkflowTriggersClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowTriggersClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -256,18 +264,25 @@ func (client *WorkflowTriggersClient) listHandleResponse(resp *http.Response) (W // - options - WorkflowTriggersClientListCallbackURLOptions contains the optional parameters for the WorkflowTriggersClient.ListCallbackURL // method. func (client *WorkflowTriggersClient) ListCallbackURL(ctx context.Context, resourceGroupName string, workflowName string, triggerName string, options *WorkflowTriggersClientListCallbackURLOptions) (WorkflowTriggersClientListCallbackURLResponse, error) { + var err error + const operationName = "WorkflowTriggersClient.ListCallbackURL" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listCallbackURLCreateRequest(ctx, resourceGroupName, workflowName, triggerName, options) if err != nil { return WorkflowTriggersClientListCallbackURLResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowTriggersClientListCallbackURLResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowTriggersClientListCallbackURLResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowTriggersClientListCallbackURLResponse{}, err } - return client.listCallbackURLHandleResponse(resp) + resp, err := client.listCallbackURLHandleResponse(httpResp) + return resp, err } // listCallbackURLCreateRequest creates the ListCallbackURL request. @@ -318,16 +333,22 @@ func (client *WorkflowTriggersClient) listCallbackURLHandleResponse(resp *http.R // - triggerName - The workflow trigger name. // - options - WorkflowTriggersClientResetOptions contains the optional parameters for the WorkflowTriggersClient.Reset method. func (client *WorkflowTriggersClient) Reset(ctx context.Context, resourceGroupName string, workflowName string, triggerName string, options *WorkflowTriggersClientResetOptions) (WorkflowTriggersClientResetResponse, error) { + var err error + const operationName = "WorkflowTriggersClient.Reset" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.resetCreateRequest(ctx, resourceGroupName, workflowName, triggerName, options) if err != nil { return WorkflowTriggersClientResetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowTriggersClientResetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowTriggersClientResetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowTriggersClientResetResponse{}, err } return WorkflowTriggersClientResetResponse{}, nil } @@ -371,16 +392,22 @@ func (client *WorkflowTriggersClient) resetCreateRequest(ctx context.Context, re // - triggerName - The workflow trigger name. // - options - WorkflowTriggersClientRunOptions contains the optional parameters for the WorkflowTriggersClient.Run method. func (client *WorkflowTriggersClient) Run(ctx context.Context, resourceGroupName string, workflowName string, triggerName string, options *WorkflowTriggersClientRunOptions) (WorkflowTriggersClientRunResponse, error) { + var err error + const operationName = "WorkflowTriggersClient.Run" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.runCreateRequest(ctx, resourceGroupName, workflowName, triggerName, options) if err != nil { return WorkflowTriggersClientRunResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowTriggersClientRunResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted) { - return WorkflowTriggersClientRunResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted) { + err = runtime.NewResponseError(httpResp) + return WorkflowTriggersClientRunResponse{}, err } return WorkflowTriggersClientRunResponse{}, nil } @@ -426,16 +453,22 @@ func (client *WorkflowTriggersClient) runCreateRequest(ctx context.Context, reso // - options - WorkflowTriggersClientSetStateOptions contains the optional parameters for the WorkflowTriggersClient.SetState // method. func (client *WorkflowTriggersClient) SetState(ctx context.Context, resourceGroupName string, workflowName string, triggerName string, setState SetTriggerStateActionDefinition, options *WorkflowTriggersClientSetStateOptions) (WorkflowTriggersClientSetStateResponse, error) { + var err error + const operationName = "WorkflowTriggersClient.SetState" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.setStateCreateRequest(ctx, resourceGroupName, workflowName, triggerName, setState, options) if err != nil { return WorkflowTriggersClientSetStateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowTriggersClientSetStateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowTriggersClientSetStateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowTriggersClientSetStateResponse{}, err } return WorkflowTriggersClientSetStateResponse{}, nil } @@ -467,5 +500,8 @@ func (client *WorkflowTriggersClient) setStateCreateRequest(ctx context.Context, reqQP.Set("api-version", "2019-05-01") req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} - return req, runtime.MarshalAsJSON(req, setState) + if err := runtime.MarshalAsJSON(req, setState); err != nil { + return nil, err + } + return req, nil } diff --git a/sdk/resourcemanager/logic/armlogic/workflowtriggers_client_example_test.go b/sdk/resourcemanager/logic/armlogic/workflowtriggers_client_example_test.go index 5f485bbc2379..a03a0b5a3fd3 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowtriggers_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/workflowtriggers_client_example_test.go @@ -49,8 +49,8 @@ func ExampleWorkflowTriggersClient_NewListPager() { // Name: to.Ptr("manual"), // Type: to.Ptr("Microsoft.Logic/workflows/triggers"), // Properties: &armlogic.WorkflowTriggerProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T18:47:49.5288666Z"); return t}()), - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T17:32:30.2496336Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T18:47:49.528Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T17:32:30.249Z"); return t}()), // ProvisioningState: to.Ptr(armlogic.WorkflowTriggerProvisioningStateSucceeded), // State: to.Ptr(armlogic.WorkflowStateEnabled), // Workflow: &armlogic.ResourceReference{ @@ -87,8 +87,8 @@ func ExampleWorkflowTriggersClient_Get() { // Name: to.Ptr("manual"), // Type: to.Ptr("Microsoft.Logic/workflows/triggers"), // Properties: &armlogic.WorkflowTriggerProperties{ - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T18:47:49.5288666Z"); return t}()), - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T17:32:30.2496336Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T18:47:49.528Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-10T17:32:30.249Z"); return t}()), // ProvisioningState: to.Ptr(armlogic.WorkflowTriggerProvisioningStateSucceeded), // State: to.Ptr(armlogic.WorkflowStateEnabled), // Workflow: &armlogic.ResourceReference{ diff --git a/sdk/resourcemanager/logic/armlogic/workflowversions_client.go b/sdk/resourcemanager/logic/armlogic/workflowversions_client.go index efd2463a0fa4..cfb9b5c2be22 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowversions_client.go +++ b/sdk/resourcemanager/logic/armlogic/workflowversions_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -34,7 +33,7 @@ type WorkflowVersionsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkflowVersionsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkflowVersionsClient, error) { - cl, err := arm.NewClient(moduleName+".WorkflowVersionsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,18 +53,25 @@ func NewWorkflowVersionsClient(subscriptionID string, credential azcore.TokenCre // - versionID - The workflow versionId. // - options - WorkflowVersionsClientGetOptions contains the optional parameters for the WorkflowVersionsClient.Get method. func (client *WorkflowVersionsClient) Get(ctx context.Context, resourceGroupName string, workflowName string, versionID string, options *WorkflowVersionsClientGetOptions) (WorkflowVersionsClientGetResponse, error) { + var err error + const operationName = "WorkflowVersionsClient.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, workflowName, versionID, options) if err != nil { return WorkflowVersionsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowVersionsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowVersionsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowVersionsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -120,25 +126,20 @@ func (client *WorkflowVersionsClient) NewListPager(resourceGroupName string, wor return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *WorkflowVersionsClientListResponse) (WorkflowVersionsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, workflowName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "WorkflowVersionsClient.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, resourceGroupName, workflowName, options) + }, nil) if err != nil { return WorkflowVersionsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return WorkflowVersionsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowVersionsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/logic/armlogic/workflowversions_client_example_test.go b/sdk/resourcemanager/logic/armlogic/workflowversions_client_example_test.go index 25ee61fddcf4..df246678d406 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowversions_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/workflowversions_client_example_test.go @@ -50,8 +50,8 @@ func ExampleWorkflowVersionsClient_NewListPager() { // }, // Properties: &armlogic.WorkflowVersionProperties{ // AccessEndpoint: to.Ptr("http://tempuri.org"), - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T22:54:54.3533634Z"); return t}()), - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-25T01:39:21.4365247Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T22:54:54.353Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-25T01:39:21.436Z"); return t}()), // Definition: map[string]any{ // "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", // "actions":map[string]any{ @@ -137,8 +137,8 @@ func ExampleWorkflowVersionsClient_Get() { // }, // Properties: &armlogic.WorkflowVersionProperties{ // AccessEndpoint: to.Ptr("http://tempuri.org"), - // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T22:54:54.3533634Z"); return t}()), - // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-25T01:39:21.4365247Z"); return t}()), + // ChangedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-08-09T22:54:54.353Z"); return t}()), + // CreatedTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-04-25T01:39:21.436Z"); return t}()), // Definition: map[string]any{ // "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#", // "actions":map[string]any{ diff --git a/sdk/resourcemanager/logic/armlogic/workflowversiontriggers_client.go b/sdk/resourcemanager/logic/armlogic/workflowversiontriggers_client.go index fa867c2c792a..b50eed946ea1 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowversiontriggers_client.go +++ b/sdk/resourcemanager/logic/armlogic/workflowversiontriggers_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogic @@ -33,7 +32,7 @@ type WorkflowVersionTriggersClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewWorkflowVersionTriggersClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*WorkflowVersionTriggersClient, error) { - cl, err := arm.NewClient(moduleName+".WorkflowVersionTriggersClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -55,18 +54,25 @@ func NewWorkflowVersionTriggersClient(subscriptionID string, credential azcore.T // - options - WorkflowVersionTriggersClientListCallbackURLOptions contains the optional parameters for the WorkflowVersionTriggersClient.ListCallbackURL // method. func (client *WorkflowVersionTriggersClient) ListCallbackURL(ctx context.Context, resourceGroupName string, workflowName string, versionID string, triggerName string, options *WorkflowVersionTriggersClientListCallbackURLOptions) (WorkflowVersionTriggersClientListCallbackURLResponse, error) { + var err error + const operationName = "WorkflowVersionTriggersClient.ListCallbackURL" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.listCallbackURLCreateRequest(ctx, resourceGroupName, workflowName, versionID, triggerName, options) if err != nil { return WorkflowVersionTriggersClientListCallbackURLResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return WorkflowVersionTriggersClientListCallbackURLResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return WorkflowVersionTriggersClientListCallbackURLResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return WorkflowVersionTriggersClientListCallbackURLResponse{}, err } - return client.listCallbackURLHandleResponse(resp) + resp, err := client.listCallbackURLHandleResponse(httpResp) + return resp, err } // listCallbackURLCreateRequest creates the ListCallbackURL request. @@ -101,7 +107,10 @@ func (client *WorkflowVersionTriggersClient) listCallbackURLCreateRequest(ctx co req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Parameters != nil { - return req, runtime.MarshalAsJSON(req, *options.Parameters) + if err := runtime.MarshalAsJSON(req, *options.Parameters); err != nil { + return nil, err + } + return req, nil } return req, nil } diff --git a/sdk/resourcemanager/logic/armlogic/workflowversiontriggers_client_example_test.go b/sdk/resourcemanager/logic/armlogic/workflowversiontriggers_client_example_test.go index c6defe27daff..18f491aaefd4 100644 --- a/sdk/resourcemanager/logic/armlogic/workflowversiontriggers_client_example_test.go +++ b/sdk/resourcemanager/logic/armlogic/workflowversiontriggers_client_example_test.go @@ -33,7 +33,7 @@ func ExampleWorkflowVersionTriggersClient_ListCallbackURL() { } res, err := clientFactory.NewWorkflowVersionTriggersClient().ListCallbackURL(ctx, "testResourceGroup", "testWorkflowName", "testWorkflowVersionId", "testTriggerName", &armlogic.WorkflowVersionTriggersClientListCallbackURLOptions{Parameters: &armlogic.GetCallbackURLParameters{ KeyType: to.Ptr(armlogic.KeyTypePrimary), - NotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-05T08:00:00Z"); return t }()), + NotAfter: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-03-05T08:00:00.000Z"); return t }()), }, }) if err != nil { diff --git a/sdk/resourcemanager/logz/armlogz/CHANGELOG.md b/sdk/resourcemanager/logz/armlogz/CHANGELOG.md index e0a60027f043..bb41132c0d07 100644 --- a/sdk/resourcemanager/logz/armlogz/CHANGELOG.md +++ b/sdk/resourcemanager/logz/armlogz/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.2.0 (2023-11-24) +### Features Added + +- Support for test fakes and OpenTelemetry trace spans. + + ## 1.1.1 (2023-04-14) ### Bug Fixes diff --git a/sdk/resourcemanager/logz/armlogz/README.md b/sdk/resourcemanager/logz/armlogz/README.md index d77ea41c2c54..a9529a6d014b 100644 --- a/sdk/resourcemanager/logz/armlogz/README.md +++ b/sdk/resourcemanager/logz/armlogz/README.md @@ -60,6 +60,13 @@ A client groups a set of related APIs, providing access to its functionality. C client := clientFactory.NewSingleSignOnClient() ``` +## 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 diff --git a/sdk/resourcemanager/logz/armlogz/autorest.md b/sdk/resourcemanager/logz/armlogz/autorest.md index ee051bbaedcf..2bd9a7f65387 100644 --- a/sdk/resourcemanager/logz/armlogz/autorest.md +++ b/sdk/resourcemanager/logz/armlogz/autorest.md @@ -8,6 +8,6 @@ require: - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/logz/resource-manager/readme.md - https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/logz/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.1.1 +module-version: 1.2.0 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/logz/armlogz/client_factory.go b/sdk/resourcemanager/logz/armlogz/client_factory.go index 9478b8bce90a..f259f647361d 100644 --- a/sdk/resourcemanager/logz/armlogz/client_factory.go +++ b/sdk/resourcemanager/logz/armlogz/client_factory.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogz @@ -28,7 +27,7 @@ type ClientFactory struct { // - 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+".ClientFactory", moduleVersion, credential, options) + _, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -38,37 +37,44 @@ func NewClientFactory(subscriptionID string, credential azcore.TokenCredential, }, nil } +// NewMonitorClient creates a new instance of MonitorClient. +func (c *ClientFactory) NewMonitorClient() *MonitorClient { + subClient, _ := NewMonitorClient(c.subscriptionID, c.credential, c.options) + return subClient +} + +// NewMonitorsClient creates a new instance of MonitorsClient. func (c *ClientFactory) NewMonitorsClient() *MonitorsClient { subClient, _ := NewMonitorsClient(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 } -func (c *ClientFactory) NewTagRulesClient() *TagRulesClient { - subClient, _ := NewTagRulesClient(c.subscriptionID, c.credential, c.options) - return subClient -} - +// NewSingleSignOnClient creates a new instance of SingleSignOnClient. func (c *ClientFactory) NewSingleSignOnClient() *SingleSignOnClient { subClient, _ := NewSingleSignOnClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewSubAccountClient creates a new instance of SubAccountClient. func (c *ClientFactory) NewSubAccountClient() *SubAccountClient { subClient, _ := NewSubAccountClient(c.subscriptionID, c.credential, c.options) return subClient } +// NewSubAccountTagRulesClient creates a new instance of SubAccountTagRulesClient. func (c *ClientFactory) NewSubAccountTagRulesClient() *SubAccountTagRulesClient { subClient, _ := NewSubAccountTagRulesClient(c.subscriptionID, c.credential, c.options) return subClient } -func (c *ClientFactory) NewMonitorClient() *MonitorClient { - subClient, _ := NewMonitorClient(c.subscriptionID, c.credential, c.options) +// NewTagRulesClient creates a new instance of TagRulesClient. +func (c *ClientFactory) NewTagRulesClient() *TagRulesClient { + subClient, _ := NewTagRulesClient(c.subscriptionID, c.credential, c.options) return subClient } diff --git a/sdk/resourcemanager/logz/armlogz/constants.go b/sdk/resourcemanager/logz/armlogz/constants.go index 85a075a524a6..127279949f7b 100644 --- a/sdk/resourcemanager/logz/armlogz/constants.go +++ b/sdk/resourcemanager/logz/armlogz/constants.go @@ -3,15 +3,14 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogz const ( - moduleName = "armlogz" - moduleVersion = "v1.1.1" + moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/logz/armlogz" + moduleVersion = "v1.2.0" ) // CreatedByType - The type of identity that created the resource. diff --git a/sdk/resourcemanager/logz/armlogz/fake/internal.go b/sdk/resourcemanager/logz/armlogz/fake/internal.go new file mode 100644 index 000000000000..5f75802a569e --- /dev/null +++ b/sdk/resourcemanager/logz/armlogz/fake/internal.go @@ -0,0 +1,64 @@ +//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 ( + "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" + "net/http" + "sync" +) + +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/logz/armlogz/fake/monitor_server.go b/sdk/resourcemanager/logz/armlogz/fake/monitor_server.go new file mode 100644 index 000000000000..defa5dca0b04 --- /dev/null +++ b/sdk/resourcemanager/logz/armlogz/fake/monitor_server.go @@ -0,0 +1,212 @@ +//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/logz/armlogz" + "net/http" + "net/url" + "reflect" + "regexp" +) + +// MonitorServer is a fake server for instances of the armlogz.MonitorClient type. +type MonitorServer struct { + // NewListVMHostUpdatePager is the fake for method MonitorClient.NewListVMHostUpdatePager + // HTTP status codes to indicate success: http.StatusOK + NewListVMHostUpdatePager func(resourceGroupName string, monitorName string, options *armlogz.MonitorClientListVMHostUpdateOptions) (resp azfake.PagerResponder[armlogz.MonitorClientListVMHostUpdateResponse]) + + // NewListVMHostsPager is the fake for method MonitorClient.NewListVMHostsPager + // HTTP status codes to indicate success: http.StatusOK + NewListVMHostsPager func(resourceGroupName string, monitorName string, options *armlogz.MonitorClientListVMHostsOptions) (resp azfake.PagerResponder[armlogz.MonitorClientListVMHostsResponse]) + + // VMHostPayload is the fake for method MonitorClient.VMHostPayload + // HTTP status codes to indicate success: http.StatusOK + VMHostPayload func(ctx context.Context, resourceGroupName string, monitorName string, options *armlogz.MonitorClientVMHostPayloadOptions) (resp azfake.Responder[armlogz.MonitorClientVMHostPayloadResponse], errResp azfake.ErrorResponder) +} + +// NewMonitorServerTransport creates a new instance of MonitorServerTransport with the provided implementation. +// The returned MonitorServerTransport instance is connected to an instance of armlogz.MonitorClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewMonitorServerTransport(srv *MonitorServer) *MonitorServerTransport { + return &MonitorServerTransport{ + srv: srv, + newListVMHostUpdatePager: newTracker[azfake.PagerResponder[armlogz.MonitorClientListVMHostUpdateResponse]](), + newListVMHostsPager: newTracker[azfake.PagerResponder[armlogz.MonitorClientListVMHostsResponse]](), + } +} + +// MonitorServerTransport connects instances of armlogz.MonitorClient to instances of MonitorServer. +// Don't use this type directly, use NewMonitorServerTransport instead. +type MonitorServerTransport struct { + srv *MonitorServer + newListVMHostUpdatePager *tracker[azfake.PagerResponder[armlogz.MonitorClientListVMHostUpdateResponse]] + newListVMHostsPager *tracker[azfake.PagerResponder[armlogz.MonitorClientListVMHostsResponse]] +} + +// Do implements the policy.Transporter interface for MonitorServerTransport. +func (m *MonitorServerTransport) 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 "MonitorClient.NewListVMHostUpdatePager": + resp, err = m.dispatchNewListVMHostUpdatePager(req) + case "MonitorClient.NewListVMHostsPager": + resp, err = m.dispatchNewListVMHostsPager(req) + case "MonitorClient.VMHostPayload": + resp, err = m.dispatchVMHostPayload(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *MonitorServerTransport) dispatchNewListVMHostUpdatePager(req *http.Request) (*http.Response, error) { + if m.srv.NewListVMHostUpdatePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListVMHostUpdatePager not implemented")} + } + newListVMHostUpdatePager := m.newListVMHostUpdatePager.get(req) + if newListVMHostUpdatePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/vmHostUpdate` + 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[armlogz.VMHostUpdateRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + var options *armlogz.MonitorClientListVMHostUpdateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armlogz.MonitorClientListVMHostUpdateOptions{ + Body: &body, + } + } + resp := m.srv.NewListVMHostUpdatePager(resourceGroupNameParam, monitorNameParam, options) + newListVMHostUpdatePager = &resp + m.newListVMHostUpdatePager.add(req, newListVMHostUpdatePager) + server.PagerResponderInjectNextLinks(newListVMHostUpdatePager, req, func(page *armlogz.MonitorClientListVMHostUpdateResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListVMHostUpdatePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + m.newListVMHostUpdatePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListVMHostUpdatePager) { + m.newListVMHostUpdatePager.remove(req) + } + return resp, nil +} + +func (m *MonitorServerTransport) dispatchNewListVMHostsPager(req *http.Request) (*http.Response, error) { + if m.srv.NewListVMHostsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListVMHostsPager not implemented")} + } + newListVMHostsPager := m.newListVMHostsPager.get(req) + if newListVMHostsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listVMHosts` + 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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + resp := m.srv.NewListVMHostsPager(resourceGroupNameParam, monitorNameParam, nil) + newListVMHostsPager = &resp + m.newListVMHostsPager.add(req, newListVMHostsPager) + server.PagerResponderInjectNextLinks(newListVMHostsPager, req, func(page *armlogz.MonitorClientListVMHostsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListVMHostsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + m.newListVMHostsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListVMHostsPager) { + m.newListVMHostsPager.remove(req) + } + return resp, nil +} + +func (m *MonitorServerTransport) dispatchVMHostPayload(req *http.Request) (*http.Response, error) { + if m.srv.VMHostPayload == nil { + return nil, &nonRetriableError{errors.New("fake for method VMHostPayload not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/vmHostPayload` + 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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.VMHostPayload(req.Context(), resourceGroupNameParam, monitorNameParam, 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).VMExtensionPayload, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/logz/armlogz/fake/monitors_server.go b/sdk/resourcemanager/logz/armlogz/fake/monitors_server.go new file mode 100644 index 000000000000..2006eafa1365 --- /dev/null +++ b/sdk/resourcemanager/logz/armlogz/fake/monitors_server.go @@ -0,0 +1,461 @@ +//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/logz/armlogz" + "net/http" + "net/url" + "reflect" + "regexp" +) + +// MonitorsServer is a fake server for instances of the armlogz.MonitorsClient type. +type MonitorsServer struct { + // BeginCreate is the fake for method MonitorsClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, monitorName string, options *armlogz.MonitorsClientBeginCreateOptions) (resp azfake.PollerResponder[armlogz.MonitorsClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method MonitorsClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, monitorName string, options *armlogz.MonitorsClientBeginDeleteOptions) (resp azfake.PollerResponder[armlogz.MonitorsClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method MonitorsClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, monitorName string, options *armlogz.MonitorsClientGetOptions) (resp azfake.Responder[armlogz.MonitorsClientGetResponse], errResp azfake.ErrorResponder) + + // NewListByResourceGroupPager is the fake for method MonitorsClient.NewListByResourceGroupPager + // HTTP status codes to indicate success: http.StatusOK + NewListByResourceGroupPager func(resourceGroupName string, options *armlogz.MonitorsClientListByResourceGroupOptions) (resp azfake.PagerResponder[armlogz.MonitorsClientListByResourceGroupResponse]) + + // NewListBySubscriptionPager is the fake for method MonitorsClient.NewListBySubscriptionPager + // HTTP status codes to indicate success: http.StatusOK + NewListBySubscriptionPager func(options *armlogz.MonitorsClientListBySubscriptionOptions) (resp azfake.PagerResponder[armlogz.MonitorsClientListBySubscriptionResponse]) + + // NewListMonitoredResourcesPager is the fake for method MonitorsClient.NewListMonitoredResourcesPager + // HTTP status codes to indicate success: http.StatusOK + NewListMonitoredResourcesPager func(resourceGroupName string, monitorName string, options *armlogz.MonitorsClientListMonitoredResourcesOptions) (resp azfake.PagerResponder[armlogz.MonitorsClientListMonitoredResourcesResponse]) + + // NewListUserRolesPager is the fake for method MonitorsClient.NewListUserRolesPager + // HTTP status codes to indicate success: http.StatusOK + NewListUserRolesPager func(resourceGroupName string, monitorName string, options *armlogz.MonitorsClientListUserRolesOptions) (resp azfake.PagerResponder[armlogz.MonitorsClientListUserRolesResponse]) + + // Update is the fake for method MonitorsClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, monitorName string, options *armlogz.MonitorsClientUpdateOptions) (resp azfake.Responder[armlogz.MonitorsClientUpdateResponse], errResp azfake.ErrorResponder) +} + +// NewMonitorsServerTransport creates a new instance of MonitorsServerTransport with the provided implementation. +// The returned MonitorsServerTransport instance is connected to an instance of armlogz.MonitorsClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewMonitorsServerTransport(srv *MonitorsServer) *MonitorsServerTransport { + return &MonitorsServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armlogz.MonitorsClientCreateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armlogz.MonitorsClientDeleteResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armlogz.MonitorsClientListByResourceGroupResponse]](), + newListBySubscriptionPager: newTracker[azfake.PagerResponder[armlogz.MonitorsClientListBySubscriptionResponse]](), + newListMonitoredResourcesPager: newTracker[azfake.PagerResponder[armlogz.MonitorsClientListMonitoredResourcesResponse]](), + newListUserRolesPager: newTracker[azfake.PagerResponder[armlogz.MonitorsClientListUserRolesResponse]](), + } +} + +// MonitorsServerTransport connects instances of armlogz.MonitorsClient to instances of MonitorsServer. +// Don't use this type directly, use NewMonitorsServerTransport instead. +type MonitorsServerTransport struct { + srv *MonitorsServer + beginCreate *tracker[azfake.PollerResponder[armlogz.MonitorsClientCreateResponse]] + beginDelete *tracker[azfake.PollerResponder[armlogz.MonitorsClientDeleteResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armlogz.MonitorsClientListByResourceGroupResponse]] + newListBySubscriptionPager *tracker[azfake.PagerResponder[armlogz.MonitorsClientListBySubscriptionResponse]] + newListMonitoredResourcesPager *tracker[azfake.PagerResponder[armlogz.MonitorsClientListMonitoredResourcesResponse]] + newListUserRolesPager *tracker[azfake.PagerResponder[armlogz.MonitorsClientListUserRolesResponse]] +} + +// Do implements the policy.Transporter interface for MonitorsServerTransport. +func (m *MonitorsServerTransport) 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 "MonitorsClient.BeginCreate": + resp, err = m.dispatchBeginCreate(req) + case "MonitorsClient.BeginDelete": + resp, err = m.dispatchBeginDelete(req) + case "MonitorsClient.Get": + resp, err = m.dispatchGet(req) + case "MonitorsClient.NewListByResourceGroupPager": + resp, err = m.dispatchNewListByResourceGroupPager(req) + case "MonitorsClient.NewListBySubscriptionPager": + resp, err = m.dispatchNewListBySubscriptionPager(req) + case "MonitorsClient.NewListMonitoredResourcesPager": + resp, err = m.dispatchNewListMonitoredResourcesPager(req) + case "MonitorsClient.NewListUserRolesPager": + resp, err = m.dispatchNewListUserRolesPager(req) + case "MonitorsClient.Update": + resp, err = m.dispatchUpdate(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (m *MonitorsServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if m.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := m.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?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[armlogz.MonitorResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + var options *armlogz.MonitorsClientBeginCreateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armlogz.MonitorsClientBeginCreateOptions{ + Body: &body, + } + } + respr, errRespr := m.srv.BeginCreate(req.Context(), resourceGroupNameParam, monitorNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + m.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + m.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + m.beginCreate.remove(req) + } + + return resp, nil +} + +func (m *MonitorsServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if m.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := m.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.BeginDelete(req.Context(), resourceGroupNameParam, monitorNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + m.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) { + m.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) { + m.beginDelete.remove(req) + } + + return resp, nil +} + +func (m *MonitorsServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if m.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\.Logz/monitors/(?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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + respr, errRespr := m.srv.Get(req.Context(), resourceGroupNameParam, monitorNameParam, 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).MonitorResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (m *MonitorsServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if m.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} + } + newListByResourceGroupPager := m.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors` + 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 := m.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + m.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armlogz.MonitorsClientListByResourceGroupResponse, 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) { + m.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListByResourceGroupPager) { + m.newListByResourceGroupPager.remove(req) + } + return resp, nil +} + +func (m *MonitorsServerTransport) dispatchNewListBySubscriptionPager(req *http.Request) (*http.Response, error) { + if m.srv.NewListBySubscriptionPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListBySubscriptionPager not implemented")} + } + newListBySubscriptionPager := m.newListBySubscriptionPager.get(req) + if newListBySubscriptionPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors` + 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 := m.srv.NewListBySubscriptionPager(nil) + newListBySubscriptionPager = &resp + m.newListBySubscriptionPager.add(req, newListBySubscriptionPager) + server.PagerResponderInjectNextLinks(newListBySubscriptionPager, req, func(page *armlogz.MonitorsClientListBySubscriptionResponse, 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) { + m.newListBySubscriptionPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListBySubscriptionPager) { + m.newListBySubscriptionPager.remove(req) + } + return resp, nil +} + +func (m *MonitorsServerTransport) dispatchNewListMonitoredResourcesPager(req *http.Request) (*http.Response, error) { + if m.srv.NewListMonitoredResourcesPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListMonitoredResourcesPager not implemented")} + } + newListMonitoredResourcesPager := m.newListMonitoredResourcesPager.get(req) + if newListMonitoredResourcesPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listMonitoredResources` + 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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + resp := m.srv.NewListMonitoredResourcesPager(resourceGroupNameParam, monitorNameParam, nil) + newListMonitoredResourcesPager = &resp + m.newListMonitoredResourcesPager.add(req, newListMonitoredResourcesPager) + server.PagerResponderInjectNextLinks(newListMonitoredResourcesPager, req, func(page *armlogz.MonitorsClientListMonitoredResourcesResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListMonitoredResourcesPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + m.newListMonitoredResourcesPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListMonitoredResourcesPager) { + m.newListMonitoredResourcesPager.remove(req) + } + return resp, nil +} + +func (m *MonitorsServerTransport) dispatchNewListUserRolesPager(req *http.Request) (*http.Response, error) { + if m.srv.NewListUserRolesPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListUserRolesPager not implemented")} + } + newListUserRolesPager := m.newListUserRolesPager.get(req) + if newListUserRolesPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listUserRoles` + 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[armlogz.UserRoleRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + var options *armlogz.MonitorsClientListUserRolesOptions + if !reflect.ValueOf(body).IsZero() { + options = &armlogz.MonitorsClientListUserRolesOptions{ + Body: &body, + } + } + resp := m.srv.NewListUserRolesPager(resourceGroupNameParam, monitorNameParam, options) + newListUserRolesPager = &resp + m.newListUserRolesPager.add(req, newListUserRolesPager) + server.PagerResponderInjectNextLinks(newListUserRolesPager, req, func(page *armlogz.MonitorsClientListUserRolesResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListUserRolesPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + m.newListUserRolesPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListUserRolesPager) { + m.newListUserRolesPager.remove(req) + } + return resp, nil +} + +func (m *MonitorsServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if m.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\.Logz/monitors/(?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[armlogz.MonitorResourceUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + var options *armlogz.MonitorsClientUpdateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armlogz.MonitorsClientUpdateOptions{ + Body: &body, + } + } + respr, errRespr := m.srv.Update(req.Context(), resourceGroupNameParam, monitorNameParam, options) + 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).MonitorResource, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/logz/armlogz/fake/operations_server.go b/sdk/resourcemanager/logz/armlogz/fake/operations_server.go new file mode 100644 index 000000000000..6634edafcc2f --- /dev/null +++ b/sdk/resourcemanager/logz/armlogz/fake/operations_server.go @@ -0,0 +1,96 @@ +//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 ( + "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/logz/armlogz" + "net/http" +) + +// OperationsServer is a fake server for instances of the armlogz.OperationsClient type. +type OperationsServer struct { + // NewListPager is the fake for method OperationsClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(options *armlogz.OperationsClientListOptions) (resp azfake.PagerResponder[armlogz.OperationsClientListResponse]) +} + +// NewOperationsServerTransport creates a new instance of OperationsServerTransport with the provided implementation. +// The returned OperationsServerTransport instance is connected to an instance of armlogz.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[armlogz.OperationsClientListResponse]](), + } +} + +// OperationsServerTransport connects instances of armlogz.OperationsClient to instances of OperationsServer. +// Don't use this type directly, use NewOperationsServerTransport instead. +type OperationsServerTransport struct { + srv *OperationsServer + newListPager *tracker[azfake.PagerResponder[armlogz.OperationsClientListResponse]] +} + +// Do implements the policy.Transporter interface for OperationsServerTransport. +func (o *OperationsServerTransport) 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 "OperationsClient.NewListPager": + resp, err = o.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (o *OperationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if o.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := o.newListPager.get(req) + if newListPager == nil { + resp := o.srv.NewListPager(nil) + newListPager = &resp + o.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogz.OperationsClientListResponse, 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) { + o.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + o.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/logz/armlogz/fake/server_factory.go b/sdk/resourcemanager/logz/armlogz/fake/server_factory.go new file mode 100644 index 000000000000..15cd80c81f44 --- /dev/null +++ b/sdk/resourcemanager/logz/armlogz/fake/server_factory.go @@ -0,0 +1,107 @@ +//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 ( + "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 armlogz.ClientFactory type. +type ServerFactory struct { + MonitorServer MonitorServer + MonitorsServer MonitorsServer + OperationsServer OperationsServer + SingleSignOnServer SingleSignOnServer + SubAccountServer SubAccountServer + SubAccountTagRulesServer SubAccountTagRulesServer + TagRulesServer TagRulesServer +} + +// NewServerFactoryTransport creates a new instance of ServerFactoryTransport with the provided implementation. +// The returned ServerFactoryTransport instance is connected to an instance of armlogz.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 armlogz.ClientFactory to instances of ServerFactory. +// Don't use this type directly, use NewServerFactoryTransport instead. +type ServerFactoryTransport struct { + srv *ServerFactory + trMu sync.Mutex + trMonitorServer *MonitorServerTransport + trMonitorsServer *MonitorsServerTransport + trOperationsServer *OperationsServerTransport + trSingleSignOnServer *SingleSignOnServerTransport + trSubAccountServer *SubAccountServerTransport + trSubAccountTagRulesServer *SubAccountTagRulesServerTransport + trTagRulesServer *TagRulesServerTransport +} + +// 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 "MonitorClient": + initServer(s, &s.trMonitorServer, func() *MonitorServerTransport { return NewMonitorServerTransport(&s.srv.MonitorServer) }) + resp, err = s.trMonitorServer.Do(req) + case "MonitorsClient": + initServer(s, &s.trMonitorsServer, func() *MonitorsServerTransport { return NewMonitorsServerTransport(&s.srv.MonitorsServer) }) + resp, err = s.trMonitorsServer.Do(req) + case "OperationsClient": + initServer(s, &s.trOperationsServer, func() *OperationsServerTransport { return NewOperationsServerTransport(&s.srv.OperationsServer) }) + resp, err = s.trOperationsServer.Do(req) + case "SingleSignOnClient": + initServer(s, &s.trSingleSignOnServer, func() *SingleSignOnServerTransport { return NewSingleSignOnServerTransport(&s.srv.SingleSignOnServer) }) + resp, err = s.trSingleSignOnServer.Do(req) + case "SubAccountClient": + initServer(s, &s.trSubAccountServer, func() *SubAccountServerTransport { return NewSubAccountServerTransport(&s.srv.SubAccountServer) }) + resp, err = s.trSubAccountServer.Do(req) + case "SubAccountTagRulesClient": + initServer(s, &s.trSubAccountTagRulesServer, func() *SubAccountTagRulesServerTransport { + return NewSubAccountTagRulesServerTransport(&s.srv.SubAccountTagRulesServer) + }) + resp, err = s.trSubAccountTagRulesServer.Do(req) + case "TagRulesClient": + initServer(s, &s.trTagRulesServer, func() *TagRulesServerTransport { return NewTagRulesServerTransport(&s.srv.TagRulesServer) }) + resp, err = s.trTagRulesServer.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/logz/armlogz/fake/singlesignon_server.go b/sdk/resourcemanager/logz/armlogz/fake/singlesignon_server.go new file mode 100644 index 000000000000..ca4611b6801d --- /dev/null +++ b/sdk/resourcemanager/logz/armlogz/fake/singlesignon_server.go @@ -0,0 +1,223 @@ +//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/logz/armlogz" + "net/http" + "net/url" + "reflect" + "regexp" +) + +// SingleSignOnServer is a fake server for instances of the armlogz.SingleSignOnClient type. +type SingleSignOnServer struct { + // BeginCreateOrUpdate is the fake for method SingleSignOnClient.BeginCreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreateOrUpdate func(ctx context.Context, resourceGroupName string, monitorName string, configurationName string, options *armlogz.SingleSignOnClientBeginCreateOrUpdateOptions) (resp azfake.PollerResponder[armlogz.SingleSignOnClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method SingleSignOnClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, monitorName string, configurationName string, options *armlogz.SingleSignOnClientGetOptions) (resp azfake.Responder[armlogz.SingleSignOnClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method SingleSignOnClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, monitorName string, options *armlogz.SingleSignOnClientListOptions) (resp azfake.PagerResponder[armlogz.SingleSignOnClientListResponse]) +} + +// NewSingleSignOnServerTransport creates a new instance of SingleSignOnServerTransport with the provided implementation. +// The returned SingleSignOnServerTransport instance is connected to an instance of armlogz.SingleSignOnClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSingleSignOnServerTransport(srv *SingleSignOnServer) *SingleSignOnServerTransport { + return &SingleSignOnServerTransport{ + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armlogz.SingleSignOnClientCreateOrUpdateResponse]](), + newListPager: newTracker[azfake.PagerResponder[armlogz.SingleSignOnClientListResponse]](), + } +} + +// SingleSignOnServerTransport connects instances of armlogz.SingleSignOnClient to instances of SingleSignOnServer. +// Don't use this type directly, use NewSingleSignOnServerTransport instead. +type SingleSignOnServerTransport struct { + srv *SingleSignOnServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armlogz.SingleSignOnClientCreateOrUpdateResponse]] + newListPager *tracker[azfake.PagerResponder[armlogz.SingleSignOnClientListResponse]] +} + +// Do implements the policy.Transporter interface for SingleSignOnServerTransport. +func (s *SingleSignOnServerTransport) 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 "SingleSignOnClient.BeginCreateOrUpdate": + resp, err = s.dispatchBeginCreateOrUpdate(req) + case "SingleSignOnClient.Get": + resp, err = s.dispatchGet(req) + case "SingleSignOnClient.NewListPager": + resp, err = s.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SingleSignOnServerTransport) dispatchBeginCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreateOrUpdate not implemented")} + } + beginCreateOrUpdate := s.beginCreateOrUpdate.get(req) + if beginCreateOrUpdate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/singleSignOnConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogz.SingleSignOnResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + configurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("configurationName")]) + if err != nil { + return nil, err + } + var options *armlogz.SingleSignOnClientBeginCreateOrUpdateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armlogz.SingleSignOnClientBeginCreateOrUpdateOptions{ + Body: &body, + } + } + respr, errRespr := s.srv.BeginCreateOrUpdate(req.Context(), resourceGroupNameParam, monitorNameParam, configurationNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreateOrUpdate = &respr + s.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) { + s.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) { + s.beginCreateOrUpdate.remove(req) + } + + return resp, nil +} + +func (s *SingleSignOnServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.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\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/singleSignOnConfigurations/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + configurationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("configurationName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, monitorNameParam, configurationNameParam, 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).SingleSignOnResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SingleSignOnServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := s.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/singleSignOnConfigurations` + 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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListPager(resourceGroupNameParam, monitorNameParam, nil) + newListPager = &resp + s.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogz.SingleSignOnClientListResponse, 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) { + s.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + s.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/logz/armlogz/fake/subaccount_server.go b/sdk/resourcemanager/logz/armlogz/fake/subaccount_server.go new file mode 100644 index 000000000000..43ee61630456 --- /dev/null +++ b/sdk/resourcemanager/logz/armlogz/fake/subaccount_server.go @@ -0,0 +1,544 @@ +//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/logz/armlogz" + "net/http" + "net/url" + "reflect" + "regexp" +) + +// SubAccountServer is a fake server for instances of the armlogz.SubAccountClient type. +type SubAccountServer struct { + // BeginCreate is the fake for method SubAccountClient.BeginCreate + // HTTP status codes to indicate success: http.StatusOK, http.StatusCreated + BeginCreate func(ctx context.Context, resourceGroupName string, monitorName string, subAccountName string, options *armlogz.SubAccountClientBeginCreateOptions) (resp azfake.PollerResponder[armlogz.SubAccountClientCreateResponse], errResp azfake.ErrorResponder) + + // BeginDelete is the fake for method SubAccountClient.BeginDelete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + BeginDelete func(ctx context.Context, resourceGroupName string, monitorName string, subAccountName string, options *armlogz.SubAccountClientBeginDeleteOptions) (resp azfake.PollerResponder[armlogz.SubAccountClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method SubAccountClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, monitorName string, subAccountName string, options *armlogz.SubAccountClientGetOptions) (resp azfake.Responder[armlogz.SubAccountClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method SubAccountClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, monitorName string, options *armlogz.SubAccountClientListOptions) (resp azfake.PagerResponder[armlogz.SubAccountClientListResponse]) + + // NewListMonitoredResourcesPager is the fake for method SubAccountClient.NewListMonitoredResourcesPager + // HTTP status codes to indicate success: http.StatusOK + NewListMonitoredResourcesPager func(resourceGroupName string, monitorName string, subAccountName string, options *armlogz.SubAccountClientListMonitoredResourcesOptions) (resp azfake.PagerResponder[armlogz.SubAccountClientListMonitoredResourcesResponse]) + + // NewListVMHostUpdatePager is the fake for method SubAccountClient.NewListVMHostUpdatePager + // HTTP status codes to indicate success: http.StatusOK + NewListVMHostUpdatePager func(resourceGroupName string, monitorName string, subAccountName string, options *armlogz.SubAccountClientListVMHostUpdateOptions) (resp azfake.PagerResponder[armlogz.SubAccountClientListVMHostUpdateResponse]) + + // NewListVMHostsPager is the fake for method SubAccountClient.NewListVMHostsPager + // HTTP status codes to indicate success: http.StatusOK + NewListVMHostsPager func(resourceGroupName string, monitorName string, subAccountName string, options *armlogz.SubAccountClientListVMHostsOptions) (resp azfake.PagerResponder[armlogz.SubAccountClientListVMHostsResponse]) + + // Update is the fake for method SubAccountClient.Update + // HTTP status codes to indicate success: http.StatusOK + Update func(ctx context.Context, resourceGroupName string, monitorName string, subAccountName string, options *armlogz.SubAccountClientUpdateOptions) (resp azfake.Responder[armlogz.SubAccountClientUpdateResponse], errResp azfake.ErrorResponder) + + // VMHostPayload is the fake for method SubAccountClient.VMHostPayload + // HTTP status codes to indicate success: http.StatusOK + VMHostPayload func(ctx context.Context, resourceGroupName string, monitorName string, subAccountName string, options *armlogz.SubAccountClientVMHostPayloadOptions) (resp azfake.Responder[armlogz.SubAccountClientVMHostPayloadResponse], errResp azfake.ErrorResponder) +} + +// NewSubAccountServerTransport creates a new instance of SubAccountServerTransport with the provided implementation. +// The returned SubAccountServerTransport instance is connected to an instance of armlogz.SubAccountClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSubAccountServerTransport(srv *SubAccountServer) *SubAccountServerTransport { + return &SubAccountServerTransport{ + srv: srv, + beginCreate: newTracker[azfake.PollerResponder[armlogz.SubAccountClientCreateResponse]](), + beginDelete: newTracker[azfake.PollerResponder[armlogz.SubAccountClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armlogz.SubAccountClientListResponse]](), + newListMonitoredResourcesPager: newTracker[azfake.PagerResponder[armlogz.SubAccountClientListMonitoredResourcesResponse]](), + newListVMHostUpdatePager: newTracker[azfake.PagerResponder[armlogz.SubAccountClientListVMHostUpdateResponse]](), + newListVMHostsPager: newTracker[azfake.PagerResponder[armlogz.SubAccountClientListVMHostsResponse]](), + } +} + +// SubAccountServerTransport connects instances of armlogz.SubAccountClient to instances of SubAccountServer. +// Don't use this type directly, use NewSubAccountServerTransport instead. +type SubAccountServerTransport struct { + srv *SubAccountServer + beginCreate *tracker[azfake.PollerResponder[armlogz.SubAccountClientCreateResponse]] + beginDelete *tracker[azfake.PollerResponder[armlogz.SubAccountClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armlogz.SubAccountClientListResponse]] + newListMonitoredResourcesPager *tracker[azfake.PagerResponder[armlogz.SubAccountClientListMonitoredResourcesResponse]] + newListVMHostUpdatePager *tracker[azfake.PagerResponder[armlogz.SubAccountClientListVMHostUpdateResponse]] + newListVMHostsPager *tracker[azfake.PagerResponder[armlogz.SubAccountClientListVMHostsResponse]] +} + +// Do implements the policy.Transporter interface for SubAccountServerTransport. +func (s *SubAccountServerTransport) 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 "SubAccountClient.BeginCreate": + resp, err = s.dispatchBeginCreate(req) + case "SubAccountClient.BeginDelete": + resp, err = s.dispatchBeginDelete(req) + case "SubAccountClient.Get": + resp, err = s.dispatchGet(req) + case "SubAccountClient.NewListPager": + resp, err = s.dispatchNewListPager(req) + case "SubAccountClient.NewListMonitoredResourcesPager": + resp, err = s.dispatchNewListMonitoredResourcesPager(req) + case "SubAccountClient.NewListVMHostUpdatePager": + resp, err = s.dispatchNewListVMHostUpdatePager(req) + case "SubAccountClient.NewListVMHostsPager": + resp, err = s.dispatchNewListVMHostsPager(req) + case "SubAccountClient.Update": + resp, err = s.dispatchUpdate(req) + case "SubAccountClient.VMHostPayload": + resp, err = s.dispatchVMHostPayload(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SubAccountServerTransport) dispatchBeginCreate(req *http.Request) (*http.Response, error) { + if s.srv.BeginCreate == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginCreate not implemented")} + } + beginCreate := s.beginCreate.get(req) + if beginCreate == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogz.MonitorResource](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + subAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("subAccountName")]) + if err != nil { + return nil, err + } + var options *armlogz.SubAccountClientBeginCreateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armlogz.SubAccountClientBeginCreateOptions{ + Body: &body, + } + } + respr, errRespr := s.srv.BeginCreate(req.Context(), resourceGroupNameParam, monitorNameParam, subAccountNameParam, options) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginCreate = &respr + s.beginCreate.add(req, beginCreate) + } + + resp, err := server.PollerResponderNext(beginCreate, req) + if err != nil { + return nil, err + } + + if !contains([]int{http.StatusOK, http.StatusCreated}, resp.StatusCode) { + s.beginCreate.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusCreated", resp.StatusCode)} + } + if !server.PollerResponderMore(beginCreate) { + s.beginCreate.remove(req) + } + + return resp, nil +} + +func (s *SubAccountServerTransport) dispatchBeginDelete(req *http.Request) (*http.Response, error) { + if s.srv.BeginDelete == nil { + return nil, &nonRetriableError{errors.New("fake for method BeginDelete not implemented")} + } + beginDelete := s.beginDelete.get(req) + if beginDelete == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + subAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("subAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.BeginDelete(req.Context(), resourceGroupNameParam, monitorNameParam, subAccountNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + beginDelete = &respr + s.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) { + s.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) { + s.beginDelete.remove(req) + } + + return resp, nil +} + +func (s *SubAccountServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.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\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + subAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("subAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, monitorNameParam, subAccountNameParam, 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).MonitorResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SubAccountServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := s.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/accounts` + 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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListPager(resourceGroupNameParam, monitorNameParam, nil) + newListPager = &resp + s.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogz.SubAccountClientListResponse, 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) { + s.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + s.newListPager.remove(req) + } + return resp, nil +} + +func (s *SubAccountServerTransport) dispatchNewListMonitoredResourcesPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListMonitoredResourcesPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListMonitoredResourcesPager not implemented")} + } + newListMonitoredResourcesPager := s.newListMonitoredResourcesPager.get(req) + if newListMonitoredResourcesPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listMonitoredResources` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + subAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("subAccountName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListMonitoredResourcesPager(resourceGroupNameParam, monitorNameParam, subAccountNameParam, nil) + newListMonitoredResourcesPager = &resp + s.newListMonitoredResourcesPager.add(req, newListMonitoredResourcesPager) + server.PagerResponderInjectNextLinks(newListMonitoredResourcesPager, req, func(page *armlogz.SubAccountClientListMonitoredResourcesResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListMonitoredResourcesPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListMonitoredResourcesPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListMonitoredResourcesPager) { + s.newListMonitoredResourcesPager.remove(req) + } + return resp, nil +} + +func (s *SubAccountServerTransport) dispatchNewListVMHostUpdatePager(req *http.Request) (*http.Response, error) { + if s.srv.NewListVMHostUpdatePager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListVMHostUpdatePager not implemented")} + } + newListVMHostUpdatePager := s.newListVMHostUpdatePager.get(req) + if newListVMHostUpdatePager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/vmHostUpdate` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogz.VMHostUpdateRequest](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + subAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("subAccountName")]) + if err != nil { + return nil, err + } + var options *armlogz.SubAccountClientListVMHostUpdateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armlogz.SubAccountClientListVMHostUpdateOptions{ + Body: &body, + } + } + resp := s.srv.NewListVMHostUpdatePager(resourceGroupNameParam, monitorNameParam, subAccountNameParam, options) + newListVMHostUpdatePager = &resp + s.newListVMHostUpdatePager.add(req, newListVMHostUpdatePager) + server.PagerResponderInjectNextLinks(newListVMHostUpdatePager, req, func(page *armlogz.SubAccountClientListVMHostUpdateResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListVMHostUpdatePager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListVMHostUpdatePager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListVMHostUpdatePager) { + s.newListVMHostUpdatePager.remove(req) + } + return resp, nil +} + +func (s *SubAccountServerTransport) dispatchNewListVMHostsPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListVMHostsPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListVMHostsPager not implemented")} + } + newListVMHostsPager := s.newListVMHostsPager.get(req) + if newListVMHostsPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/listVMHosts` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + subAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("subAccountName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListVMHostsPager(resourceGroupNameParam, monitorNameParam, subAccountNameParam, nil) + newListVMHostsPager = &resp + s.newListVMHostsPager.add(req, newListVMHostsPager) + server.PagerResponderInjectNextLinks(newListVMHostsPager, req, func(page *armlogz.SubAccountClientListVMHostsResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListVMHostsPager, req) + if err != nil { + return nil, err + } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListVMHostsPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListVMHostsPager) { + s.newListVMHostsPager.remove(req) + } + return resp, nil +} + +func (s *SubAccountServerTransport) dispatchUpdate(req *http.Request) (*http.Response, error) { + if s.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\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogz.MonitorResourceUpdateParameters](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + subAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("subAccountName")]) + if err != nil { + return nil, err + } + var options *armlogz.SubAccountClientUpdateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armlogz.SubAccountClientUpdateOptions{ + Body: &body, + } + } + respr, errRespr := s.srv.Update(req.Context(), resourceGroupNameParam, monitorNameParam, subAccountNameParam, options) + 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).MonitorResource, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SubAccountServerTransport) dispatchVMHostPayload(req *http.Request) (*http.Response, error) { + if s.srv.VMHostPayload == nil { + return nil, &nonRetriableError{errors.New("fake for method VMHostPayload not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/vmHostPayload` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + subAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("subAccountName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.VMHostPayload(req.Context(), resourceGroupNameParam, monitorNameParam, subAccountNameParam, 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).VMExtensionPayload, req) + if err != nil { + return nil, err + } + return resp, nil +} diff --git a/sdk/resourcemanager/logz/armlogz/fake/subaccounttagrules_server.go b/sdk/resourcemanager/logz/armlogz/fake/subaccounttagrules_server.go new file mode 100644 index 000000000000..fd27239ba9f2 --- /dev/null +++ b/sdk/resourcemanager/logz/armlogz/fake/subaccounttagrules_server.go @@ -0,0 +1,272 @@ +//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/logz/armlogz" + "net/http" + "net/url" + "reflect" + "regexp" +) + +// SubAccountTagRulesServer is a fake server for instances of the armlogz.SubAccountTagRulesClient type. +type SubAccountTagRulesServer struct { + // CreateOrUpdate is the fake for method SubAccountTagRulesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK + CreateOrUpdate func(ctx context.Context, resourceGroupName string, monitorName string, subAccountName string, ruleSetName string, options *armlogz.SubAccountTagRulesClientCreateOrUpdateOptions) (resp azfake.Responder[armlogz.SubAccountTagRulesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method SubAccountTagRulesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, monitorName string, subAccountName string, ruleSetName string, options *armlogz.SubAccountTagRulesClientDeleteOptions) (resp azfake.Responder[armlogz.SubAccountTagRulesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method SubAccountTagRulesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, monitorName string, subAccountName string, ruleSetName string, options *armlogz.SubAccountTagRulesClientGetOptions) (resp azfake.Responder[armlogz.SubAccountTagRulesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method SubAccountTagRulesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, monitorName string, subAccountName string, options *armlogz.SubAccountTagRulesClientListOptions) (resp azfake.PagerResponder[armlogz.SubAccountTagRulesClientListResponse]) +} + +// NewSubAccountTagRulesServerTransport creates a new instance of SubAccountTagRulesServerTransport with the provided implementation. +// The returned SubAccountTagRulesServerTransport instance is connected to an instance of armlogz.SubAccountTagRulesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewSubAccountTagRulesServerTransport(srv *SubAccountTagRulesServer) *SubAccountTagRulesServerTransport { + return &SubAccountTagRulesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogz.SubAccountTagRulesClientListResponse]](), + } +} + +// SubAccountTagRulesServerTransport connects instances of armlogz.SubAccountTagRulesClient to instances of SubAccountTagRulesServer. +// Don't use this type directly, use NewSubAccountTagRulesServerTransport instead. +type SubAccountTagRulesServerTransport struct { + srv *SubAccountTagRulesServer + newListPager *tracker[azfake.PagerResponder[armlogz.SubAccountTagRulesClientListResponse]] +} + +// Do implements the policy.Transporter interface for SubAccountTagRulesServerTransport. +func (s *SubAccountTagRulesServerTransport) 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 "SubAccountTagRulesClient.CreateOrUpdate": + resp, err = s.dispatchCreateOrUpdate(req) + case "SubAccountTagRulesClient.Delete": + resp, err = s.dispatchDelete(req) + case "SubAccountTagRulesClient.Get": + resp, err = s.dispatchGet(req) + case "SubAccountTagRulesClient.NewListPager": + resp, err = s.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (s *SubAccountTagRulesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if s.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tagRules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogz.MonitoringTagRules](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + subAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("subAccountName")]) + if err != nil { + return nil, err + } + ruleSetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("ruleSetName")]) + if err != nil { + return nil, err + } + var options *armlogz.SubAccountTagRulesClientCreateOrUpdateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armlogz.SubAccountTagRulesClientCreateOrUpdateOptions{ + Body: &body, + } + } + respr, errRespr := s.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, monitorNameParam, subAccountNameParam, ruleSetNameParam, options) + 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).MonitoringTagRules, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SubAccountTagRulesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if s.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tagRules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + subAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("subAccountName")]) + if err != nil { + return nil, err + } + ruleSetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("ruleSetName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Delete(req.Context(), resourceGroupNameParam, monitorNameParam, subAccountNameParam, ruleSetNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).Location; val != nil { + resp.Header.Set("location", *val) + } + return resp, nil +} + +func (s *SubAccountTagRulesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if s.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\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tagRules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 5 { + 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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + subAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("subAccountName")]) + if err != nil { + return nil, err + } + ruleSetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("ruleSetName")]) + if err != nil { + return nil, err + } + respr, errRespr := s.srv.Get(req.Context(), resourceGroupNameParam, monitorNameParam, subAccountNameParam, ruleSetNameParam, 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).MonitoringTagRules, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (s *SubAccountTagRulesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := s.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/accounts/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tagRules` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + subAccountNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("subAccountName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListPager(resourceGroupNameParam, monitorNameParam, subAccountNameParam, nil) + newListPager = &resp + s.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogz.SubAccountTagRulesClientListResponse, 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) { + s.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + s.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/logz/armlogz/fake/tagrules_server.go b/sdk/resourcemanager/logz/armlogz/fake/tagrules_server.go new file mode 100644 index 000000000000..e29de8fba62a --- /dev/null +++ b/sdk/resourcemanager/logz/armlogz/fake/tagrules_server.go @@ -0,0 +1,256 @@ +//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/logz/armlogz" + "net/http" + "net/url" + "reflect" + "regexp" +) + +// TagRulesServer is a fake server for instances of the armlogz.TagRulesClient type. +type TagRulesServer struct { + // CreateOrUpdate is the fake for method TagRulesClient.CreateOrUpdate + // HTTP status codes to indicate success: http.StatusOK + CreateOrUpdate func(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *armlogz.TagRulesClientCreateOrUpdateOptions) (resp azfake.Responder[armlogz.TagRulesClientCreateOrUpdateResponse], errResp azfake.ErrorResponder) + + // Delete is the fake for method TagRulesClient.Delete + // HTTP status codes to indicate success: http.StatusOK, http.StatusAccepted, http.StatusNoContent + Delete func(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *armlogz.TagRulesClientDeleteOptions) (resp azfake.Responder[armlogz.TagRulesClientDeleteResponse], errResp azfake.ErrorResponder) + + // Get is the fake for method TagRulesClient.Get + // HTTP status codes to indicate success: http.StatusOK + Get func(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *armlogz.TagRulesClientGetOptions) (resp azfake.Responder[armlogz.TagRulesClientGetResponse], errResp azfake.ErrorResponder) + + // NewListPager is the fake for method TagRulesClient.NewListPager + // HTTP status codes to indicate success: http.StatusOK + NewListPager func(resourceGroupName string, monitorName string, options *armlogz.TagRulesClientListOptions) (resp azfake.PagerResponder[armlogz.TagRulesClientListResponse]) +} + +// NewTagRulesServerTransport creates a new instance of TagRulesServerTransport with the provided implementation. +// The returned TagRulesServerTransport instance is connected to an instance of armlogz.TagRulesClient via the +// azcore.ClientOptions.Transporter field in the client's constructor parameters. +func NewTagRulesServerTransport(srv *TagRulesServer) *TagRulesServerTransport { + return &TagRulesServerTransport{ + srv: srv, + newListPager: newTracker[azfake.PagerResponder[armlogz.TagRulesClientListResponse]](), + } +} + +// TagRulesServerTransport connects instances of armlogz.TagRulesClient to instances of TagRulesServer. +// Don't use this type directly, use NewTagRulesServerTransport instead. +type TagRulesServerTransport struct { + srv *TagRulesServer + newListPager *tracker[azfake.PagerResponder[armlogz.TagRulesClientListResponse]] +} + +// Do implements the policy.Transporter interface for TagRulesServerTransport. +func (t *TagRulesServerTransport) 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 "TagRulesClient.CreateOrUpdate": + resp, err = t.dispatchCreateOrUpdate(req) + case "TagRulesClient.Delete": + resp, err = t.dispatchDelete(req) + case "TagRulesClient.Get": + resp, err = t.dispatchGet(req) + case "TagRulesClient.NewListPager": + resp, err = t.dispatchNewListPager(req) + default: + err = fmt.Errorf("unhandled API %s", method) + } + + if err != nil { + return nil, err + } + + return resp, nil +} + +func (t *TagRulesServerTransport) dispatchCreateOrUpdate(req *http.Request) (*http.Response, error) { + if t.srv.CreateOrUpdate == nil { + return nil, &nonRetriableError{errors.New("fake for method CreateOrUpdate not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tagRules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + body, err := server.UnmarshalRequestAsJSON[armlogz.MonitoringTagRules](req) + if err != nil { + return nil, err + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + ruleSetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("ruleSetName")]) + if err != nil { + return nil, err + } + var options *armlogz.TagRulesClientCreateOrUpdateOptions + if !reflect.ValueOf(body).IsZero() { + options = &armlogz.TagRulesClientCreateOrUpdateOptions{ + Body: &body, + } + } + respr, errRespr := t.srv.CreateOrUpdate(req.Context(), resourceGroupNameParam, monitorNameParam, ruleSetNameParam, options) + 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).MonitoringTagRules, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TagRulesServerTransport) dispatchDelete(req *http.Request) (*http.Response, error) { + if t.srv.Delete == nil { + return nil, &nonRetriableError{errors.New("fake for method Delete not implemented")} + } + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tagRules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + ruleSetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("ruleSetName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Delete(req.Context(), resourceGroupNameParam, monitorNameParam, ruleSetNameParam, nil) + if respErr := server.GetError(errRespr, req); respErr != nil { + return nil, respErr + } + respContent := server.GetResponseContent(respr) + if !contains([]int{http.StatusOK, http.StatusAccepted, http.StatusNoContent}, respContent.HTTPStatus) { + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK, http.StatusAccepted, http.StatusNoContent", respContent.HTTPStatus)} + } + resp, err := server.NewResponse(respContent, req, nil) + if err != nil { + return nil, err + } + if val := server.GetResponse(respr).Location; val != nil { + resp.Header.Set("location", *val) + } + return resp, nil +} + +func (t *TagRulesServerTransport) dispatchGet(req *http.Request) (*http.Response, error) { + if t.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\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tagRules/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + 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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + ruleSetNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("ruleSetName")]) + if err != nil { + return nil, err + } + respr, errRespr := t.srv.Get(req.Context(), resourceGroupNameParam, monitorNameParam, ruleSetNameParam, 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).MonitoringTagRules, req) + if err != nil { + return nil, err + } + return resp, nil +} + +func (t *TagRulesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if t.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} + } + newListPager := t.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.Logz/monitors/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/tagRules` + 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 + } + monitorNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("monitorName")]) + if err != nil { + return nil, err + } + resp := t.srv.NewListPager(resourceGroupNameParam, monitorNameParam, nil) + newListPager = &resp + t.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armlogz.TagRulesClientListResponse, 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) { + t.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + t.newListPager.remove(req) + } + return resp, nil +} diff --git a/sdk/resourcemanager/logz/armlogz/fake/time_rfc3339.go b/sdk/resourcemanager/logz/armlogz/fake/time_rfc3339.go new file mode 100644 index 000000000000..b0535a7b63e6 --- /dev/null +++ b/sdk/resourcemanager/logz/armlogz/fake/time_rfc3339.go @@ -0,0 +1,86 @@ +//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 ( + "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 ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +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 { + layout := utcDateTimeJSON + if tzOffsetRegex.Match(data) { + layout = dateTimeJSON + } + return t.Parse(layout, string(data)) +} + +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime + if tzOffsetRegex.Match(data) { + layout = time.RFC3339Nano + } + 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 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 || strings.EqualFold(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/logz/armlogz/go.mod b/sdk/resourcemanager/logz/armlogz/go.mod index b08c7988cf01..9511705720c4 100644 --- a/sdk/resourcemanager/logz/armlogz/go.mod +++ b/sdk/resourcemanager/logz/armlogz/go.mod @@ -3,19 +3,19 @@ module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/logz/armlogz go 1.18 require ( - github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 - github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 + github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 + github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 ) require ( - github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 // indirect - github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 // indirect - github.com/golang-jwt/jwt/v4 v4.5.0 // indirect - github.com/google/uuid v1.3.0 // indirect + github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 // indirect + github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 // indirect + github.com/golang-jwt/jwt/v5 v5.0.0 // indirect + github.com/google/uuid v1.3.1 // indirect github.com/kylelemons/godebug v1.1.0 // indirect github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect - golang.org/x/crypto v0.6.0 // indirect - golang.org/x/net v0.7.0 // indirect - golang.org/x/sys v0.5.0 // indirect - golang.org/x/text v0.7.0 // indirect + golang.org/x/crypto v0.14.0 // indirect + golang.org/x/net v0.17.0 // indirect + golang.org/x/sys v0.13.0 // indirect + golang.org/x/text v0.13.0 // indirect ) diff --git a/sdk/resourcemanager/logz/armlogz/go.sum b/sdk/resourcemanager/logz/armlogz/go.sum index 8ba445a8c4da..7985f1da436f 100644 --- a/sdk/resourcemanager/logz/armlogz/go.sum +++ b/sdk/resourcemanager/logz/armlogz/go.sum @@ -1,31 +1,31 @@ -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0 h1:rTnT/Jrcm+figWlYz4Ixzt0SJVR2cMC8lvZcimipiEY= -github.com/Azure/azure-sdk-for-go/sdk/azcore v1.4.0/go.mod h1:ON4tFdPTwRcgWEaVDrN3584Ef+b7GgSJaXxe5fW9t4M= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2 h1:uqM+VoHjVH6zdlkLF2b6O0ZANcHoj3rO0PoQ3jglUJA= -github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.2/go.mod h1:twTKAa1E6hLmSDjLhaCkbTMQKc7p/rNLU40rLxGEOCI= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0 h1:leh5DwKv6Ihwi+h60uHtn6UWAxBbZ0q8DwQVMzf61zw= -github.com/Azure/azure-sdk-for-go/sdk/internal v1.2.0/go.mod h1:eWRD7oawr1Mu1sLCawqVc0CUiF43ia3qQMxLscsKQ9w= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0 h1:UE9n9rkJF62ArLb1F3DEjRt8O3jLwMWdSoypKV4f3MU= -github.com/AzureAD/microsoft-authentication-library-for-go v0.9.0/go.mod h1:kgDmCTgBzIEPFElEF+FK0SdjAor06dRq2Go927dnQ6o= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0 h1:fb8kj/Dh4CSwgsOzHeZY4Xh68cFVbzXx+ONXGMY//4w= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.0/go.mod h1:uReU2sSxZExRPBAg3qKzmAucSi51+SP1OhohieR821Q= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0 h1:BMAjVKJM0U/CYF27gA0ZMmXGkOcvfFtD0oHVZ1TIPRI= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.4.0/go.mod h1:1fXstnBMas5kzG+S3q8UoJcmyU6nUeunJcMDHcRYHhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0 h1:d81/ng9rET2YqdVkVwkb6EXeRrLJIwyGnJcAlAWKwhs= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.0/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1 h1:WpB/QDNLpMw72xHJc34BNNykqSOeEJDAWkhf0u12/Jk= +github.com/AzureAD/microsoft-authentication-library-for-go v1.1.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/dnaeon/go-vcr v1.1.0 h1:ReYa/UBrRyQdant9B4fNHGoCNKw6qh6P0fsdGmZpR7c= -github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg= -github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= +github.com/golang-jwt/jwt/v5 v5.0.0 h1:1n1XNM9hk7O9mnQoNBGolZvzebBQ7p93ULHRc28XJUE= +github.com/golang-jwt/jwt/v5 v5.0.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= +github.com/google/uuid v1.3.1 h1:KjJaJ9iWZ3jOFZIf1Lqf4laDRCasjl0BCmnEGxkdLb4= +github.com/google/uuid v1.3.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU= github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= -golang.org/x/crypto v0.6.0 h1:qfktjS5LUO+fFKeJXZ+ikTRijMmljikvG68fpMMruSc= -golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58= -golang.org/x/net v0.7.0 h1:rJrUqqhjsgNp7KqAIc25s9pZnjU7TUcSY7HcVZjdn1g= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.7.0 h1:4BRB4x83lYWy72KwLD/qYDuTu7q9PjSagHvijDw7cLo= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/sdk/resourcemanager/logz/armlogz/models.go b/sdk/resourcemanager/logz/armlogz/models.go index cd869e99a7f1..8ab85234bf85 100644 --- a/sdk/resourcemanager/logz/armlogz/models.go +++ b/sdk/resourcemanager/logz/armlogz/models.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogz @@ -86,22 +85,6 @@ type LogRules struct { SendSubscriptionLogs *bool } -// MonitorClientListVMHostUpdateOptions contains the optional parameters for the MonitorClient.NewListVMHostUpdatePager method. -type MonitorClientListVMHostUpdateOptions struct { - // Request body to update the collection for agent installed in the given monitor. - Body *VMHostUpdateRequest -} - -// MonitorClientListVMHostsOptions contains the optional parameters for the MonitorClient.NewListVMHostsPager method. -type MonitorClientListVMHostsOptions struct { - // placeholder for future optional parameters -} - -// MonitorClientVMHostPayloadOptions contains the optional parameters for the MonitorClient.VMHostPayload method. -type MonitorClientVMHostPayloadOptions struct { - // placeholder for future optional parameters -} - // MonitorProperties - Properties specific to the monitor resource. type MonitorProperties struct { LogzOrganizationProperties *OrganizationProperties @@ -242,52 +225,6 @@ type MonitoringTagRulesProperties struct { SystemData *SystemData } -// MonitorsClientBeginCreateOptions contains the optional parameters for the MonitorsClient.BeginCreate method. -type MonitorsClientBeginCreateOptions struct { - Body *MonitorResource - // Resumes the LRO from the provided token. - ResumeToken string -} - -// MonitorsClientBeginDeleteOptions contains the optional parameters for the MonitorsClient.BeginDelete method. -type MonitorsClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// MonitorsClientGetOptions contains the optional parameters for the MonitorsClient.Get method. -type MonitorsClientGetOptions struct { - // placeholder for future optional parameters -} - -// MonitorsClientListByResourceGroupOptions contains the optional parameters for the MonitorsClient.NewListByResourceGroupPager -// method. -type MonitorsClientListByResourceGroupOptions struct { - // placeholder for future optional parameters -} - -// MonitorsClientListBySubscriptionOptions contains the optional parameters for the MonitorsClient.NewListBySubscriptionPager -// method. -type MonitorsClientListBySubscriptionOptions struct { - // placeholder for future optional parameters -} - -// MonitorsClientListMonitoredResourcesOptions contains the optional parameters for the MonitorsClient.NewListMonitoredResourcesPager -// method. -type MonitorsClientListMonitoredResourcesOptions struct { - // placeholder for future optional parameters -} - -// MonitorsClientListUserRolesOptions contains the optional parameters for the MonitorsClient.NewListUserRolesPager method. -type MonitorsClientListUserRolesOptions struct { - Body *UserRoleRequest -} - -// MonitorsClientUpdateOptions contains the optional parameters for the MonitorsClient.Update method. -type MonitorsClientUpdateOptions struct { - Body *MonitorResourceUpdateParameters -} - // OperationDisplay - The object that represents the operation. type OperationDisplay struct { // Description of the operation, e.g., 'Write monitors'. @@ -327,11 +264,6 @@ type OperationResult struct { Origin *string } -// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. -type OperationsClientListOptions struct { - // placeholder for future optional parameters -} - type OrganizationProperties struct { // Name of the Logz organization. CompanyName *string @@ -360,24 +292,6 @@ type PlanData struct { UsageType *string } -// SingleSignOnClientBeginCreateOrUpdateOptions contains the optional parameters for the SingleSignOnClient.BeginCreateOrUpdate -// method. -type SingleSignOnClientBeginCreateOrUpdateOptions struct { - Body *SingleSignOnResource - // Resumes the LRO from the provided token. - ResumeToken string -} - -// SingleSignOnClientGetOptions contains the optional parameters for the SingleSignOnClient.Get method. -type SingleSignOnClientGetOptions struct { - // placeholder for future optional parameters -} - -// SingleSignOnClientListOptions contains the optional parameters for the SingleSignOnClient.NewListPager method. -type SingleSignOnClientListOptions struct { - // placeholder for future optional parameters -} - type SingleSignOnProperties struct { // The Id of the Enterprise App used for Single sign-on. EnterpriseAppID *string @@ -417,78 +331,6 @@ type SingleSignOnResourceListResponse struct { Value []*SingleSignOnResource } -// SubAccountClientBeginCreateOptions contains the optional parameters for the SubAccountClient.BeginCreate method. -type SubAccountClientBeginCreateOptions struct { - Body *MonitorResource - // Resumes the LRO from the provided token. - ResumeToken string -} - -// SubAccountClientBeginDeleteOptions contains the optional parameters for the SubAccountClient.BeginDelete method. -type SubAccountClientBeginDeleteOptions struct { - // Resumes the LRO from the provided token. - ResumeToken string -} - -// SubAccountClientGetOptions contains the optional parameters for the SubAccountClient.Get method. -type SubAccountClientGetOptions struct { - // placeholder for future optional parameters -} - -// SubAccountClientListMonitoredResourcesOptions contains the optional parameters for the SubAccountClient.NewListMonitoredResourcesPager -// method. -type SubAccountClientListMonitoredResourcesOptions struct { - // placeholder for future optional parameters -} - -// SubAccountClientListOptions contains the optional parameters for the SubAccountClient.NewListPager method. -type SubAccountClientListOptions struct { - // placeholder for future optional parameters -} - -// SubAccountClientListVMHostUpdateOptions contains the optional parameters for the SubAccountClient.NewListVMHostUpdatePager -// method. -type SubAccountClientListVMHostUpdateOptions struct { - // Request body to update the collection for agent installed in the given monitor. - Body *VMHostUpdateRequest -} - -// SubAccountClientListVMHostsOptions contains the optional parameters for the SubAccountClient.NewListVMHostsPager method. -type SubAccountClientListVMHostsOptions struct { - // placeholder for future optional parameters -} - -// SubAccountClientUpdateOptions contains the optional parameters for the SubAccountClient.Update method. -type SubAccountClientUpdateOptions struct { - Body *MonitorResourceUpdateParameters -} - -// SubAccountClientVMHostPayloadOptions contains the optional parameters for the SubAccountClient.VMHostPayload method. -type SubAccountClientVMHostPayloadOptions struct { - // placeholder for future optional parameters -} - -// SubAccountTagRulesClientCreateOrUpdateOptions contains the optional parameters for the SubAccountTagRulesClient.CreateOrUpdate -// method. -type SubAccountTagRulesClientCreateOrUpdateOptions struct { - Body *MonitoringTagRules -} - -// SubAccountTagRulesClientDeleteOptions contains the optional parameters for the SubAccountTagRulesClient.Delete method. -type SubAccountTagRulesClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// SubAccountTagRulesClientGetOptions contains the optional parameters for the SubAccountTagRulesClient.Get method. -type SubAccountTagRulesClientGetOptions struct { - // placeholder for future optional parameters -} - -// SubAccountTagRulesClientListOptions contains the optional parameters for the SubAccountTagRulesClient.NewListPager method. -type SubAccountTagRulesClientListOptions struct { - // placeholder for future optional parameters -} - // SystemData - Metadata pertaining to creation and last modification of the resource. type SystemData struct { // The timestamp of resource creation (UTC). @@ -510,26 +352,6 @@ type SystemData struct { LastModifiedByType *CreatedByType } -// TagRulesClientCreateOrUpdateOptions contains the optional parameters for the TagRulesClient.CreateOrUpdate method. -type TagRulesClientCreateOrUpdateOptions struct { - Body *MonitoringTagRules -} - -// TagRulesClientDeleteOptions contains the optional parameters for the TagRulesClient.Delete method. -type TagRulesClientDeleteOptions struct { - // placeholder for future optional parameters -} - -// TagRulesClientGetOptions contains the optional parameters for the TagRulesClient.Get method. -type TagRulesClientGetOptions struct { - // placeholder for future optional parameters -} - -// TagRulesClientListOptions contains the optional parameters for the TagRulesClient.NewListPager method. -type TagRulesClientListOptions struct { - // placeholder for future optional parameters -} - type UserInfo struct { // Email of the user used by Logz for contacting them if needed EmailAddress *string diff --git a/sdk/resourcemanager/logz/armlogz/models_serde.go b/sdk/resourcemanager/logz/armlogz/models_serde.go index 403dd6de12d8..2aac1ebf5c49 100644 --- a/sdk/resourcemanager/logz/armlogz/models_serde.go +++ b/sdk/resourcemanager/logz/armlogz/models_serde.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogz @@ -764,7 +763,7 @@ func (o *OrganizationProperties) UnmarshalJSON(data []byte) error { func (p PlanData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) populate(objectMap, "billingCycle", p.BillingCycle) - populateTimeRFC3339(objectMap, "effectiveDate", p.EffectiveDate) + populateDateTimeRFC3339(objectMap, "effectiveDate", p.EffectiveDate) populate(objectMap, "planDetails", p.PlanDetails) populate(objectMap, "usageType", p.UsageType) return json.Marshal(objectMap) @@ -783,7 +782,7 @@ func (p *PlanData) UnmarshalJSON(data []byte) error { err = unpopulate(val, "BillingCycle", &p.BillingCycle) delete(rawMsg, key) case "effectiveDate": - err = unpopulateTimeRFC3339(val, "EffectiveDate", &p.EffectiveDate) + err = unpopulateDateTimeRFC3339(val, "EffectiveDate", &p.EffectiveDate) delete(rawMsg, key) case "planDetails": err = unpopulate(val, "PlanDetails", &p.PlanDetails) @@ -915,10 +914,10 @@ func (s *SingleSignOnResourceListResponse) UnmarshalJSON(data []byte) error { // MarshalJSON implements the json.Marshaller interface for type SystemData. func (s SystemData) MarshalJSON() ([]byte, error) { objectMap := make(map[string]any) - populateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) + populateDateTimeRFC3339(objectMap, "createdAt", s.CreatedAt) populate(objectMap, "createdBy", s.CreatedBy) populate(objectMap, "createdByType", s.CreatedByType) - populateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) + populateDateTimeRFC3339(objectMap, "lastModifiedAt", s.LastModifiedAt) populate(objectMap, "lastModifiedBy", s.LastModifiedBy) populate(objectMap, "lastModifiedByType", s.LastModifiedByType) return json.Marshal(objectMap) @@ -934,7 +933,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { var err error switch key { case "createdAt": - err = unpopulateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) + err = unpopulateDateTimeRFC3339(val, "CreatedAt", &s.CreatedAt) delete(rawMsg, key) case "createdBy": err = unpopulate(val, "CreatedBy", &s.CreatedBy) @@ -943,7 +942,7 @@ func (s *SystemData) UnmarshalJSON(data []byte) error { err = unpopulate(val, "CreatedByType", &s.CreatedByType) delete(rawMsg, key) case "lastModifiedAt": - err = unpopulateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) + err = unpopulateDateTimeRFC3339(val, "LastModifiedAt", &s.LastModifiedAt) delete(rawMsg, key) case "lastModifiedBy": err = unpopulate(val, "LastModifiedBy", &s.LastModifiedBy) diff --git a/sdk/resourcemanager/logz/armlogz/monitor_client.go b/sdk/resourcemanager/logz/armlogz/monitor_client.go index a5e6ede9f003..45de7d14ae30 100644 --- a/sdk/resourcemanager/logz/armlogz/monitor_client.go +++ b/sdk/resourcemanager/logz/armlogz/monitor_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogz @@ -33,7 +32,7 @@ type MonitorClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewMonitorClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MonitorClient, error) { - cl, err := arm.NewClient(moduleName+".MonitorClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -58,25 +57,20 @@ func (client *MonitorClient) NewListVMHostUpdatePager(resourceGroupName string, return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *MonitorClientListVMHostUpdateResponse) (MonitorClientListVMHostUpdateResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listVMHostUpdateCreateRequest(ctx, resourceGroupName, monitorName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "MonitorClient.NewListVMHostUpdatePager") + 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.listVMHostUpdateCreateRequest(ctx, resourceGroupName, monitorName, options) + }, nil) if err != nil { return MonitorClientListVMHostUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return MonitorClientListVMHostUpdateResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MonitorClientListVMHostUpdateResponse{}, runtime.NewResponseError(resp) - } return client.listVMHostUpdateHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -104,7 +98,10 @@ func (client *MonitorClient) listVMHostUpdateCreateRequest(ctx context.Context, req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -130,25 +127,20 @@ func (client *MonitorClient) NewListVMHostsPager(resourceGroupName string, monit return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *MonitorClientListVMHostsResponse) (MonitorClientListVMHostsResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listVMHostsCreateRequest(ctx, resourceGroupName, monitorName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "MonitorClient.NewListVMHostsPager") + 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.listVMHostsCreateRequest(ctx, resourceGroupName, monitorName, options) + }, nil) if err != nil { return MonitorClientListVMHostsResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return MonitorClientListVMHostsResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MonitorClientListVMHostsResponse{}, runtime.NewResponseError(resp) - } return client.listVMHostsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -195,18 +187,25 @@ func (client *MonitorClient) listVMHostsHandleResponse(resp *http.Response) (Mon // - monitorName - Monitor resource name // - options - MonitorClientVMHostPayloadOptions contains the optional parameters for the MonitorClient.VMHostPayload method. func (client *MonitorClient) VMHostPayload(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorClientVMHostPayloadOptions) (MonitorClientVMHostPayloadResponse, error) { + var err error + const operationName = "MonitorClient.VMHostPayload" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.vmHostPayloadCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return MonitorClientVMHostPayloadResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorClientVMHostPayloadResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MonitorClientVMHostPayloadResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return MonitorClientVMHostPayloadResponse{}, err } - return client.vmHostPayloadHandleResponse(resp) + resp, err := client.vmHostPayloadHandleResponse(httpResp) + return resp, err } // vmHostPayloadCreateRequest creates the VMHostPayload request. diff --git a/sdk/resourcemanager/logz/armlogz/monitors_client.go b/sdk/resourcemanager/logz/armlogz/monitors_client.go index da83aca0b2e1..9c03741eed75 100644 --- a/sdk/resourcemanager/logz/armlogz/monitors_client.go +++ b/sdk/resourcemanager/logz/armlogz/monitors_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogz @@ -33,7 +32,7 @@ type MonitorsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewMonitorsClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*MonitorsClient, error) { - cl, err := arm.NewClient(moduleName+".MonitorsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -57,11 +56,15 @@ func (client *MonitorsClient) BeginCreate(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MonitorsClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MonitorsClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[MonitorsClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[MonitorsClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -70,18 +73,24 @@ func (client *MonitorsClient) BeginCreate(ctx context.Context, resourceGroupName // // Generated from API version 2020-10-01 func (client *MonitorsClient) create(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "MonitorsClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createCreateRequest(ctx, resourceGroupName, monitorName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createCreateRequest creates the Create request. @@ -108,7 +117,10 @@ func (client *MonitorsClient) createCreateRequest(ctx context.Context, resourceG req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -126,11 +138,15 @@ func (client *MonitorsClient) BeginDelete(ctx context.Context, resourceGroupName if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MonitorsClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[MonitorsClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[MonitorsClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[MonitorsClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -139,18 +155,24 @@ func (client *MonitorsClient) BeginDelete(ctx context.Context, resourceGroupName // // Generated from API version 2020-10-01 func (client *MonitorsClient) deleteOperation(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "MonitorsClient.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, monitorName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -187,18 +209,25 @@ func (client *MonitorsClient) deleteCreateRequest(ctx context.Context, resourceG // - monitorName - Monitor resource name // - options - MonitorsClientGetOptions contains the optional parameters for the MonitorsClient.Get method. func (client *MonitorsClient) Get(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientGetOptions) (MonitorsClientGetResponse, error) { + var err error + const operationName = "MonitorsClient.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, monitorName, options) if err != nil { return MonitorsClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MonitorsClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return MonitorsClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -248,25 +277,20 @@ func (client *MonitorsClient) NewListByResourceGroupPager(resourceGroupName stri return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *MonitorsClientListByResourceGroupResponse) (MonitorsClientListByResourceGroupResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "MonitorsClient.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 MonitorsClientListByResourceGroupResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return MonitorsClientListByResourceGroupResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MonitorsClientListByResourceGroupResponse{}, runtime.NewResponseError(resp) - } return client.listByResourceGroupHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -312,25 +336,20 @@ func (client *MonitorsClient) NewListBySubscriptionPager(options *MonitorsClient return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *MonitorsClientListBySubscriptionResponse) (MonitorsClientListBySubscriptionResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listBySubscriptionCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return MonitorsClientListBySubscriptionResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "MonitorsClient.NewListBySubscriptionPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + 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 MonitorsClientListBySubscriptionResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MonitorsClientListBySubscriptionResponse{}, runtime.NewResponseError(resp) - } return client.listBySubscriptionHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -374,25 +393,20 @@ func (client *MonitorsClient) NewListMonitoredResourcesPager(resourceGroupName s return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *MonitorsClientListMonitoredResourcesResponse) (MonitorsClientListMonitoredResourcesResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listMonitoredResourcesCreateRequest(ctx, resourceGroupName, monitorName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return MonitorsClientListMonitoredResourcesResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "MonitorsClient.NewListMonitoredResourcesPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listMonitoredResourcesCreateRequest(ctx, resourceGroupName, monitorName, options) + }, nil) if err != nil { return MonitorsClientListMonitoredResourcesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MonitorsClientListMonitoredResourcesResponse{}, runtime.NewResponseError(resp) - } return client.listMonitoredResourcesHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -444,25 +458,20 @@ func (client *MonitorsClient) NewListUserRolesPager(resourceGroupName string, mo return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *MonitorsClientListUserRolesResponse) (MonitorsClientListUserRolesResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listUserRolesCreateRequest(ctx, resourceGroupName, monitorName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return MonitorsClientListUserRolesResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "MonitorsClient.NewListUserRolesPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listUserRolesCreateRequest(ctx, resourceGroupName, monitorName, options) + }, nil) if err != nil { return MonitorsClientListUserRolesResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MonitorsClientListUserRolesResponse{}, runtime.NewResponseError(resp) - } return client.listUserRolesHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -490,7 +499,10 @@ func (client *MonitorsClient) listUserRolesCreateRequest(ctx context.Context, re req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -512,18 +524,25 @@ func (client *MonitorsClient) listUserRolesHandleResponse(resp *http.Response) ( // - monitorName - Monitor resource name // - options - MonitorsClientUpdateOptions contains the optional parameters for the MonitorsClient.Update method. func (client *MonitorsClient) Update(ctx context.Context, resourceGroupName string, monitorName string, options *MonitorsClientUpdateOptions) (MonitorsClientUpdateResponse, error) { + var err error + const operationName = "MonitorsClient.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, monitorName, options) if err != nil { return MonitorsClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return MonitorsClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return MonitorsClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return MonitorsClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -550,7 +569,10 @@ func (client *MonitorsClient) updateCreateRequest(ctx context.Context, resourceG req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } diff --git a/sdk/resourcemanager/logz/armlogz/monitors_client_example_test.go b/sdk/resourcemanager/logz/armlogz/monitors_client_example_test.go index 55bc67ff0667..cbe89d9ddd41 100644 --- a/sdk/resourcemanager/logz/armlogz/monitors_client_example_test.go +++ b/sdk/resourcemanager/logz/armlogz/monitors_client_example_test.go @@ -83,7 +83,7 @@ func ExampleMonitorsClient_NewListBySubscriptionPager() { // MonitoringStatus: to.Ptr(armlogz.MonitoringStatusEnabled), // PlanData: &armlogz.PlanData{ // BillingCycle: to.Ptr("Monthly"), - // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-30T15:14:33+02:00"); return t}()), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-30T13:14:33.000Z"); return t}()), // PlanDetails: to.Ptr("logzapitestplan"), // UsageType: to.Ptr("Committed"), // }, @@ -135,7 +135,7 @@ func ExampleMonitorsClient_NewListByResourceGroupPager() { // Properties: &armlogz.MonitorProperties{ // PlanData: &armlogz.PlanData{ // BillingCycle: to.Ptr("Monthly"), - // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-30T15:14:33+02:00"); return t}()), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-30T13:14:33.000Z"); return t}()), // PlanDetails: to.Ptr("logzapitestplan"), // UsageType: to.Ptr("Committed"), // }, @@ -182,7 +182,7 @@ func ExampleMonitorsClient_Get() { // MonitoringStatus: to.Ptr(armlogz.MonitoringStatusEnabled), // PlanData: &armlogz.PlanData{ // BillingCycle: to.Ptr("Monthly"), - // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-30T15:14:33+02:00"); return t}()), + // EffectiveDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-30T13:14:33.000Z"); return t}()), // PlanDetails: to.Ptr("logzapitestplan"), // UsageType: to.Ptr("Committed"), // }, diff --git a/sdk/resourcemanager/logz/armlogz/operations_client.go b/sdk/resourcemanager/logz/armlogz/operations_client.go index 9ea65ddb28be..4b48257e9864 100644 --- a/sdk/resourcemanager/logz/armlogz/operations_client.go +++ b/sdk/resourcemanager/logz/armlogz/operations_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogz @@ -28,7 +27,7 @@ type OperationsClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewOperationsClient(credential azcore.TokenCredential, options *arm.ClientOptions) (*OperationsClient, error) { - cl, err := arm.NewClient(moduleName+".OperationsClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -48,25 +47,20 @@ func (client *OperationsClient) NewListPager(options *OperationsClientListOption return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *OperationsClientListResponse) (OperationsClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "OperationsClient.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, options) + }, nil) if err != nil { return OperationsClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return OperationsClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return OperationsClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/logz/armlogz/options.go b/sdk/resourcemanager/logz/armlogz/options.go new file mode 100644 index 000000000000..859cffea76ae --- /dev/null +++ b/sdk/resourcemanager/logz/armlogz/options.go @@ -0,0 +1,189 @@ +//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 armlogz + +// MonitorClientListVMHostUpdateOptions contains the optional parameters for the MonitorClient.NewListVMHostUpdatePager method. +type MonitorClientListVMHostUpdateOptions struct { + // Request body to update the collection for agent installed in the given monitor. + Body *VMHostUpdateRequest +} + +// MonitorClientListVMHostsOptions contains the optional parameters for the MonitorClient.NewListVMHostsPager method. +type MonitorClientListVMHostsOptions struct { + // placeholder for future optional parameters +} + +// MonitorClientVMHostPayloadOptions contains the optional parameters for the MonitorClient.VMHostPayload method. +type MonitorClientVMHostPayloadOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientBeginCreateOptions contains the optional parameters for the MonitorsClient.BeginCreate method. +type MonitorsClientBeginCreateOptions struct { + Body *MonitorResource + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// MonitorsClientBeginDeleteOptions contains the optional parameters for the MonitorsClient.BeginDelete method. +type MonitorsClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// MonitorsClientGetOptions contains the optional parameters for the MonitorsClient.Get method. +type MonitorsClientGetOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientListByResourceGroupOptions contains the optional parameters for the MonitorsClient.NewListByResourceGroupPager +// method. +type MonitorsClientListByResourceGroupOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientListBySubscriptionOptions contains the optional parameters for the MonitorsClient.NewListBySubscriptionPager +// method. +type MonitorsClientListBySubscriptionOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientListMonitoredResourcesOptions contains the optional parameters for the MonitorsClient.NewListMonitoredResourcesPager +// method. +type MonitorsClientListMonitoredResourcesOptions struct { + // placeholder for future optional parameters +} + +// MonitorsClientListUserRolesOptions contains the optional parameters for the MonitorsClient.NewListUserRolesPager method. +type MonitorsClientListUserRolesOptions struct { + Body *UserRoleRequest +} + +// MonitorsClientUpdateOptions contains the optional parameters for the MonitorsClient.Update method. +type MonitorsClientUpdateOptions struct { + Body *MonitorResourceUpdateParameters +} + +// OperationsClientListOptions contains the optional parameters for the OperationsClient.NewListPager method. +type OperationsClientListOptions struct { + // placeholder for future optional parameters +} + +// SingleSignOnClientBeginCreateOrUpdateOptions contains the optional parameters for the SingleSignOnClient.BeginCreateOrUpdate +// method. +type SingleSignOnClientBeginCreateOrUpdateOptions struct { + Body *SingleSignOnResource + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SingleSignOnClientGetOptions contains the optional parameters for the SingleSignOnClient.Get method. +type SingleSignOnClientGetOptions struct { + // placeholder for future optional parameters +} + +// SingleSignOnClientListOptions contains the optional parameters for the SingleSignOnClient.NewListPager method. +type SingleSignOnClientListOptions struct { + // placeholder for future optional parameters +} + +// SubAccountClientBeginCreateOptions contains the optional parameters for the SubAccountClient.BeginCreate method. +type SubAccountClientBeginCreateOptions struct { + Body *MonitorResource + + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SubAccountClientBeginDeleteOptions contains the optional parameters for the SubAccountClient.BeginDelete method. +type SubAccountClientBeginDeleteOptions struct { + // Resumes the LRO from the provided token. + ResumeToken string +} + +// SubAccountClientGetOptions contains the optional parameters for the SubAccountClient.Get method. +type SubAccountClientGetOptions struct { + // placeholder for future optional parameters +} + +// SubAccountClientListMonitoredResourcesOptions contains the optional parameters for the SubAccountClient.NewListMonitoredResourcesPager +// method. +type SubAccountClientListMonitoredResourcesOptions struct { + // placeholder for future optional parameters +} + +// SubAccountClientListOptions contains the optional parameters for the SubAccountClient.NewListPager method. +type SubAccountClientListOptions struct { + // placeholder for future optional parameters +} + +// SubAccountClientListVMHostUpdateOptions contains the optional parameters for the SubAccountClient.NewListVMHostUpdatePager +// method. +type SubAccountClientListVMHostUpdateOptions struct { + // Request body to update the collection for agent installed in the given monitor. + Body *VMHostUpdateRequest +} + +// SubAccountClientListVMHostsOptions contains the optional parameters for the SubAccountClient.NewListVMHostsPager method. +type SubAccountClientListVMHostsOptions struct { + // placeholder for future optional parameters +} + +// SubAccountClientUpdateOptions contains the optional parameters for the SubAccountClient.Update method. +type SubAccountClientUpdateOptions struct { + Body *MonitorResourceUpdateParameters +} + +// SubAccountClientVMHostPayloadOptions contains the optional parameters for the SubAccountClient.VMHostPayload method. +type SubAccountClientVMHostPayloadOptions struct { + // placeholder for future optional parameters +} + +// SubAccountTagRulesClientCreateOrUpdateOptions contains the optional parameters for the SubAccountTagRulesClient.CreateOrUpdate +// method. +type SubAccountTagRulesClientCreateOrUpdateOptions struct { + Body *MonitoringTagRules +} + +// SubAccountTagRulesClientDeleteOptions contains the optional parameters for the SubAccountTagRulesClient.Delete method. +type SubAccountTagRulesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// SubAccountTagRulesClientGetOptions contains the optional parameters for the SubAccountTagRulesClient.Get method. +type SubAccountTagRulesClientGetOptions struct { + // placeholder for future optional parameters +} + +// SubAccountTagRulesClientListOptions contains the optional parameters for the SubAccountTagRulesClient.NewListPager method. +type SubAccountTagRulesClientListOptions struct { + // placeholder for future optional parameters +} + +// TagRulesClientCreateOrUpdateOptions contains the optional parameters for the TagRulesClient.CreateOrUpdate method. +type TagRulesClientCreateOrUpdateOptions struct { + Body *MonitoringTagRules +} + +// TagRulesClientDeleteOptions contains the optional parameters for the TagRulesClient.Delete method. +type TagRulesClientDeleteOptions struct { + // placeholder for future optional parameters +} + +// TagRulesClientGetOptions contains the optional parameters for the TagRulesClient.Get method. +type TagRulesClientGetOptions struct { + // placeholder for future optional parameters +} + +// TagRulesClientListOptions contains the optional parameters for the TagRulesClient.NewListPager method. +type TagRulesClientListOptions struct { + // placeholder for future optional parameters +} diff --git a/sdk/resourcemanager/logz/armlogz/response_types.go b/sdk/resourcemanager/logz/armlogz/response_types.go index a06ec1460325..7f24ea9c159e 100644 --- a/sdk/resourcemanager/logz/armlogz/response_types.go +++ b/sdk/resourcemanager/logz/armlogz/response_types.go @@ -3,24 +3,26 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogz // MonitorClientListVMHostUpdateResponse contains the response from method MonitorClient.NewListVMHostUpdatePager. type MonitorClientListVMHostUpdateResponse struct { + // Response of a list VM Host Update Operation. VMResourcesListResponse } // MonitorClientListVMHostsResponse contains the response from method MonitorClient.NewListVMHostsPager. type MonitorClientListVMHostsResponse struct { + // Response of a list VM Host Update Operation. VMResourcesListResponse } // MonitorClientVMHostPayloadResponse contains the response from method MonitorClient.VMHostPayload. type MonitorClientVMHostPayloadResponse struct { + // Response of payload to be passed while installing VM agent. VMExtensionPayload } @@ -41,21 +43,25 @@ type MonitorsClientGetResponse struct { // MonitorsClientListByResourceGroupResponse contains the response from method MonitorsClient.NewListByResourceGroupPager. type MonitorsClientListByResourceGroupResponse struct { + // Response of a list operation. MonitorResourceListResponse } // MonitorsClientListBySubscriptionResponse contains the response from method MonitorsClient.NewListBySubscriptionPager. type MonitorsClientListBySubscriptionResponse struct { + // Response of a list operation. MonitorResourceListResponse } // MonitorsClientListMonitoredResourcesResponse contains the response from method MonitorsClient.NewListMonitoredResourcesPager. type MonitorsClientListMonitoredResourcesResponse struct { + // Response of a list operation. MonitoredResourceListResponse } // MonitorsClientListUserRolesResponse contains the response from method MonitorsClient.NewListUserRolesPager. type MonitorsClientListUserRolesResponse struct { + // Response for list of user's role for Logz.io account. UserRoleListResponse } @@ -66,6 +72,7 @@ type MonitorsClientUpdateResponse struct { // OperationsClientListResponse contains the response from method OperationsClient.NewListPager. type OperationsClientListResponse struct { + // Result of GET request to list the Microsoft.Logz operations. OperationListResult } @@ -81,6 +88,7 @@ type SingleSignOnClientGetResponse struct { // SingleSignOnClientListResponse contains the response from method SingleSignOnClient.NewListPager. type SingleSignOnClientListResponse struct { + // Response of a list operation. SingleSignOnResourceListResponse } @@ -101,21 +109,25 @@ type SubAccountClientGetResponse struct { // SubAccountClientListMonitoredResourcesResponse contains the response from method SubAccountClient.NewListMonitoredResourcesPager. type SubAccountClientListMonitoredResourcesResponse struct { + // Response of a list operation. MonitoredResourceListResponse } // SubAccountClientListResponse contains the response from method SubAccountClient.NewListPager. type SubAccountClientListResponse struct { + // Response of a list operation. MonitorResourceListResponse } // SubAccountClientListVMHostUpdateResponse contains the response from method SubAccountClient.NewListVMHostUpdatePager. type SubAccountClientListVMHostUpdateResponse struct { + // Response of a list VM Host Update Operation. VMResourcesListResponse } // SubAccountClientListVMHostsResponse contains the response from method SubAccountClient.NewListVMHostsPager. type SubAccountClientListVMHostsResponse struct { + // Response of a list VM Host Update Operation. VMResourcesListResponse } @@ -126,11 +138,13 @@ type SubAccountClientUpdateResponse struct { // SubAccountClientVMHostPayloadResponse contains the response from method SubAccountClient.VMHostPayload. type SubAccountClientVMHostPayloadResponse struct { + // Response of payload to be passed while installing VM agent. VMExtensionPayload } // SubAccountTagRulesClientCreateOrUpdateResponse contains the response from method SubAccountTagRulesClient.CreateOrUpdate. type SubAccountTagRulesClientCreateOrUpdateResponse struct { + // Capture logs and metrics of Azure resources based on ARM tags. MonitoringTagRules } @@ -142,16 +156,19 @@ type SubAccountTagRulesClientDeleteResponse struct { // SubAccountTagRulesClientGetResponse contains the response from method SubAccountTagRulesClient.Get. type SubAccountTagRulesClientGetResponse struct { + // Capture logs and metrics of Azure resources based on ARM tags. MonitoringTagRules } // SubAccountTagRulesClientListResponse contains the response from method SubAccountTagRulesClient.NewListPager. type SubAccountTagRulesClientListResponse struct { + // Response of a list operation. MonitoringTagRulesListResponse } // TagRulesClientCreateOrUpdateResponse contains the response from method TagRulesClient.CreateOrUpdate. type TagRulesClientCreateOrUpdateResponse struct { + // Capture logs and metrics of Azure resources based on ARM tags. MonitoringTagRules } @@ -163,10 +180,12 @@ type TagRulesClientDeleteResponse struct { // TagRulesClientGetResponse contains the response from method TagRulesClient.Get. type TagRulesClientGetResponse struct { + // Capture logs and metrics of Azure resources based on ARM tags. MonitoringTagRules } // TagRulesClientListResponse contains the response from method TagRulesClient.NewListPager. type TagRulesClientListResponse struct { + // Response of a list operation. MonitoringTagRulesListResponse } diff --git a/sdk/resourcemanager/logz/armlogz/singlesignon_client.go b/sdk/resourcemanager/logz/armlogz/singlesignon_client.go index 074195ca5e97..62ec239218e7 100644 --- a/sdk/resourcemanager/logz/armlogz/singlesignon_client.go +++ b/sdk/resourcemanager/logz/armlogz/singlesignon_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogz @@ -33,7 +32,7 @@ type SingleSignOnClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSingleSignOnClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SingleSignOnClient, error) { - cl, err := arm.NewClient(moduleName+".SingleSignOnClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -58,11 +57,15 @@ func (client *SingleSignOnClient) BeginCreateOrUpdate(ctx context.Context, resou if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SingleSignOnClientCreateOrUpdateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SingleSignOnClientCreateOrUpdateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[SingleSignOnClientCreateOrUpdateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SingleSignOnClientCreateOrUpdateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -71,18 +74,24 @@ func (client *SingleSignOnClient) BeginCreateOrUpdate(ctx context.Context, resou // // Generated from API version 2020-10-01 func (client *SingleSignOnClient) createOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, configurationName string, options *SingleSignOnClientBeginCreateOrUpdateOptions) (*http.Response, error) { + var err error + const operationName = "SingleSignOnClient.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, monitorName, configurationName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -113,7 +122,10 @@ func (client *SingleSignOnClient) createOrUpdateCreateRequest(ctx context.Contex req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -126,18 +138,25 @@ func (client *SingleSignOnClient) createOrUpdateCreateRequest(ctx context.Contex // - monitorName - Monitor resource name // - options - SingleSignOnClientGetOptions contains the optional parameters for the SingleSignOnClient.Get method. func (client *SingleSignOnClient) Get(ctx context.Context, resourceGroupName string, monitorName string, configurationName string, options *SingleSignOnClientGetOptions) (SingleSignOnClientGetResponse, error) { + var err error + const operationName = "SingleSignOnClient.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, monitorName, configurationName, options) if err != nil { return SingleSignOnClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SingleSignOnClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SingleSignOnClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SingleSignOnClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -191,25 +210,20 @@ func (client *SingleSignOnClient) NewListPager(resourceGroupName string, monitor return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *SingleSignOnClientListResponse) (SingleSignOnClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, monitorName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SingleSignOnClient.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, resourceGroupName, monitorName, options) + }, nil) if err != nil { return SingleSignOnClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return SingleSignOnClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SingleSignOnClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/logz/armlogz/subaccount_client.go b/sdk/resourcemanager/logz/armlogz/subaccount_client.go index e03802211722..354933aac18f 100644 --- a/sdk/resourcemanager/logz/armlogz/subaccount_client.go +++ b/sdk/resourcemanager/logz/armlogz/subaccount_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogz @@ -33,7 +32,7 @@ type SubAccountClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSubAccountClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SubAccountClient, error) { - cl, err := arm.NewClient(moduleName+".SubAccountClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -58,11 +57,15 @@ func (client *SubAccountClient) BeginCreate(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SubAccountClientCreateResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SubAccountClientCreateResponse]{ FinalStateVia: runtime.FinalStateViaAzureAsyncOp, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[SubAccountClientCreateResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SubAccountClientCreateResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -71,18 +74,24 @@ func (client *SubAccountClient) BeginCreate(ctx context.Context, resourceGroupNa // // Generated from API version 2020-10-01 func (client *SubAccountClient) create(ctx context.Context, resourceGroupName string, monitorName string, subAccountName string, options *SubAccountClientBeginCreateOptions) (*http.Response, error) { + var err error + const operationName = "SubAccountClient.BeginCreate" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.createCreateRequest(ctx, resourceGroupName, monitorName, subAccountName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusCreated) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusCreated) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // createCreateRequest creates the Create request. @@ -113,7 +122,10 @@ func (client *SubAccountClient) createCreateRequest(ctx context.Context, resourc req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -132,11 +144,15 @@ func (client *SubAccountClient) BeginDelete(ctx context.Context, resourceGroupNa if err != nil { return nil, err } - return runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SubAccountClientDeleteResponse]{ + poller, err := runtime.NewPoller(resp, client.internal.Pipeline(), &runtime.NewPollerOptions[SubAccountClientDeleteResponse]{ FinalStateVia: runtime.FinalStateViaLocation, + Tracer: client.internal.Tracer(), }) + return poller, err } else { - return runtime.NewPollerFromResumeToken[SubAccountClientDeleteResponse](options.ResumeToken, client.internal.Pipeline(), nil) + return runtime.NewPollerFromResumeToken(options.ResumeToken, client.internal.Pipeline(), &runtime.NewPollerFromResumeTokenOptions[SubAccountClientDeleteResponse]{ + Tracer: client.internal.Tracer(), + }) } } @@ -145,18 +161,24 @@ func (client *SubAccountClient) BeginDelete(ctx context.Context, resourceGroupNa // // Generated from API version 2020-10-01 func (client *SubAccountClient) deleteOperation(ctx context.Context, resourceGroupName string, monitorName string, subAccountName string, options *SubAccountClientBeginDeleteOptions) (*http.Response, error) { + var err error + const operationName = "SubAccountClient.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, monitorName, subAccountName, options) if err != nil { return nil, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return nil, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return nil, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return nil, err } - return resp, nil + return httpResp, nil } // deleteCreateRequest creates the Delete request. @@ -198,18 +220,25 @@ func (client *SubAccountClient) deleteCreateRequest(ctx context.Context, resourc // - subAccountName - Sub Account resource name // - options - SubAccountClientGetOptions contains the optional parameters for the SubAccountClient.Get method. func (client *SubAccountClient) Get(ctx context.Context, resourceGroupName string, monitorName string, subAccountName string, options *SubAccountClientGetOptions) (SubAccountClientGetResponse, error) { + var err error + const operationName = "SubAccountClient.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, monitorName, subAccountName, options) if err != nil { return SubAccountClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SubAccountClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SubAccountClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SubAccountClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -263,25 +292,20 @@ func (client *SubAccountClient) NewListPager(resourceGroupName string, monitorNa return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *SubAccountClientListResponse) (SubAccountClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, monitorName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SubAccountClient.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, resourceGroupName, monitorName, options) + }, nil) if err != nil { return SubAccountClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return SubAccountClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SubAccountClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -334,25 +358,20 @@ func (client *SubAccountClient) NewListMonitoredResourcesPager(resourceGroupName return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *SubAccountClientListMonitoredResourcesResponse) (SubAccountClientListMonitoredResourcesResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listMonitoredResourcesCreateRequest(ctx, resourceGroupName, monitorName, subAccountName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SubAccountClient.NewListMonitoredResourcesPager") + 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.listMonitoredResourcesCreateRequest(ctx, resourceGroupName, monitorName, subAccountName, options) + }, nil) if err != nil { return SubAccountClientListMonitoredResourcesResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return SubAccountClientListMonitoredResourcesResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SubAccountClientListMonitoredResourcesResponse{}, runtime.NewResponseError(resp) - } return client.listMonitoredResourcesHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -410,25 +429,20 @@ func (client *SubAccountClient) NewListVMHostUpdatePager(resourceGroupName strin return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *SubAccountClientListVMHostUpdateResponse) (SubAccountClientListVMHostUpdateResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listVMHostUpdateCreateRequest(ctx, resourceGroupName, monitorName, subAccountName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SubAccountClient.NewListVMHostUpdatePager") + 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.listVMHostUpdateCreateRequest(ctx, resourceGroupName, monitorName, subAccountName, options) + }, nil) if err != nil { return SubAccountClientListVMHostUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return SubAccountClientListVMHostUpdateResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SubAccountClientListVMHostUpdateResponse{}, runtime.NewResponseError(resp) - } return client.listVMHostUpdateHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -460,7 +474,10 @@ func (client *SubAccountClient) listVMHostUpdateCreateRequest(ctx context.Contex req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -488,25 +505,20 @@ func (client *SubAccountClient) NewListVMHostsPager(resourceGroupName string, mo return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *SubAccountClientListVMHostsResponse) (SubAccountClientListVMHostsResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listVMHostsCreateRequest(ctx, resourceGroupName, monitorName, subAccountName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) - } - if err != nil { - return SubAccountClientListVMHostsResponse{}, err + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SubAccountClient.NewListVMHostsPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink } - resp, err := client.internal.Pipeline().Do(req) + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listVMHostsCreateRequest(ctx, resourceGroupName, monitorName, subAccountName, options) + }, nil) if err != nil { return SubAccountClientListVMHostsResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SubAccountClientListVMHostsResponse{}, runtime.NewResponseError(resp) - } return client.listVMHostsHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } @@ -558,18 +570,25 @@ func (client *SubAccountClient) listVMHostsHandleResponse(resp *http.Response) ( // - subAccountName - Sub Account resource name // - options - SubAccountClientUpdateOptions contains the optional parameters for the SubAccountClient.Update method. func (client *SubAccountClient) Update(ctx context.Context, resourceGroupName string, monitorName string, subAccountName string, options *SubAccountClientUpdateOptions) (SubAccountClientUpdateResponse, error) { + var err error + const operationName = "SubAccountClient.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, monitorName, subAccountName, options) if err != nil { return SubAccountClientUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SubAccountClientUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SubAccountClientUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SubAccountClientUpdateResponse{}, err } - return client.updateHandleResponse(resp) + resp, err := client.updateHandleResponse(httpResp) + return resp, err } // updateCreateRequest creates the Update request. @@ -600,7 +619,10 @@ func (client *SubAccountClient) updateCreateRequest(ctx context.Context, resourc req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -624,18 +646,25 @@ func (client *SubAccountClient) updateHandleResponse(resp *http.Response) (SubAc // - options - SubAccountClientVMHostPayloadOptions contains the optional parameters for the SubAccountClient.VMHostPayload // method. func (client *SubAccountClient) VMHostPayload(ctx context.Context, resourceGroupName string, monitorName string, subAccountName string, options *SubAccountClientVMHostPayloadOptions) (SubAccountClientVMHostPayloadResponse, error) { + var err error + const operationName = "SubAccountClient.VMHostPayload" + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) + ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) + defer func() { endSpan(err) }() req, err := client.vmHostPayloadCreateRequest(ctx, resourceGroupName, monitorName, subAccountName, options) if err != nil { return SubAccountClientVMHostPayloadResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SubAccountClientVMHostPayloadResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SubAccountClientVMHostPayloadResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SubAccountClientVMHostPayloadResponse{}, err } - return client.vmHostPayloadHandleResponse(resp) + resp, err := client.vmHostPayloadHandleResponse(httpResp) + return resp, err } // vmHostPayloadCreateRequest creates the VMHostPayload request. diff --git a/sdk/resourcemanager/logz/armlogz/subaccounttagrules_client.go b/sdk/resourcemanager/logz/armlogz/subaccounttagrules_client.go index 2ebe6dae92f4..1e481abb1e8d 100644 --- a/sdk/resourcemanager/logz/armlogz/subaccounttagrules_client.go +++ b/sdk/resourcemanager/logz/armlogz/subaccounttagrules_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogz @@ -33,7 +32,7 @@ type SubAccountTagRulesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewSubAccountTagRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*SubAccountTagRulesClient, error) { - cl, err := arm.NewClient(moduleName+".SubAccountTagRulesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -54,18 +53,25 @@ func NewSubAccountTagRulesClient(subscriptionID string, credential azcore.TokenC // - options - SubAccountTagRulesClientCreateOrUpdateOptions contains the optional parameters for the SubAccountTagRulesClient.CreateOrUpdate // method. func (client *SubAccountTagRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, subAccountName string, ruleSetName string, options *SubAccountTagRulesClientCreateOrUpdateOptions) (SubAccountTagRulesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "SubAccountTagRulesClient.CreateOrUpdate" + 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, monitorName, subAccountName, ruleSetName, options) if err != nil { return SubAccountTagRulesClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SubAccountTagRulesClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SubAccountTagRulesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SubAccountTagRulesClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -100,7 +106,10 @@ func (client *SubAccountTagRulesClient) createOrUpdateCreateRequest(ctx context. req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -124,18 +133,25 @@ func (client *SubAccountTagRulesClient) createOrUpdateHandleResponse(resp *http. // - options - SubAccountTagRulesClientDeleteOptions contains the optional parameters for the SubAccountTagRulesClient.Delete // method. func (client *SubAccountTagRulesClient) Delete(ctx context.Context, resourceGroupName string, monitorName string, subAccountName string, ruleSetName string, options *SubAccountTagRulesClientDeleteOptions) (SubAccountTagRulesClientDeleteResponse, error) { + var err error + const operationName = "SubAccountTagRulesClient.Delete" + 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, monitorName, subAccountName, ruleSetName, options) if err != nil { return SubAccountTagRulesClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SubAccountTagRulesClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return SubAccountTagRulesClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return SubAccountTagRulesClientDeleteResponse{}, err } - return client.deleteHandleResponse(resp) + resp, err := client.deleteHandleResponse(httpResp) + return resp, err } // deleteCreateRequest creates the Delete request. @@ -190,18 +206,25 @@ func (client *SubAccountTagRulesClient) deleteHandleResponse(resp *http.Response // - subAccountName - Sub Account resource name // - options - SubAccountTagRulesClientGetOptions contains the optional parameters for the SubAccountTagRulesClient.Get method. func (client *SubAccountTagRulesClient) Get(ctx context.Context, resourceGroupName string, monitorName string, subAccountName string, ruleSetName string, options *SubAccountTagRulesClientGetOptions) (SubAccountTagRulesClientGetResponse, error) { + var err error + const operationName = "SubAccountTagRulesClient.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, monitorName, subAccountName, ruleSetName, options) if err != nil { return SubAccountTagRulesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return SubAccountTagRulesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SubAccountTagRulesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return SubAccountTagRulesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -261,25 +284,20 @@ func (client *SubAccountTagRulesClient) NewListPager(resourceGroupName string, m return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *SubAccountTagRulesClientListResponse) (SubAccountTagRulesClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, monitorName, subAccountName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "SubAccountTagRulesClient.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, resourceGroupName, monitorName, subAccountName, options) + }, nil) if err != nil { return SubAccountTagRulesClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return SubAccountTagRulesClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return SubAccountTagRulesClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/logz/armlogz/tagrules_client.go b/sdk/resourcemanager/logz/armlogz/tagrules_client.go index aa418e38deb7..6e26d360414a 100644 --- a/sdk/resourcemanager/logz/armlogz/tagrules_client.go +++ b/sdk/resourcemanager/logz/armlogz/tagrules_client.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogz @@ -33,7 +32,7 @@ type TagRulesClient struct { // - credential - used to authorize requests. Usually a credential from azidentity. // - options - pass nil to accept the default values. func NewTagRulesClient(subscriptionID string, credential azcore.TokenCredential, options *arm.ClientOptions) (*TagRulesClient, error) { - cl, err := arm.NewClient(moduleName+".TagRulesClient", moduleVersion, credential, options) + cl, err := arm.NewClient(moduleName, moduleVersion, credential, options) if err != nil { return nil, err } @@ -52,18 +51,25 @@ func NewTagRulesClient(subscriptionID string, credential azcore.TokenCredential, // - monitorName - Monitor resource name // - options - TagRulesClientCreateOrUpdateOptions contains the optional parameters for the TagRulesClient.CreateOrUpdate method. func (client *TagRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientCreateOrUpdateOptions) (TagRulesClientCreateOrUpdateResponse, error) { + var err error + const operationName = "TagRulesClient.CreateOrUpdate" + 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, monitorName, ruleSetName, options) if err != nil { return TagRulesClientCreateOrUpdateResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return TagRulesClientCreateOrUpdateResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return TagRulesClientCreateOrUpdateResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TagRulesClientCreateOrUpdateResponse{}, err } - return client.createOrUpdateHandleResponse(resp) + resp, err := client.createOrUpdateHandleResponse(httpResp) + return resp, err } // createOrUpdateCreateRequest creates the CreateOrUpdate request. @@ -94,7 +100,10 @@ func (client *TagRulesClient) createOrUpdateCreateRequest(ctx context.Context, r req.Raw().URL.RawQuery = reqQP.Encode() req.Raw().Header["Accept"] = []string{"application/json"} if options != nil && options.Body != nil { - return req, runtime.MarshalAsJSON(req, *options.Body) + if err := runtime.MarshalAsJSON(req, *options.Body); err != nil { + return nil, err + } + return req, nil } return req, nil } @@ -116,18 +125,25 @@ func (client *TagRulesClient) createOrUpdateHandleResponse(resp *http.Response) // - monitorName - Monitor resource name // - options - TagRulesClientDeleteOptions contains the optional parameters for the TagRulesClient.Delete method. func (client *TagRulesClient) Delete(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientDeleteOptions) (TagRulesClientDeleteResponse, error) { + var err error + const operationName = "TagRulesClient.Delete" + 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, monitorName, ruleSetName, options) if err != nil { return TagRulesClientDeleteResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return TagRulesClientDeleteResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { - return TagRulesClientDeleteResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK, http.StatusAccepted, http.StatusNoContent) { + err = runtime.NewResponseError(httpResp) + return TagRulesClientDeleteResponse{}, err } - return client.deleteHandleResponse(resp) + resp, err := client.deleteHandleResponse(httpResp) + return resp, err } // deleteCreateRequest creates the Delete request. @@ -177,18 +193,25 @@ func (client *TagRulesClient) deleteHandleResponse(resp *http.Response) (TagRule // - monitorName - Monitor resource name // - options - TagRulesClientGetOptions contains the optional parameters for the TagRulesClient.Get method. func (client *TagRulesClient) Get(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, options *TagRulesClientGetOptions) (TagRulesClientGetResponse, error) { + var err error + const operationName = "TagRulesClient.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, monitorName, ruleSetName, options) if err != nil { return TagRulesClientGetResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) + httpResp, err := client.internal.Pipeline().Do(req) if err != nil { return TagRulesClientGetResponse{}, err } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return TagRulesClientGetResponse{}, runtime.NewResponseError(resp) + if !runtime.HasStatusCode(httpResp, http.StatusOK) { + err = runtime.NewResponseError(httpResp) + return TagRulesClientGetResponse{}, err } - return client.getHandleResponse(resp) + resp, err := client.getHandleResponse(httpResp) + return resp, err } // getCreateRequest creates the Get request. @@ -242,25 +265,20 @@ func (client *TagRulesClient) NewListPager(resourceGroupName string, monitorName return page.NextLink != nil && len(*page.NextLink) > 0 }, Fetcher: func(ctx context.Context, page *TagRulesClientListResponse) (TagRulesClientListResponse, error) { - var req *policy.Request - var err error - if page == nil { - req, err = client.listCreateRequest(ctx, resourceGroupName, monitorName, options) - } else { - req, err = runtime.NewRequest(ctx, http.MethodGet, *page.NextLink) + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "TagRulesClient.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, resourceGroupName, monitorName, options) + }, nil) if err != nil { return TagRulesClientListResponse{}, err } - resp, err := client.internal.Pipeline().Do(req) - if err != nil { - return TagRulesClientListResponse{}, err - } - if !runtime.HasStatusCode(resp, http.StatusOK) { - return TagRulesClientListResponse{}, runtime.NewResponseError(resp) - } return client.listHandleResponse(resp) }, + Tracer: client.internal.Tracer(), }) } diff --git a/sdk/resourcemanager/logz/armlogz/time_rfc3339.go b/sdk/resourcemanager/logz/armlogz/time_rfc3339.go index 1122702470f5..f758d5698513 100644 --- a/sdk/resourcemanager/logz/armlogz/time_rfc3339.go +++ b/sdk/resourcemanager/logz/armlogz/time_rfc3339.go @@ -3,9 +3,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -// Code generated by Microsoft (R) AutoRest Code Generator. +// Code generated by Microsoft (R) AutoRest Code Generator. DO NOT EDIT. // Changes may cause incorrect behavior and will be lost if the code is regenerated. -// DO NOT EDIT. package armlogz @@ -19,50 +18,50 @@ import ( "time" ) -const ( - utcLayoutJSON = `"2006-01-02T15:04:05.999999999"` - utcLayout = "2006-01-02T15:04:05.999999999" - rfc3339JSON = `"` + time.RFC3339Nano + `"` -) - // Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases. var tzOffsetRegex = regexp.MustCompile(`(Z|z|\+|-)(\d+:\d+)*"*$`) -type timeRFC3339 time.Time +const ( + utcDateTimeJSON = `"2006-01-02T15:04:05.999999999"` + utcDateTime = "2006-01-02T15:04:05.999999999" + dateTimeJSON = `"` + time.RFC3339Nano + `"` +) + +type dateTimeRFC3339 time.Time -func (t timeRFC3339) MarshalJSON() (json []byte, err error) { +func (t dateTimeRFC3339) MarshalJSON() ([]byte, error) { tt := time.Time(t) return tt.MarshalJSON() } -func (t timeRFC3339) MarshalText() (text []byte, err error) { +func (t dateTimeRFC3339) MarshalText() ([]byte, error) { tt := time.Time(t) return tt.MarshalText() } -func (t *timeRFC3339) UnmarshalJSON(data []byte) error { - layout := utcLayoutJSON +func (t *dateTimeRFC3339) UnmarshalJSON(data []byte) error { + layout := utcDateTimeJSON if tzOffsetRegex.Match(data) { - layout = rfc3339JSON + layout = dateTimeJSON } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) UnmarshalText(data []byte) (err error) { - layout := utcLayout +func (t *dateTimeRFC3339) UnmarshalText(data []byte) error { + layout := utcDateTime if tzOffsetRegex.Match(data) { layout = time.RFC3339Nano } return t.Parse(layout, string(data)) } -func (t *timeRFC3339) Parse(layout, value string) error { +func (t *dateTimeRFC3339) Parse(layout, value string) error { p, err := time.Parse(layout, strings.ToUpper(value)) - *t = timeRFC3339(p) + *t = dateTimeRFC3339(p) return err } -func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { +func populateDateTimeRFC3339(m map[string]any, k string, t *time.Time) { if t == nil { return } else if azcore.IsNullValue(t) { @@ -71,14 +70,14 @@ func populateTimeRFC3339(m map[string]any, k string, t *time.Time) { } else if reflect.ValueOf(t).IsNil() { return } - m[k] = (*timeRFC3339)(t) + m[k] = (*dateTimeRFC3339)(t) } -func unpopulateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { +func unpopulateDateTimeRFC3339(data json.RawMessage, fn string, t **time.Time) error { if data == nil || strings.EqualFold(string(data), "null") { return nil } - var aux timeRFC3339 + var aux dateTimeRFC3339 if err := json.Unmarshal(data, &aux); err != nil { return fmt.Errorf("struct field %s: %v", fn, err) }